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


Java GL2.glColor4f方法代碼示例

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


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

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

示例2: debugRender

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Render a debugging hint for the arcball tool.
 * 
 * @param gl GL class for rendering-
 */
@SuppressWarnings("unused")
public void debugRender(GL2 gl) {
  if (!DEBUG || (startcamera == null)) {
    return;
  }
  gl.glLineWidth(3f);
  gl.glColor4f(1.f, 0.f, 0.f, .66f);
  gl.glBegin(GL.GL_LINES);
  gl.glVertex3f(0.f, 0.f, 0.f);
  double rot = startangle - startcamera.getRotationZ();
  gl.glVertex3f((float) FastMath.cos(rot) * 4.f, (float) -FastMath.sin(rot) * 4.f, 0.f);
  gl.glVertex3f((float) FastMath.cos(rot) * 1.f, (float) -FastMath.sin(rot) * 1.f, 0.f);
  gl.glVertex3f((float) FastMath.cos(rot) * 1.f, (float) -FastMath.sin(rot) * 1.f, 1.f);
  gl.glEnd();
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:21,代碼來源:Arcball1DOFAdapter.java

示例3: renderContents

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
void renderContents(GL2 gl) {
  // Get text bounds.
  Rectangle2D bounds = renderer.getBounds(getMessage());

  // Render message background:
  final float bx1 = .45f * (float) (width - bounds.getWidth());
  final float bx2 = .55f * (float) (width + bounds.getWidth());
  final float by1 = .45f * (float) (height - bounds.getHeight());
  final float by2 = .55f * (float) (height + bounds.getHeight());
  gl.glBegin(GL2.GL_QUADS);
  gl.glColor4f(0f, 0f, 0f, .75f);
  gl.glVertex2f(bx1, by1);
  gl.glVertex2f(bx1, by2);
  gl.glVertex2f(bx2, by2);
  gl.glVertex2f(bx2, by1);
  gl.glEnd();

  // Render message
  renderer.beginRendering(width, height);
  renderer.setColor(1f, 1f, 1f, 1f);
  renderer.setColor(1f, 1f, 1f, 1f);
  renderer.draw(getMessage(), (width - (int) bounds.getWidth()) >> 1, (height - (int) bounds.getHeight()) >> 1);
  renderer.endRendering();
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:26,代碼來源:SimpleMessageOverlay.java

示例4: drawCircle

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawCircle(Vec2 center, float radius, Color3f color) {
    System.err.println("drawCircle: "+center +", "+radius+", "+color);
  GL2 gl = panel.getGL().getGL2();
  gl.glPushMatrix();
  transformViewport(gl, zero);
  float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
  float c = MathUtils.cos(theta);
  float s = MathUtils.sin(theta);
  float x = radius;
  float y = 0;
  float cx = center.x;
  float cy = center.y;
  gl.glBegin(GL2.GL_LINE_LOOP);
  gl.glColor4f(color.x, color.y, color.z, 1);
  for (int i = 0; i < NUM_CIRCLE_POINTS; i++) {
    gl.glVertex3f(x + cx, y + cy, 0);
    // apply the rotation matrix
    float temp = x;
    x = c * x - s * y;
    y = s * temp + c * y;
  }
  gl.glEnd();
  gl.glPopMatrix();
}
 
開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:26,代碼來源:JoglDebugDraw.java

示例5: drawSolidPolygon

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
  GL2 gl = panel.getGL().getGL2();
  gl.glBegin(GL2.GL_TRIANGLE_FAN);
  gl.glColor4f(color.x, color.y, color.z, .4f);
  for (int i = 0; i < vertexCount; i++) {
    getWorldToScreenToOut(vertices[i], trans);
    gl.glVertex2f(trans.x, trans.y);
  }
  gl.glEnd();

  gl.glBegin(GL2.GL_LINE_LOOP);
  gl.glColor4f(color.x, color.y, color.z, 1f);
  for (int i = 0; i < vertexCount; i++) {
    getWorldToScreenToOut(vertices[i], trans);
    gl.glVertex2f(trans.x, trans.y);
  }
  gl.glEnd();
}
 
開發者ID:weimingtom,項目名稱:jbox2d,代碼行數:20,代碼來源:JoglDebugDraw.java

示例6: render

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Main render method
 * 
 * @param gl GL context
 */
public final void render(GL2 gl) {
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glPushMatrix();
  gl.glLoadIdentity();
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glPushMatrix();
  gl.glLoadIdentity();

  gl.glOrtho(0, width, 0, height, -1, +1);
  gl.glColor4f(0f, 0f, 0f, .5f);

  // Fade background:
  gl.glBegin(GL2.GL_QUADS);
  gl.glVertex2f(0f, 0f);
  gl.glVertex2f(width, 0f);
  gl.glVertex2f(width, height);
  gl.glVertex2f(0f, height);
  gl.glEnd();
  
  renderContents(gl);

  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glPopMatrix();
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glPopMatrix();
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:32,代碼來源:AbstractSimpleOverlay.java

示例7: drawPolygon

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
  GL2 gl = panel.getGL().getGL2();
  gl.glPushMatrix();
  transformViewport(gl, zero);
  gl.glBegin(GL2.GL_LINE_LOOP);
  gl.glColor4f(color.x, color.y, color.z, 1f);
  for (int i = 0; i < vertexCount; i++) {
    Vec2 v = vertices[i];
    System.err.println("polygon vertex: "+v.x +", "+v.y);
    gl.glVertex2f(v.x, v.y);
  }
  gl.glEnd();
  gl.glPopMatrix();
}
 
開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:16,代碼來源:JoglDebugDraw.java

示例8: drawParticles

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawParticles(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
  GL2 gl = panel.getGL().getGL2();
  gl.glPushMatrix();
  transformViewport(gl, zero);

  float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
  float c = MathUtils.cos(theta);
  float s = MathUtils.sin(theta);

  float x = radius;
  float y = 0;

  for (int i = 0; i < count; i++) {
    Vec2 center = centers[i];
    float cx = center.x;
    float cy = center.y;
    gl.glBegin(GL2.GL_TRIANGLE_FAN);
    if (colors == null) {
      gl.glColor4f(1, 1, 1, .4f);
    } else {
      ParticleColor color = colors[i];
      gl.glColor4b(color.r, color.g, color.b, color.a);
    }
    for (int j = 0; j < NUM_CIRCLE_POINTS; j++) {
      gl.glVertex3f(x + cx, y + cy, 0);
      float temp = x;
      x = c * x - s * y;
      y = s * temp + c * y;
    }
    gl.glEnd();
  }
  gl.glPopMatrix();
}
 
開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:35,代碼來源:JoglDebugDraw.java

示例9: drawParticlesWireframe

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawParticlesWireframe(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
  GL2 gl = panel.getGL().getGL2();
  gl.glPushMatrix();
  transformViewport(gl, zero);

  float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
  float c = MathUtils.cos(theta);
  float s = MathUtils.sin(theta);

  float x = radius;
  float y = 0;

  for (int i = 0; i < count; i++) {
    Vec2 center = centers[i];
    float cx = center.x;
    float cy = center.y;
    gl.glBegin(GL2.GL_LINE_LOOP);
    if (colors == null) {
      gl.glColor4f(1, 1, 1, 1);
    } else {
      ParticleColor color = colors[i];
      gl.glColor4b(color.r, color.g, color.b, (byte) 127);
    }
    for (int j = 0; j < NUM_CIRCLE_POINTS; j++) {
      gl.glVertex3f(x + cx, y + cy, 0);
      float temp = x;
      x = c * x - s * y;
      y = s * temp + c * y;
    }
    gl.glEnd();
  }
  gl.glPopMatrix();
}
 
開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:35,代碼來源:JoglDebugDraw.java

示例10: render

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
    if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0) {
        return;
    }

    assert (initialized_context_ != null);

    final float[] vertex_data = {
            //tu,   tv,     x,     y,    z
            0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f };
    FloatBuffer vertices = FloatBuffer.wrap(vertex_data);

    gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);

    gl2.glMatrixMode(gl2.GL_MODELVIEW);
    gl2.glLoadIdentity();

    // Match GL units to screen coordinates.
    gl2.glViewport(0, 0, view_width_, view_height_);
    gl2.glMatrixMode(gl2.GL_PROJECTION);
    gl2.glLoadIdentity();

    // Draw the background gradient.
    gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
    gl2.glBegin(gl2.GL_QUADS);
    gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);  // red
    gl2.glVertex2f(-1.0f, -1.0f);
    gl2.glVertex2f(1.0f, -1.0f);
    gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);  // blue
    gl2.glVertex2f(1.0f, 1.0f);
    gl2.glVertex2f(-1.0f, 1.0f);
    gl2.glEnd();
    gl2.glPopAttrib();

    // Rotate the view based on the mouse spin.
    if (spin_x_ != 0) {
        gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
    }
    if (spin_y_ != 0) {
        gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);
    }

    if (transparent_) {
        // Alpha blending style. Texture values have premultiplied alpha.
        gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);

        // Enable alpha blending.
        gl2.glEnable(gl2.GL_BLEND);
    }

    // Enable 2D textures.
    gl2.glEnable(gl2.GL_TEXTURE_2D);

    // Draw the facets with the texture.
    assert (texture_id_[0] != 0);
    gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
    gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
    gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);

    // Disable 2D textures.
    gl2.glDisable(gl2.GL_TEXTURE_2D);

    if (transparent_) {
        // Disable alpha blending.
        gl2.glDisable(gl2.GL_BLEND);
    }
}
 
