本文整理匯總了Java中javax.media.opengl.GL2.glPopMatrix方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glPopMatrix方法的具體用法?Java GL2.glPopMatrix怎麽用?Java GL2.glPopMatrix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glPopMatrix方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: end
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void end(DrawContext dc)
{
if (dc.isPickingMode())
pickSupport.endPicking(dc);
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPopMatrix();
// gl.glDisable(GL.GL_LIGHT1);
// gl.glEnable(GL.GL_LIGHT0);
// gl.glDisable(GL.GL_LIGHTING);
// gl.glDisable(GL.GL_NORMALIZE);
gl.glPopAttrib();
}
示例2: drawVertex
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private Vector3f drawVertex(Vector3f vert, double size, float[] color, GL2 gl, GLUT glut) {
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);
gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
gl.glDisable(GL2.GL_TEXTURE_2D);
gl.glEnable(GL2.GL_LIGHTING);
gl.glPushMatrix();
gl.glTranslatef(vert.getX(), vert.getY(), vert.getZ());
glut.glutSolidSphere(size, 20, 20);
gl.glPopMatrix();
gl.glEnable(GL2.GL_TEXTURE_2D);
gl.glDisable(GL2.GL_LIGHTING);
gl.glPopAttrib();
return vert;
}
示例3: drawCylinder
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawCylinder(Vector3f from, Vector3f to, GL2 gl, GLUT glut) {
Vector3f zAxis = new Vector3f(0, 0, 1);
Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
float length = vector.length();
vector.normalize();
float angle = zAxis.angle(vector);
Vector3f axis = new Vector3f();
axis.cross(zAxis, vector);
float convert = (float) (180f / Math.PI);
gl.glPushMatrix();
gl.glTranslatef(from.x, from.y, from.z);
gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
glut.glutSolidCylinder(info.getPointSize() / 4.5, length - info.getPointSize(), 20, 20);
gl.glPopMatrix();
}
示例4: drawCylinder
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawCylinder(GLUT glut, GL2 gl, Vector3f from, Vector3f to) {
Vector3f zAxis = new Vector3f(0, 0, 1);
Vector3f vector1 = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
float length = vector1.length();
vector1.normalize();
float angle = zAxis.angle(vector1);
Vector3f axis = new Vector3f();
axis.cross(zAxis, vector1);
float convert = (float) (180f / Math.PI);
gl.glPushMatrix();
gl.glTranslatef(from.x, from.y, from.z);
gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
glut.glutSolidCylinder(0.5f, length - 0.5f, 20, 5);
//glut.glutSolidCylinder(0.5f, 10, 20, 5);
gl.glPopMatrix();
}
示例5: drawWithoutTextures
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param gl
* @param dropFaces faces to be hidden when rendering model.
*/
public void drawWithoutTextures(GL2 gl, ArrayList<Integer> dropFaces) {
gl.glPushMatrix();
gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
for (int i = 0; i < faces.getNumFaces(); i++) {
gl.glDisable(GL2.GL_TEXTURE_2D);
gl.glEnable(GL2.GL_LIGHTING);
faces.renderFace(i, flipTexCoords, gl);
gl.glEnable(GL2.GL_TEXTURE_2D);
gl.glDisable(GL2.GL_LIGHTING);
}
gl.glPopAttrib();
gl.glPopMatrix();
}
示例6: 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;
}
}
示例7: endDrawLasso
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void endDrawLasso(DrawContext dc) {
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPopMatrix();
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPopMatrix();
gl.glPopAttrib();
}
示例8: drawArrow
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawArrow(Vector3f from, Vector3f to, float[] color, GL2 gl, GLUT glut) {
Vector3f zAxis = new Vector3f(0, 0, 1);
Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
float length = vector.length();
vector.normalize();
float angle = zAxis.angle(vector);
Vector3f axis = new Vector3f();
axis.cross(zAxis, vector);
float convert = (float) (180f / Math.PI);
gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
gl.glDisable(GL2.GL_TEXTURE_2D);
gl.glEnable(GL2.GL_LIGHTING);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);
gl.glPushMatrix();
gl.glTranslatef(from.x, from.y, from.z);
gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
glut.glutSolidCylinder(info.getPointSize() / 3, length - info.getPointSize(), 20, 20);
gl.glTranslatef(0, 0, length - info.getPointSize());
glut.glutSolidCone(info.getPointSize(), info.getPointSize(), 20, 20);
gl.glPopMatrix();
gl.glEnable(GL2.GL_TEXTURE_2D);
gl.glDisable(GL2.GL_LIGHTING);
gl.glPopAttrib();
}
示例9: drawForShaders
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void drawForShaders(GL2 gl, ArrayList<VertexInfo> info, int shaderVertices, int shaderNormals, int shaderPrincipal, int shaderSecondary) {
gl.glPushMatrix();
for (int i = 0; i < faces.getNumFaces(); i++) {
faces.renderFace(i, gl, info, shaderVertices, shaderNormals, shaderPrincipal, shaderSecondary);
}
gl.glPopMatrix();
}
示例10: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param gl
*/
public void draw(GL2 gl) {
gl.glPushMatrix();
gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_TEXTURE_2D);
if (materials != null) {
materials.clearUsedMaterials();
}
// render the model face-by-face
String faceMat;
for (int i = 0; i < faces.getNumFaces(); i++) {
faceMat = faces.findMaterial(i); // get material used by face i
if (faceMat != null && materials != null) {
flipTexCoords = materials.renderWithMaterial(faceMat, gl);
} // render using that material
faces.renderFace(i, flipTexCoords, gl); // draw face i
}
gl.glDisable(GL2.GL_TEXTURE_2D);
gl.glEnable(GL2.GL_LIGHTING);
gl.glPopAttrib();
gl.glPopMatrix();
}
示例11: drawParticles
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawParticles(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
float c = MathUtils.cos(theta);
float s = MathUtils.sin(theta);
float x = radius;
float y = 0;
for (int i = 0; i < count; i++) {
Vec2 center = centers[i];
float cx = center.x;
float cy = center.y;
gl.glBegin(GL2.GL_TRIANGLE_FAN);
if (colors == null) {
gl.glColor4f(1, 1, 1, .4f);
} else {
ParticleColor color = colors[i];
gl.glColor4b(color.r, color.g, color.b, color.a);
}
for (int j = 0; j < NUM_CIRCLE_POINTS; j++) {
gl.glVertex3f(x + cx, y + cy, 0);
float temp = x;
x = c * x - s * y;
y = s * temp + c * y;
}
gl.glEnd();
}
gl.glPopMatrix();
}
示例12: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void draw(GL2 gl, GLUT glut, boolean stickFigure, Animation animation) {
gl.glPushMatrix();
drawHips(gl, glut, stickFigure, animation);
drawKnees(gl, glut, stickFigure, animation);
drawAnkles(gl, glut, stickFigure, animation);
gl.glPopMatrix();
}
示例13: drawPolygon
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glColor4f(color.x, color.y, color.z, 1f);
for (int i = 0; i < vertexCount; i++) {
Vec2 v = vertices[i];
System.err.println("polygon vertex: "+v.x +", "+v.y);
gl.glVertex2f(v.x, v.y);
}
gl.glEnd();
gl.glPopMatrix();
}
示例14: drawAxis
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawAxis( final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
gl.glLineWidth( (float)config.getRenderingConfig().getThickness() );
gl.glColor3f( config.getRenderingConfig().getColour()[0],
config.getRenderingConfig().getColour()[1],
config.getRenderingConfig().getColour()[2] );
final float n1 = this.calculatePosition( config.getMinValue() ).floatValue();
final float n2 = this.calculatePosition( config.getMaxValue() ).floatValue();
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( n1, zero, zero );
gl.glVertex3f( n2, zero, zero );
}
gl.glEnd();
gl.glPopMatrix();
}
示例15: drawSurface
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawSurface(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glPushMatrix();
gl.glEvalMesh2(GL2.GL_FILL, 0, 20, 0, 20);
gl.glPopMatrix();
gl.glFlush();
}