本文整理匯總了Java中javax.media.opengl.GL.glMatrixMode方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glMatrixMode方法的具體用法?Java GL.glMatrixMode怎麽用?Java GL.glMatrixMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glMatrixMode方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderText
import javax.media.opengl.GL; //導入方法依賴的package包/類
private void renderText(GL gl, String text, int x, int y, int font) {
int viewport[] = new int[4];
gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
{
gl.glOrtho(0, viewport[2], 0, viewport[3], -1, 1);
gl.glColor3d(1, 1, 1);
gl.glRasterPos3d(0, 0, 0);
glut.glutBitmapString(font, text);
}
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPopMatrix();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPopMatrix();
}
示例2: init
import javax.media.opengl.GL; //導入方法依賴的package包/類
@Override
public synchronized void init(GLAutoDrawable glDrawable) {
GL gl = glDrawable.getGL();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glClearDepth(1.0);
gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
/* float[] lightAmbient = new float[]{0.5f, 0.5f, 0.5f, 1.0f};
float[] lightDiffuse = new float[]{1.0f, 1.0f, 1.0f, 1.0f};
float[] lightPosition = new float[]{
0, 0, 0,
// (float)levelBox.getFlag().getCenterX(),
// (float)levelBox.getFlag().getCenterY(),
// (float)levelBox.getFlag().getCenterZ() + (float)levelBox.getFlag().getDeltaZ(),
1.0f};
gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, FloatBuffer.wrap(lightAmbient));
gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, FloatBuffer.wrap(lightDiffuse));
gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, FloatBuffer.wrap(lightPosition));
gl.glEnable(GL.GL_LIGHT0);
*/
gl.glDisable(GL.GL_LIGHTING);
// Now preprocess our data for rendering
agentRenderes.prepare(gl);
mapRenderer.prepare(gl);
}
示例3: setProjection
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Set projection, viewpoinbt and so on. Used every rendered frame.
*/
private synchronized void setProjection(GL gl, int x, int y, int width, int height) {
if (height <= 0) { // avoid a divide by zero error!
height = 1;
}
float h = (float) width / (float) height;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(viewpoint.getViewAngle(), h, 10.0, 100000.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例4: prepareCanvas
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Clear the screen, set up correct observer position and other stuff
* @param gl
*/
private synchronized void prepareCanvas(GL gl) {
// Clear the drawing area
gl.glEnable(GL.GL_DEPTH_TEST); // GL.GL_NORMALIZE|
gl.glClearColor(0.45f, 0.45f, 0.45f, 0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// Reset the modelview to the "identity"
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
// Move the "drawing cursor" around
Location observerLoc = viewpoint.getLocation();
Location eyeLoc = viewpoint.getEye();
Vector3d upVec = viewpoint.getUp();
// gl.glTranslated(observerLocation.x, observerLocation.y, observerLocation.z);
glu.gluLookAt(
eyeLoc.x,
eyeLoc.y,
eyeLoc.z,
observerLoc.x,
observerLoc.y,
observerLoc.z,
upVec.x,
upVec.y,
upVec.z);
gl.glScaled (1., 1., -1.);
}
示例5: setOrthoViewport
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Set mode according to viewport. 0,0 is at left top
*/
public static void setOrthoViewport(GL gl) {
Rectangle viewport = getViewport(gl);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(viewport.getMinX(), viewport.getMaxX(), viewport.getMinY(), viewport.getMaxY(), -1, 1);
gl.glMatrixMode(GL.GL_MODELVIEW);
}
示例6: pushMatrixMode
import javax.media.opengl.GL; //導入方法依賴的package包/類
public static void pushMatrixMode(GL gl) {
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();
}
示例7: popMatrixMode
import javax.media.opengl.GL; //導入方法依賴的package包/類
public static void popMatrixMode(GL gl) {
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPopMatrix();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPopMatrix();
}