本文整理匯總了Java中javax.media.opengl.GL2.glVertex3f方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glVertex3f方法的具體用法?Java GL2.glVertex3f怎麽用?Java GL2.glVertex3f使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glVertex3f方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: glRender
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void glRender(GLRenderContext glc)
{
GL2 gl2 = glc.gl2;
gl2.glBegin(GL2.GL_QUADS);
{
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(0, 1);
gl2.glVertex3f(left, up,0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(0, 0);
gl2.glVertex3f(left, down, 0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(1, 0);
gl2.glVertex3f(right, down, 0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(1, 1);
gl2.glVertex3f(right, up, 0);
}
gl2.glEnd();
}
示例2: debugRender
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Render a debugging hint for the arcball tool.
*
* @param gl GL class for rendering-
*/
@SuppressWarnings("unused")
public void debugRender(GL2 gl) {
if (!DEBUG || (startcamera == null)) {
return;
}
gl.glLineWidth(3f);
gl.glColor4f(1.f, 0.f, 0.f, .66f);
gl.glBegin(GL.GL_LINES);
gl.glVertex3f(0.f, 0.f, 0.f);
double rot = startangle - startcamera.getRotationZ();
gl.glVertex3f((float) FastMath.cos(rot) * 4.f, (float) -FastMath.sin(rot) * 4.f, 0.f);
gl.glVertex3f((float) FastMath.cos(rot) * 1.f, (float) -FastMath.sin(rot) * 1.f, 0.f);
gl.glVertex3f((float) FastMath.cos(rot) * 1.f, (float) -FastMath.sin(rot) * 1.f, 1.f);
gl.glEnd();
}
示例3: drawCorners
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawCorners(GL2 gl, Map<String, Vertex> map) {
Vertex rightBottom = map.get("rightBottom");
Vertex leftBottom = map.get("leftBottom");
Vertex rightTop = map.get("rightTop");
Vertex leftTop = map.get("leftTop");
TextureCoords textureCoords = texture.getImageTexCoords();
float leftTex = textureCoords.left();
float rightTex = textureCoords.right();
float topTex = textureCoords.top();
float bottomTex = textureCoords.bottom();
gl.glPushMatrix();
gl.glBegin(GL_TRIANGLE_STRIP);
gl.glTexCoord2d(rightTex, bottomTex);
gl.glVertex3f(rightBottom.getPositionX(), rightBottom.getPositionY(),
rightBottom.getPositionZ());
gl.glTexCoord2d(rightTex, topTex);
gl.glVertex3f(rightTop.getPositionX(), rightTop.getPositionY(), rightTop.getPositionZ());
gl.glTexCoord2d(leftTex, bottomTex);
gl.glVertex3f(leftBottom.getPositionX(), leftBottom.getPositionY(), leftBottom.getPositionZ());
gl.glTexCoord2d(leftTex, topTex);
gl.glVertex3f(leftTop.getPositionX(), leftTop.getPositionY(), leftTop.getPositionZ());
gl.glEnd();
gl.glPopMatrix();
}
示例4: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
if(blendTexture == null) {
Environment environment = Environment.getInstance();
String texPath = environment.getString(EnvVariable.SCREENSHOT_BLEND_TEXTURE);
try {
blendTexture = TextureIO.newTexture(new File(texPath), false);
} catch (GLException | IOException e) {
Logger.getInstance().warning("Texture " + texPath + " not found!");
}
}
if(active && state != null && blendTexture != null) {
TextureCoords texCoords = blendTexture.getImageTexCoords();
FloatVector3D[] vertices = state.getBoundingBox().getCornersCounterClockwise();
blendTexture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(vertices[0].getX(), vertices[0].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(vertices[1].getX(), vertices[1].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(vertices[2].getX(), vertices[2].getY(), 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(vertices[3].getX(), vertices[3].getY(), 0);
gl.glEnd();
}
// Draw next layer.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}
示例5: drawMinorTick
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawMinorTick( final double location, final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
// gl.glEnable( GL2.GL_LINE_STIPPLE );
// gl.glLineStipple( 2, (short) 0x00FF );
gl.glLineWidth( (float)config.getRenderingConfig().getMinorTickThickness() );
gl.glColor3f( config.getRenderingConfig().getMinorTickColour()[0],
config.getRenderingConfig().getMinorTickColour()[1],
config.getRenderingConfig().getMinorTickColour()[2] );
final float l = (float)config.getRenderingConfig().getMinorTickLength();
final float l2 = -l;
final float ll = this.calculatePosition( location ).floatValue();
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, l, zero );
gl.glVertex3f( ll, l2, zero );
}
gl.glEnd();
gl.glPopMatrix();
}
示例6: drawMajorTickGridline
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawMajorTickGridline( final double location, final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
gl.glLineWidth( (float)config.getRenderingConfig().getMajorGridThickness() );
gl.glColor3f( config.getRenderingConfig().getMajorGridColour()[0],
config.getRenderingConfig().getMajorGridColour()[1],
config.getRenderingConfig().getMajorGridColour()[2] );
final float ll = this.calculatePosition( location ).floatValue();
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, zero, zero );
gl.glVertex3f( ll, 1, zero );
}
gl.glEnd();
gl.glBegin( GL.GL_LINE_STRIP );
{
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, zero, zero );
gl.glVertex3f( ll, zero, 1*this.gridDirection );
}
gl.glEnd();
gl.glPopMatrix();
}
示例7: drawSegment
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawSegment(Vec2 p1, Vec2 p2, Color3f color) {
GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
gl.glBegin(GL2.GL_LINES);
gl.glColor3f(color.x, color.y, color.z);
gl.glVertex3f(p1.x, p1.y, 0);
gl.glVertex3f(p2.x, p2.y, 0);
gl.glEnd();
gl.glPopMatrix();
}
示例8: 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();
}
示例9: 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();
}
示例10: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
void render( GL2 gl2 )
{
gl2.glClear( GL.GL_COLOR_BUFFER_BIT );
// draw a triangle filling the window
gl2.glLoadIdentity();
gl2.glBegin( GL.GL_TRIANGLES );
gl2.glColor3f( 1, 0, 0 );
gl2.glVertex3f( 0, 0, 0 );
gl2.glColor3f( 0, 1, 0 );
gl2.glVertex3f( 5, 0, 2 );
gl2.glColor3f( 0, 0, 1 );
gl2.glVertex3f( 2, 5, 3 );
gl2.glEnd();
}
示例11: drawAxis
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawAxis( final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
gl.glLineWidth( (float)config.getRenderingConfig().getThickness() );
gl.glColor3f( config.getRenderingConfig().getColour()[0],
config.getRenderingConfig().getColour()[1],
config.getRenderingConfig().getColour()[2] );
final float n1 = this.calculatePosition( config.getMinValue() ).floatValue();
final float n2 = this.calculatePosition( config.getMaxValue() ).floatValue();
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( n1, zero, zero );
gl.glVertex3f( n2, zero, zero );
}
gl.glEnd();
gl.glPopMatrix();
}
示例12: drawMajorTick
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawMajorTick( final double location, final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
gl.glLineWidth( (float)config.getRenderingConfig().getMajorTickThickness() );
gl.glColor3f( config.getRenderingConfig().getMajorTickColour()[0],
config.getRenderingConfig().getMajorTickColour()[1],
config.getRenderingConfig().getMajorTickColour()[2] );
final float l = (float)config.getRenderingConfig().getMajorTickLength();
final float l2 = -l;
final float ll = this.calculatePosition( location ).floatValue();
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, l, zero );
gl.glVertex3f( ll, l2, zero );
}
gl.glEnd();
gl.glBegin( GL.GL_LINE_STRIP );
{
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, zero, l );
gl.glVertex3f( ll, zero, l2 );
}
gl.glEnd();
gl.glPopMatrix();
}
示例13: 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();
}
示例14: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void render(GL2 gl) {
// Create the credits texture if not done yet:
if(creditsTexture == null) {
createTexture();
}
if(creditsTexture != null) {
// Activate alpha:
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
// Bind the texture for use:
creditsTexture.bind(gl);
// The textures 2D-coordinates:
TextureCoords texCoords = creditsTexture.getImageTexCoords();
// Backup current matrix:
gl.glPushMatrix();
gl.glLoadIdentity();
// Apply transformation:
gl.glRotatef(rotation, 1, 0, 0);
gl.glTranslatef(0, -2, position);
gl.glRotatef(-90, 1, 0, 0);
// Draw vertices and pass uv-coords.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(CREDITS_PANE_WIDTH/2, CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(-CREDITS_PANE_WIDTH/2, CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(-CREDITS_PANE_WIDTH/2, -CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(CREDITS_PANE_WIDTH/2, -CREDITS_PANE_HEIGHT/2, 0);
gl.glEnd();
// Restore matrix:
gl.glPopMatrix();
}
}
示例15: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
// Update and fetch texture.
if (adapter.toDraw()) {
adapter.bindTexture(gl);
Texture tex = adapter.getTexture();
if (tex != null) {
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
tex.bind(gl);
TextureCoords texCoords = tex.getImageTexCoords();
FloatBoundingBox box = adapter.getDrawBox();
FloatVector3D upperLeft = box.getUpperLeft();
FloatVector3D upperRight = box.getUpperRight();
FloatVector3D lowerLeft = box.getLowerLeft();
FloatVector3D lowerRight = box.getLowerRight();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(-1, 1,
-1, 1,
-10000, 10000);
gl.glDisable(GL2.GL_DEPTH_TEST);
gl.glMatrixMode(GL2.GL_MODELVIEW);
// Lift the x-y-pane up:
gl.glTranslatef(0, 0, height);
// Draw texture.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(upperLeft.getX(), upperLeft.getY(), 0.0f);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(lowerLeft.getX(), lowerLeft.getY(), 0.0f);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(lowerRight.getX(), lowerRight.getY(), 0.0f);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(upperRight.getX(), upperRight.getY(), 0.0f);
gl.glEnd();
}
}
// Draw next layer if available.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}