Rotating a Group of Vectors

Construct 4×4 transform matrix instead of Quaternions. Do not forget that OpenGL has column wise matrix so for double m[16]; is X axis vector in m[ 0],m[ 1],m[ 2] is Y axis vector in m[ 4],m[ 5],m[ 6] is Z axis vector in m[ 8],m[ 9],m[10] and position is in m[12],m[13],m[14] The LCS mean local … Read more

glVertexAttribPointer and glVertexAttribFormat: What’s the difference?

glVertexAttribPointer has two flaws, one of them semi-subjective, the other objective. The first flaw is its dependency on GL_ARRAY_BUFFER. This means that the behavior of glVertexAttribPointer is contingent on whatever was bound to GL_ARRAY_BUFFER at the time it was called. But once it is called, what is bound to GL_ARRAY_BUFFER no longer matters; the buffer … Read more

How to render depth linearly in modern OpenGL with gl_FragCoord.z in fragment shader?

but I still don’t know whether or not the gl_FragCoord.z is linear. Whether gl_FragCoord.z is linear or not depends on, the projection matrix. While for Orthographic Projection gl_FragCoord.z is linear, for Perspective Projection it is not linear. In general, the depth (gl_FragCoord.z and gl_FragDepth) is calculated as follows (see GLSL gl_FragCoord.z Calculation and Setting gl_FragDepth): … Read more

About OpenGL texture coordinates

Texture coordinates specify the point in the texture image that will correspond to the vertex you are specifying them for. Think of a rectangular rubber sheet with your texture image printed on it, where the length of each side is normalized to the range 0-1. Now let’s say you wanted to draw a triangle using … Read more