Point distance attenuation with OGL-extension - how?

Apprentice
Posts: 11
Joined: 2008.05
Post: #1
Hello,

I am little lost on how to use extensions and would like to enable point-size attenuating for particles (large at close and smaller when far Smile )

Anyone willing to share source or step-by-step instructions how to do this exactly in Cocoa? i.e. detect if required extensions are available, grab fPointer and call it to set GL_POINT_DISTANCE_ATTENUATION_ARB , GL_POINT_FADE_THRESHOLD_SIZE_ARB , GL_POINT_SIZE_MIN_ARB, GL_POINT_SIZE_MAX_ARB, etc.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
You don't need to grab the function pointer, just check for the extension and call the function; aside from that it's exactly the same as any other platform.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.05
Post: #3
OneSadCookie Wrote:You don't need to grab the function pointer, just check for the extension and call the function; aside from that it's exactly the same as any other platform.
Thanks. I found win32 example but it does indeed get the fpointer(s) to set parameters for extensions. Like:

Code:
char *ext = (char*)glGetString( GL_EXTENSIONS );
   if( strstr( ext, "GL_ARB_point_parameters" ) == NULL )
      bailout....
  else {
   glPointParameterfARB  = (PFNGLPOINTPARAMETERFARBPROC)wglGetProcAddress("glPointParameterfARB");
   glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)wglGetProcAddress("glPointParameterfvARB");

   float quadratic[] =  { 1.0f, 0.0f, 0.01f };
   glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );
   glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );
   ...

I don't understand how I do that without fPointers? I found something about NSGLGetProcAddress() but don't know if that's what I should use or is there some new more "elegant" way in Leopard?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Just delete the first two lines after the else, and the declarations of those variables earlier in the file.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.05
Post: #5
OneSadCookie Wrote:Just delete the first two lines after the else, and the declarations of those variables earlier in the file.

Huh. That sounds too easy. Smile
Thanks! .... (going to try it out).
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
As Keith pointed out, on Mac OS X, all extensions are statically linked.
Look at /System/Library/Frameworks/OpenGL.framework/headers/glext.h
Everything there "just works"; if the extension is exported, you can use the API directly.

Here's some example code written in GLUT that you can port pretty easily.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.05
Post: #7
arekkusu Wrote:As Keith pointed out, on Mac OS X, all extensions are statically linked.

It seems so. I forget to post thanks - so thanks to both.

I got it to work as instructed. However there is something weird with attenuation.
I don't get the quadric-parameter working correctly. (i.e. point size varies per distance to "camera").

I have gluPerspective & gluLookAt and initially the sizes seems to be correct. When I move my eyepoint with gluLookAt it seems that the biggest points are near center of scene (0,0,0) and then they get smaller to every direction from there?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Signed Distance Fields for Alpha Tested Magnification of Vector Textures maximile 2 5,862 Mar 29, 2010 10:59 AM
Last Post: Skorche
  OpenGL Distance Optimizations merrill541 17 6,728 Oct 4, 2009 11:27 AM
Last Post: arekkusu
  light attenuation NelsonMandella 2 3,713 Jun 4, 2009 03:28 PM
Last Post: reubert
  OpenGL Extension Loading othello 5 5,305 Aug 14, 2008 01:59 PM
Last Post: OneSadCookie
  Thoughts on GL_HP_occlusion_test extension Mars_999 13 5,225 Aug 9, 2004 10:37 PM
Last Post: OneSadCookie