Init graphics with the level instead of passing it to the render function everytime.
This commit is contained in:
parent
5b2233e1b3
commit
e531ede144
@ -21,11 +21,11 @@ void Application::init()
|
|||||||
ACGL::Base::Settings::the()->setTexturePath("Levels/Textures/");
|
ACGL::Base::Settings::the()->setTexturePath("Levels/Textures/");
|
||||||
ACGL::Base::Settings::the()->setGeometryPath("Levels/Geometry/");
|
ACGL::Base::Settings::the()->setGeometryPath("Levels/Geometry/");
|
||||||
|
|
||||||
graphics.init();
|
|
||||||
|
|
||||||
// load Level
|
// load Level
|
||||||
level.load();
|
level.load();
|
||||||
|
|
||||||
|
graphics.init(&level);
|
||||||
|
|
||||||
// just in case: check for errors
|
// just in case: check for errors
|
||||||
openGLCriticalError();
|
openGLCriticalError();
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,10 @@ Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane) {
|
|||||||
Graphics::Graphics() {
|
Graphics::Graphics() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::init() {
|
void Graphics::init(Level* level) {
|
||||||
|
// save Level
|
||||||
|
this->level = level;
|
||||||
|
|
||||||
// construct VAO to give shader correct Attribute locations
|
// construct VAO to give shader correct Attribute locations
|
||||||
SharedArrayBuffer ab = SharedArrayBuffer(new ArrayBuffer());
|
SharedArrayBuffer ab = SharedArrayBuffer(new ArrayBuffer());
|
||||||
ab->defineAttribute("aPosition", GL_FLOAT, 3);
|
ab->defineAttribute("aPosition", GL_FLOAT, 3);
|
||||||
@ -74,7 +77,7 @@ glm::uvec2 Graphics::getWindowSize() {
|
|||||||
return windowSize;
|
return windowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::render(Level* level)
|
void Graphics::render()
|
||||||
{
|
{
|
||||||
// render depth texture for sun
|
// render depth texture for sun
|
||||||
// near pass
|
// near pass
|
||||||
|
@ -12,8 +12,8 @@ class Graphics {
|
|||||||
public:
|
public:
|
||||||
Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane);
|
Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane);
|
||||||
Graphics();
|
Graphics();
|
||||||
void init();
|
void init(Level* level);
|
||||||
void render(Level* level);
|
void render();
|
||||||
// to build the projection matrix:
|
// to build the projection matrix:
|
||||||
glm::mat4 buildFrustum( float phiInDegree, float near, float far, float aspectRatio);
|
glm::mat4 buildFrustum( float phiInDegree, float near, float far, float aspectRatio);
|
||||||
glm::mat4 buildViewMatrix(Level* level);
|
glm::mat4 buildViewMatrix(Level* level);
|
||||||
@ -36,6 +36,7 @@ class Graphics {
|
|||||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer_middle;
|
ACGL::OpenGL::SharedFrameBufferObject framebuffer_middle;
|
||||||
ACGL::OpenGL::SharedTexture2D depthTexture_far;
|
ACGL::OpenGL::SharedTexture2D depthTexture_far;
|
||||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer_far;
|
ACGL::OpenGL::SharedFrameBufferObject framebuffer_far;
|
||||||
|
Level* level;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
3
main.cc
3
main.cc
@ -77,6 +77,7 @@ int main( int argc, char *argv[] )
|
|||||||
glEnable( GL_DEPTH_TEST );
|
glEnable( GL_DEPTH_TEST );
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||||
app.init();
|
app.init();
|
||||||
|
|
||||||
int frameCount = 0;
|
int frameCount = 0;
|
||||||
@ -123,7 +124,7 @@ int main( int argc, char *argv[] )
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastUpdate = now;
|
lastUpdate = now;
|
||||||
app.getGraphics()->render(app.getLevel());
|
app.getGraphics()->render();
|
||||||
|
|
||||||
openGLCriticalError();
|
openGLCriticalError();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user