Fixed loading screen resizing.

This commit is contained in:
Steffen Fündgens 2015-03-09 13:41:34 +01:00
parent 371cccb273
commit bfd8b25a7d
2 changed files with 51 additions and 16 deletions

View File

@ -196,23 +196,23 @@ void Graphics::renderLoadingScreen() {
loadingScreen->generateMipmaps();
loadingContinueScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenContinuePath));
loadingContinueScreen->generateMipmaps();
int loadingScreenWidth = loadingScreen->getWidth();
int loadingScreenHeight = loadingScreen->getHeight();
loadingScreenWidth = (float)loadingScreen->getWidth();
loadingScreenHeight = (float)loadingScreen->getHeight();
fullscreen_quad_ab_loading = SharedArrayBuffer(new ArrayBuffer());
fullscreen_quad_ab_loading->defineAttribute("aPosition", GL_FLOAT, 2);
fullscreen_quad_ab_loading->defineAttribute("aTexCoord", GL_FLOAT, 2);
float quadData[24];
if (loadingScreenWidth/loadingScreenHeight < (int)windowSize.x/(int)windowSize.y) {
if (loadingScreenWidth/loadingScreenHeight < ((float)windowSize.x)/((float)windowSize.y)) {
float quadTemp[24] ={
-1.0f + ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), 1.0f, 0.0f, 1.0f,
1.0f - ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), 1.0f, 1.0f, 1.0f,
1.0f - ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), -1.0f, 1.0f, 0.0f,
-(((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,
1.0f - ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), -1.0f, 1.0f, 0.0f,
-1.0f + ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), -1.0f, 0.0f, 0.0f,
-1.0f + ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), 1.0f, 0.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, 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];
@ -220,13 +220,13 @@ void Graphics::renderLoadingScreen() {
}
else {
float quadTemp[24] = {
-1.0f, 1.0f - (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 0.0f, 1.0f,
1.0f, 1.0f - (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 1.0f, 1.0f,
1.0f, -1.0f + (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 1.0f, 0.0f,
-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, -1.0f + (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 1.0f, 0.0f,
-1.0f, -1.0f + (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 0.0f, 0.0f,
-1.0f, 1.0f - (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 0.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), 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];
@ -257,6 +257,39 @@ 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 {
@ -334,7 +367,7 @@ void Graphics::render(double time)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//wind
glm::vec2 wind = glm::vec2(-0.3f, 0.0f);
glm::vec2 wind = glm::vec2(-0.4f, 0.3f);
//set view and projection matrix
glm::mat4 lightingViewProjectionMatrix = glm::perspective(1.571f, (float)windowSize.x/(float)windowSize.y, 0.1f, farPlane) * buildViewMatrix(level);

View File

@ -63,6 +63,8 @@ class Graphics {
Level* level;
int number_of_texture_units = 0;
bool gameStart;
float loadingScreenWidth;
float loadingScreenHeight;
};
#endif