/** * @param glRenderContext */ public void disable( RenderContext glRenderContext ) { if ( shaderProgram != null ) { shaderProgram.disable( glRenderContext.getContext() ); } }
@Override public void render( RenderContext glRenderContext ) { drawCube( glRenderContext.getContext() ); }
/** * Load the dem fragment on the GPU, in other words, enable the VBO's, of the normals, vertices and indizes. * * @param glRenderContext */ private void loadDEMOnGPU( RenderContext glRenderContext ) { long begin = System.currentTimeMillis(); try { fragmentManager.requireOnGPU( activeLOD, glRenderContext.getContext() ); } catch ( IOException e ) { LOG.debug( "Could not load the fragments on the gpu, stack.", e ); LOG.error( "Could not load the fragments on the gpu because: " + e.getMessage() ); } LOG.debug( "GPU upload of " + activeLOD.size() + " fragments: " + ( System.currentTimeMillis() - begin ) + " milliseconds." ); }
@Override public void disableArrays( RenderContext glRenderContext ) { super.disableArrays( glRenderContext ); LOG.trace( "Disabling array state and texture 2d" ); glRenderContext.getContext().glDisableClientState( GL.GL_TEXTURE_COORD_ARRAY ); glRenderContext.getContext().glDisable( GL.GL_TEXTURE_2D ); }
/** * Create a dem lod for the given render context. * * @param glRenderContext * @param scale * @param textureManagers */ private void updateLOD( RenderContext glRenderContext, float scale, TextureManager[] textureManagers ) { long begin = System.currentTimeMillis(); Set<RenderMeshFragment> nextLOD = getNewLOD( glRenderContext, scale, textureManagers ); // determine fragments that can be released for the next frame Set<RenderMeshFragment> unloadFragments = new HashSet<RenderMeshFragment>( activeLOD ); unloadFragments.removeAll( nextLOD ); fragmentManager.release( unloadFragments, glRenderContext.getContext() ); activeLOD = nextLOD; try { fragmentManager.require( activeLOD ); } catch ( IOException e ) { LOG.error( "Could not load all required DEM LOD fragments for the given render context stack.", e ); LOG.error( "Could not load all required DEM LOD fragments for the given render context because: " + e.getLocalizedMessage() ); } LOG.debug( "Loading of " + activeLOD.size() + " fragments: " + ( System.currentTimeMillis() - begin ) + " milliseconds." ); }
private void renderCopyright() { Texture copyImage = TexturePool.getTexture( glRenderContext, copyrightID ); if ( copyImage != null ) { float tH = copyImage.getHeight(); float tW = copyImage.getWidth(); float quadWidth = tW; float quadHeight = tH; glRenderContext.getContext().glEnable( GL.GL_ALPHA_TEST ); glRenderContext.getContext().glAlphaFunc( GL.GL_GREATER, 0.4f ); draw2D( 0, 0, quadWidth, quadHeight, copyImage, true ); glRenderContext.getContext().glDisable( GL.GL_ALPHA_TEST ); glRenderContext.getContext().glAlphaFunc( GL.GL_ALWAYS, 1 ); } }
@Override protected void enableArrays( RenderContext glRenderContext, DirectGeometryBuffer geomBuffer ) { super.enableArrays( glRenderContext, geomBuffer ); if ( texturePosition >= 0 && textureBuffer == null && geomBuffer != null ) { textureBuffer = geomBuffer.getTextureCoordinates( texturePosition, textureOrdinatesCount ); if ( textureBuffer == null ) { texturePosition = -1; } } if ( textureBuffer != null ) { glRenderContext.getContext().glEnable( GL.GL_TEXTURE_2D ); TexturePool.loadTexture( glRenderContext, texture ); glRenderContext.getContext().glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY ); glRenderContext.getContext().glTexCoordPointer( 2, GL.GL_FLOAT, 0, textureBuffer ); } }
/** * Render the fragments with a colormap * * @param glRenderContext * @param colorMap */ private void render( RenderContext glRenderContext, Colormap colorMap ) { colorMap.enable( glRenderContext ); render( glRenderContext.getContext() ); colorMap.disable( glRenderContext ); }
/** * @param gl */ private void renderCopyright( RenderContext context ) { Texture copyImage = TexturePool.getTexture( context, copyrightID ); if ( copyImage != null ) { float tH = copyImage.getHeight(); float tW = copyImage.getWidth(); float quadWidth = tW; float quadHeight = tH; /** * rb: Scaling of copyright image could be realized with following code. */ // if ( width > height ) { // quadWidth = (float) ( width * copyrightScale ); // quadHeight = quadWidth * ( ( tW > tH ) ? ( tH / tW ) : ( tW / tH ) ); // } else { // quadHeight = (float) ( height * copyrightScale ); // // if the width of the texture is larger then the height, use the scalediff to calculate the texwidth. // quadWidth = quadHeight * ( ( tW > tH ) ? ( tW / tH ) : ( tH / tW ) ); // } context.getContext().glEnable( GL.GL_ALPHA_TEST ); context.getContext().glAlphaFunc( GL.GL_GREATER, 0.4f ); draw2D( context, 0, 0, quadWidth, quadHeight, copyImage, true ); context.getContext().glDisable( GL.GL_ALPHA_TEST ); context.getContext().glAlphaFunc( GL.GL_ALWAYS, 1 ); } }
createColors(); glRenderContext.getContext().glVertexPointer( 3, GL.GL_FLOAT, 0, coordBuffer ); if ( hasNormals ) { LOG.trace( "Loading normal buffer" ); glRenderContext.getContext().glNormalPointer( GL.GL_FLOAT, 0, normalBuffer );
long begin = System.currentTimeMillis(); ViewParams params = glRenderContext.getViewParams(); GL context = glRenderContext.getContext(); params.getViewFrustum().getEyePos(); Set<WorldRenderableObject> buildings = getObjects( params );
GL gl = glRenderContext.getContext(); for ( RenderMeshFragment fragment : activeLOD ) { List<FragmentTexture> textures = fragmentToTextures.get( fragment );
@Override public void render( RenderContext glRenderContext ) { ViewParams params = glRenderContext.getViewParams(); GL context = glRenderContext.getContext(); long begin = System.currentTimeMillis(); Point3d eye = params.getViewFrustum().getEyePos();
GL gl = glRenderContext.getContext();
/** * @param glRenderContext * @param prototype * @param buffer * to be used for rendering. */ public synchronized static void render( RenderContext glRenderContext, PrototypeReference prototype, DirectGeometryBuffer buffer ) { if ( prototype == null || prototype.getPrototypeID() == null ) { return; } RenderablePrototype model = prototypes.get( prototype.getPrototypeID() ); if ( model == null ) { LOG.warn( "No model found for prototype: " + prototype.getPrototypeID() ); return; } GL context = glRenderContext.getContext(); context.glPushMatrix(); float[] loc = prototype.getLocation(); context.glTranslatef( loc[0], loc[1], loc[2] ); context.glRotatef( prototype.getAngle(), 0, 0, 1 ); context.glScalef( prototype.getWidth(), prototype.getDepth(), prototype.getHeight() ); if ( buffer == null ) { model.render( null ); } else { model.renderPrepared( glRenderContext, buffer ); } context.glPopMatrix(); }
public void renderPrepared( RenderContext glRenderContext, DirectGeometryBuffer geomBuffer ) { enableArrays( glRenderContext, geomBuffer ); GL context = glRenderContext.getContext(); normalBuffer.rewind(); context.glPushAttrib( GL.GL_CURRENT_BIT | GL.GL_LIGHTING_BIT ); // context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, ambientColor, 0 ); context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, diffuseColor, 0 ); context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, specularColor, 0 ); context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, emmisiveColor, 0 ); context.glMaterialf( GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, style.getShininess() ); context.glDrawArrays( openGLType, 0, vertexCount ); context.glPopAttrib(); disableArrays( glRenderContext ); }
/** * @param glRenderContext */ public void enable( RenderContext glRenderContext ) { GL gl = glRenderContext.getContext(); if ( shaderProgram == null ) { if ( !setupShaderProgram( gl ) ) { this.shaderProgram = null; return; } } if ( shaderProgram.useProgram( gl ) ) { int mCLoc = gl.glGetUniformLocation( shaderProgram.getOGLId(), UNIFORM_MIN_COLOR ); int maxCLoc = gl.glGetUniformLocation( shaderProgram.getOGLId(), UNIFORM_HEIGHT_COLOR ); int dVLoc = gl.glGetUniformLocation( shaderProgram.getOGLId(), UNIFORM_DIFF_VEC ); int miZLoc = gl.glGetUniformLocation( shaderProgram.getOGLId(), UNIFORM_MIN_Z ); if ( mCLoc == -1 || maxCLoc == -1 || dVLoc == -1 || miZLoc == -1 ) { LOG.warn( "Could not get uniform location of Vertex shader, no color map is enabled: {},{},{},{}.", new Object[] { mCLoc, maxCLoc, dVLoc, miZLoc, } ); return; } gl.glUniform4f( mCLoc, minColor[0], minColor[1], minColor[2], 1 ); gl.glUniform4f( maxCLoc, heightColor[0], heightColor[1], heightColor[2], 1 ); gl.glUniform4f( dVLoc, difVec[0], difVec[1], difVec[2], 1 ); gl.glUniform4f( miZLoc, zMin, invDifZ, 0, 0 ); } }
private void debug( RenderContext context ) { GL gl = context.getContext(); gl.glPushAttrib( GL.GL_CURRENT_BIT | GL.GL_LIGHTING_BIT ); gl.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[] { 1, 0, 0 }, 0 ); gl.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, new float[] { 1, 0, 0 }, 0 ); float[] bbox = getModelBBox(); gl.glBegin( GL.GL_QUADS ); // Front face gl.glNormal3f( 0, 0, 1 ); gl.glVertex3f( bbox[0], bbox[1], bbox[2] ); gl.glVertex3f( bbox[3], bbox[4], bbox[2] ); gl.glVertex3f( bbox[3], bbox[4], bbox[5] ); gl.glVertex3f( bbox[0], bbox[1], bbox[5] ); gl.glEnd(); gl.glPopAttrib(); } }
@Override public void render( RenderContext glRenderContext ) { Point3d eye = glRenderContext.getViewParams().getViewFrustum().getEyePos(); GL context = glRenderContext.getContext(); context.glPushMatrix(); context.glDepthMask( false ); context.glEnable( GL.GL_TEXTURE_2D ); context.glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY ); // the translation context.glTranslatef( location[0], location[1], location[2] ); // the rotation calculateAndSetRotation( context, new float[] { (float) eye.x, (float) eye.y, (float) eye.z } ); context.glScalef( width, 1, height ); TexturePool.loadTexture( glRenderContext, textureID ); // context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, new float[] { 1, 1, 1, .1f }, 0 ); context.glVertexPointer( 3, GL.GL_FLOAT, 0, coordBuffer ); context.glTexCoordPointer( 2, GL.GL_FLOAT, 0, textureBuffer ); // context.glDisableClientState( GL.GL_NORMAL_ARRAY ); context.glDrawArrays( GL.GL_QUADS, 0, 4 ); context.glDisableClientState( GL.GL_TEXTURE_COORD_ARRAY ); context.glDisable( GL.GL_TEXTURE_2D ); context.glDepthMask( true ); context.glMatrixMode( GL.GL_MODELVIEW ); context.glPopMatrix(); }
GL gl = glRenderContext.getContext(); if ( !useDepth ) { gl.glDisable( GL.GL_DEPTH_TEST );