浏览代码

gpu: fixed vbo attribute binding when one of the attribute on the buffer does not exist in the shader

undefined
Benlitz Sam Hocevar <sam@hocevar.net> 11 年前
父节点
当前提交
1a2bfe6609
共有 2 个文件被更改,包括 27 次插入24 次删除
  1. +0
    -1
      src/gpu/shader.cpp
  2. +27
    -23
      src/gpu/vertexbuffer.cpp

+ 0
- 1
src/gpu/shader.cpp 查看文件

@@ -342,7 +342,6 @@ ShaderAttrib Shader::GetAttribLocation(char const *attr,
if (l < 0) if (l < 0)
{ {
Log::Warn("tried to query invalid attribute: %s\n", attr); Log::Warn("tried to query invalid attribute: %s\n", attr);
l = 0;
} }
else else
{ {


+ 27
- 23
src/gpu/vertexbuffer.cpp 查看文件

@@ -356,7 +356,8 @@ void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attr1,
uint32_t index = l[n].m_flags & 0xffff; uint32_t index = l[n].m_flags & 0xffff;


# if !defined __CELLOS_LV2__ # if !defined __CELLOS_LV2__
glEnableVertexAttribArray((GLint)reg); if (reg != 0xffffffff)
glEnableVertexAttribArray((GLint)reg);
# else # else
switch (usage) switch (usage)
{ {
@@ -438,32 +439,35 @@ void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attr1,




# if !defined __CELLOS_LV2__ # if !defined __CELLOS_LV2__
if (tlut[type_index].type == GL_FLOAT if (reg != 0xffffffff)
|| tlut[type_index].type == GL_DOUBLE {
|| tlut[type_index].type == GL_BYTE if (tlut[type_index].type == GL_FLOAT
|| tlut[type_index].type == GL_UNSIGNED_BYTE || tlut[type_index].type == GL_DOUBLE
|| tlut[type_index].type == GL_BYTE
|| tlut[type_index].type == GL_UNSIGNED_BYTE
# if defined USE_GLEW && !defined __APPLE__ # if defined USE_GLEW && !defined __APPLE__
/* If this is not available, don't use it */ /* If this is not available, don't use it */
|| !glVertexAttribIPointer || !glVertexAttribIPointer
# endif # endif
|| false) || false)
{ {
/* Normalize unsigned bytes by default, because it's usually /* Normalize unsigned bytes by default, because it's usually
* some color information. */ * some color information. */
GLboolean normalize = (tlut[type_index].type == GL_UNSIGNED_BYTE) GLboolean normalize = (tlut[type_index].type == GL_UNSIGNED_BYTE)
|| (tlut[type_index].type == GL_BYTE); || (tlut[type_index].type == GL_BYTE);
glVertexAttribPointer((GLint)reg, tlut[type_index].size, glVertexAttribPointer((GLint)reg, tlut[type_index].size,
tlut[type_index].type, normalize, tlut[type_index].type, normalize,
stride, (GLvoid const *)(uintptr_t)offset); stride, (GLvoid const *)(uintptr_t)offset);
} }
# if defined GL_VERSION_3_0 # if defined GL_VERSION_3_0
else else
{ {
glVertexAttribIPointer((GLint)reg, tlut[type_index].size, glVertexAttribIPointer((GLint)reg, tlut[type_index].size,
tlut[type_index].type, tlut[type_index].type,
stride, (GLvoid const *)(uintptr_t)offset); stride, (GLvoid const *)(uintptr_t)offset);
} }
# endif # endif
}
# else # else
switch (usage) switch (usage)
{ {


||||||
x
 
000:0
正在加载...
取消
保存