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


Java GL類代碼示例

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


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

示例1: renderWaypoints

import javax.media.opengl.GL; //導入依賴的package包/類
/**
 * Render all waypoints (the circles in the map), data generated in createWaypointsList
 * @param gl
 * @param triangles
 */
private synchronized void renderWaypoints(GL gl, List<BlendTriangle> triangles) {
    GlColor color = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getDegaultARGB())));

    gl.glEnable(GL.GL_COLOR_MATERIAL);
    gl.glShadeModel(GL.GL_SMOOTH);

    gl.glBegin(GL.GL_TRIANGLES);
    for (BlendTriangle triangle : triangles) {
        for (BlendVertex v : triangle.getVerts()) {
            // take color according to width
            gl.glColor4d(color.r, color.g, color.b, color.a);
            gl.glVertex3d(v.getLocation().x, v.getLocation().y, v.getLocation().z + 0.1);
        }
    }
    gl.glEnd();
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:22,代碼來源:MapRenderer.java

示例2: renderSquare

import javax.media.opengl.GL; //導入依賴的package包/類
public static void renderSquare(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,Geometry selectedGeometry,float renderWidth,Color color){
	GL2 gl = context.getGL().getGL2();
       float[] c = color.brighter().getColorComponents(null);
       gl.glColor3f(c[0], c[1], c[2]);

	for (Geometry temp : geometries) {
           gl.glLineWidth(temp == selectedGeometry ? renderWidth * 3 : renderWidth);
           Coordinate point = new Coordinate(temp.getCoordinate());
           point.x = (point.x - context.getX()) / zoomWidth;
           point.y = 1 - (point.y - context.getY()) / zoomHeight;
           double rectwidth = 0.01;
           gl.glBegin(GL.GL_LINE_STRIP);
           gl.glVertex2d(point.x - rectwidth, point.y - rectwidth);
           gl.glVertex2d(point.x - rectwidth, point.y + rectwidth);
           gl.glVertex2d(point.x + rectwidth, point.y + rectwidth);
           gl.glVertex2d(point.x + rectwidth, point.y - rectwidth);
           gl.glVertex2d(point.x - rectwidth, point.y - rectwidth);
           gl.glEnd();
           gl.glFlush();
       }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:22,代碼來源:GL2ShapesRender.java

示例3: updateMapDisplayLists

import javax.media.opengl.GL; //導入依賴的package包/類
/**
 * Update display lists for waypoints and path quads according to preferences
 */
private synchronized void updateMapDisplayLists(GL gl) {
    // delete old
    gl.glDeleteLists(pathDisplayList, 1);
    gl.glDeleteLists(waypointDisplayList, 1);

    // create new
    pathDisplayList = gl.glGenLists(1);
    gl.glNewList(pathDisplayList, GL.GL_COMPILE);
    renderPaths(gl, pathTris);
    gl.glEndList();

    waypointDisplayList = gl.glGenLists(1);
    gl.glNewList(waypointDisplayList, GL.GL_COMPILE);
    renderWaypoints(gl, waypointsTris);
    gl.glEndList();
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:20,代碼來源:MapRenderer.java

示例4: glOrientToPlane

import javax.media.opengl.GL; //導入依賴的package包/類
/**
 * orient the scene to the sketch plane.  
 * @param gl
 */
public void glOrientToPlane(GL gl){
	//gl.glLoadIdentity();
	// align to origin
	gl.glTranslated(origin.getX(), origin.getY(), origin.getZ());
	
	// rotate to align planes
	double xRot = getRotationX();
	double yRot = getRotationY();
	gl.glRotated(xRot*180.0/Math.PI, 1.0, 0.0, 0.0);
	gl.glRotated(yRot*180.0/Math.PI, 0.0, 1.0, 0.0);
	
	// rotate around z-axis to align 2D grid
	double zRot = getRotationZ();
	gl.glRotated(zRot*180.0/Math.PI, 0.0, 0.0, 1.0);
	//System.out.println("xRot:" + xRot + " yRot:" + yRot + " zRot:" + zRot);
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:21,代碼來源:SketchPlane.java

示例5: drawLine

import javax.media.opengl.GL; //導入依賴的package包/類
protected void drawLine(DrawContext dc, Vec4 screenPoint, Vec4 projectedPoint, DetailedOrderedIcon uIcon) {
	//GL gl = dc.getGL();
	GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
	
	gl.glLoadIdentity();
	
	double opacity = uIcon.getOpacity();
	
	opacity = Math.min(opacity, .5f);
	
	gl.glDisable(GL.GL_TEXTURE_2D);
	gl.glColor4d(.2,.2,.2, opacity);
	
	gl.glBegin(GL.GL_LINES);
		gl.glVertex2d(screenPoint.x, screenPoint.y);
		gl.glVertex2d(projectedPoint.x, projectedPoint.y);
	gl.glEnd();
	gl.glEnable(GL.GL_TEXTURE_2D);
	
	gl.glColor4f(1,1,1,1);
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:22,代碼來源:DetailedIconRenderer.java

示例6: renderCross

import javax.media.opengl.GL; //導入依賴的package包/類
public static void renderCross(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,Geometry selectedGeometry,float renderWidth,Color color){
	GL2 gl = context.getGL().getGL2();
       float[] c = color.brighter().getColorComponents(null);
       gl.glColor3f(c[0], c[1], c[2]);
       if(geometries!=null){
		for (Geometry temp : geometries) {
	        gl.glLineWidth(temp == selectedGeometry ? renderWidth * 2 : renderWidth);
	        Coordinate point = new Coordinate(temp.getCoordinate());
	        point.x = (point.x - context.getX()) / zoomWidth;
	        point.y = 1 - (point.y - context.getY()) / zoomHeight;
	        double rectwidth = 0.01;
	        gl.glBegin(GL.GL_LINE_STRIP);
	        gl.glVertex2d(point.x - rectwidth, point.y);
	        gl.glVertex2d(point.x + rectwidth, point.y);
	        gl.glEnd();
	        gl.glBegin(GL.GL_LINE_STRIP);
	        gl.glVertex2d(point.x, point.y - rectwidth);
	        gl.glVertex2d(point.x, point.y + rectwidth);
	        gl.glEnd();
	        gl.glFlush();
	    }
       }	
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:24,代碼來源:GL2ShapesRender.java

示例7: renderTriangle

import javax.media.opengl.GL; //導入依賴的package包/類
public static void renderTriangle(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,Geometry selectedGeometry,float renderWidth,Color color){
	GL2 gl = context.getGL().getGL2();
       float[] c = color.brighter().getColorComponents(null);
       gl.glColor3f(c[0], c[1], c[2]);
       if(geometries!=null){
		for (Geometry temp : geometries) {
	        gl.glLineWidth(temp == selectedGeometry ? renderWidth * 2 : renderWidth);
	        Coordinate point = new Coordinate(temp.getCoordinate());
	        point.x = (point.x - context.getX()) / zoomWidth;
	        point.y = 1 - (point.y - context.getY()) / zoomHeight;
	        double rectwidth = 0.01;
	        gl.glBegin(GL.GL_LINE_STRIP);
	        gl.glVertex2d(point.x - rectwidth, point.y - rectwidth);
	        gl.glVertex2d(point.x, point.y + rectwidth);
	        gl.glVertex2d(point.x + rectwidth, point.y - rectwidth);
	        gl.glVertex2d(point.x - rectwidth, point.y - rectwidth);
	        gl.glEnd();
	        gl.glFlush();
	    }
       }	
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:22,代碼來源:GL2ShapesRender.java

示例8: display

import javax.media.opengl.GL; //導入依賴的package包/類
public void display(GLDrawable gLDrawable)
{
  String [] fonts = { "BitMap 9 by 15", "BitMap 8 by 13",
        "Times Roman 10 Point ", "Times Roman 24 Point ",
        "Helvetica 10 Point ","Helvetica 12 Point ","Helvetica 18 Point "};
       
  final GL2 gl = SumoPlatform.getApplication().getGeoContext().getGL().getGL2();
  final GLUT glut = new GLUT();
	 
  gl.glClear (GL.GL_COLOR_BUFFER_BIT);  // Set display window to color.
  gl.glColor3f (0.0f, 0.0f, 0.0f);  // Set text e.color to black
  gl.glMatrixMode (GL2.GL_MODELVIEW);
  gl.glLoadIdentity();
 
  int x = 20, y=15;
  for (int i=0; i<7;i++){
        gl.glRasterPos2i(x,y); // set position
        glut.glutBitmapString(i+2, fonts[i]);
         y+= 20;
  }

}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:23,代碼來源:GLTextRender.java

示例9: render

import javax.media.opengl.GL; //導入依賴的package包/類
@Override
public void render(Object glC) {
	OpenGLContext context=(OpenGLContext)glC;//SumoPlatform.getApplication().getGeoContext();
    GL gl = context.getGL();
    gl.getGL2().glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
    BufferedImage temp=new BufferedImage(overview.getWidth(), overview.getHeight(), overview.getType());
    this.overview.copyData(temp.getRaster());

    BufferedImage buffer=rescale.filter(temp, temp);
    Texture texture = AWTTextureIO.newTexture(((GLBase)gl).getGLProfile(), buffer, true);
    //Texture texture = TextureIO.newTexture(rescale.filter(temp, temp), false);

    float tempscale=this.scale*context.getHeight()/context.getWidth();
    if(tempscale<1){
        bindTexture(gl, texture, 0, tempscale, 0, 1);
    }
    else{
        bindTexture(gl, texture, 0, 1, 0, tempscale);
    }
    texture.disable(gl);
    context.setX(0);
    context.setY(0);
    context.setZoom(Math.max(thumbReader.getWidth() / context.getWidth(),thumbReader.getHeight() / context.getHeight()));
    SumoPlatform.getApplication().getLayerManager().render(context);
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:26,代碼來源:ThumbnailsLayer.java

示例10: bindTexture

import javax.media.opengl.GL; //導入依賴的package包/類
private void bindTexture(GL gl, Texture texture, float xmin, float xmax, float ymin, float ymax) {
    texture.enable(gl);
    texture.bind(gl);
    TextureCoords coords = texture.getImageTexCoords();
    gl.getGL2().glBegin(GL2.GL_QUADS);
    gl.getGL2().glTexCoord2f(coords.left(), coords.top());
    gl.getGL2().glVertex2f(xmin, 1 - ymin);
    gl.getGL2().glTexCoord2f(coords.right(), coords.top());
    gl.getGL2().glVertex2f(xmax, 1 - ymin);
    gl.getGL2().glTexCoord2f(coords.right(), coords.bottom());
    gl.getGL2().glVertex2f(xmax, 1 - ymax);
    gl.getGL2().glTexCoord2f(coords.left(), coords.bottom());
    gl.getGL2().glVertex2f(xmin, 1 - ymax);
    gl.getGL2().glEnd();
    texture.disable(gl);

}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:18,代碼來源:ThumbnailsLayer.java

示例11: updateFutures

import javax.media.opengl.GL; //導入依賴的package包/類
/**
 *
 * @param gl
 */
private void updateFutures(GL gl) {
    List<Future<Object[]>> remove1 = new ArrayList<Future<Object[]>>();
    for (Future<Object[]> f : futures) {
        if (f.isDone() || f.isCancelled()) {
            remove1.add(f);
            try {
                Object[] o = f.get();
                submitedTiles.remove(o[1]);
                if (o.length>2&&o[2] != null) {
                    tcm.add((String) o[0], AWTTextureIO.newTexture(gl.getGLProfile(),(BufferedImage) o[2], false));
                }
            } catch (Exception ex) {
            	logger.error(ex.getMessage(),ex);
            }
        }
    }
    futures.removeAll(remove1);
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:23,代碼來源:ImageLayer.java

示例12: createTexture

import javax.media.opengl.GL; //導入依賴的package包/類
public static JOGLTexture createTexture(GL gl, BufferedImage awtImage)
{
	int textureID = createTextureID(gl);

	gl.glEnable(GL.GL_TEXTURE_2D);
	
	// convert that image into a byte buffer of texture data
       ByteBuffer textureBuffer = ImageConverter.convertPowerOf2(awtImage);
       gl.glBindTexture(GL.GL_TEXTURE_2D, textureID);

       gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
       gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
       gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
       gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
       
       int texWidth = ImageConverter.powerOf2(awtImage.getWidth());
       int texHeight = ImageConverter.powerOf2(awtImage.getHeight());
       
       gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, 
       	texWidth, texHeight, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, textureBuffer);
       
       gl.glDisable(GL.GL_TEXTURE_2D);
       
	return new JOGLTexture(gl, textureID, awtImage.getWidth(), awtImage.getHeight(), texWidth, texHeight);
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:26,代碼來源:JOGLTexture.java

示例13: drawTransparentMouseLayer

import javax.media.opengl.GL; //導入依賴的package包/類
private void drawTransparentMouseLayer(){
	//
	// invisible plane to catch mouse events at depth ~0.0
	// this should be the last thing drawn in the 2D mode
	// TODO: HACK, this should be sized according to the grid, which should also be dynamic!
	//
	if(AvoGlobal.menuet.getCurrentToolMode() == Menuet.MENUET_MODE_SKETCH ||
			AvoGlobal.menuet.getCurrentToolMode() == Menuet.MENUET_MODE_BUILD){
		gl.glColor4f(1.0f,0.0f,0.0f, 0.0f);
		gl.glBegin(GL.GL_QUADS);
		gl.glVertex3f(-100.0f, 100.0f, 0.0f);
		gl.glVertex3f( 100.0f, 100.0f, 0.0f);
		gl.glVertex3f( 100.0f,-100.0f, 0.0f);
		gl.glVertex3f(-100.0f,-100.0f, 0.0f);
		gl.glEnd();
	}
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:18,代碼來源:GLView.java

示例14: circle2D

import javax.media.opengl.GL; //導入依賴的package包/類
private static void circle2D(GL gl, Point2D center, double radius, double zOffset){
	gl.glPushMatrix();
		gl.glTranslatef((float)center.getX(), (float)center.getY(), (float)zOffset);
		float w = (float)Math.cos(Math.PI / 4);
		cad_NURBS(gl, 	radius,0.0,0.0,1.0,  
					radius,radius,0.0,w, 
					0.0,radius,0.0,1.0);	
		cad_NURBS(gl,	-radius,0.0,0.0,1.0,  
					-radius,radius,0.0,w, 
					0.0,radius,0.0,1.0);	
		cad_NURBS(gl,	-radius,0.0,0.0,1.0,  
					-radius,-radius,0.0,w, 
					0.0,-radius,0.0,1.0);	
		cad_NURBS(gl,	radius,0.0,0.0,1.0,  
					radius,-radius,0.0,w, 
					0.0,-radius,0.0,1.0);
	gl.glPopMatrix();
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:19,代碼來源:GLDynPrim.java

示例15: mesh

import javax.media.opengl.GL; //導入依賴的package包/類
public static void mesh(GL gl, double xstart, double xend, double ystart, double yend, int xsteps, int ysteps){
	double grid[] =  new double[] {xstart, ystart, 0.0, xstart, yend, 0.0, xend, ystart, 0.0, xend, yend, 0.0};
 
	gl.glEnable(GL.GL_MAP2_VERTEX_3);
	gl.glLineWidth(1.0f);
	gl.glMap2d(GL.GL_MAP2_VERTEX_3,
			0.0, 1.0,  /* U ranges 0..1 */
			3,         /* U stride, 3 floats per coord */
			2,         /* U is 2nd order, ie. linear */
			0.0, 1.0,  /* V ranges 0..1 */
			2 * 3,     /* V stride, row is 2 coords, 3 floats per coord */
			2,         /* V is 2nd order, ie linear */
			grid,0);  /* control points */
  
	gl.glMapGrid2d(
		    ysteps, 0.0, 1.0,
		    xsteps, 0.0, 1.0);
  
	gl.glEvalMesh2(GL.GL_LINE, 0, ysteps, 0, xsteps); 	  
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:21,代碼來源:GLDynPrim.java


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