本文整理汇总了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);
}
示例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();
}
示例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));
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}