PDA

View Full Version : Compiled vertex array issues.



dabeav
05-23-2002, 05:00 AM
I have been trying very hard the last couple of days to get use my first extension. glLockArrays. I am attampting to lock an interleaved array. Could some one please give me some pointers here? If I compile normaly, it tells me that glLockArraysEXT, and glUnlockArraysEXT are undelcared identifiers. If I use the SDK files from SGI, and include the glext.h, and glprocs.h files, it tells me that glprocs.h is an unresolved external symbol. Im I doing something incorrect, or does my video not support this particulare extension? Any ideas please let me know. And as always, code is apprieciated, but not neccessary.
Thanks in advance.

Robbo
05-23-2002, 06:00 AM
Create a source file as below and then execute the load-extensions method after creating your render context.

#define GLH_EXT_SINGLE_FILE


#include "glh_genext.h"

#include "gl.h"
#include "glu.h"

extern int glh_init_extension ( const char* extension );


void Load_Extensions ()

{

glh_init_extension ( "GL_EXT_compiled_vertex_array" );

// and init any other extensions you may want to use here.....
glh_init_extension ( "GL_ARB_multitexture" );
}


[This message has been edited by Robbo (edited 05-23-2002).]

dabeav
05-23-2002, 07:50 AM
where is this found?
glh_genext.h??

also by using will my program be limited to what OS's or video cards it will run on? if it does, I would like to find another way. Thank you.

[This message has been edited by dabeav (edited 05-23-2002).]

mproso
05-23-2002, 08:20 AM
If you are going to use only GL_EXT_compiled_vertex_array extension you dont have to
use SDK from SGI(or any other SDK), just download new headers from http://oss.sgi.com/projects/ogl-sample/registry/
and put at the begining of your program

PFNGLLOCKARRAYSEXTPROC glLockArraysEXT;
PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT;

and after you create valid GL context,
first check is this extension supported (look for extension name in string that is returned by function glGetString(GL_EXTENSIONS) ).
If it is supported you can get function pointers like this

glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC)wglGetProcAddress("glLockArraysEXT");
glUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXTPROC)wglGetProcAddress("glUnlockArraysEXT");

It is good practise to check are pointers valid.
This you have to for every extension you want to use.
That glh_genext.h is header form NVIDIA OpenGL SDK.
Hope this help.

Robbo
05-23-2002, 08:48 AM
Originally posted by dabeav:
where is this found?
glh_genext.h??


Its in the NVIDIA SDK - compiled vertex arrays will work on all implementations (erm, not sure actually - perhaps 1.1 onwards?). You cannot initialize these methods in the same way on different os's.

dabeav
05-23-2002, 09:38 AM
That header, realy gave me problems, It told me that it was missing ;'s and an unexpted end of file was found, can some one tell me more about this PFNGLOCKARRAYSEXTPROC thing, ??

zeckensack
05-23-2002, 10:08 AM
These are function pointers. If that doesn't work for you, I can donate some macros and sample code:

Put something like this in a header file:


//'extern' function pointer declaration for use in headers
#define FP_DECLARE(name,ret,parms) typedef ret (APIENTRY *FP_##name)##parms;\
extern FP_##name name
//example:
// the following two lines:
// typedef void (APIENTRY *FP_glLockArraysEXT)(GLint,GLsizei);
// extern FP_glLockArraysEXT glLockArraysEXT;
// get replaced by:
// FP_DECLARE(glLockArraysEXT,void,(GLint,GLsizei))

//FP_DEFINE will be used in the .cpp file that wants to export the function pointer
#define FP_DEFINE(name) FP_##name name=NULL
//the '=NULL' thingy is merely a safeguard against stray pointers
//example:
// FP_glLockArraysEXT=NULL;
// can be abbreviated like this:
// FP_DEFINE(glLockArrays);
//a macro that ties in wonderfully with the function pointer macros to help querying GL extensions
#define GL_FP_GRAB(name) (name=(FP_##name)wglGetProcAddress(#name))

bool grab_extensions();

FP_DECLARE(glActiveTextureARB,void,(GLenum));
FP_DECLARE(glFogCoordfEXT,void,(GLfloat));
FP_DECLARE(wglSwapIntervalEXT,BOOL,(int));
FP_DECLARE(glFogCoordPointerEXT,void,(GLenum,GLsiz ei,GLvoid*));
FP_DECLARE(glLockArraysEXT,void,(GLint,GLsizei));
FP_DECLARE(glUnlockArraysEXT,void,(void));
FP_DECLARE(glDrawRangeElementsEXT,void,(GLenum,GLu int,GLuint,GLsizei,GLenum,const GLvoid*));
FP_DECLARE(glClientActiveTexture,void,(GLenum));
FP_DECLARE(glWindowPos2iARB,void,(GLint,GLint));
FP_DECLARE(wglGetExtensionsStringARB,const char*,(HDC));Then, in a .cpp file, include the header and maybe this:

FP_DEFINE(glActiveTextureARB);
FP_DEFINE(glFogCoordfEXT);
FP_DEFINE(wglSwapIntervalEXT);
FP_DEFINE(glFogCoordPointerEXT);
FP_DEFINE(glLockArraysEXT);
FP_DEFINE(glUnlockArraysEXT);
FP_DEFINE(glDrawRangeElementsEXT);
FP_DEFINE(glClientActiveTexture);
FP_DEFINE(glWindowPos2iARB);
FP_DEFINE(wglGetExtensionsStringARB);

bool
grab_extensions()
{
if (GL_FP_GRAB(wglGetExtensionsStringARB))
{
const char* junk=wglGetExtensionsStringARB(wstate.hDc);
}
else return(false);

if (GL_FP_GRAB(glActiveTextureARB)&&
GL_FP_GRAB(glFogCoordfEXT)&&
GL_FP_GRAB(wglSwapIntervalEXT)&&
GL_FP_GRAB(glFogCoordPointerEXT)&&
GL_FP_GRAB(glLockArraysEXT)&&
GL_FP_GRAB(glUnlockArraysEXT)&&
GL_FP_GRAB(glDrawRangeElementsEXT)&&
GL_FP_GRAB(glClientActiveTexture)&&
GL_FP_GRAB(glWindowPos2iARB))
{
int tex_units;
glGetIntegerv(GL_MAX_ACTIVE_TEXTURES_ARB,&tex_unit s);
if (tex_units>=2) return(true);
}
return(false);
}
For Unix platforms, there should be an equivalent glx call to get the pointers, you can swap that out in the macro.

dabeav
05-23-2002, 10:39 AM
PFNGLLOCKARRAYSEXTPROC glLockArraysEXT;
PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT;
this dosnt work, it generates 3 errors missing ;. and end of file errors. What i am doing wrong? any one have any ideas?

kehziah
05-23-2002, 02:19 PM
typedef void (APIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
typedef void (APIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void);

mproso
05-24-2002, 01:06 AM
Are you sure you included windows.h, gl.h, glu.h and glext.h in your project?
If you did include those headers you must put those function pointers declarations after headers files with your other globals.
Hope this helps.