我正在尝试将 uint 传递给我的着色器,但我一定做错了什么,因为在着色器中该值是 3212836864 而不是 4294967295。
我有一个顶点数组,在将每个顶点发送到着色器之前将其存储在其中glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vertex) * 4 * vertexBufferArrayInserts, vertexBufferArray);
这些是我的glVertexAttribPointer电话:
shaderPosAttrib = glGetAttribLocation(shaderProgram, "position");
glVertexAttribPointer(shaderPosAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position));
glEnableVertexAttribArray(shaderPosAttrib);
shaderTexCoordAttrib = glGetAttribLocation(shaderProgram, "texCoord");
glVertexAttribPointer(shaderTexCoordAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, texCoords));
glEnableVertexAttribArray(shaderTexCoordAttrib);
shaderColorAttrib = glGetAttribLocation(shaderProgram, "color");
glVertexAttribPointer(shaderColorAttrib, 1, GL_UNSIGNED_INT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, color));
glEnableVertexAttribArray(shaderColorAttrib);
Run Code Online (Sandbox Code Playgroud)
这是顶点结构
struct Vertex
{
Vector2<GLfloat> position;
Vector2<GLfloat> texCoords;
GLuint color;
Vertex() {
}
Vertex(Vector2<GLfloat> position, Vector2<GLfloat> texCoords, GLuint color) {
this->position = position;
this->texCoords = texCoords; …Run Code Online (Sandbox Code Playgroud)