Rendering 2d textures onto a 3d object Lwjgl

Im attempting to draw a 2d texture onto a 3d cube. here is the code.

public class test1 extends Game {
	// VBO Vertex Buffer ID
    int vboVertexID;
    // VBO Color Buffer ID
    int vboColorID;
    
    /**
     * Initialize
     */
    private texture te;
    public void init()
    {
        Display.setTitle("Tutorial 11: A Rotating Cube");
        
        // Initialize OpenGL
        glMatrixMode(GL_PROJECTION);
        gluPerspective(70f, Display.getWidth()/Display.getHeight(), 1, 1000);
        glViewport(0, 0, Display.getWidth(), Display.getHeight());
        
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        
        // Enable Depth Testing
        glEnable(GL_DEPTH_TEST);
        
        // Enable client states
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);
        glEnable(GL_TEXTURE_2D);
        // Create Cube vertices
        FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(3*24);
        vertexBuffer.put(new float[]
        {
            // Front face
            -0.5f, +0.5f, +0.5f,
            +0.5f, +0.5f, +0.5f,
            -0.5f, -0.5f, +0.5f,
            +0.5f, -0.5f, +0.5f,

            // Right face
            +0.5f, +0.5f, +0.5f,
            +0.5f, +0.5f, -0.5f,
            +0.5f, -0.5f, +0.5f,
            +0.5f, -0.5f, -0.5f,
            
            // Back face
            +0.5f, +0.5f, -0.5f,
            -0.5f, +0.5f, -0.5f,
            +0.5f, -0.5f, -0.5f,
            -0.5f, -0.5f, -0.5f,
            
            // Left face
            -0.5f, +0.5f, -0.5f,
            -0.5f, +0.5f, +0.5f,
            -0.5f, -0.5f, -0.5f,
            -0.5f, -0.5f, +0.5f,
            
            // Top face
            -0.5f, +0.5f, +0.5f,
            +0.5f, +0.5f, +0.5f,
            -0.5f, +0.5f, -0.5f,
            +0.5f, +0.5f, -0.5f,
            
            // Bottom face
            -0.5f, -0.5f, +0.5f,
            +0.5f, -0.5f, +0.5f,
            -0.5f, -0.5f, -0.5f,
            +0.5f, -0.5f, -0.5f,
        });
        vertexBuffer.rewind();
        
        // Create cube colors
        te = texture.loadtexture("graphics/test].png");
        FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(2*24);
        colorBuffer.put(new float[]
        {
        		0,0,
        		1,0,
        		1,1,
        		0,1,
        		0,0,
        		1,0,
        		1,1,
        		0,1,
        		0,0,
        		1,0,
        		1,1,
        		0,1,
        		0,0,
        		1,0,
        		1,1,
        		0,1,
        		0,0,
        		1,0,
        		1,1,
        		0,1,
        		0,0,
        		1,0,
        		1,1,
        		0,1
        		
        		
           
        });
        colorBuffer.rewind();
        
        // Create vertex VBO
        vboVertexID = glGenBuffers();
        glBindBuffer(GL_ARRAY_BUFFER, vboVertexID);
        glBufferData(GL_ARRAY_BUFFER, vertexBuffer, GL_STATIC_DRAW);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
        
        // Create color VBO
        vboColorID = glGenBuffers();
        glBindBuffer(GL_ARRAY_BUFFER, vboColorID);
        glBufferData(GL_ARRAY_BUFFER, colorBuffer, GL_STATIC_DRAW);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
    
    /**
     * Update logic
     */
    public void update(long elapsedTime)
    {
        if (isKeyDown(KEY_ESCAPE))
            end();
    }
    
    /**
     * Render to screen
     */
    public void render()
    {
        // Clean both color and depth buffers
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        
        // Translate into the view
        glTranslatef(0, 0, -2);
        
        // Rotate on both x and y axes
        glRotatef(1, 1, 1, 1);
        glBindTexture(GL_TEXTURE_2D
, te.id);
        // Bind the vertex VBO
        glBindBuffer(GL_ARRAY_BUFFER, vboVertexID);
        glVertexPointer(3, GL_FLOAT, 0, 0);
        
        // Bind the color VBO
        glBindBuffer(GL_ARRAY_BUFFER, vboColorID);
        glTexCoordPointer(2, GL_FLOAT, 0, 0);
        
        // Draw the cube with triangle strip
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 24);
        
        // Translate back
        glTranslatef(0, 0, 2);
    }
    
    /**
     * Display resized
     */
    public void resized()
    {
        glViewport(0, 0, Display.getWidth(), Display.getHeight());
    }
    
    /**
     * Dispose resources
     */
    public void dispose()
    {
        glDeleteBuffers(vboVertexID);
        glDeleteBuffers(vboColorID);
    }
    
    public static void main(String[] args)
    {
        new test1();
    }
}

what im trying to do is map the texture to each face within the floatbuffer , however I get an error when I try to run it Selected DisplayMode: 800 x 600 x 0 @0Hz

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005327c300, pid=6608, tid=6256

JRE version: Java™ SE Runtime Environment (7.0_45-b18) (build 1.7.0_45-b18)

Java VM: Java HotSpot™ 64-Bit Server VM (24.45-b08 mixed mode windows-amd64 compressed oops)

Problematic frame:

C [nvoglv64.DLL+0x98c300]

Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

An error report file with more information is saved as:

C:\Users\lucas\workspace\LWJGL test\hs_err_pid6608.log

If you would like to submit a bug report, please visit:

http://bugreport.sun.com/bugreport/crash.jsp

The crash happened outside the Java Virtual Machine in native code.

See problematic frame for where to report the bug.

if there is a better way to do this it would be appreciated.

So you are using your color buffer for the texture coord pointer?? Personally not used to VBO’s, but I believe you will have to use three buffers, the color buffer with glColorPointer and an additional texCoord buffer with glTexCoordPointer…
btw:
Does the texture path “graphics/test].png” really contain ] ?

He doesn’t need all three, just as long as he makes sure he uses them correctly. The texture path (good catch) wouldn’t crash the runtime, but you should see if that’s correct or not.

Maybe part of your issue is that you’re enabling client states so early? Enable them right before you render, and then disable them immediately after.

Just noticed that the color buffer is used correctly, but is no color but the text coord buffer…
Maybe it would help readability to change this.

its ok I fixed it I just need to get used to placing the textures on the image.

If you use an vertex and an texture coord array and nothing for color, why are you enabling GL_COLOR_ARRAY and not GL_TEXTURE_COORD_ARRAY?
You are really messing around with texCoord and color.

Very new to it and im playing around with it abit.

Ok, but it won’t work if you use Textures without enabling them.
It is also useless to enable something (color) you do not use.