OpenGLの例
|
#include <GL/glut.h>
void ohinit(void)
{
glClearColor(0.0,0.0,0.4,0.0);
glFrontFace(GL_CW);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
}
void ohreshape(int w,int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-1.2,1.2,-1.2,1.2);
glMatrixMode(GL_MODELVIEW);
}
void ohdraw(void)
{
glBegin(GL_TRIANGLE_FAN);
glColor3f(0.0,0.0,1.0); glVertex3f(0.0,0.0,1.0);
glColor3f(1.0,0.0,0.0); glVertex3f(1.0,0.0,0.0);
glColor3f(0.0,1.0,0.0); glVertex3f(0.0,1.0,0.0);
glColor3f(0.0,1.0,1.0); glVertex3f(-1.0,0.0,0.0);
glColor3f(1.0,0.0,1.0); glVertex3f(0.0,-1.0,0.0);
glColor3f(1.0,0.0,0.0); glVertex3f(1.0,0.0,0.0);
glEnd();
glBegin(GL_TRIANGLE_FAN);
glColor3f(1.0,1.0,0.0); glVertex3f(0.0,0.0,-1.0);
glColor3f(1.0,0.0,0.0); glVertex3f(1.0,0.0,0.0);
glColor3f(1.0,0.0,1.0); glVertex3f(0.0,-1.0,0.0);
glColor3f(0.0,1.0,1.0); glVertex3f(-1.0,0.0,0.0);
glColor3f(0.0,1.0,0.0); glVertex3f(0.0,1.0,0.0);
glColor3f(1.0,0.0,0.0); glVertex3f(1.0,0.0,0.0);
glEnd();
}