Combining glVertexPointer and glVertexAttribPointer gives problems

I had a problem when first rendering a vertex buffer with a program, and then rendering another vertexbuffer without a program.

for the first buffer, when the program is on, I use code similar to:

glBindBuffer( GL_ARRAY_BUFFER, m_id ); GLint location = glGetAttribLocation( pID, "position" ); glEnableVertexAttribArray( location ); glVertexAttribPointer( location, 3, GL_FLOAT, GL_FALSE, 3 * sizeof( GLfloat ), 0 ); glDrawArrays( m_mode, 0, m_numVertices ); 

for the second, without a program:

 glBindBuffer( GL_ARRAY_BUFFER, m_id ); glEnableClientState( GL_VERTEX_ARRAY ); glVertexPointer( 3, GL_FLOAT, 3 * sizeof( GLfloat ), 0 ); glDrawArrays( m_mode, 0, m_numVertices ); 

both encodings work fine individually, but when they are executed in the order "with the program" β†’ "without the program", the second one seems to use the buffer of the first, and in the order "without the program" β†’ "with the program" the first is not drawn (in the second iteration) .

now this tells me that i am missing any state change executed by the glEnableVertexAttribArray block, but I don’t understand which state change is causing the problems.

ps the reason why I am rendering with and without the program is that in lib im script mode you can enable or disable programs for node.

+4
source share
1 answer

Try to add

 glDisableVertexAttribArray( location ); // location of "position" 

before switching to rendering a fixed function.

+2
source

Source: https://habr.com/ru/post/1383304/


All Articles