PDA

View Full Version : Stencil buffer not hardware supported??



zix99
07-16-2003, 02:36 PM
This might be a stupid questing, but i can't get the stencil buffer to run faster then 5 FPS. I heard that it is hardware supported, so i don't know what i'm doing wrong. I program in VB (that might be it) and i have a Radeon 9800, and i've also tested it on a GeForece 4 TI, and Geforce 4 440. I use it in 8 bits.

Can someone please tell me what i'm doing wrong.

Thanks in advance


P.S. I have the latest drivers, so please don't say that. http://www.opengl.org/discussion_boards/ubb/wink.gif

Klaus
07-16-2003, 02:59 PM
The stencil buffer is definately suported in hardware on ATI and NVidia cards. I use it on the ATI R9700/9800 and NVidia GeForce 1/2/3/4/FX cards and it's works flawlessly.

Your framerate drops to 5 fps as soon as you enable stencil test ?

Klaus

zeckensack
07-16-2003, 03:46 PM
Originally posted by zix99:
Can someone please tell me what i'm doing wrong.No.

Not before you tell us what you're doing.

http://www.opengl.org/discussion_boards/ubb/wink.gif

V-man
07-16-2003, 05:19 PM
Possibly the pixel format you chose is no good. I think you need a 32bpp color buffer. It could be that the depth buffer has effect as well.

Jan
07-17-2003, 01:44 AM
And the depth-buffer should be 24 Bit.
Not 16 and not 32 Bit.

Jan.

zix99
07-17-2003, 06:28 AM
I am using 24 bit colors, 24 bit depth, 8 bit stencil, and 8 bit alpha. The thing is all i do is draw ONE quad with a recording stencil buffer:
glEnable GL_STENCILBUFFER
glStencilFunc cfAlways, 0.5, 1
glStencilOp soReplace, soReplace, soReplace
(Sorry if the code isn't right, but you get the idea)
And the whole thing just slows down when i usually get over 300 FPS for ONE quad.

I'm trying to do shadows now, and it would look much better with the stencil buffer.

Is the Stencil bits suppose to be 8 bit?

Any sugestions would be useful, even some type of substitute for the stencil would be useful.

Thanks, ZIX


I'll try 32bpp color now, and i'll tell you my results with one quad drawing over another w/ stencil.

[This message has been edited by zix99 (edited 07-17-2003).]

zix99
07-17-2003, 06:51 AM
I think i feel very stupid right now. I just tested a quad over quad w. stencil and got 1500 FPS! I don;t understand it, before i DID get 5 FPS, but now i get 1500! I guess i'll just feel happy for myself http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks for your help anyway, i don't know what i did, but it works.

Here is my code if anyone wants it (sorry its in BASIC, but its still very easy to understand)




glDisable glcDepthTest
glEnable glcStencilTest
glStencilFunc cfAlways, 0.5, 1
glStencilOp soReplace, soReplace, soReplace
glColorMask 0, 0, 0, 0

glBegin bmQuads
glVertex3f 1, 0, 1
glVertex3f -1, 0, 1
glVertex3f -1, 0, -1
glVertex3f 1, 0, -1
glEnd

glColorMask 1, 1, 1, 1
glStencilFunc cfEqual, 0.5, 1
glStencilOp soKeep, soKeep, soKeep

glColor3f 0, 1, 0
glBegin bmQuads
glVertex3f 0.5, 0, 0.5
glVertex3f -0.5, 0, 0.5
glVertex3f -0.5, 0, -0.5
glVertex3f 0.5, 0, -0.5
glEnd

glDisable glcStencilTest
glEnable glcDepthTest

P.S. Y axis is up

[This message has been edited by zix99 (edited 07-17-2003).]

jwatte
07-17-2003, 12:17 PM
Some OS-es run out of resources and can't allocate new GL contexts until you reboot. Also, other programs you run at the time may interfere.

What I do is put code at start-up that checks whether the GL_VENDOR contains the string Microsoft, and die with a dialog box if that is the case.

Klaus
07-17-2003, 12:36 PM
Dying when the vendor is Microsoft sounds like a good idea. ;-)

