|
|
@@ -14,6 +14,9 @@
|
|
|
|
|
|
#include "game/graphics/material.hpp"
|
|
|
#include "game/graphics/vertex.h"
|
|
|
+#include "game/util/env.hpp"
|
|
|
+#include "game/util/time.hpp"
|
|
|
+#include "matrix.hpp"
|
|
|
#include "matrix/matrix.hpp"
|
|
|
#include "matrix/matrix_helpers.hpp"
|
|
|
|
|
|
@@ -51,19 +54,25 @@ opengl_renderer::~opengl_renderer() {
|
|
|
void opengl_renderer::clear() {
|
|
|
world_to_clip = identity;
|
|
|
|
|
|
- // vec2i resolution = env::resolution();
|
|
|
- // orthogonal_view(0.0, resolution[0], 0.0, resolution[1], -1.0, 1.0);
|
|
|
+ // math::vec2i resolution = env::resolution();
|
|
|
+ math::vec2i resolution = env::screen_size();
|
|
|
+ world_to_clip = graphics::orthogonal_view(0.f, resolution[0], 0.f,
|
|
|
+ resolution[1], -1.f, 1.f);
|
|
|
|
|
|
glClearDepth(1.f);
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
glClearColor(0.f, 0.f, 0.0f, 1.f);
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
|
- // TODO: Use a unified time calculation
|
|
|
- current_time = time(NULL);
|
|
|
+ // TODO (sjaffe): Refactor this out...
|
|
|
+ current_time =
|
|
|
+ std::chrono::duration<double>(engine::clock::now().time_since_epoch())
|
|
|
+ .count();
|
|
|
|
|
|
- // TODO: ???
|
|
|
- // scale(0.5, 0.5, 1); // Don't know why I need to do this
|
|
|
+ // TODO (sjaffe): I labeled this as needed before, but I don't know why
|
|
|
+ // I think it has to do with the resolution being 2x the screen size
|
|
|
+ // static auto const rescale = make_vector(0.5f, 0.5f, 1.f);
|
|
|
+ // world_to_clip = world_to_clip * math::matrix::scalar(rescale);
|
|
|
}
|
|
|
|
|
|
void opengl_renderer::flush() { glFlush(); }
|
|
|
@@ -78,10 +87,11 @@ void opengl_renderer::draw(flyweight<material> material,
|
|
|
mat.activate();
|
|
|
|
|
|
int objectLocation = glGetUniformLocation(id, "u_objectToWorldMatrix");
|
|
|
- glUniformMatrix4fv(objectLocation, 1, false, &object_to_world(0, 0));
|
|
|
+ // Argument 2: GL_TRUE -> row-major ; GL_FALSE -> column-major
|
|
|
+ glUniformMatrix4fv(objectLocation, 1, GL_TRUE, &object_to_world(0, 0));
|
|
|
|
|
|
int clipLocation = glGetUniformLocation(id, "u_worldToClipMatrix");
|
|
|
- glUniformMatrix4fv(clipLocation, 1, false, &world_to_clip(0, 0));
|
|
|
+ glUniformMatrix4fv(clipLocation, 1, GL_TRUE, &world_to_clip(0, 0));
|
|
|
|
|
|
int timeLocation = glGetUniformLocation(id, "u_time");
|
|
|
glUniform1d(timeLocation, current_time);
|