本文整理匯總了Java中javax.media.opengl.GL2.glPolygonMode方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glPolygonMode方法的具體用法?Java GL2.glPolygonMode怎麽用?Java GL2.glPolygonMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glPolygonMode方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: paint
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void paint(){
// Compute maximum width of text we're going to draw
TextRenderer textRenderer = new TextRenderer(new Font(Font.SERIF,0 , 18));
int maxTextWidth = (int) textRenderer.getBounds(this.text).getWidth();
maxTextWidth = Math.min(maxTextWidth+10,size.width);
GL2 gl=glContext.getGL2();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glPolygonMode (GL2.GL_FRONT, GL2.GL_LINE_STRIP);
gl.glColor3f(0.5f, 0.5f, 0.5f);
gl.glBegin(GL2.GL_LINE_STRIP);
gl.glVertex2i( this.posx,this.posy); //x1,y1
gl.glVertex2i( this.posx+maxTextWidth,this.posy ); //x2,y1
gl.glVertex2i( this.posx+maxTextWidth,this.posy +size.height); //x2,y2
gl.glVertex2i( this.posx,this.posy+size.height); //x1,y2
gl.glVertex2i( this.posx,this.posy);
gl.glEnd( );
GLDrawable draw=gl.getGL().getContext().getGLDrawable();
textRenderer.beginRendering(draw.getWidth(),draw.getHeight());
textRenderer.setColor(Color.WHITE);
textRenderer.setSmoothing(true);
textRenderer.draw(this.text,(int)posx,(int)posy+5); //text and position
textRenderer.flush();
textRenderer.endRendering();
gl.glFlush();
}
示例2: renderPatchBoundary
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void renderPatchBoundary(DrawContext dc, RectTile tile)
{
// GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
OGLStackHandler ogsh = new OGLStackHandler();
ogsh.pushAttrib(gl, GL2.GL_ENABLE_BIT | GL2.GL_CURRENT_BIT | GL2.GL_POLYGON_BIT);
try
{
gl.glDisable(GL.GL_BLEND);
// Don't perform depth clipping but turn on backface culling
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glEnable(GL.GL_CULL_FACE);
gl.glCullFace(GL.GL_BACK);
gl.glPolygonMode(GL.GL_FRONT, GL2.GL_LINE);
Vec4[] corners = tile.sector.computeCornerPoints(dc.getGlobe(), dc.getVerticalExaggeration());
gl.glColor4d(1d, 0, 0, 1d);
gl.glBegin(javax.media.opengl.GL2.GL_QUADS);
gl.glVertex3d(corners[0].x, corners[0].y, corners[0].z);
gl.glVertex3d(corners[1].x, corners[1].y, corners[1].z);
gl.glVertex3d(corners[2].x, corners[2].y, corners[2].z);
gl.glVertex3d(corners[3].x, corners[3].y, corners[3].z);
gl.glEnd();
}
finally
{
ogsh.pop(gl);
}
}
示例3: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGL
* @param polygonMode
* @param sides
*/
public final void draw(final GL2 openGL, final int polygonMode,
final int sides) {
asureIsBuffered(openGL);
openGL.glEnableClientState(GL.GL_ELEMENT_ARRAY_BUFFER);
openGL.glPolygonMode(sides, polygonMode);
openGL.glDrawElements(primitive, getBufferCapacity(),
GL.GL_UNSIGNED_INT, 0);
openGL.glBindBuffer(target(), 0);
}
示例4: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void draw(DrawContext dc)
{
this.assembleTiles(dc); // Determine the tiles to draw.
if (this.currentTiles.size() >= 1)
{
// Indicate that this layer rendered something this frame.
this.setValue(AVKey.FRAME_TIMESTAMP, dc.getFrameTimeStamp());
if (this.getScreenCredit() != null)
{
dc.addScreenCredit(this.getScreenCredit());
}
TextureTile[] sortedTiles = new TextureTile[this.currentTiles.size()];
sortedTiles = this.currentTiles.toArray(sortedTiles);
Arrays.sort(sortedTiles, levelComparer);
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
if (this.isUseTransparentTextures() || this.getOpacity() < 1)
{
gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT | GL2.GL_CURRENT_BIT);
this.setBlendingFunction(dc);
}
else
{
gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT);
}
gl.glPolygonMode(GL.GL_FRONT, GL2.GL_FILL);
gl.glEnable(GL.GL_CULL_FACE);
gl.glCullFace(GL.GL_BACK);
dc.setPerFrameStatistic(PerformanceStatistic.IMAGE_TILE_COUNT, this.tileCountName,
this.currentTiles.size());
dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles);
gl.glPopAttrib();
if (this.drawTileIDs)
this.drawTileIDs(dc, this.currentTiles);
if (this.drawBoundingVolumes)
this.drawBoundingVolumes(dc, this.currentTiles);
// Check texture expiration. Memory-cached textures are checked for expiration only when an explicit,
// non-zero expiry time has been set for the layer. If none has been set, the expiry times of the layer's
// individual levels are used, but only for images in the local file cache, not textures in memory. This is
// to avoid incurring the overhead of checking expiration of in-memory textures, a very rarely used feature.
if (this.getExpiryTime() > 0 && this.getExpiryTime() <= System.currentTimeMillis())
this.checkTextureExpiration(dc, this.currentTiles);
this.currentTiles.clear();
}
this.sendRequests();
this.requestQ.clear();
}
示例5: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void draw(DrawContext dc)
{
this.referencePoint = this.computeReferencePoint(dc);
Position pos = dc.getView().getEyePosition();
this.centerPoint = new LatLon(pos.getLatitude(), pos.getLongitude());
this.assembleTiles(dc); // Determine the tiles to draw.
if (this.currentTiles.size() >= 1)
{
TextureTile[] sortedTiles = new TextureTile[this.currentTiles.size()];
sortedTiles = this.currentTiles.toArray(sortedTiles);
Arrays.sort(sortedTiles, levelComparer);
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
if (this.isUseTransparentTextures() || this.getOpacity() < 1)
{
gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT | GL2.GL_CURRENT_BIT);
gl.glColor4d(1d, 1d, 1d, this.getOpacity());
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
}
else
{
gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT);
}
gl.glPolygonMode(GL.GL_FRONT, GL2.GL_FILL);
gl.glEnable(GL.GL_CULL_FACE);
gl.glCullFace(GL.GL_BACK);
dc.setPerFrameStatistic(PerformanceStatistic.IMAGE_TILE_COUNT, this.tileCountName,
this.currentTiles.size());
dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles);
gl.glPopAttrib();
if (this.drawTileIDs)
this.drawTileIDs(dc, this.currentTiles);
if (this.drawBoundingVolumes)
this.drawBoundingVolumes(dc, this.currentTiles);
this.currentTiles.clear();
}
this.sendRequests();
this.requestQ.clear();
}
示例6: init
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void init(GLAutoDrawable drawable) {
if(clContext == null) {
// find gl compatible device
CLDevice[] devices = CLPlatform.getDefault().listCLDevices();
CLDevice device = null;
for (CLDevice d : devices) {
if(d.isGLMemorySharingSupported()) {
device = d;
break;
}
}
if(null==device) {
throw new RuntimeException("couldn't find any CL/GL memory sharing devices ..");
}
// create OpenCL context before creating any OpenGL objects
// you want to share with OpenCL (AMD driver requirement)
clContext = CLGLContext.create(drawable.getContext(), device);
// enable GL error checking using the composable pipeline
drawable.setGL(new DebugGL2(drawable.getGL().getGL2()));
// OpenGL initialization
GL2 gl = drawable.getGL().getGL2();
gl.setSwapInterval(1);
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
gl.glGenBuffers(glObjects.length, glObjects, 0);
// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, glObjects[INDICES]);
// gl.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, ib.capacity() * SIZEOF_INT, ib, GL2.GL_STATIC_DRAW);
// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);
final int bsz = MESH_SIZE * MESH_SIZE * 4 * SIZEOF_FLOAT;
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]);
gl.glBufferData(GL2.GL_ARRAY_BUFFER, bsz, null, GL2.GL_DYNAMIC_DRAW);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
pushPerspectiveView(gl);
gl.glFinish();
// init OpenCL
initCL(gl, bsz);
// start rendering thread
Animator animator = new Animator(drawable);
animator.start();
}
}
示例7: 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();
}