Further separate the render logic and the scene logic
With some cleanup
This commit is contained in:
parent
74ffe23551
commit
383d5d3f62
|
@ -32,7 +32,9 @@ void runProgram(GLFWwindow* window, CommandLineOptions options)
|
|||
glClearColor(0.3f, 0.5f, 0.8f, 1.0f);
|
||||
|
||||
initRenderer(window, options);
|
||||
|
||||
init_scene(options);
|
||||
getTimeDeltaSeconds();
|
||||
|
||||
// Rendering Loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
|
@ -41,7 +43,9 @@ void runProgram(GLFWwindow* window, CommandLineOptions options)
|
|||
|
||||
int w, h;
|
||||
glfwGetWindowSize(window, &w, &h);
|
||||
|
||||
|
||||
step_scene(getTimeDeltaSeconds());
|
||||
|
||||
updateFrame(window, w, h);
|
||||
renderFrame(window, w, h);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <GLFW/glfw3.h>
|
||||
#include <SFML/Audio/Sound.hpp>
|
||||
#include <SFML/Audio/SoundBuffer.hpp>
|
||||
#include <chrono>
|
||||
#include <glad/glad.h>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
@ -13,7 +12,6 @@
|
|||
#include <algorithm>
|
||||
#include <utilities/glfont.h>
|
||||
#include <utilities/shader.hpp>
|
||||
#include <utilities/timeutils.h>
|
||||
|
||||
using glm::vec3;
|
||||
using glm::vec4;
|
||||
|
@ -51,11 +49,6 @@ void initRenderer(GLFWwindow* window, CommandLineOptions options) {
|
|||
}
|
||||
|
||||
glfwSetCursorPosCallback(window, mouse_callback);
|
||||
|
||||
init_scene(options);
|
||||
|
||||
// init
|
||||
getTimeDeltaSeconds();
|
||||
}
|
||||
|
||||
// traverses and updates matricies
|
||||
|
@ -81,11 +74,7 @@ void updateNodeTransformations(SceneNode* node, mat4 transformationThusFar, mat4
|
|||
|
||||
// step
|
||||
void updateFrame(GLFWwindow* window, int windowWidth, int windowHeight) {
|
||||
double timeDelta = getTimeDeltaSeconds();
|
||||
float aspect = float(windowWidth) / float(windowHeight);
|
||||
|
||||
// main action:
|
||||
step_scene(timeDelta);
|
||||
|
||||
// calculate camera
|
||||
mat4 projection = glm::perspective(
|
||||
|
@ -185,7 +174,9 @@ void renderNode(SceneNode* node, Gloom::Shader* parent_shader, vector<NodeDistSh
|
|||
}
|
||||
else if(node->vertexArrayObjectID != -1) {
|
||||
// load uniforms
|
||||
um4fv(MVP); um4fv(MV); um4fv(MVnormal);
|
||||
um4fv(MVP);
|
||||
um4fv(MV);
|
||||
um4fv(MVnormal);
|
||||
u2fv (uvOffset);
|
||||
u3fv (diffuse_color);
|
||||
u3fv (emissive_color);
|
||||
|
@ -263,7 +254,7 @@ void renderFrame(GLFWwindow* window, int windowWidth, int windowHeight) {
|
|||
//glDisable(GL_DEPTH_TEST);
|
||||
for (NodeDistShader a : transparent_nodes)
|
||||
renderNode(a.node, a.s, nullptr, false);
|
||||
std::cout << transparent_nodes.size() << std::endl;
|
||||
//std::cout << transparent_nodes.size() << std::endl;
|
||||
glDepthMask(GL_TRUE); // read write
|
||||
//glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ PNGImage t_cobble_normal = loadPNGFile("../res/textures/cobble_normal.png");
|
|||
PNGImage t_plain_diff = loadPNGFile("../res/textures/plain_diff.png");
|
||||
PNGImage t_plain_normal = loadPNGFile("../res/textures/plain_normal.png", true);
|
||||
PNGImage t_reflection = loadPNGFile("../res/textures/reflection_field.png");
|
||||
PNGImage t_reflection2 = loadPNGFile("../res/textures/reflection_blurry.png");
|
||||
PNGImage t_perlin = makePerlinNoisePNG(256, 256, 0.05/16);
|
||||
|
||||
void init_scene(CommandLineOptions options) {
|
||||
|
|
Loading…
Reference in New Issue