FSAA multisampling code example..

Member
Posts: 321
Joined: 2004.10
Post: #1
I've been reading up and googling for a long time now and even looked at Apple's code examples. But I'm still not getting it. There seems to be all these non-openGL calls that are never documented.

Does anybody have a simple OSX "demo" program that they could post. I'm assuming
the meat of the algorithm is fairly short.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
What are you using to create your OpenGL context? The prefix will be different depending on whether you're using CGL, AGL, or Cocoa, but you will need to include the number of sampleBuffers (usually just 1) and the number of samples (the factor you want to have the FSAA at). (when you're looking at the pixel format attributes, search for the terms in bold)

When you want to turn on anti-aliasing, you use glEnable(GL_MULTISAMPLE), and when you want to turn it off you use glDisable(GL_MULTISAMPLE)
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #3
Quote:What are you using to create your OpenGL context?

Assuming I know what a context is, I believe the answer is GLUT.

Quote:The prefix will be different depending on whether you're using CGL, AGL, or Cocoa...).

prefix to what? Is this some OpenGL function call?

AGL is Apple's openGL. Cocoa is Apple's objective-C language that OS X is written in.
What is CGL? What shouldI use if I'm developing in GLUT/C++/OpenGL within Xcode?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
if you're using GLUT, you'll need to use glutDisplayModeString instead of glutInitDisplayMode to get FSAA. Use "man glutDisplayModeString" to read the documentation...
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #5
In your glutInitDisplayMode, you can add GLUT_MULTISAMPLE to your string of ORs. If you want more control (such as over how many samples), you will need to use glutDisplayModeString.

An OpenGL context is the current place that your OpenGL calls go, and holds your pixel format, all your texture objects, display lists, etc. GLUT is an API that makes creating the context and using it easier. For the different APIs to use OpenGL, IIRC AGL is a frontend for OpenGL in Carbon, and CGL is the lowest level for OpenGL. (don't quote me on that, though)
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #6
Is it this simple or am I forgetting something? I first tried this

glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE );
glEnable(GL_MULTISAMPLE);

No improvement that my eyes could detect. So I tried this:

glutInitDisplayString( "rgba double samples>=4 ");
glEnable(GL_MULTISAMPLE);

Still nothing. I think I read that not all cards support multisampling.
I've got an ATI Radeon 9200.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #7
Both should work. Sometimes it can be a little difficult to tell if FSAA is on, depending on the scene. You should have a toggle (via key or whatnot) and toggle it on and off, seeing if you can see any difference whatsoever. You can also try posting the program and seeing if that does anything.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
The 9200 supports FSAA -- up to 4x by the looks
Quote this message in a reply
Member
Posts: 49
Joined: 2006.07
Post: #9
Once I had that problem with GLUT, and switching to glEnable(GLUT_MULTISAMPLE_ARB) fixed it.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Multisampling in iOS4 Bersaelor 4 6,023 Jul 10, 2010 12:59 AM
Last Post: Bersaelor
  Multisampling: performance hit if disabled? Fenris 5 4,809 Aug 1, 2007 01:57 PM
Last Post: Fenris