Stencil drawing

BlitzMax Forums/BlitzMax Programming/Stencil drawing

Shagwana(Posted 2005) [#1]
Anyone know how well supported stencil drawing is on computers in general? (esp the stencil buffers of one bit [on/off])


Tom(Posted 2005) [#2]
I think most (if not all) DX7 generation GFX cards have a stencil buffer. 'Fossil' cards probably have a 1bit stencil :P


ImaginaryHuman(Posted 2005) [#3]
As far as I understand it, EVERY OpenGL implementation MUST have at least

a) An RGBA color buffer
b) An RGBA accumulation buffer
c) A stencil buffer
d) A depth buffer
e) An Index-mode color buffer
f) An Index-mode accumulation buffer
g) maybe also index-mode stencil and depth (if that differs?)

I think that's meant to be a minimal requirement of any implementation, so you should be able to rely on it existing. If your graphics card doesn't support such a thing then maybe the OpenGL driver for it will implement that part of things in software?


Dreamora(Posted 2005) [#4]
There are even hardware implementations of stencil that are that deadly slow that software could be better with a usefull cpu


Robert(Posted 2005) [#5]
Stencil ops are fairly well supported even on older hardware. However, the number of bits in the stencil buffer varies. If possible try and make sure that your code can handle smaller stencil buffers (if something has less bits, would way say that it has a "lower resolution"?)


Shagwana(Posted 2005) [#6]
Well I have done a little reading and from what I understand 8 bits per pixel stencils are quite common (now a days).


Shagwana(Posted 2005) [#7]
Right, I whipped up this lump of code...
'Number of bitplanes in the stencil buffers
Graphics 800,600,0
num=0
glGetIntegerv(GL_STENCIL_BITS,Varptr num)
Print "Number of stencil bits = "+num
End


Reports that my Radeon 9800 pro has 8 bits, how about you lot?


fredborg(Posted 2005) [#8]
0 (Zero) on a GeForce4-Ti4200. If I'm not mistaken you have to set some flags to make sure a stencil buffer is created. Look up the bglCreateContext command to see the different flags.

Using:
bglCreateContext(800,600,0,0,BGL_BACKBUFFER|BGL_DEPTHBUFFER|BGL_STENCILBUFFER)
I get 8 stencil bits.


Shagwana(Posted 2005) [#9]
bglCreateContext(800,600,0,0,BGL_BACKBUFFER|BGL_DEPTHBUFFER|BGL_STENCILBUFFER)
num=0
glGetIntegerv(GL_STENCIL_BITS,Varptr num)
Print "Number of stencil bits = "+num
End


Does it give you a different result?


fredborg(Posted 2005) [#10]
I get 8 stencil bits.



Shagwana(Posted 2005) [#11]
:o) Ta, what else do you other lot get?


flying willy(Posted 2005) [#12]
8 bits, ati radeon 9800 pro.


Shagwana(Posted 2005) [#13]
My old Radeon 7200 reports 8 as well


Shagwana(Posted 2005) [#14]
My even older Tnt1 card also reports 8! (and also works on winxp!)


Bremer(Posted 2005) [#15]
Number of stencil bits = 8 , FX5900


Shagwana(Posted 2005) [#16]
GeForce 4 Mx has 8 as well :)


ImaginaryHuman(Posted 2005) [#17]
Cool to know you need to specify it in the context creation.

From what I read, EVERY implementation of OpenGL should have an stencil buffer but not necessarily 8-bit. ...

"Your particular OpenGL implementation determines which buffers are available and how many bits per pixel each holds. Additionally, you can have multiple visuals, or window types, that have different buffers available. At a minimum, you're guaranteed to have one color buffer for use in RGBA mode with associated stencil, depth, and accumulation buffers that have color components of nonzero size, and one color buffer for use in color-index mode with associated depth and stencil buffers. Table 10-1 lists the parameters to use with glGetIntegerv() to query your OpenGL system about per-pixel buffer storage for a particular visual. If you're using the X Window System, you'll probably want to use glXGetConfig() to query your visuals; see Appendix D and the OpenGL Reference Manual for more information about this routine. "


Shagwana(Posted 2005) [#18]
Yep, what im trying to work out is there going to be a major problem for me to use more then 1 stencil bit. The more computer the game works on, the bigger the market!. As you can see so far, all above have reported 8 bits.

What I would like to see if some older hardware posted here. Anyone willing to try for me (and the good of the blitzy world :P)


TeaVirus(Posted 2005) [#19]
I get 8 bits on an older Radeon Mobility (7xxx series I think).


Bot Builder(Posted 2005) [#20]
radeon 9600, 8 bits.


flying willy(Posted 2005) [#21]
if it's for shadows then just have blob fallback on <8bits and be damned with them!


xlsior(Posted 2005) [#22]
Radeon 9600 Pro, 8 bits


Takuan(Posted 2005) [#23]
old FX5200 8 bits