Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
OpenGLRenderer.h
Go to the documentation of this file.
1#ifndef ULT_RENDERER_OPENGL_H_INCLUDED
2#define ULT_RENDERER_OPENGL_H_INCLUDED
3
4#include <vector>
5
6#include <GL/glew.h>
7
8#include "RenderInterface.h"
13#include "VertexDescriptor.h"
14
15namespace Ult
16{
17
23{
24 //TODO
25 //BB_RTTI_EXPOSE_TYPE;
26
27public:
29 virtual ~OpenGLRenderer();
30
31 virtual bool Initialize(const RenderParams* params);
32 virtual void Shutdown();
33
34 virtual void SetViewport(int x, int y, int width, int height);
35 virtual void ResizeWindow(
36 float fov,
37 float nearDist, float farDist,
38 int width, int height
39 );
40 virtual void ResizeWindowOrtho(
41 int left, int right,
42 int bottom, int top,
43 float nearDist, float farDist
44 );
45
46 virtual void SetClearColor(int r, int g, int b, int a);
47 virtual void StartRendering(bool color, bool depth, bool stencil);
48 virtual void EndRendering();
49
50 virtual bool Enable(RenderState state);
51 virtual bool Disable(RenderState state);
52 virtual void SetAlphaFunc(AlphaState state, float val);
53
54 virtual void SetView(
55 float posX, float posY, float posZ,
56 float lookX, float lookY, float lookZ,
57 float upX, float upY, float upZ
58 );
59 virtual void SetMatrix(const float* matrix);
60 virtual void MultiplyToCurrentMatrix(const float* m);
61 virtual bool SwitchMatrixType(MatrixType type);
62 virtual void GetMatrix(MatrixType type, float* matrix);
63
64 virtual void RotateMatrix(float angle, float x, float y, float z);
65 virtual void TranslateMatrix(float x, float y, float z);
66
67 virtual void LoadIdentityMatrix();
68 virtual void PushMatrix();
69 virtual void PopMatrix();
70
71
72 virtual void ApplyFilters(Texture& handle, FilterListPtr filters);
73 virtual bool AddEmptyTexture(
74 const char* name,
75 int width, int height, int numComponents,
76 TextureType type,
77 TextureFormat format,
78 Texture* handle
79 );
80 virtual bool LoadTexFromFile(
81 const char* fileName,
82 TextureType type,
83 Texture* handle
84 );
85 virtual bool LoadTexFromMemory(
86 const char* name,
87 char* fileData,
88 int length,
89 TextureType type,
90 Texture* handle
91 );
92 virtual bool ApplyTexture(int texUnit, Texture& handle);
93 virtual void DeleteTexture(Texture& handle);
94
95
96 virtual bool CreateShaderFromFile(const char* vs, const char* ps, ShaderHandle* handle);
97 virtual bool CreateShaderFromMemory(const char* vsFile, const char* psFile, ShaderHandle* handle);
98 virtual void ApplyShader(ShaderHandle shader);
99
100 virtual void SetupShaderParameter(const char* pname, ShaderHandle shader, ParameterHandle* param);
101 virtual void SetShaderParameter1i(ParameterHandle param, float val);
102 virtual void SetShaderParameter1f(ParameterHandle param, float val);
103 virtual void SetShaderParameter2f(ParameterHandle param, float x, float y);
104 virtual void SetShaderParameter3f(ParameterHandle param, float x, float y, float z);
105 virtual void SetShaderParameter4f(ParameterHandle param, float x, float y, float z, float w);
106
107
108 virtual void Render(
109 PrimitiveType type,
110 VertexDescriptor* desc,
111 char* vertexData,
112 unsigned int* indices,
113 int totalVertices, // size in bytes
114 int totalIndices,
115 int stride
116 );
117
118protected:
121 GLuint mVbo, mIbo;
123
124 std::vector<GLSLShader> mShaders;
125 std::vector<GLSLParameter> mParameters;
126
127
128 bool InitializeOS(const RenderParams* params);
129 void ShutdownOS();
131};
132
133
134} // namespace Ult
135
136#endif // ULT_RENDERER_OPENGL_H_INCLUDED
137
virtual void SetShaderParameter2f(ParameterHandle param, float x, float y)
Definition OpenGLRenderer.cpp:749
virtual bool Disable(RenderState state)
Definition OpenGLRenderer.cpp:295
virtual void SetShaderParameter1i(ParameterHandle param, float val)
Definition OpenGLRenderer.cpp:737
OpenGLRenderer()
Definition OpenGLRenderer.cpp:154
virtual void PopMatrix()
Definition OpenGLRenderer.cpp:400
bool mFboSupport
Definition OpenGLRenderer.h:120
virtual void GetMatrix(MatrixType type, float *matrix)
Definition OpenGLRenderer.cpp:370
virtual void DeleteTexture(Texture &handle)
Definition OpenGLRenderer.cpp:602
std::vector< GLSLParameter > mParameters
Definition OpenGLRenderer.h:125
virtual void ApplyFilters(Texture &handle, FilterListPtr filters)
Definition OpenGLRenderer.cpp:406
virtual void SetAlphaFunc(AlphaState state, float val)
Definition OpenGLRenderer.cpp:319
virtual void TranslateMatrix(float x, float y, float z)
Definition OpenGLRenderer.cpp:387
virtual bool ApplyTexture(int texUnit, Texture &handle)
Definition OpenGLRenderer.cpp:579
virtual void LoadIdentityMatrix()
Definition OpenGLRenderer.cpp:392
virtual void SetShaderParameter4f(ParameterHandle param, float x, float y, float z, float w)
Definition OpenGLRenderer.cpp:761
ResourceManager< GLTexture, Texture > * mTexManager
Definition OpenGLRenderer.h:122
VertexDescriptor * mCurrentDesc
Definition OpenGLRenderer.h:119
virtual bool SwitchMatrixType(MatrixType type)
Definition OpenGLRenderer.cpp:358
virtual void SetupShaderParameter(const char *pname, ShaderHandle shader, ParameterHandle *param)
Definition OpenGLRenderer.cpp:716
bool InitializeOS(const RenderParams *params)
Definition OpenGLRenderer.cpp:941
virtual void SetShaderParameter1f(ParameterHandle param, float val)
Definition OpenGLRenderer.cpp:743
GLuint mVbo
Definition OpenGLRenderer.h:121
virtual void SetView(float posX, float posY, float posZ, float lookX, float lookY, float lookZ, float upX, float upY, float upZ)
Definition OpenGLRenderer.cpp:334
GLuint mIbo
Definition OpenGLRenderer.h:121
bool mVboSupport
Definition OpenGLRenderer.h:120
void ShutdownOS()
Definition OpenGLRenderer.cpp:962
virtual void MultiplyToCurrentMatrix(const float *m)
Definition OpenGLRenderer.cpp:352
virtual void SetClearColor(int r, int g, int b, int a)
Definition OpenGLRenderer.cpp:236
virtual bool CreateShaderFromMemory(const char *vsFile, const char *psFile, ShaderHandle *handle)
Definition OpenGLRenderer.cpp:658
virtual void SetViewport(int x, int y, int width, int height)
Definition OpenGLRenderer.cpp:207
virtual bool CreateShaderFromFile(const char *vs, const char *ps, ShaderHandle *handle)
Definition OpenGLRenderer.cpp:608
virtual bool Enable(RenderState state)
Definition OpenGLRenderer.cpp:257
virtual void ResizeWindow(float fov, float nearDist, float farDist, int width, int height)
Definition OpenGLRenderer.cpp:211
virtual ~OpenGLRenderer()
Definition OpenGLRenderer.cpp:165
virtual void EndRendering()
Definition OpenGLRenderer.cpp:252
virtual bool LoadTexFromFile(const char *fileName, TextureType type, Texture *handle)
Definition OpenGLRenderer.cpp:497
void InitializeExtensions()
Definition OpenGLRenderer.cpp:966
virtual void RotateMatrix(float angle, float x, float y, float z)
Definition OpenGLRenderer.cpp:383
virtual void Render(PrimitiveType type, VertexDescriptor *desc, char *vertexData, unsigned int *indices, int totalVertices, int totalIndices, int stride)
Definition OpenGLRenderer.cpp:769
virtual void PushMatrix()
Definition OpenGLRenderer.cpp:396
virtual void SetMatrix(const float *matrix)
Definition OpenGLRenderer.cpp:346
virtual bool Initialize(const RenderParams *params)
Definition OpenGLRenderer.cpp:170
virtual void StartRendering(bool color, bool depth, bool stencil)
Definition OpenGLRenderer.cpp:244
bool mGlslSupport
Definition OpenGLRenderer.h:120
virtual void Shutdown()
Definition OpenGLRenderer.cpp:185
virtual void ResizeWindowOrtho(int left, int right, int bottom, int top, float nearDist, float farDist)
Definition OpenGLRenderer.cpp:223
std::vector< GLSLShader > mShaders
Definition OpenGLRenderer.h:124
virtual bool AddEmptyTexture(const char *name, int width, int height, int numComponents, TextureType type, TextureFormat format, Texture *handle)
Definition OpenGLRenderer.cpp:463
virtual void SetShaderParameter3f(ParameterHandle param, float x, float y, float z)
Definition OpenGLRenderer.cpp:755
virtual void ApplyShader(ShaderHandle shader)
Definition OpenGLRenderer.cpp:707
virtual bool LoadTexFromMemory(const char *name, char *fileData, int length, TextureType type, Texture *handle)
Definition OpenGLRenderer.cpp:536
RenderInterface()
Definition RenderInterface.cpp:6
Definition ResourceManager.h:17
Definition VertexDescriptor.h:18
int ShaderHandle
Definition RenderInterface.h:25
RenderState
Definition RenderState.h:9
int ParameterHandle
Definition RenderInterface.h:27
PrimitiveType
Definition PrimitiveType.h:9
MatrixType
Definition MatrixType.h:9
AlphaState
Definition AlphaState.h:9
Definition Archive.h:13
Handle< stTexture > Texture
Definition Texture.h:10
TextureType
Definition TextureType.h:8
FilterList * FilterListPtr
Definition FilterType.h:37
TextureFormat
Definition TextureFormat.h:8
Definition RenderParams.h:11