定数 | (fR,fG,fB,fA) |
---|---|
GL_ZERO | (0,0,0,0) |
GL_ONE | (1,1,1,1) |
GL_SRC_COLOR | (Rs/kR ,Gs/kG,Bs/kB,As/kA) |
GL_ONE_MINUS_SRC_COLOR | (1,1,1,1)-(Rs/kR,Gs/kG,Bs/kB,As/kA) |
GL_DST_COLOR | (Rd/kR,Gd/kG,Bd/kB,Ad/kA) |
GL_ONE_MINUS_DST_COLOR | (1,1,1,1)-(Rd/kR,Gd/kG,Bd/kB,Ad/kA) |
GL_SRC_ALPHA | (As/kA,As/kA,As/kA,As/kA) |
GL_ONE_MINUS_SRC_ALPHA | (1,1,1,1)-(As/kA,As/kA,As/kA,As/kA) |
GL_DST_ALPHA | (Ad/kA,Ad/kA,Ad/kA,Ad/kA) |
GL_ONE_MINUS_DST_ALPHA | (1,1,1,1)-(Ad/kA,Ad/kA,Ad/kA,Ad/kA) |
GL_SRC_ALPHA_SATURATE | (i,i,i,1) |
#include <windows.h> #include <GL/gl.h> #include <GL/glut.h> int width , height; void Draw(void); void Draw() { glBegin(GL_TRIANGLES); glVertex2f(-0.9 , -0.9); glVertex2f(0.9 , -0.9); glVertex2f(0 , 0.9); glEnd(); glViewport(0 , 0 , width , height); } void disp( void ) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glColor4f(1 , 0 , 0 , 0.7); glTranslatef(-0.5 , 0 , 0); Draw(); glPopMatrix(); glPushMatrix(); glColor4f(0 , 0 , 1 , 0.5); glTranslatef(0.5 , 0 , 0); Draw(); glPopMatrix(); glFlush(); } void reshape(int w , int h) { width = w; height = h; disp(); } int main(int argc , char ** argv) { glutInit(&argc , argv); glutInitWindowSize(400 , 300); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA); glutCreateWindow("Kitty on your lap"); glutDisplayFunc(disp); glutReshapeFunc(reshape); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA , GL_ONE); glutMainLoop(); return 0; }