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


Java IndexBufferObject.setIndices方法代碼示例

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


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

示例1: create

import com.badlogic.gdx.graphics.glutils.IndexBufferObject; //導入方法依賴的package包/類
@Override
public void create () {
	String vertexShader = "attribute vec4 a_position;    \n" + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoords;\n"
		+ "varying vec4 v_color;" + "varying vec2 v_texCoords;" + "void main()                  \n"
		+ "{                            \n" + "   v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n"
		+ "   v_texCoords = a_texCoords; \n" + "   gl_Position =  a_position;  \n" + "}                            \n";
	String fragmentShader = "#ifdef GL_ES\n" + "precision mediump float;\n" + "#endif\n" + "varying vec4 v_color;\n"
		+ "varying vec2 v_texCoords;\n" + "uniform sampler2D u_texture;\n" + "void main()                                  \n"
		+ "{                                            \n" + "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n"
		+ "}";

	shader = new ShaderProgram(vertexShader, fragmentShader);
	vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_position"),
		new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"), new VertexAttribute(
			VertexAttributes.Usage.ColorPacked, 4, "a_color"));
	float[] vertices = new float[] {-1, -1, 0, 0, Color.toFloatBits(1f, 0f, 0f, 1f), 0, 1, 0.5f, 1.0f,
		Color.toFloatBits(0f, 1f, 0f, 1f), 1, -1, 1, 0, Color.toFloatBits(0f, 0f, 1f, 1f)};
	vbo.setVertices(vertices, 0, vertices.length);

	ibo = new IndexBufferObject(true, 3);
	ibo.setIndices(new short[] {0, 1, 2}, 0, 3);

	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:25,代碼來源:IndexBufferObjectShaderTest.java

示例2: createIndexBuffer

import com.badlogic.gdx.graphics.glutils.IndexBufferObject; //導入方法依賴的package包/類
private static IndexBufferObject createIndexBuffer(int paramInt)
{
  short[] arrayOfShort = new short[paramInt];
  int i = 0;
  for (int j = 0; i < paramInt; j = (short)(j + 4))
  {
    arrayOfShort[(i + 0)] = ((short)(j + 0));
    arrayOfShort[(i + 1)] = ((short)(j + 1));
    arrayOfShort[(i + 2)] = ((short)(j + 2));
    arrayOfShort[(i + 3)] = ((short)(j + 2));
    arrayOfShort[(i + 4)] = ((short)(j + 3));
    arrayOfShort[(i + 5)] = ((short)(j + 0));
    i += 6;
  }
  IndexBufferObject localIndexBufferObject = new IndexBufferObject(true, paramInt);
  localIndexBufferObject.setIndices(arrayOfShort, 0, paramInt);
  return localIndexBufferObject;
}
 
開發者ID:isnuryusuf,項目名稱:ingress-indonesia-dev,代碼行數:19,代碼來源:SpriteBatch.java

示例3: create

import com.badlogic.gdx.graphics.glutils.IndexBufferObject; //導入方法依賴的package包/類
@Override
public void create () {
	//@off
	String vertexShader = 
		  "attribute vec4 a_position;    \n"
		+ "attribute vec4 a_color;\n"
		+ "attribute vec2 a_texCoords;\n"
		+ "varying vec4 v_color;"
		+ "varying vec2 v_texCoords;" + "void main()                  \n"
		+ "{                            \n"
		+ "   v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n"
		+ "   v_texCoords = a_texCoords; \n"
		+ "   gl_Position =  a_position;  \n"
		+ "}                            \n";
	String fragmentShader = 
		  "#ifdef GL_ES\n"
		+ "precision mediump float;\n"
		+ "#endif\n" 
		+ "varying vec4 v_color;\n"
		+ "varying vec2 v_texCoords;\n" 
		+ "uniform sampler2D u_texture;\n" 
		+ "void main()                                  \n"
		+ "{                                            \n" 
		+ "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n"
		+ "}";
	//@on

	shader = new ShaderProgram(vertexShader, fragmentShader);
	vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_position"),
		new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"), new VertexAttribute(
			VertexAttributes.Usage.ColorPacked, 4, "a_color"));
	float[] vertices = new float[] {-1, -1, 0, 0, Color.toFloatBits(1f, 0f, 0f, 1f), 0, 1, 0.5f, 1.0f,
		Color.toFloatBits(0f, 1f, 0f, 1f), 1, -1, 1, 0, Color.toFloatBits(0f, 0f, 1f, 1f)};
	vbo.setVertices(vertices, 0, vertices.length);
	indices = new IndexBufferObject(3);
	indices.setIndices(new short[] {0, 1, 2}, 0, 3);

	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:40,代碼來源:VertexBufferObjectShaderTest.java

示例4: a

import com.badlogic.gdx.graphics.glutils.IndexBufferObject; //導入方法依賴的package包/類
private static IndexBufferObject a(short[] paramArrayOfShort)
{
  if (paramArrayOfShort == null)
    return null;
  IndexBufferObject localIndexBufferObject = new IndexBufferObject(paramArrayOfShort.length);
  localIndexBufferObject.setIndices(paramArrayOfShort, 0, paramArrayOfShort.length);
  return localIndexBufferObject;
}
 
開發者ID:isnuryusuf,項目名稱:ingress-indonesia-dev,代碼行數:9,代碼來源:ai.java


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