render vertex points and fundamental region

This commit is contained in:
2019-09-14 01:49:01 -04:00
parent 67c03a67da
commit fb1a22898b
7 changed files with 36 additions and 18 deletions

View File

@@ -7,14 +7,16 @@ target_link_libraries(${PROJECT_NAME}
PRIVATE glad glm glfw)
add_custom_command(
TARGET cosets POST_BUILD
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/src/shaders
${CMAKE_CURRENT_BINARY_DIR}/shaders
)
add_executable(coxeter src/coxeter.cpp)
add_executable(mirror src/mirrors.cpp)
target_link_libraries(mirror PRIVATE glm)
add_executable(mesh src/mesh.cpp)
target_link_libraries(mesh PRIVATE glm)

View File

@@ -33,10 +33,10 @@ public:
program = build_program("main", vs, fs);
verts_data = vertices<3>({}, Multiplicites<3>({
{0, 1, 4},
{0, 1, 5},
{1, 2, 3}
}), {
2.0f, .05f, 0.05f
10, 1, 1
});
glGenBuffers(1, &verts);
@@ -58,25 +58,32 @@ public:
glViewport(0, 0, w, h);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
const glm::mat4 id = glm::mat4(1);
const glm::vec3 ax = glm::vec3(0, 0, 1);
double t = glfwGetTime();
float angle = (float) t;
const auto id = glm::mat4(1);
const auto ax_1 = glm::vec3(0, 0, 1);
const auto ax_2 = glm::vec3(.5, 1, 0.2);
const auto t = glfwGetTime();
const auto angle = (float) t / 2;
float ar = (float) w / (float) h;
const float sc = 1.5f;
const float ar = (float) w / (float) h;
const glm::mat4 proj = glm::ortho(-ar, ar, -1.f, 1.f, -1.f, 1.f);
const glm::mat4 view = glm::rotate(id, angle, ax);
const glm::mat4 proj = glm::ortho(-ar * sc, ar * sc, -sc, sc, -10.f, 10.f);
const glm::mat4 view = glm::rotate(id, angle, ax_1) * glm::rotate(id, angle, ax_2);
const glm::mat4 mat = proj * view;
glUseProgram(program);
glUniformMatrix4fv(0, 1, false, glm::value_ptr(mat));
glUniformMatrix4fv(1, 1, false, glm::value_ptr(mat));
glEnable(GL_DEPTH_TEST);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPointSize(10.f);
glBindVertexArray(tri);
glDrawArrays(GL_POINTS, 0, verts_data.size());
glUniform4f(0, 1, 1, 1, 1);
glDrawArrays(GL_POINTS, 0, verts_data.size() - 3);
glUniform4f(0, 1, 1, 1, .1);
glDrawArrays(GL_TRIANGLES, verts_data.size() - 3, 3);
swapbuffers();
}

View File

@@ -1,7 +1,11 @@
#version 400
#version 440 core
uniform vec4 color;
in vec4 v;
out vec4 fcolor;
vec3 hsv2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
@@ -9,5 +13,5 @@ vec3 hsv2rgb(vec3 c) {
}
void main(){
gl_FragColor = vec4(hsv2rgb(vec3(v.w, 1, 1)), 0);
fcolor = color;
}

View File

@@ -1,4 +1,4 @@
#version 400
#version 440 core
uniform mat4 proj;

View File

@@ -46,7 +46,7 @@ vertices(const std::vector<int> &subgens, const Multiplicites<N> &mults, const f
const std::vector<float> coords_vec(coords, coords + N);
const glm::vec4 &identity = glm::normalize(barycentric(corners, coords_vec));
std::vector<glm::vec4> verts(table->size());
std::vector<glm::vec4> verts{};
for (const auto &word : table->words()) {
glm::vec4 vert = identity;
@@ -56,5 +56,9 @@ vertices(const std::vector<int> &subgens, const Multiplicites<N> &mults, const f
verts.push_back(vert);
}
for (const auto &e : corners) {
verts.push_back(e * 1.1f);
}
return verts;
}

View File

@@ -43,7 +43,7 @@ glm::vec4 barycentric(std::vector<glm::vec4> basis, std::vector<float> coords) {
for (int i = 0; i < N; ++i) {
res += basis[i] * coords[i];
}
return res;
return glm::normalize(res);
}
std::vector<glm::vec4> plane_intersections(std::vector<glm::vec4> normals) {
@@ -51,8 +51,8 @@ std::vector<glm::vec4> plane_intersections(std::vector<glm::vec4> normals) {
std::vector<glm::vec4> results(N);
for (int i = 0; i < N; ++i) {
results[i] = glm::normalize(gram_schmidt_last(normals));
std::rotate(normals.begin(), normals.begin() + 1, normals.end());
results[i] = gram_schmidt_last(normals);
}
return results;

View File

@@ -31,6 +31,7 @@ public:
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, _gl_major);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, _gl_minor);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_ALPHA_BITS, 8);
_window = glfwCreateWindow(640, 480, "GLFW App", nullptr, nullptr);