開發者ID:Panda-Programming-Language,項目名稱:Pandomium,代碼行數:69,代碼來源:CefRenderer.java

示例11: render

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
  if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0)
    return;

  assert(initialized_context_ != null);

  final float[] vertex_data = {
      //tu,   tv,     x,     y,    z
      0.0f, 1.0f, -1.0f, -1.0f, 0.0f,
      1.0f, 1.0f,  1.0f, -1.0f, 0.0f,
      1.0f, 0.0f,  1.0f,  1.0f, 0.0f,
      0.0f, 0.0f, -1.0f,  1.0f, 0.0f
  };
  FloatBuffer vertices = FloatBuffer.wrap(vertex_data);

  gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);

  gl2.glMatrixMode(gl2.GL_MODELVIEW);
  gl2.glLoadIdentity();

  // Match GL units to screen coordinates.
  gl2.glViewport(0, 0, view_width_, view_height_);
  gl2.glMatrixMode(gl2.GL_PROJECTION);
  gl2.glLoadIdentity();
  gl2.glOrtho(0, 0, view_width_, view_height_, 0.1, 100.0);

  // Draw the background gradient.
  gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
  gl2.glBegin(gl2.GL_QUADS);
  gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);  // red
  gl2.glVertex2f(-1.0f, -1.0f);
  gl2.glVertex2f(1.0f, -1.0f);
  gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);  // blue
  gl2.glVertex2f(1.0f, 1.0f);
  gl2.glVertex2f(-1.0f, 1.0f);
  gl2.glEnd();
  gl2.glPopAttrib();

  // Rotate the view based on the mouse spin.
  if (spin_x_ != 0)
    gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
  if (spin_y_ != 0)
    gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);

  if (transparent_) {
    // Alpha blending style. Texture values have premultiplied alpha.
    gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);

    // Enable alpha blending.
    gl2.glEnable(gl2.GL_BLEND);
  }

  // Enable 2D textures.
  gl2.glEnable(gl2.GL_TEXTURE_2D);

  // Draw the facets with the texture.
  assert(texture_id_[0] != 0);
  gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
  gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
  gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);

  // Disable 2D textures.
  gl2.glDisable(gl2.GL_TEXTURE_2D);

  if (transparent_) {
    // Disable alpha blending.
    gl2.glDisable(gl2.GL_BLEND);
  }
}
 
開發者ID:viglucci,項目名稱:app-jcef-example,代碼行數:71,代碼來源:CefRenderer.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

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


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