PDA

View Full Version : help me to install glext.h and wglext.h please



raaji
05-28-2011, 05:35 PM
hello guys

i am trying to install glext.h and wglext.h but it seems there are some tricks i don't know.

i use vc++6 with windows xp, first i downloaded the recent driver for my grafics card and (glext.h and wglext.h) from OpenGL Registry (http://www.opengl.org/registry/)

i use the code that create the window at nehe's tutorial first lesson so my .cpp contains the following headers.

#include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h>

#include <gl\glext.h>
#include <gl\wglext.h>
#include <gl\pfuncs.h>


in pfuncs.h header file i put the following pointer functions' definations.


extern PFNGLVIEWPORTPROC glViewport;
extern PFNGLLOADIDENTITYPROC glLoadIdentity;
extern PFNGLSHADEMODELPROC glShadeModel;
extern PFNGLCLEARCOLORPROC glClearColor;
extern PFNGLCLEARDEPTHPROC glClearDepth;
extern PFNGLENABLEPROC glEnable;
extern PFNGLDEPTHFUNCPROC glDepthFunc;
extern PFNGLHINTPROC glHint;
extern PFNGLCLEARPROC glClear;
extern PFNGLGETSTRINGPROC glGetString;


when i run the program i receive the following error that is about the first function defination whatever the first is from the definations above:


--------Configuration: lesson1 - Win32 Debug---------
Compiling...
Lesson1.cpp
c:\program files\microsoft visual studio\vc98\include\gl\pfuncs.h(17) : error C2146: syntax error : missing ';' before identifier 'glViewport'
c:\program files\microsoft visual studio\vc98\include\gl\pfuncs.h(17) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

lesson1.exe - 2 error(s), 0 warning(s)

but if i put the following function defination i don't receive an error message about it even i put it at the first of the header file but still receive the error for the next defination.

extern PFNGLACTIVETEXTUREPROC glActiveTexture;

so what's the problem doesn't all the opengl functions need a pointer function or what is wrong here??

----------------------------------------
an other thing,now after i updated my graphics card driver i note that my program can run even without (#include <gl/gl.h>)
could you explain that for me.

many thanks

Aleksandar
05-29-2011, 01:21 AM
in pfuncs.h header file i put the following pointer functions' definations.


extern PFNGLVIEWPORTPROC glViewport;
extern PFNGLLOADIDENTITYPROC glLoadIdentity;
extern PFNGLSHADEMODELPROC glShadeModel;
extern PFNGLCLEARCOLORPROC glClearColor;
extern PFNGLCLEARDEPTHPROC glClearDepth;
extern PFNGLENABLEPROC glEnable;
extern PFNGLDEPTHFUNCPROC glDepthFunc;
extern PFNGLHINTPROC glHint;
extern PFNGLCLEARPROC glClear;
extern PFNGLGETSTRINGPROC glGetString;

Why did you do that?
There is no definition for PFNGLVIEWPORTPROC or similar typederf.
GL 1.1 functionality is already defined in gl.h
The compiler clearly stated that PFNGLVIEWPORTPROC is not defined.
So, in short, add function pointers only when you don't have adequate function in GL 1.1 (i.e. in gl.h).


an other thing,now after i updated my graphics card driver i note that my program can run even without (#include <gl/gl.h>)
could you explain that for me.
No. :)
Unless you are using gl3.h.

V-man
05-29-2011, 06:06 AM
No. :)
Unless you are using gl3.h.

This is how the glu.h starts.
Newcommers to programming seem to not know that you can open .h files and read them. Trust me, these are text file. You can read them!



/*++ BUILD Version: 0004 // Increment this if a change has global effects

Copyright (c) 1985-95, Microsoft Corporation

Module Name:

glu.h

Abstract:

Procedure declarations, constant definitions and macros for the OpenGL
Utility Library.

--*/

#ifndef __glu_h__
#ifndef __GLU_H__

#define __glu_h__
#define __GLU_H__

#include <GL/gl.h>

raaji
05-29-2011, 07:21 AM
Why did you do that?
There is no definition for PFNGLVIEWPORTPROC or similar typederf.
GL 1.1 functionality is already defined in gl.h
The compiler clearly stated that PFNGLVIEWPORTPROC is not defined.
So, in short, add function pointers only when you don't have adequate function in GL 1.1 (i.e. in gl.h).


thank you Aleksandar


i thought that i should add a declaration for every opengl function.

but how do i know what functions are not found in GL 1.1 or what functions are in GL 1.1 but i shouldn't use because there is a recent substitute in last versions of opengl? is it by reading the OpenGL Reference Pages, if yes, what one i should be reading? OpenGL 2.1 , 3.3 or 4.1 Reference Pages.



No. :)
Unless you are using gl3.h.


i don't know, maybe.
what is it gl3.h? is it a version of opengl, is it the one that OpenGL 3.3 Reference Pages talk about ?

how do i know if it is what i use?

raaji
05-29-2011, 07:44 AM
thank you V-man

so gl.h is called from glu.h it was really a hide information that i might not find at all. :D

