vertex input stream functions
This commit is contained in:
parent
6116e51b24
commit
576d211cbd
@ -87,7 +87,7 @@ but because librw is supposed to be able to
|
||||
convert between all sorts of platform specific files,
|
||||
the code for that has to be available no matter
|
||||
the render platform used.
|
||||
The common interface for all device-indepenent
|
||||
The common interface for all device-independent
|
||||
platform code is the `Driver` struct.
|
||||
The `Engine` struct has an array with one for each platform.
|
||||
|
||||
|
@ -127,13 +127,7 @@ matfxRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
setWorldMatrix(atomic->getFrame()->getLTM());
|
||||
lightingCB(atomic);
|
||||
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(header->vao);
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
|
||||
setAttribPointers(header->attribDesc, header->numAttribs);
|
||||
#endif
|
||||
setupVertexInput(header);
|
||||
|
||||
lastEnvFrame = nil;
|
||||
|
||||
@ -155,9 +149,7 @@ matfxRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
}
|
||||
inst++;
|
||||
}
|
||||
#ifndef RW_GL_USE_VAOS
|
||||
disableAttribPointers(header->attribDesc, header->numAttribs);
|
||||
#endif
|
||||
teardownVertexInput(header);
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
|
@ -90,6 +90,26 @@ disableAttribPointers(AttribDesc *attribDescs, int32 numAttribs)
|
||||
glDisableVertexAttribArray(a->index);
|
||||
}
|
||||
|
||||
void
|
||||
setupVertexInput(InstanceDataHeader *header)
|
||||
{
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(header->vao);
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
|
||||
setAttribPointers(header->attribDesc, header->numAttribs);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
teardownVertexInput(InstanceDataHeader *header)
|
||||
{
|
||||
#ifndef RW_GL_USE_VAOS
|
||||
disableAttribPointers(header->attribDesc, header->numAttribs);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32
|
||||
lightingCB(Atomic *atomic)
|
||||
{
|
||||
@ -115,8 +135,6 @@ lightingCB(Atomic *atomic)
|
||||
}
|
||||
}
|
||||
|
||||
#define U(i) currentShader->uniformLocations[i]
|
||||
|
||||
void
|
||||
defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
{
|
||||
@ -126,13 +144,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
setWorldMatrix(atomic->getFrame()->getLTM());
|
||||
lightingCB(atomic);
|
||||
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(header->vao);
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
|
||||
setAttribPointers(header->attribDesc, header->numAttribs);
|
||||
#endif
|
||||
setupVertexInput(header);
|
||||
|
||||
InstanceData *inst = header->inst;
|
||||
int32 n = header->numMeshes;
|
||||
@ -151,9 +163,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
drawInst(header, inst);
|
||||
inst++;
|
||||
}
|
||||
#ifndef RW_GL_USE_VAOS
|
||||
disableAttribPointers(header->attribDesc, header->numAttribs);
|
||||
#endif
|
||||
teardownVertexInput(header);
|
||||
}
|
||||
|
||||
|
||||
|
@ -259,13 +259,7 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
setWorldMatrix(atomic->getFrame()->getLTM());
|
||||
lightingCB(atomic);
|
||||
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(header->vao);
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
|
||||
setAttribPointers(header->attribDesc, header->numAttribs);
|
||||
#endif
|
||||
setupVertexInput(header);
|
||||
|
||||
InstanceData *inst = header->inst;
|
||||
int32 n = header->numMeshes;
|
||||
@ -286,9 +280,7 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
drawInst(header, inst);
|
||||
inst++;
|
||||
}
|
||||
#ifndef RW_GL_USE_VAOS
|
||||
disableAttribPointers(header->attribDesc, header->numAttribs);
|
||||
#endif
|
||||
teardownVertexInput(header);
|
||||
}
|
||||
|
||||
static void*
|
||||
|
@ -150,6 +150,8 @@ struct Im2DVertex
|
||||
|
||||
void setAttribPointers(AttribDesc *attribDescs, int32 numAttribs);
|
||||
void disableAttribPointers(AttribDesc *attribDescs, int32 numAttribs);
|
||||
void setupVertexInput(InstanceDataHeader *header);
|
||||
void teardownVertexInput(InstanceDataHeader *header);
|
||||
|
||||
// Render state
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user