|
|
|
@ -9,7 +9,7 @@
|
|
|
|
|
|
|
|
|
|
#include <glad/glad.h>
|
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
|
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
|
#include "common/logging.hpp"
|
|
|
|
|
#include "common/messaging/bus.hpp"
|
|
|
|
|
|
|
|
|
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
|
|
|
|
|
|
|
|
|
int height = 0, width = 0;
|
|
|
|
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
|
|
|
|
|
|
|
|
|
float fov = 45.0;
|
|
|
|
|
// Triangle example
|
|
|
|
|
// @see http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/
|
|
|
|
|
GLuint VertexArrayID;
|
|
|
|
@ -109,6 +109,11 @@ int main(int argc, char** argv)
|
|
|
|
|
static std::vector<RegisteredShaderProgram> shader_program_registry;
|
|
|
|
|
loadShaderProgramsFromFile("shaders/shader_programs.txt", &shader_registry, &shader_program_registry);
|
|
|
|
|
messager.registerCallback(&debug_messagebus_callback);
|
|
|
|
|
int window_height, window_width;
|
|
|
|
|
glm::mat4 projection;
|
|
|
|
|
glm::mat4 view = glm::lookAt(glm::vec3(4,3,3), glm::vec3(0,0,0), glm::vec3(0,1,0));
|
|
|
|
|
glm::mat4 model_default = glm::mat4(1.0f);
|
|
|
|
|
glm::mat4 mvp_matrix;
|
|
|
|
|
while(!glfwWindowShouldClose(window)) {
|
|
|
|
|
glfwPollEvents();
|
|
|
|
|
// Process input.
|
|
|
|
@ -127,11 +132,17 @@ int main(int argc, char** argv)
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
|
|
// Render game geometries
|
|
|
|
|
glfwGetWindowSize(window, &window_width, &window_height);
|
|
|
|
|
// 45d FoV
|
|
|
|
|
projection = glm::perspective(glm::radians(fov), (float) window_width / (float) window_height,
|
|
|
|
|
0.1f, 100.0f);
|
|
|
|
|
mvp_matrix = projection * view * model_default;
|
|
|
|
|
// @see https://blog.conan.io/2019/06/26/An-introduction-to-the-Dear-ImGui-library.html
|
|
|
|
|
// 1st attribute buffer : vertices
|
|
|
|
|
GLuint p = find_shader_program_by_name("default", &shader_program_registry);
|
|
|
|
|
printf("Using program %d\n", p);
|
|
|
|
|
glUseProgram(p);
|
|
|
|
|
GLuint matrix_id = glGetUniformLocation(p, "MVP");
|
|
|
|
|
glUniformMatrix4fv(matrix_id, 1, GL_FALSE, &mvp_matrix[0][0]);
|
|
|
|
|
glEnableVertexAttribArray(0);
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
|
|
|
|
|
glVertexAttribPointer(
|
|
|
|
@ -152,12 +163,11 @@ int main(int argc, char** argv)
|
|
|
|
|
ImGui_ImplGlfw_NewFrame();
|
|
|
|
|
ImGui::NewFrame();
|
|
|
|
|
{
|
|
|
|
|
static float f = 0.0f;
|
|
|
|
|
static int counter = 0;
|
|
|
|
|
|
|
|
|
|
ImGui::Begin("Misc"); // Create a window called "Hello, world!" and append into it.
|
|
|
|
|
|
|
|
|
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
|
|
|
|
ImGui::SliderFloat("Field of View (FOV)", &fov, 45.0f, 180.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
|
|
|
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
|
|
|
|
|
|
|
|
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
|
|
|
|