Fixed loading screen resizing.
This commit is contained in:
parent
371cccb273
commit
bfd8b25a7d
65
graphics.cc
65
graphics.cc
@ -196,23 +196,23 @@ void Graphics::renderLoadingScreen() {
|
|||||||
loadingScreen->generateMipmaps();
|
loadingScreen->generateMipmaps();
|
||||||
loadingContinueScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenContinuePath));
|
loadingContinueScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenContinuePath));
|
||||||
loadingContinueScreen->generateMipmaps();
|
loadingContinueScreen->generateMipmaps();
|
||||||
int loadingScreenWidth = loadingScreen->getWidth();
|
loadingScreenWidth = (float)loadingScreen->getWidth();
|
||||||
int loadingScreenHeight = loadingScreen->getHeight();
|
loadingScreenHeight = (float)loadingScreen->getHeight();
|
||||||
|
|
||||||
fullscreen_quad_ab_loading = SharedArrayBuffer(new ArrayBuffer());
|
fullscreen_quad_ab_loading = SharedArrayBuffer(new ArrayBuffer());
|
||||||
fullscreen_quad_ab_loading->defineAttribute("aPosition", GL_FLOAT, 2);
|
fullscreen_quad_ab_loading->defineAttribute("aPosition", GL_FLOAT, 2);
|
||||||
fullscreen_quad_ab_loading->defineAttribute("aTexCoord", GL_FLOAT, 2);
|
fullscreen_quad_ab_loading->defineAttribute("aTexCoord", GL_FLOAT, 2);
|
||||||
|
|
||||||
float quadData[24];
|
float quadData[24];
|
||||||
if (loadingScreenWidth/loadingScreenHeight < (int)windowSize.x/(int)windowSize.y) {
|
if (loadingScreenWidth/loadingScreenHeight < ((float)windowSize.x)/((float)windowSize.y)) {
|
||||||
float quadTemp[24] ={
|
float quadTemp[24] ={
|
||||||
-1.0f + ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), 1.0f, 0.0f, 1.0f,
|
-(((float)windowSize.y*loadingScreenWidth)/((float)windowSize.x*loadingScreenHeight)), 1.0f, 0.0f, 1.0f,
|
||||||
1.0f - ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), 1.0f, 1.0f, 1.0f,
|
(((float)windowSize.y*loadingScreenWidth)/((float)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, 1.0f, 0.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, 1.0f, 0.0f,
|
||||||
-1.0f + ((windowSize.y*loadingScreenWidth)/(windowSize.x*loadingScreenHeight)), -1.0f, 0.0f, 0.0f,
|
-(((float)windowSize.y*loadingScreenWidth)/((float)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, 0.0f, 1.0f
|
||||||
};
|
};
|
||||||
for(int i = 0; i<24; i++) {
|
for(int i = 0; i<24; i++) {
|
||||||
quadData[i] = quadTemp[i];
|
quadData[i] = quadTemp[i];
|
||||||
@ -220,13 +220,13 @@ void Graphics::renderLoadingScreen() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float quadTemp[24] = {
|
float quadTemp[24] = {
|
||||||
-1.0f, 1.0f - (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 0.0f, 1.0f,
|
-1.0f, ((float)windowSize.x*loadingScreenHeight)/((float)windowSize.y*loadingScreenWidth), 0.0f, 1.0f,
|
||||||
1.0f, 1.0f - (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 1.0f, 1.0f,
|
1.0f, ((float)windowSize.x*loadingScreenHeight)/((float)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), 1.0f, 0.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), 1.0f, 0.0f,
|
||||||
-1.0f, -1.0f + (windowSize.x*loadingScreenHeight)/(windowSize.y*loadingScreenWidth), 0.0f, 0.0f,
|
-1.0f, -((float)windowSize.x*loadingScreenHeight)/((float)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), 0.0f, 1.0f
|
||||||
};
|
};
|
||||||
for(int i = 0; i<24; i++) {
|
for(int i = 0; i<24; i++) {
|
||||||
quadData[i] = quadTemp[i];
|
quadData[i] = quadTemp[i];
|
||||||
@ -257,6 +257,39 @@ void Graphics::render(double time)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
loadingShader->use();
|
loadingShader->use();
|
||||||
loadingShader->setUniform("time", float(time));
|
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();
|
fullscreen_quad_loading->render();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -334,7 +367,7 @@ void Graphics::render(double time)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
//wind
|
//wind
|
||||||
glm::vec2 wind = glm::vec2(-0.3f, 0.0f);
|
glm::vec2 wind = glm::vec2(-0.4f, 0.3f);
|
||||||
|
|
||||||
//set view and projection matrix
|
//set view and projection matrix
|
||||||
glm::mat4 lightingViewProjectionMatrix = glm::perspective(1.571f, (float)windowSize.x/(float)windowSize.y, 0.1f, farPlane) * buildViewMatrix(level);
|
glm::mat4 lightingViewProjectionMatrix = glm::perspective(1.571f, (float)windowSize.x/(float)windowSize.y, 0.1f, farPlane) * buildViewMatrix(level);
|
||||||
|
@ -63,6 +63,8 @@ class Graphics {
|
|||||||
Level* level;
|
Level* level;
|
||||||
int number_of_texture_units = 0;
|
int number_of_texture_units = 0;
|
||||||
bool gameStart;
|
bool gameStart;
|
||||||
|
float loadingScreenWidth;
|
||||||
|
float loadingScreenHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user