本文整理汇总了Java中com.badlogic.gdx.Gdx.gl30方法的典型用法代码示例。如果您正苦于以下问题:Java Gdx.gl30方法的具体用法?Java Gdx.gl30怎么用?Java Gdx.gl30使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.Gdx
的用法示例。
在下文中一共展示了Gdx.gl30方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.badlogic.gdx.Gdx; //导入方法依赖的package包/类
public static void main(String[] args)
{
SpringApplication.run(HeadlessServerLauncher.class, args);
ServerSettings.isHeadless = true;
LwjglNativesLoader.load();
Gdx.files = new LwjglFiles();
HeadlessNativesLoader.load();
MockGraphics mockGraphics = new MockGraphics();
Gdx.graphics = mockGraphics;
HeadlessNet headlessNet = new HeadlessNet();
Gdx.net = headlessNet;
Gdx.gl = new NullGL20();
Gdx.gl20 = new NullGL20();
Gdx.gl30 = new NullGL30();
HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration();
new HeadlessApplication(new GameServer(), config);
}
示例2: generateGenericVertexShader
import com.badlogic.gdx.Gdx; //导入方法依赖的package包/类
public static String generateGenericVertexShader (int textureCount) {
boolean v3 = Gdx.gl30 != null;
String attribute = v3 ? "in" : "attribute";
String varying = v3 ? "out" : "varying";
StringBuilder sb = new StringBuilder();
if (v3) sb.append("#version 300 es\n");
sb.append(attribute).append(" vec4 ").append(ShaderProgram.POSITION_ATTRIBUTE).append(";\n");
sb.append(attribute).append(" vec4 ").append(ShaderProgram.COLOR_ATTRIBUTE).append(";\n");
for (int i = 0; i < textureCount; i++)
sb.append(attribute).append(" vec2 ").append(ShaderProgram.TEXCOORD_ATTRIBUTE).append(i).append(";\n");
sb.append("uniform mat4 u_projTrans;\n");
sb.append(varying).append(" vec4 v_color;\n");
for (int i = 0; i < textureCount; i++)
sb.append(varying).append(" vec2 v_texCoords").append(i).append(";\n\n");
sb.append("void main()\n");
sb.append("{\n");
sb.append(" v_color = ").append(ShaderProgram.COLOR_ATTRIBUTE).append(";\n");
sb.append(" v_color.a = v_color.a * (255.0/254.0);\n");
for (int i = 0; i < textureCount; i++)
sb.append(" v_texCoords").append(i).append(" = ").append(ShaderProgram.TEXCOORD_ATTRIBUTE).append(i).append(";\n");
sb.append(" gl_Position = u_projTrans * ").append(ShaderProgram.POSITION_ATTRIBUTE).append(";\n");
sb.append("}\n");
return sb.toString();
}
示例3: generateGenericFragmentShader
import com.badlogic.gdx.Gdx; //导入方法依赖的package包/类
public static String generateGenericFragmentShader (int textureCount) { // TODO default should only use first texture
boolean v3 = Gdx.gl30 != null;
String varying = v3 ? "in" : "varying";
String outColor = v3 ? "fragmentColor" : "gl_FragColor";
String tex2D = v3 ? "texture, " : "texture2D";
StringBuilder sb = new StringBuilder();
if (v3) sb.append("#version 300 es\n");
sb.append("#ifdef GL_ES\n");
sb.append("#define LOWP lowp\n");
sb.append("precision mediump float;\n");
sb.append("#else\n");
sb.append("#define LOWP \n");
sb.append("#endif\n\n");
sb.append(varying).append(" LOWP vec4 v_color;\n");
for (int i = 0; i < textureCount; i++)
sb.append(varying).append(" vec2 v_texCoords").append(i).append(";\n");
for (int i = 0; i < textureCount; i++)
sb.append("uniform sampler2D u_texture").append(i).append(";\n");
if (v3) sb.append("out LOWP vec4 ").append(outColor).append("\n");
sb.append("\n");
sb.append("void main()\n");
sb.append("{\n");
if (textureCount == 0)
sb.append(" ").append(outColor).append(" = v_color;\n");
else if (textureCount == 1)
sb.append(" ").append(outColor).append(" = v_color * texture2D(u_texture0, v_texCoords0);\n");
else {
sb.append("LOWP vec4 color = ").append(tex2D).append("(u_texture0, v_texCoords0);\n");
for (int i = 1; i < textureCount; i++)
sb.append("color += ").append(tex2D).append("(u_texture").append(i).append(", v_texCoords").append(i).append(");\n");
sb.append(" ").append(outColor).append(" = v_color * color / ").append(textureCount).append(";\n");
}
sb.append("}");
return sb.toString();
}
示例4: FlexBatch
import com.badlogic.gdx.Gdx; //导入方法依赖的package包/类
/**
* Construct a FlexBatch capable of drawing the given Batchable type and other compatible Batchables (ones with the same + *
* VertexAttributes or subset of beginning VertexAttributes). The FlexBatch will not be limited to FixedSizeBatchables.
*
* @param batchableType The type of Batchable that defines the VertexAttributes supported by this FlexBatch, and the + *
* default Batchable type drawn by the {@link #draw()} method.
* @param maxVertices The number of vertices this FlexBatch can batch at once. Maximum of 32767. If the Batchable is a
* FixedSizeBatchable and 0 is used for maxTriangles, this value will be rounded down to a multiple of the
* Batchable's size.
* @param maxTriangles The number of triangles this FlexBatch can batch at once, or 0 to optimize this FlexBatch to draw only
* FixedSizeBatchables.
*/
public FlexBatch (Class<T> batchableType, int maxVertices, int maxTriangles) {
// 32767 is max vertex index.
if (maxVertices > 32767)
throw new IllegalArgumentException("Can't have more than 32767 vertices per batch: " + maxTriangles);
if (Modifier.isAbstract(batchableType.getModifiers()))
throw new IllegalArgumentException("Can't use an abstract batchableType");
this.batchableType = batchableType;
try {
internalBatchable = batchableType.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException("Batchable classes must be public and have an empty constructor.", e);
}
Array<VertexAttribute> attributesArray = new Array<VertexAttribute>(true, 10, VertexAttribute.class);
internalBatchable.addVertexAttributes(attributesArray);
VertexAttributes vertexAttributes = new VertexAttributes(attributesArray.toArray());
attributeOffsets = new AttributeOffsets(vertexAttributes);
vertexSize = vertexAttributes.vertexSize / 4;
final int vertexArraySize = vertexSize * maxVertices;
vertices = new float[vertexArraySize];
fixedIndices = internalBatchable instanceof FixedSizeBatchable && maxTriangles == 0;
if (fixedIndices) {
FixedSizeBatchable fixedSizeBatchable = (FixedSizeBatchable) internalBatchable;
verticesPerBatchable = fixedSizeBatchable.getVerticesPerBatchable();
vertexDataPerBatchable = verticesPerBatchable * vertexSize;
this.maxVertices = maxVertices - (maxVertices % verticesPerBatchable);
this.maxIndices = (this.maxVertices / verticesPerBatchable) * fixedSizeBatchable.getTrianglesPerBatchable() * 3;
indicesPerBatchable = fixedSizeBatchable.getTrianglesPerBatchable() * 3;
triangles = new short[maxIndices];
fixedSizeBatchable.populateTriangleIndices(triangles);
} else {
if (maxTriangles == 0) throw new IllegalArgumentException(
"maxTriangles must be greater than 0 if batchableType is not a FixedSizeBatchable");
this.maxVertices = maxVertices;
maxIndices = maxTriangles * 3;
triangles = new short[maxIndices];
indicesPerBatchable = verticesPerBatchable = vertexDataPerBatchable = 0;
}
Mesh.VertexDataType vertexDataType = Gdx.gl30 != null ? VertexDataType.VertexBufferObjectWithVAO
: Mesh.VertexDataType.VertexArray;
mesh = new Mesh(vertexDataType, false, this.maxVertices, maxIndices, attributesArray.toArray());
if (fixedIndices) mesh.setIndices(triangles);
textureUnitUniforms = new String[internalBatchable.getNumberOfTextures()];
for (int i = 0; i < textureUnitUniforms.length; i++) {
;
textureUnitUniforms[i] = "u_texture" + i;
}
projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
renderContext = new RenderContextAccumulator();
renderContext.setBlending(true);
renderContext.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}