當前位置: 首頁>>代碼示例>>Java>>正文


Java BufferUtils.createFloatBuffer方法代碼示例

本文整理匯總了Java中org.lwjgl.BufferUtils.createFloatBuffer方法的典型用法代碼示例。如果您正苦於以下問題:Java BufferUtils.createFloatBuffer方法的具體用法?Java BufferUtils.createFloatBuffer怎麽用?Java BufferUtils.createFloatBuffer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.BufferUtils的用法示例。


在下文中一共展示了BufferUtils.createFloatBuffer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renderGL

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
/**
 * Render the GL scene, this isn't efficient and if you know 
 * OpenGL I'm assuming you can see why. If not, you probably
 * don't want to use this feature anyway
 */
public void renderGL() {		
	FloatBuffer pos = BufferUtils.createFloatBuffer(4);
	pos.put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}).flip();
	FloatBuffer red = BufferUtils.createFloatBuffer(4);
	red.put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}).flip();

	GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
	GL11.glEnable(GL11.GL_LIGHT0);

	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_LIGHTING);
	
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	float h = (float) 600 / (float) 800;
	GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glLoadIdentity();	
	GL11.glTranslatef(0.0f, 0.0f, -40.0f);	
	GL11.glRotatef(rot,0,1,1);		
	
	GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
	gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:31,代碼來源:SlickCallableTest.java

示例2: ShaderUniform

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
public ShaderUniform(String name, int type, int count, ShaderManager manager)
{
    this.shaderName = name;
    this.uniformCount = count;
    this.uniformType = type;
    this.shaderManager = manager;

    if (type <= 3)
    {
        this.uniformIntBuffer = BufferUtils.createIntBuffer(count);
        this.uniformFloatBuffer = null;
    }
    else
    {
        this.uniformIntBuffer = null;
        this.uniformFloatBuffer = BufferUtils.createFloatBuffer(count);
    }

    this.uniformLocation = -1;
    this.markDirty();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:ShaderUniform.java

示例3: processTransforms

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
private void processTransforms(String jointName, String[] rawData, KeyFrameData[] keyFrames, boolean root){
	FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
	float[] matrixData = new float[16];
	for(int i=0;i<keyFrames.length;i++){
		for(int j=0;j<16;j++){
			matrixData[j] = Float.parseFloat(rawData[i*16 + j]);
		}
		buffer.clear();
		buffer.put(matrixData);
		buffer.flip();
		Matrix4f transform = new Matrix4f();
		transform.load(buffer);
		transform.transpose();
		if(root){
			//because up axis in Blender is different to up axis in game
			Matrix4f.mul(CORRECTION, transform, transform);
		}
		keyFrames[i].addJointTransform(new JointTransformData(jointName, transform));
	}
}
 
開發者ID:TheThinMatrix,項目名稱:OpenGL-Animation,代碼行數:21,代碼來源:AnimationLoader.java

示例4: glLoadMatrixx

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
@Override
public void glLoadMatrixx(int[] m, int offset) {
    FloatBuffer buffer = BufferUtils.createFloatBuffer(m.length);
    for (int i : m) {
        buffer.put(i);
    }
    buffer.position(offset);
    GL11.glLoadMatrix(buffer);
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:10,代碼來源:OpenGLImpl.java

示例5: toWorld

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
/**
 * Converts the specified X, Y, and Z screen positions
 * to a position in the world, that through some fancy
 * maths (raytracing) can be used get the actual block
 * position of the conversion
 *
 * @return World projected coordinates
 */
public static Vec3 toWorld(double x, double y, double z) {
    FloatBuffer screenCoords = BufferUtils.createFloatBuffer(3);
    boolean result = GLU.gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, screenCoords);
    if (result) {
        return new Vec3(screenCoords.get(0), Display.getHeight() - screenCoords.get(1), screenCoords.get(2));
    }
    return null;
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:17,代碼來源:GLUtils.java

示例6: Mesh

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
public Mesh(float[] positions, float[] textCoords, int[] indices, Texture texture) {
  this.texture = texture;
  vertexCount = indices.length;

  vaoId = glGenVertexArrays();
  glBindVertexArray(vaoId);

  vboIdList = new LinkedList<>();

  // Position VBO
  posVboId = glGenBuffers();
  FloatBuffer posBuffer = BufferUtils.createFloatBuffer(positions.length);
  FloatBuffer textCoordsBuffer = null;
  posBuffer.put(positions).flip();
  glBindBuffer(GL_ARRAY_BUFFER, posVboId);
  glBufferData(GL_ARRAY_BUFFER, posBuffer, GL_STATIC_DRAW);
  glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);


  //Texture VBO
  int vboId = glGenBuffers();
  textCoordsBuffer = MemoryUtil.memAllocFloat(textCoords.length);
  textCoordsBuffer.put(textCoords).flip();
  glBindBuffer(GL_ARRAY_BUFFER, vboId);
  glBufferData(GL_ARRAY_BUFFER, textCoordsBuffer, GL_STATIC_DRAW);
  glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);

  // Index VBO
  idxVboId = glGenBuffers();
  IntBuffer indicesBuffer = BufferUtils.createIntBuffer(indices.length);
  indicesBuffer.put(indices).flip();
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idxVboId);
  glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL_STATIC_DRAW);

  glBindBuffer(GL_ARRAY_BUFFER, 0);
  glBindVertexArray(0);
}
 
開發者ID:adamegyed,項目名稱:endless-hiker,代碼行數:38,代碼來源:Mesh.java

