Skip to main content
GameDev.net gamedev.net
🔒 Locked

glBindVertexBuffer, glVertexAttribFormat, & glVertexAttribBinding Questions/Issues

Started by Shawn Myers Oct 12, 2012 at 12:58 AM 1 replies 4.1k views
Original Post
Shawn Myers
Shawn Myers
Hey all,

I've recently been in the process of moving from the DirectX/XNA camp to the OpenlGL side of things as of late. I've found the process very interesting and fun so far, but I keep running into an issue that has been irking me. Perhaps someone here can help.

I have been attempting to set up the Vertex Attribute Layout using the glBindVertexBuffer, glVertexAttribFormat, & glVertexAttribBinding commands, but I get a "0xC0000005: Access violation reading location 0x00000000" when glBindVertexBuffer is encountered. Are these commands supported in OpenGL 4.2? I tried to do some research to find what version these functions were introduced, but I haven't found anything specific as of yet.

In the case that they are supported in OpenGL 4.2, here is the setup code I am using:
[source lang="cpp"] //Interleave position, color, and UV data.
const float vertexData[] =
{
//Vertex 0
-.50f, .50f, 0.0f, 1.0f,
1.0f, 0.0, 0.0, 1.0f,
0.0f, 0.0f,

//Vertex 1
.50f, .50f, 0.0f, 1.0f,
0.0, .50, 0.0, 1.0f,
1.0f, 0.0f,

//Vertex 2
.50f, -.50f, 0.0f, 1.0f,
0.0, 0.0, 1.0, 1.0f,
1.0f, 1.0f,

//Vertex 3
-.50f, -.50f, 0.0f, 1.0f,
.50, .50, 1.0, 1.0f,
0.0f, 1.0f
};

//Build our 'vertex buffer'
glGenBuffers(1, &bufferName);
glBindBuffer(GL_ARRAY_BUFFER, bufferName);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);

//Create the 'IA Layout'
//We crash right here
glBindVertexBuffer(0, bufferName, 0, sizeof(float) * 10);
glEnableVertexAttribArray(0);
glVertexAttribFormat(0, 4, GL_FLOAT, GL_FALSE, 0);
glVertexAttribBinding(0, 0);

glEnableVertexAttribArray(1);
glVertexAttribFormat(1, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4);
glVertexAttribBinding(1, 0);

glEnableVertexAttribArray(2);
glVertexAttribFormat(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 8);
glVertexAttribBinding(2, 0);

/* This will set up things fine */
//glEnableVertexAttribArray(0);
//glVertexAttribPointer(0, 4, GL_FLOAT, false, sizeof(float) * 10, reinterpret_cast(0));

//glEnableVertexAttribArray(1);
//glVertexAttribPointer(1, 4, GL_FLOAT, false, sizeof(float) * 10, reinterpret_cast(sizeof(float) * 4));

//glEnableVertexAttribArray(2);
//glVertexAttribPointer(2, 2, GL_FLOAT, false, sizeof(float) * 10, reinterpret_cast(sizeof(float) * 8));[/source]


I'm using GLEW and I'm running Visual Studio 2010. I'm guessing that it may not be supported on 4.2, and thus GLEW is returning a null pointer to the function it can't find, but I want to be sure.
21st Century Moose
21st Century Moose
These are OpenGL 4.3; currently only NVIDIA have a GL4.3 driver available, and even that's just in beta.
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.