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


Java FloatBuffer.capacity方法代码示例

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


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

示例1: setupJoystick

import java.nio.FloatBuffer; //导入方法依赖的package包/类
/** Setup a specific joystick that is connected
 * 
 * @param joy the joystick id to setup
 */
public static void setupJoystick(int joy){
	//make sure the joystick is connected
	if(!GLFW.glfwJoystickPresent(joy))
		return;
	
	//get the name of the joystick and normalize the casing
	String name = GLFW.glfwGetJoystickName(joy).toLowerCase();
	JoystickType type = JoystickType.OTHER;
	
	//check the name for the type
	if(name.contains("xbox"))
		type = JoystickType.XBOX360;
	else if(name.contains("playstation"))
		type = JoystickType.PLAYSTATION;
	
	//setup the axis size for the controller
	FloatBuffer buf  = GLFW.glfwGetJoystickAxes(joy);
	int axisCount = buf.capacity();
	
	//setup the button size for the controller
	ByteBuffer bbuf = GLFW.glfwGetJoystickButtons(joy);
	int buttonCount = bbuf.capacity();
	
	//add the controller to the static array for usage
	connected.add(new Joystick(joy, type, axisCount, buttonCount));
}
 
开发者ID:tek256,项目名称:LD38,代码行数:31,代码来源:Joystick.java

示例2: compile

import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
 * Compiles a FloatBuffer and binds it to OpenGL for rendering.
 *
 * @param buffer a FloatBuffer populated with VBO vertices
 * @return The original VBO
 */
