From e531ede14405b470fc2a50192e2c0dff3377fa0a Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 15 Dec 2014 01:05:46 +0100 Subject: [PATCH] Init graphics with the level instead of passing it to the render function everytime. --- application.cc | 4 ++-- graphics.cc | 7 +++++-- graphics.hh | 5 +++-- main.cc | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/application.cc b/application.cc index e2c375e..6019fdb 100644 --- a/application.cc +++ b/application.cc @@ -21,11 +21,11 @@ void Application::init() ACGL::Base::Settings::the()->setTexturePath("Levels/Textures/"); ACGL::Base::Settings::the()->setGeometryPath("Levels/Geometry/"); - graphics.init(); - // load Level level.load(); + graphics.init(&level); + // just in case: check for errors openGLCriticalError(); } diff --git a/graphics.cc b/graphics.cc index ce4b94e..4e7534d 100644 --- a/graphics.cc +++ b/graphics.cc @@ -16,7 +16,10 @@ Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane) { Graphics::Graphics() { } -void Graphics::init() { +void Graphics::init(Level* level) { + // save Level + this->level = level; + // construct VAO to give shader correct Attribute locations SharedArrayBuffer ab = SharedArrayBuffer(new ArrayBuffer()); ab->defineAttribute("aPosition", GL_FLOAT, 3); @@ -74,7 +77,7 @@ glm::uvec2 Graphics::getWindowSize() { return windowSize; } -void Graphics::render(Level* level) +void Graphics::render() { // render depth texture for sun // near pass diff --git a/graphics.hh b/graphics.hh index a807d11..c4432a9 100644 --- a/graphics.hh +++ b/graphics.hh @@ -12,8 +12,8 @@ class Graphics { public: Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane); Graphics(); - void init(); - void render(Level* level); + void init(Level* level); + void render(); // to build the projection matrix: glm::mat4 buildFrustum( float phiInDegree, float near, float far, float aspectRatio); glm::mat4 buildViewMatrix(Level* level); @@ -36,6 +36,7 @@ class Graphics { ACGL::OpenGL::SharedFrameBufferObject framebuffer_middle; ACGL::OpenGL::SharedTexture2D depthTexture_far; ACGL::OpenGL::SharedFrameBufferObject framebuffer_far; + Level* level; }; #endif diff --git a/main.cc b/main.cc index b21edfa..717c0ea 100644 --- a/main.cc +++ b/main.cc @@ -77,6 +77,7 @@ int main( int argc, char *argv[] ) glEnable( GL_DEPTH_TEST ); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); app.init(); int frameCount = 0; @@ -123,7 +124,7 @@ int main( int argc, char *argv[] ) } lastUpdate = now; - app.getGraphics()->render(app.getLevel()); + app.getGraphics()->render(); openGLCriticalError();