PDA

View Full Version : Where can I get the latest header files for OpenGL



Debugger
12-30-2006, 05:19 AM
Hi, all
I have a piece of code which using function glBlendEquation, but I can't compile this program successfully, the compiler said glBlendEquation was not declared, so I think maybe my header files became older, such as gl.h, glu.h..., or that it is due to something else?


where can i get the latest one ?
BTW:I am using WINXP-SP2&VS2005

here is my code:

#include <windows.h>
#include <GL/glut.h>

void init(void)
{
glClearColor(1.0, 1.0, 0.0, 0.0) ;
glBlendFunc(GL_ONE, GL_ONE) ;
glEnable(GL_BLEND) ;
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT) ;
glColor3f(0.0, 0.0, 1.0) ;
glRectf(-0.5, -0.5, 0.5, 0.5) ;
glFlush() ;
}

void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei)w, (GLsizei)h) ;
glMatrixMode(GL_PROJECTION) ;
glLoadIdentity() ;
if(w<=h)
glOrtho(-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w,
1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0) ;
else
glOrtho(-1.5*(GLfloat)w/(GLfloat)h,
1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0) ;
glMatrixMode(GL_MODELVIEW) ;
glLoadIdentity() ;
}

void keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 'a':
case 'A':
glBlendEquation(GL_FUNC_ADD) ;
break ;
case 's':
case 'S':
glBlendEquation(GL_FUNC_SUBTRACT) ;
break ;
case 'r':
case 'R':
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT) ;
case 'm':
case 'M':
glBlendEquation(GL_MIN) ;
break ;
case 'x':
case 'X':
glBlendEquation(GL_MAX) ;
break ;
case 27:
exit(0) ;
break ;
}
glutPostRedisplay() ;
}

int main(int argc, char **argv)
{
glutInit(&amp;argc, argv) ;
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB) ;
glutInitWindowSize(200, 200) ;
glutCreateWindow(argv[0]) ;
init() ;
glutReshapeFunc(reshape) ;
glutKeyboardFunc(keyboard) ;
glutDisplayFunc(display) ;
glutMainLoop() ;
return 0 ;
}

Overmind
12-30-2006, 06:47 AM
http://www.opengl.org/wiki/index.php/Getting_started

Debugger
12-30-2006, 05:22 PM
Thank you very much!

Debugger
12-31-2006, 05:20 AM
Another question, compile has no problem this time, but the app crashed when runing, why ?

here is my change:

#include &amp;lt;windows.h&amp;gt;
#include &amp;lt;GL/glut.h&amp;gt;
#include &amp;lt;GL/glext.h&amp;gt;

extern PFNGLBLENDEQUATIONPROC glBlendEquation;
PFNGLBLENDEQUATIONPROC glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation");I am trying to debug it when I got the crash, I find the app breaked at here:

switch(key)
{
case 'a':
case 'A':
//when I pressed A on the keyboard, I am stopped here, it seems the function is invalidate
glBlendEquation(GL_FUNC_ADD) ;
break ;
case 's':
case 'S':
glBlendEquation(GL_FUNC_SUBTRACT) ;
break ;Any idea?

ZbuffeR
12-31-2006, 07:43 AM
Check that your call to wglGetProcAddress returns a valid (non null) pointer.

if (glBindBufferARB == NULL) {
// Error, unable to find
} else {
//ok
}

Overmind
12-31-2006, 10:14 AM
PFNGLBLENDEQUATIONPROC glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation");That won't work directly, because this code will be executed before your main function.

You first have to initialize the OpenGL context (open the window and so on). Then you can call wglGetProcAddress.

Debugger
01-04-2007, 01:28 AM
Yes, you are right, wglGetProcAddress failed, the return value is NULL, how should I do?
is there other way to use extent functions?

I also moving the code to keyboard function, it si OK to call wglGetProcAddress, becase the main window is created when calling keyboard function.

Debugger
01-04-2007, 04:47 AM
I am also trying to use glew but still failed.
code like this

#include <windows.h>
#include <GL/glew.h>
#include <GL/glut.h>

void init(void)
{
glClearColor(1.0, 1.0, 0.0, 0.0) ;
glBlendFunc(GL_ONE, GL_ONE) ;
glEnable(GL_BLEND) ;
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT) ;
glColor3f(0.0, 0.0, 1.0) ;
glRectf(-0.5, -0.5, 0.5, 0.5) ;
glFlush() ;
}

void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei)w, (GLsizei)h) ;
glMatrixMode(GL_PROJECTION) ;
glLoadIdentity() ;
if(w<=h)
glOrtho(-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w,
1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0) ;
else
glOrtho(-1.5*(GLfloat)w/(GLfloat)h,
1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0) ;
glMatrixMode(GL_MODELVIEW) ;
glLoadIdentity() ;
}

void keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 'a':
case 'A':
glBlendEquation(GL_FUNC_ADD) ;
break ;
case 's':
case 'S':
glBlendEquation(GL_FUNC_SUBTRACT) ;
break ;
case 'r':
case 'R':
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT) ;
case 'm':
case 'M':
glBlendEquation(GL_MIN) ;
break ;
case 'x':
case 'X':
glBlendEquation(GL_MAX) ;
break ;
case 27:
exit(0) ;
break ;
}
glutPostRedisplay() ;
}

int main(int argc, char **argv)
{
glutInit(&amp;argc, argv) ;
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB) ;
glutInitWindowSize(200, 200) ;
glutCreateWindow(argv[0]) ;
init() ;
glutReshapeFunc(reshape) ;
glutKeyboardFunc(keyboard) ;
glutDisplayFunc(display) ;
glutMainLoop() ;
return 0 ;
}Is that because my video card doesn't support OpenGL extension? I invoke gluGetString(GLU_EXTENSIONS) and the return value is GL_EXT_bgra, could anyone tell me what does this mean? and also it would be great if someone can share me some code about how to use OpenGL extension, some code can compile and execute successfully.

Overmind
01-04-2007, 06:48 AM
You have to call glewInit after glutCreateWindow.
http://glew.sourceforge.net/basic.html


gluGetString(GLU_EXTENSIONS)That's the wrong extension string ;) . Try glGetString(GL_EXTENSIONS) and glGetString(GL_VERSION).

AFAIK glBlendEquation needs at least OpenGL 1.4.

Debugger
01-04-2007, 10:27 PM
The return value of glGetString(GL_VERSION) is 1.2, Maybe this is the reason.

jide
01-05-2007, 03:37 AM
What kind of graphic card do you have ? If it's not really old, then try to update your drivers.

Debugger
01-06-2007, 12:25 AM
it's not because my video card, I have moving this program to another machine with a better video card but the error still happen, really strange!
it disturb me a long time, I even want to give up.
who can help me ?

Debugger
01-07-2007, 12:10 AM
I got it, it is because my video card driver is too old, with the latest driver installed, this works well.
Thank you all!