本文整理匯總了Java中javax.media.opengl.GL2.glLoadIdentity方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glLoadIdentity方法的具體用法?Java GL2.glLoadIdentity怎麽用?Java GL2.glLoadIdentity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glLoadIdentity方法的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);
}
示例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();
}
示例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;
}
}
示例4: 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);
}
示例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);
}
示例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);
}
示例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());
}
示例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 */
}
示例9: 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);
}
示例10: 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 );
}
示例11: 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();
}
示例12: 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);
}
示例13: display
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void display(GLAutoDrawable drawable)
{
GL2 gl = drawable.getGL().getGL2();
switch(cmd)
{
case UPDATE:
drawScene(gl);
break;
case SELECT:
int buffsize = 512;
double x = (double) mouse_x, y = (double) mouse_y;
int[] viewPort = new int[4];
IntBuffer selectBuffer = Buffers.newDirectIntBuffer(buffsize);
int hits = 0;
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0);
gl.glSelectBuffer(buffsize, selectBuffer);
gl.glRenderMode(GL2.GL_SELECT);
gl.glInitNames();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
glu.gluPickMatrix(x, (double) viewPort[3] - y, 5.0d, 5.0d, viewPort, 0);
glu.gluOrtho2D(0.0d, 1.0d, 0.0d, 1.0d);
drawScene(gl);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPopMatrix();
gl.glFlush();
hits = gl.glRenderMode(GL2.GL_RENDER);
processHits(hits, selectBuffer);
cmd = UPDATE;
break;
}
}
示例14: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void render(DrawContext dc) {
beginDrawLasso(dc);
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
gl.glLoadIdentity();
gl.glColor3f(1, 1, 0);
gl.glBegin(GL.GL_LINE_STRIP);
Vec4 startPoint = null;
for (Position pos : lasso)
{
Vec4 screenPoint = dc.getView().project(
dc.getGlobe().computePointFromPosition(pos));
if (screenPoint == null)
continue;
if (startPoint == null)
startPoint = screenPoint;
gl.glVertex3d(screenPoint.x, screenPoint.y, startPoint.z);
}
if (startPoint != null)
gl.glVertex3d(startPoint.x, startPoint.y, startPoint.z);
gl.glEnd();
endDrawLasso(dc);
}
示例15: 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();
}