Opengl 3.3 doesn't draw anything. Using GLSL 330 Core

后端 未结 1 422
感动是毒
感动是毒 2021-01-17 02:46

I am following the guides from this site and have stopped on the lesson 2. At first I have tried wiriting my own code but after it didn\'t work I have simply taken the code

相关标签:
1条回答
  • 2021-01-17 03:14

    The OpenGL Core Profile requires the use of Vertex Array Objects (VAOs). This is in the "Deprecated and Removed Features" of the spec:

    Client vertex and index arrays - all vertex array attribute and element array index pointers must refer to buffer objects. The default vertex array object (the name zero) is also deprecated. Calling VertexAttribPointer when no buffer object or no vertex array object is bound will generate an INVALID_OPERATION error, as will calling any array drawing command when no vertex array object is bound.

    The tutorial you are using suggests to use this code as part of your initialization:

    GLuint VertexArrayID;
    glGenVertexArrays(1, &VertexArrayID);
    glBindVertexArray(VertexArrayID);
    

    This will be enough to get the tutorial code working. To make productive use of VAOs in more complex applications, you will probably want to create a VAO for each object. This will then track the full vertex setup state for the object, and allow you to set the state with a single glBindVertexArray() call before drawing.

    0 讨论(0)
提交回复
热议问题