I've created a simple GLUT program that should simply draw a triangle:
#include <GL/glut.h>
#include <iostream>
using namespace std;
void render(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
cout << "ran" << endl;
glutSwapBuffers();
}
void update(int value) {
static_cast<void>(value);
glutPostRedisplay();
glutTimerFunc(16, update, 0);
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0, 0);
glutInitWindowSize(1000, 1000);
glutCreateWindow("window");
glutDisplayFunc(render);
glutTimerFunc(25, update, 0);
glutMainLoop();
return 1;
}
...but it has unexpected results:
When I don't have the update function, it seems to only show the weird screen once and then it fixes itself. It also shows the correct display when dragging the window around. I think it may be an issue with my machine? I've been able to use OpenGL and GLUT before in the past.
I had this exact issue, same visuals, same environment. I feel silly for not trying earlier, but wsl --update
and then a restart fixed this for me.