Where can I get the latest header files for OpenGL

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(&argc, argv) ;
	glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB) ;
	glutInitWindowSize(200, 200) ;
	glutCreateWindow(argv[0]) ;
	init() ;
	glutReshapeFunc(reshape) ;
	glutKeyboardFunc(keyboard) ;
	glutDisplayFunc(display) ;
	glutMainLoop() ;
	return 0 ;
}

http://www.opengl.org/wiki/index.php/Getting_started

Thank you very much!

Another question, compile has no problem this time, but the app crashed when runing, why ?

here is my change:

#include &lt;windows.h&gt;
#include &lt;GL/glut.h&gt;
#include &lt;GL/glext.h&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?

Check that your call to wglGetProcAddress returns a valid (non null) pointer.

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

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.

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.

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(&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.

You have to call glewInit after glutCreateWindow.
http://glew.sourceforge.net/basic.html

gluGetString(GLU_EXTENSIONS)

That’s the wrong extension string :wink: . Try glGetString(GL_EXTENSIONS) and glGetString(GL_VERSION).

AFAIK glBlendEquation needs at least OpenGL 1.4.

The return value of glGetString(GL_VERSION) is 1.2, Maybe this is the reason.

What kind of graphic card do you have ? If it’s not really old, then try to update your drivers.

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 ?

I got it, it is because my video card driver is too old, with the latest driver installed, this works well.
Thank you all!