fork download
  1. void shader_draw(shader* this, unsigned int vbo_id, unsigned int vertex_count, GLenum draw_mode) {
  2. if (this == NULL) {
  3. debug_warning("[shader_draw] this cannot be NULL");
  4. return;
  5. }
  6.  
  7. this->bind(this); /* Not usually here. Putting it here doesn't seem to help. Makes appropriate calls to glUseProgram() */
  8.  
  9. if (this->vertex_array_object_id == 0) {
  10. /* No VAO initialized yet, we create one just in time */
  11.  
  12. glGenVertexArrays(1, &this->vertex_array_object_id); /* Generate and bind the VAO so we can set the values. */
  13. glBindVertexArray(this->vertex_array_object_id);
  14.  
  15. glEnableVertexAttribArray(0); /* Enable vertex attributes. */
  16. glEnableVertexAttribArray(1);
  17.  
  18. glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, NULL); /* Set up the shader vertex format (XY position, XY texcoord) */
  19. glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*) (sizeof(float) * 2));
  20. }
  21.  
  22. glBindVertexArray(this->vertex_array_object_id); /* Binds correct VAO. Each shader has been confirmed to have a seperate stored VAO. ? */
  23. glBindBuffer(GL_ARRAY_BUFFER, vbo_id); /* Should be binding unique target VBO, passed as argument */
  24.  
  25. glDrawArrays(draw_mode, 0, vertex_count); /* Draw VBO to screen. Textures are handled earlier and don't seem to be much of a problem */
  26.  
  27. /* When drawn, it seems to take VBOs from different VAOs, resulting in really odd distortion */
  28. }
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:18: error: unknown type name ‘shader’
 void shader_draw(shader* this, unsigned int vbo_id, unsigned int vertex_count, GLenum draw_mode) {
                  ^
prog.c:1:80: error: unknown type name ‘GLenum’
 void shader_draw(shader* this, unsigned int vbo_id, unsigned int vertex_count, GLenum draw_mode) {
                                                                                ^
stdout
Standard output is empty