Jake
Jake

Reputation: 637

OpenGL GLfloat not recognized Java

I tried to create a GLfloat buffer array with

GLfloat mat_diffuse[] = { .2f, .2f, .6f, 1f };

But java can not find class GLfloat and when I try to use a normal float array I get an error with this line

gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, mat_diffuse);

Error reads incompatible types: float[] cannot be converted to FloatBuffer

Is there a special way to create a GLfloat or is there something that I need to import from openGL to make this work?

Upvotes: 1

Views: 494

Answers (1)

Jake
Jake

Reputation: 637

So the solution I found for this was to use a float array

float mat_diffuse[] = { .2f, .2f, .6f, 1f };

and then changed

gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, mat_diffuse);

to

gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, mat_diffuse, 0);

not sure why it worked, but it did.

Upvotes: 1

Related Questions