/** Draws circular particle using a display list. */ public void display(GL gl) { if (PARTICLE_DISPLAY_LIST < 0) { // MAKE DISPLAY LIST: int displayListIndex = gl.glGenLists(1); gl.glNewList(displayListIndex, GL.GL_COMPILE); drawParticle(gl, new Point3d(), radius); // /particle at origin gl.glEndList(); System.out.println("MADE LIST " + displayListIndex + " : " + gl.glIsList(displayListIndex)); PARTICLE_DISPLAY_LIST = displayListIndex; } // / COLOR: DEFAULT WHITE; GREEN IF HIGHLIGHTED; ADD RED IF PINNED Color3f c = new Color3f(1, 1, 1); // default: white if (pin) { c.x = 1f; // add red c.y *= 0.2f; c.z = 0; } if (highlight) { c.y = 1; c.z = 0; } if (GooParticle.class.isInstance(this)) { c.x = 0; c.y = 0; // now its blue } gl.glColor3f(c.x, c.y, c.z); // / DRAW ORIGIN-CIRCLE TRANSLATED TO "p": gl.glPushMatrix(); gl.glTranslated(x.x, x.y, x.z); gl.glCallList(PARTICLE_DISPLAY_LIST); gl.glPopMatrix(); }
/** * Renders the tile to the given context, in the process building all needed resources. * * @param gl */ public void render(GL gl) { projection = ProjectionFactory.getCurrentProjection(); heightmap = State.getInstance().getLoadedHeightmap(); // BUILD TEXTURES IF NECESSARY if (!gl.glIsTexture(textureID)) { textureID = createTexture(gl, getImage(), false); // prerenderToTexture(gl); } if (!gl.glIsTexture(grainTextureID)) { createGrainTexture(gl); } // RENDER TILE FROM DISPLAY LIST, OR ELSE BUILD DISPLAY LIST if (gl.glIsList(displaylistID)) { gl.glCallList(displaylistID); } else { displaylistID = gl.glGenLists(1); gl.glNewList(displaylistID, GL_COMPILE_AND_EXECUTE); gl.glActiveTexture(GL_TEXTURE0); gl.glEnable(GL_TEXTURE_2D); gl.glBindTexture(GL_TEXTURE_2D, grainTextureID); gl.glActiveTexture(GL_TEXTURE1); gl.glEnable(GL_TEXTURE_2D); gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); gl.glBindTexture(GL_TEXTURE_2D, textureID); gl.glColor3f(1, 1, 1); float[] color = new float[3]; float hRes = HEIGHT_RESOLUTION - 1; float stepSize = bounds.getWidth() / hRes; Coordinates pos = new Coordinates(); for (int x = 0; x < hRes; x++) { gl.glBegin(GL_TRIANGLE_STRIP); for (int y = 0; y <= hRes; y++) { for (int i = 0; i < 2; i++) { pos.setLatitude(bounds.getTop() + y * stepSize); pos.setLongitude(bounds.getLeft() + (x + i) * stepSize); gl.glMultiTexCoord2f( GL_TEXTURE0, (x + i) / (float) GRAIN_RESOLUTION, y / (float) GRAIN_RESOLUTION); gl.glMultiTexCoord2f(GL_TEXTURE1, (x + i) / hRes, y / hRes); float height = heights[x + HEIGHT_BORDER + i][y + HEIGHT_BORDER]; getHeightColor(color, height); float shade = getShade(x + i, y, stepSize); gl.glColor3f(color[0] * shade, color[1] * shade, color[2] * shade); gl.glVertex3f(pos.getLongitude(), pos.getLatitude(), height); } } gl.glEnd(); } gl.glDisable(GL_TEXTURE_2D); gl.glActiveTexture(GL_TEXTURE0); renderPOIs(gl); gl.glEndList(); } }
/** * We want to draw the scene using a display list to make it fast when using the IDENT style * (i.e., avoid recomputing all the face colours) * * @param drawable * @param style */ private void draw(GLAutoDrawable drawable, DrawStyle style) { GL gl = drawable.getGL(); if (listID != -1) { gl.glCallList(listID); } else { listID = gl.glGenLists(1); gl.glNewList(listID, GL.GL_COMPILE_AND_EXECUTE); scene.draw(drawable, style); gl.glEndList(); } }
public void beginPreRender(Dimension size) { currentCallList = gl.glGenLists(1); currentCallListSize = size; gl.glNewList(currentCallList, GL.GL_COMPILE); }