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


Java GL2.glOrtho方法代碼示例

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


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

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

示例4: beginDrawLasso

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

	int attributeMask =
		GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
			| GL2.GL_TRANSFORM_BIT // for modelview and perspective
			| GL2.GL_VIEWPORT_BIT // for depth range
			| GL2.GL_CURRENT_BIT // for current color
			| GL2.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
			| GL2.GL_DEPTH_BUFFER_BIT // for depth func
			| GL2.GL_ENABLE_BIT; // for enable/disable changes
	gl.glPushAttrib(attributeMask);

	// Apply the depth buffer but don't change it.
	gl.glEnable(GL.GL_DEPTH_TEST);
	gl.glDepthFunc(GL.GL_ALWAYS);
	gl.glDepthMask(false);

	// Load a parallel projection with dimensions (viewportWidth, viewportHeight)
	int[] viewport = new int[4];
	gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
	gl.glMatrixMode(GL2.GL_PROJECTION);
	gl.glPushMatrix();
	gl.glLoadIdentity();
	gl.glOrtho(0d, viewport[2], 0d, viewport[3], -1d, 1d);

	gl.glMatrixMode(GL2.GL_MODELVIEW);
	gl.glPushMatrix();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:31,代碼來源:LassoSelectionHandler.java

示例5: display

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

	// Apply transformations
	double transx = -origin.getX(), transy = -origin.getY();

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

	gl.glTranslated(transx + zoomPos.getX(), transy + zoomPos.getY(), 0);
	gl.glScaled(scaleFactor, scaleFactor, 1);
	gl.glTranslated(-zoomPos.getX(), -zoomPos.getY(), 0);

	gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelview);
	gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projection);
	gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport);
	gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

	// Draw edges, arrows and vertices
	edgeRenderer.transform(transx, transy, scaleFactor);
	edgeRenderer.render();

	if (animateLabels) {
		labelRenderer.scale(scaleFactor);
		labelRenderer.drawLabels();
	}

	vertexRenderer.transform(transx, transy, scaleFactor);
	vertexRenderer.render();
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:34,代碼來源:NetworkRenderer.java

示例6: setProjection

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void setProjection(GL2 openGl) {
    float halfOfHorizont = width / zoom;
    float halfOfVertical = height / zoom;
    openGl.glViewport(0, 0, width, height);
    openGl.glMatrixMode(GL2.GL_PROJECTION);
    openGl.glLoadIdentity();
    openGl.glOrtho(-halfOfHorizont, halfOfHorizont, -halfOfVertical, halfOfVertical, -1000, +1000);
    openGl.glMatrixMode(GL2.GL_MODELVIEW);
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:10,代碼來源:Camera.java

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

示例8: beginDrawIcons

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

	this.oglStackHandler.clear();

	int attributeMask =
		GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
			| GL2.GL_TRANSFORM_BIT // for modelview and perspective
			| GL2.GL_VIEWPORT_BIT // for depth range
			| GL2.GL_CURRENT_BIT // for current color
			| GL.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
			| GL2.GL_TEXTURE_BIT // for texture env
			| GL.GL_DEPTH_BUFFER_BIT // for depth func
			| GL2.GL_ENABLE_BIT; // for enable/disable changes
	this.oglStackHandler.pushAttrib(gl, attributeMask);

	// Apply the depth buffer but don't change it.
	if ((!dc.isDeepPickingEnabled())) {
		gl.glEnable(GL.GL_DEPTH_TEST);
	}
	gl.glDepthMask(false);

	// Suppress any fully transparent image pixels
	gl.glEnable(GL2.GL_ALPHA_TEST);
	gl.glAlphaFunc(GL.GL_GREATER, 0.001f);

	// Load a parallel projection with dimensions (viewportWidth, viewportHeight)
	this.oglStackHandler.pushProjectionIdentity(gl);
	gl.glOrtho(0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -16d, 16d);

	this.oglStackHandler.pushModelview(gl);
	this.oglStackHandler.pushTexture(gl);

	if (dc.isPickingMode())
	{
		this.pickSupport.beginPicking(dc);

		// Set up to replace the non-transparent texture colors with the single pick color.
		gl.glEnable(GL.GL_TEXTURE_2D);
		gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
		gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_SRC0_RGB, GL2.GL_PREVIOUS);
		gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, GL2.GL_REPLACE);
	}
	else
	{
		gl.glEnable(GL.GL_TEXTURE_2D);
		gl.glEnable(GL.GL_BLEND);
		gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
	}

	//Only calculate pitch / heading once **
	heading = this.computeHeading(dc.getView());
	pitch = this.computePitch(dc.getView());
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:56,代碼來源:DetailedIconRenderer.java

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


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