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; i.e. 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

其他提示

What Windows version do you use? If you have at least an Intel HD 3000 and use Windows 10 then consider downgrading to Windows 7 and reinstalling the drivers because Windows 7 works well with most apps, For example: I used Windows 10 and when I tried to use GZDoom to play Doom, it said to use the vintage version because I don't have OpenGL 3.3 as Intel HD 3000 only supports upto OpenGL 3.1. While both the Windows use OpenGL 3.1, Windows 7 tends to have more compatibility with features. Back to the example, after I downgraded to Windows 7, I tried installing it again and it seemed to launch without the help of any patch or tweak. So this might be useful.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top