当前位置: 首页>>代码示例>>Java>>正文


Java GL2.glColor3f方法代码示例

本文整理汇总了Java中javax.media.opengl.GL2.glColor3f方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glColor3f方法的具体用法?Java GL2.glColor3f怎么用?Java GL2.glColor3f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.glColor3f方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderSquare

import javax.media.opengl.GL2; //导入方法依赖的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

示例2: renderCross

import javax.media.opengl.GL2; //导入方法依赖的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

示例3: renderTriangle

import javax.media.opengl.GL2; //导入方法依赖的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

示例4: renderCircle

import javax.media.opengl.GL2; //导入方法依赖的package包/类
public static void renderCircle(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,Geometry selectedGeometry,float size,Color color){
	GL2 gl = context.getGL().getGL2();
	float[] c = color.brighter().getColorComponents(null);
       gl.glColor3f(c[0], c[1], c[2]);
	gl.glBegin(GL.GL_POINTS);
   	
   	for (int ii=0;ii<geometries.size();ii++) {
   	   Geometry temp =geometries.get(ii);
   	   gl.glLineWidth(temp == selectedGeometry ? size * 2 : size);
   	   gl.glPointSize(temp == selectedGeometry ? size * 2 : size);
          Coordinate point = temp.getCoordinate();
          double dx=(point.x - context.getX()) / zoomWidth;
          double dy=1 - (point.y - context.getY()) / zoomHeight;
   	   for (int i=0; i < 360; i++){
   		   //double angle = 2 * Math.PI * i / 360;
   		   double xx = dx+Math.sin(i)*0.005;
   		   double yy = dy+Math.cos(i)*0.005;
   		   
   		   gl.glVertex2d(xx,yy);
   	   }
       } 
    gl.glEnd();
       gl.glFlush();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:25,代码来源:GL2ShapesRender.java

示例5: drawPoly

import javax.media.opengl.GL2; //导入方法依赖的package包/类
/**
   * 
   * @param gl
   * @param cs
   * @param width
   * @param height
   * @param x
   * @param y
   */
  public static void drawPoly(OpenGLContext context,Coordinate[] cs,float width,float height,int x,int y,float rwidth,Color color){
GL2 gl = context.getGL().getGL2();
float[] c = color.getColorComponents(null);
      gl.glColor3f(c[0], c[1], c[2]);
  	gl.glLineWidth(rwidth);
      gl.glBegin(GL.GL_LINE_STRIP);
      
     // System.out.println("----------------------------------");
      for (int p = 0; p < cs.length; p++) {
      	double vx=(cs[p].x - x) / width;
      	double vy=1 - (cs[p].y - y) / height;
      //	System.out.println(vx+"  "+vy+",");
          gl.glVertex2d(vx,vy);
      }
   //   System.out.println("----------------------------------");
      //close polygon
      Coordinate point = cs[0];
      gl.glVertex2d((point.x - x) / width, 1 - (point.y - y) / height);
      
      gl.glEnd();
      gl.glFlush();
  }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:32,代码来源:GL2ShapesRender.java

示例6: display

import javax.media.opengl.GL2; //导入方法依赖的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

示例7: render

import javax.media.opengl.GL2; //导入方法依赖的package包/类
public void render(OpenGLContext context) {
    if (initPosition == null) {
        return;
    }
    int x = context.getX(), y = context.getY();
    float zoom = context.getZoom(), width = context.getWidth() * zoom, height = context.getHeight() * zoom;
    GL2 gl = context.getGL().getGL2();
    gl.glLineWidth(1);
    float[] c = Color.GREEN.getColorComponents(null);
    gl.glColor3f(c[0], c[1], c[2]);
    gl.glBegin(GL.GL_LINE_STRIP);
    gl.glVertex2d((initPosition.x - x) / width, 1 - (initPosition.y - y) / height);
    if (endPosition == null) {
        gl.glVertex2d((imagePosition.x - x) / width, 1 - (imagePosition.y - y) / height);
    } else {
        gl.glVertex2d((endPosition.x - x) / width, 1 - (endPosition.y - y) / height);
    }
    gl.glEnd();
    gl.glFlush();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:21,代码来源:PositionLayer.java

示例8: drawTransform

import javax.media.opengl.GL2; //导入方法依赖的package包/类
@Override
public void drawTransform(Transform xf) {
  GL2 gl = panel.getGL().getGL2();
  getWorldToScreenToOut(xf.p, temp);
  temp2.setZero();
  float k_axisScale = 0.4f;

  gl.glBegin(GL2.GL_LINES);
  gl.glColor3f(1, 0, 0);

  temp2.x = xf.p.x + k_axisScale * xf.q.c;
  temp2.y = xf.p.y + k_axisScale * xf.q.s;
  getWorldToScreenToOut(temp2, temp2);
  gl.glVertex2f(temp.x, temp.y);
  gl.glVertex2f(temp2.x, temp2.y);

  gl.glColor3f(0, 1, 0);
  temp2.x = xf.p.x + -k_axisScale * xf.q.s;
  temp2.y = xf.p.y + k_axisScale * xf.q.c;
  getWorldToScreenToOut(temp2, temp2);
  gl.glVertex2f(temp.x, temp.y);
  gl.glVertex2f(temp2.x, temp2.y);
  gl.glEnd();
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:25,代码来源:JoglDebugDraw.java

示例9: createVertex

import javax.media.opengl.GL2; //导入方法依赖的package包/类
/**
 * 	Creates a single colour mapped vertex.
 *
 *	@param gl The GL context
 *	@param N The number of points in the X direction
 *	@param M The number of points in the Z direction
 *	@param stepSizeX The size of each quad in the patch
 *	@param stepSizeY The size of each quad in the patch
 *	@param X The index along the X direction
 *	@param Y The index along the Z direction (Y in the data)
 */
private void createVertex( final GL2 gl, final int N, final int M,
		final double stepSizeX, final double stepSizeY, final int X, final int Y )
{
	final double x = X * stepSizeX;
	final double z = Y * stepSizeY;
	double y = this.data[Y][X];

	if( this.autoScale )
		y *= 1d/(this.max-this.min);

	if( this.renderType == HeightMapType.TEXTURED )
		gl.glTexCoord2f( (float)(x / N), (float)(z / M) );
	else
	{
		final float[] c = this.colour;
		if( this.colourMap != null )
			this.colourMap.apply( (float)(this.data[Y][X] * 1d/(this.max-this.min)), c );

		gl.glColor3f( c[0], c[1], c[2] );
	}
	gl.glVertex3d( x, y, z );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:HeightMap3D.java

示例10: 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();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:33,代码来源:GLButton.java

示例11: renderPolygons

import javax.media.opengl.GL2; //导入方法依赖的package包/类
public static void renderPolygons(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,float size,Color color){
	GL2 gl = context.getGL().getGL2();
	float[] c = color.brighter().getColorComponents(null);
       gl.glColor3f(c[0], c[1], c[2]);
	gl.glPointSize(size);
       gl.glBegin(GL.GL_POINTS);
       for (Geometry temp : geometries) {
           for (Coordinate point : temp.getCoordinates()) {
               gl.glVertex2d((point.x - context.getX()) / zoomWidth, 1 - (point.y - context.getY()) / zoomHeight);
           }
       }
       gl.glEnd();
       gl.glFlush();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:15,代码来源:GL2ShapesRender.java

示例12: renderPolygon

import javax.media.opengl.GL2; //导入方法依赖的package包/类
public static void renderPolygon(OpenGLContext context,float zoomWidth,float zoomHeight,Coordinate[] coordinates,float size,Color color){
	GL2 gl = context.getGL().getGL2();
	float[] c = color.brighter().getColorComponents(null);
       gl.glColor3f(c[0], c[1], c[2]);
	gl.glPointSize(size);
       gl.glBegin(GL.GL_LINE_STRIP);
       for (Coordinate point : coordinates) {
           gl.glVertex2d((point.x - context.getX()) / zoomWidth, 1 - (point.y - context.getY()) / zoomHeight);
       }
       //Coordinate point = temp.getCoordinates()[0];
       //gl.glVertex2d((point.x - x) / width, 1 - (point.y - y) / height);

       gl.glEnd();
       gl.glFlush();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:16,代码来源:GL2ShapesRender.java

示例13: renderPoint

import javax.media.opengl.GL2; //导入方法依赖的package包/类
public static void renderPoint(OpenGLContext context,float zoomWidth,float zoomHeight,Coordinate point,float size,Color color){
	GL2 gl = context.getGL().getGL2();
       float[] c = color.brighter().getColorComponents(null);
       gl.glColor3f(c[0], c[1], c[2]);
       gl.glPointSize(size);
       gl.glBegin(GL.GL_POINTS);
       gl.glVertex2d((point.x - context.getX()) / zoomWidth, 1 - (point.y - context.getY()) / zoomHeight);
       gl.glEnd();
       gl.glFlush();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:11,代码来源:GL2ShapesRender.java

示例14: render

import javax.media.opengl.GL2; //导入方法依赖的package包/类
public void render(OpenGLContext context) {
    GL2 gl = context.getGL().getGL2();
    gl.glColor3f(1, 1, 1);
    gl.glLineWidth(1.0f);
    gl.glBegin(GL.GL_LINE_LOOP);
    float zoom=context.getZoom();
    gl.glVertex2f(context.getX() / (1f*width),1-context.getY() / (1f*height));
    gl.glVertex2f((context.getX() + zoom*context.getWidth()) / width,1- context.getY() / (1f*height));
    gl.glVertex2f((context.getX() + zoom*context.getWidth()) / width,1- (context.getY() + zoom*context.getHeight()) / height);
    gl.glVertex2f(context.getX() / (1f*width),1-(context.getY() + zoom*context.getHeight()) / height);
    gl.glEnd();
    gl.glFlush();


}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:16,代码来源:CaretLayer.java

示例15: render

import javax.media.opengl.GL2; //导入方法依赖的package包/类
public void render(DrawContext dc) {
	beginDrawLasso(dc);
	
	//GL gl = dc.getGL();
	GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
	gl.glLoadIdentity();

	gl.glColor3f(1, 1, 0);
	gl.glBegin(GL.GL_LINE_STRIP);

	Vec4 startPoint = null;

	for (Position pos : lasso)
	{
		Vec4 screenPoint = dc.getView().project(
				dc.getGlobe().computePointFromPosition(pos));

		if (screenPoint == null)
			continue;
		if (startPoint == null)
			startPoint = screenPoint;

		gl.glVertex3d(screenPoint.x, screenPoint.y, startPoint.z);
	}
	if (startPoint != null) 
		gl.glVertex3d(startPoint.x, startPoint.y, startPoint.z);

	gl.glEnd();
	endDrawLasso(dc);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:31,代码来源:LassoSelectionHandler.java


注:本文中的javax.media.opengl.GL2.glColor3f方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。