public VBO compile(FloatBuffer buffer) {
	this.size = buffer.capacity();
	FEATHER.bindBuffer(this.id);
	GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
	FEATHER.bindBuffer(0);
	return this;
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:14,代码来源:VBO.java

示例3: getFloat

import java.nio.FloatBuffer; //导入方法依赖的package包/类
public float[] getFloat(Attribute attrib) {
	int pname = getAttrib(attrib);
	FloatBuffer buf = ByteBuffer.allocateDirect(16).order(ByteOrder.nativeOrder()).asFloatBuffer();
	gl.glGetFloatv(pname, buf);

	float[] result = new float[buf.capacity()];
	for(int i = 0; i < result.length; i++)
		result[i] = buf.get();

	return result;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:12,代码来源:JOGLOpenGL.java

示例4: store

import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
    * Stores the specified data into the VAO with a VBO
    * @param data
    * @param dimensions
    */
   private void store(FloatBuffer data, int[] dimensions) {
bind();

// Generate a VBO to hold the data
int vboid = GL15.glGenBuffers();
// Bind the VBO
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboid);
// Store the data in the VBO
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW);

// Get the stride of the data in bytes
int stride = 0;
if(dimensions.length > 1)
    for(int i = 0; i < dimensions.length; i++) {
	stride += dimensions[i] * 4;
    }

// Determine the number of vertices assuming attribute 0 is position
vertexCount = data.capacity() / dimensions[0];

// Setup data in VBO
int offset = 0;
for(int i = 0; i < dimensions.length; i++) {
    GL20.glVertexAttribPointer(i, dimensions[i], GL11.GL_FLOAT, false, stride, offset);
    offset += dimensions[i] * 4;
}

// Add the vbo to the list of buffer objects for memory management
addBufferObject(vboid);

unbind();
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:38,代码来源:VAO.java

示例5: bufferToFloatArray

import java.nio.FloatBuffer; //导入方法依赖的package包/类
private static float[] bufferToFloatArray(ByteBuffer buffer) {
	buffer.order(ByteOrder.nativeOrder());
	FloatBuffer floats = buffer.asFloatBuffer();

	if (floats.hasArray()) {
		return floats.array();
	} else {
		float[] resultArray = new float[floats.capacity()];
		floats.get(resultArray);
		return resultArray;
	}
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:13,代码来源:ThriftBmiBridge.java

示例6: getTexCoordArray

import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
 * Returns the array of texture coordinates.  The first time this is called, we generate
 * a modified version of the array from the parent class.
 * <p>
 * To avoid allocations, this returns internal state.  The caller must not modify it.
 */
@Override
public FloatBuffer getTexCoordArray() {
    if (mRecalculate) {
        //Log.v(TAG, "Scaling to " + mScale);
        FloatBuffer parentBuf = super.getTexCoordArray();
        int count = parentBuf.capacity();

        if (mTweakedTexCoordArray == null) {
            ByteBuffer bb = ByteBuffer.allocateDirect(count * SIZEOF_FLOAT);
            bb.order(ByteOrder.nativeOrder());
            mTweakedTexCoordArray = bb.asFloatBuffer();
        }

        // Texture coordinates range from 0.0 to 1.0, inclusive.  We do a simple scale
        // here, but we could get much fancier if we wanted to (say) zoom in and pan
        // around.
        FloatBuffer fb = mTweakedTexCoordArray;
        float scale = mScale;
        for (int i = 0; i < count; i++) {
            float fl = parentBuf.get(i);
            fl = ((fl - 0.5f) * scale) + 0.5f;
            fb.put(i, fl);
        }

        mRecalculate = false;
    }

    return mTweakedTexCoordArray;
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:36,代码来源:ScaledDrawable2d.java

示例7: update

import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
 * Update the values of the joystick
 */
public void update(){
	this.buttonsLastFrame = this.buttons.clone();
	this.axesLastFrame = this.axes.clone();
	
	FloatBuffer abuf = GLFW.glfwGetJoystickAxes(this.id);
	ByteBuffer bbuf = GLFW.glfwGetJoystickButtons(this.id);
	for(int i=0;i<abuf.capacity();i++)
		this.axes[i] = abuf.get(i);
	for(int i=0;i<bbuf.capacity();i++)
		this.buttons[i] = bbuf.get(i);
}
 
开发者ID:tek256,项目名称:LD38,代码行数:15,代码来源:Joystick.java

示例8: update

import java.nio.FloatBuffer; //导入方法依赖的package包/类
public void update(){
    float mouseX = Input.getMousePosition().x;
    float mouseY = Input.getMousePosition().y;
    float dMouseX = Input.getDMouse().x;
    float dMouseY = Input.getDMouse().y;
    if(mouseX >= this.x && mouseX <= this.x + this.width && mouseY >= this.y && mouseY <= this.y + this.height){
        for(int i = 0;i < Input.NBRE_BUTTON;i++){
            if(Input.isButton(i)){
                action.clicked(mouseX,mouseY,i,Input.getButtonState(i));
            }
        }
        if(mouseInGUI == 0){
            mouseInGUI = 1;
            action.enter(mouseX,mouseY);
        }else if(mouseInGUI == 1 || mouseInGUI == 2){
            mouseInGUI = 2;
            action.hover(mouseX,mouseY);
            if(dMouseX != 0 || dMouseY != 0)action.move(mouseX,mouseY);
        }
    }else{
        if(mouseInGUI == 1 || mouseInGUI == 2){
            mouseInGUI = 0;
            action.leave(mouseX,mouseY);
        }
    }
    for(int id : Input.getJoysticks()){
    	try{
    		FloatBuffer axis = Input.getJoysticksAxis(id);
        	for(int i = 0;i < axis.capacity();i++){
        		action.joystickAxisState(id, i, axis.get(i));
        	}
        	ByteBuffer buttons = Input.getJoysticksButton(id);
        	for(int i = 0;i < buttons.capacity();i++){
        		action.joystickButtonState(id, i, buttons.get(i));
        	}
    	}catch(Exception e){}
    }
}
 
开发者ID:mrdev023,项目名称:Global-Gam-Jam-2017,代码行数:39,代码来源:GUI.java

示例9: RangeFloatDicManager

import java.nio.FloatBuffer; //导入方法依赖的package包/类
public RangeFloatDicManager( final FloatBuffer dicBuffer ){
  this.dicBuffer = dicBuffer;
  dicLength = dicBuffer.capacity(); 
}
 
开发者ID:yahoojapan,项目名称:multiple-dimension-spread,代码行数:5,代码来源:RangeDumpFloatColumnBinaryMaker.java


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