li20034
Posts: 2
Joined: Fri Jun 14, 2019 2:29 pm

OpenGL 2.1 glLineStipple not working on Pi 4

Thu Mar 26, 2020 6:52 pm

Hi,

I'm not sure if this is the correct place to post this, but, it seems that glLineStipple isn't working with OpenGL 2.1 on the Pi 4. I'm currently using the latest image and have run apt-get update and apt-get dist-upgrade. The function is supposed to make lines dotted, however, the lines appear solid regardless. Here's some sample code that demonstrates that.

Code: Select all

//This code only works with OpenGL 2.1
//compile with: gcc -O2 -s -o gl_stipple_test gl_stipple_test.c -lGL -lglut

#include <GL/glut.h>  // GLUT, include glu.h and gl.h

int ww = 320, wh = 320, wid;

void initGL() {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //set background to opaque black
    
    glLineStipple(1, 0xc0c0);
    glEnable(GL_LINE_STIPPLE);
    
    glColor3ub(0, 128, 0);
}

void display() {
    glClear(GL_COLOR_BUFFER_BIT); //clear color buffer
    
    glBegin(GL_LINES);
    glVertex2i(ww / 2, 0);
    glVertex2i(ww / 2, wh);
    
    glVertex2i(0, wh / 2);
    glVertex2i(ww, wh / 2);
    glEnd();
    
    glutSwapBuffers(); //render
}

void reshape(int w, int h) {
    wh = h;   
    ww = w;
    
    glViewport(0, 0, ww, wh); //map viewport to window
    
    glMatrixMode(GL_PROJECTION); //modify projection matrix
    glLoadIdentity(); //reset projection matrix
    
    //use absolute coordinates, inverted y-axis (0, 0) -> top left
    glOrtho(0, ww, wh, 0, -1, 1);
    
    //reset to model mode so we can draw stuff
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}

int main(int argc, char** argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE); //Set double buffered mode

    glutInitWindowSize(ww, wh);
    wid = glutCreateWindow("glLineStipple test");
    
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    
    initGL(); //initialize GL params
    glutMainLoop(); //Enter the event-processing loop
}
Using the V3D mesa drivers, the lines appear solid. However, running with mesa's llvmpipe software renderer (using LIBGL_ALWAYS_SOFTWARE=1), the lines appear dotted as expected. And on a laptop with Intel HD 4400 graphics, the lines also appear dotted.

So I'm wondering if I made a mistake somehow, or if there's a problem with V3D.

Return to “Graphics programming”