本文整理匯總了Java中javax.media.opengl.GL2.glPopAttrib方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glPopAttrib方法的具體用法?Java GL2.glPopAttrib怎麽用?Java GL2.glPopAttrib使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glPopAttrib方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void draw(DrawContext dc)
{
this.assembleTiles(dc); // Determine the tiles to draw.
if (this.currentTiles.size() >= 1)
{
// Indicate that this layer rendered something this frame.
this.setValue(AVKey.FRAME_TIMESTAMP, dc.getFrameTimeStamp());
if (this.getScreenCredit() != null)
{
dc.addScreenCredit(this.getScreenCredit());
}
TextureTile[] sortedTiles = new TextureTile[this.currentTiles.size()];
sortedTiles = this.currentTiles.toArray(sortedTiles);
Arrays.sort(sortedTiles, levelComparer);
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
if (this.isUseTransparentTextures() || this.getOpacity() < 1)
{
gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT | GL2.GL_CURRENT_BIT);
this.setBlendingFunction(dc);
}
else
{
gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT);
}
gl.glPolygonMode(GL.GL_FRONT, GL2.GL_FILL);
gl.glEnable(GL.GL_CULL_FACE);
gl.glCullFace(GL.GL_BACK);
dc.setPerFrameStatistic(PerformanceStatistic.IMAGE_TILE_COUNT, this.tileCountName,
this.currentTiles.size());
dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles);
gl.glPopAttrib();
if (this.drawTileIDs)
this.drawTileIDs(dc, this.currentTiles);
if (this.drawBoundingVolumes)
this.drawBoundingVolumes(dc, this.currentTiles);
// Check texture expiration. Memory-cached textures are checked for expiration only when an explicit,
// non-zero expiry time has been set for the layer. If none has been set, the expiry times of the layer's
// individual levels are used, but only for images in the local file cache, not textures in memory. This is
// to avoid incurring the overhead of checking expiration of in-memory textures, a very rarely used feature.
if (this.getExpiryTime() > 0 && this.getExpiryTime() <= System.currentTimeMillis())
this.checkTextureExpiration(dc, this.currentTiles);
this.currentTiles.clear();
}
this.sendRequests();
this.requestQ.clear();
}
示例8: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void draw(DrawContext dc)
{
this.referencePoint = this.computeReferencePoint(dc);
Position pos = dc.getView().getEyePosition();
this.centerPoint = new LatLon(pos.getLatitude(), pos.getLongitude());
this.assembleTiles(dc); // Determine the tiles to draw.
if (this.currentTiles.size() >= 1)
{
TextureTile[] sortedTiles = new TextureTile[this.currentTiles.size()];
sortedTiles = this.currentTiles.toArray(sortedTiles);
Arrays.sort(sortedTiles, levelComparer);
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
if (this.isUseTransparentTextures() || this.getOpacity() < 1)
{
gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT | GL2.GL_CURRENT_BIT);
gl.glColor4d(1d, 1d, 1d, this.getOpacity());
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
}
else
{
gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT);
}
gl.glPolygonMode(GL.GL_FRONT, GL2.GL_FILL);
gl.glEnable(GL.GL_CULL_FACE);
gl.glCullFace(GL.GL_BACK);
dc.setPerFrameStatistic(PerformanceStatistic.IMAGE_TILE_COUNT, this.tileCountName,
this.currentTiles.size());
dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles);
gl.glPopAttrib();
if (this.drawTileIDs)
this.drawTileIDs(dc, this.currentTiles);
if (this.drawBoundingVolumes)
this.drawBoundingVolumes(dc, this.currentTiles);
this.currentTiles.clear();
}
this.sendRequests();
this.requestQ.clear();
}
示例9: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0) {
return;
}
assert (initialized_context_ != null);
final float[] vertex_data = {
//tu, tv, x, y, z
0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f };
FloatBuffer vertices = FloatBuffer.wrap(vertex_data);
gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);
gl2.glMatrixMode(gl2.GL_MODELVIEW);
gl2.glLoadIdentity();
// Match GL units to screen coordinates.
gl2.glViewport(0, 0, view_width_, view_height_);
gl2.glMatrixMode(gl2.GL_PROJECTION);
gl2.glLoadIdentity();
// Draw the background gradient.
gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
gl2.glBegin(gl2.GL_QUADS);
gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f); // red
gl2.glVertex2f(-1.0f, -1.0f);
gl2.glVertex2f(1.0f, -1.0f);
gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f); // blue
gl2.glVertex2f(1.0f, 1.0f);
gl2.glVertex2f(-1.0f, 1.0f);
gl2.glEnd();
gl2.glPopAttrib();
// Rotate the view based on the mouse spin.
if (spin_x_ != 0) {
gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
}
if (spin_y_ != 0) {
gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);
}
if (transparent_) {
// Alpha blending style. Texture values have premultiplied alpha.
gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);
// Enable alpha blending.
gl2.glEnable(gl2.GL_BLEND);
}
// Enable 2D textures.
gl2.glEnable(gl2.GL_TEXTURE_2D);
// Draw the facets with the texture.
assert (texture_id_[0] != 0);
gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);
// Disable 2D textures.
gl2.glDisable(gl2.GL_TEXTURE_2D);
if (transparent_) {
// Disable alpha blending.
gl2.glDisable(gl2.GL_BLEND);
}
}
示例10: drawFaceShape
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawFaceShape(List<Vector3f> fps, 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.glDisable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_NORMALIZE);
//celo nos
drawCylinder(fps.get(4), fps.get(8), gl, glut);
drawCylinder(fps.get(8), fps.get(9), gl, glut);
drawCylinder(fps.get(4), fps.get(10), gl, glut);
//brada
drawCylinder(fps.get(11), fps.get(12), gl, glut);
drawCylinder(fps.get(12), fps.get(13), gl, glut);
//usta
drawCylinder(fps.get(6), fps.get(5), gl, glut);
drawCylinder(fps.get(5), fps.get(7), gl, glut);
drawCylinder(fps.get(6), fps.get(10), gl, glut);
drawCylinder(fps.get(10), fps.get(7), gl, glut);
drawCylinder(fps.get(6), fps.get(11), gl, glut);
drawCylinder(fps.get(11), fps.get(7), gl, glut);
drawCylinder(fps.get(10), fps.get(5), gl, glut);
drawCylinder(fps.get(5), fps.get(11), gl, glut);
//oci -- zanedbava nespecifikovane body v strede oka
/*drawCylinder(fps.get(1), fps.get(14), gl, glut);
drawCylinder(fps.get(14), fps.get(3), gl, glut);*/
drawCylinder(fps.get(1), fps.get(3), gl, glut);
//drawCylinder(fps.get(3), fps.get(8), gl, glut);
/*drawCylinder(fps.get(0), fps.get(15), gl, glut);
drawCylinder(fps.get(15), fps.get(2), gl, glut);*/
drawCylinder(fps.get(0), fps.get(2), gl, glut);
//drawCylinder(fps.get(2), fps.get(8), gl, glut);
gl.glEnable(GL2.GL_TEXTURE_2D);
gl.glDisable(GL2.GL_LIGHTING);
gl.glPopAttrib();
}
示例11: paintNormals
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void paintNormals(GL2 gl) {
info.c.assignGl(gl);
Faces faces = info.getModel().getFaces();
List<Vector3f> mesh = info.getModel().getVerts();
List<Vector3f> normals = info.getModel().getNormals();
List<Float> distanceCopy = new ArrayList<>(info.getDistance().size());
for (Float f : info.getDistance()) {
if (!info.isUseRelative()) {
distanceCopy.add(Math.abs(f));
} else {
distanceCopy.add(f);
}
}
float[] color = new float[3];
color[0] = 0.8667f;
color[1] = 0.7176f;
color[2] = 0.6275f;
gl.glPushAttrib(GL_ALL_ATTRIB_BITS);
Vector3f normal;
gl.glDisable(GL2.GL_TEXTURE_2D);
gl.glEnable(GL2.GL_LIGHTING);
for (int i = 0; i < faces.getNumFaces(); i++) {
int[] facesInd = faces.getFaceVertIdxs(i);
int[] faceNormIndex = faces.getFaceNormalIdxs(i);
gl.glBegin(GL.GL_TRIANGLES);
for (int f = 0; f < facesInd.length; f++) {
if (faceNormIndex[f] != 0) { // if there are normals, render them
normal = normals.get(faceNormIndex[f] - 1);
gl.glNormal3d(normal.getX(), normal.getY(), normal.getZ());
}
float[] ambient = {0.1f, 0.1f, 0.1f, 0.0f};
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, ambient, 0);
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);
float[] colorKs = {0, 0, 0, 1.0f};
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, colorKs, 0);
gl.glVertex3f(mesh.get(facesInd[f] - 1).getX(), mesh.get(facesInd[f] - 1).getY(), mesh.get(facesInd[f] - 1).getZ());
}
gl.glEnd();
}
if (info.getRecompute()) {
recomputeNormals(gl, info, distanceCopy);
info.setRecompute(false);
}
gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
info.c.draw();
gl.glDisableClientState(gl.GL_VERTEX_ARRAY);
gl.glPopAttrib();
}
示例12: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0)
return;
assert(initialized_context_ != null);
final float[] vertex_data = {
//tu, tv, x, y, z
0.0f, 1.0f, -1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 1.0f, -1.0f, 0.0f,
1.0f, 0.0f, 1.0f, 1.0f, 0.0f,
0.0f, 0.0f, -1.0f, 1.0f, 0.0f
};
FloatBuffer vertices = FloatBuffer.wrap(vertex_data);
gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);
gl2.glMatrixMode(gl2.GL_MODELVIEW);
gl2.glLoadIdentity();
// Match GL units to screen coordinates.
gl2.glViewport(0, 0, view_width_, view_height_);
gl2.glMatrixMode(gl2.GL_PROJECTION);
gl2.glLoadIdentity();
gl2.glOrtho(0, 0, view_width_, view_height_, 0.1, 100.0);
// Draw the background gradient.
gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
gl2.glBegin(gl2.GL_QUADS);
gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f); // red
gl2.glVertex2f(-1.0f, -1.0f);
gl2.glVertex2f(1.0f, -1.0f);
gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f); // blue
gl2.glVertex2f(1.0f, 1.0f);
gl2.glVertex2f(-1.0f, 1.0f);
gl2.glEnd();
gl2.glPopAttrib();
// Rotate the view based on the mouse spin.
if (spin_x_ != 0)
gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
if (spin_y_ != 0)
gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);
if (transparent_) {
// Alpha blending style. Texture values have premultiplied alpha.
gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);
// Enable alpha blending.
gl2.glEnable(gl2.GL_BLEND);
}
// Enable 2D textures.
gl2.glEnable(gl2.GL_TEXTURE_2D);
// Draw the facets with the texture.
assert(texture_id_[0] != 0);
gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);
// Disable 2D textures.
gl2.glDisable(gl2.GL_TEXTURE_2D);
if (transparent_) {
// Disable alpha blending.
gl2.glDisable(gl2.GL_BLEND);
}
}