diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-11-22 22:42:34 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-11-22 22:42:34 -0500 |
commit | 27a7d334931514e4ca4fabe8eef7d47495c68301 (patch) | |
tree | a553d6be30025aa2761f1fb804966aba4b489096 /src/world.cpp | |
parent | 05dd30a5158184fea83d93f53e8100aecaebb74a (diff) |
Black bars if world is smaller than screen (messy)
Diffstat (limited to 'src/world.cpp')
-rw-r--r-- | src/world.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/world.cpp b/src/world.cpp index 02db9cf..62e4f69 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -955,8 +955,50 @@ void WorldSystem::render(void) glVertexAttribPointer(Render::worldShader.tex, 2, GL_FLOAT, GL_FALSE, 0, &grasst[0]); glDrawArrays(GL_TRIANGLES, 0 , c.size()); - Render::worldShader.disable(); + // the starting pixel of the world + float s = -(static_cast<float>(SCREEN_WIDTH)/2.0f); + // the ending pixel of the world + float e = (static_cast<float>(SCREEN_WIDTH)/2.0f); + + if (offset.x + world.startX > s) { + + glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(0,0,0))); + glUniform1f(Render::worldShader.uniform[WU_light_impact], 0.0f); + + GLfloat blackBarLeft[] = {s, 0.0f, -3.0f, 0.0f, 0.0f, + world.startX, 0.0f, -3.0f, 1.0f, 0.0f, + world.startX, static_cast<float>(SCREEN_HEIGHT), -3.0f, 1.0f, 1.0f, + + world.startX, static_cast<float>(SCREEN_HEIGHT), -3.0f, 1.0f, 1.0f, + s, static_cast<float>(SCREEN_HEIGHT), -3.0f, 0.0f, 1.0f, + s, 0.0f, -3.0f, 0.0f, 0.0f}; + + glVertexAttribPointer(Render::worldShader.coord, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*5, &blackBarLeft[0]); + glVertexAttribPointer(Render::worldShader.tex, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*5, &blackBarLeft[3]); + glDrawArrays(GL_TRIANGLES, 0 , 6); + } + + if (offset.x - world.startX < e) { + + glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(0,0,0))); + glUniform1f(Render::worldShader.uniform[WU_light_impact], 0.0f); + + GLfloat blackBarRight[] = {grassc[grassc.size()-3], 0.0f, -3.0f, 0.0f, 0.0f, + e, 0.0f, -3.0f, 1.0f, 0.0f, + e, static_cast<float>(SCREEN_HEIGHT), -3.0f, 1.0f, 1.0f, + + e, static_cast<float>(SCREEN_HEIGHT), -3.0f, 1.0f, 1.0f, + grassc[grassc.size()-3], static_cast<float>(SCREEN_HEIGHT), -3.0f, 0.0f, 1.0f, + grassc[grassc.size()-3], 0.0f, -3.0f, 0.0f, 0.0f}; + + glVertexAttribPointer(Render::worldShader.coord, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*5, &blackBarRight[0]); + glVertexAttribPointer(Render::worldShader.tex, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*5, &blackBarRight[3]); + glDrawArrays(GL_TRIANGLES, 0 , 6); + } + + Render::worldShader.disable(); Render::worldShader.unuse(); + } else { Render::useShader(&Render::worldShader); Render::worldShader.use(); |