How to use an extension directly????????
It has occured to me the following problem.
The extension GL_EXT_point_parameters is supported by my system.But when I keep the return address of wglGetProcAddress("glPointParameterEXT")at a global scope variable,I take compliler errors like this:
missing type specifier - int assumed. Note: C++ does not support default-int
glPointParameterEXT' : redefinition; different type modifiers
initializing' : cannot convert from 'PFNGLPOINTPARAMETERFEXTPROC' to 'int
I have made it work but only when I return the address within a function.
like
void FunctionName()
{
glPointParameterEXT = (PFNGLPOINTPARAMETERFEXTPROC) wglGetProcAddress("glPointParameterEXT");
}
so, how can I use the extension functions directly?
How do you define your glPointParameterEXT at global scope? This always works for me:
and then I can use it just like any other pointer to function.
// in header file that is included when I need extension:extern PFNGLPOINTPARAMETERFEXTPROC glPointParameterEXT;// in cpp file where I initialize function pointers:PFNGLPOINTPARAMETERFEXTPROC glPointParameterEXT = NULL;
and then I can use it just like any other pointer to function.
Like b2b3 alluded to, you just need to define your variable.
tj963
PFNGLPOINTPARAMETERFEXTPROC glPointParameterEXT = (PFNGLPOINTPARAMETERFEXTPROC)wglGetProcAddress("glPointParameterEXT");
tj963
I define it like this
In header file:
typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
In cpp file:
PFNGLPOINTPARAMETERFEXTPROC glPointParameterEXT;
glPointParameterEXT = (PFNGLPOINTPARAMETERFEXTPROC) wglGetProcAddress("glPointParameterEXT");
but anything I do at a global scope
produces the errors
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
glPointParameterEXT' : redefinition; different type modifiers
see declaration of 'glPointParameterEXT'
error C2440: 'initializing' : cannot convert from 'PFNGLPOINTPARAMETERFEXTPROC' to 'int'
In header file:
typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
In cpp file:
PFNGLPOINTPARAMETERFEXTPROC glPointParameterEXT;
glPointParameterEXT = (PFNGLPOINTPARAMETERFEXTPROC) wglGetProcAddress("glPointParameterEXT");
but anything I do at a global scope
produces the errors
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
glPointParameterEXT' : redefinition; different type modifiers
see declaration of 'glPointParameterEXT'
error C2440: 'initializing' : cannot convert from 'PFNGLPOINTPARAMETERFEXTPROC' to 'int'
Quote:Original post by Lord_Vader
It has occured to me the following problem.
The extension GL_EXT_point_parameters is supported by my system.But when I keep the return address of wglGetProcAddress("glPointParameterEXT")at a global scope variable,I take compliler errors like this:
missing type specifier - int assumed. Note: C++ does not support default-int
glPointParameterEXT' : redefinition; different type modifiers
initializing' : cannot convert from 'PFNGLPOINTPARAMETERFEXTPROC' to 'int
I have made it work but only when I return the address within a function.
like
void FunctionName()
{
glPointParameterEXT = (PFNGLPOINTPARAMETERFEXTPROC) wglGetProcAddress("glPointParameterEXT");
}
so, how can I use the extension functions directly?
For extensions under OpenGL I use GLExt.pas that comes with the pascal version of SDL.
I haven't had any issues :)
perhaps there is something similar when using C/C++?
cheers,
Paul.
Quote:Original post by paul_nicholls
For extensions under OpenGL I use GLExt.pas that comes with the pascal version of SDL.
I haven't had any issues :)
perhaps there is something similar when using C/C++?
cheers,
Paul.
Sure there is. It's glext.h. It contains all declarations and typedefs for all extensions you need.
To OP:
As Solias suggested, you should use GLEE or similar extension loader. It's quite easy to use and it will save you all the trouble of detecting which extensions are supported and it will initialize appropriate pointers for you.
Also, if you want to use variable from one cpp file in another, you have to use extern. If you don't, compiler will assume, that your function returns int and that generates an error. You can put it into the header file if you want (as I do in example in my first post).
Yeah, there's Glext for C/C++, but I prefer what the first reply said, using GLee. It's very very simple to use.
The point is that EVEN if I use the extern the same errors occurs.
I am aware of GLEE but I would like to know how I can fix this first...
As I told you before I manage to use the extension within a function...
The problem is why I cant use it at global scope...
I am aware of GLEE but I would like to know how I can fix this first...
As I told you before I manage to use the extension within a function...
The problem is why I cant use it at global scope...
the error you are getting
initializing' : cannot convert from 'PFNGLPOINTPARAMETERFEXTPROC' to 'int
is because PFNGLPOINTPARAMETERFEXTPROC hasnt been defined yet. you need to include glext.h which has the typedef PFNGLPOINTPARAMETERFEXTPROC defined prior to trying to declare or extern it. otherwise the compiler doesnt know what on earth that function is.
initializing' : cannot convert from 'PFNGLPOINTPARAMETERFEXTPROC' to 'int
is because PFNGLPOINTPARAMETERFEXTPROC hasnt been defined yet. you need to include glext.h which has the typedef PFNGLPOINTPARAMETERFEXTPROC defined prior to trying to declare or extern it. otherwise the compiler doesnt know what on earth that function is.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement