1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <windows.h>
#include <stdlib.h>
#include <GL/glut.h>
bool destroy = false;
int x = 0;
int y = 0;
void reshape (int w, int h)
{
if(h == 0)
h = 1;
float ratio = 1.0 * w/h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,w,h);
gluPerspective(45,ratio,1,1000);
gluLookAt(0.0,0.0,20.0,
0.0,0.0,0.0,
0.0f,1.0f,0.0f);
glMatrixMode(GL_MODELVIEW);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(destroy == false)
{
glPushMatrix();
glTranslated(x,y,0);
glBegin(GL_QUADS);
glVertex2f(0.0,0.0);
glVertex2f(2.0,0.0);
glVertex2f(2.0,2.0);
glVertex2f(0.0,2.0);
glEnd();
glPopMatrix();
}
glutSwapBuffers();
}
void mouse(int b,int s,int x,int y)
{
////////// ?????????????????????????????????????????????
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Mouse");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutReshapeFunc(reshape);
glutMainLoop();
}
|