Sometimes you need to decompose the OpenGL projection matrix into its original components to adjust some values. Here’s how to do that. I found a thread on stackoverflow on the subject. The formulas there are in row-major format though, but OpenGL is column-major, so they need to be swapped around: For a perspective matrix: ForContinue reading “Decompose the OpenGL projection matrix”
Tag Archives: opengl
Reading the OpenGL backbuffer to system memory
Sometimes you are in the need to read back the OpenGL backbuffer, or other framebuffers. In my case the question was how to read back a downsampled framebuffer resp. its texture to system memory. There are different methods for this and I wrote a small benchmark to test them on various systems. UPDATE #1: AContinue reading “Reading the OpenGL backbuffer to system memory”
Using FrameBufferObjects in shaders
Using FrameBufferObjects in shaders would go something like this: Set up your FBO (see here). Render scene while writing values to gl_FragColor and gl_FragDepth (in our case). You could also have more draw buffers, then you could also write to gl_FragData[0-9]. Keep in mind, that values will be clamped to [0,1] unless you use glClampColorContinue reading “Using FrameBufferObjects in shaders”
FrameBufferObjects in OpenGL
FrameBufferObjects are basically off-screen frame buffers, similar to the regular frame buffer you are normally rendering to. Using FBOs in OpenGL you can do some nice stuff like post-processing or rendering to a texture. There’s a difference between: FrameBufferObjects: FBOs can be bound to / used as a texture, but performance may be lower. RenderbufferObjects:Continue reading “FrameBufferObjects in OpenGL”