Rendercommand API
parent
69c56269de
commit
c7cbe4ac21
|
@ -7,7 +7,41 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
const int cNumMaxRenderCommands = 1024;
|
||||||
|
|
||||||
|
RenderCommand sRenderCommands[PassCount][cNumMaxRenderCommands];
|
||||||
|
int sRenderCommandCount[PassCount];
|
||||||
|
|
||||||
|
void RenderCommandReset(RenderCommand *command) {
|
||||||
|
assert (command != nullptr);
|
||||||
|
|
||||||
|
command->mColor[0] = 0.f;
|
||||||
|
command->mColor[1] = 0.f;
|
||||||
|
command->mColor[2] = 0.f;
|
||||||
|
command->mColor[3] = 0.f;
|
||||||
|
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
command->mTransform[i] = 0.f;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
command->mTransform[i * 4 + i] = 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
command->mVAId = -1;
|
||||||
|
command->mVBId = -1;
|
||||||
|
|
||||||
|
command->mAlbedoTexture = -1;
|
||||||
|
command->mPrimitive = PrimitiveTriangles;
|
||||||
|
};
|
||||||
|
|
||||||
void RenderCommandsClear() {
|
void RenderCommandsClear() {
|
||||||
|
for (int i = 0; i < PassCount; i++) {
|
||||||
|
for (int j = 0; j < sRenderCommandCount[i]; j++) {
|
||||||
|
RenderCommandReset(&sRenderCommands[i][j]);
|
||||||
|
}
|
||||||
|
sRenderCommandCount[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (gRenderer == NULL) {
|
if (gRenderer == NULL) {
|
||||||
gLog ("Warning: Cannot clear render commands: no renderer found!");
|
gLog ("Warning: Cannot clear render commands: no renderer found!");
|
||||||
return;
|
return;
|
||||||
|
@ -15,6 +49,19 @@ void RenderCommandsClear() {
|
||||||
gRenderer->mRenderCommands.clear();
|
gRenderer->mRenderCommands.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RenderCommand *GetRenderCommand(RenderPass pass) {
|
||||||
|
int& pass_count = sRenderCommandCount[pass];
|
||||||
|
if (pass_count == cNumMaxRenderCommands) {
|
||||||
|
gLog ("Error: Reached max number of render commands: %d for pass %d",
|
||||||
|
cNumMaxRenderCommands, pass);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pass_count++;
|
||||||
|
|
||||||
|
return &sRenderCommands[pass][pass_count];
|
||||||
|
}
|
||||||
|
|
||||||
void RenderSubmit (
|
void RenderSubmit (
|
||||||
RenderObject object,
|
RenderObject object,
|
||||||
float* transform,
|
float* transform,
|
||||||
|
|
|
@ -8,12 +8,41 @@ typedef enum {
|
||||||
DebugCube = 1,
|
DebugCube = 1,
|
||||||
DebugFrame = 2,
|
DebugFrame = 2,
|
||||||
DebugSphere = 3,
|
DebugSphere = 3,
|
||||||
DebugBone = 4
|
DebugBone = 4,
|
||||||
|
StaticMesh = 5,
|
||||||
|
Line = 6,
|
||||||
|
SkinnedMesh = 7
|
||||||
} RenderObject;
|
} RenderObject;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PassDepth = 1,
|
||||||
|
PassShadowMap = 2,
|
||||||
|
PassSSAO = 3,
|
||||||
|
PassLighting = 4,
|
||||||
|
PassCount
|
||||||
|
} RenderPass;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PrimitivePoints
|
||||||
|
PrimitiveLines,
|
||||||
|
PrimitiveTriangles,
|
||||||
|
} RenderPrimitive;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float mColor[4];
|
||||||
|
float mTransform[16];
|
||||||
|
GLuint mVAId;
|
||||||
|
GLuint mVBId;
|
||||||
|
GLuint mAlbedoTexture;
|
||||||
|
RenderPrimitive mPrimitive;
|
||||||
|
} RenderCommand;
|
||||||
|
|
||||||
void RenderCommandsClear ();
|
void RenderCommandsClear ();
|
||||||
|
|
||||||
|
RenderCommand *GetRenderCommand(RenderPass pass);
|
||||||
|
|
||||||
void RenderSubmit (
|
void RenderSubmit (
|
||||||
|
RenderPass pass,
|
||||||
RenderObject object,
|
RenderObject object,
|
||||||
float* transform,
|
float* transform,
|
||||||
float color[4]
|
float color[4]
|
||||||
|
|
Loading…
Reference in New Issue