]> git.localhorst.tv Git - blank.git/blobdiff - src/graphics/viewport.cpp
sky box model & shader
[blank.git] / src / graphics / viewport.cpp
index 48bd5ee32ce017751f436a25a8228a51f5703059..875da78d83c6ecb1913f5cfa61a45ebcc0cabbcb 100644 (file)
@@ -79,6 +79,7 @@ Viewport::Viewport()
 , cursor(1.0f)
 , chunk_prog()
 , entity_prog()
+, sky_prog()
 , sprite_prog()
 , active_prog(NONE) {
        glClearColor(0.0, 0.0, 0.0, 1.0);
@@ -95,6 +96,11 @@ void Viewport::EnableDepthTest() noexcept {
        glDepthFunc(GL_LESS);
 }
 
+void Viewport::EqualDepthTest() noexcept {
+       glEnable(GL_DEPTH_TEST);
+       glDepthFunc(GL_LEQUAL);
+}
+
 void Viewport::DisableDepthTest() noexcept {
        glDisable(GL_DEPTH_TEST);
 }
@@ -218,6 +224,16 @@ PlainColor &Viewport::HUDOutlineProgram() noexcept {
        return outline_prog;
 }
 
+SkyBoxShader &Viewport::SkyBoxProgram() noexcept {
+       if (active_prog != SKY_BOX) {
+               sky_prog.Activate();
+               DisableBlending();
+               EqualDepthTest();
+               active_prog = SKY_BOX;
+       }
+       return sky_prog;
+}
+
 BlendedSprite &Viewport::SpriteProgram() noexcept {
        if (active_prog != SPRITE) {
                sprite_prog.Activate();