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


Java GL2.glVertex2d方法代碼示例

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


在下文中一共展示了GL2.glVertex2d方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: drawPoly

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param gl
 * @param cs
 * @param width
 * @param height
 * @param x
 * @param y
 */
protected void drawPoly(GL2 gl,Coordinate[] cs,float width,float height,int x,int y,float rwidth){
	gl.glLineWidth(rwidth);
    gl.glBegin(GL.GL_LINE_STRIP);
    for (int p = 0; p < cs.length; p++) {
    	double vx=(cs[p].x - x) / width;
    	double vy=1 - (cs[p].y - y) / height;
        gl.glVertex2d(vx,vy);
    }

    //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,代碼行數:25,代碼來源:SimpleGeometryLayer.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: drawLine

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

示例9: 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

示例10: 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

示例11: 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

示例12: doRoi

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override protected void doRoi() {
        transformer.transform(srcRoiPts, dstRoiPts, parameters, false);
        double[] pts = dstRoiPts.get();
        for (int i = 0; i < pts.length; i++) {
            pts[i] /= (1<<pyramidLevel);
        }
        roi.x(0).y(0).width(maskCL[pyramidLevel].width).height(maskCL[pyramidLevel].height);
        // Add +3 all around because cvWarpPerspective() needs it for interpolation,
        // and there seems to be something funny with memory alignment and
        // ROIs, so let's align our ROI to a 16 byte boundary just in case..
        JavaCV.boundingRect(pts, roi, 3, 3, 16, 1);
//System.out.println(roi);
        inputData.roiX = roi.x();
        inputData.roiY = roi.y();
        inputData.roiWidth  = roi.width();
        inputData.roiHeight = roi.height();

//        GLContext glContext = context.getGLContext();
//        glContext.makeCurrent();
        GL2 gl = context.getGL2();
        gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, maskfb[pyramidLevel]);

        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();
        context.getGLU().gluOrtho2D(0.0f, maskCL[pyramidLevel].width, 0.0f, maskCL[pyramidLevel].height);

        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();
        gl.glViewport(0, 0, maskCL[pyramidLevel].width, maskCL[pyramidLevel].height);

        gl.glClearColor(0, 0, 0, 0);
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
        gl.glColor4f(1, 1, 1, 1);
        gl.glBegin(GL2.GL_POLYGON);
// XXX: Remove "extra" pixels here...
            gl.glVertex2d(pts[0],   pts[1]);
            gl.glVertex2d(pts[2]+1, pts[3]);
            gl.glVertex2d(pts[4]+1, pts[5]+1);
            gl.glVertex2d(pts[6],   pts[7]+1);
        gl.glEnd();
//        gl.glFinish();
//        glContext.release();
    }
 
開發者ID:wordin0,項目名稱:javacv,代碼行數:44,代碼來源:GNImageAlignerCL.java


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