Jump to content

  • Log In with Google      Sign In   
  • Create Account

Madd

Member Since 28 Jun 2012
Offline Last Active Nov 14 2014 09:28 AM

Posts I've Made

In Topic: OpenGL suddenly won't draw buffers?

27 September 2014 - 10:55 AM

My guess would be that the shader compiler is optimizing out the 'inNormal' attribute resulting in glEnableVertexAttribArray raising invalid value (-1 for an attribute index).

I think so too, but that shouldn't stop the model from being rendered.


In Topic: OpenGL suddenly won't draw buffers?

27 September 2014 - 09:39 AM

I think in your model constructor, you need to bind your VBO after you have bound your VAO. The "current VBO" binding is associated with the currently bound VAO; it is not global state. As a result, your calls to glVertexAttribPointer aren't actually referring to any VBOs at all.
 

glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
 
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(Model::Vertex)*count, vertices, GL_DYNAMIC_DRAW);
 
glEnableVertexAttribArray(attrVertex);
glEnableVertexAttribArray(attrTexCoords);

 

Something like that should work.

 

As an extra, after you've bound the VBO there's no need to unbind it afterwards, or to rebind it before (or after) binding the VAO again.

I have changed it now and it still does not work. I'm sure the matrices are correct because it worked before.


In Topic: OpenGL doesn't draw triangle

07 May 2014 - 11:37 AM

Thank you, that answers everything smile.png

 

EDIT: Do I have to bind both the VBO and VAO before calling glDrawArray()? Or do I just need to bind the VAO?


In Topic: OpenGL doesn't draw triangle

07 May 2014 - 11:06 AM

Thanks for the replies. I don't fully understand this though. If I create a VAO, and set up the vertex attributes with glVertexAttribPointer(), it tkaes the data from the currently-bound VBO, right? And before I call glDrawArrays(), do I have to bind into the VAO, or the VBO as well? And if I update the VBO, using glBufferData() or OpenCL, do those changes automatically affect the VAO, or do I have to create the VAO again?


In Topic: GLSL 1.5 and Sending Vertices

16 July 2013 - 09:53 AM

 

 

Pretty sure gl_FragColor is deprecated in glsl version 150.

I'm sorry, I tried upvoting your post and accidentally clicked the wrong thing and now i don't know how to reverse it -.-

Unfortunately, votes are final immediately. I would definitely like to see some grace period though so silly mistakes like that can be corrected. I'll bump him up a step so the post doesn't show a -1 at least.

 

If gl_FragColor is deprecated, then how do I tell the GPU what color the pixel should be??

You use custom out variables in the fragment shader, just like the inputs to the vertex shader are custom in variables. The variable on location 0 goes to the primary render target, the variable on location 1 goes to the second render target, and so on. If you're not working with multiple render targets, then just define an out variable in the fragment shader and write to it.

 

Aaah, thanks, that makes sense. Thank you to everyone who helped :)


PARTNERS