WIP Render Queue
This commit is contained in:
@@ -8,8 +8,12 @@ namespace Components
|
||||
|
||||
struct Camera : Component
|
||||
{
|
||||
Camera() : FOV(glm::radians(45.f)), NearClip(0.1f), FarClip(100.f) { }
|
||||
Camera()
|
||||
: FOV(glm::radians(45.f))
|
||||
, NearClip(0.1f)
|
||||
, FarClip(100.f) { }
|
||||
|
||||
std::string Viewport;
|
||||
float FOV;
|
||||
float NearClip;
|
||||
float FarClip;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef GUI_Viewport_h__
|
||||
#define GUI_Viewport_h__
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class Viewport : public Frame
|
||||
{
|
||||
public:
|
||||
// Create a frame as a child
|
||||
Viewport(std::shared_ptr<Frame> parent)
|
||||
: Frame(parent) { }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GUI_Viewport_h__
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef RenderQueue_h__
|
||||
#define RenderQueue_h__
|
||||
|
||||
#include <cstdint>
|
||||
#include <forward_list>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "Texture.h"
|
||||
#include "Model.h"
|
||||
|
||||
class RenderQueue;
|
||||
|
||||
struct RenderJob
|
||||
{
|
||||
friend class RenderQueue;
|
||||
|
||||
unsigned int ViewportID;
|
||||
unsigned int TextureID;
|
||||
|
||||
GLuint DiffuseTexture;
|
||||
GLuint NormalTexture;
|
||||
GLuint SpecularTexture;
|
||||
GLuint VAO;
|
||||
unsigned int StartIndex;
|
||||
unsigned int EndIndex;
|
||||
glm::mat4 ModelMatrix;
|
||||
|
||||
protected:
|
||||
uint64_t Hash;
|
||||
|
||||
void CalculateHash()
|
||||
{
|
||||
Hash = ViewportID << 58 // 6 bits
|
||||
| TextureID << 42; // 16 bits
|
||||
}
|
||||
|
||||
bool operator<(const RenderJob& rhs)
|
||||
{
|
||||
return this->Hash < rhs.Hash;
|
||||
}
|
||||
};
|
||||
|
||||
class RenderQueue
|
||||
{
|
||||
public:
|
||||
void Add(RenderJob &job)
|
||||
{
|
||||
job.CalculateHash();
|
||||
m_Jobs.push_front(job);
|
||||
m_Jobs.sort();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_Jobs.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
std::forward_list<RenderJob> m_Jobs;
|
||||
};
|
||||
|
||||
#endif // RenderQueue_h__
|
||||
@@ -155,6 +155,7 @@
|
||||
<ClInclude Include="..\..\src\GameWorld.h" />
|
||||
<ClInclude Include="..\..\src\GUI\Frame.h" />
|
||||
<ClInclude Include="..\..\src\EventBroker.h" />
|
||||
<ClInclude Include="..\..\src\GUI\Viewport.h" />
|
||||
<ClInclude Include="..\..\src\InputController.h" />
|
||||
<ClInclude Include="..\..\src\InputManager.h" />
|
||||
<ClInclude Include="..\..\src\Model.h" />
|
||||
@@ -162,6 +163,7 @@
|
||||
<ClInclude Include="..\..\src\Physics\VehicleSetup.h" />
|
||||
<ClInclude Include="..\..\src\PrecompiledHeader.h" />
|
||||
<ClInclude Include="..\..\src\Renderer.h" />
|
||||
<ClInclude Include="..\..\src\RenderQueue.h" />
|
||||
<ClInclude Include="..\..\src\ResourceManager.h" />
|
||||
<ClInclude Include="..\..\src\ShaderProgram.h" />
|
||||
<ClInclude Include="..\..\src\Skybox.h" />
|
||||
|
||||
@@ -279,6 +279,12 @@
|
||||
<ClInclude Include="..\..\src\InputController.h">
|
||||
<Filter>Input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\RenderQueue.h">
|
||||
<Filter>Rendering</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\GUI\Viewport.h">
|
||||
<Filter>GUI</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\src\Shaders\AABB.frag.glsl">
|
||||
|
||||
Reference in New Issue
Block a user