2016-09-01 2 views
1

Ce code fonctionne très bien dans l'OpenGL 3.0 hérité, mais échoue dans le mode compatible avant (4.1 et 3.3 sur mon installation). Je l'ai testé sur le matériel et les implémentations du logiciel. J'utilise SDL pour obtenir le contexte OpenGL, et GLEW pour trouver des fonctions. Ajouter la ligne ci-dessous à mon code fait le problème.OpenGL 3.0 glVertexAttribPointer: l'ancien fonctionne, compatible avant (core) ne fonctionne pas

SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); 

La partie problématique de code est appel à glVertexAttribPointer

glBindBuffer(GL_ARRAY_BUFFER, glb.vbo); 
glBufferData(
    GL_ARRAY_BUFFER, 
    size * sizeof(GLfloat), 
    input, 
    GL_DYNAMIC_DRAW 
); 
test_gl_errors(); /* GL_NO_ERROR */ 

glUseProgram(glb.program); 
glEnableVertexAttribArray(glb.vert_array); 
glEnableVertexAttribArray(glb.colour_array); /* I use this later. */ 

test_gl_errors(); /* GL_NO_ERROR */ 
glVertexAttribPointer(
    glb.vert_array, 
    2, 
    GL_FLOAT, 
    GL_FALSE, 
    5 * sizeof(GLfloat), 
    0 
); 
test_gl_errors(); /* GL_INVALID_OPERATION */ 

Je voudrais ajouter plus de code, mais il y a beaucoup de choses. Lire les informations du lien ci-dessous ne m'a pas aidé. Aucune suggestion?
https://www.opengl.org/sdk/docs/man/html/glVertexAttribPointer.xhtml

Ma configuration OpenGL:

  • Gallium 0,4 sur AMD CAP-VERT (DRM 2.45.0/4.7.2-1-ck, LLVM 3.8.1)
  • Gallium 0,4 sur llvmpipe (LLVM 3.8, 128 bits)
  • Mesa3D: 12.0.1
+0

Avez-vous un VAO lié lorsque vous passez l'appel? Ils sont requis dans le profil de base. –

+0

@RetoKoradi J'ai ajouté un peu plus de code. – Michas

+1

Je ne vois toujours pas de VAO. Il doit y avoir des appels 'glGenVertexArray()' et 'glBindVertexArray()' quelque part avant cela. –

Répondre

1

Le code de travail, en fonction des commentaires de Reto Koradi.

glBindVertexArray(GL_ARRAY_BUFFER, glb.vao); /* <-- NEW !!! */ 
glBindBuffer(GL_ARRAY_BUFFER, glb.vbo); 
glBufferData(
    GL_ARRAY_BUFFER, 
    size * sizeof(GLfloat), 
    input, 
    GL_DYNAMIC_DRAW 
); 

glUseProgram(glb.program); 
glEnableVertexAttribArray(glb.vert_array); 

glVertexAttribPointer(
    glb.vert_array, 
    2, 
    GL_FLOAT, 
    GL_FALSE, 
    5 * sizeof(GLfloat), 
    0 
); 
test_gl_errors(); /* GL_NO_ERROR */