@#$@! i'm having problems with gl.glDrawElements i keep getting access violations. I'm trying to convert some of the code off the opengl bible (pg 439) to run in processing before trying to implement it with the rest of my code.
import processing.opengl.*;
import javax.media.opengl.*;
import java.nio.*;
PGraphicsOpenGL pgl;
GL gl;
float [] corners;
int [] indexes;
FloatBuffer fcorners;
IntBuffer findexes;
void setup(){
size (600,600,OPENGL);
pgl = (PGraphicsOpenGL) g;
gl = pgl.gl;
float[] corners= {
-25.0f, 25.0f, 25.0f, // 0 // Front of cube
25.0f, 25.0f, 25.0f, // 1
25.0f, -25.0f, 25.0f,// 2
-25.0f, -25.0f, 25.0f,// 3
-25.0f, 25.0f, -25.0f,// 4 // Back of cube
25.0f, 25.0f, -25.0f,// 5
25.0f, -25.0f, -25.0f,// 6
-25.0f, -25.0f, -25.0f };// 7
int[] indexes= {
0, 1, 2, 3, // Front Face
4, 5, 1, 0, // Top Face
3, 2, 6, 7, // Bottom Face
5, 4, 7, 6, // Back Face
1, 5, 6, 2, // Right Face
4, 0, 3, 7 }; // Left Face*/
FloatBuffer fcorners = ByteBuffer.allocateDirect(4*corners.length).order(ByteOrder.nativeOrder()).asFlo
atBuffer();
fcorners.put(corners);
fcorners.rewind();
IntBuffer findexes = ByteBuffer.allocateDirect(4*indexes.length).order(ByteOrder.nativeOrder()).asInt
Buffer();
findexes.put(indexes);
findexes.rewind();
}
void draw(){
background(100);
pgl.beginGL();
gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(3,GL.GL_FLOAT, 0, fcorners);
gl.glDrawElements(GL.GL_QUADS, 24, GL.GL_UNSIGNED_INT, findexes);
pgl.endGL();
}
I know i'm close.. i can feel it... help... please