X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FViewport.hpp;fp=src%2Fgraphics%2FViewport.hpp;h=d64e580e56676bcc9024ce302c01bc07f8528885;hb=5d2da8a07411ad6417d6ed8d1be997189cf5ce89;hp=0000000000000000000000000000000000000000;hpb=37a1465a83e4ac4363ed0d8e0fa1ce5055dd2db4;p=blank.git diff --git a/src/graphics/Viewport.hpp b/src/graphics/Viewport.hpp new file mode 100644 index 0000000..d64e580 --- /dev/null +++ b/src/graphics/Viewport.hpp @@ -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 +#include + + +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