哪位大侠帮我看下代码 关于openGL的混合的 为什么我运行结果只显示一个白色的窗口呢?。。。。
#include<windows.h>#include<gl/glew.h>#include<gl/glut.h>voidinit(void){glClearColor(...
#include <windows.h>
#include<gl/glew.h>
#include<gl/glut.h>
void init(void)
{
glClearColor(0.0,0.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.2,-0.2,0.2,0.2);
glFlush();
}
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);
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
int main (int argc,char *argv[])
{
glutInit( &argc,argv);
glutInitDisplayMode(GLUT_RGB |GLUT_DOUBLE );
glutInitWindowSize(500,500);
glutInitWindowPosition(200,200);
glutCreateWindow("zenmele?");
init();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
} 展开
#include<gl/glew.h>
#include<gl/glut.h>
void init(void)
{
glClearColor(0.0,0.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.2,-0.2,0.2,0.2);
glFlush();
}
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);
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
int main (int argc,char *argv[])
{
glutInit( &argc,argv);
glutInitDisplayMode(GLUT_RGB |GLUT_DOUBLE );
glutInitWindowSize(500,500);
glutInitWindowPosition(200,200);
glutCreateWindow("zenmele?");
init();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询