当前位置: 首页>>代码示例>>Java>>正文


Java GL10.glDrawArrays方法代码示例

本文整理汇总了Java中javax.microedition.khronos.opengles.GL10.glDrawArrays方法的典型用法代码示例。如果您正苦于以下问题:Java GL10.glDrawArrays方法的具体用法?Java GL10.glDrawArrays怎么用?Java GL10.glDrawArrays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.khronos.opengles.GL10的用法示例。


在下文中一共展示了GL10.glDrawArrays方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
public void render(GL10 gl) {
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    if (colorIndex>4) {
        gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    }
    else {
        gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
    }

    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexBuffer);
    if (colorIndex>4) {
        gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);
    }
    else if (colorIndex==4) {
        // single color
        gl.glColor4f(
                colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
    }

    gl.glDrawArrays(glMode, 0, numVertices);
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:22,代码来源:GLVertexList.java

示例2: drawLines

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
/**
 * 画坐标
 * @param gl
 */
private void drawLines(GL10 gl){
	gl.glLineWidth(3f);
	float[] vertexArray = { -100, 0, 0, 100, 0, 0, 0, -100, 0, 0, 100, 0, 0, 0, -100, 0, 0, 100 };
	FloatBuffer lineBuffer = getFloatBufferFromArray(vertexArray);
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, lineBuffer);

	// X : red
	gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 1.0f, 0f, 0f, 0.75f }, 0);
	gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 1.0f, 0f, 0f, 0.5f }, 0);
	gl.glDrawArrays(GL10.GL_LINES, 0, 2);

	// Y : blue
	gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 0f, 0f, 1.0f, 0.75f }, 0);
	gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 0f, 0f, 1.0f, 0.5f }, 0);
	gl.glDrawArrays(GL10.GL_LINES, 2, 2);

	// Z : green
	gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 0f, 1.0f, 0f, 0.75f }, 0);
	gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 0f, 1.0f, 0f, 0.5f }, 0);
	gl.glDrawArrays(GL10.GL_LINES, 4, 2);
}
 
开发者ID:xhd-Git,项目名称:3DPrint-Controller,代码行数:26,代码来源:STLRenderer.java

示例3: draw

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
public void draw(GL10 gl) {
	if (normalList == null || triangleBuffer == null) {
		return;
	}
	
	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
	//gl.glFrontFace(GL10.GL_CCW);
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, triangleBuffer);
	gl.glNormalPointer(GL10.GL_FLOAT,0, normalBuffer);
	gl.glDrawArrays(GL10.GL_TRIANGLES, 0, vertext_size*3);
	gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
	

}
 
开发者ID:xhd-Git,项目名称:3DPrint-Controller,代码行数:17,代码来源:STLObject.java

示例4: draw

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
/**
 * Encapsulates the OpenGL ES instructions for drawing this shape.
 *
 * @param gl - The OpenGL ES context in which to draw this shape.
 */
