How to properly render to a texture in OpenGL 3.1
This will be my first time rendering to anything other than the default frame buffer, and my searches suggest that FBOs are the way to go for this task. Actually, they appear to be the only method from what I have seen - please correct me if I am wrong on this.
I am specifically trying to limit myself to OpenGL functionality that has been core since 3.1 . According to the OpenGL wiki, FBOs have been core since 3.0.
I've found a large number of resources on setting up FBOs and how to attach textures to them, but they all use functions that (according to the OpenGL wiki) have only been core since 3.2 (for example, glFrameBufferTexture and glFrameBufferTextureLayer).
What is the proper/recommended method to render to a texture using OpenGL 3.1 or below ? It should be noted that I will need a depth buffer for what I am rendering (a feature that FBO's provide).
NOTE: I originally titled this "How to attach a texture to a Frame Buffer Object in OpenGL 3.1.", but went with a more general title in-case there are other options.
Actually, they appear to be the only method from what I have seen - please correct me if I am wrong on this.
There's also PBuffers, but you don't want to use those. They're cumbersome to work with, difficult to set up and may get their contents invalidated at inconvenient times. For reference: PBuffers are kind of invisible windows. They're pretty useless by themself, because they can't render to a texture; ie you had to copy to a texture after rendering to a PBuffer. Then an extension was introduced to allow binding a PBuffer as a texture.
Don't bother with them.
I am specifically trying to limit myself to OpenGL functionality that has been core since 3.1
Actually Framebuffer Objects have been around for much, much longer. And because they're mostly a memory management thing, even the oldest GPU can actually support them; at least if you're making their format resemble a typical on-screen framebuffer.
Until OpenGL-3 Framebuffer Objects were a so called extension, and if you look at the framebuffer object extension's specification ARB_framebuffer_object you'll see that they've been approved against at that time 12 year old OpenGL-1.1; work on it began already some time earlier in the form of the EXT_framebuffer_object extension.
So, well, they're pretty much well supported. If you're limiting yourself to OpenGL-3 you don't have to bother with it, but if you wanted to support a wider range of hardware (like my most recent project does; OpenGL-2.1 is the target) then you'll have to use that extension.
according to the OpenGL wiki
The OpenGL wiki is not the authorative reference. The specifications are. And according to the OpenGL-3.0 those functions are part of specified functionality. Note that OpenGL did introduce core and compatiblity profiles only with OpenGL-3.2, so that's why you're not going to find anything core for before OpenGL-3.2
链接地址: http://www.djcxy.com/p/34058.html上一篇: 渲染到纹理