-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderer.cpp
More file actions
58 lines (47 loc) · 1.33 KB
/
Renderer.cpp
File metadata and controls
58 lines (47 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "Renderer.h"
#include "Assert.h"
#include "CameraComp.h"
#include "Window.h"
#include <thread>
using namespace Wolverine;
using namespace std;
BasicRenderer::BasicRenderer( SdlCanvas &canvas): m_FrameBuffer(canvas)
{
m_RasterShader.m_FrameBuffer = &m_FrameBuffer;
m_RenderCtx.setResolution( canvas.getWidth(), canvas.getHeight());
m_RenderCtx.setVertexShader(m_VertexShader);
m_RenderCtx.setFragmentShader(m_FragmentShader);
m_RenderCtx.setRasterShader(m_RasterShader);
}
void BasicRenderer::setModelMatrix(Mat4x4f const &modelMatrix)
{
m_ModelMatrix = modelMatrix;
}
void BasicRenderer::setViewMatrix(Mat4x4f const &viewMatrix)
{
m_ViewMatrix = viewMatrix;
}
void BasicRenderer::setProjMatrix(Mat4x4f const &projMatrix)
{
m_ProjMatrix = projMatrix;
}
void BasicRenderer::setViewportMatrix(Mat4x4f const &viewportMatrix)
{
m_ViewportMatrix = viewportMatrix;
}
void BasicRenderer::frameBegin()
{
m_FrameBuffer.frameBegin();
}
void BasicRenderer::frameEnd()
{
m_FrameBuffer.frameEnd();
}
void BasicRenderer::render(SharedMeshData const &meshData)
{
m_VertexShader.m_Uniforms.modelMatrix = m_ModelMatrix;
m_VertexShader.m_Uniforms.viewMatrix = m_ViewMatrix;
m_VertexShader.m_Uniforms.projMatrix = m_ProjMatrix;
m_VertexShader.m_Uniforms.viewportMatrix = m_ViewportMatrix;
m_RenderCtx.render(meshData.vData, meshData.iData);
}