public void draw(GL10 gl) {
    // Since this shape uses vertex arrays, enable them
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

    // draw the shape
    gl.glColor4f(       // set color:
            color[0], color[1],
            color[2], color[3]);
    gl.glVertexPointer( // point to vertex data:
            COORDS_PER_VERTEX,
            GL10.GL_FLOAT, 0, vertexBuffer);
    gl.glDrawArrays(    // draw shape:
            GL10.GL_TRIANGLES, 0,
            triangleCoords.length / COORDS_PER_VERTEX);

    // Disable vertex array drawing to avoid
    // conflicts with shapes that don't use it
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:25,代码来源:Triangle.java

示例5: drawLine

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
public void drawLine(GL10 gl, Position3D p3PrevPoint, Position3D p3NextPoint, com.cyzapps.VisualMFP.Color color) {
    // set the colour for the line
    gl.glColor4f(color.getF1R(), color.getF1G(), color.getF1B(), color.getF1Alpha());
    float vertices[] = {
            (float)p3PrevPoint.getX(), (float)p3PrevPoint.getY(), (float)p3PrevPoint.getZ(),
            (float)p3NextPoint.getX(), (float)p3NextPoint.getY(), (float)p3NextPoint.getZ(),

    };
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(vertices.length * 4);
    byteBuffer.order(ByteOrder.nativeOrder());
    FloatBuffer vertexBuffer;
    vertexBuffer = byteBuffer.asFloatBuffer();
    vertexBuffer.put(vertices);
    // set the cursor position to the beginning of the buffer
    vertexBuffer.position(0);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    // Set the face rotation
    //gl.glFrontFace(GL10.GL_CW);
    // Point to our vertex buffer
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    // Draw the vertices as triangle strip
    gl.glDrawArrays(GL10.GL_LINES, 0, vertices.length / 3);

    // Disable the client state before leaving
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:27,代码来源:OGLChart.java

示例6: drawPoint

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
public void drawPoint(GL10 gl, Position3D p3Point, com.cyzapps.VisualMFP.Color color) {
	// 3d chart ignore point shape and size.
    gl.glColor4f(color.getF1R(), color.getF1G(), color.getF1B(), color.getF1Alpha());
    float vertices[] = {
            (float)p3Point.getX(), (float)p3Point.getY(), (float)p3Point.getZ()
            };
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(vertices.length * 4);
    byteBuffer.order(ByteOrder.nativeOrder());
    FloatBuffer vertexBuffer;
    vertexBuffer = byteBuffer.asFloatBuffer();
    vertexBuffer.put(vertices);
    // set the cursor position to the beginning of the buffer
    vertexBuffer.position(0);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    // Set the face rotation
    //gl.glFrontFace(GL10.GL_CW);
    // Point to our vertex buffer
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    // Draw the vertices as triangle strip
    gl.glDrawArrays(GL10.GL_POINTS, 0, vertices.length / 3);

    // Disable the client state before leaving
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:25,代码来源:OGLChart.java

示例7: drawGrids

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
/**
 * 画网格
 * @param gl
 */
private void drawGrids(GL10 gl) {
	List<Float> lineList = new ArrayList<Float>();
	
	for (int x = -100; x <= 100; x += 5) {
		lineList.add((float) x);
		lineList.add(-100f);
		lineList.add(0f);
		lineList.add((float)x);
		lineList.add(100f);
		lineList.add(0f);
	}
	for (int y = -100; y <= 100; y += 5) {
		lineList.add(-100f);
		lineList.add((float) y);
		lineList.add(0f);
		lineList.add(100f);
		lineList.add((float) y);
		lineList.add(0f);
	}

	FloatBuffer lineBuffer = getFloatBufferFromList(lineList);
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, lineBuffer);

	gl.glLineWidth(1f);
	gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[]{0.5f, 0.5f, 0.5f, 1.0f}, 0);
	gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[]{0.5f, 0.5f, 0.5f, 1.0f}, 0);
	gl.glDrawArrays(GL10.GL_LINES, 0, lineList.size() / 3);
}
 
开发者ID:xhd-Git,项目名称:3DPrint-Controller,代码行数:33,代码来源:STLRenderer.java

示例8: draw

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
    public void draw(GL10 gl) {
//        gl.glColor4f(1.0f,0.0f,0.0f,1.0f);
//        gl.glPointSize(8.0f);
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
        gl.glVertexPointer(3, GL10.GL_VERTEX_ARRAY,0,mVertexBuffer);
        gl.glColorPointer(4, GL10.GL_FIXED,0,mColorBuffer);
        gl.glDrawArrays(GL10.GL_POINTS,0,3);

        gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    }
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:14,代码来源:Point.java

