mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
remove test
This commit is contained in:
@@ -12,8 +12,3 @@ add_executable(vis src/main.cpp)
|
|||||||
target_include_directories(vis PRIVATE include)
|
target_include_directories(vis PRIVATE include)
|
||||||
target_link_libraries(vis PRIVATE tc glad glm glfw)
|
target_link_libraries(vis PRIVATE tc glad glm glfw)
|
||||||
add_dependencies(vis shaders)
|
add_dependencies(vis shaders)
|
||||||
|
|
||||||
add_executable(test src/test.cpp)
|
|
||||||
target_include_directories(test PRIVATE include)
|
|
||||||
target_link_libraries(test PRIVATE tc glad glm glfw)
|
|
||||||
add_dependencies(test shaders)
|
|
||||||
|
|||||||
@@ -30,21 +30,17 @@ struct Matrices {
|
|||||||
|
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
struct MeshRef {
|
struct MeshRef {
|
||||||
GLuint vao;
|
cgl::vertexarray vao;
|
||||||
GLuint ibo;
|
cgl::buffer<Primitive<N>> ibo;
|
||||||
|
|
||||||
unsigned primitive_count;
|
unsigned primitive_count;
|
||||||
unsigned index_count;
|
unsigned index_count;
|
||||||
|
|
||||||
explicit MeshRef(const Mesh<N> &mesh) {
|
explicit MeshRef(const Mesh<N> &mesh) : vao(), ibo() {
|
||||||
vao = utilCreateVertexArray();
|
|
||||||
ibo = utilCreateBuffer();
|
|
||||||
primitive_count = mesh.size();
|
primitive_count = mesh.size();
|
||||||
index_count = primitive_count * N;
|
index_count = primitive_count * N;
|
||||||
|
|
||||||
glBindVertexArray(vao);
|
ibo.put(mesh.prims);;
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, ibo);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(Primitive<N>) * primitive_count, &mesh.prims[0], GL_STATIC_DRAW);
|
|
||||||
glBindVertexArray(0);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -145,17 +141,16 @@ void run(GLFWwindow *window) {
|
|||||||
glLineWidth(1.5);
|
glLineWidth(1.5);
|
||||||
const auto wires_dark = glm::vec3(.3, .3, .3);
|
const auto wires_dark = glm::vec3(.3, .3, .3);
|
||||||
const auto wires_light = wires_dark;
|
const auto wires_light = wires_dark;
|
||||||
glBindProgramPipeline(proj_pipe);
|
|
||||||
for (auto ref : wires) {
|
|
||||||
glProgramUniform3f(solid, 2, 1, 1, 1);
|
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ref.ibo);
|
proj_pipe.bound([&]() {
|
||||||
glDrawElements(WIRE_MODE, ref.index_count, GL_UNSIGNED_INT, nullptr);
|
for (const auto &ref : wires) {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glProgramUniform3f(solid, 2, 1, 1, 1);
|
||||||
}
|
|
||||||
|
|
||||||
glBindProgramPipeline(0);
|
ref.ibo.bound(GL_ELEMENT_ARRAY_BUFFER, [&]() {
|
||||||
glBindVertexArray(0);
|
glDrawElements(WIRE_MODE, ref.index_count, GL_UNSIGNED_INT, nullptr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
|
||||||
|
|||||||
107
vis/src/test.cpp
107
vis/src/test.cpp
@@ -1,107 +0,0 @@
|
|||||||
#include <glad/glad.h>
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <cmath>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
|
||||||
|
|
||||||
#include <tc/groups.hpp>
|
|
||||||
|
|
||||||
#include "util.hpp"
|
|
||||||
#include "mirror.hpp"
|
|
||||||
#include "geometry.hpp"
|
|
||||||
|
|
||||||
#include <cgl/render.hpp>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
extern "C" {
|
|
||||||
__attribute__((unused)) __declspec(dllexport) int NvOptimusEnablement = 0x00000001;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct globals {
|
|
||||||
glm::mat4 proj = glm::identity<glm::mat4>();
|
|
||||||
float time = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
void run(GLFWwindow *window) {
|
|
||||||
auto direct = cgl::pgm::vert::file("shaders/test/direct.glsl");
|
|
||||||
auto white = cgl::pgm::frag::file("shaders/test/white.glsl");
|
|
||||||
|
|
||||||
auto pipe = cgl::pipeline();
|
|
||||||
pipe.stage(direct).stage(white);
|
|
||||||
|
|
||||||
auto vbo = cgl::buffer<float>({
|
|
||||||
-0.5, +0.866, 0, 1,
|
|
||||||
-0.5, -0.866, 0, 1,
|
|
||||||
+1.0, +0.000, 0, 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
auto global_ubo = cgl::buffer<globals>();
|
|
||||||
glBindBufferBase(GL_UNIFORM_BUFFER, 0, global_ubo);
|
|
||||||
|
|
||||||
auto vao = cgl::vertexarray();
|
|
||||||
vao.bound([&]() {
|
|
||||||
vbo.bound(GL_ARRAY_BUFFER, [&]() {
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window)) {
|
|
||||||
int width, height;
|
|
||||||
glfwGetFramebufferSize(window, &width, &height);
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
auto aspect = (float) width / (float) height;
|
|
||||||
globals data;
|
|
||||||
data.time = (float) glfwGetTime();
|
|
||||||
data.proj = glm::ortho(-aspect, aspect, -1.0f, 1.0f);
|
|
||||||
global_ubo.put(data);
|
|
||||||
|
|
||||||
pipe.bound([&]() {
|
|
||||||
vao.bound([&]() {
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
|
|
||||||
glfwPollEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
//region init window
|
|
||||||
if (!glfwInit()) {
|
|
||||||
std::cerr << "Failed to initialize GLFW" << std::endl;
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto window = glfwCreateWindow(
|
|
||||||
1920, 1080,
|
|
||||||
"Coset Visualization",
|
|
||||||
nullptr, nullptr);
|
|
||||||
|
|
||||||
if (!window) {
|
|
||||||
std::cerr << "Failed to create window" << std::endl;
|
|
||||||
glfwTerminate();
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
|
||||||
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
|
||||||
glfwSwapInterval(1);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
std::cout << utilInfo();
|
|
||||||
|
|
||||||
run(window);
|
|
||||||
|
|
||||||
glfwTerminate();
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user