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


Java Usage.ColorPacked方法代碼示例

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


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

示例1: PositionalLight

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
public PositionalLight (RayHandler rayHandler, int rays, Color color, float distance, float x, float y, float directionDegree) {
	super(rayHandler, rays, color, directionDegree, distance);
	start.x = x;
	start.y = y;
	sin = new float[rays];
	cos = new float[rays];
	endX = new float[rays];
	endY = new float[rays];

	lightMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
		"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	softShadowMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum * 2, 0, new VertexAttribute(Usage.Position, 2,
		"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	setMesh();
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:18,代碼來源:PositionalLight.java

示例2: DirectionalLight

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** Directional lights simulate light source that locations is at infinite distance. Direction and intensity is same everywhere.
 * -90 direction is straight from up.
 * 
 * @param rayHandler
 * @param rays
 * @param color
 * @param directionDegree */
public DirectionalLight (RayHandler rayHandler, int rays, Color color, float directionDegree) {

	super(rayHandler, rays, color, directionDegree, Float.POSITIVE_INFINITY);

	vertexNum = (vertexNum - 1) * 2;

	start = new Vector2[rayNum];
	end = new Vector2[rayNum];
	for (int i = 0; i < rayNum; i++) {
		start[i] = new Vector2();
		end[i] = new Vector2();
	}
	setDirection(direction);

	lightMesh = new Mesh(VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
		"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	softShadowMesh = new Mesh(VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
		"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	update();
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:30,代碼來源:DirectionalLight.java

示例3: RavChainLight

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** Creates chain light from specified vertices
 * 
 * @param rayHandler not {@code null} instance of RayHandler
 * @param rays number of rays - more rays make light to look more realistic but will decrease performance, can't be less than
 *           MIN_RAYS
 * @param color color, set to {@code null} to use the default color
 * @param distance distance of light
 * @param rayDirection direction of rays
 *           <ul>
 *           <li>1 = left</li>
 *           <li>-1 = right</li>
 *           </ul>
 * @param chain float array of (x, y) vertices from which rays will be evenly distributed */
public RavChainLight (RayHandler rayHandler, int rays, Color color, float distance, int rayDirection, float[] chain) {
	super(rayHandler, rays, color, distance, 0f);

	rayStartOffset = ChainLight.defaultRayStartOffset;
	this.rayDirection = rayDirection;
	vertexNum = (vertexNum - 1) * 2;
	endX = new float[rays];
	endY = new float[rays];
	startX = new float[rays];
	startY = new float[rays];
	this.chain = (chain != null) ? new FloatArray(chain) : new FloatArray();

	lightMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum, 0,
		new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	softShadowMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum * 2, 0,
		new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	setMesh();
}
 
開發者ID:Quexten,項目名稱:RavTech,代碼行數:34,代碼來源:RavChainLight.java

示例4: createAttributes

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal and
 *           TextureCoordinates is supported. */
public static VertexAttributes createAttributes (long usage) {
	final Array<VertexAttribute> attrs = new Array<VertexAttribute>();
	if ((usage & Usage.Position) == Usage.Position)
		attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
	if ((usage & Usage.Color) == Usage.Color) attrs.add(new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE));
	if ((usage & Usage.ColorPacked) == Usage.ColorPacked)
		attrs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
	if ((usage & Usage.Normal) == Usage.Normal)
		attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
	if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates)
		attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
	final VertexAttribute attributes[] = new VertexAttribute[attrs.size];
	for (int i = 0; i < attributes.length; i++)
		attributes[i] = attrs.get(i);
	return new VertexAttributes(attributes);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:19,代碼來源:MeshBuilder.java

示例5: PolygonSpriteBatch

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** Constructs a new PolygonSpriteBatch. Sets the projection matrix to an orthographic projection with y-axis point upwards,
 * x-axis point to the right and the origin being in the bottom left corner of the screen. The projection will be pixel perfect
 * with respect to the current screen resolution.
 * <p>
 * The defaultShader specifies the shader to use. Note that the names for uniforms for this default shader are different than
 * the ones expect for shaders set with {@link #setShader(ShaderProgram)}. See {@link SpriteBatch#createDefaultShader()}.
 * @param size The max number of vertices and number of triangles in a single batch. Max of 10920.
 * @param defaultShader The default shader to use. This is not owned by the PolygonSpriteBatch and must be disposed separately. */
public PolygonSpriteBatch (int size, ShaderProgram defaultShader) {
	// 32767 is max index, so 32767 / 3 - (32767 / 3 % 3) = 10920.
	if (size > 10920) throw new IllegalArgumentException("Can't have more than 10920 triangles per batch: " + size);

	mesh = new Mesh(VertexDataType.VertexArray, false, size, size * 3, new VertexAttribute(Usage.Position, 2,
		ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
		new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

	vertices = new float[size * VERTEX_SIZE];
	triangles = new short[size * 3];

	if (defaultShader == null) {
		shader = SpriteBatch.createDefaultShader();
		ownsShader = true;
	} else
		shader = defaultShader;

	projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:28,代碼來源:PolygonSpriteBatch.java

示例6: create

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
@Override
public void create () {
	mesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(Usage.ColorPacked, 4,
		"a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
	float c1 = Color.toFloatBits(255, 0, 0, 255);
	float c2 = Color.toFloatBits(255, 0, 0, 255);
	float c3 = Color.toFloatBits(0, 0, 255, 255);

	mesh.setVertices(new float[] {-0.5f, -0.5f, 0, c1, 0, 0, 0.5f, -0.5f, 0, c2, 1, 0, 0, 0.5f, 0, c3, 0.5f, 1});

	stencilMesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(
		Usage.ColorPacked, 4, "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
	stencilMesh.setVertices(new float[] {-0.5f, 0.5f, 0, c1, 0, 0, 0.5f, 0.5f, 0, c2, 1, 0, 0, -0.5f, 0, c3, 0.5f, 1});

	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));

	spriteBatch = new SpriteBatch();
	frameBuffer = new FrameBuffer(Format.RGB565, 128, 128, false);
	stencilFrameBuffer = new FrameBuffer(Format.RGB565, 128, 128, false, true);
	createShader(Gdx.graphics);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:22,代碼來源:FrameBufferTest.java

示例7: init

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
private void init(String tex0, float w, float h) {
    setTexture0(tex0);

    // Init comparator
    comp = new DistToCameraComparator<IRenderable>();
    // Init vertices
    float[] vertices = new float[20];
    fillVertices(vertices, w, h);

    // We wont need indices if we use GL_TRIANGLE_FAN to draw our quad
    // TRIANGLE_FAN will draw the verts in this order: 0, 1, 2; 0, 2, 3
    mesh = new Mesh(VertexDataType.VertexArray, true, 4, 6, new VertexAttribute(Usage.Position, 2, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE), new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

    mesh.setVertices(vertices, 0, vertices.length);
    mesh.getIndicesBuffer().position(0);
    mesh.getIndicesBuffer().limit(6);

    short[] indices = new short[] { 0, 1, 2, 0, 2, 3 };
    mesh.setIndices(indices);

    quaternion = new Quaternion();
    aux = new Vector3();

}
 
開發者ID:langurmonkey,項目名稱:gaiasky,代碼行數:25,代碼來源:BillboardStarRenderSystem.java

示例8: init

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
private void init(float w, float h) {
    // Init comparator
    comp = new DistToCameraComparator<IRenderable>();
    // Init vertices
    float[] vertices = new float[20];
    fillVertices(vertices, w, h);

    // We wont need indices if we use GL_TRIANGLE_FAN to draw our quad
    // TRIANGLE_FAN will draw the verts in this order: 0, 1, 2; 0, 2, 3
    mesh = new Mesh(VertexDataType.VertexArray, true, 4, 6, new VertexAttribute(Usage.Position, 2, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE), new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

    mesh.setVertices(vertices, 0, vertices.length);
    mesh.getIndicesBuffer().position(0);
    mesh.getIndicesBuffer().limit(6);

    short[] indices = new short[] { 0, 1, 2, 0, 2, 3 };
    mesh.setIndices(indices);

    quaternion = new Quaternion();
    aux = new Vector3();

}
 
開發者ID:langurmonkey,項目名稱:gaiasky,代碼行數:23,代碼來源:BillboardSpriteRenderSystem.java

示例9: createAttributes

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal and
 *           TextureCoordinates is supported. */
public static VertexAttributes createAttributes(long usage) {
    final Array<VertexAttribute> attrs = new Array<VertexAttribute>();
    if ((usage & Usage.Position) == Usage.Position)
        attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
    if ((usage & Usage.ColorUnpacked) == Usage.ColorUnpacked)
        attrs.add(new VertexAttribute(Usage.ColorUnpacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
    if ((usage & Usage.ColorPacked) == Usage.ColorPacked)
        attrs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
    if ((usage & Usage.Normal) == Usage.Normal)
        attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
    if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates)
        attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
    final VertexAttribute attributes[] = new VertexAttribute[attrs.size];
    for (int i = 0; i < attributes.length; i++)
        attributes[i] = attrs.get(i);
    return new VertexAttributes(attributes);
}
 
開發者ID:langurmonkey,項目名稱:gaiasky,代碼行數:20,代碼來源:MeshBuilder2.java

示例10: DrawingBatch

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/**
 * Create a new DrawingBatch
 *
 * @param size          - the size of the batch
 * @param shader        - the shader program to use
 * @param disposeShader - should the batch dispose the shader when it disposes
 */
public DrawingBatch(int size, ShaderProgram shader, boolean disposeShader) {
    //8191 max size
    if (size > 8191) throw new IllegalArgumentException("Can't have more than 8191 sprites per batch: " + size);
    
    this.shader = shader;
    this.disposeShader = disposeShader;
    
    //aliases reference variables in basic.vertex.glsl
    mesh = new Mesh(false, size * 4, size * 6,
                    new VertexAttribute(Usage.Position, 2, "a_position"),
                    new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0"),
                    new VertexAttribute(Usage.ColorPacked, 4, "a_multTint"),
                    new VertexAttribute(Usage.ColorPacked, 4, "a_addTint"));
    
    //4 bytes per type @ 2 vals per position, 1 val per color, 2 val per coordinate, and 2 vals for both tints together
    verticies = new float[size * (4 * (2 + 2 + 1 + 1))];
    
    int     len     = size * 6;
    short[] indices = new short[len];
    short   j       = 0;
    for (int i = 0; i < len; i += 6, j += 4) {
        indices[i] = j;
        indices[i + 1] = (short) (j + 1);
        indices[i + 2] = (short) (j + 2);
        indices[i + 3] = (short) (j + 2);
        indices[i + 4] = (short) (j + 3);
        indices[i + 5] = j;
    }
    mesh.setIndices(indices);
}
 
開發者ID:SergeySave,項目名稱:SpaceGame,代碼行數:38,代碼來源:DrawingBatch.java

示例11: ChainLight

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/**
 * Creates chain light from specified vertices
 * 
 * @param rayHandler
 *            not {@code null} instance of RayHandler
 * @param rays
 *            number of rays - more rays make light to look more realistic
 *            but will decrease performance, can't be less than MIN_RAYS
 * @param color
 *            color, set to {@code null} to use the default color
 * @param distance
 *            distance of light
 * @param rayDirection
 *            direction of rays
 *            <ul>
 *            <li>1 = left</li>
 *            <li>-1 = right</li>
 *            </ul>
 * @param chain
 *            float array of (x, y) vertices from which rays will be
 *            evenly distributed
 */
public ChainLight(RayHandler rayHandler, int rays, Color color,
		float distance, int rayDirection, float[] chain) {
	
	super(rayHandler, rays, color, distance, 0f);
	rayStartOffset = ChainLight.defaultRayStartOffset;
	this.rayDirection = rayDirection;
	vertexNum = (vertexNum - 1) * 2;
	endX = new float[rays];
	endY = new float[rays];
	startX = new float[rays];
	startY = new float[rays];
	this.chain = (chain != null) ?
				 new FloatArray(chain) : new FloatArray();
	
	lightMesh = new Mesh(
			VertexDataType.VertexArray, false, vertexNum, 0,
			new VertexAttribute(Usage.Position, 2, "vertex_positions"),
			new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
			new VertexAttribute(Usage.Generic, 1, "s"));
	softShadowMesh = new Mesh(
			VertexDataType.VertexArray, false, vertexNum * 2,
			0, new VertexAttribute(Usage.Position, 2, "vertex_positions"),
			new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
			new VertexAttribute(Usage.Generic, 1, "s"));
	setMesh();
}
 
開發者ID:bitbrain,項目名稱:rbcgj-2016,代碼行數:49,代碼來源:ChainLight.java

示例12: DirectionalLight

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/**
 * Creates directional light which source is at infinite distance,
 * direction and intensity is same everywhere
 * 
 * <p>-90 direction is straight from up
 * 
 * @param rayHandler
 *            not {@code null} instance of RayHandler
 * @param rays
 *            number of rays - more rays make light to look more realistic
 *            but will decrease performance, can't be less than MIN_RAYS
 * @param color
 *            color, set to {@code null} to use the default color
 * @param directionDegree
 *            direction in degrees
 */
public DirectionalLight(RayHandler rayHandler, int rays, Color color,
		float directionDegree) {
	
	super(rayHandler, rays, color, Float.POSITIVE_INFINITY, directionDegree);
	
	vertexNum = (vertexNum - 1) * 2;
	start = new Vector2[rayNum];
	end = new Vector2[rayNum];
	for (int i = 0; i < rayNum; i++) {
		start[i] = new Vector2();
		end[i] = new Vector2();
	}
	
	lightMesh = new Mesh(
			VertexDataType.VertexArray, staticLight, vertexNum, 0,
			new VertexAttribute(Usage.Position, 2, "vertex_positions"),
			new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
			new VertexAttribute(Usage.Generic, 1, "s"));
	softShadowMesh = new Mesh(
			VertexDataType.VertexArray, staticLight, vertexNum, 0,
			new VertexAttribute(Usage.Position, 2, "vertex_positions"),
			new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
			new VertexAttribute(Usage.Generic, 1, "s"));
	
	update();
}
 
開發者ID:bitbrain,項目名稱:rbcgj-2016,代碼行數:43,代碼來源:DirectionalLight.java

示例13: FontBatch

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** Constructs a new SpriteBatch. Sets the projection matrix to an orthographic projection with y-axis point upwards, x-axis
 * point to the right and the origin being in the bottom left corner of the screen. The projection will be pixel perfect with
 * respect to the current screen resolution.
 * <p>
 * The defaultShader specifies the shader to use. Note that the names for uniforms for this default shader are different than
 * the ones expect for shaders set with {@link #setShader(ShaderProgram)}. See {@link #createDefaultShader()}.
 * @param size The max number of sprites in a single batch. Max of 5460.
 * @param defaultShader The default shader to use. This is not owned by the SpriteBatch and must be disposed separately. */
public FontBatch (int size, ShaderProgram defaultShader) {
	this.vertexsize = size;
	size = 1000;
	// 32767 is max index, so 32767 / 6 - (32767 / 6 % 3) = 5460.
	if (size > 5460) throw new IllegalArgumentException("Can't have more than 5460 sprites per batch: " + size);

	Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexArray;
	if (Gdx.gl30 != null) {
		vertexDataType = Mesh.VertexDataType.VertexBufferObjectWithVAO;
	}
	mesh = new Mesh(vertexDataType, false, size * 4, size * 6, new VertexAttribute(Usage.Position, vertexsize-3,
		ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
		new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

	projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

	vertices = new float[size * 4*vertexsize];

	int len = size * 6;
	short[] indices = new short[len];
	short j = 0;
	for (int i = 0; i < len; i += 6, j += 4) {
		indices[i] = j;
		indices[i + 1] = (short)(j + 1);
		indices[i + 2] = (short)(j + 2);
		indices[i + 3] = (short)(j + 2);
		indices[i + 4] = (short)(j + 3);
		indices[i + 5] = j;
	}
	mesh.setIndices(indices);

	if (defaultShader == null) {
		shader = createDefaultShader();
		ownsShader = true;
	} else
		shader = defaultShader;
}
 
開發者ID:Osaris31,項目名稱:exterminate,代碼行數:46,代碼來源:FontBatch.java

示例14: SpriteBatch

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** Constructs a new SpriteBatch. Sets the projection matrix to an orthographic projection with y-axis point upwards, x-axis
 * point to the right and the origin being in the bottom left corner of the screen. The projection will be pixel perfect with
 * respect to the current screen resolution.
 * <p>
 * The defaultShader specifies the shader to use. Note that the names for uniforms for this default shader are different than
 * the ones expect for shaders set with {@link #setShader(ShaderProgram)}. See {@link #createDefaultShader()}.
 * @param size The max number of sprites in a single batch. Max of 5460.
 * @param defaultShader The default shader to use. This is not owned by the SpriteBatch and must be disposed separately. */
public SpriteBatch (int size, ShaderProgram defaultShader) {
	// 32767 is max index, so 32767 / 6 - (32767 / 6 % 3) = 5460.
	if (size > 5460) throw new IllegalArgumentException("Can't have more than 5460 sprites per batch: " + size);

	mesh = new Mesh(VertexDataType.VertexArray, false, size * 4, size * 6, new VertexAttribute(Usage.Position, 2,
		ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
		new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

	projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

	vertices = new float[size * Sprite.SPRITE_SIZE];

	int len = size * 6;
	short[] indices = new short[len];
	short j = 0;
	for (int i = 0; i < len; i += 6, j += 4) {
		indices[i] = j;
		indices[i + 1] = (short)(j + 1);
		indices[i + 2] = (short)(j + 2);
		indices[i + 3] = (short)(j + 2);
		indices[i + 4] = (short)(j + 3);
		indices[i + 5] = j;
	}
	mesh.setIndices(indices);

	if (defaultShader == null) {
		shader = createDefaultShader();
		ownsShader = true;
	} else
		shader = defaultShader;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:40,代碼來源:SpriteBatch.java

示例15: SpriteCache

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入方法依賴的package包/類
/** Creates a cache with the specified size and OpenGL ES 2.0 shader.
 * @param size The maximum number of images this cache can hold. The memory required to hold the images is allocated up front.
 *           Max of 5460 if indices are used.
 * @param useIndices If true, indexed geometry will be used. */
public SpriteCache (int size, ShaderProgram shader, boolean useIndices) {
	this.shader = shader;

	if (useIndices && size > 5460) throw new IllegalArgumentException("Can't have more than 5460 sprites per batch: " + size);

	mesh = new Mesh(true, size * (useIndices ? 4 : 6), useIndices ? size * 6 : 0, new VertexAttribute(Usage.Position, 2,
		ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
		new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
	mesh.setAutoBind(false);

	if (useIndices) {
		int length = size * 6;
		short[] indices = new short[length];
		short j = 0;
		for (int i = 0; i < length; i += 6, j += 4) {
			indices[i + 0] = (short)j;
			indices[i + 1] = (short)(j + 1);
			indices[i + 2] = (short)(j + 2);
			indices[i + 3] = (short)(j + 2);
			indices[i + 4] = (short)(j + 3);
			indices[i + 5] = (short)j;
		}
		mesh.setIndices(indices);
	}

	projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:32,代碼來源:SpriteCache.java


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