Multisampling example?

Started by wmjoers, July 07, 2005, 15:08:49

Previous topic - Next topic

wmjoers

Hi,

Are there any examples on how to accomplish antialiasing using LWJGL?

I know that the best approach is to use multisampling but can't find any examples. I read in another thread about using PixelFormat (I guess in Display.create(...)) but I don't know what parameters I should use when creating the PixelFormat object.

I guess I also must enable something with glEnable(...) but I don't know what..

Fool Running

Just pass a value greater than 0 to the PixelFormat constructor in the samples parameter:
PixelFormat(bpp, alpha, depth, stencil, 4) ;

would do 4x( :? ) anti-alaising
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

wmjoers

Oki, thanks!

But...not to be a pain...how do I determine what to put in the other parameters?

Ok...I will make an effort to guess:
* bpp - should be the same as the display modes bits per pixel?
* alpha - could be zero if I don't intend to use alpha??
* depth - little lost here...though....
* stencil - can also be zero if I don't intend to use that??

Fool Running

*bpp - can be 16 or 32 (maybe 24 for linux). If you are windowed then use the bpp of the current mode, else pick one  :lol:
*alpha - can be 0 if you don't use alpha
*depth - the number of bits for the depth buffer (used to keep things drawn last from appearing on top of things that are drawn first) 16 or 24 (possibly 8, but seems useless  :wink: )
*stencil - can be 0 if not using the stencil buffer
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Orangy Tang

General cavets with the above:
- Num samples should probably be power-of-two (although anything above 4 is likely to be overkill anyway)
- You can only really have 0 or 8 for alpha and stencil
- You can only get 8 bits of alpha with 24 or 32 bit colour
- Non-zero stencil buffer will probably require depth buffer to be greater than 16
- Depth buffer should be equal or less than colour

These are lagely due to the fact that most graphics cards like to interleave the colour with alpha, and also the depth with stencil bits.