Jump to content


GL Extension setup question


6 replies to this topic

#1 zhang_mdev

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 22 June 2005 - 07:43 AM

Hi,

Started GLSL programming by the famous lighthouse3d tutorial

I am used to use Glew to setup the OpenGL Extension like: glCompileShaderARB

I have some weird error report that my program failed to load on some computer with a better GPU than mine. I develop and test it on my GeForce FX 5600, but people failed to load on 6800 Ultra. Seems that failed to init the function and shader source.

I'd like to try setup the GL Extension without using Glew. But I just know how to setup glTexImage3D:

PFNGLTEXIMAGE3DPROC glTexImage3D;
glTexImage3D = (PFNGLTEXIMAGE3DPROC) wglGetProcAddress("glTexImage3D");

My question is how to setup all the necessary extension functions,

I have download the glext.h neader file from SGI site and included in my project, but still get loads of error about "undeclared identifier" :( Is there any example I can refer to?

Thanks in advance,

zhang

#2 zhang_mdev

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 22 June 2005 - 02:00 PM

More in detail.

When I just
#include "glext.h"

That is compiling error

Quote

'glActiveTexture' : undeclared identifier

So i change the lines
#include "glext.h"
PFNGLACTIVETEXTUREPROC glActiveTexture;

Compiling is OK, but got linking error:

Quote

StdAfx.obj : error LNK2005: "void (__stdcall* glActiveTexture)(unsigned int)"(?glActiveTexture@@3P6GXI@ZA) already defined in gApplication.obj
one or more multiply defined symbols found

I cannot use wglGetProcAddress() due to undeclared identifier error

OpenGL troubleshoot seems not working.

What is going wrong?

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 4976 posts
  • LocationBellevue, WA

Posted 22 June 2005 - 03:54 PM

It looks like that SGI header file is written against OpenGL 2.0, while Microsoft only implements OpenGL 1.1 (OGL 2 functionality is available through extensions on supporting hardware). You will need to get wglGetProcAddress working to use extensions - be sure you're including all the right files (windows.h, gl.h) and also linking with opengl32.lib.
reedbeta.com - developer blog, OpenGL demos, and other projects

#4 zhang_mdev

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 23 June 2005 - 05:25 AM

I found the solution! It is a little more complex than expected.

First need a header:

#ifndef _USREXT_H
#define _USREXT_H

#ifdef _WIN32
#include<windows.h>
#endif
#include<stdio.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glext.h>

#ifdef _WIN32

extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;

void initGLExt();

#endif

#endif

Still use the same glext.h from the SGI site. Include it after the gl.h and glu.h
Then implement the init function in a CPP:
#include "stdafx.h"
#include "usrext.h"

#ifdef _WIN32

PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;

void initGLExt()
{
	glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
}
#endif

Call initGLExt() inside the initGL(), if the procedure glActiveTextureARB still refers to NULL, means that is not supported by the hardware.

I have tested in my app, works fine. Free from the Glew library now.

Thanks.

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 4976 posts
  • LocationBellevue, WA

Posted 23 June 2005 - 03:47 PM

Great, that is basically the same sort of code that I use.

If you want, I can send you a file with setup functions for many of the most common extensions. I have already written it, so it saves you the trouble of doing all that typing.
reedbeta.com - developer blog, OpenGL demos, and other projects

#6 zhang_mdev

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 24 June 2005 - 12:00 AM

Reedbeta said:

I can send you a file with setup functions for many of the most common extensions. I have already written it, so it saves you the trouble of doing all that typing.

Yes, that is lot of typing. Thanks for sharing your code. Why not just post it or link it here? So it is avaliable for everyone. Would make this thread a complete note about how to setup gl EXT on windows:)

#7 Reedbeta

    DevMaster Staff

  • Administrators
  • 4976 posts
  • LocationBellevue, WA

Posted 24 June 2005 - 01:40 AM

Sure, here it is:

http://pages.pomona....loads/glext.zip

It doesn't have any nVidia extensions, because I have an ATI card. But, we should really restrict ourselves to ARB extensions as much as possible anyway :)
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users