本文整理匯總了Java中javax.media.opengl.GL.glBlendFunc方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glBlendFunc方法的具體用法?Java GL.glBlendFunc怎麽用?Java GL.glBlendFunc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glBlendFunc方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}