本文整理汇总了Java中com.badlogic.gdx.utils.BufferUtils.newFloatBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java BufferUtils.newFloatBuffer方法的具体用法?Java BufferUtils.newFloatBuffer怎么用?Java BufferUtils.newFloatBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.BufferUtils
的用法示例。
在下文中一共展示了BufferUtils.newFloatBuffer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getScissorRect
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/**
* Get the current scissor rectangle
*/
public Rect getScissorRect() {
if(!Engine.instance().isGLThread()) {
// 不能在非gl线程中访问
CCLog.error(TAG, "GLThread error");
return null;
}
FloatBuffer fb = BufferUtils.newFloatBuffer(16); //4 * 4
Gdx.gl.glGetFloatv(GL20.GL_SCISSOR_BOX, fb);
float[] params = new float[4];
fb.get(params);
float x = (params[0] - _viewPortRect.x) / _scaleX;
float y = (params[1] - _viewPortRect.y) / _scaleY;
float w = params[2] / _scaleX;
float h = params[3] / _scaleY;
return (Rect) poolRect.set(x, y, w, h);
}
示例2: isSupported
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/**
* @return Whether the device supports anisotropic filtering.
*/
public static boolean isSupported () {
GL20 gl = Gdx.gl;
if (gl != null) {
if (Gdx.graphics.supportsExtension("GL_EXT_texture_filter_anisotropic")) {
anisotropySupported = true;
FloatBuffer buffer = BufferUtils.newFloatBuffer(16);
buffer.position(0);
buffer.limit(buffer.capacity());
Gdx.gl20.glGetFloatv(GL20.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, buffer);
maxAnisotropySupported = buffer.get(0);
}
checkComplete = true;
}
return anisotropySupported;
}
示例3: ShaderProgram
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Constructs a new ShaderProgram and immediately compiles it.
*
* @param vertexShader the vertex shader
* @param fragmentShader the fragment shader */
public ShaderProgram (String vertexShader, String fragmentShader) {
if (vertexShader == null) throw new IllegalArgumentException("vertex shader must not be null");
if (fragmentShader == null) throw new IllegalArgumentException("fragment shader must not be null");
this.vertexShaderSource = vertexShader;
this.fragmentShaderSource = fragmentShader;
this.matrix = BufferUtils.newFloatBuffer(16);
compileShaders(vertexShader, fragmentShader);
if (isCompiled()) {
fetchAttributes();
fetchUniforms();
addManagedShader(Gdx.app, this);
}
}
示例4: ShaderProgram
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public ShaderProgram(String paramString1, String paramString2)
{
if (paramString1 == null)
throw new IllegalArgumentException("vertex shader must not be null");
if (paramString2 == null)
throw new IllegalArgumentException("fragment shader must not be null");
this.vertexShaderSource = paramString1;
this.fragmentShaderSource = paramString2;
this.matrix = BufferUtils.newFloatBuffer(16);
compileShaders(paramString1, paramString2);
if (isCompiled())
{
fetchAttributes();
fetchUniforms();
addManagedShader(Gdx.app, this);
}
}
示例5: VertexBufferObject
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Constructs a new interleaved VertexBufferObject.
*
* @param isStatic whether the vertex data is static.
* @param numVertices the maximum number of vertices
* @param attributes the {@link VertexAttributes}. */
public VertexBufferObject (boolean isStatic, int numVertices, VertexAttributes attributes) {
this.isStatic = isStatic;
this.attributes = attributes;
buffer = BufferUtils.newFloatBuffer(this.attributes.vertexSize / 4 * numVertices);
buffer.flip();
bufferHandle = Gdx.gl20.glGenBuffer();
usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW;
}
示例6: benchFloat
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
private void benchFloat () {
FloatBuffer fb = BufferUtils.newFloatBuffer(1024 * 1024 / 4);
float[] floats = new float[1024 * 1024 / 4];
int len = floats.length;
// relative put
long start = TimeUtils.nanoTime();
for (int j = 0; j < NUM_MB; j++) {
fb.clear();
for (int i = 0; i < len; i++)
fb.put(floats[i]);
}
Gdx.app.log("BufferUtilsTest", "FloatBuffer relative put: " + (TimeUtils.nanoTime() - start) / 1000000000.0f);
// absolute put
start = TimeUtils.nanoTime();
for (int j = 0; j < NUM_MB; j++) {
fb.clear();
for (int i = 0; i < len; i++)
fb.put(i, floats[i]);
}
Gdx.app.log("BufferUtilsTest", "FloatBuffer absolute put: " + (TimeUtils.nanoTime() - start) / 1000000000.0f);
// bulk put
start = TimeUtils.nanoTime();
for (int j = 0; j < NUM_MB; j++) {
fb.clear();
fb.put(floats);
}
Gdx.app.log("BufferUtilsTest", "FloatBuffer bulk put: " + (TimeUtils.nanoTime() - start) / 1000000000.0f);
// JNI put
start = TimeUtils.nanoTime();
for (int j = 0; j < NUM_MB; j++) {
fb.clear();
BufferUtils.copy(floats, 0, fb, len);
}
Gdx.app.log("BufferUtilsTest", "FloatBuffer native bulk put: " + (TimeUtils.nanoTime() - start) / 1000000000.0f);
}
示例7: ImmediateModeRenderer10
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public ImmediateModeRenderer10(int paramInt)
{
this.maxVertices = paramInt;
if (Gdx.graphics.isGL20Available())
throw new GdxRuntimeException("ImmediateModeRenderer can only be used with OpenGL ES 1.0/1.1");
this.positions = new float[paramInt * 3];
this.positionsBuffer = BufferUtils.newFloatBuffer(paramInt * 3);
this.colors = new float[paramInt * 4];
this.colorsBuffer = BufferUtils.newFloatBuffer(paramInt * 4);
this.normals = new float[paramInt * 3];
this.normalsBuffer = BufferUtils.newFloatBuffer(paramInt * 3);
this.texCoords = new float[paramInt * 2];
this.texCoordsBuffer = BufferUtils.newFloatBuffer(paramInt * 2);
}
示例8: prepare
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void prepare() {
if (isPrepared) throw new GdxRuntimeException("Already prepared");
this.buffer = BufferUtils.newFloatBuffer(width * height * numComponents);
isPrepared = true;
}
示例9: prepare
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void prepare () {
if (isPrepared) throw new GdxRuntimeException("Already prepared");
this.buffer = BufferUtils.newFloatBuffer(width * height * 4);
isPrepared = true;
}
示例10: create
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void create () {
//Not emulated in gwt
//ByteBuffer bytebuffer = BufferUtils.newUnsafeByteBuffer(1000 * 1000);
//BufferUtils.disposeUnsafeByteBuffer(bytebuffer);
ByteBuffer bb = BufferUtils.newByteBuffer(8);
CharBuffer cb = BufferUtils.newCharBuffer(8);
ShortBuffer sb = BufferUtils.newShortBuffer(8);
IntBuffer ib = BufferUtils.newIntBuffer(8);
LongBuffer lb = BufferUtils.newLongBuffer(8);
FloatBuffer fb = BufferUtils.newFloatBuffer(8);
DoubleBuffer db = BufferUtils.newDoubleBuffer(8);
bb.position(4);
BufferUtils.copy(new byte[] {1, 2, 3, 4}, 0, bb, 4);
checkInt(bb.get(), 1);
checkInt(bb.get(), 2);
checkInt(bb.get(), 3);
checkInt(bb.get(), 4);
cb.position(4);
BufferUtils.copy(new char[] {1, 2, 3, 4}, 0, cb, 4);
checkInt(cb.get(), 1);
checkInt(cb.get(), 2);
checkInt(cb.get(), 3);
checkInt(cb.get(), 4);
sb.position(4);
BufferUtils.copy(new short[] {1, 2, 3, 4}, 0, sb, 4);
checkInt(sb.get(), 1);
checkInt(sb.get(), 2);
checkInt(sb.get(), 3);
checkInt(sb.get(), 4);
ib.position(4);
BufferUtils.copy(new int[] {1, 2, 3, 4}, 0, ib, 4);
checkInt(ib.get(), 1);
checkInt(ib.get(), 2);
checkInt(ib.get(), 3);
checkInt(ib.get(), 4);
lb.position(4);
BufferUtils.copy(new long[] {1, 2, 3, 4}, 0, lb, 4);
checkInt(lb.get(), 1);
checkInt(lb.get(), 2);
checkInt(lb.get(), 3);
checkInt(lb.get(), 4);
fb.position(4);
BufferUtils.copy(new float[] {1, 2, 3, 4}, 0, fb, 4);
checkFloat(fb.get(), 1);
checkFloat(fb.get(), 2);
checkFloat(fb.get(), 3);
checkFloat(fb.get(), 4);
if (Gdx.app.getType() != ApplicationType.WebGL) { // gwt throws: NYI: Numbers.doubleToRawLongBits
db.position(4);
BufferUtils.copy(new double[] {1, 2, 3, 4}, 0, db, 4);
checkFloat(db.get(), 1);
checkFloat(db.get(), 2);
checkFloat(db.get(), 3);
checkFloat(db.get(), 4);
}
ByteBuffer bb2 = BufferUtils.newByteBuffer(4);
bb.position(4);
BufferUtils.copy(bb, bb2, 4);
checkInt(bb2.get(), 1);
checkInt(bb2.get(), 2);
checkInt(bb2.get(), 3);
checkInt(bb2.get(), 4);
bench();
}
示例11: VertexArrayEmulator
import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/**
* Constructs a new interleaved VertexBufferObject.
*
* @param isStatic
* whether the vertex data is static.
* @param numVertices
* the maximum number of vertices
* @param attributes
* the {@link VertexAttributes}.
*/
public VertexArrayEmulator(boolean isStatic, int numVertices, VertexAttributes attributes) {
this.isStatic = isStatic;
this.attributes = attributes;
buffer = BufferUtils.newFloatBuffer(this.attributes.vertexSize / 4 * numVertices);
buffer.flip();
bufferHandle = Gdx.gl20.glGenBuffer();
usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW;
}