Stencil buffer not hardware supported??

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.

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

Originally posted by zix99:
Can someone please tell me what i’m doing wrong.
No.

Not before you tell us what you’re doing.

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.

And the depth-buffer should be 24 Bit.
Not 16 and not 32 Bit.

Jan.

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).]

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

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).]

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.

Dying when the vendor is Microsoft sounds like a good idea. :wink:

Thanks for the idea

Dying when the OS says Microsoft sounds like a pretty good idea too :slight_smile:

Originally posted by Shag:
Dying when the OS says Microsoft sounds like a pretty good idea too :slight_smile:

LOL

-SirKnight

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.

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.

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.

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?

“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.

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

Originally posted by JanHH:
[b]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[/b]
Ummm …
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.

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.