Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

150 Neutral

About mrr

  • Rank
  1. Apparently not for the GL_ARRAY_BUFFER if it is done after glVertexAttribPointer().. But since the GL_ELEMENT_ARRAY_BUFFER has no attribute this does not work for it.
  2. No according to opengl standard they are all void. Now If I needed to find the pointer like Glew does then I think you are right..but that is already done by Glew.
  3. Ok it seems I found the problem.. You should not do: glBindBuffer(,0); Before glBindVertexArray(0); It is fine for the other buffers because the states are saved when glVertexAttribPointer() is called.. I am not 100% on that last thing though.
  4. Ok here is some source.. I have a class for buffer objects like this.. class Bo { public: Bo(); ~Bo(); void Dump(); string name; GLuint object; GLenum target; GLuint vertices; GLint elements_per_vertex; GLint size_of_element; GLenum element_type; bool keep_data; GLvoid *data; GLenum usage; GLint attribute; GLuint size; }; Then I have a VAO class..I only show the important part (Bo:s already added before calling CreateVAO() ) // Creates the vertex array object, Buffer Objects must be added first though void Vao::CreateVAO() { map<string,Bo *>::iterator it; it=bos.begin(); Bo *bo; GLenum error; printf("> Creating Vertex Array Object\n"); if(it!=bos.end()) { glGenVertexArrays(1,&vao); glBindVertexArray(vao); for(;it!=bos.end();it++) { bo=it->second; //bo->Dump(); glGenBuffers(1,&bo->object); glBindBuffer(bo->target,bo->object); printf(" Adding Buffer Object %s to VAO\n",bo->name.c_str()); glBufferData(bo->target,bo->size,bo->data,bo->usage); if((error = glGetError())!=GL_NO_ERROR) LogGLError(error,"%s","glBufferData"); if(bo->attribute>=0) { glVertexAttribPointer(bo->attribute,bo->elements_per_vertex,bo->element_type,GL_FALSE,0,NULL); if((error = glGetError())!=GL_NO_ERROR) LogGLError(error,"glVertexAttribPointer %s",bo->name.c_str()); glEnableVertexAttribArray(bo->attribute); } glBindBuffer(bo->target,0); if(!bo->keep_data) { free(bo->data); bo->data=NULL; } } glBindVertexArray(0); // Indices buffers are treated separately..they do not store with VAO states ? if(! { glGenBuffers(1,&ibo.object); glBindBuffer(,ibo.object); glBufferData(,ibo.size,,ibo.usage); glBindBuffer(,0); } } else LogError(-1,"%s","No buffer objects added no VAO created."); } Then I have a function for drawing.. void Vao::DrawVAO() { Bind(); if(! { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,ibo.object); glDrawElements(GL_TRIANGLE_STRIP,ibo.vertices,ibo.element_type,NULL); } else glDrawArrays(GL_TRIANGLE_STRIP,0,bos["vertices"]->vertices); UnBind(); } If I remove the glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,ibo.object); and do not treat the binding of the IBO separately..thus if I move it inside the glBindVertexArray(vao) glBindVertexArray(0) inside Vao::CreateVAO.. then it crashes on glDrawElements because of the NULL. And Bind() UnBind just glBindVertexArray(vao); and with 0. Also found more people saying the same: Are you sure ?
  5. Or you can just compile and link your shaders and then afterwards ask for the location using. glGetFragDataLocation() Disadvantage is that you need to keep track of this info when you create VAOs etc, you can not just pick a default. Advantage is that it is more are not tied to a default attribute/location definitions.
  6. Hi I am using VAO in opengl 4 and I have to bind the indices buffer separately it seems it can not be stored in the VAO? (Thus a GL_ELEMENT_ARRAY_BUFFER state is not stored in a VAO) I assume this is so because a index ELEMENT does not have a corresponding attribute? Am I right? or do I do something wrong ?
  7. I do not know.. I am C programmer dabbling with C++..
  8. Nah it is probably about the same speed.. I just do not like switch case statements.
  9. I solved it. The initialization of the pointers can not be done in the constructor. Since at that time glew has not started yet..
  10. Hi I am trying to make an array of some opengl functions so I can call them easier, what I am doing is this. In a class: void (*glUniformNfv[4])(GLint location,GLsizei count,const GLfloat * value); In class constructor I initialize pointers to the functions; glUniformNfv[0] = glUniform1fv; glUniformNfv[1] = glUniform2fv; glUniformNfv[2] = glUniform3fv; glUniformNfv[3] = glUniform4fv; And then calling by: glUniformNfv[nitems ](loc,1,data); This way no switch case statement on the number of items (nitems) is needed, and this is faster. However passing the address of the functions glUniform1fv passes null!!! Note they are initialized already by Glew.. (calling them in the normal way works) But here somehow they do not behave like ordinary functions? or is this not allowed in C++ ?
  11. mrr

    Opengl 4 VAO BO ?

    I am using the compatible profile, but I try to remove all deprecated functions anyway.
  12. mrr

    Opengl 4 VAO BO ?

    No, put multiple items into one buffer and draw a specific range with glDrawArrays. VAOs are optional. [/quote] Ok, thanks.
  13. Hello Do I need a buffer object for every little thing I want to draw? (that is irritating!!) Also do the buffer objects need to be inside a VAO or is that optional ?
  14. Yes backface culling is on. I have not implemented LOD yet.. hehe you are right that must help. Thanks.
  15. The problem was only far away and it disappeared with log z buffer..does that not mean it was z buffer precision problem ? What is GPU RTE ?
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!