• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

150 Neutral

About mrr

  • Rank
  1. [quote name='V-man' timestamp='1302619821' post='4797519'] Of course, if you are setting up the VAO and suddenly call glBindBuffer(.....,0); then you are messing it up. This is a good example: [url="http://www.opengl.org/wiki/Tutorial1:_Rendering_shapes_with_glDrawRangeElements,_VAO,_VBO,_shaders_%28C%2B%2B_/_freeGLUT%29"]http://www.opengl.or...B_/_freeGLUT%29[/url] [/quote] 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. [quote name='mhagain' timestamp='1302458714' post='4796751'] You've got a potential type mismatch on your function pointer; should be void (GLAPIENTRY *glUniformNfv[4])(GLint location,GLsizei count,const GLfloat * value); [/quote] 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(ibo.target,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.. [code] 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; }; [/code] Then I have a VAO class..I only show the important part (Bo:s already added before calling CreateVAO() ) [code] // 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(!ibo.name.empty()) { glGenBuffers(1,&ibo.object); glBindBuffer(ibo.target,ibo.object); glBufferData(ibo.target,ibo.size,ibo.data,ibo.usage); glBindBuffer(ibo.target,0); } } else LogError(-1,"%s","No buffer objects added no VAO created."); } [/code] Then I have a function for drawing.. [code]void Vao::DrawVAO() { Bind(); if(!ibo.name.empty()) { 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(); } [/code] 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: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showthreaded&Number=251861 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 flexible..you 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. [quote name='JackTheRapper' timestamp='1302362916' post='4796371'] When does the class get instantiated? edit: beat me to the punch [/quote] I do not know.. I am C programmer dabbling with C++..
  8. [quote name='Danny02' timestamp='1302364841' post='4796386'] I'm not so sure if this will be fast. I'm no C expert, but I think that switch cases are similar handled in assembler as array lookups. And using a function pointer gives extra overhead [/quote] 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. [quote name='V-man' timestamp='1302290615' post='4796067'] You could make a backwards compatible context and use all the "oldies". [/quote] I am using the compatible profile, but I try to remove all deprecated functions anyway.
  12. [quote name='triangles' timestamp='1302289526' post='4796063'] [quote name='mrr' timestamp='1302288677' post='4796059'] 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 ? [/quote] 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. [quote name='Aks9' timestamp='1298754878' post='4779439'] Well, more than an year ago, I thought that Z-buffer caused my problems with the precision. I was also excited with logarithmic Z-buffer, but then I realized that jitter was the cause of it and GPU RTE was right way to solve it. Using logarithmic Z-buffer and inverting planes may prevent early-z and other similar techniques for early fragment discarding. Now I live happily with 24-bit Z-buffer although rendering very huge terrains. [/quote] 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