public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); // gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glColor3f(1.0f, 1.0f, 1.0f); gl.glCallList(startList); gl.glCallList(startList + 1); gl.glFlush(); }
@Override public void drawGl(GL2 gl) { if (this.displayList == -1) { generateDisplaylist(gl); } gl.glCallList(displayList); }
@Override public void draw(final GL2 gl, final boolean picking) { JOGLRenderer renderer = drawer.getRenderer(); gl.glColor3d(1.0, 1.0, 1.0); if (picking) { if (renderer.colorPicking) { gl.glDisable(GL.GL_DITHER); gl.glDisable(GLLightingFunc.GL_LIGHTING); gl.glDisable(GL.GL_TEXTURE); int viewport[] = new int[4]; gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); FloatBuffer pixels = FloatBuffer.allocate(4); gl.glReadPixels( renderer.camera.getLastMousePressedPosition().x, viewport[3] - renderer.camera.getLastMousePressedPosition().y, 1, 1, GL.GL_RGBA, GL.GL_FLOAT, pixels); gl.glEnable(GL.GL_DITHER); gl.glEnable(GLLightingFunc.GL_LIGHTING); gl.glEnable(GL.GL_TEXTURE); // Color index = new Color(pixels.get(0), pixels.get(1), pixels.get(2)); // System.out.println("color picked " + index.toString()); } else { gl.glPushMatrix(); gl.glInitNames(); gl.glPushName(0); double alpha = 0d; int size = objects.size(); double delta = size == 0 ? 0 : 1d / size; for (final List<T> list : objects) { alpha = alpha + delta; for (T object : list) { if (isFading) { double originalAlpha = object.getAlpha(); object.setAlpha(originalAlpha * alpha); object.draw(gl, drawer, picking); object.setAlpha(originalAlpha); } else { object.draw(gl, drawer, picking); } } } gl.glPopName(); gl.glPopMatrix(); } } else if (drawAsList) { Integer index = openGLListIndex; if (index == null) { index = gl.glGenLists(1); gl.glNewList(index, GL2.GL_COMPILE); double alpha = 0d; int size = objects.size(); double delta = size == 0 ? 0 : 1d / size; for (final List<T> list : objects) { alpha = alpha + delta; for (T object : list) { if (isFading) { double originalAlpha = object.getAlpha(); object.setAlpha(originalAlpha * alpha); object.draw(gl, drawer, picking); object.setAlpha(originalAlpha); } else { object.draw(gl, drawer, picking); } } } gl.glEndList(); } gl.glCallList(index); openGLListIndex = index; } else if (drawAsVBO) { if (vah == null) { GLU glu = renderer.getGlu(); vah = new VertexArrayHandler(gl, glu, renderer); vah.buildVertexArray(getObjects()); } else { // vah.loadCollada(null); } } else { for (final T object : getObjects()) { object.draw(gl, drawer, picking); } } }