示例9: drawRectangle

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
public void drawRectangle(GL10 gl, Position3D p3LeftTop, Position3D p3RightBottom, com.cyzapps.VisualMFP.Color color) {
	/** 3d chart ignore point shape and size. An alternative way is like
        gl.glColor3f(r, g, b);
        gl.glBegin(GL.GL_QUADS);
        gl.glVertex3f(-halfFaceSize, -halfFaceSize, halfFaceSize);
        gl.glVertex3f( halfFaceSize, -halfFaceSize, halfFaceSize);
        gl.glVertex3f( halfFaceSize,  halfFaceSize, halfFaceSize);
        gl.glVertex3f(-halfFaceSize,  halfFaceSize, halfFaceSize);
        gl.glEnd();
    */
    gl.glColor4f(color.getF1R(), color.getF1G(), color.getF1B(), color.getF1Alpha());
    float vertices[] = {
            (float)p3LeftTop.getX(), (float)p3RightBottom.getY(), (float)p3LeftTop.getZ(),
            (float)p3RightBottom.getX(), (float)p3RightBottom.getY(), (float)p3RightBottom.getZ(),
            (float)p3LeftTop.getX(), (float)p3LeftTop.getY(), (float)p3LeftTop.getZ(),
            (float)p3RightBottom.getX(), (float)p3LeftTop.getY(), (float)p3LeftTop.getZ()
            };
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(vertices.length * 4);
    byteBuffer.order(ByteOrder.nativeOrder());
    FloatBuffer vertexBuffer;
    vertexBuffer = byteBuffer.asFloatBuffer();
    vertexBuffer.put(vertices);
    // set the cursor position to the beginning of the buffer
    vertexBuffer.position(0);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    // Set the face rotation
    //gl.glFrontFace(GL10.GL_CW);
    // Point to our vertex buffer
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    // Draw the vertices as triangle strip
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);

    // Disable the client state before leaving
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:36,代码来源:OGLChart.java

示例10: render

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
void render(GL10 gl, boolean DrawDest) {

		if (DRAW_TEXTURE && mPage.getTexturesChanged()) {
			mPage.recycle();
			reset();
		}
		// Some 'global' settings.
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

		if (DRAW_TEXTURE) {
			gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
			gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mBufTexCoords);
		}
		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mBufVertices);
		// Enable color array.
		gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
		gl.glColorPointer(4, GL10.GL_FLOAT, 0, mBufColors);
		gl.glDisable(GL10.GL_LIGHTING);
		gl.glDisable(GL10.GL_TEXTURE_2D);
		if (!DRAW_TEXTURE) {
			// inja khasiate transparent ro faAl mikonim ke betoonim too
			// CurlPage be kaaghaz alpha bedim
			gl.glEnable(GL10.GL_BLEND);
			gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
			gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, mVerticesCountFront);
		}
		// Draw front facing texture.
		if (DRAW_TEXTURE) {
			gl.glEnable(GL10.GL_BLEND);
			gl.glEnable(GL10.GL_TEXTURE_2D);
			gl.glBindTexture(GL10.GL_TEXTURE_2D, renderTex[0]);
			gl.glBlendFunc(GL10.GL_ONE_MINUS_DST_ALPHA, GL10.GL_ZERO);
			gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, mVerticesCountFront);
			gl.glDisable(GL10.GL_BLEND);
			gl.glDisable(GL10.GL_TEXTURE_2D);
		}

		int backStartIdx = Math.max(0, mVerticesCountFront - 2);
		int backCount = mVerticesCountFront + mVerticesCountBack - backStartIdx;

		// Draw back facing blank vertices.
		if (!DRAW_TEXTURE) {
			// Added At 5/6/1394
			gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
			gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, backStartIdx, backCount);
		}

		// Draw back facing texture.
		if (DRAW_TEXTURE) {
			gl.glEnable(GL10.GL_BLEND);
			gl.glEnable(GL10.GL_TEXTURE_2D);
			gl.glBindTexture(GL10.GL_TEXTURE_2D, renderTex[0]);
			// Changed with gl.glBlendFunc(GLES10.GL_SRC_ALPHA,
			// GLES10.GL_ONE_MINUS_SRC_ALPHA); At 5/6/1394
			gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
			gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, backStartIdx, backCount);
			gl.glDisable(GL10.GL_BLEND);
			gl.glDisable(GL10.GL_TEXTURE_2D);
		}

		// Disable textures and color array.
		gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
		gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
		
		if (DRAW_POLYGON_OUTLINES_FRONT) {
			gl.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
			gl.glLineWidth(3.0f);
			gl.glVertexPointer(2, GL10.GL_FLOAT, 0, mBufOutFront);
			gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, mOutFrontCount);
		}
		if (DRAW_DEST_POLY && DrawDest) {
			gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
			gl.glLineWidth(5.0f);
			gl.glVertexPointer(2, GL10.GL_FLOAT, 0, mBufDestVertices);
			gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, mDesPoly.getNumPoints());

		}

		gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
	}
 
