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


Java GL2.glMatrixMode方法代碼示例

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


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

示例1: init

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void init(GLAutoDrawable drawable) {
	System.out.println("--init--");
	GL2 gl = drawable.getGL().getGL2();
	glu = new GLU();

	System.out.println("INIT GL IS: " + gl.getClass().getName());
	if (!bDoNurbs) {
		gl.glMap2f(GL2.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, ctlarray, 0);
	}
	gl.glEnable(GL2.GL_MAP2_VERTEX_3);
	gl.glEnable(GL2.GL_AUTO_NORMAL);
	gl.glMapGrid2f(20, 0.0f, 1.0f, 20, 0.0f, 1.0f);

	setupLighting(drawable, gl);
	float fovy=40.f;
	float aspect=1.f;
	float znear=1.f;
	float zfar=20f;
	glu.gluPerspective(fovy, aspect, znear, zfar);

	gl.glMatrixMode(GL2.GL_MODELVIEW);
	gl.glLoadIdentity();
	glu.gluLookAt(cameraLoc.x, cameraLoc.y, cameraLoc.z,
			lookAtPt.x, lookAtPt.y, lookAtPt.z,
			cameraUpDirection.x, cameraUpDirection.y, cameraUpDirection.z);
}
 
開發者ID:akmaier,項目名稱:CONRAD,代碼行數:27,代碼來源:SurfaceTest.java

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

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

示例4: end

import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void end(DrawContext dc)
	{
		if (dc.isPickingMode())
			pickSupport.endPicking(dc);
		
		//GL gl = dc.getGL();
		GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

		gl.glMatrixMode(GL2.GL_MODELVIEW);
		gl.glPopMatrix();

//		gl.glDisable(GL.GL_LIGHT1);
//		gl.glEnable(GL.GL_LIGHT0);
//		gl.glDisable(GL.GL_LIGHTING);
//		gl.glDisable(GL.GL_NORMALIZE);
		gl.glPopAttrib();
	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:18,代碼來源:FMSRenderer.java

示例5: reshape

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void reshape(GLAutoDrawable drawable, int x, int y, int width,
		int height) {
	GL2 gl = drawable.getGL().getGL2();
	this.drawable = drawable;
	this.width = width;
	this.height = height;

	gl.glMatrixMode(GL2.GL_PROJECTION);
	gl.glLoadIdentity();
	gl.glOrtho(0, width, height, 0, -1, 1);
	gl.glViewport(0, 0, width, height);

	gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelview);
	gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projection);
	gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:17,代碼來源:NetworkRenderer.java

示例6: useCamera

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param openGl
 */
public void useCamera(final GL2 openGl) {
    if (resetProjection) {
        resetProjection = false;
        setProjection(openGl);
    }

    openGl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, new float[]{1000.f,1000.f,1000.f}, 0);
    openGl.glEnable(GL2.GL_LIGHT0);

    openGl.glMatrixMode(GL2.GL_MODELVIEW);
    openGl.glLoadIdentity();
    position.translateBy(openGl);
    product.rotateAround(openGl);
    upVector.rotateAround(openGl);
    
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:21,代碼來源:Camera.java

