Sign in to follow this  

a problem about glBlendEquation function

This topic is 4351 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello All I am reading "The Red Book" 4th edition. In chapter 6 the book introduces a blend function called glBlendEquation. I wrote a program using it. The code was successfully compiled, but an error occured when I ran it. code:
#include <Windows.h>
#include <gl/glew.h>
#include <gl/glut.h>

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

void display()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(0.0, 0.0, 1.0);
	glBlendEquation(GL_FUNC_ADD); // this line causes a run-time error!
	glRectf(-0.5, -0.5, 0.5, 0.5);
	glFlush();
}

int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowPosition(200, 100);
	glutInitWindowSize(400, 400);
	glutCreateWindow("Blend Equation");

	init();
	glutDisplayFunc(display);
	glutMainLoop();
}
anything wrong?

Share this post


Link to post
Share on other sites
Quote:
Original post by Skeleton_V@T
glBlendEquation () is not part of the core OpenGL functions. You should check for GL_ARB_imaging extension before using it. I guess your hardware doesn't support that extension.


My graphics card is Geforce FX5700 which dose support GL_ARB_imaging extension.
And I've updated OpenGL driver to 2.0.

Any other reason?

Share this post


Link to post
Share on other sites
ive never used glew but i think u need to call a function before u can use it to setup the extension points (ie just including the header aint enuf) eg
init_glew();

glBlendEquation is part of gl1.2 i think + gffx supports it in hardware
also GL_FUNC_ADD is just normal blending use GL_LOGIC_OP for some different blending methods ( coincidently i was playing around with today)

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
ive never used glew but i think u need to call a function before u can use it to setup the extension points (ie just including the header aint enuf) eg
init_glew();

glBlendEquation is part of gl1.2 i think + gffx supports it in hardware
also GL_FUNC_ADD is just normal blending use GL_LOGIC_OP for some different blending methods ( coincidently i was playing around with today)


I couldn't find glBlendEquation ni gl.h, so I googled.
And I found the GLEW library which includes glBlendEquation, but I don't know how to use it.
If I don't use GLEW library, is there any other method could let me use the extensions in OpenGL 1.2 or later?

Share this post


Link to post
Share on other sites
You may try OpenGL Easy Extension (a.k.a GLee) library. Before using any OpenGL extensions, you check for it's availability roughly like this:
if (GLEE_ARB_multitexture)    //is multitexture support available?
{
glMultiTexCoord2fARB(...); //safe to use multitexture
}


To use GLee in your project, you need to include GLee.h, put it's header and library files into default Include and Lib directories, and that's all.

Share this post


Link to post
Share on other sites

This topic is 4351 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this