本文整理匯總了Java中javax.media.opengl.GL2.glColor4b方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glColor4b方法的具體用法?Java GL2.glColor4b怎麽用?Java GL2.glColor4b使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glColor4b方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: drawParticlesWireframe
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawParticlesWireframe(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_LINE_LOOP);
if (colors == null) {
gl.glColor4f(1, 1, 1, 1);
} else {
ParticleColor color = colors[i];
gl.glColor4b(color.r, color.g, color.b, (byte) 127);
}
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();
}