Reputation: 21
Is there any alternative to GLfloat
in lwjgl
? There are many sources for OpenGL which use GLfloat
. Is GLfloat
even necessary in lwjgl
? Can't I just replace it with a regular float
?
Upvotes: 2
Views: 2523
Reputation: 250
you must use the lwjgl utilities to create a float buffer in place of the glfloat array. located in this import. import org.lwjgl.BufferUtils;
for example:
lightPos = BufferUtils.createFloatBuffer(4);
lightPos.put(1).put(1).put(3).put(0).flip();
difuseLight = BufferUtils.createFloatBuffer(4);
difuseLight.put(10.0f).put(10.0f).put(10.0f).put(1.0f).flip();
ambientLight = BufferUtils.createFloatBuffer(4);
ambientLight.put(.75f).put(.75f).put(.75f).put(1).flip();
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLight(GL_LIGHT0, GL_LIGHT_MODEL_AMBIENT, ambientLight);
glLight(GL_LIGHT0, GL_SPECULAR, difuseLight);
Upvotes: 0
Reputation: 182093
In Java, it's just a plain old Java float
, and you don't have any need for GLfloat
at all. All APIs in lwjgl are defined in terms of the Java primitive type float
.
(In all C implementations that I know of, GLfloat
is just plain old float
as well.)
Upvotes: 2