@@ -46,6 +46,7 @@ void _GLGetError(const char* file, int line, const char* call) {
4646#include " floating_camera.h"
4747#include " mesh.h"
4848#include " font.h"
49+ #include " framebuffer.h"
4950
5051void openGLDebugCallback (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void * userParam) {
5152 std::cout << " [OpenGL Error] " << message << std::endl;
@@ -159,6 +160,11 @@ int main(int argc, char** argv) {
159160 GLCALL (glEnable (GL_CULL_FACE));
160161 GLCALL (glEnable (GL_DEPTH_TEST));
161162
163+ Framebuffer framebuffer;
164+ int w, h;
165+ SDL_GetWindowSize (window, &w, &h);
166+ framebuffer.create (w, h);
167+
162168 while (!close) {
163169 SDL_Event event;
164170 while (SDL_PollEvent (&event)) {
@@ -240,6 +246,8 @@ int main(int argc, char** argv) {
240246 }
241247
242248 camera.update ();
249+
250+ framebuffer.bind ();
243251 shader.bind ();
244252 model = glm::rotate (model, 1 .0f *delta, glm::vec3 (0 , 1 , 0 ));
245253 modelViewProj = camera.getViewProj () * model;
@@ -259,6 +267,7 @@ int main(int argc, char** argv) {
259267 GLCALL (glUniformMatrix4fv (invModelViewLocation, 1 , GL_FALSE, &invModelView[0 ][0 ]));
260268 monkey.render ();
261269 shader.unbind ();
270+ framebuffer.unbind ();
262271
263272 fontShader.bind ();
264273
@@ -289,5 +298,7 @@ int main(int argc, char** argv) {
289298 lastCounter = endCounter;
290299 }
291300
301+ framebuffer.destroy ();
302+
292303 return 0 ;
293304}
0 commit comments