PickingPass now publishes an event that others can listen to to get pickingdata.
This commit is contained in:
@@ -6,11 +6,13 @@
|
|||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
#include "Util/UnorderedMapVec2.h"
|
#include "Util/UnorderedMapVec2.h"
|
||||||
|
#include "../Core/EventBroker.h"
|
||||||
|
#include "EPicking.h"
|
||||||
|
|
||||||
class PickingPass
|
class PickingPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PickingPass(IRenderer* renderer);
|
PickingPass(IRenderer* renderer, EventBroker* eb);
|
||||||
~PickingPass();
|
~PickingPass();
|
||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
@@ -30,6 +32,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
|
||||||
|
EventBroker* m_EventBroker;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
ShaderProgram m_PickingProgram;
|
ShaderProgram m_PickingProgram;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#include "Rendering/PickingPass.h"
|
#include "Rendering/PickingPass.h"
|
||||||
|
|
||||||
PickingPass::PickingPass(IRenderer* renderer)
|
PickingPass::PickingPass(IRenderer* renderer, EventBroker* eb)
|
||||||
{
|
{
|
||||||
m_Renderer = renderer;
|
m_Renderer = renderer;
|
||||||
|
m_EventBroker = eb;
|
||||||
|
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
InitializeFrameBuffers();
|
InitializeFrameBuffers();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
@@ -89,6 +91,17 @@ void PickingPass::Draw(RenderQueueCollection& rq)
|
|||||||
}
|
}
|
||||||
m_PickingBuffer.Unbind();
|
m_PickingBuffer.Unbind();
|
||||||
GLERROR("PickingPass Error");
|
GLERROR("PickingPass Error");
|
||||||
|
|
||||||
|
//Publish pick event every frame with the pick data that can be picked by the event
|
||||||
|
Events::Picking pickEvent = Events::Picking(
|
||||||
|
&m_PickingBuffer,
|
||||||
|
&m_DepthBuffer,
|
||||||
|
m_Renderer->Camera()->ProjectionMatrix(),
|
||||||
|
m_Renderer->Camera()->ViewMatrix(),
|
||||||
|
m_Renderer->Resolution(),
|
||||||
|
&m_PickingColorsToEntity);
|
||||||
|
|
||||||
|
m_EventBroker->Publish(pickEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PickingPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
void PickingPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
|
|||||||
@@ -263,16 +263,6 @@ void Renderer::DrawScene(RenderQueueCollection& rq)
|
|||||||
//m_PickingBuffer.Unbind();
|
//m_PickingBuffer.Unbind();
|
||||||
//GLERROR("PickingPass Error");
|
//GLERROR("PickingPass Error");
|
||||||
|
|
||||||
//Publish pick event every frame with the pick data that can be picked by the event
|
|
||||||
Events::Picking pickEvent = Events::Picking(
|
|
||||||
&m_PickingBuffer,
|
|
||||||
&m_DepthBuffer,
|
|
||||||
m_Camera->ProjectionMatrix(),
|
|
||||||
m_Camera->ViewMatrix(),
|
|
||||||
m_Resolution,
|
|
||||||
&m_PickingColorsToEntity);
|
|
||||||
|
|
||||||
m_EventBroker->Publish(pickEvent);
|
|
||||||
|
|
||||||
void Renderer::DrawScreenQuad(GLuint textureToDraw)
|
void Renderer::DrawScreenQuad(GLuint textureToDraw)
|
||||||
{
|
{
|
||||||
@@ -384,7 +374,7 @@ void Renderer::InitializeSSBOs()
|
|||||||
|
|
||||||
void Renderer::InitializeRenderPasses()
|
void Renderer::InitializeRenderPasses()
|
||||||
{
|
{
|
||||||
m_PickingPass = new PickingPass(this);
|
m_PickingPass = new PickingPass(this, m_EventBroker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CalculateFrustum()
|
void Renderer::CalculateFrustum()
|
||||||
|
|||||||
Reference in New Issue
Block a user