本文整理汇总了Java中com.jogamp.opengl.GL2.glOrtho方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glOrtho方法的具体用法?Java GL2.glOrtho怎么用?Java GL2.glOrtho使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glOrtho方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCameraMapping
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void setCameraMapping(GL2 gl, GLU glu)
{
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(-1, 1, -1, 1, 0.01, 1000);
//look at the player from 2.5 units directly above the player
glu.gluLookAt(
inst.player.pos.x + inst.offset.x, inst.player.pos.y + inst.offset.y, 1.5,
inst.player.pos.x + inst.offset.x, inst.player.pos.y + inst.offset.y, 0,
0, 1, 0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例2: display
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Called by the drawable to initiate OpenGL rendering by the
client. After all GLEventListeners have been notified of a
display event, the drawable will swap its buffers if {@link
GLAutoDrawable#setAutoSwapBufferMode setAutoSwapBufferMode} is
enabled. */
@Override
public void display(GLAutoDrawable drawable){
target.update();
GL2 gl=drawable.getGL().getGL2();
gl.glClearColor(0,0,0,0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glPushMatrix();
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
gl.glLoadIdentity(); // very important to load identity matrix here so this works after first resize!!!
gl.glOrtho(0,drawable.getSurfaceWidth() ,0,drawable.getSurfaceHeight(),10000,-10000);
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glPopMatrix();
gl.glPushMatrix();
gl.glColor3f(1,1,1);
gl.glRectf(target.x()-SIZE, target.y()-SIZE, target.x()+SIZE, target.y()+SIZE);
// gl.glColor3f(1,1,1);
// gl.glTranslatef(target.x(),target.y(),0);
// if(eyeQuad==null) eyeQuad = glu.gluNewQuadric();
// glu.gluQuadricDrawStyle(eyeQuad,GLU.GLU_FILL);
// glu.gluDisk(eyeQuad,0,5,16,1);
gl.glPopMatrix();
}
示例3: init
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void init(GLAutoDrawable drawable)
{
GL2 gl = drawable.getGL().getGL2();
gl.glPointSize(5.0f);
gl.glLineWidth(1.0f);
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(-1, 1, -1, 1, 0.01, 1000);
//gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glEnable(GL2.GL_DEPTH_TEST);
gl.glDepthFunc(GL2.GL_LEQUAL);
// Enable smooth shading.
gl.glShadeModel(GL2.GL_SMOOTH);
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
// Define "clear" color.
gl.glClearColor(0f, 0f, 0f, 0f);
// We want a nice perspective.
gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
float[] pos = {1,-1,1,0};
float[] diff = {1,1,1,1};
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diff, 0);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0);
gl.glEnable(GL2.GL_LIGHT0);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_COLOR_MATERIAL);
if(Shoot.DEBUG)
drawable.getAnimator().setUpdateFPSFrames(25, System.out);
}
示例4: reshape
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void reshape(Graphics3D graphics, int x, int y, int width, int height) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2();
gl.glViewport (x, y, width, height);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
double left = -10;
double right = +10;
double bottom = -10;
double top = +10;
float aspect = (float)width / (float)height;
gl.glOrtho(left*aspect, right*aspect, bottom, top, 0.1, 500);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}