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


Java BufferUtils.newFloatBuffer方法代码示例

本文整理汇总了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);
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:21,代码来源:GLView.java

示例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;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:19,代码来源:Anisotropy.java

示例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);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:21,代码来源:ShaderProgram.java

示例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);
  }
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:18,代码来源:ShaderProgram.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:15,代码来源:VertexBufferObject.java

示例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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:40,代码来源:BufferUtilsTest.java

示例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);
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:15,代码来源:ImmediateModeRenderer10.java

示例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;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:7,代码来源:NhgFloatTextureData.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:7,代码来源:FloatTextureData.java

示例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();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:76,代码来源:BufferUtilsTest.java

示例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;
}
 
开发者ID:konsoletyper,项目名称:teavm-libgdx,代码行数:20,代码来源:VertexArrayEmulator.java


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