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


Java GL2.glClearColor方法代碼示例

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


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

示例1: init

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void init(GLAutoDrawable drawable) {
	GL2 gl = drawable.getGL().getGL2();
	glu = new GLU();
	
    /* select clearing color (background) color */
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
 
    /* initialize viewing values */
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
	
 // Start animator (which should be a field).
       animator = new FPSAnimator(drawable, 60);
       animator.start();
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:18,代碼來源:TestFrameComponent.java

示例2: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Invokes all layers to draw.
 */
public void draw(GL2 gl) {
	super.draw(gl);
	
	if (state != null && gl != null && drawableLayer != null) {

		GaiaCanvas canvas = GaiaCanvas.getInstance();

		// Clear the color-buffer to white:
		gl.glClearColor(0xFF, 0xFF, 0xFF, 0);
		gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

		// Set camera.
		float currentZoom = state.getZoom();

		setupCamera(gl, new GLU(), state.getPosition().getX(), state
				.getPosition().getY(), currentZoom, canvas.getWidth(),
				canvas.getHeight());

		// Draw all layers beginning with the lowest:
		drawableLayer.draw(gl, 0);
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:26,代碼來源:Mode2D.java

示例3: init

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void init(GLAutoDrawable gLDrawable)
{
  final GL2  gl =   gLDrawable.getContext().getGL().getGL2();
  final GLUT glu =  new GLUT();
       
  gl.glMatrixMode (GL2.GL_PROJECTION); 
  gl.glClearColor (1.0f, 1.0f, 1.0f, 0.0f);   //set background to white
  //glu.gluOrtho2D (0.0, 200.0, 0.0, 150.0);  // define drawing area
  //gLDrawable.addKeyListener(this);
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:11,代碼來源:GLTextRender.java

示例4: init

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void init(GLAutoDrawable drawable) 
{
  GL2 gl = drawable.getGL().getGL2();
  gl.glEnable(GL2.GL_CULL_FACE);
  gl.glEnable(GL2.GL_DEPTH_TEST);
  gl.glEnable(GL2.GL_NORMALIZE);
  gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:9,代碼來源:Picking.java

示例5: init

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void init(GLAutoDrawable drawable) {
	GL2 gl = drawable.getGL().getGL2();
	this.drawable = drawable;

	if (AA_SMOOTHING) {
		// Anti-aliasing using Smoothing
		if (AA_SMOOTH_LINES) {
			gl.glEnable(GL2.GL_LINE_SMOOTH);
			gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST);
		}

		// TODO: This AA method creates "transparency" in GLU polygons
		if (AA_SMOOTH_POLYGONS) {
			gl.glEnable(GL2.GL_POLYGON_SMOOTH);
			gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_NICEST);
		}

		if (AA_SMOOTH_POINTS) {
			gl.glEnable(GL2.GL_POINT_SMOOTH);
			gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST);
		}

		gl.glEnable(GL2.GL_BLEND);
		gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);

	} else if (AA_MULTISAMPLING) {
		// Anti-aliasing using Multisampling
		gl.glEnable(GL2.GL_MULTISAMPLE);
	}

	gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

	// Renderers
	this.vertexRenderer = new VertexRenderer(drawable, this);
	this.edgeRenderer = new EdgeRenderer(drawable, this);
	this.labelRenderer = new LabelRenderer(drawable, this);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:38,代碼來源:NetworkRenderer.java

示例6: initialize

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

    initialized_context_ = gl2;

    if (!gl2.getContext().isHardwareRasterizer()) {
        // Workaround for Windows Remote Desktop which requires pot textures.
        CefApp.getLogger().info("opengl rendering may be slow as hardware rendering isn't available");
        use_draw_pixels_ = true;
        return;
    }

    gl2.glHint(gl2.GL_POLYGON_SMOOTH_HINT, gl2.GL_NICEST);

    gl2.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    // Necessary for non-power-of-2 textures to render correctly.
    gl2.glPixelStorei(gl2.GL_UNPACK_ALIGNMENT, 1);

    // Create the texture.
    gl2.glGenTextures(1, texture_id_, 0);
    assert (texture_id_[0] != 0);

    gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
    gl2.glTexParameteri(gl2.GL_TEXTURE_2D, gl2.GL_TEXTURE_MIN_FILTER, gl2.GL_NEAREST);
    gl2.glTexParameteri(gl2.GL_TEXTURE_2D, gl2.GL_TEXTURE_MAG_FILTER, gl2.GL_NEAREST);
    gl2.glTexEnvf(gl2.GL_TEXTURE_ENV, gl2.GL_TEXTURE_ENV_MODE, gl2.GL_MODULATE);
}
 
開發者ID:Panda-Programming-Language,項目名稱:Pandomium,代碼行數:32,代碼來源:CefRenderer.java

示例7: initialize

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

  initialized_context_ = gl2;

  if (!gl2.getContext().isHardwareRasterizer()) {
    // Workaround for Windows Remote Desktop which requires pot textures.
    System.out.println("opengl rendering may be slow as hardware rendering isn't available");
    use_draw_pixels_ = true;
    return;
  }

  gl2.glHint(gl2.GL_POLYGON_SMOOTH_HINT, gl2.GL_NICEST);

  gl2.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

  // Necessary for non-power-of-2 textures to render correctly.
  gl2.glPixelStorei(gl2.GL_UNPACK_ALIGNMENT, 1);

  // Create the texture.
  gl2.glGenTextures(1, texture_id_, 0);
  assert(texture_id_[0] != 0);

  gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
  gl2.glTexParameteri(gl2.GL_TEXTURE_2D, gl2.GL_TEXTURE_MIN_FILTER, gl2.GL_NEAREST);
  gl2.glTexParameteri(gl2.GL_TEXTURE_2D, gl2.GL_TEXTURE_MAG_FILTER, gl2.GL_NEAREST);
  gl2.glTexEnvf(gl2.GL_TEXTURE_ENV, gl2.GL_TEXTURE_ENV_MODE, gl2.GL_MODULATE);
}
 