zix99
07-17-2003, 02:32 PM
Thanks for the idea

Shag
07-17-2003, 03:30 PM
Dying when the OS says Microsoft sounds like a pretty good idea too :-)

SirKnight
07-17-2003, 05:23 PM
Originally posted by Shag:
Dying when the OS says Microsoft sounds like a pretty good idea too :-)

LOL http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-SirKnight

V-man
07-17-2003, 07:29 PM
When I was working with VB with a GL ActiveX control, eventually, maybe after the 1th or 2nd or 3rd run, it ran extremely slow and the vendor was M$.
I guess VB didn't terminate things correctly.

With VC++, I don't have problems.
It sounds like you're gone have a hell of a time with it if this is the problem.

zix99
07-18-2003, 05:19 AM
I know how to delete all the textures, and the opengl context at the end, so I usually don't have any problems. I make sure i erase everything before ending.

jwatte
07-18-2003, 08:26 AM
The problem is when you Alt-F5 out of the debugger, or your program crashes. At that point, you don't have good clean-up in 16-bit Windows environments (Win98/WinME).or un-protected environments (MacOS 9). Luckily, 32-bit kernels, such as NT/2000/XP, do a much better job of clean-up, as does Linux and MacOS X.

If you're running on XP and are still seeing the "die after N iterations" problem, then your development environment probably isn't creating a new process for you, but instead forces you to live with the dregs of whatever the last invocation left behind. Quitting and re-starting the development environment should then (theoretically) clear it up.

zix99
07-18-2003, 12:50 PM
I run XP and the stencil runs just fine, maybe thats what fixed it. Before on my geforce i had 98, 1st edition. Maybe that was the problem?

blender
07-18-2003, 01:07 PM
"Before on my geforce i had 98, 1st edition. Maybe that was the problem?"

I have win98 the 1st edition and stencil buffer works fine with gf2mx and radeon9500pro.

JanHH
07-19-2003, 04:56 PM
DON'T USE VB!!!!

Can anyone tell me any reason why one should choose VB (other than being too stupid for "real" programming language)? At least, when working with OpenGL
and not Excel/Access?

Jan

zeckensack
07-19-2003, 06:05 PM
Originally posted by JanHH:
DON'T USE VB!!!!

Can anyone tell me any reason why one should choose VB (other than being too stupid for "real" programming language)? At least, when working with OpenGL
and not Excel/Access?

JanUmmm ...
Most "management types" will tout ease of use and increased productivity, because VB is supposedly easy to learn.

While I wouldn't say that VB is exclusively an idiot language, it does go to some measures to prevent people from shooting themselves in the foot. At the same time these measures seem to prevent people from getting things done.

I believe every day spent learning VB is a day wasted. But to answer your question:
Management thinks it's a good idea.

Antorian
07-20-2003, 12:25 PM
My POV:
VB has not the same final disallocation than MS VS.
Most of configurations of VS take care about a local garbage collector that free ressources even if you let "some" local array allocated.
(just look at the difference between C++ Compilator from Microsoft VS and Borland.)

May be it's due to that.

I worked on activeX with OpenGL under VB and VSC++ and a program (quite simple) doesn't behave alike on both.
Freeing hardware Handle is not always successful under VB (in my case).

NB: I'm not taking part for VSC++ or VB , but some difference must be known.

(Sometimes VSC compilator sucks with 300ko .EXE's to display a "hello world")

But , sure that VSC got most of time no problem with freeing ressouces.

Regards.

roffe
07-20-2003, 03:30 PM
More VB thoughts...

I've heard of apps using VB for GUI related code only because it is easier/faster(creating it, not running it) than using the C/C++ counterpart. But since I know nothing about VB can't really verify this.