Last active
January 3, 2016 06:29
-
-
Save Lekensteyn/8423151 to your computer and use it in GitHub Desktop.
Attempt to debug https://bugs.freedesktop.org/show_bug.cgi?id=72926
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* cc -g -Wall -Wextra -fsanitize=address robot.c -lGL -lglut -lGLU -o robot */ | |
#include <stdio.h> /* for printf of glError */ | |
#include <GL/glut.h> | |
void display(void) { | |
glClear(GL_COLOR_BUFFER_BIT); | |
// draw axis | |
glLineWidth(2); | |
glBegin(GL_LINES); | |
// 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: */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment