Defining textures for VBOs


I recently started using VBOs for creating some cuboidal objects. The objects are coming out fine, but I am unable to define a texture for 'em.

The code is something like:

                    glBindTexture(GL_TEXTURE_2D, <some_index>);
                    GLdouble texVertices[] = { 0,0, 1,0, 1,1, 0,1 };
                    glTexCoordPointer(2, GL_DOUBLE, 0 , texVertices);
                    glBindBuffer(GL_ARRAY_BUFFER, <vbo_object>)
                    glVertexPointer(3, GL_DOUBLE, 0, NULL);
                    glDrawArrays(GL_QUADS, j*4, 4);     // j here is an iterator; values goes 0,4,8,12,16,20 for the 6 planes.

As you can see, my texture vertices are defined separately and not part of the vbo. But if I try using the commented code, I get an access violation error.
What should I be fixing?

Try adding “glBindBuffer( GL_ARRAY_BUFFER, 0 )” before your glTexCoordPointer call. You want to make sure that the driver realizes that this is a CPU pointer, not an offset into the currently-bound GPU buffer object.

Second, don’t use GL_DOUBLE. This is going to be run-time converted down into float in the driver anyway. So above, replace GLdouble -> GLfloat, GL_DOUBLE -> GL_FLOAT. You’ll also want to change the data you load into your <vbo_object> to contain floats rather than doubles.

Thanks for the reply @Dark Photon.
But it doesn’t seem to work. The code is no longer crashing, but I am not getting any texture on the plane.
I did try to switch to a colored texture for testing (blue with black lines). I ended up with a completely blue colored plane but I couldn’t see any lines. I’m guessing the code it packing/tiling them too densely into the plane.