OpenGL 3.2 code samples

rpg.314

Veteran
Just had a look at the opengl quick reference card. So much of the API has been deprecated that it makes my head spin looking at all those blues...:rolleyes:

Does any one know of any sample code (must be free as in gratis) that uses modern API? Any source I may look towards? Most of the stuff on the web I find is tied in an essential way to the deprecated parts of the API/pipeline?

Thanks

EDIT: It must NOT use any feature of the API/pipeline that is deprecated. I am looking towards something that runs on linux. However, if it is something that is source-portable, ie with SDL/glut etc., then it is OK too.
 
VAO is completely something different. It is object that stores all vertex array pointers and which of them are enabled/disabled.
So basically you can do following:
Code:
// on init
vao1 = glGenVAO();
glBindVAO(vao1);
glEnableVertexPointer(0);
glEnableVertexPointer(1);
glBindBuffer(vbo);
glVertexAttribPointer(0, ..., offset0);
glVertexAttribPointer(0, ..., offset1);
gllBindVOA(0);

// on render
glBindVAO(vao1)
glDrawArrays(GL_TRIANGLES, ...);

glBindVAO(vao2)
glDrawArrays(GL_TRIANGLES, ...);

No need to rebind/reenable all those VBO's and vertex attribs for each draw call.
 
But that means that it is client side storage and all the data has to be sent back to the GPU on each render call. Isn't it? So wouldn't that affect perf?
 
What is client side storage? Vertex data? If you use VBO, then all vertex data is not on client side. And VA (Vertex Arrays) are deprecated in GL3 core profile - so only option is to use VBO.
VAO should theoretically only increase performance - because instead of multiple GL function calls, you now need to call only one function (binding correct VAO).
 
Question: Then whay weren't they (vbo) deprecated in gl3? After all, vao are the preferred method in gl3 and newer right?

Q2: regarding nvidia'a bindless graphics extension, is this how dx10 operates? letting app take care of the gpu mem addresses? or is it just nv's hw quirk?
 
No, you don't understand. VAO can not be used without VBO. (I misunderstood your "VAO over VBO" text before - that's why I said yes. English is not my native language).

VBO provides vertex data (positions, normals, colors, texture coordinates, anything else) to input of vertex shader.
To get this data to vertex shader, you need to bind and enable vertex attribute pointer (glVertexAttribPointer and glEnableVertexAttribute) and also you need to bind VBO (buffer just contains raw data, attributes specify what is inside and how to get them to vertex shader).
Before each draw call, if you need to draw something else, you need to rebind/reenable correct attributes to different pointer, and rebind correct VBO.
This is overhead - because you need to call lot of functions for different VBO/vertex attribute setup. And here is where VAO comes in.

VAO stores this VBO binding (which vertex buffer object is currently bound) and all the vertex attribute setup (vertex attribute pointers - their type, stride, count, offset), and which of them are enabled. Also it stores element array binding, and some other thing (6.4 and 6.5 state tables from 3.2 code spec).

So when you want to setup different VBO/vertex attribute setup, you just bind VAO, and it setups everything (glBindBuffer & glVertexAttribPointer & glEnable/DisableVertexAttrib).

About blindness extension I don't know much.
 
VAO is essentially doing the same thing as vertex declarations in DirectX, except that it stores more than just the vertex format but also what buffers they come from.

As for bindless, I assume you mean GL_EXT_direct_state_access, which just allows you to modify objects without binding them first. DirectX never had the bind-to-modify model. So yes, with that extension you do things a bit more like DirectX does.
 
Back
Top