本文整理匯總了Java中javax.media.opengl.GL.glPushMatrix方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glPushMatrix方法的具體用法?Java GL.glPushMatrix怎麽用?Java GL.glPushMatrix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glPushMatrix方法的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: circle2D
import javax.media.opengl.GL; //導入方法依賴的package包/類
private static void circle2D(GL gl, Point2D center, double radius, double zOffset){
gl.glPushMatrix();
gl.glTranslatef((float)center.getX(), (float)center.getY(), (float)zOffset);
float w = (float)Math.cos(Math.PI / 4);
cad_NURBS(gl, radius,0.0,0.0,1.0,
radius,radius,0.0,w,
0.0,radius,0.0,1.0);
cad_NURBS(gl, -radius,0.0,0.0,1.0,
-radius,radius,0.0,w,
0.0,radius,0.0,1.0);
cad_NURBS(gl, -radius,0.0,0.0,1.0,
-radius,-radius,0.0,w,
0.0,-radius,0.0,1.0);
cad_NURBS(gl, radius,0.0,0.0,1.0,
radius,-radius,0.0,w,
0.0,-radius,0.0,1.0);
gl.glPopMatrix();
}
示例3: renderAgent
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Render agent at specified position
* @param gl
* @param position
*/
private void renderAgent(GL gl, GlColor color, Location position) {
gl.glPushMatrix();
{
gl.glTranslated(position.x, position.y, position.z);
// draw sphere
gl.glColor4d(color.r, color.g, color.b, color.a);
glu.gluSphere(quadratic, SPHERE_RADIUS, SPHERE_SLICES, SPHERE_STACKS);
IPogamutEnvironments environments = Lookup.getDefault().lookup(IPogamutEnvironments.class);
if (environments != null) {
Collection c = environments.getEnvironmentSelection(map).lookupAll(this.agent.getDataSource().getClass());
for (Object o : c) {
if (agent.getDataSource().equals(o)) {
gl.glColor3d(0.3, 0.3, 0.3);
glu.gluDisk(quadratic, SPHERE_RADIUS * 1.2, SPHERE_RADIUS * 1.5, 32, 3);
}
}
}
}
gl.glPopMatrix();
Rotation rot = agent.getRotation();
if (rot != null) {
renderRotation(gl, new GlColor(1, 0, 0), position, rot);
}
/* if (window == null) {
window = new GLTextWindow(gl, 100, 20, 200, 50, "Hi, this is a test text 1234567890");
}
window.render();
*/
}
示例4: renderPlacedMapEvent
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Render {@link MapEvent} that is placed at fixed place (=not at the player).
* @param gl
* @param color what color should be map event drawn.
* @param mapEvent map event to render.
*/
private void renderPlacedMapEvent(GL gl, GlColor color, MapEvent mapEvent) {
LogMapMark mapMark = mapEvent.getMark();
Location position = mapMark.getLocation();
if (logger.isLoggable(Level.FINE)) logger.fine(" MSG: " + mapMark.getMessage() + ", LOC: " + position);
// gl.glEnable(GL.GL_BLEND);
// gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glPushMatrix();
{
gl.glTranslated(position.x, position.y, position.z + SPHERE_RADIUS * 1.1);
gl.glColor4d(color.r, color.g, color.b, color.a);
// glu.gluSphere(quadratic, SPHERE_RADIUS * 3, SPHERE_SLICES, SPHERE_STACKS);
glu.gluCylinder(quadratic, SPHERE_RADIUS, SPHERE_RADIUS, 2*SPHERE_RADIUS, 4, 1);
}
gl.glPopMatrix();
gl.glDisable(GL.GL_DEPTH_TEST);
{
gl.glColor3d(0, 0, 0);
gl.glRasterPos3d(position.x, position.y, position.z);
glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, mapEvent.getMessage());
gl.glColor3d(1, 1, 1);
}
gl.glEnable(GL.GL_DEPTH_TEST);
// gl.glDisable(GL.GL_BLEND);
}
示例5: 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();
}
示例6: renderRotation
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Draw rotation arrow
* @param gl
* @param color What color should arrow be
* @param center Where is center of arrow
* @param rotation In what direction does arrow points
*/
private void renderRotation(GL gl, GlColor color, Location center, Rotation rotation) {
gl.glPushMatrix();
{
gl.glTranslated(center.x, center.y, center.z);
Location endOfArrow = rotation.toLocation().getNormalized().scale(SPHERE_RADIUS * 2.5);
gl.glBegin(GL.GL_LINES);
gl.glColor4d(color.r, color.g, color.b, color.a);
gl.glVertex3d(0, 0, 0);
gl.glVertex3d(endOfArrow.x, endOfArrow.y, endOfArrow.z);
gl.glEnd();
gl.glTranslated(endOfArrow.x, endOfArrow.y, endOfArrow.z);
// XXX: This works only in 2D, not 3D, because I am not in the mood
// to figure out direction of Roll, Yaw and Pitch as well as order of
// transformations. And rotation.toLocation() returns 2D coords anyway.
double yaw = rotation.getYaw() / 32767 * 180; // left right, aka around z
double roll = rotation.getRoll() / 32767 * 180; // clockwise/counter? around x
double pitch = rotation.getPitch() / 32767 * 180; // up and down, around y
/*
gl.glRotated(pitch, );
gl.glRotated(yaw, );
gl.glRotated(roll, );
*/
// return res.mul(pitch).mul(yaw).mul(roll);
if (logger.isLoggable(Level.FINE)) logger.fine(" Rotation: Yaw " + yaw + " roll " + roll + " pitch " + pitch);
//gl.glRotated(roll, 1,0,0);
gl.glRotated(yaw, 0, 0, 1);
//gl.glRotated(pitch, 0,1,0);
gl.glRotated(90, 0, 1, 0);
glut.glutSolidCone(20, 40, 16, 16);
}
gl.glPopMatrix();
}
示例7: display
import javax.media.opengl.GL; //導入方法依賴的package包/類
@Override
public void display(GLAutoDrawable glAutoDrawable) {
// System.out.println("MER.display " + time + " " + this.mapEvent.getMessage());
GL gl = glAutoDrawable.getGL();
gl.glPushMatrix();
gl.glTranslated(location.x, location.y, location.z + 60 * 1.1);
// display small
// gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA);
GlColor color = new GlColor(entity.getColor(), 0.5);
gl.glColor4d(color.r, color.g, color.b, color.a);
GLUquadric quadratic = glu.gluNewQuadric();
glu.gluSphere(quadratic, SPHERE_RADIUS, SPHERE_SLICES, SPHERE_STACKS);
gl.glPopMatrix();
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glColor3d(1,1,1);
gl.glRasterPos3d(location.x, location.y, location.z);
glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, this.mapEvent.getMessage());
gl.glEnable(GL.GL_DEPTH_TEST);
// gl.glDisable(GL.GL_BLEND);
}