當前位置: 首頁>>代碼示例>>Java>>正文


Java GL2.glPolygonOffset方法代碼示例

本文整理匯總了Java中javax.media.opengl.GL2.glPolygonOffset方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glPolygonOffset方法的具體用法?Java GL2.glPolygonOffset怎麽用?Java GL2.glPolygonOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.glPolygonOffset方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param openGl
 */
public final synchronized void draw(final GL2 openGl) {
    if (points == null || points.size() == 0) {
        return;
    }
    AbstractDoubleCordinateBuffer.bindIfExists(verticesBuf, openGl);
    openGl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
    openGl.glPolygonOffset(1.0f, 1.0f);
    AbstractDoubleCordinateBuffer.bindIfExists(lineColorBuf, openGl);
    indicesBuf.drawLine(openGl, GL2.GL_LINE_LOOP, GL2.GL_FRONT_AND_BACK);
    AbstractDoubleCordinateBuffer.unBindExists(lineColorBuf, openGl);
    AbstractDoubleCordinateBuffer.bindIfExists(pointColorBuf, openGl);

    float[] f = new float[1];
    openGl.glGetFloatv(GL2.GL_POINT_SIZE, f, 0);
    openGl.glPointSize(3.0f);
    indicesBuf.drawLine(openGl, GL2.GL_POINTS, GL2.GL_FRONT);
    openGl.glPointSize(f[0]);

    AbstractDoubleCordinateBuffer.bindIfExists(pointColorBuf, openGl);
    AbstractDoubleCordinateBuffer.unBindExists(verticesBuf, openGl);

}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:27,代碼來源:LineLoop.java

示例2: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public final synchronized void draw(final GL2 openGl) {

        AbstractDoubleCordinateBuffer.bindIfExists(verticesBuf, openGl);
        AbstractDoubleCordinateBuffer.bindIfExists(normalsBuf, openGl);
        AbstractDoubleCordinateBuffer.bindIfExists(faceColorBuf, openGl);
        openGl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
        openGl.glPolygonOffset(1.0f, 1.0f);
        indicesBuf.draw(openGl, GL2.GL_FILL, GL2.GL_FRONT);
        AbstractDoubleCordinateBuffer.unBindExists(faceColorBuf, openGl);
        AbstractDoubleCordinateBuffer.bindIfExists(lineColorBuf, openGl);
        indicesBuf.draw(openGl, GL2.GL_LINE, GL2.GL_FRONT_AND_BACK);
        indicesBuf.draw(openGl, GL2.GL_POINT, GL2.GL_FRONT);
        AbstractDoubleCordinateBuffer.unBindExists(lineColorBuf, openGl);

        AbstractDoubleCordinateBuffer.unBindExists(verticesBuf, openGl);
        AbstractDoubleCordinateBuffer.unBindExists(normalsBuf, openGl);

    }
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:19,代碼來源:MeshBuffer.java

示例3: renderVis

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
	 * {@inheritDoc}
	 *
	 * @see org.openimaj.vis.Visualisation3D#renderVis(javax.media.opengl.GLAutoDrawable)
	 */
	@Override
	protected void renderVis( final GLAutoDrawable drawable )
	{
		if( this.resetCamera )
			this.setupCamera();

		final GL2 gl = drawable.getGL().getGL2();

		gl.glPushMatrix();
		gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );

		// Determine whether we're creating lines or quads
		switch( this.renderType )
		{
			case POINTS:
				gl.glBegin( GL.GL_POINTS );
				break;
			case LINE:
				gl.glBegin( GL.GL_LINES );
				break;
			case SOLID_AND_WIRE:
				gl.glEnable( GL.GL_POLYGON_OFFSET_FILL );
				gl.glPolygonOffset( 1, 1 );
			case SOLID:
			case TEXTURED:
				gl.glBegin( GL2.GL_QUADS );
			    gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL );
			    break;
			case WIRE:
				break;
			default:
				break;
		}

		this.renderHeightMap( gl );

		gl.glDisable( GL.GL_POLYGON_OFFSET_FILL );
		if( this.renderType == HeightMapType.SOLID_AND_WIRE )
		{
			final ColourMap cm = this.colourMap;
			this.colourMap = null;
			this.colour = new float[] { 0f,0f,0f };

			gl.glEnd();
			gl.glBegin( GL.GL_LINE_STRIP );
			this.renderType = HeightMapType.WIRE;

			gl.glDisable( GLLightingFunc.GL_LIGHTING );
		    gl.glDisable( GLLightingFunc.GL_LIGHT0 );

			this.renderHeightMap( gl );

			this.renderType = HeightMapType.SOLID_AND_WIRE;
			this.colourMap = cm;
		}

		gl.glEnd();

		// Reset stuff
		gl.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
//	    gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL );

		gl.glPopMatrix();
	}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:70,代碼來源:HeightMap3D.java

示例4: renderVis

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
	 * Renders the visualisation
	 */
	@Override
	protected void renderVis( final GLAutoDrawable drawable )
	{
		if( drawable == null || this.axesRenderer == null ) return;

		final GL2 gl = drawable.getGL().getGL2();
		gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );

		this.axesRenderer.renderAxis( drawable );

		// Create the boxes
		if( this.data != null )
		{
//				synchronized( this.data )
			{
				for( int z = 0; z < this.data.length; z++ )
				{
					final double b = 1d / this.data[z].length;
					for( int x = 0; x < this.data[z].length; x++ )
					{
						final double v = this.oneOverMax * this.data[z][x];
						gl.glPushMatrix();
						{
							final float[] colour = new float[3];
							this.colourMap.apply( (float) (this.data[z][x] / this.max), colour );
							gl.glColor3f( colour[0], colour[1], colour[2] );
							gl.glTranslatef(
									(float) (b * x + b / 2d),
									(float) (v / 2d),
									(float)(this.oneOverDataLength * z + this.oneOverDataLength / 2d)-1f );
							gl.glScalef( (float) b, (float)Math.abs(v), (float) this.oneOverDataLength );
							gl.glEnable( GL.GL_POLYGON_OFFSET_FILL );
							gl.glPolygonOffset( 1, 1 );
							this.glut.glutSolidCube( 1f );
							gl.glDisable( GL.GL_POLYGON_OFFSET_FILL );
							gl.glColor3f( 0, 0, 0 );
							this.glut.glutWireCube( 1f );
						}
						gl.glPopMatrix();
					}
				}
			}
		}
	}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:48,代碼來源:BarVisualisation3D.java


注:本文中的javax.media.opengl.GL2.glPolygonOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。