Temor wrote:Now that's cool. I will definitely take a look at LWJGL
![Smile :)](./images/smilies/icon_e_smile.gif)
It's actually really easy
![Smile :)](./images/smilies/icon_e_smile.gif)
For example, here is the really simple code to render the "player"
[syntax=java]// build VBO
this.dataVBOId = ARBVertexBufferObject.glGenBuffersARB();
this.indexVBOId = ARBVertexBufferObject.glGenBuffersARB();
int intSize = Integer.SIZE / 8;
int floatSize = Float.SIZE / 8;
int doubleSize = Double.SIZE / 8;
this.vertexSize = doubleSize * 3;
this.normalSize = doubleSize * 3;
this.colourSize = floatSize * 4;
this.totalVertices = 8;
this.VBOElementSize = this.vertexSize + this.normalSize + this.colourSize;
int totalDataSize = this.VBOElementSize * this.totalVertices;
int totalIndexSize = intSize * this.totalVertices;
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.dataVBOId);
ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, totalDataSize, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
ByteBuffer dataBuffer = ARBVertexBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, ARBVertexBufferObject.GL_WRITE_ONLY_ARB, totalDataSize, null);
// base
dataBuffer.putDouble(-20).putDouble(20).putDouble(0.1);
dataBuffer.putDouble(0).putDouble(0).putDouble(1);
dataBuffer.putFloat(1.0f).putFloat(0.4f).putFloat(0.4f).putFloat(1);
dataBuffer.putDouble(20).putDouble(20).putDouble(0.1);
dataBuffer.putDouble(0).putDouble(0).putDouble(1);
dataBuffer.putFloat(1.0f).putFloat(0.4f).putFloat(0.4f).putFloat(1);
dataBuffer.putDouble(20).putDouble(-20).putDouble(0.1);
dataBuffer.putDouble(0).putDouble(0).putDouble(1);
dataBuffer.putFloat(1.0f).putFloat(0.4f).putFloat(0.4f).putFloat(1);
dataBuffer.putDouble(-20).putDouble(-20).putDouble(0.1);
dataBuffer.putDouble(0).putDouble(0).putDouble(1);
dataBuffer.putFloat(1.0f).putFloat(0.4f).putFloat(0.4f).putFloat(1);
// gun
dataBuffer.putDouble(-6).putDouble(26).putDouble(0.2);
dataBuffer.putDouble(0).putDouble(0).putDouble(1);
dataBuffer.putFloat(0.4f).putFloat(1.0f).putFloat(0.4f).putFloat(1);
dataBuffer.putDouble(6).putDouble(26).putDouble(0.2);
dataBuffer.putDouble(0).putDouble(0).putDouble(1);
dataBuffer.putFloat(0.4f).putFloat(1.0f).putFloat(0.4f).putFloat(1);
dataBuffer.putDouble(6).putDouble(4).putDouble(0.2);
dataBuffer.putDouble(0).putDouble(0).putDouble(1);
dataBuffer.putFloat(0.4f).putFloat(1.0f).putFloat(0.4f).putFloat(1);
dataBuffer.putDouble(-6).putDouble(4).putDouble(0.2);
dataBuffer.putDouble(0).putDouble(0).putDouble(1);
dataBuffer.putFloat(0.4f).putFloat(1.0f).putFloat(0.4f).putFloat(1);
dataBuffer.flip();
ARBVertexBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, this.indexVBOId);
ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, totalIndexSize, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
ByteBuffer indexBuffer = ARBVertexBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, ARBVertexBufferObject.GL_WRITE_ONLY_ARB, totalIndexSize, null);
for (int i = 0; i < this.totalVertices; ++i){
indexBuffer.putInt(i);
}
indexBuffer.flip();
ARBVertexBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
// render VBO
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.dataVBOId);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, this.indexVBOId);
GL11.glVertexPointer(3, GL11.GL_DOUBLE, this.VBOElementSize, 0);
GL11.glNormalPointer(GL11.GL_DOUBLE, this.VBOElementSize, this.vertexSize);
GL11.glColorPointer(4, GL11.GL_FLOAT, this.VBOElementSize, this.vertexSize + this.normalSize);
GL11.glPushMatrix();
GL11.glRotated(this.lookAngle, 0, 0, -1);
GL11.glDrawElements(GL11.GL_QUADS, this.totalVertices, GL11.GL_UNSIGNED_INT, 0);
GL11.glPopMatrix();
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);[/syntax]
See, simple...
![Laughing :lol:](./images/smilies/icon_lol.gif)