Hi all,
Below is a piece of code im working on.
Im playing with vertex arrays… but im not getting any output on the screen.
This section of code represents a shape… my render will forward calls to draw and init when its display and init are called…
Right now all i get is a black screen.
Guidance would be appreciated… as i want to understand what im doing wrong.
package spacegame;
import java.util.*;
import java.nio.*;
import net.java.games.jogl.*;
import net.java.games.util.*;
import darkmatter.*;
public class Shape implements Model {
private FloatBuffer vertexBuffer;
private FloatList tmpBuffer = new FloatList();
private float[] data = { 4.0f, 5.0f, 6.0f, 7.0f,
1.0f, 2.0f, 6.0f, 5.0f,
0.0f, 1.0f, 5.0f, 4.0f,
0.0f, 3.0f, 2.0f, 1.0f,
0.0f, 4.0f, 7.0f, 3.0f,
2.0f, 3.0f, 7.0f, 6.0f,
};
public void draw(GLDrawable glDrawable) {
GL gl = glDrawable.getGL();
gl.glColor3f(1.0f,0.0f,0.0f);
gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
gl.glVertexPointer(4, gl.GL_FLOAT, 0, vertexBuffer);
gl.glFlush();
}
public void init(GLDrawable glDrawable) {
GL gl = glDrawable.getGL();
tmpBuffer.setData(data);
vertexBuffer = BufferUtils.newFloatBuffer(tmpBuffer.size());
}
}