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


Java ShaderProgram.COLOR_ATTRIBUTE属性代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.glutils.ShaderProgram.COLOR_ATTRIBUTE属性的典型用法代码示例。如果您正苦于以下问题:Java ShaderProgram.COLOR_ATTRIBUTE属性的具体用法?Java ShaderProgram.COLOR_ATTRIBUTE怎么用?Java ShaderProgram.COLOR_ATTRIBUTE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.badlogic.gdx.graphics.glutils.ShaderProgram的用法示例。


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

示例1: FontBatch

/** 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,代码行数:45,代码来源:FontBatch.java

示例2: createDefaultShader

/** Returns a new instance of the default shader used by SpriteBatch for GL2 when no shader is specified. */
static public ShaderProgram createDefaultShader () {
	String vertexShader = "attribute vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" //
		+ "attribute vec4 " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" //
		+ "attribute vec2 " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" //
		+ "uniform mat4 u_projTrans;\n" //
		+ "varying vec4 v_color;\n" //
		+ "varying vec2 v_texCoords;\n" //
		+ "\n" //
		+ "void main()\n" //
		+ "{\n" //
		+ "   v_color = " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" //
		+ "   v_color.a = v_color.a * (255.0/254.0);\n" //
		+ "   v_texCoords = " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" //
		+ "   gl_Position =  u_projTrans * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" //
		+ "}\n";
	String fragmentShader = "#ifdef GL_ES\n" //
		+ "#define LOWP lowp\n" //
		+ "precision mediump float;\n" //
		+ "#else\n" //
		+ "#define LOWP \n" //
		+ "#endif\n" //
		+ "varying LOWP 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" //
		+ "}";

	ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader);
	if (shader.isCompiled() == false) throw new IllegalArgumentException("Error compiling shader: " + shader.getLog());
	return shader;
}
 
开发者ID:Osaris31,项目名称:exterminate,代码行数:34,代码来源:FontBatch.java

示例3: ColorPacked

public static VertexAttribute ColorPacked () {
	return new VertexAttribute(Usage.ColorPacked, 4, GL20.GL_UNSIGNED_BYTE, true, ShaderProgram.COLOR_ATTRIBUTE);
}
 
开发者ID:Osaris31,项目名称:exterminate,代码行数:3,代码来源:VertexAttribute.java

示例4: ColorUnpacked

public static VertexAttribute ColorUnpacked () {
	return new VertexAttribute(Usage.ColorUnpacked, 4, GL20.GL_FLOAT, false, ShaderProgram.COLOR_ATTRIBUTE);
}
 
开发者ID:Osaris31,项目名称:exterminate,代码行数:3,代码来源:VertexAttribute.java


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