Hi all,
I'm currently working on a bit of homework ("Create any 2D scene you want".. How great is uni?), and to bump my marks up I need/would very much like to use a vertex array (have done heirarchical drawing, use of textures, alpha blending)
In the project we were given, there is an interleaved array which holds the vx, vy, vr, vg, vb for a five point star, and this is drawn using (GL_LINE_LOOP). So, far, so good.
I'm trying to create a vertex array, which interleaves vx, vy, and the texture coordinates for a rectangle. Sounds easy right? Textured rectangle from vertex array?
The Error is occuring everytime on the line i've signed ~#:
Unhandled exception at 0x10103a6c in GfxProject.exe: 0xC0000005: Access violation reading location 0x00000000.
Okay before I chat more, here's the code:
the global interleaved array:
Code:
/* OpenGL Interleaved vertex array */ //x y texcoords
static GLfloat StageModel_interleaved [] ={ -4.0f, -4.0f, 0,0,
-4.0f, -0.04f, 0,1,
4.0f, -0.04f, 1,1,
4.0f, -4.0f, 1,0};
static GLubyte StageVertexIndices [] = {0, 1, 2, 3};
In renderscene():
Code:
glPushMatrix();
//drawing the staging.. the ground etc
glVertexPointer(2, GL_FLOAT, ( (2*sizeof(GLfloat)) + (2*sizeof(GLuint)) ), StageModel_interleaved);
glTexCoordPointer(2, GL_UNSIGNED_INT, ( (2*sizeof(GLfloat)) + (2*sizeof(GLuint)) ), &(StageModel_interleaved[2]));
//size of tex index?!
DrawStage_glDrawElements(1);
glPopMatrix();
and finally the actual draw function:
Code:
void DrawStage_glDrawElements(int texArrayIndex)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureLib[texArrayIndex]);
~# glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, StageVertexIndices);
glDisable(GL_TEXTURE_2D);
}
Please somebody help me: I know I've done something stupid I just can't see what!
Many thanks C Board!