本文整理匯總了Java中com.badlogic.gdx.graphics.VertexAttribute.ColorUnpacked方法的典型用法代碼示例。如果您正苦於以下問題:Java VertexAttribute.ColorUnpacked方法的具體用法?Java VertexAttribute.ColorUnpacked怎麽用?Java VertexAttribute.ColorUnpacked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.VertexAttribute
的用法示例。
在下文中一共展示了VertexAttribute.ColorUnpacked方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import com.badlogic.gdx.graphics.VertexAttribute; //導入方法依賴的package包/類
@Override
public void create () {
String vertexShader = "attribute vec4 a_position; \n" + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoord0;\n"
+ "uniform mat4 u_worldView;\n" + "varying vec4 v_color;" + "varying vec2 v_texCoords;"
+ "void main() \n" + "{ \n" + " v_color = vec4(1, 1, 1, 1); \n"
+ " v_texCoords = a_texCoord0; \n" + " gl_Position = u_worldView * 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);
if (shader.isCompiled() == false) {
Gdx.app.log("ShaderTest", shader.getLog());
Gdx.app.exit();
}
mesh = new Mesh(true, 4, 6, VertexAttribute.Position(), VertexAttribute.ColorUnpacked(), VertexAttribute.TexCoords(0));
mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 1, 1, 1, 1, 0, 1, 0.5f, -0.5f, 0, 1, 1, 1, 1, 1, 1, 0.5f, 0.5f, 0, 1, 1, 1,
1, 1, 0, -0.5f, 0.5f, 0, 1, 1, 1, 1, 0, 0});
mesh.setIndices(new short[] {0, 1, 2, 2, 3, 0});
texture = new Texture(Gdx.files.internal("data/bobrgb888-32x32.png"));
}
示例2: setupMesh
import com.badlogic.gdx.graphics.VertexAttribute; //導入方法依賴的package包/類
private void setupMesh(Model model, MaterialTileMapping textures) {
int numVertices = countModelVertices(model);
vertices = new Vertices(
numVertices,
VertexAttribute.Position(),
VertexAttribute.ColorUnpacked(),
VertexAttribute.Normal(),
VertexAttribute.TexCoords(0)
);
model.calculateBoundingBox(tmpModelBounds);
if (scaleToSize != null) {
MathHelpers.getScaleFactor(tmpModelBounds.getDimensions(), scaleToSize, tmpScaleFactor);
bounds = new BoundingBox().set(Vector3.Zero, scaleToSize);
} else {
bounds = new BoundingBox().set(Vector3.Zero, tmpModelBounds.getDimensions());
tmpScaleFactor.set(1.0f, 1.0f, 1.0f);
}
for (int i = 0; i < model.nodes.size; ++i)
collectModelNodeVertices(model.nodes.get(i), vertices, textures, color, tmpScaleFactor, positionOffset);
}
示例3: Sunburst
import com.badlogic.gdx.graphics.VertexAttribute; //導入方法依賴的package包/類
public Sunburst(Stage stage) {
this.setX(stage.getWidth() / 2);
this.setY(stage.getHeight() / 2);
String vertexShader = "attribute vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" //
+ "attribute vec4 " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" //
+ "uniform mat4 u_transformMatrix;\n" //
+ "uniform mat4 u_projectionViewMatrix;\n" //
+ "varying vec4 v_color;\n" //
+ "\n" //
+ "void main()\n" //
+ "{\n" //
+ " v_color = " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" //
+ " gl_Position = u_transformMatrix * u_projectionViewMatrix * " + 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" //
+ "void main()\n"//
+ "{\n" //
+ " gl_FragColor = v_color;\n" //
+ "}";
shader = new ShaderProgram(vertexShader, fragmentShader);
float radius = stage.getWidth();
int i = 0;
float[] vertices = new float[378];
for (int angle = 0; angle < 360; angle += 20) {
i = makePoint(radius, i, vertices, angle);
i = makePoint(radius, i, vertices, angle + 10);
vertices[i++] = getX();
vertices[i++] = getY();
vertices[i++] = 0f;
vertices[i++] = 0f;
vertices[i++] = 0f;
vertices[i++] = 0.5f;
vertices[i++] = 0f;
}
mesh = new Mesh(true, vertices.length, 0, VertexAttribute.Position(), VertexAttribute.ColorUnpacked());
mesh.setVertices(vertices);
transformMatrix = new Matrix4();
}