本文整理匯總了Java中javax.media.opengl.GL.glRasterPos3d方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glRasterPos3d方法的具體用法?Java GL.glRasterPos3d怎麽用?Java GL.glRasterPos3d使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glRasterPos3d方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
示例3: renderInfo
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Render info about agent (in most cases event messages) and its name.
* TODO: Ugly code, refactor
* @param gl
* @param color What color should be used to render info.
* @param location position of agent
*/
private void renderInfo(GL gl, GlColor color, Location location) {
// get text
List<String> infos = new ArrayList<String>(agent.getAssociatedInfo());
infos.add(0, '*' + agent.getName() + '*');
Location topHead = new Location(location);
topHead = new Location(topHead.x, topHead.y, topHead.z + 2 * SPHERE_RADIUS * 1.1);
Location top2d = GLTools.getScreenCoordinates(gl, glu, topHead, null);
int lineGap = 12;
int font = GLUT.BITMAP_HELVETICA_10;
int maxWidth = 0;
for (String line : infos) {
int lineWidth = glut.glutBitmapLength(font, line);
if (lineWidth > maxWidth) {
maxWidth = lineWidth;
}
}
// update starting position
top2d = new Location(top2d.x - maxWidth / 2, top2d.y + (infos.size() - 1) * lineGap);
GlColor textColor = color.getMixedWith(new GlColor(0, 0, 0), 80);
gl.glColor3d(textColor.r, textColor.g, textColor.b);
for (int i = 0; i < infos.size(); i++) {
String text = infos.get(i);
if (i == 0) {
gl.glColor3d(color.r, color.g, color.b);
} else {
gl.glColor3d(textColor.r, textColor.g, textColor.b);
// gl.glColor3d(0, 0, 0);
}
Location textPos = GLTools.getWorldCoordinates(gl, glu, top2d, null);
gl.glRasterPos3d(textPos.x, textPos.y, textPos.z);
glut.glutBitmapString(font, text);
top2d = top2d.setY(top2d.y - lineGap);
}
}
示例4: 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);
}