開發者ID:viglucci,項目名稱:app-jcef-example,代碼行數:31,代碼來源:CefRenderer.java

示例8: setupLighting

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void setupLighting(GLAutoDrawable drawable, GL2 gl) {
	int paramsOffset = 0;
	float pos[] = { 2.0f, -2.0f, 10.0f, 0.0f };
	float ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
	float diffuse[] = {0.9f, 0.9f, 0.9f, 1.0f};
	float specular[] = {0.05f, 0.05f, 0.99f, 1.0f};

	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0);
	gl.glEnable(GL2.GL_LIGHTING);
	gl.glEnable(GL2.GL_LIGHT0);
	gl.glEnable(GL2.GL_DEPTH_TEST);
	gl.glEnable(GL2.GL_AUTO_NORMAL);
	gl.glEnable(GL2.GL_NORMALIZE);

	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, paramsOffset);
	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, paramsOffset);
	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specular, paramsOffset);
	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, paramsOffset);
	gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL2.GL_TRUE);

	gl.glClearColor(1f, 1f, 1f, 1f);
	gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
	gl.glMatrixMode(GL2.GL_MODELVIEW);
	gl.glLoadIdentity();
	gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
	gl.glMatrixMode(GL2.GL_PROJECTION);
	gl.glLoadIdentity();
	if (gl instanceof GLLightingFunc) {
		((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT_AND_DIFFUSE, blue, 0);
		((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SPECULAR, white, 0);
		float[] medHiShiny = new float[] {80.0f};
		((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, medHiShiny, 0);
		((GLLightingFunc) gl).glShadeModel(GLLightingFunc.GL_FLAT);
	}
}
 
開發者ID:akmaier,項目名稱:CONRAD,代碼行數:36,代碼來源:SurfaceTest.java

示例9: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl) {
	
	boolean lastFrame2D = wasLastFrame2D();
	super.draw(gl);
	
	// Clear the color-buffer to white:
	gl.glClearColor(0x0, 0x0, 0x0, 0);
	gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

	this.setCamera(gl, this.glu, this.width, this.height);
	// this.setLights(gl);

	gl.glLoadIdentity();

	if(state.is2DMode() != lastFrame2D) {
		oldRotation = new FloatVector3D(0, 0, 0);
		System.arraycopy(IDENTITY, 0, modelViewMatrix, 0, IDENTITY.length);
		gl.glRotatef(-90, 1, 0, 0);
		gl.glMultMatrixf(modelViewMatrix, 0);
		gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, modelViewMatrix, 0);
		gl.glLoadIdentity();
	}

	
	FloatVector3D relativeRotation = new FloatVector3D(oldRotation);
	relativeRotation.sub(state.getRotation());
	
	
	// rotate the globe
	gl.glRotatef(relativeRotation.getX(), 1, 0, 0);
	gl.glRotatef(relativeRotation.getY(), 0, 1, 0);
	// compute 'old' rotation
	gl.glMultMatrixf(modelViewMatrix, 0);

	// reset the rotations
	oldRotation = new FloatVector3D(state.getRotation());

	// store the current rotation in the GL-state
	gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, modelViewMatrix, 0);

	this.drawEarth(gl);
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:44,代碼來源:Mode3D.java

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