本文整理匯總了Java中javax.media.opengl.GL.glEnable方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glEnable方法的具體用法?Java GL.glEnable怎麽用?Java GL.glEnable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glEnable方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderWaypoints
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Render all waypoints (the circles in the map), data generated in createWaypointsList
* @param gl
* @param triangles
*/
private synchronized void renderWaypoints(GL gl, List<BlendTriangle> triangles) {
GlColor color = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getDegaultARGB())));
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glShadeModel(GL.GL_SMOOTH);
gl.glBegin(GL.GL_TRIANGLES);
for (BlendTriangle triangle : triangles) {
for (BlendVertex v : triangle.getVerts()) {
// take color according to width
gl.glColor4d(color.r, color.g, color.b, color.a);
gl.glVertex3d(v.getLocation().x, v.getLocation().y, v.getLocation().z + 0.1);
}
}
gl.glEnd();
}
示例2: createTexture
import javax.media.opengl.GL; //導入方法依賴的package包/類
public static JOGLTexture createTexture(GL gl, BufferedImage awtImage)
{
int textureID = createTextureID(gl);
gl.glEnable(GL.GL_TEXTURE_2D);
// convert that image into a byte buffer of texture data
ByteBuffer textureBuffer = ImageConverter.convertPowerOf2(awtImage);
gl.glBindTexture(GL.GL_TEXTURE_2D, textureID);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
int texWidth = ImageConverter.powerOf2(awtImage.getWidth());
int texHeight = ImageConverter.powerOf2(awtImage.getHeight());
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA,
texWidth, texHeight, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, textureBuffer);
gl.glDisable(GL.GL_TEXTURE_2D);
return new JOGLTexture(gl, textureID, awtImage.getWidth(), awtImage.getHeight(), texWidth, texHeight);
}
示例3: mesh
import javax.media.opengl.GL; //導入方法依賴的package包/類
public static void mesh(GL gl, double xstart, double xend, double ystart, double yend, int xsteps, int ysteps){
double grid[] = new double[] {xstart, ystart, 0.0, xstart, yend, 0.0, xend, ystart, 0.0, xend, yend, 0.0};
gl.glEnable(GL.GL_MAP2_VERTEX_3);
gl.glLineWidth(1.0f);
gl.glMap2d(GL.GL_MAP2_VERTEX_3,
0.0, 1.0, /* U ranges 0..1 */
3, /* U stride, 3 floats per coord */
2, /* U is 2nd order, ie. linear */
0.0, 1.0, /* V ranges 0..1 */
2 * 3, /* V stride, row is 2 coords, 3 floats per coord */
2, /* V is 2nd order, ie linear */
grid,0); /* control points */
gl.glMapGrid2d(
ysteps, 0.0, 1.0,
xsteps, 0.0, 1.0);
gl.glEvalMesh2(GL.GL_LINE, 0, ysteps, 0, xsteps);
}
示例4: renderPaths
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Render triangles stored in pathTriangles with info from settings
* @param gl
*/
private synchronized void renderPaths(GL gl, List<PathTriangle> triangles) {
// Get colors from preferences
GlColor lowColor = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.LOW_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.LOW_COLOR_KEY.getDegaultARGB())));
GlColor highColor = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.HIGH_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.HIGH_COLOR_KEY.getDegaultARGB())));
boolean includeFlagBehavior = NbPreferences.forModule(TimelinePanel.class).getBoolean(TimelinePanel.INCLUDE_FLAG_KEY, true);
double deltaZ = this.map.getBox().getDeltaZ();
double displaceZ = this.map.getBox().minZ;
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glShadeModel(GL.GL_SMOOTH);
gl.glBegin(GL.GL_TRIANGLES);
for (PathTriangle triangle : triangles) {
boolean render = false;
if (includeFlagBehavior) {
render = includeCanRenderPathFlag(triangle.getFlags());
} else {
render = excludeCanRenderFlag(triangle.getFlags());
}
if (render) {
for (BlendVertex v : triangle.getVerts()) {
Location vertexLoc = v.getLocation();
GlColor color = lowColor.getMixedWith(highColor, (vertexLoc.z - displaceZ) / deltaZ);
gl.glColor4d(color.r, color.g, color.b, color.a);
gl.glVertex3d(vertexLoc.x, vertexLoc.y, vertexLoc.z);
}
}
}
gl.glEnd();
}
示例5: init
import javax.media.opengl.GL; //導入方法依賴的package包/類
@Override
public synchronized void init(GLAutoDrawable glDrawable) {
GL gl = glDrawable.getGL();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glClearDepth(1.0);
gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
/* float[] lightAmbient = new float[]{0.5f, 0.5f, 0.5f, 1.0f};
float[] lightDiffuse = new float[]{1.0f, 1.0f, 1.0f, 1.0f};
float[] lightPosition = new float[]{
0, 0, 0,
// (float)levelBox.getFlag().getCenterX(),
// (float)levelBox.getFlag().getCenterY(),
// (float)levelBox.getFlag().getCenterZ() + (float)levelBox.getFlag().getDeltaZ(),
1.0f};
gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, FloatBuffer.wrap(lightAmbient));
gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, FloatBuffer.wrap(lightDiffuse));
gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, FloatBuffer.wrap(lightPosition));
gl.glEnable(GL.GL_LIGHT0);
*/
gl.glDisable(GL.GL_LIGHTING);
// Now preprocess our data for rendering
agentRenderes.prepare(gl);
mapRenderer.prepare(gl);
}
示例6: prepareCanvas
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Clear the screen, set up correct observer position and other stuff
* @param gl
*/
private synchronized void prepareCanvas(GL gl) {
// Clear the drawing area
gl.glEnable(GL.GL_DEPTH_TEST); // GL.GL_NORMALIZE|
gl.glClearColor(0.45f, 0.45f, 0.45f, 0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// Reset the modelview to the "identity"
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
// Move the "drawing cursor" around
Location observerLoc = viewpoint.getLocation();
Location eyeLoc = viewpoint.getEye();
Vector3d upVec = viewpoint.getUp();
// gl.glTranslated(observerLocation.x, observerLocation.y, observerLocation.z);
glu.gluLookAt(
eyeLoc.x,
eyeLoc.y,
eyeLoc.z,
observerLoc.x,
observerLoc.y,
observerLoc.z,
upVec.x,
upVec.y,
upVec.z);
gl.glScaled (1., 1., -1.);
}
示例7: renderFade
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Render passed fade line in passed color.
* @param gl
* @param fadeline Data about fadeline
* @param color what color should fadeline be drawn
*/
private void renderFade(GL gl, GlColor color, IFadeLine fadeline) {
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glBegin(GL.GL_QUADS);
Location lastLocation = null;
double lastAlpha = 0; // how much is point opaque
for (long ms = 0; ms < fadeline.getDuration(); ms += 100) {
Location currentLocation = fadeline.getPosition(ms);
double currentAlpha = ((double) ms) / fadeline.getDuration();
if (lastLocation == null) {
lastLocation = currentLocation;
lastAlpha = currentAlpha;
continue;
}
if (currentLocation != null) {
pushFadeQuad(gl, color, currentLocation, lastLocation, currentAlpha, lastAlpha);
lastLocation = currentLocation;
lastAlpha = currentAlpha;
}
}
gl.glEnd();
gl.glDisable(GL.GL_BLEND);
}
示例8: 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);
}
示例9: configureGLLighting
import javax.media.opengl.GL; //導入方法依賴的package包/類
private void configureGLLighting(GL gl)
{
float global_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f };
gl.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, global_ambient, 0);
// Create light components
float ambientLight[] = { 0.0f, 0.0f, 0.0f, 1.0f };
float diffuseLight[] = { 0.8f, 0.8f, 0.8f, 1.0f };
float specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
float position[] = { -50.0f, 50.0f, 50.0f, 0.0f };
float direction[] = { 50.0f, -50.0f, -50.0f, 0.0f };
// Assign created components to GL_LIGHT0
gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambientLight, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuseLight, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, specularLight, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, position, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPOT_DIRECTION, direction, 0);
gl.glLightf(GL.GL_LIGHT0, GL.GL_SPOT_CUTOFF, 30);
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);
// now all subsequent glColor commands will also effect the lighting colors.
/*
//light attenuation in function of the vertex distance
float constantAttenuation = 1.0f;
float linearAttenuation = 0.2f;
float quadraticAttenuation = 0.08f;
gl.glLightf(GL.GL_LIGHT0, GL.GL_CONSTANT_ATTENUATION, constantAttenuation);
gl.glLightf(GL.GL_LIGHT0, GL.GL_LINEAR_ATTENUATION, linearAttenuation);
gl.glLightf(GL.GL_LIGHT0, GL.GL_QUADRATIC_ATTENUATION, quadraticAttenuation);
*/
gl.glLightf(GL.GL_LIGHT0, GL.GL_QUADRATIC_ATTENUATION, 0.08f);
}
示例10: turnGLLightsOn
import javax.media.opengl.GL; //導入方法依賴的package包/類
private void turnGLLightsOn(GL gl){
gl.glEnable(GL.GL_LIGHT0);
gl.glEnable(GL.GL_LIGHTING);
}
示例11: cad_NURBS
import javax.media.opengl.GL; //導入方法依賴的package包/類
public static void cad_NURBS(GL gl, double x1, double y1, double z1, double w1,
double x2, double y2, double z2, double w2,
double x3, double y3, double z3, double w3){
//
// Dynamically choose how many segments to use for
// approximation of curve.
//
int segments;
switch(AvoGlobal.renderLevel){
case PhotoReal :{
segments = 100;
break;
}
case High :{
segments = 25;
break;
}
case Medium :{
segments = 10;
break;
}
case Low :{
segments = 5;
break;
}
case Fastest :{
segments = 3;
break;
}
default:{
segments = 3;
break;
}
}
double [] ctrlPoints = {x1*w1,y1*w1,z1*w1,w1,
x2*w2,y2*w2,z2*w2,w2,
x3*w3,y3*w3,z3*w3,w3 };
gl.glEnable(GL.GL_MAP1_VERTEX_4);
gl.glEnable(GL.GL_AUTO_NORMAL);
gl.glMap1d(GL.GL_MAP1_VERTEX_4, 0.0, 1.0, 4, 3, ctrlPoints, 0);
gl.glMapGrid1d(segments, 0.0, 1.0);
gl.glEvalMesh1(GL.GL_LINE, 0, segments);
}
示例12: 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);
}