View Full Version : how to transform using shaders without deprecated?

10-30-2008, 10:39 AM
On my GL3 programming journey, i'm trying to use as little deprecated GL 2.1 features as possible, while i save enough money for a GL3 capable card.
But I got stuck reading the GLSL 1.3 spec.
I'm trying to do 3d trasnformations (probably a rotating cube) using as little of the fixed pipeline as possible (so, VBOs and Shaders, instead of Begin/End and Fixed Matrix operations) and I thought that using gl_ModelViewMatrix and gl_ProjectionMatrix in my shader was THE way.
But now i've seen that they're deprecated!! :eek:
so, would anyone tell me how is it suposed to be done?
Thanks in advance! :D

10-30-2008, 10:53 AM
Build your own matrix stack replacement and use a 4x4 uniform matrix....

10-30-2008, 11:30 AM
glLoadMatrix* is nice but deprecated ^_^

but the proper OpenGL 2.0/3.0 way is glUniformMatrix4fv :)

However It seams to me to be already deprecated ...
AKA D3D10 common buffer... XD

So that you will load your matrix this way:
glBindBuffer(GL_UNIFORM_BUFFER_EXT, BufferName);
glBufferData(GL_UNIFORM_BUFFER_EXT, BufferSize, BufferData, GL_STATIC_READ);

Other way is:
glBindBuffer(GL_UNIFORM_BUFFER_EXT, BufferName);
glUniformBufferEXT(programName, bindableBufferUniform, BufferName);
glUniformMatrix4fv(BufferUniform, 1, GL_FALSE, BufferData);

With BufferData containing all you uniform data, including your matrices. Could seams complicated but actually the first bindable buffer way could be the only calls for all uniform variable and the second way could be use to just update specifique par of the buffer (with glBufferSubData)

Just nice!!! :)
That's definitly the next feature I want being included in OpenGL core !!!