本文整理匯總了Java中javax.media.opengl.GL2.glEnable方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glEnable方法的具體用法?Java GL2.glEnable怎麽用?Java GL2.glEnable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glEnable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void init(GLAutoDrawable drawable) {
System.out.println("--init--");
GL2 gl = drawable.getGL().getGL2();
glu = new GLU();
System.out.println("INIT GL IS: " + gl.getClass().getName());
if (!bDoNurbs) {
gl.glMap2f(GL2.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, ctlarray, 0);
}
gl.glEnable(GL2.GL_MAP2_VERTEX_3);
gl.glEnable(GL2.GL_AUTO_NORMAL);
gl.glMapGrid2f(20, 0.0f, 1.0f, 20, 0.0f, 1.0f);
setupLighting(drawable, gl);
float fovy=40.f;
float aspect=1.f;
float znear=1.f;
float zfar=20f;
glu.gluPerspective(fovy, aspect, znear, zfar);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(cameraLoc.x, cameraLoc.y, cameraLoc.z,
lookAtPt.x, lookAtPt.y, lookAtPt.z,
cameraUpDirection.x, cameraUpDirection.y, cameraUpDirection.z);
}
示例2: drawLine
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void drawLine(DrawContext dc, Vec4 screenPoint, Vec4 projectedPoint, DetailedOrderedIcon uIcon) {
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
gl.glLoadIdentity();
double opacity = uIcon.getOpacity();
opacity = Math.min(opacity, .5f);
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glColor4d(.2,.2,.2, opacity);
gl.glBegin(GL.GL_LINES);
gl.glVertex2d(screenPoint.x, screenPoint.y);
gl.glVertex2d(projectedPoint.x, projectedPoint.y);
gl.glEnd();
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glColor4f(1,1,1,1);
}
示例3: useCamera
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGl
*/
public void useCamera(final GL2 openGl) {
if (resetProjection) {
resetProjection = false;
setProjection(openGl);
}
openGl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, new float[]{1000.f,1000.f,1000.f}, 0);
openGl.glEnable(GL2.GL_LIGHT0);
openGl.glMatrixMode(GL2.GL_MODELVIEW);
openGl.glLoadIdentity();
position.translateBy(openGl);
product.rotateAround(openGl);
upVector.rotateAround(openGl);
}
示例4: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGl
*/
public final synchronized void draw(final GL2 openGl) {
if (points == null || points.size() == 0) {
return;
}
AbstractDoubleCordinateBuffer.bindIfExists(verticesBuf, openGl);
openGl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
openGl.glPolygonOffset(1.0f, 1.0f);
AbstractDoubleCordinateBuffer.bindIfExists(lineColorBuf, openGl);
indicesBuf.drawLine(openGl, GL2.GL_LINE_LOOP, GL2.GL_FRONT_AND_BACK);
AbstractDoubleCordinateBuffer.unBindExists(lineColorBuf, openGl);
AbstractDoubleCordinateBuffer.bindIfExists(pointColorBuf, openGl);
float[] f = new float[1];
openGl.glGetFloatv(GL2.GL_POINT_SIZE, f, 0);
openGl.glPointSize(3.0f);
indicesBuf.drawLine(openGl, GL2.GL_POINTS, GL2.GL_FRONT);
openGl.glPointSize(f[0]);
AbstractDoubleCordinateBuffer.bindIfExists(pointColorBuf, openGl);
AbstractDoubleCordinateBuffer.unBindExists(verticesBuf, openGl);
}
示例5: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public final synchronized void draw(final GL2 openGl) {
AbstractDoubleCordinateBuffer.bindIfExists(verticesBuf, openGl);
AbstractDoubleCordinateBuffer.bindIfExists(normalsBuf, openGl);
AbstractDoubleCordinateBuffer.bindIfExists(faceColorBuf, openGl);
openGl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
openGl.glPolygonOffset(1.0f, 1.0f);
indicesBuf.draw(openGl, GL2.GL_FILL, GL2.GL_FRONT);
AbstractDoubleCordinateBuffer.unBindExists(faceColorBuf, openGl);
AbstractDoubleCordinateBuffer.bindIfExists(lineColorBuf, openGl);
indicesBuf.draw(openGl, GL2.GL_LINE, GL2.GL_FRONT_AND_BACK);
indicesBuf.draw(openGl, GL2.GL_POINT, GL2.GL_FRONT);
AbstractDoubleCordinateBuffer.unBindExists(lineColorBuf, openGl);
AbstractDoubleCordinateBuffer.unBindExists(verticesBuf, openGl);
AbstractDoubleCordinateBuffer.unBindExists(normalsBuf, openGl);
}
示例6: 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;
}
示例7: 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();
}
示例8: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Draws the terrain.
*
* @param gl The instance of GL2 responsible for drawing the body.
* @param glut An instance of GLUT that can be optionally used to assist
* in drawing.
* @param camPos The position of the camera in world coordinates.
* @param lighting The Lighting instance responsible for calculating the
* lighting in this scene. Can be used to set the colours of
* bodies before drawing them.
*/
public void draw(GL2 gl, GLUT glut, Vector camPos, Lighting lighting) {
gl.glPushMatrix();
{
gl.glTranslated(TERRAIN_LEVEL.x(), TERRAIN_LEVEL.y(), TERRAIN_LEVEL.z());
gl.glEnable(GL_CULL_FACE);
lighting.setMaterial(gl, Material.DIRT, true);
terrainBody.draw(gl);
lighting.setMaterial(gl, Material.WATER);
waterBody.draw(gl);
gl.glDisable(GL_CULL_FACE);
final Vector camPosRelativeToTerrain = camPos.subtract(TERRAIN_LEVEL);
trees.stream().forEach((tree) -> tree.draw(gl, camPosRelativeToTerrain, lighting));
}
gl.glPopMatrix();
}
示例9: setBlending
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private Map<String, Object> setBlending() {
Map<String, Object> result = new HashMap<>();
GL2 gl = drawable.getGL().getGL2();
IntBuffer equation = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_EQUATION, equation);
result.put("equation", equation);
IntBuffer sourceFactor = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_SRC, sourceFactor);
result.put("sourceFactor", sourceFactor);
IntBuffer destinationFactor = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_DST, destinationFactor);
result.put("destinationFactor", destinationFactor);
boolean enabled = gl.glIsEnabled(GL_BLEND);
result.put("enabled", enabled);
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE);
gl.glBlendEquation(GL_FUNC_ADD);
gl.glEnable(GL_BLEND);
return result;
}
示例10: setLights
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void setLights(GL2 gl) {
// prepare light parameters
float SHINE_ALL_DIRECTIONS = 1;
float[] lightPos = { -40, 0, 20, SHINE_ALL_DIRECTIONS };
// 'weak' light which is everywhere
float[] lightColorAmbient = { 0.2f, 0.2f, 0.2f, 1f };
// 'strong' light from a particular spot which creates a 3d-effect
float[] lightColorSpecular = { 0.8f, 0.8f, 0.8f, 1f };
// set light parameters
gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_POSITION, lightPos, 0);
gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_AMBIENT, lightColorAmbient, 0);
gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_SPECULAR, lightColorSpecular, 0);
// enable lights
gl.glEnable(GL2.GL_LIGHT1);
gl.glEnable(GL2.GL_LIGHTING);
}
示例11: init
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void init( final GLAutoDrawable drawable )
{
final GL2 gl = drawable.getGL().getGL2();
gl.setSwapInterval( 1 );
gl.glEnable( GL.GL_DEPTH_TEST );
gl.glDepthFunc( GL.GL_LEQUAL );
gl.glShadeModel( GLLightingFunc.GL_SMOOTH );
gl.glHint( GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST );
// gl.glEnable( GL.GL_BLEND );
// gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA );
gl.glEnable( GL2GL3.GL_POLYGON_SMOOTH );
final float w = this.window.getDrawableSurface().getWidth();
final float h = this.window.getDrawableSurface().getHeight();
// Set the projection matrix (only done once - just here)
gl.glMatrixMode( GLMatrixFunc.GL_PROJECTION );
gl.glLoadIdentity();
this.glu.gluPerspective( 50, (w / h), 0.01, 10 );
// Set the initial model matrix
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
gl.glLoadIdentity();
gl.glViewport( 0, 0, (int) w, (int) h ); /* viewport size in pixels */
}
示例12: init
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void init(GLAutoDrawable drawable)
{
GL2 gl = drawable.getGL().getGL2();
gl.glEnable(GL2.GL_CULL_FACE);
gl.glEnable(GL2.GL_DEPTH_TEST);
gl.glEnable(GL2.GL_NORMALIZE);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
示例13: renderPatchBoundary
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void renderPatchBoundary(DrawContext dc, RectTile tile)
{
// GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
OGLStackHandler ogsh = new OGLStackHandler();
ogsh.pushAttrib(gl, GL2.GL_ENABLE_BIT | GL2.GL_CURRENT_BIT | GL2.GL_POLYGON_BIT);
try
{
gl.glDisable(GL.GL_BLEND);
// Don't perform depth clipping but turn on backface culling
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glEnable(GL.GL_CULL_FACE);
gl.glCullFace(GL.GL_BACK);
gl.glPolygonMode(GL.GL_FRONT, GL2.GL_LINE);
Vec4[] corners = tile.sector.computeCornerPoints(dc.getGlobe(), dc.getVerticalExaggeration());
gl.glColor4d(1d, 0, 0, 1d);
gl.glBegin(javax.media.opengl.GL2.GL_QUADS);
gl.glVertex3d(corners[0].x, corners[0].y, corners[0].z);
gl.glVertex3d(corners[1].x, corners[1].y, corners[1].z);
gl.glVertex3d(corners[2].x, corners[2].y, corners[2].z);
gl.glVertex3d(corners[3].x, corners[3].y, corners[3].z);
gl.glEnd();
}
finally
{
ogsh.pop(gl);
}
}
示例14: beginDrawLasso
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void beginDrawLasso(DrawContext dc) {
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
int attributeMask =
GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
| GL2.GL_TRANSFORM_BIT // for modelview and perspective
| GL2.GL_VIEWPORT_BIT // for depth range
| GL2.GL_CURRENT_BIT // for current color
| GL2.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
| GL2.GL_DEPTH_BUFFER_BIT // for depth func
| GL2.GL_ENABLE_BIT; // for enable/disable changes
gl.glPushAttrib(attributeMask);
// Apply the depth buffer but don't change it.
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDepthFunc(GL.GL_ALWAYS);
gl.glDepthMask(false);
// Load a parallel projection with dimensions (viewportWidth, viewportHeight)
int[] viewport = new int[4];
gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glOrtho(0d, viewport[2], 0d, viewport[3], -1d, 1d);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
}
示例15: setBlendingFunction
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void setBlendingFunction(DrawContext dc)
{
// Set up a premultiplied-alpha blending function. Any texture read by JOGL will have alpha-premultiplied color
// components, as will any DDS file created by World Wind or the World Wind WMS. We'll also set up the base
// color as a premultiplied color, so that any incoming premultiplied color will be properly combined with the
// base color.
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
double alpha = this.getOpacity();
gl.glColor4d(alpha, alpha, alpha, alpha);
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
}