Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
RenderInterface.h
Go to the documentation of this file.
1#ifndef ULT_RENDERER_INTERFACE_H_INCLUDED
2#define ULT_RENDERER_INTERFACE_H_INCLUDED
3
7
8#include <Cg/cg.h>
9
10#include "AlphaState.h"
11#include "MatrixType.h"
12#include "PrimitiveType.h"
13#include "RenderParams.h"
14#include "RenderState.h"
15#include "../Texture/Texture.h"
19#include "VertexDescriptor.h"
20
21namespace Ult
22{
23
25typedef int ShaderHandle;
27typedef int ParameterHandle;
28
34{
35 //TODO
36 //BB_RTTI_EXPOSE_TYPE;
37
38public:
42 virtual ~RenderInterface();
43
48 virtual bool Initialize(const RenderParams* params) = 0;
52 virtual void Shutdown() = 0;
53
55 virtual void SetViewport(int x, int y, int width, int height) = 0;
60 virtual void ResizeWindow(
61 float fov,
62 float nearDist, float farDist,
63 int width, int height
64 ) = 0;
69 virtual void ResizeWindowOrtho(
70 int left, int right,
71 int bottom, int top,
72 float nearDist, float farDist
73 ) = 0;
74
76 virtual void SetClearColor(int r, int g, int b, int a) = 0;
81 virtual void StartRendering(bool color, bool depth, bool stencil) = 0;
83 virtual void EndRendering() = 0;
84
86 virtual bool Enable(RenderState state) = 0;
88 virtual bool Disable(RenderState state) = 0;
90 virtual void SetAlphaFunc(AlphaState state, float val) = 0;
91
93 virtual void SetView(
94 float posX, float posY, float posZ,
95 float lookX, float lookY, float lookZ,
96 float upX, float upY, float upZ
97 ) = 0;
99 virtual void SetMatrix(const float* matrix) = 0;
101 virtual void MultiplyToCurrentMatrix(const float* m) = 0;
103 virtual bool SwitchMatrixType(MatrixType type) = 0;
105 virtual void GetMatrix(MatrixType type, float* matrix) = 0;
106
112 virtual void RotateMatrix(float angle, float x, float y, float z) = 0;
116 virtual void TranslateMatrix(float x, float y, float z) = 0;
117
119 virtual void LoadIdentityMatrix() = 0;
121 virtual void PushMatrix() = 0;
123 virtual void PopMatrix() = 0;
124
125
127 virtual void ApplyFilters(Texture& handle, FilterListPtr filters) = 0;
129 virtual bool AddEmptyTexture(
130 const char* name,
131 int width, int height, int numComponents,
132 TextureType type,
133 TextureFormat format,
134 Texture* handle
135 ) = 0;
137 virtual bool LoadTexFromFile(
138 const char* fileName,
139 TextureType type,
140 Texture* handle
141 ) = 0;
143 virtual bool LoadTexFromMemory(
144 const char* name,
145 char* fileData,
146 int length,
147 TextureType type,
148 Texture* handle
149 ) = 0;
151 virtual bool ApplyTexture(int texUnit, Texture& handle) = 0;
153 virtual void DeleteTexture(Texture& handle) = 0;
154
155
160 virtual bool CreateShaderFromFile(const char* vs, const char* ps, ShaderHandle* handle) = 0;
165 virtual bool CreateShaderFromMemory(const char* vsFile, const char* psFile, ShaderHandle* handle) = 0;
167 virtual void ApplyShader(ShaderHandle shader) = 0;
168
173 virtual void SetupShaderParameter(const char* pname, ShaderHandle shader, ParameterHandle* param) = 0;
175 virtual void SetShaderParameter1i(ParameterHandle param, float val) = 0;
177 virtual void SetShaderParameter1f(ParameterHandle param, float val) = 0;
179 virtual void SetShaderParameter2f(ParameterHandle param, float x, float y) = 0;
181 virtual void SetShaderParameter3f(ParameterHandle param, float x, float y, float z) = 0;
183 virtual void SetShaderParameter4f(ParameterHandle param, float x, float y, float z, float w) = 0;
184
185
196 virtual void Render(
197 PrimitiveType type,
198 VertexDescriptor* desc,
199 char* vertexData,
200 unsigned int* indices,
201 int totalVertices,
202 int totalIndices,
203 int stride
204 ) = 0;
205
206protected:
209
211
212 CGcontext mCgContext;
214};
215
216} // namespace Ult
217
218#endif // ULT_RENDERER_INTERFACE_H_INCLUDED
219
int mAlpha
Definition RenderInterface.h:207
int mRed
Definition RenderInterface.h:207
virtual void DeleteTexture(Texture &handle)=0
virtual bool Initialize(const RenderParams *params)=0
CGprofile mPsProfile
Definition RenderInterface.h:213
virtual bool Enable(RenderState state)=0
virtual void TranslateMatrix(float x, float y, float z)=0
virtual void LoadIdentityMatrix()=0
bool mMultiTexSupport
Definition RenderInterface.h:208
CGcontext mCgContext
Definition RenderInterface.h:212
virtual void SetShaderParameter4f(ParameterHandle param, float x, float y, float z, float w)=0
virtual void Render(PrimitiveType type, VertexDescriptor *desc, char *vertexData, unsigned int *indices, int totalVertices, int totalIndices, int stride)=0
virtual void EndRendering()=0
virtual void Shutdown()=0
virtual bool LoadTexFromFile(const char *fileName, TextureType type, Texture *handle)=0
virtual void SetMatrix(const float *matrix)=0
CGprofile mVsProfile
Definition RenderInterface.h:213
virtual void SetAlphaFunc(AlphaState state, float val)=0
virtual bool CreateShaderFromFile(const char *vs, const char *ps, ShaderHandle *handle)=0
int mBlue
Definition RenderInterface.h:207
virtual void StartRendering(bool color, bool depth, bool stencil)=0
virtual void ApplyFilters(Texture &handle, FilterListPtr filters)=0
virtual void ResizeWindowOrtho(int left, int right, int bottom, int top, float nearDist, float farDist)=0
virtual void GetMatrix(MatrixType type, float *matrix)=0
virtual void SetShaderParameter2f(ParameterHandle param, float x, float y)=0
virtual void SetShaderParameter1f(ParameterHandle param, float val)=0
virtual void SetView(float posX, float posY, float posZ, float lookX, float lookY, float lookZ, float upX, float upY, float upZ)=0
virtual void SetClearColor(int r, int g, int b, int a)=0
RenderInterface()
Definition RenderInterface.cpp:6
virtual void SetupShaderParameter(const char *pname, ShaderHandle shader, ParameterHandle *param)=0
virtual void ResizeWindow(float fov, float nearDist, float farDist, int width, int height)=0
virtual void PushMatrix()=0
virtual bool CreateShaderFromMemory(const char *vsFile, const char *psFile, ShaderHandle *handle)=0
virtual void SetViewport(int x, int y, int width, int height)=0
bool mCubeMapSupport
Definition RenderInterface.h:208
int mGreen
Definition RenderInterface.h:207
RenderParams mParams
Definition RenderInterface.h:210
virtual void RotateMatrix(float angle, float x, float y, float z)=0
virtual void PopMatrix()=0
virtual bool SwitchMatrixType(MatrixType type)=0
virtual ~RenderInterface()
Definition RenderInterface.cpp:16
virtual void SetShaderParameter3f(ParameterHandle param, float x, float y, float z)=0
virtual void ApplyShader(ShaderHandle shader)=0
virtual bool LoadTexFromMemory(const char *name, char *fileData, int length, TextureType type, Texture *handle)=0
virtual bool ApplyTexture(int texUnit, Texture &handle)=0
virtual void SetShaderParameter1i(ParameterHandle param, float val)=0
virtual void MultiplyToCurrentMatrix(const float *m)=0
virtual bool AddEmptyTexture(const char *name, int width, int height, int numComponents, TextureType type, TextureFormat format, Texture *handle)=0
virtual bool Disable(RenderState state)=0
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