PDA

View Full Version : VAO, VBO code broken by Catalyst 11.11 & 11.12



NoDocs
12-18-2011, 03:29 PM
Hi,

I have some Windows 7 code that works under ATI's Catalyst 11.8 but does not under 11.12 or 11.11: I have not tried 11.9 or 11.10.



void SimpleTriangle::setupVBOs()
{
float positionData[] =
{
-0.8f, -0.8f, 0.0f,
0.8f, -0.8f, 0.0f,
0.0f, 0.8f, 0.0f
};

float colorData[] =
{
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f
};

GLubyte indices[] =
{
0, 1, 2
};

GLenum err(glGetError());
// Create and populate the buffer objects
enum { VERTICES, COLORS, INDICES, NUM_VBOS };
GLuint vboHandles[NUM_VBOS];
m_glex->glGenBuffers(NUM_VBOS, vboHandles);

m_glex->glBindBuffer(GL_ARRAY_BUFFER, vboHandles[VERTICES]);
m_glex->glBufferData(GL_ARRAY_BUFFER, sizeof(positionData), positionData, GL_STATIC_DRAW);

m_glex->glBindBuffer(GL_ARRAY_BUFFER, vboHandles[COLORS]);
m_glex->glBufferData(GL_ARRAY_BUFFER, sizeof(colorData), colorData, GL_STATIC_DRAW);

m_glex->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboHandles[INDICES]);
m_glex->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

// Create and set-up the vertex array object
m_glex->glGenVertexArrays( 1, &m_VAO );
m_glex->glBindVertexArray(m_VAO);

m_glex->glEnableVertexAttribArray(0); // Vertex position
m_glex->glEnableVertexAttribArray(1); // Vertex color

m_glex->glBindBuffer(GL_ARRAY_BUFFER, vboHandles[VERTICES]);
m_glex->glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte *)NULL );

m_glex->glBindBuffer(GL_ARRAY_BUFFER, vboHandles[COLORS]);
m_glex->glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte *)NULL );

m_glex->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboHandles[INDICES]);
err = glGetError();
}


and



void SimpleTriangle::render()
{
float mvpMatrix[16];
GetOGLFixedFunctionMVPMatrix(mvpMatrix);

GLenum err(glGetError());
m_shaderPrograms[0]->use();
m_shaderPrograms[0]->sendUniform("MVPMatrix", mvpMatrix);
m_glex->glBindVertexArray(m_VAO);
glDrawElements(GL_TRIANGLE_STRIP, 3, GL_UNSIGNED_BYTE, 0);

m_glex->glUseProgram(0);
err = glGetError();
}


No gl errors are found when run under Catalyst 11.12. Just a window of background colour. Immediate mode works just as usual - OK.

Am I doing something wrong for 11.12? Is it a question of 11.12 being more rigorous to the OpenGL specs? Or can it be the 11.12 is itself in error?

Thanks

Sam

tksuoran
12-19-2011, 04:01 AM
How do you map vertex attribute indices 0 and 1 to position and color?

NoDocs
12-19-2011, 07:02 AM
tksuoran,



void SimpleTriangle::setupShaderPrograms()
{
char const * const vShaderFiles[] = {"G:/GlobeProject/Resources/SimpleTriangle/simpletriangle.vert", 0};
char const * const fShaderFiles[] = {"G:/GlobeProject/Resources/SimpleTriangle/simpletriangle.frag", 0};

m_shaderPrograms.push_back(GLSLProgram::CreateGLSL Program(m_glex));

m_shaderPrograms[0]->compileShaderFromFile(vShaderFiles[0], GLSLProgram::VERTEX );
m_shaderPrograms[0]->compileShaderFromFile(fShaderFiles[0], GLSLProgram::FRAGMENT );

// bind attributes here before linking
GLenum err(glGetError());
m_shaderPrograms[0]->bindAttrib(0, "VertexPosition");
m_shaderPrograms[0]->bindAttrib(1, "VertexColor");
err = glGetError();

m_shaderPrograms[0]->link();
}


I have a class GLSLProgram whose method for this is defined as:


void GLSLProgram::bindAttrib(GLuint index, std::string const & attribName) const
{
m_glex->glBindAttribLocation(m_programID, index, attribName.c_str());
}


This code is run before SimpleTriangle::setupVBOs()
as shown in the original post.