當前位置: 首頁>>代碼示例>>Java>>正文


Java GL2.glVertex2f方法代碼示例

本文整理匯總了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();
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:26,代碼來源:SimpleMessageOverlay.java

示例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();
}
 
開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:25,代碼來源:JoglDebugDraw.java

示例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();
}
 
開發者ID:weimingtom,項目名稱:jbox2d,代碼行數:20,代碼來源:JoglDebugDraw.java

示例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();


}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:16,代碼來源:CaretLayer.java

示例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();
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:32,代碼來源:AbstractSimpleOverlay.java

示例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();
}
 
開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:10,代碼來源:JoglDebugDraw.java

示例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();
}
 
開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:16,代碼來源:JoglDebugDraw.java

示例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();
}
 
開發者ID:weimingtom,項目名稱:jbox2d,代碼行數:10,代碼來源:JoglDebugDraw.java

示例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();
}
 
開發者ID:weimingtom,項目名稱:jbox2d,代碼行數:12,代碼來源:JoglDebugDraw.java

示例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);
    }
}
 
開發者ID:Panda-Programming-Language,項目名稱:Pandomium,代碼行數:69,代碼來源:CefRenderer.java

示例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);
  }
}
 
開發者ID:viglucci,項目名稱:app-jcef-example,代碼行數:71,代碼來源:CefRenderer.java

示例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);
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:50,代碼來源:BBoxDebugLayer.java


注:本文中的javax.media.opengl.GL2.glVertex2f方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。