本文整理匯總了Java中javax.media.opengl.GL2.glVertex2f方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glVertex2f方法的具體用法?Java GL2.glVertex2f怎麽用?Java GL2.glVertex2f使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glVertex2f方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderContents
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
void renderContents(GL2 gl) {
// Get text bounds.
Rectangle2D bounds = renderer.getBounds(getMessage());
// Render message background:
final float bx1 = .45f * (float) (width - bounds.getWidth());
final float bx2 = .55f * (float) (width + bounds.getWidth());
final float by1 = .45f * (float) (height - bounds.getHeight());
final float by2 = .55f * (float) (height + bounds.getHeight());
gl.glBegin(GL2.GL_QUADS);
gl.glColor4f(0f, 0f, 0f, .75f);
gl.glVertex2f(bx1, by1);
gl.glVertex2f(bx1, by2);
gl.glVertex2f(bx2, by2);
gl.glVertex2f(bx2, by1);
gl.glEnd();
// Render message
renderer.beginRendering(width, height);
renderer.setColor(1f, 1f, 1f, 1f);
renderer.setColor(1f, 1f, 1f, 1f);
renderer.draw(getMessage(), (width - (int) bounds.getWidth()) >> 1, (height - (int) bounds.getHeight()) >> 1);
renderer.endRendering();
}
示例2: drawTransform
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawTransform(Transform xf) {
GL2 gl = panel.getGL().getGL2();
getWorldToScreenToOut(xf.p, temp);
temp2.setZero();
float k_axisScale = 0.4f;
gl.glBegin(GL2.GL_LINES);
gl.glColor3f(1, 0, 0);
temp2.x = xf.p.x + k_axisScale * xf.q.c;
temp2.y = xf.p.y + k_axisScale * xf.q.s;
getWorldToScreenToOut(temp2, temp2);
gl.glVertex2f(temp.x, temp.y);
gl.glVertex2f(temp2.x, temp2.y);
gl.glColor3f(0, 1, 0);
temp2.x = xf.p.x + -k_axisScale * xf.q.s;
temp2.y = xf.p.y + k_axisScale * xf.q.c;
getWorldToScreenToOut(temp2, temp2);
gl.glVertex2f(temp.x, temp.y);
gl.glVertex2f(temp2.x, temp2.y);
gl.glEnd();
}
示例3: drawSolidPolygon
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
GL2 gl = panel.getGL().getGL2();
gl.glBegin(GL2.GL_TRIANGLE_FAN);
gl.glColor4f(color.x, color.y, color.z, .4f);
for (int i = 0; i < vertexCount; i++) {
getWorldToScreenToOut(vertices[i], trans);
gl.glVertex2f(trans.x, trans.y);
}
gl.glEnd();
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glColor4f(color.x, color.y, color.z, 1f);
for (int i = 0; i < vertexCount; i++) {
getWorldToScreenToOut(vertices[i], trans);
gl.glVertex2f(trans.x, trans.y);
}
gl.glEnd();
}
示例4: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void render(OpenGLContext context) {
GL2 gl = context.getGL().getGL2();
gl.glColor3f(1, 1, 1);
gl.glLineWidth(1.0f);
gl.glBegin(GL.GL_LINE_LOOP);
float zoom=context.getZoom();
gl.glVertex2f(context.getX() / (1f*width),1-context.getY() / (1f*height));
gl.glVertex2f((context.getX() + zoom*context.getWidth()) / width,1- context.getY() / (1f*height));
gl.glVertex2f((context.getX() + zoom*context.getWidth()) / width,1- (context.getY() + zoom*context.getHeight()) / height);
gl.glVertex2f(context.getX() / (1f*width),1-(context.getY() + zoom*context.getHeight()) / height);
gl.glEnd();
gl.glFlush();
}
示例5: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Main render method
*
* @param gl GL context
*/
public final void render(GL2 gl) {
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glOrtho(0, width, 0, height, -1, +1);
gl.glColor4f(0f, 0f, 0f, .5f);
// Fade background:
gl.glBegin(GL2.GL_QUADS);
gl.glVertex2f(0f, 0f);
gl.glVertex2f(width, 0f);
gl.glVertex2f(width, height);
gl.glVertex2f(0f, height);
gl.glEnd();
renderContents(gl);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPopMatrix();
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPopMatrix();
}
示例6: drawPoint
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawPoint(Vec2 argPoint, float argRadiusOnScreen, Color3f argColor) {
Vec2 vec = getWorldToScreen(argPoint);
GL2 gl = panel.getGL().getGL2();
gl.glPointSize(argRadiusOnScreen);
gl.glBegin(GL2.GL_POINTS);
gl.glVertex2f(vec.x, vec.y);
gl.glEnd();
}
示例7: drawPolygon
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glColor4f(color.x, color.y, color.z, 1f);
for (int i = 0; i < vertexCount; i++) {
Vec2 v = vertices[i];
System.err.println("polygon vertex: "+v.x +", "+v.y);
gl.glVertex2f(v.x, v.y);
}
gl.glEnd();
gl.glPopMatrix();
}
示例8: drawPoint
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawPoint(Vec2 argPoint, float argRadiusOnScreen, Color3f argColor) {
Vec2 vec = getWorldToScreen(argPoint);
GL2 gl = panel.getGL().getGL2();
gl.glBegin(GL2.GL_POINT);
gl.glPointSize(argRadiusOnScreen);
gl.glVertex2f(vec.x, vec.y);
gl.glEnd();
}
示例9: drawSegment
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawSegment(Vec2 p1, Vec2 p2, Color3f color) {
GL2 gl = panel.getGL().getGL2();
gl.glBegin(GL2.GL_LINES);
gl.glColor3f(color.x, color.y, color.z);
getWorldToScreenToOut(p1, trans);
gl.glVertex2f(trans.x, trans.y);
getWorldToScreenToOut(p2, trans);
gl.glVertex2f(trans.x, trans.y);
gl.glEnd();
}
示例10: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0) {
return;
}
assert (initialized_context_ != null);
final float[] vertex_data = {
//tu, tv, x, y, z
0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f };
FloatBuffer vertices = FloatBuffer.wrap(vertex_data);
gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);
gl2.glMatrixMode(gl2.GL_MODELVIEW);
gl2.glLoadIdentity();
// Match GL units to screen coordinates.
gl2.glViewport(0, 0, view_width_, view_height_);
gl2.glMatrixMode(gl2.GL_PROJECTION);
gl2.glLoadIdentity();
// Draw the background gradient.
gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
gl2.glBegin(gl2.GL_QUADS);
gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f); // red
gl2.glVertex2f(-1.0f, -1.0f);
gl2.glVertex2f(1.0f, -1.0f);
gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f); // blue
gl2.glVertex2f(1.0f, 1.0f);
gl2.glVertex2f(-1.0f, 1.0f);
gl2.glEnd();
gl2.glPopAttrib();
// Rotate the view based on the mouse spin.
if (spin_x_ != 0) {
gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
}
if (spin_y_ != 0) {
gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);
}
if (transparent_) {
// Alpha blending style. Texture values have premultiplied alpha.
gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);
// Enable alpha blending.
gl2.glEnable(gl2.GL_BLEND);
}
// Enable 2D textures.
gl2.glEnable(gl2.GL_TEXTURE_2D);
// Draw the facets with the texture.
assert (texture_id_[0] != 0);
gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);
// Disable 2D textures.
gl2.glDisable(gl2.GL_TEXTURE_2D);
if (transparent_) {
// Disable alpha blending.
gl2.glDisable(gl2.GL_BLEND);
}
}
示例11: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0)
return;
assert(initialized_context_ != null);
final float[] vertex_data = {
//tu, tv, x, y, z
0.0f, 1.0f, -1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 1.0f, -1.0f, 0.0f,
1.0f, 0.0f, 1.0f, 1.0f, 0.0f,
0.0f, 0.0f, -1.0f, 1.0f, 0.0f
};
FloatBuffer vertices = FloatBuffer.wrap(vertex_data);
gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);
gl2.glMatrixMode(gl2.GL_MODELVIEW);
gl2.glLoadIdentity();
// Match GL units to screen coordinates.
gl2.glViewport(0, 0, view_width_, view_height_);
gl2.glMatrixMode(gl2.GL_PROJECTION);
gl2.glLoadIdentity();
gl2.glOrtho(0, 0, view_width_, view_height_, 0.1, 100.0);
// Draw the background gradient.
gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
gl2.glBegin(gl2.GL_QUADS);
gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f); // red
gl2.glVertex2f(-1.0f, -1.0f);
gl2.glVertex2f(1.0f, -1.0f);
gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f); // blue
gl2.glVertex2f(1.0f, 1.0f);
gl2.glVertex2f(-1.0f, 1.0f);
gl2.glEnd();
gl2.glPopAttrib();
// Rotate the view based on the mouse spin.
if (spin_x_ != 0)
gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
if (spin_y_ != 0)
gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);
if (transparent_) {
// Alpha blending style. Texture values have premultiplied alpha.
gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);
// Enable alpha blending.
gl2.glEnable(gl2.GL_BLEND);
}
// Enable 2D textures.
gl2.glEnable(gl2.GL_TEXTURE_2D);
// Draw the facets with the texture.
assert(texture_id_[0] != 0);
gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);
// Disable 2D textures.
gl2.glDisable(gl2.GL_TEXTURE_2D);
if (transparent_) {
// Disable alpha blending.
gl2.glDisable(gl2.GL_BLEND);
}
}
示例12: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
if(!texturesLoaded) {
loadTextures();
}
GLState glState = (GLState) StateManager.getInstance().getState(StateType.GLState);
FloatBoundingBox bbox = glState.getBoundingBox();
FloatVector3D current = bbox.getUpperLeft();
TextureCoords texCoords = texUpperLeft.getImageTexCoords();
texUpperLeft.enable(gl);
texUpperLeft.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(current.getX() + TEXSIZE, current.getY(), layerDist);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(current.getX(), current.getY(), layerDist);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(current.getX(), current.getY() - TEXSIZE, layerDist);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex2f(current.getX() + TEXSIZE, current.getY() - TEXSIZE);
gl.glEnd();
current = bbox.getLowerRight();
texCoords = texLowerRight.getImageTexCoords();
texLowerRight.enable(gl);
texLowerRight.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(current.getX(), current.getY() + TEXSIZE, layerDist);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(current.getX() - TEXSIZE, current.getY() + TEXSIZE, layerDist);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(current.getX() - TEXSIZE, current.getY(), layerDist);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex2f(current.getX(), current.getY());
gl.glEnd();
DrawableLayer nextLayer = getNextLayer();
if(nextLayer != null) {
nextLayer.draw(gl, height + HEIGHT_GAP);
}
}