/* Minimal OpenGL code to replicate part of * https://bugzilla.opensuse.org/show_bug.cgi?id=1021803 * * gcc -Wall -Wextra -pedantic -o missing-pixels missing-pixels.c -lglut -lGL -lGLU */ #include #ifdef __APPLE__ #include #include #include #else #include #include #include #endif /**************************** * GLUT window event handlers ***************************/ void on_display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Some context. * Black. */ glColor3f(0.0, 0.0, 0.0); glBegin(GL_LINE_STRIP); glVertex3f(11, 10, 0); glVertex3f(20, 10, 0); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(11, 20, 0); glVertex3f(20, 20, 0); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(30, 11, 0); glVertex3f(30, 20, 0); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(40, 11, 0); glVertex3f(40, 20, 0); glEnd(); /* The problematic lines. * Problematic renderers omit the first pixel. * Red. */ glColor3f(1.0, 0.5, 0.5); glBegin(GL_LINE_STRIP); glVertex3f(10, 20, 0); glVertex3f(10, 10, 0); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(40, 10, 0); glVertex3f(30, 10, 0); glEnd(); glFlush(); glutSwapBuffers(); } void on_reshape(int w, int h) { /* Set up the Viewport transformation */ glViewport(0, 0, (GLsizei) w, (GLsizei) h); /* Set up the Projection transformation */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, w-1, h-1, 0); /* Switch to Model/view transformation for drawing objects */ glMatrixMode(GL_MODELVIEW); } /**************************** * Main function ***************************/ int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); /* Init GL */ glClearColor(1.0, 1.0, 1.0, 0.0); glShadeModel(GL_FLAT); /* glShadeModel(GL_SMOOTH); */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* Init camera matrix */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* Register callbacks */ glutDisplayFunc(on_display); glutReshapeFunc(on_reshape); glutMainLoop(); return 0; }