开发者ID:AmulaySoftGroup,项目名称:TaBeTa,代码行数:82,代码来源:CurlMesh.java

示例11: applyRectTexture

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
/**
   * convert a rectangle bitmap texture and apply it to a rectangle,
   * note that order of pnts is top left -> top right -> bottom left -> bottom right
   */
  public void applyRectTexture(GL10 gl, Position3D[] pnts, int nTextureId) {    //a 4 point rectangle.

  	if (nTextureId < 0 || nTextureId >= NUMBER_OF_TEXTURES)	{
  		return;	// invalid texture
  	}
      // apply the texture
      FloatBuffer vertexBuffer;    // buffer holding the vertices
      float vertices[] = {
              (float)pnts[0].getX(), (float)pnts[0].getY(), (float)pnts[0].getZ(),    // bottom left
              (float)pnts[1].getX(), (float)pnts[1].getY(), (float)pnts[1].getZ(),    // top left
              (float)pnts[2].getX(), (float)pnts[2].getY(), (float)pnts[2].getZ(),    // bottom right
              (float)pnts[3].getX(), (float)pnts[3].getY(), (float)pnts[3].getZ(),    // top right
      };

      FloatBuffer textureBuffer;    // buffer holding the texture coordinates
      float texture[] = {           
              // Mapping coordinates for the vertices
              0.0f, 1.0f,        // top left
              0.0f, 0.0f,        // bottom left
              1.0f, 1.0f,        // top right
              1.0f, 0.0f        // bottom right
      };
      // a float has 4 bytes so we allocate for each coordinate 4 bytes
      ByteBuffer byteBuffer = ByteBuffer.allocateDirect(vertices.length * 4);
      byteBuffer.order(ByteOrder.nativeOrder());
     
      // allocates the memory from the byte buffer
      vertexBuffer = byteBuffer.asFloatBuffer();
     
      // fill the vertexBuffer with the vertices
      vertexBuffer.put(vertices);
     
      // set the cursor position to the beginning of the buffer
      vertexBuffer.position(0);
     
      byteBuffer = ByteBuffer.allocateDirect(texture.length * 4);
      byteBuffer.order(ByteOrder.nativeOrder());
      textureBuffer = byteBuffer.asFloatBuffer();
      textureBuffer.put(texture);
      textureBuffer.position(0);

// Set the face rotation
gl.glFrontFace(GL10.GL_CW);
     
      // Point to our buffers
      gl.glEnable(GL10.GL_TEXTURE_2D);            //Enable Texture Mapping ( NEW )
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
//gl.glBlendFunc(GL10.GL_ZERO, GL10.GL_ONE);
      gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
      gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
      gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);	// was GL10.GL_REPLACE
     
      //...and bind it to our array
      gl.glBindTexture(GL10.GL_TEXTURE_2D, mtextureMgr.mtextures[nTextureId]);
      
      gl.glColor4f(0f, 0f, 0f, 0f);
     
      // Point to our vertex buffer
      gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
      gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
     
      // Draw the vertices as triangle strip
      gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);

      //Disable the client state before leaving
      gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
      gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
      gl.glDisable(GL10.GL_BLEND);
      gl.glDisable(GL10.GL_TEXTURE_2D);            //Disable Texture Mapping ( NEW )
  }
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:76,代码来源:OGLChart.java


注:本文中的javax.microedition.khronos.opengles.GL10.glDrawArrays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。