示例7: glMultMatrixx

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
@Override
public void glMultMatrixx(IntBuffer m) {
    FloatBuffer buffer = BufferUtils.createFloatBuffer(m.capacity());
    for (int i : m.array()) {
        buffer.put(i);
    }
    GL11.glMultMatrix(buffer);
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:9,代碼來源:OpenGLImpl.java

示例8: prepare

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
@Override
public void prepare(MissionInit missionInit)
{
       this.fbo = new Framebuffer(this.videoParams.getWidth(), this.videoParams.getHeight(), true);
       // Create a buffer for retrieving the depth map, if requested:
       if (this.videoParams.isWantDepth())
       	this.depthBuffer = BufferUtils.createFloatBuffer(this.videoParams.getWidth() * this.videoParams.getHeight());
       // Set the requested camera position
       Minecraft.getMinecraft().gameSettings.thirdPersonView = this.videoParams.getViewpoint();
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:11,代碼來源:VideoProducerImplementation.java

示例9: Shader

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
public Shader(String vertex, String fragment){
	this.vertex = vertex;
	this.fragment = fragment;
	
	//create each sub shader
	int vid = createShader(GL_VERTEX_SHADER, vertex);
	int fid = createShader(GL_FRAGMENT_SHADER, fragment);
	
	//create the program id
	id = glCreateProgram();
	
	//attach each individual shader
	glAttachShader(id, vid);
	glAttachShader(id, fid);
	
	//link the shaders together to make the program
	glLinkProgram(id);

	//if there is an error with linking, output the message
	if(glGetProgrami(id, GL_LINK_STATUS) == GL11.GL_FALSE){
		System.err.println(glGetProgramInfoLog(id, 1024));
		glDeleteProgram(id);
	}
	
	//remove the sub shader instances (already compiled into a whole)
	glDetachShader(id, vid);
	glDetachShader(id, fid);
	
	//add the shader program to the shader list by both paths of the shaders
	//note: collision will occur when reusing sub shaders
	shaders.put(vertex, this);
	shaders.put(fragment, this);
	
	//setup a uniform map (string uniform name, integer uniform location)
	uniforms = new HashMap<>();
	
	//create a buffer for 4x4 matrices
	buffer = BufferUtils.createFloatBuffer(16);
	
}
 
開發者ID:tek256,項目名稱:LD38,代碼行數:41,代碼來源:Shader.java

示例10: getBackground

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
/**
 * Get the current graphics context background color
 * 
 * @return The background color of this graphics context
 */
public Color getBackground() {
	predraw();
	FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
	GL.glGetFloat(SGL.GL_COLOR_CLEAR_VALUE, buffer);
	postdraw();

	return new Color(buffer);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:14,代碼來源:Graphics.java

示例11: toBuffer

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
/**
    * Stores the specified data into a FloatBuffer
    * @param data The array of float data
    * @return The generated FloatBuffer
    */
   public static FloatBuffer toBuffer(float[] data) {
// Create an empty FloatBuffer with the correct size
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);

// Store all the data in the buffer
for(int i = 0; i < data.length; i++) {
    buffer.put(data[i]);
}

// Prepares the buffer for get() operations
buffer.flip();

return buffer;
   }
 
開發者ID:camilne,項目名稱:open-world,代碼行數:20,代碼來源:Util.java

示例12: createFloatBuffer

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
public static FloatBuffer createFloatBuffer(float[] floats) {
  FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
  buffer.put(floats);
  buffer.rewind();
  return buffer;
}
 
開發者ID:shaunlebron,項目名稱:flex-fov,代碼行數:7,代碼來源:Cube.java

示例13: createBuffer

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
private FloatBuffer createBuffer(float[] data) {
	FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
	buffer.put(data);
	buffer.flip();
	return buffer;
}
 
開發者ID:MarcPopescu-Pfeiffer,項目名稱:2DGame,代碼行數:7,代碼來源:Model.java

示例14: VertexArrays

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
private VertexArrays() {
    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Immediate Mode");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(1, 1, 1, 1, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    final int amountofVertices = 3;
    final int vertexSize = 2;
    final int colorSize = 3;

    FloatBuffer vertexData = BufferUtils.createFloatBuffer(amountofVertices * vertexSize);
    vertexData.put(new float[]{-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f});
    vertexData.flip();

    FloatBuffer colorData = BufferUtils.createFloatBuffer(amountofVertices * colorSize);
    colorData.put(new float[]{-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f});
    colorData.flip();

    while(!Display.isCloseRequested()) {
        glClear(GL_COLOR_BUFFER_BIT);

        // Allows usage of vertex and color arrays
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);

        // Shows OpenGL where to find our arrays
        glVertexPointer(vertexSize, 0, vertexData);
        glColorPointer(colorSize, 0, colorData);

        // Draws the arrays
        glDrawArrays(GL_TRIANGLES, 0, amountofVertices);

        // Closes it and disables it
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);

        Display.update();
        Display.sync(60);
    }
    Display.destroy();
    System.exit(0);
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:51,代碼來源:VertexArrays.java

示例15: getAsFloatBuffer

import org.lwjgl.BufferUtils; //導入方法依賴的package包/類
public FloatBuffer getAsFloatBuffer() {
	FloatBuffer buffer = BufferUtils.createFloatBuffer(4);
	buffer.put(new float[] { col.x, col.y, col.z, a });
	buffer.flip();
	return buffer;
}
 
開發者ID:TheThinMatrix,項目名稱:LowPolyWater,代碼行數:7,代碼來源:Colour.java


注:本文中的org.lwjgl.BufferUtils.createFloatBuffer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。