#pragma once #include #include #include #include "math_types.h" #include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you. #include "Globals.h" #include "RenderUtils.h" struct Camera { Vector3f eye; Vector3f poi; Vector3f up; float near; float far; float fov; bool orthographic; float width; float height; Matrix44f mtxProj; Matrix44f mtxView; Camera() : eye {5.f, 4.f, 5.f}, poi {0.f, 2.f, 0.f}, up {0.f, 1.f, 0.f}, near (0.1f), far (150.f), fov (60.f), orthographic (false), width (-1.f), height (-1.f), mtxProj ( 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f), mtxView ( 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f) {} void updateMatrices(); }; struct Light { Vector3f pos; Vector3f dir; float mtxView[16]; float mtxProj[16]; float mtxLight[16]; float mtxShadow[16]; float shadowMapBias; uint16_t shadowMapSize; bool enabled; float near; float far; float area; Light() : pos (Vector3f(0.f, 10.f, 10.f)), dir (Vector3f(-1.f, -1.f, -1.f)), mtxView { 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f }, mtxProj { 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f }, mtxShadow { 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f }, shadowMapBias (0.004f), shadowMapSize (2048), near (0.1f), far (100.f), area (10.f), enabled (false) { } }; struct Mesh { GLuint mVertexArrayId = -1; GLuint mVertexBuffer = -1; }; struct Renderer { bool mInitialized = false; uint32_t mWidth = 1; uint32_t mHeight = 1; Camera mCamera; Mesh mMesh; RenderProgram mProgram; RenderTarget mRenderTarget; GLuint mRenderQuadVertexArrayId; GLuint mRenderQuadVertexBufferId; RenderProgram mRenderQuadProgramColor; GLuint muRenderQuadModelViewProj; GLuint muRenderQuadTexture; GLuint muRenderQuadTime; RenderProgram mRenderQuadProgramDepth; GLuint muRenderQuadDepthModelViewProj; GLuint muRenderQuadDepthNear; GLuint muRenderQuadDepthFar; Renderer() : mInitialized(false), mWidth (0), mHeight (0) { } void Initialize(int width, int height); void Shutdown(); void RenderGl(); void RenderGui(); void Resize (int width, int height); };