protected SurfaceTextureProgram getShaderProgram(RenderContext rc) { SurfaceTextureProgram program = (SurfaceTextureProgram) rc.getShaderProgram(SurfaceTextureProgram.KEY); if (program == null) { program = (SurfaceTextureProgram) rc.putShaderProgram(SurfaceTextureProgram.KEY, new SurfaceTextureProgram(rc.resources)); } return program; } }
protected void determineActiveProgram(RenderContext rc) { this.activeProgram = (SurfaceTextureProgram) rc.getShaderProgram(SurfaceTextureProgram.KEY); if (this.activeProgram == null) { this.activeProgram = (SurfaceTextureProgram) rc.putShaderProgram(SurfaceTextureProgram.KEY, new SurfaceTextureProgram(rc.resources)); } }
/** * Prepares this placemark's icon or symbol for processing in a subsequent drawing pass. Implementations must be * careful not to leak resources from Placemark into the Drawable. * * @param rc the current render context * @param drawable the Drawable to be prepared */ protected void prepareDrawableIcon(RenderContext rc, DrawableScreenTexture drawable) { // Use the basic GLSL program to draw the placemark's icon. drawable.program = (BasicShaderProgram) rc.getShaderProgram(BasicShaderProgram.KEY); if (drawable.program == null) { drawable.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources)); } // Use the plaemark's unit square transform matrix. drawable.unitSquareTransform.set(unitSquareTransform); // Configure the drawable according to the placemark's active attributes. Use a color appropriate for the pick // mode. When picking use a unique color associated with the picked object ID. Use the texture associated with // the active attributes' image source and its associated tex coord transform. If the texture is not specified // or not available, draw a simple colored square. drawable.color.set(rc.pickMode ? this.pickColor : this.activeAttributes.imageColor); drawable.texture = this.activeTexture; drawable.enableDepthTest = this.activeAttributes.depthTest; }
/** * Prepares this placemark's leader for drawing in a subsequent drawing pass. Implementations must be careful not to * leak resources from Placemark into the Drawable. * * @param rc the current render context * @param drawable the Drawable to be prepared */ protected void prepareDrawableLeader(RenderContext rc, DrawableLines drawable) { // Use the basic GLSL program to draw the placemark's leader. drawable.program = (BasicShaderProgram) rc.getShaderProgram(BasicShaderProgram.KEY); if (drawable.program == null) { drawable.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources)); } // Compute the drawable's vertex points, in Cartesian coordinates relative to the placemark's ground point. drawable.vertexPoints[0] = 0; // groundPoint.x - groundPoint.x drawable.vertexPoints[1] = 0; // groundPoint.y - groundPoint.y drawable.vertexPoints[2] = 0; // groundPoint.z - groundPoint.z drawable.vertexPoints[3] = (float) (placePoint.x - groundPoint.x); drawable.vertexPoints[4] = (float) (placePoint.y - groundPoint.y); drawable.vertexPoints[5] = (float) (placePoint.z - groundPoint.z); // Compute the drawable's modelview-projection matrix, relative to the placemark's ground point. drawable.mvpMatrix.set(rc.modelviewProjection); drawable.mvpMatrix.multiplyByTranslation(groundPoint.x, groundPoint.y, groundPoint.z); // Configure the drawable according to the placemark's active leader attributes. Use a color appropriate for the // pick mode. When picking use a unique color associated with the picked object ID. drawable.color.set(rc.pickMode ? this.pickColor : this.activeAttributes.leaderAttributes.outlineColor); drawable.lineWidth = this.activeAttributes.leaderAttributes.outlineWidth; drawable.enableDepthTest = this.activeAttributes.leaderAttributes.depthTest; }
@Override protected void doRender(RenderContext rc) { if (rc.terrain.getSector().isEmpty()) { return; // no terrain to render } // Use WorldWind's basic GLSL program. BasicShaderProgram program = (BasicShaderProgram) rc.getShaderProgram(BasicShaderProgram.KEY); if (program == null) { program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources)); } Pool<DrawableTessellation> pool = rc.getDrawablePool(DrawableTessellation.class); Drawable drawable = DrawableTessellation.obtain(pool).set(program, this.color); rc.offerSurfaceDrawable(drawable, 1.0 /*z-order after surface textures*/); } }
drawState.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources));
protected void makeDrawable(RenderContext rc) { // Obtain a pooled drawable and configure it to draw the sightline's coverage. Pool<DrawableSightline> pool = rc.getDrawablePool(DrawableSightline.class); DrawableSightline drawable = DrawableSightline.obtain(pool); // Compute the transform from sightline local coordinates to world coordinates. drawable.centerTransform = rc.globe.cartesianToLocalTransform(this.centerPoint.x, this.centerPoint.y, this.centerPoint.z, drawable.centerTransform); drawable.range = (float) WWMath.clamp(this.range, 0, Float.MAX_VALUE); // Configure the drawable colors according to the current attributes. When picking use a unique color associated // with the picked object ID. Null attributes indicate that nothing is drawn. if (this.activeAttributes != null) { drawable.visibleColor.set(rc.pickMode ? this.pickColor : this.activeAttributes.interiorColor); } if (this.occludeAttributes != null) { drawable.occludedColor.set(rc.pickMode ? this.pickColor : this.occludeAttributes.interiorColor); } // Use the sightline GLSL program to draw the coverage. drawable.program = (SightlineProgram) rc.getShaderProgram(SightlineProgram.KEY); if (drawable.program == null) { drawable.program = (SightlineProgram) rc.putShaderProgram(SightlineProgram.KEY, new SightlineProgram(rc.resources)); } // Enqueue a drawable for processing on the OpenGL thread. rc.offerSurfaceDrawable(drawable, 0 /*z-order*/); } }
drawState.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources));
protected void renderGround(RenderContext rc) { if (rc.terrain.getSector().isEmpty()) { return; // no terrain surface to render on } Pool<DrawableGroundAtmosphere> pool = rc.getDrawablePool(DrawableGroundAtmosphere.class); DrawableGroundAtmosphere drawable = DrawableGroundAtmosphere.obtain(pool); drawable.program = (GroundProgram) rc.getShaderProgram(GroundProgram.KEY); if (drawable.program == null) { drawable.program = (GroundProgram) rc.putShaderProgram(GroundProgram.KEY, new GroundProgram(rc.resources)); } drawable.lightDirection.set(this.activeLightDirection); drawable.globeRadius = rc.globe.getEquatorialRadius(); // Use this layer's night image when the light location is different than the eye location. if (this.nightImageSource != null && this.lightLocation != null) { drawable.nightTexture = rc.getTexture(this.nightImageSource); if (drawable.nightTexture == null) { drawable.nightTexture = rc.retrieveTexture(this.nightImageSource, this.nightImageOptions); } } else { drawable.nightTexture = null; } rc.offerSurfaceDrawable(drawable, Double.POSITIVE_INFINITY /*z-order after all other surface drawables*/); }
protected void renderTerrainPickedObject(RenderContext rc) { if (rc.terrain.getSector().isEmpty()) { return; // no terrain to pick } // Acquire a unique picked object ID for terrain. int pickedObjectId = rc.nextPickedObjectId(); // Enqueue a drawable for processing on the OpenGL thread that displays terrain in the unique pick color. Pool<DrawableSurfaceColor> pool = rc.getDrawablePool(DrawableSurfaceColor.class); DrawableSurfaceColor drawable = DrawableSurfaceColor.obtain(pool); drawable.color = PickedObject.identifierToUniqueColor(pickedObjectId, drawable.color); drawable.program = (BasicShaderProgram) rc.getShaderProgram(BasicShaderProgram.KEY); if (drawable.program == null) { drawable.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources)); } rc.offerSurfaceDrawable(drawable, Double.NEGATIVE_INFINITY /*z-order before all other surface drawables*/); // If the pick ray intersects the terrain, enqueue a picked object that associates the terrain drawable with its // picked object ID and the intersection position. if (rc.pickRay != null && rc.terrain.intersect(rc.pickRay, this.pickPoint)) { rc.globe.cartesianToGeographic(this.pickPoint.x, this.pickPoint.y, this.pickPoint.z, this.pickPos); this.pickPos.altitude = 0; // report the actual altitude, which may not lie on the terrain's surface rc.offerPickedObject(PickedObject.fromTerrain(pickedObjectId, this.pickPos)); } }
protected void renderSky(RenderContext rc) { Pool<DrawableSkyAtmosphere> pool = rc.getDrawablePool(DrawableSkyAtmosphere.class); DrawableSkyAtmosphere drawable = DrawableSkyAtmosphere.obtain(pool); int size = 128; drawable.program = (SkyProgram) rc.getShaderProgram(SkyProgram.KEY); if (drawable.program == null) { drawable.program = (SkyProgram) rc.putShaderProgram(SkyProgram.KEY, new SkyProgram(rc.resources)); } drawable.vertexPoints = rc.getBufferObject(VERTEX_POINTS_KEY); if (drawable.vertexPoints == null) { drawable.vertexPoints = rc.putBufferObject(VERTEX_POINTS_KEY, this.assembleVertexPoints(rc, size, size, (float) drawable.program.getAltitude())); } drawable.triStripElements = rc.getBufferObject(TRI_STRIP_ELEMENTS_KEY); if (drawable.triStripElements == null) { drawable.triStripElements = rc.putBufferObject(TRI_STRIP_ELEMENTS_KEY, this.assembleTriStripElements(size, size)); } drawable.lightDirection.set(this.activeLightDirection); drawable.globeRadius = rc.globe.getEquatorialRadius(); rc.offerSurfaceDrawable(drawable, Double.POSITIVE_INFINITY /*z-order after all other surface drawables*/); }
drawState.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources));
drawable.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources));