本文整理汇总了C++中CBuffer::commitVBO方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::commitVBO方法的具体用法?C++ CBuffer::commitVBO怎么用?C++ CBuffer::commitVBO使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::commitVBO方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void CKLBOGLWrapper::draw(
GLenum mode,
CShaderInstance* instance,
CBuffer** ppBuffer,
u32 bufferCount,
CIndexBuffer* pIndexBuffer,
CTextureUsage** array_pTexture,
s32* uniformID,
s32 indexCount) {
// Force buffer to commit changes if they are VBO and were not updated.
u32 n=0;
while (n < bufferCount) {
CBuffer* pBuffer = ppBuffer[n];
n++;
if (pBuffer->VBOModified) {
pBuffer->commitVBO();
}
}
if (pIndexBuffer->VBOModified) {
pIndexBuffer->commitVBO();
}
if (m_lastShaderInstance != instance) {
// Same Shader with different param is also a possibility.
if (!m_lastShaderInstance || (m_lastShaderInstance->m_pShaderSet != instance->m_pShaderSet)) {
// Use Shader only when program really changes.
dglUseProgram(instance->m_pShaderSet->programObj);
}
// Transform matrix
// u32 _projectionUniform = dglGetUniformLocation(instance->m_pShaderSet->programObj, "Projection");
// dglUniformMatrix4fv(_projectionUniform, 1, 0, displayMatrix2D);
m_lastShaderInstance = instance;
}
u32 _projectionUniform = dglGetUniformLocation(instance->m_pShaderSet->programObj, "Projection");
dglUniformMatrix4fv(_projectionUniform, 1, 0, displayMatrix2D);
//
// Process all input for shaders.
//
CShader* pVertexS = instance->m_pShaderSet->vertexShader;
s32 maxVertexInput = pVertexS->countStreamInfo;
s32 count = 0;
while (count < maxVertexInput) {
CShaderInstance::SInternalParam* pParam = &instance->paramArrayVertexVertexShader[count];
if (pParam->isConstantifiedOrUniform)
{
dglDisableVertexAttribArray(count);
// Constantified
switch (pParam->dType & 0x0F) {
case VEC1F:
dglVertexAttrib1fv(count, (GLfloat*)pParam->values);
break;
case VEC2:
dglVertexAttrib2fv(count, (GLfloat*)pParam->values);
break;
case VEC3:
dglVertexAttrib3fv(count, (GLfloat*)pParam->values);
break;
case VEC4BYTE:
case VEC4:
dglVertexAttrib4fv(count, (GLfloat*)pParam->values);
break;
default:
klb_assertAlways("Invalid Type for vertex attribute");
}
} else {
//
// Search in buffer the source mapping the shader input.
//
s32 vertID = instance->paramArrayVertexVertexShader[count].vertexInfoID;
u32 n=0;
while (n < bufferCount) {
CBuffer* pBuffer = ppBuffer[n];
n++;
SVertexEntry* pEntries = pBuffer->structure;
SVertexEntry* pEntriesEnd = &pEntries[pBuffer->dynCount + pBuffer->vboCount];
while ((pEntries->vertexInfoID != vertID) && (pEntries < pEntriesEnd)) {
pEntries++;
}
if (pEntries < pEntriesEnd) {
GLint size = GLint(pParam->dType & 0xF);
GLenum type = GL_FLOAT;
GLboolean normalized = GL_FALSE;
if (size == VEC4BYTE) {
size = 4;
type = GL_UNSIGNED_BYTE;
normalized = GL_TRUE;
}
if (pEntries->isVBO) {
_glBindBuffer(pBuffer->vboID);
//.........这里部分代码省略.........