示例7: setView

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void setView(GL2 gl, GLU glu, GlobalState gs) {
    // Select part of window.
    gl.glViewport(0, 0, gs.w, gs.h);
    // Set projection matrix.
    gl.glMatrixMode(GL_PROJECTION);
    //Load the identity matrix.
    gl.glLoadIdentity();
    glu.gluPerspective(fovAngle, (float) gs.w / gs.h, planeNear, planeFar);
    // Set camera.
    gl.glMatrixMode(GL_MODELVIEW);
    //Load the identity matrix.
    gl.glLoadIdentity();
    glu.gluLookAt(eye.x(), eye.y(), eye.z(),
            center.x(), center.y(), center.z(),
            up.x(), up.y(), up.z());
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:17,代碼來源:CameraMode.java

示例8: init

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
	public void init( final GLAutoDrawable drawable )
	{
		final GL2 gl = drawable.getGL().getGL2();
		gl.setSwapInterval( 1 );
		gl.glEnable( GL.GL_DEPTH_TEST );
        gl.glDepthFunc( GL.GL_LEQUAL );
        gl.glShadeModel( GLLightingFunc.GL_SMOOTH );
        gl.glHint( GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST );
//		gl.glEnable( GL.GL_BLEND );
//		gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA );
		gl.glEnable( GL2GL3.GL_POLYGON_SMOOTH );

		final float w = this.window.getDrawableSurface().getWidth();
		final float h = this.window.getDrawableSurface().getHeight();

		// Set the projection matrix (only done once - just here)
		gl.glMatrixMode( GLMatrixFunc.GL_PROJECTION );
		gl.glLoadIdentity();
		this.glu.gluPerspective( 50, (w / h), 0.01, 10 );

		// Set the initial model matrix
		gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
		gl.glLoadIdentity();
		gl.glViewport( 0, 0, (int) w, (int) h ); /* viewport size in pixels */
	}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:27,代碼來源:Visualisation3D.java

示例9: applyCamera

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Apply the camera settings.
 * 
 * @param gl GL API.
 */
public void applyCamera(GL2 gl) {
  // Setup projection.
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glLoadIdentity();
  glu.gluPerspective(45f, // fov,
      width / (float) height, // ratio
      0.f, 10.f); // near, far clipping
  eye[0] = (float) Math.sin(theta) * 2.f;
  eye[1] = .5f;
  eye[2] = (float) Math.cos(theta) * 2.f;
  glu.gluLookAt(eye[0], eye[1], eye[2], // eye
      .0f, .0f, 0.f, // center
      0.f, 1.f, 0.f); // up

  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glLoadIdentity();

  gl.glViewport(0, 0, width, height);
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:25,代碼來源:SimpleCamera3D.java

示例10: apply

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Apply the camera to a GL context.
 * 
 * @param gl GL context.
 */
public void apply(GL2 gl) {
  // 3D projection
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glLoadIdentity();
  // Perspective.
  glu.gluPerspective(35, ratio, 1, 1000);
  glu.gluLookAt(distance * sinZ, distance * -cosZ, height, // pos
      0, 0, .5, // center
      0, 0, 1 // up
  );
  // Change back to model view matrix.
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glLoadIdentity();

  // Store the matrixes for reference.
  gl.glGetIntegerv(GL.GL_VIEWPORT, viewp, 0);
  gl.glGetDoublev(GLMatrixFunc.GL_MODELVIEW_MATRIX, modelview, 0);
  gl.glGetDoublev(GLMatrixFunc.GL_PROJECTION_MATRIX, projection, 0);
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:25,代碼來源:Simple1DOFCamera.java

示例11: reshape

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {
  GL2 gl2 = arg0.getGL().getGL2();

  gl2.glMatrixMode(GL2.GL_PROJECTION);
  gl2.glLoadIdentity();

  // coordinate system origin at lower left with width and height same as the window
  GLU glu = new GLU();
  glu.gluOrtho2D(0.0f, getWidth(), 0.0f, getHeight());

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

  gl2.glViewport(0, 0, getWidth(), getHeight());

  controller.updateExtents(arg3 / 2, arg4 / 2);
}
 
開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:19,代碼來源:JoglPanel.java

示例12: updateView

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void updateView( GL2 gl2 )
{
    gl2 .glMatrixMode( GL2.GL_PROJECTION );
    gl2 .glLoadIdentity();

    // coordinate system origin at lower left with width and height same as the window
    if ( this .fov == 0 )
    	gl2 .glOrtho( - this .halfEdge, this .halfEdge, - this .halfEdge, this .halfEdge, this .near, this .far );
    else
    	this .glu .gluPerspective( this .fov, this .width / this .height, this .near, this .far );
    glu .gluLookAt( 0, 0, (this .far - this .near) / 2f, 0, 0, 0, 0, 1, 0 );

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

    gl2 .glViewport( 0, 0, this .width, this .height );
}
 
開發者ID:vZome,項目名稱:vzome-desktop,代碼行數:18,代碼來源:JoglRenderingViewer.java

示例13: setCamera

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void setCamera() {
      GLU glu=new GLU();
      GL2 gl2=GLU.getCurrentGL().getGL2();
      
// Change to projection matrix.
      gl2.glMatrixMode(GL2.GL_PROJECTION);
      gl2.glLoadIdentity();
      glu.gluOrtho2D(0,gl2.getContext().getGLDrawable().getWidth(),0,
      		gl2.getContext().getGLDrawable().getHeight());
	
      // Change back to model view matrix.
      gl2.glMatrixMode(GL2.GL_MODELVIEW);
      gl2.glLoadIdentity();
  }
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:15,代碼來源:GLWidget.java

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

示例15: reshape

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) 
{
  GL2 gl = drawable.getGL().getGL2();
  gl.glViewport(0, 0, width, height);
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glLoadIdentity();
  glu.gluOrtho2D(0.0f,1.0f,0.0f,1.0f);
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:9,代碼來源:Picking.java


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