Aleksandar
05-29-2011, 08:05 AM
but how do i know what functions are not found in GL 1.1 or what functions are in GL 1.1 but i shouldn't use because there is a recent substitute in last versions of opengl? is it by reading the OpenGL Reference Pages, if yes, what one i should be reading? OpenGL 2.1 , 3.3 or 4.1 Reference Pages.
Just call the function and if compiler doesn't print any error that's GL1.1 function, or a function that you have already declared a pointer to.


what is it gl3.h? is it a version of opengl, is it the one that OpenGL 3.3 Reference Pages talk about ?
Why didn't you read OpenGL Registry page before downloading glext.h/wglext.h? OpenGL registry is the Holy Grail of OpenGL! There you can find all answers you need. ;)

Well, to help you to get answer quicker, gl3.h is a modern substitution for gl.h which excludes all deprecated functionality. It can be downloaded from OpenGL Registry page. Personally I'm not using gl3.h, but it can help beginners to easily exclude deprecated functionality.

By the way, if you are planning to use moder OpenGL, get rid of glu.h as soon as possible. GLU is a wrapper around core (not core profile in GL 3.2+, but functions that makes bare bones of legacy GL). It just makes usage of some standard chores in GL easier. But, it uses old and deprecated functionality. Of course, it is up to you what profile will be used.


how do i know if it is what i use?
If you don't know, who knows? :)

raaji
05-29-2011, 08:34 AM
If you don't know, who knows?
:D

now i know that it is not what i use because i don't remember that i downloaded it before.



Why didn't you read OpenGL Registry page before downloading glext.h/wglext.h? OpenGL registry is the Holy Grail of OpenGL! There you can find all answers you need. ;)


after i heard what you said about it,i will start reading it now.

thank you a lot dear Aleksandar

V-man
05-30-2011, 05:35 AM
If you want to know which function has been introduced in which version, just look into the glext.h file. The gl.h file has only the GL 1.1 functions.

Also, why don't you do what is recommended on the Wiki? Just download GLEW. It will get the function pointers for you.

raaji
05-30-2011, 03:35 PM
thank you V-man, i appreciate your help



Also, why don't you do what is recommended on the Wiki? Just download GLEW. It will get the function pointers for you.

it is because i want to know how things occurs in its fundamental rules, after i understand its work , most likely i will use GLEW.


If you want to know which function has been introduced in which version, just look into the glext.h file. The gl.h file has only the GL 1.1 functions.


actualy i am not good in reading header files, but i hope to learn reading them to get more flexibility in c++ programming.

i read a lesson about preprocessor commands but i still not very good in that because i didn't started to test the skils i learnt but i think it is the time and start will be here in this file "glext.h" .

if you or someone else help me to follow only one function defination and any related things with it in "glext.h", it will be a good training for me.

raaji
05-30-2011, 06:06 PM
hi V-man

i think i found it, here are some of the functions that was introduced in Gl 1.4 ,is that right?



#ifndef GL_VERSION_1_4
#define GL_VERSION_1_4 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
...
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
...
#endif

#ifndef GL_VERSION_1_4_DEPRECATED
#define GL_VERSION_1_4_DEPRECATED 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glFogCoordf (GLfloat coord);
GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord);
...
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);
typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);
...
#endif


i want to ask about something, my operating system like i said is windows xp professional, which is like i read with a GL 1.1 version but when i used the function glGetString(GL_VERSION) i found that the GL version is 1.4.0 .
this was checked only after i updated my grafics card driver.
so this version, GL 1.4, was came with my windows or when i updated the driver of gafics card.

if GL 1.4 was downloaded with the grafics card driver then i have two versions of GL in my PC, is that right?

if yes, now i may use the functions in GL 1.1 and also the new functions in GL 1.4, by the help of "glext.h and wglext.h" i think yes but my question here: can i use new functions in GL versions that came after the two i have? i think no, is it right?

it is what i think i may be wrong, actualy this is the first time i deal with DLLs and i don't understand what they are used for exactly. only i think they are containing functions and classes and maybe some other sorts of files. :D

thank you a lot for your help

ZbuffeR
05-30-2011, 11:54 PM
This page is not the best structured piece of information, but try to read it entirely :
http://www.opengl.org/wiki/Getting_started

Short version is that indeed, at runtime, the Windows-provided Opengl DLL is extended by whatever video driver is installed on the system. It means that, to benefit from new functions not existing in the Windows GL DLL, a pointer must be asked at runtime.

BionicBytes
05-31-2011, 03:12 AM
so this version, GL 1.4, was came with my windows or when i updated the driver of gafics card.
Your GFX card has updated and supplied OpenGL drivers.
Windows only ships with OpenGL 1.1 interface DLL. When you install a GFX driver, this hooks into the Microsoft DLL and effectvely replaces its functionality with the vendor drivers.

if GL 1.4 was downloaded with the grafics card driver then i have two versions of GL in my PC
Not really. You have the version as reported by glGetString(GL_Version). In your case Open GL 1.4.

can i use new functions in GL versions that came after the two i have? You can access all functions from GL 1.0 upto GL 1.4

raaji
05-31-2011, 07:28 AM
ZbuffeR and BionicBytes i thank you very much for your help, i was what i need.