Made attempt at scaling loading screen.
This commit is contained in:
parent
c5a4ee98d5
commit
bcc7767978
86
graphics.cc
86
graphics.cc
@ -77,6 +77,25 @@ void Graphics::init(Level* level) {
|
|||||||
flameShader = ShaderProgramCreator("flame")
|
flameShader = ShaderProgramCreator("flame")
|
||||||
.attributeLocations(flame_positions->getAttributeLocations()).create();
|
.attributeLocations(flame_positions->getAttributeLocations()).create();
|
||||||
|
|
||||||
|
fullscreen_quad_ab = SharedArrayBuffer(new ArrayBuffer());
|
||||||
|
fullscreen_quad_ab->defineAttribute("aPosition", GL_FLOAT, 2);
|
||||||
|
fullscreen_quad_ab->defineAttribute("aTexCoord", GL_FLOAT, 2);
|
||||||
|
|
||||||
|
float quadData[] = {
|
||||||
|
-1.0f, 1.0f, 0.0f, 1.0f,
|
||||||
|
1.0f, 1.0f, 1.0f, 1.0f,
|
||||||
|
1.0f, -1.0f, 1.0f, 0.0f,
|
||||||
|
|
||||||
|
1.0f, -1.0f, 1.0f, 0.0f,
|
||||||
|
-1.0f, -1.0f, 0.0f, 0.0f,
|
||||||
|
-1.0f, 1.0f, 0.0f, 1.0f
|
||||||
|
};
|
||||||
|
|
||||||
|
fullscreen_quad_ab->setDataElements(6, quadData);
|
||||||
|
|
||||||
|
fullscreen_quad = SharedVertexArrayObject(new VertexArrayObject);
|
||||||
|
fullscreen_quad->attachAllAttributes(fullscreen_quad_ab);
|
||||||
|
|
||||||
flamePostShader = ShaderProgramCreator("flame_post")
|
flamePostShader = ShaderProgramCreator("flame_post")
|
||||||
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
|
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
|
||||||
|
|
||||||
@ -173,35 +192,58 @@ void Graphics::renderLoadingScreen() {
|
|||||||
printf("You need at least 18 texture units to run this application. Exiting\n");
|
printf("You need at least 18 texture units to run this application. Exiting\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
fullscreen_quad_ab = SharedArrayBuffer(new ArrayBuffer());
|
|
||||||
fullscreen_quad_ab->defineAttribute("aPosition", GL_FLOAT, 2);
|
|
||||||
fullscreen_quad_ab->defineAttribute("aTexCoord", GL_FLOAT, 2);
|
|
||||||
|
|
||||||
float quadData[] = {
|
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
|
||||||
1.0f, 1.0f, 1.0f, 1.0f,
|
|
||||||
1.0f, -1.0f, 1.0f, 0.0f,
|
|
||||||
|
|
||||||
1.0f, -1.0f, 1.0f, 0.0f,
|
|
||||||
-1.0f, -1.0f, 0.0f, 0.0f,
|
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
fullscreen_quad_ab->setDataElements(6, quadData);
|
|
||||||
|
|
||||||
fullscreen_quad = SharedVertexArrayObject(new VertexArrayObject);
|
|
||||||
fullscreen_quad->attachAllAttributes(fullscreen_quad_ab);
|
|
||||||
loadingScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenPath));
|
loadingScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenPath));
|
||||||
loadingScreen->generateMipmaps();
|
loadingScreen->generateMipmaps();
|
||||||
loadingContinueScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenContinuePath));
|
loadingContinueScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenContinuePath));
|
||||||
loadingContinueScreen->generateMipmaps();
|
loadingContinueScreen->generateMipmaps();
|
||||||
|
int loadingScreenWidth = loadingScreen->getWidth();
|
||||||
|
int loadingScreenHeight = 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) {
|
||||||
|
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,
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
for(int i = 0; i<24; i++) {
|
||||||
|
quadData[i] = quadTemp[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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, -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
|
||||||
|
};
|
||||||
|
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);
|
||||||
loadingShader = ShaderProgramCreator("loading")
|
loadingShader = ShaderProgramCreator("loading")
|
||||||
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
|
.attributeLocations(fullscreen_quad_loading->getAttributeLocations()).create();
|
||||||
loadingShader->use();
|
loadingShader->use();
|
||||||
loadingShader->setUniform("time", 0.0f);
|
loadingShader->setUniform("time", 0.0f);
|
||||||
loadingShader->setTexture("screen", loadingScreen, 16);
|
loadingShader->setTexture("screen", loadingScreen, 16);
|
||||||
loadingShader->setTexture("screenContinue", loadingContinueScreen, 17);
|
loadingShader->setTexture("screenContinue", loadingContinueScreen, 17);
|
||||||
fullscreen_quad->render();
|
fullscreen_quad_loading->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::uvec2 Graphics::getWindowSize() {
|
glm::uvec2 Graphics::getWindowSize() {
|
||||||
@ -215,7 +257,7 @@ 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));
|
||||||
fullscreen_quad->render();
|
fullscreen_quad_loading->render();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
double nextUpdate = lastUpdate + lightUpdateDelay;
|
double nextUpdate = lastUpdate + lightUpdateDelay;
|
||||||
@ -292,7 +334,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.4f, 0.3f);
|
glm::vec2 wind = glm::vec2(-0.3f, 0.0f);
|
||||||
|
|
||||||
//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);
|
||||||
|
@ -56,6 +56,8 @@ class Graphics {
|
|||||||
SharedTexture2D light_fbo_depth_texture;
|
SharedTexture2D light_fbo_depth_texture;
|
||||||
SharedVertexArrayObject fullscreen_quad;
|
SharedVertexArrayObject fullscreen_quad;
|
||||||
SharedArrayBuffer fullscreen_quad_ab;
|
SharedArrayBuffer fullscreen_quad_ab;
|
||||||
|
SharedVertexArrayObject fullscreen_quad_loading;
|
||||||
|
SharedArrayBuffer fullscreen_quad_ab_loading;
|
||||||
int cube_size;
|
int cube_size;
|
||||||
unsigned int maxShadowRenderCount;
|
unsigned int maxShadowRenderCount;
|
||||||
Level* level;
|
Level* level;
|
||||||
|
Loading…
Reference in New Issue
Block a user