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


Java GL2.glOrthof方法代碼示例

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


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

示例1: setupCamera

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void setupCamera(GL2 gl, GLU glu, float x, float y, float z,
		int width, int height) {

	if(state != null) {
		// Change to projection matrix.
		gl.glMatrixMode(GL2.GL_PROJECTION);
		gl.glLoadIdentity();

		gl.glViewport(0, 0, width, height);

		FloatBoundingBox bbox = state.getOrthogonalBBox();
		float glWidth = Math.abs(bbox.getUpperRight().getX()
				- bbox.getUpperLeft().getX());
		float glHeight = Math.abs(bbox.getUpperRight().getY()
				- bbox.getLowerRight().getY());

		FloatVector3D glCenter = state.getPosition();
		
		gl.glOrthof(glCenter.getX() - glWidth / 2.0f, glCenter.getX() + glWidth
				/ 2.0f, glCenter.getY() - glHeight / 2.0f, glCenter.getY()
				+ glHeight / 2.0f, -10000, 10000);
		
		gl.glTranslatef(glCenter.getX(), glCenter.getY(), 0);
		gl.glRotatef(state.getRotation().getX(), 1, 0, 0);
		gl.glRotatef(state.getRotation().getZ(), 0, 0, 1);
		gl.glTranslatef(-glCenter.getX(), -glCenter.getY(), 0);
		
		// Change back to model view matrix.
		gl.glMatrixMode(GL2.GL_MODELVIEW);
		gl.glLoadIdentity();
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:34,代碼來源:Mode2D.java

示例2: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
	// Update and fetch texture.
	if (adapter.toDraw()) {
		adapter.bindTexture(gl);
		Texture tex = adapter.getTexture();
		
		if (tex != null) {
			gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
			tex.bind(gl);
			
			TextureCoords texCoords = tex.getImageTexCoords();
			
			
			FloatBoundingBox box = adapter.getDrawBox();
			FloatVector3D upperLeft = box.getUpperLeft();
			FloatVector3D upperRight = box.getUpperRight();
			FloatVector3D lowerLeft = box.getLowerLeft();
			FloatVector3D lowerRight = box.getLowerRight();
			
			gl.glMatrixMode(GL2.GL_PROJECTION);
			gl.glLoadIdentity();
			gl.glOrthof(-1, 1, 
						-1, 1, 
						-10000, 10000);
			
			gl.glDisable(GL2.GL_DEPTH_TEST);
			
			gl.glMatrixMode(GL2.GL_MODELVIEW);
			
			// Lift the x-y-pane up:
			gl.glTranslatef(0, 0, height);
			
			// Draw texture.
			gl.glBegin(GL2.GL_QUADS);
			gl.glTexCoord2f(texCoords.left(), texCoords.top());
			gl.glVertex3f(upperLeft.getX(), upperLeft.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
			gl.glVertex3f(lowerLeft.getX(), lowerLeft.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
			gl.glVertex3f(lowerRight.getX(), lowerRight.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.right(), texCoords.top());
			gl.glVertex3f(upperRight.getX(), upperRight.getY(), 0.0f);
			gl.glEnd();
		}
	}
	
	// Draw next layer if available.
	if (this.hasNextLayer()) {
		this.getNextLayer().draw(gl, height + HEIGHT_GAP);			
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:53,代碼來源:WeatherLayer.java

示例3: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
	
	// If not done yet, invoke the adapters initialization:
	if(!adapterInitialized) {
		adapter.performGLInit(gl);
		adapterInitialized = true;
	}
	
	// Perform all the necessary OpenGL-stuff:
	adapter.performGLCalls(gl);
	
	// Update and fetch texture.
	Texture tex = adapter.getTexture(CopyrightAdapter.COPYRIGHT_TEXTURE_KEY);
	if (tex != null) {
		gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
		tex.bind(gl);
		
		TextureCoords texCoords = tex.getImageTexCoords();
		
		FloatBoundingBox box = adapter.getDrawBox();
		if(box != null) {
			FloatVector3D upperLeft = box.getUpperLeft();
			FloatVector3D upperRight = box.getUpperRight();
			FloatVector3D lowerLeft = box.getLowerLeft();
			FloatVector3D lowerRight = box.getLowerRight();
			
			gl.glMatrixMode(GL2.GL_PROJECTION);
			gl.glLoadIdentity();
			gl.glOrthof(-1, 1, 
						-1, 1, 
						-10000, 10000);
			
			gl.glDisable(GL2.GL_DEPTH_TEST);
			
			gl.glMatrixMode(GL2.GL_MODELVIEW);
			
			// Lift the x-y-pane up:
			gl.glTranslatef(0, 0, height);
			
			// Draw texture.
			gl.glBegin(GL2.GL_QUADS);
			gl.glTexCoord2f(texCoords.left(), texCoords.top());
			gl.glVertex3f(upperLeft.getX(), upperLeft.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
			gl.glVertex3f(lowerLeft.getX(), lowerLeft.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
			gl.glVertex3f(lowerRight.getX(), lowerRight.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.right(), texCoords.top());
			gl.glVertex3f(upperRight.getX(), upperRight.getY(), 0.0f);
			gl.glEnd();
		}
	}
	
	// Draw next layer.
	if (this.hasNextLayer()) {
		this.getNextLayer().draw(gl, height + HEIGHT_GAP);
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:60,代碼來源:CopyrightLayer.java

示例4: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
	
	// If not done yet, invoke the adapters initialization:
	if(!adapterInitialized) {
		adapter.performGLInit(gl);
	}
	
	// Perform all the necessary OpenGL-stuff:
	adapter.performGLCalls(gl);
	
	// Update and fetch texture.
	Texture tex = adapter.getTexture(CompassAdapter.COMPASS_TEXTURE_KEY);
	if (tex != null) {
		gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
		tex.bind(gl);
		
		TextureCoords texCoords = tex.getImageTexCoords();
		
		FloatBoundingBox box = adapter.getDrawBox();
		FloatVector3D upperLeft = box.getUpperLeft();
		FloatVector3D upperRight = box.getUpperRight();
		FloatVector3D lowerLeft = box.getLowerLeft();
		FloatVector3D lowerRight = box.getLowerRight();
		
		gl.glMatrixMode(GL2.GL_PROJECTION);
		gl.glLoadIdentity();
		gl.glOrthof(-1, 1, 
					-1, 1, 
					-10000, 10000);
		
		gl.glDisable(GL2.GL_DEPTH_TEST);
		
		gl.glMatrixMode(GL2.GL_MODELVIEW);
		
		// Lift the x-y-pane up:
		gl.glTranslatef(0, 0, height);
		
		// Draw texture.
		gl.glBegin(GL2.GL_QUADS);
		gl.glTexCoord2f(texCoords.left(), texCoords.top());
		gl.glVertex3f(upperLeft.getX(), upperLeft.getY(), 0.0f);
		gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
		gl.glVertex3f(lowerLeft.getX(), lowerLeft.getY(), 0.0f);
		gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
		gl.glVertex3f(lowerRight.getX(), lowerRight.getY(), 0.0f);
		gl.glTexCoord2f(texCoords.right(), texCoords.top());
		gl.glVertex3f(upperRight.getX(), upperRight.getY(), 0.0f);
		gl.glEnd();
	}
	
	// Draw next layer.
	if (this.hasNextLayer()) {
		this.getNextLayer().draw(gl, height + HEIGHT_GAP);
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:57,代碼來源:CompassLayer.java


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