本文整理汇总了Java中com.jogamp.opengl.GL2.glVertex2d方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glVertex2d方法的具体用法?Java GL2.glVertex2d怎么用?Java GL2.glVertex2d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glVertex2d方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glColor3f(0, 1, 1);
gl.glLineWidth(5f);
gl.glBegin(GL.GL_LINES);
for (int n = 0; n < numberOfLinesInUse; n++) {
gl.glVertex2d((sx2 * (lsx[n] + 1)), (sy2 * (lsy[n] + 1)));
gl.glVertex2d((sx2 * (lex[n] + 1)), (sy2 * (ley[n] + 1)));
// g.drawLine((int) (sx2 * (gsx + 1) * 4), (int) (sy2 * (gsy + 1) * 4), (int) (sx2 * (gex + 1) * 4), (int) (sy2 * (gey + 1) * 4));
}
gl.glEnd();
// show matrix
MultilineAnnotationTextRenderer.resetToYPositionPixels(chip.getSizeY());
StringBuilder sb = new StringBuilder("PigTracker\n");
sb.append(String.format("# lines = %d\nm=\n", numberOfLinesInUse));
sb.append(String.format("%6.3f %6.3f %6.3f\n", cm[0], cm[1], cm[2]));
sb.append(String.format("%6.3f %6.3f %6.3f\n", cm[3], cm[4], cm[5]));
sb.append(String.format("%6.3f %6.3f %6.3f\n", cm[6], cm[7], cm[8]));
MultilineAnnotationTextRenderer.renderMultilineString(sb.toString());
}
示例2: fillCircleFromCenter
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Fills the circle from the center location using the given radius.
*
* @param gl the OpenGL files
* @param r the radius
* @param cx the x coordinate of the center
* @param cy the y coordinate of the center
*/
public static final void fillCircleFromCenter(GL2 gl, double r, double cx, double cy) {
// pre compute sin and cos
double c = COS;
double s = SIN;
double t;
// start at 0
double x = r;
double y = 0;
gl.glBegin(GL.GL_TRIANGLE_FAN);
gl.glVertex2d(cx, cy);
for (int i = 0; i <= N; i++) {
gl.glVertex2d(x + cx, y + cy);//output vertex
//apply the rotation matrix
t = x;
x = c * x - s * y;
y = s * t + c * y;
}
gl.glEnd();
}
示例3: renderVelocity
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Renders the linear and angular velocity.
*
* @param gl the OpenGL files
*/
public void renderVelocity(GL2 gl) {
// set the color
gl.glColor4fv(Preferences.getBodyVelocityColor(), 0);
// draw the velocities
Vector2 c = this.getWorldCenter();
Vector2 v = this.getLinearVelocity();
double av = this.getAngularVelocity();
// draw the linear velocity for each body
gl.glBegin(GL.GL_LINES);
gl.glVertex2d(c.x, c.y);
gl.glVertex2d(c.x + v.x, c.y + v.y);
gl.glEnd();
// draw an arc
RenderUtilities.drawArc(gl, c.x, c.y, 0.125, 0, av);
}
示例4: drawPulleyJoint
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Renders a PulleyJoint to the given graphics object.
*
* @param gl the OpenGL graphics files
* @param joint the joint
* @since 2.2.0
*/
public static final void drawPulleyJoint(GL2 gl, PulleyJoint joint) {
// set the color to be mostly transparent
gl.glColor4f(0.0f, 0.0f, 0.0f, 0.3f);
Vector2 p1 = joint.getAnchor1();
Vector2 p2 = joint.getPulleyAnchor1();
Vector2 p3 = joint.getPulleyAnchor2();
Vector2 p4 = joint.getAnchor2();
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex2d(p1.x, p1.y);
gl.glVertex2d(p2.x, p2.y);
gl.glVertex2d(p3.x, p3.y);
gl.glVertex2d(p4.x, p4.y);
gl.glEnd();
}
示例5: drawMouseJoint
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Renders a MouseJoint to the given graphics object.
*
* @param gl the OpenGL graphics files
* @param joint the joint
* @param invdt the inverse of the delta time of the last world step
*/
public static final void drawMouseJoint(GL2 gl, PinJoint joint, double invdt) {
// set the color
gl.glColor4f(0.0f, 0.0f, 0.0f, 0.8f);
// draw the anchor point
Vector2 anchor = joint.getAnchor2();
RenderUtilities.fillRectangleFromCenter(gl, anchor.x, anchor.y, 0.05, 0.05);
// draw the target point
Vector2 target = joint.getTarget();
RenderUtilities.fillRectangleFromCenter(gl, target.x, target.y, 0.05, 0.05);
// draw a line connecting them
// make the line color a function of stress (black to red)
// getProperty the inverse delta time
double maxForce = joint.getMaximumForce();
double force = joint.getReactionForce(invdt).getMagnitude();
double red = force / maxForce;
red *= 1.10;
red = Interval.clamp(red, 0.0, 1.0);
// set the color
gl.glColor4f((float) red, 0.0f, 0.0f, 0.8f);
gl.glBegin(GL.GL_LINES);
gl.glVertex2d(anchor.x, anchor.y);
gl.glVertex2d(target.x, target.y);
gl.glEnd();
}
示例6: drawRectangleFromTopLeft
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Draws an outline of a rectangle from the top left position using the given height and width.
*
* @param gl the OpenGL files
* @param sx the x coordinate of the top left position
* @param sy the y coordinate of the top left position
* @param w the width
* @param h the height
* @param points true if points should be drawn
*/
public static final void drawRectangleFromTopLeft(GL2 gl, double sx, double sy, double w, double h, boolean points) {
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex2d(sx, sy);
gl.glVertex2d(sx + w, sy);
gl.glVertex2d(sx + w, sy - h);
gl.glVertex2d(sx, sy - h);
gl.glEnd();
if (points) {
gl.glBegin(GL.GL_POINTS);
gl.glVertex2d(sx, sy);
gl.glVertex2d(sx + w, sy);
gl.glVertex2d(sx + w, sy - h);
gl.glVertex2d(sx, sy - h);
gl.glEnd();
}
}
示例7: drawEllipse
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public static void drawEllipse(GL2 gl, float centerX, float centerY, float radiusX, float radiusY, float angle, int N) {
final float r2d = (float) (180 / Math.PI);
gl.glTranslatef(centerX, centerY, 0);
if(angle!=0) gl.glRotatef(angle * r2d, 0, 0, 1);
gl.glBegin(GL.GL_LINE_LOOP);
{
for (int i = 0; i < N; i++) {
double a = ((float) i / N) * 2 * Math.PI;
double cosA = Math.cos(a);
double sinA = Math.sin(a);
gl.glVertex2d(radiusX * cosA, radiusY * sinA);
}
}
gl.glEnd();
}
示例8: drawPlayerInfo
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void drawPlayerInfo(GL2 gl)
{
gl.glBegin(GL2.GL_QUADS);
gl.glColor4d(0.75, 0.25, 0.25, 0.5);
gl.glNormal3d(0, 0, 1);
gl.glVertex3d(-1, 1, 0.5);
gl.glVertex3d(-1, 0.95, 0.5);
gl.glVertex3d((inst.player.life - 5.0)/5.0 , 0.95, 0.5);
gl.glVertex3d((inst.player.life - 5.0)/5.0 , 1, 0.5);
gl.glEnd();
{
java.awt.Point pos = inst.canvas.getMousePosition();
if(pos != null)
{
gl.glBegin(GL2.GL_POINTS);
gl.glColor3d(Math.random(), Math.random(), Math.random());
Vector pos2 = inst.translateToReal(pos.x, pos.y);
gl.glVertex2d(pos.x, pos.y);
gl.glEnd();
}
}
}
示例9: drawLineSegment
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Draws the line segment specified by two points.
*
* @param gl the OpenGL files
* @param p1x the x coordinate of the first point
* @param p1y the y coordinate of the first point
* @param p2x the x coordinate of the second point
* @param p2y the y coordinate of the second point
* @param points true if points should be drawn
*/
public static final void drawLineSegment(GL2 gl, double p1x, double p1y, double p2x, double p2y, boolean points) {
gl.glBegin(GL.GL_LINES);
gl.glVertex2d(p1x, p1y);
gl.glVertex2d(p2x, p2y);
gl.glEnd();
if (points) {
gl.glBegin(GL.GL_POINTS);
gl.glVertex2d(p1x, p1y);
gl.glVertex2d(p2x, p2y);
gl.glEnd();
}
}
示例10: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* JOGL annotation
*/
@Override
public void annotate(GLAutoDrawable drawable) {
if (!isFilterEnabled()) {
return;
}
Point2D p = medianPoint;
Point2D s = stdPoint;
GL2 gl = drawable.getGL().getGL2();
// already in chip pixel context with LL corner =0,0
gl.glPushMatrix();
gl.glColor3f(0, 0, 1);
gl.glLineWidth(4);
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glVertex2d(p.getX() - s.getX(), p.getY() - s.getY());
gl.glVertex2d(p.getX() + s.getX(), p.getY() - s.getY());
gl.glVertex2d(p.getX() + s.getX(), p.getY() + s.getY());
gl.glVertex2d(p.getX() - s.getX(), p.getY() + s.getY());
gl.glEnd();
gl.glBegin(GL2.GL_LINES);
gl.glVertex2d(p.getX() - 10, p.getY());
gl.glVertex2d(p.getX() + 10, p.getY());
gl.glVertex2d(p.getX(), p.getY() - 10);
gl.glVertex2d(p.getX(), p.getY() + 10);
gl.glEnd();
gl.glPopMatrix();
}
示例11: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
if (!isFilterEnabled()) {
return;
}
GL2 gl = drawable.getGL().getGL2();
gl.glPushMatrix();
for (int c=0; c<numCameras; c++){
medianTrackers[c].annotate(drawable);
Float hue= (float) c*360/numCameras; // conversion in hue value, dependindin on the number of cameras
Color color=Color.hsb(hue, 0.5f, 1f);
gl.glColor3d(color.getRed(), color.getGreen(), color.getBlue());
gl.glLineWidth(4);
gl.glBegin(GL2.GL_LINE_LOOP);
Point2D p = medianTrackers[c].getMedianPoint();
Point2D s = medianTrackers[c].getStdPoint();
int sx=chip.getSizeX();
int sy=chip.getSizeY();
gl.glVertex2d((c*sx/numCameras+p.getX()) - s.getX(), p.getY() - s.getY());
gl.glVertex2d((c*sx/numCameras+p.getX()) + s.getX(), p.getY() - s.getY());
gl.glVertex2d((c*sx/numCameras+p.getX()) + s.getX(), p.getY() + s.getY());
gl.glVertex2d((c*sx/numCameras+p.getX()) - s.getX(), p.getY() + s.getY());
gl.glEnd();
}
gl.glPopMatrix();
}
示例12: fillRectangle
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Fills the given rectangle.
*
* @param gl the OpenGL files
* @param r the rectangle
*/
public static final void fillRectangle(GL2 gl, Rectangle r) {
Vector2[] vs = r.getVertices();
gl.glBegin(GL2.GL_QUADS);
for (int i = 0; i < vs.length; i++) {
Vector2 v = vs[i];
gl.glVertex2d(v.x, v.y);
}
gl.glEnd();
}
示例13: drawWeldJoint
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Renders a WeldJoint to the given graphics object.
*
* @param gl the OpenGL graphics files
* @param joint the joint
*/
public static final void drawWeldJoint(GL2 gl, WeldJoint joint) {
// set the color
gl.glColor4f(0.3f, 0.3f, 0.3f, 1.0f);
// draw an x at the anchor point
Vector2 anchor = joint.getAnchor1();
final double d = 0.025;
gl.glBegin(GL.GL_LINES);
gl.glVertex2d(anchor.x - d, anchor.y - d);
gl.glVertex2d(anchor.x + d, anchor.y + d);
gl.glVertex2d(anchor.x - d, anchor.y + d);
gl.glVertex2d(anchor.x + d, anchor.y - d);
gl.glEnd();
}
示例14: fillRectangleFromCenter
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Fills the rectangle from the center using the given height and width.
*
* @param gl the OpenGL files
* @param cx the x coordinate of the center
* @param cy the y coordinate of the center
* @param w the width
* @param h the height
*/
public static final void fillRectangleFromCenter(GL2 gl, double cx, double cy, double w, double h) {
double w2 = w * 0.5;
double h2 = h * 0.5;
gl.glBegin(GL2.GL_QUADS);
gl.glVertex2d(cx - w2, cy + h2);
gl.glVertex2d(cx + w2, cy + h2);
gl.glVertex2d(cx + w2, cy - h2);
gl.glVertex2d(cx - w2, cy - h2);
gl.glEnd();
}
示例15: render
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
protected void render(GL2 gl, int canvaswidth, int canvasheight) {
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glLoadIdentity();
// Draw a quad textured with the map image.
float textureHeight = mapTexture.getHeight();
float textureWidth = mapTexture.getWidth();
float aspect = textureHeight / textureWidth;
float height = canvasheight;
float width = height / aspect;
gl.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glColor3f(1, 1, 1);
gl.glBegin(GL2.GL_POLYGON);
gl.glTexCoord2f(0, 0);
gl.glVertex2f(0, 0);
gl.glTexCoord2f(1, 0);
gl.glVertex2f(width, 0);
gl.glTexCoord2f(1, 1);
gl.glVertex2f(width, height);
gl.glTexCoord2f(0, 1);
gl.glVertex2f(0, height);
gl.glEnd();
gl.glBindTexture(GL_TEXTURE_2D, 0);
// Draw river
double elapsed = System.currentTimeMillis() - start_time;
int current_frame_index = Math.min(data_points.length - 1,
(int) (elapsed / ms_per_day));
// We're going to interpolate in time between samples
double tween = (elapsed - current_frame_index * ms_per_day) / ms_per_day;
double depths[] = data_points[current_frame_index];
double next_depths[] = data_points[Math.min(current_frame_index + 1, data_points.length - 1)];
// The river's course
int course[][] = {{298, 2}, {291, 7}, {284, 10}, {281, 17}, {278, 24}, {277, 33}, {275, 40}, {273, 48}, {270, 56}, {264, 62}, {258, 66}, {252, 70}, {246, 74}, {237, 75}, {228, 76}, {222, 81}, {217, 87}, {213, 93}, {209, 100}, {204, 105}, {198, 109}, {193, 114}, {189, 120}, {183, 127}, {178, 133}, {172, 137}, {165, 140}, {159, 145}, {154, 150}, {150, 157}, {148, 165}, {145, 173}, {141, 180}, {138, 188}, {134, 196}, {129, 202}, {125, 209}, {120, 216}, {114, 222}, {109, 227}, {102, 230}, {94, 233}, {87, 236}, {81, 240}, {74, 243}, {68, 247}, {61, 250}, {56, 255}, {52, 261}, {47, 267}, {41, 271}, {35, 276}, {28, 279}, {23, 284}, {19, 290}, {17, 299}, {16, 308}, {14, 317}, {8, 322}, {4, 328}, {5, 337}, {9, 343}, {9, 344}, {9, 345}, {9, 346}, {9, 347}, {9, 348}, {9, 349}, {9, 350}};
gl.glLineWidth(20);
gl.glBegin(GL2.GL_LINE_STRIP);
for (int i = 0; i < course.length; ++i) {
int station = (int) Math.floor(3 * (double) i / course.length);
double shade = ((1 - tween) * depths[station] + tween * next_depths[station]) / 30;
double redgreen = Math.max(0, 1.75 * shade - 1);
double blue = shade * 2;
gl.glColor3d(redgreen, redgreen, blue);
gl.glVertex2d(width * (course[i][0]) / textureWidth,
height * (course[i][1]) / textureHeight);
}
gl.glEnd();
}