/* cc -g -Wall -Wextra -fsanitize=address robot.c -lGL -lglut -lGLU -o robot */ #include /* for printf of glError */ #include void display(void) { glClear(GL_COLOR_BUFFER_BIT); // draw axis glLineWidth(2); glBegin(GL_POINTS); // y-axis glVertex2i(0, -100); glVertex2i(0, 100); // x-axis glVertex2i(-100, 0); glVertex2i( 100, 0); glEnd(); glBegin(GL_TRIANGLES); // positive Y-axis head (left, right, top) glVertex2i(-10, 100); glVertex2i( 10, 100); glVertex2i( 0, 120); glEnd(); printf("%s\n", gluErrorString(glGetError())); glFlush(); // exit(0); } void reshape(int w, int h) { glViewport(0, 0, w, h); glLoadIdentity(); glMatrixMode(GL_PROJECTION); gluOrtho2D(0.0, w, 0.0, h); //glTranslatef(50, 50, 0); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(0); glutInitWindowPosition(100, 100); glutInitWindowSize(300, 200); glutCreateWindow(argv[0]); glutDisplayFunc(display); glutReshapeFunc(reshape); glEnable(GL_LINE_SMOOTH); //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glClearColor(1.0, 1.0, 1.0, 1.0); glColor3f(1.0, 0.0, 0.0); reshape(300, 200); glutMainLoop(); return 0; } /* vim: set sw=4 ts=4 et: */