12-28-2005, 09:15 AM
Anyone can tell me why this code don't compile!
Onde person gave me this code to compile on my computer to now if it is well installed.
only one more thing why i don't have glut.h????
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#define DimWX 400 /*Dimensoes da janela */
#define DimWY 200
int point_x= DimWX/2, point_y=DimWY/2;
void init (void);
void display (void);
void keyboard (unsigned char key, int x, int y);
int main(int argc, char * argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(DimWX, DimWY);
glutInitWindowPosition (100,100);
glutCreateWindow("Mover o ponto com n, s, e, w");
init();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
void init(void) {
glClearColor(1.0, 1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0, DimWX, 0, DimWY);
}
void display (void) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POINTS);
glVertex2i(point_x, point_y);
glEnd();
glFlush();
}
void keyboard (unsigned char key, int x, int y) {
switch (key) {
case 'q':
exit(0);
break;
case 'n':
point_y += 1;
break;
case 's':
point_y -= 1;
break;
case 'e':
point_x -= 1;
break;
case 'w':
point_x +=1;
break;
}
printf("px=%d py=%d, x=%d y=%d \n", point_x, point_y, x, y);
glutPostRedisplay();
}PS: sory my lasy english
Onde person gave me this code to compile on my computer to now if it is well installed.
only one more thing why i don't have glut.h????
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#define DimWX 400 /*Dimensoes da janela */
#define DimWY 200
int point_x= DimWX/2, point_y=DimWY/2;
void init (void);
void display (void);
void keyboard (unsigned char key, int x, int y);
int main(int argc, char * argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(DimWX, DimWY);
glutInitWindowPosition (100,100);
glutCreateWindow("Mover o ponto com n, s, e, w");
init();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
void init(void) {
glClearColor(1.0, 1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0, DimWX, 0, DimWY);
}
void display (void) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POINTS);
glVertex2i(point_x, point_y);
glEnd();
glFlush();
}
void keyboard (unsigned char key, int x, int y) {
switch (key) {
case 'q':
exit(0);
break;
case 'n':
point_y += 1;
break;
case 's':
point_y -= 1;
break;
case 'e':
point_x -= 1;
break;
case 'w':
point_x +=1;
break;
}
printf("px=%d py=%d, x=%d y=%d \n", point_x, point_y, x, y);
glutPostRedisplay();
}PS: sory my lasy english