Rebuild display list

I’ve got a display list being called to render some points on the screen. I want the user to press a button, have the display list re-created with the new points and then drawn but this isn’t working.

The points are rendered initially however the list isn’t being redrawn when edited?

public void buildFunctions(GL gl, int function) {
        functionList = gl.glGenLists(1);
        switch(function) {
            case 0 :
            {
                for (int n=0;n<3142;n++) {
                double x=(-1*3.14159)+(n*.002);
                dataX [n] = x;
                dataY [n] = x*x*x;
             }
                System.out.println("Y : " + dataY[0]);
            gl.glNewList(functionList, GL.GL_COMPILE);
                 for (float r=0;r<360;r++)
                {
                    gl.glRotated(r,xaxis,yaxis,zaxis);
                    gl.glBegin(GL.GL_POINTS);
                    gl.glColor3d (xaxis*.225+(1/(Math.random()%100+1)), yaxis*.225, zaxis*.225+(1/(Math.random()%100+1)));
                    for(int i = 0; i < dataX.length; i+= 10) {
                        gl.glVertex3d(dataX[i], dataY[i],0);
                    }
                    gl.glEnd();
                }
            gl.glEndList();
            break;
            }


            case 1:
            {
                for (int n=0;n<3142;n++) {
                double x=(-1*3.14159)+(n*.002);
                dataX [n] = x;
                dataY [n] = Math.tan(x);
             }
                System.out.println(dataY[0]);
                gl.glNewList(functionList, GL.GL_COMPILE);
                 for (float r=0;r<360;r++)
                {
                    gl.glRotated(r,xaxis,yaxis,zaxis);
                    gl.glBegin(GL.GL_POINTS);
                    gl.glColor3d (xaxis*.225+(1/(Math.random()%100+1)), yaxis*.225, zaxis*.225+(1/(Math.random()%100+1)));
                    for(int i = 0; i < dataX.length; i+= 10) {
                        gl.glVertex3d(dataX[i], dataY[i],0);
                    }
                    gl.glEnd();
                }
            gl.glEndList();
            break;
            }
        }
    }

Thanks

It’s unclear from your code what else is going on in your program…

Three things I noticed…

  1. You keep generating a new list at the top of your function, and re-assigning it to the same variable. At the very least this is going to cause a memory leak of some kind, unless you are deleting that list elsewhere.

  2. You are using GL_COMPILE, which will simply create the DL, where as GL_COMPILE_AND_EXECUTE will actually make the list and draw it at the same time.
    Perhaps you are drawing your list elsewhere?

  3. You keep applying a rotation to the Matrix. I can’t see what matrix mode you are in, or where the matrix is setup initially so it’s hard to comment on what is going on there, but that also could be a problem.

ok cool thanks. I’ll take a look through things and see if I can get it to work. Thanks