From 9b57eb0df1f8cc4f6a9efbc053c7b25ea7736193 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sun, 12 Apr 2015 20:16:24 +0200 Subject: [PATCH] Moving resizing of loading screen to resize method. --- game/graphics.cc | 68 +++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/game/graphics.cc b/game/graphics.cc index 0e87e44..ab458ca 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -319,39 +319,6 @@ void Graphics::render(double time) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); loadingShader->use(); loadingShader->setUniform("time", float(time)); - float quadData[24]; - if (loadingScreenWidth/loadingScreenHeight < ((float)windowSize.x)/((float)windowSize.y)) { - float quadTemp[24] ={ - -(((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), 1.0f, 0.0f, 1.0f, - (((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), 1.0f, 1.0f, 1.0f, - (((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), -1.0f, 1.0f, 0.0f, - - (((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), -1.0f, 1.0f, 0.0f, - -(((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), -1.0f, 0.0f, 0.0f, - -(((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), 1.0f, 0.0f, 1.0f - }; - for(int i = 0; i<24; i++) { - quadData[i] = quadTemp[i]; - } - } - else { - float quadTemp[24] = { - -1.0f, ((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 0.0f, 1.0f, - 1.0f, ((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 1.0f, 1.0f, - 1.0f, -((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 1.0f, 0.0f, - - 1.0f, -((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 1.0f, 0.0f, - -1.0f, -((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 0.0f, 0.0f, - -1.0f, ((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 0.0f, 1.0f - }; - for(int i = 0; i<24; i++) { - quadData[i] = quadTemp[i]; - } - } - - fullscreen_quad_ab_loading->setDataElements(6, quadData); - fullscreen_quad_loading = SharedVertexArrayObject(new VertexArrayObject); - fullscreen_quad_loading->attachAllAttributes(fullscreen_quad_ab_loading); fullscreen_quad_loading->render(); } else { @@ -672,6 +639,41 @@ void Graphics::resize(glm::uvec2 windowSize) { flamePostShader->setUniform("windowSizeY", int(windowSize.y)); bindTextureUnits(); } + else { + float quadData[24]; + if (loadingScreenWidth/loadingScreenHeight < ((float)windowSize.x)/((float)windowSize.y)) { + float quadTemp[24] ={ + -(((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), 1.0f, 0.0f, 1.0f, + (((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), 1.0f, 1.0f, 1.0f, + (((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), -1.0f, 1.0f, 0.0f, + + (((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), -1.0f, 1.0f, 0.0f, + -(((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), -1.0f, 0.0f, 0.0f, + -(((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), 1.0f, 0.0f, 1.0f + }; + for(int i = 0; i<24; i++) { + quadData[i] = quadTemp[i]; + } + } + else { + float quadTemp[24] = { + -1.0f, ((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 0.0f, 1.0f, + 1.0f, ((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 1.0f, 1.0f, + 1.0f, -((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 1.0f, 0.0f, + + 1.0f, -((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 1.0f, 0.0f, + -1.0f, -((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 0.0f, 0.0f, + -1.0f, ((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 0.0f, 1.0f + }; + for(int i = 0; i<24; i++) { + quadData[i] = quadTemp[i]; + } + } + + fullscreen_quad_ab_loading->setDataElements(6, quadData); + fullscreen_quad_loading = SharedVertexArrayObject(new VertexArrayObject); + fullscreen_quad_loading->attachAllAttributes(fullscreen_quad_ab_loading); + } } glm::mat4 Graphics::buildViewMatrix(Level* level) {