How did you learn modern OpenGL?

Started by
14 comments, last by Yours3!f 12 years, 11 months ago

[quote name='jeroenb' timestamp='1305698281' post='4812269']
but you can also move objects using the shaders using the uniform data variables of shaders. You then only have to tranform the matrix in the shader.


it is NOT a good idea, because moving stuff around in the vertex shader would be a per-vertex operation, resulting in poor vertex processing performance.
see this post:
http://www.gamedev.n...light-position/
[/quote]

In that post he mentions not to do per vertex operations on the CPU, but leave it to the GPU (thus in a shader). I haven't tried, but I do not think that there will be much performance loss when you transform a vertex by adding a pre-computed offset (e.g. by a physics engine) to it in the shader instead of setting the transform using (in OpenGL) glTransform.

Crafter 2D: the open source 2D game framework

?Github: https://github.com/crafter2d/crafter2d
Twitter: [twitter]crafter_2d[/twitter]

Advertisement

[quote name='Yours3!f' timestamp='1305745679' post='4812680']
[quote name='jeroenb' timestamp='1305698281' post='4812269']
but you can also move objects using the shaders using the uniform data variables of shaders. You then only have to tranform the matrix in the shader.


it is NOT a good idea, because moving stuff around in the vertex shader would be a per-vertex operation, resulting in poor vertex processing performance.
see this post:
http://www.gamedev.n...light-position/
[/quote]

In that post he mentions not to do per vertex operations on the CPU, but leave it to the GPU (thus in a shader). I haven't tried, but I do not think that there will be much performance loss when you transform a vertex by adding a pre-computed offset (e.g. by a physics engine) to it in the shader instead of setting the transform using (in OpenGL) glTransform.
[/quote]


Well now I just heard about matrices and multiplying them to the verts. It would kinda be like legacy GL but with your own matrices.

In that post he mentions not to do per vertex operations on the CPU, but leave it to the GPU (thus in a shader). I haven't tried, but I do not think that there will be much performance loss when you transform a vertex by adding a pre-computed offset (e.g. by a physics engine) to it in the shader instead of setting the transform using (in OpenGL) glTransform.
[/quote]

well, I only meant that it you think in massive scale (like a million polys) then it will probably be bad to do everything per-vertex.

Well now I just heard about matrices and multiplying them to the verts. It would kinda be like legacy GL but with your own matrices.
[/quote]

maths libraries are like legacy GL, but they're (supposed to be) faster than the GL functions.
Look at my link if you want matrix functions that look like GL.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
looks nice :)

This topic is closed to new replies.

Advertisement