好的,所以我使用自己的glwrapper成功连接了所有OpenGL函数。我遇到的问题是英特尔/ Nvidia与ATI的关系。我正在挂钩模型并为每个模型生成ID,以便我可以分辨出渲染的内容。
以下是我目前拥有的信息+差异:
glPushMatrix()
glMultMatrixf({0.70710671, 0, 0.70710683, 0}
{0, 1, 0, 0}
{-0.70710683, 0, 0.70710671, 0}
{26368, -1125, 28416, 1})
glBindBufferARB(GL_ARRAY_BUFFER, 56)
glBufferSubDataARB(GL_ARRAY_BUFFER, 0, 11544, 0x0B2DF6EC)
glGenBuffersARB(1, 0x0AE6231C)
glBindBufferARB(GL_ARRAY_BUFFER, 65)
glBufferDataARB(GL_ARRAY_BUFFER, 11544, 0x0B2DF6EC, GL_STATIC_DRAW)
glGenBuffersARB(1, 0x0AE6231C)
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 66)
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER, 7020, 0x0B2DF6EC, GL_STATIC_DRAW)
//以上所有内容均由两个显卡完成。以下是问题所在。
glBindBufferARB(GL_ARRAY_BUFFER, 56) //Intel/Nvidia makes this NULL.
glVertexPointer(3, GL_FLOAT, 12, 0x00000000) //Intel/NVidia makes this Not 0x00000.
glEnableClientState(GL_VERTEX_ARRAY)
glDisableClientState(GL_NORMAL_ARRAY)
glBindBufferARB(GL_ARRAY_BUFFER, 65)
glColorPointer(4, GL_UNSIGNED_BYTE, 12, 0x00000000)
glEnableClientState(GL_COLOR_ARRAY)
glTexCoordPointer(2, GL_FLOAT, 12, 0x00000004)
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
glDrawElements(GL_TRIANGLES, 3510, GL_UNSIGNED_SHORT, 0x00000000)
我想知道为什么要打扰NULL-ing bindbuffer调用而不是为Nvidia&&而忽略顶点指针。英特尔卡,而在ATI上,一切都如上所述。
有什么区别?另外我的第二个问题是,如果我将指针存储到顶点和指标(保证它们不会被删除),我怎样才能获得每个顶点?
示例:
VBO CurrentBuffer;
std::vector<VBO> Buffers;
Hook_glBufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage)
{
CurrentBuffer.target = target;
CurrentBuffer.size = size;
CurrentBuffer.usage = usage; //To figure out if it's indices array or vertex array.
CurrentBuffer.data = data; //Let us assume that this pointer is never deleted.
(*original_BufferDataArb)(target, size, data, usage);
}
Hook_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
{
CurrentBuffer.VNull = (pointer == NULL) ? true : false;
CurrentBuffer.VPointer = pointer; //This can be both null or not null.
CurrentBuffer.VSize = size;
CurrentBuffer.Vtype = type;
CurrentBuffer.Stride = stride;
Buffers.push_back(CurrentBuffer);
(*original_VPointer)(size, type, stride, pointer);
}
void Hook_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
{
if (mode == GL_TRIANGLES)
{
const GLfloat* Pointer = static_cast<const GLfloat*>(Buffers.back().VPointer); //Assuming it isn't NULL.
for (int I = 0; I < count / 3; ++I) //For each triangle.
{
int X = *(reinterpret_cast<const GLfloat*>(reinterpret_cast<const char*>(Pointer)));
int Y = *(reinterpret_cast<const GLfloat*>(reinterpret_cast<const char*>(Pointer) + (Buffers.back().Stride)) + 1);
int Z = *(reinterpret_cast<const GLfloat*>(reinterpret_cast<const char*>(Pointer) + (2 * Buffers.back().Stride)) + 2);
}
}
(*original_DrawElements)(mode, count, type, indices);
}
我是否正确地迭代指针?此外,如果vertexpointer为null,有没有办法可以使用bufferdata用法来获取每个顶点?我读到我能做到:
if (CurrentBuffer.VNull)
{
GLfloat* IndexPointer = Buffers[Buffers.size()].data; //Index pointer is GL_Element_Array_Buffer
GLfloat* VertexPointer = Buffers[Buffers.size() - 1].data; //Vertex pointer is GL_Array_Buffer
for (int I = 0; I < TriangleCount; ++I)
{
int X = *VertexPointer[IndexPointer[I]];
int Y = *VertexPointer[IndexPointer[I]] + 1;
int Z = *VertexPointer[IndexPointer[I]] + 2;
}
}
答案 0 :(得分:1)
glBindBufferARB(GL_ARRAY_BUFFER, 56) //Intel/Nvidia makes this NULL. glVertexPointer(3, GL_FLOAT, 12, 0x00000000) //Intel/NVidia makes this Not 0x00000.
您确定,在您的Intel / NVidia案例中,该程序没有主动设置这些值。作为glVertexPointer的数据参数的空值仅在绑定缓冲区对象时才有意义。但是,如果没有绑定缓冲区对象,例如通过使用带有ID 0的glBindBuffer调用解绑定,则glVertexPointer的数据参数必须是非空指针。