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


Java GL2.glDrawArrays方法代碼示例

本文整理匯總了Java中javax.media.opengl.GL2.glDrawArrays方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glDrawArrays方法的具體用法?Java GL2.glDrawArrays怎麽用?Java GL2.glDrawArrays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.glDrawArrays方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawInteriorVertexColorVBO

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawInteriorVertexColorVBO(final DrawContext dc, final int[] vboIds, final PathData pathData) {

		final GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

		final int vertexStride = pathData.getVertexStride();

		// Convert stride from number of elements to number of bytes.
		gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, vboIds[0]);
		{
			gl.glEnableClientState(GL2.GL_COLOR_ARRAY);
			{
				gl.glVertexPointer(3, GL2.GL_FLOAT, 4 * vertexStride, 0);
				gl.glColorPointer(4, GL2.GL_FLOAT, 4 * vertexStride, 4 * pathData.getColorOffset());

				gl.glDrawArrays(GL2.GL_TRIANGLE_STRIP, 0, pathData.getVertexCount());
			}
			gl.glDisableClientState(GL2.GL_COLOR_ARRAY);
		}
		gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:21,代碼來源:TrackPathOptimized.java

示例2: 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

示例3: 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

示例4: display

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
    public void display(GLAutoDrawable drawable) {

        GL2 gl = drawable.getGL().getGL2();

        // ensure pipeline is clean before doing cl work
        gl.glFinish();

        computeHeightfield();

        gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();

        usi.interact(gl);

        gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]);
        gl.glVertexPointer(4, GL2.GL_FLOAT, 0, 0);

//            gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, glObjects[INDICES]);

        gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
        gl.glDrawArrays(GL2.GL_POINTS, 0, MESH_SIZE * MESH_SIZE);
//            gl.glDrawElements(GL2.GL_TRIANGLES, ib.capacity(), GL2.GL_UNSIGNED_INT, 0);
        gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);

//            gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);

    }
 
開發者ID:akmaier,項目名稱:CONRAD,代碼行數:29,代碼來源:GLCLInteroperabilityDemo.java


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