#include<windows.h>
#include<math.h>
#include<GL/gl.h>
#include<GL/glu.h>
#include<GL/glaux.h>
int static left=0;
int static right=0;
int static up=0;
int static down=0;
int static aleft=0;
int static dright=0;
int static wup=0;
int static sdown=0;
void myinit(void);
void CALLBACK myReshape(GLsizei w,GLsizei h);
void CALLBACK display();
void CALLBACK toleft();
void CALLBACK toright();
void CALLBACK toup();
void CALLBACK todown();
void CALLBACK aaleft();
void CALLBACK ddright();
void CALLBACK wwup();
void CALLBACK ssdown();
void draw();
void myinit(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glShadeModel(GL_FLAT);
}
void CALLBACK myReshape(GLsizei w,GLsizei h)
{
glViewport(0.0,0.0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<h)
glOrtho(-10.0,10.0,-10.0*(GLfloat)h/(GLfloat)w,10.0*(GLfloat)w/(GLfloat)h,-10.0,10.0);
else
glOrtho(-10.0*(GLfloat)w/(GLfloat)h,10.0*(GLfloat)w/(GLfloat)h,-10.0,10.0,-10.0,10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void CALLBACK display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 1.0);
glPushMatrix();
glTranslatef(aleft,wup,0.0);
glTranslatef(dright,sdown,0.0);
glRotatef(left,0.0,1.0,0.0);
glRotatef(right,0.0,1.0,0.0);
glRotatef(up,1.0,0.0,0.0);
glRotatef(down,1.0,0.0,0.0);
draw();
glPopMatrix();
glFlush();
}
void draw()
{
auxWireSphere(3.0);
}
void CALLBACK toleft()
{
left=left+10;
}
void CALLBACK toright()
{
right=right-10;
}
void CALLBACK toup()
{
up=up+10;
}
void CALLBACK todown()
{
down=down-10;
}
void CALLBACK aaleft()
{
aleft=aleft-1;
}
void CALLBACK ddright()
{
dright=dright+1;
}
void CALLBACK wwup()
{
wup=wup+1;
}
void CALLBACK ssdown()
{
sdown=sdown-1;
}
void main()
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0.0,0.0,500,500);
auxInitWindow("test");
myinit();
auxKeyFunc(AUX_LEFT,toleft);
auxKeyFunc(AUX_RIGHT,toright);
auxKeyFunc(AUX_UP,toup);
auxKeyFunc(AUX_DOWN,todown);
auxKeyFunc(AUX_a,aaleft);
auxKeyFunc(AUX_d,ddright);
auxKeyFunc(AUX_w,wwup);
auxKeyFunc(AUX_s,ssdown);
auxReshapeFunc(myReshape);
auxMainLoop(display);
}