| 54 | } |
| 55 | |
| 56 | GLuint vaoColorCreate(const VertexColorSolid* verticies, int size){ |
| 57 | //create vertex buffer object |
| 58 | GLuint vao; |
| 59 | glGenVertexArrays(1, &vao); |
| 60 | glBindVertexArray(vao); |
| 61 | |
| 62 | GLuint vbo; |
| 63 | glGenBuffers(1, &vbo); |
| 64 | glBindBuffer(GL_ARRAY_BUFFER, vbo); |
| 65 | //copy the vertex data to VRAM |
| 66 | glBufferData(GL_ARRAY_BUFFER, size, verticies, GL_STATIC_DRAW); //store in VRAM |
| 67 | |
| 68 | //define position attribute location |
| 69 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(VertexColorSolid), (void*)offsetof(VertexColorSolid, position)); |
| 70 | glEnableVertexAttribArray(0); |
| 71 | //define texCoord attribute location |
| 72 | glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(VertexColorSolid), (void*)offsetof(VertexColorSolid, color)); |
| 73 | glEnableVertexAttribArray(1); |
| 74 | |
| 75 | //unbind |
| 76 | glBindVertexArray(0); //unbind VAO |
| 77 | |
| 78 | //check for problems: |
| 79 | GLenum err = glGetError(); |
| 80 | if (err != GL_NO_ERROR){ |
| 81 | glDeleteBuffers(1, &vbo); |
| 82 | SDL_Log("Creating VBO failed: %u\n", err); |
| 83 | vbo = 0; |
| 84 | } |
| 85 | return vao; |
| 86 | } |
| 87 | |
| 88 | GLuint vaoTextCreate(const VertexBasic* verticies, int size){ |
| 89 | //create vertex buffer object |
no outgoing calls
no test coverage detected