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()->setGeometryPath("Levels/Geometry/");
|
||||
|
||||
graphics.init();
|
||||
|
||||
// load Level
|
||||
level.load();
|
||||
|
||||
graphics.init(&level);
|
||||
|
||||
// just in case: check for errors
|
||||
openGLCriticalError();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
3
main.cc
3
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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user