]> git.localhorst.tv Git - blank.git/blobdiff - src/graphics/Viewport.hpp
reorganize basic rendering functionality
[blank.git] / src / graphics / Viewport.hpp
diff --git a/src/graphics/Viewport.hpp b/src/graphics/Viewport.hpp
new file mode 100644 (file)
index 0000000..d64e580
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef BLANK_GRAPHICS_VIEWPORT_HPP_
+#define BLANK_GRAPHICS_VIEWPORT_HPP_
+
+#include "BlendedSprite.hpp"
+#include "BlockLighting.hpp"
+#include "Camera.hpp"
+#include "Canvas.hpp"
+#include "DirectionalLighting.hpp"
+
+#include <glm/glm.hpp>
+#include <SDL.h>
+
+
+namespace blank {
+
+class Viewport {
+
+public:
+       Viewport();
+
+       Viewport(const Viewport &) = delete;
+       Viewport &operator =(const Viewport &) = delete;
+
+       void VSync(bool b) noexcept;
+
+       void EnableDepthTest() noexcept;
+       void DisableDepthTest() noexcept;
+
+       void EnableBackfaceCulling() noexcept;
+       void DisableBackfaceCulling() noexcept;
+
+       void EnableAlphaBlending() noexcept;
+       void EnableInvertBlending() noexcept;
+       void DisableBlending() noexcept;
+
+       void Resize(int w, int h) noexcept;
+
+       float Width() const noexcept { return canv.Size().x; }
+       float Height() const noexcept { return canv.Size().y; }
+
+       void Clear() noexcept;
+       void ClearDepth() noexcept;
+
+       BlockLighting &ChunkProgram() noexcept;
+       DirectionalLighting &EntityProgram() noexcept;
+       DirectionalLighting &HUDProgram() noexcept;
+       BlendedSprite &SpriteProgram() noexcept;
+
+       void WorldPosition(const glm::mat4 &) noexcept;
+
+       const glm::mat4 &Perspective() const noexcept { return cam.Projection(); }
+       const glm::mat4 &Ortho() const noexcept { return canv.Projection(); }
+       const glm::mat4 &CenterTransform() const noexcept { return center; }
+
+private:
+       SDL_GLContext ctx;
+       Camera cam;
+       Canvas canv;
+
+       glm::mat4 center;
+
+       BlockLighting chunk_prog;
+       DirectionalLighting entity_prog;
+       BlendedSprite sprite_prog;
+
+       enum {
+               NONE,
+               CHUNK,
+               ENTITY,
+               HUD,
+               SPRITE,
+       } active_prog;
+
+};
+
+}
+
+#endif