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__
|
||||
Reference in New Issue
Block a user