问题描述
我想获得一个模板缓冲区,但是如果可能的话,不会承受附加深度缓冲区的开销,因为我不会使用它。我发现大多数资源建议,虽然模板缓冲区是可选的(不包括它有利于获得更深的缓冲区精度,例如)我没有看到任何请求并成功获得只有8位模板缓冲区的代码。我看到的最常见的配置是24位深度缓冲区和8位模板缓冲区。
是否可以只使用一个彩色缓冲区的模板缓冲区?
如果可能,大多数OpenGL实现是否会授予此请求?
版本我使用的是2.0
m使用调用OpenGL是SFML,它通常不支持它的FBO包装器对象的模板分配,虽然它允许它的显示表面的帧缓冲区。我在自己编辑功能,虽然那是我被困住的地方。
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH24_STENCIL8_EXT,width,height));
此行决定了我假设的存储类型。但是, GL_DEPTH24_STENCIL8_EXT
是我发现的唯一一个定义了模板缓冲区创建的定义。 (至少没有GL_STENCIL8或类似的东西)
研究 GL_STENCIL_INDEX8
在评论中提到,我在官方OpenGL wiki中遇到了以下行,
测试两种不同的分配方案, GL_STENCIL_INDEX8_EXT
vs GL_DEPTH24_STENCIL8_EXT
,结果大致相等,无论是在内存使用和性能。我怀疑它填充模板缓冲区与24位无论如何。因此,为了便于移植,只需使用深度和模板打包方案。
I would like to acquire a stencil buffer, but not suffer the overhead of an attached depth buffer if it's possible, since I wouldn't be using it. Most of the resources I've found suggest that while the stencil buffer is optional (excluding it in favour of gaining more depth buffer precision, for example) I have not seen any code that requests and successfully gets only the 8-bit stencil buffer. The most common configuration I've seen being 24 bit depth buffers with an 8 bit stencil buffer.
Is it possible to request only a stencil buffer with a color buffer?
If it is possible, Is it likely the request would be granted by most OpenGL implementations?
The OpenGL version I'm using is 2.0
edit:
The API I'm using to call OpenGL is SFML, which normally doesn't support stencil allocation for it's FBO wrapper objects, though it allows it for the display surface's framebuffer. I edited the functionality in myself, though that's where I'm stuck.
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height));
This line decides the storage type I assume. However, GL_DEPTH24_STENCIL8_EXT
is the only define I've found that specifies a stencil buffer's creation. (there's no GL_STENCIL8 or anything similar at least)
Researching GL_STENCIL_INDEX8
that was mentioned in the comments, I came across the following line in the the official OpenGL wiki, http://www.opengl.org/wiki/Framebuffer_Object_Examples#Stencil
Stress testing the two different allocation schemes, GL_STENCIL_INDEX8_EXT
vs GL_DEPTH24_STENCIL8_EXT
, the results were roughly equal, both in terms of memory usage and performance. I suspect that it padded the stencil buffer with 24bits anyway. So for sake of portability, going to just use the depth and stencil packed scheme.
这篇关于OpenGL:只获取模板缓冲区和深度缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!