Sign in to follow this  
tjrr3d

Loading Extensions

Recommended Posts

tjrr3d    122
I'm trying to use the point sprite extention for a particle system which works great in windows, but my instructor wants it to be in Linux. (fun fun!) I don't thing I'm loading the functions correctly. This is what I have, forgive me if its horribly wrong.
#include <dlfcn.h>

int (*glPointParameterfARB)(GLenum, const GLfloat);
int (*glPointParameterfvARB)(GLenum, const GLfloat*);

void *libHandle = dlopen("libgl.so", RTD_LAZY);

glPointParameterfARB)(GLenum, const GLfloat)dlsym(libHandle, "glPointParameterfARB");

glPointParameterfvARB)(GLenum, const GLfloat*)dlsym(libHandle, "glPointParameterfvARB");

then my calls are
float quadric[] = {1.0f, 0.0f, 0.01f};
(*glPointParameterfvARB)(GL_POINT_DISTANCE_ATTENUATION_ARB, quadric);
(*glPointParameterfARB)(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f);
(*glPointParameterfARB)(GL_POINT_SIZE_MAX_ARB, 5.0f);
(*glPointParameterfARB)(GL_Point_SIZE_MIN_ARB, 1.0f);




I get a segmentation fault everytime. If anyone knows of any other way to load extensions in linux please let me know. As of right know, I need to figure out why this doesn't work.

Share this post


Link to post
Share on other sites
Cocalus    554
The simple solution is just to use GLEW and have it handle the extensions (and then you can use the same extension code in windows and linux)

Share this post


Link to post
Share on other sites
deavik    570
Quote:
Original post by tjrr3d
I'm trying to use the point sprite extention for a particle system which works great in windows, but my instructor wants it to be in Linux. (fun fun!) I don't thing I'm loading the functions correctly. This is what I have, forgive me if its horribly wrong.

*** Source Snippet Removed ***

I get a segmentation fault everytime. If anyone knows of any other way to load extensions in linux please let me know. As of right know, I need to figure out why this doesn't work.

Use glXGetProcAddressARB. eg.

#include <GL/gl.h>
#include <GL/glext.h>
#define GLX_GLXEXT_LEGACY
#include <GL/glx.h>

PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC) glXGetProcAddressARB((const GLubyte*) "glPointParameterfARB");


Also, I don't what you're using to link (unfamiliar with it), but since you have "libgl.so" in there it's worth pointing out that it's "libGL.so", ie. "GL" is in capital letters.

Share this post


Link to post
Share on other sites
nefthy    184
first you are missig the assignment operator when calling dlsym:
glPointParameterfARB = (int (*)(GLenum, const GLfloat)) dlsym(libHandle, "glPointParameterfARB");


you can also call function the way you normaly do (no need for (*...))i.e.
glPointParameterfARB(GL_POINT_DISTANCE_ATTENUATION_ARB,quadric);


but as deavik said use glXGetProcAddressARB

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this