   Adding Alpha to Textures using a Vertex Array
  Hello,I wonder if anyone can help me... I'm tearing what little hair I have left out. :(I'm using a vertex array to draw a series of textured triangles (arranged as quads). This works ok.However, I've been trying to add alpha to the textures by combing them with a colour value. If I call the following at the start of my draw function:glColor4f(1.f, 1.f, 1.f, 0.5f); , all of my vertices are alpha'd. It works exactly as I want it to. Except...What I want to be able to do is only alpha some of the vertices. In other words, combine different alpha values with the vertices in the vertex array, so that I can fade in and out individual quads, but still draw them all in the vertex array.To that end, I added 4 floats to my vertex data and filled them with RGBA values:textureStruct vertices[] ={{{minUV->x,maxUV->y},{topLeft.x,topLeft.y,topLeft.z},{1.0f,1.0f,1.0f,0.2f}},{{minUV->x,minUV->y},{bottomLeft.x,bottomLeft.y,bottomLeft.z},{1.0f,1.0f,1.0f,0.2f}},{{maxUV->x,maxUV->y},{topRight.x,topRight.y,topRight.z},{1.0f,1.0f,1.0f,0.2f}},{{maxUV->x,minUV->y},{bottomRight.x,bottomRight.y,bottomRight.z},{1.0f,1.0f,1.0f,0.2f}}};This is what I do in my draw function:glLoadIdentity();glClearColor(0.5, 0.0, 0.0, 1.0);glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glEnable(GL_TEXTURE_2D);glEnable(GL_BLEND);glBindTexture(GL_TEXTURE_2D, mTextureInfo.ID[0]);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // I've tried many different combinations of these//glColor4f(1.f, 1.f, 1.f, 0.5f); COMMENTED OUT - when I put this in, all my textures are alpha'dglTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE );//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); I've tried literally hundreds of theseglBindBuffer(GL_ARRAY_BUFFER, mTextureVertexBuffers);glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mTextureIndexBuffers);glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(3, GL_FLOAT, sizeof(textureStruct), (void*)offsetof(textureStruct,vertices));glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(2, GL_FLOAT, sizeof(textureStruct), (void*)offsetof(textureStruct,uvs));glEnableClientState(GL_COLOR_ARRAY);glColorPointer(4, GL_FLOAT, sizeof(textureStruct), (void*)offsetof(colourStruct,colour));glDrawElements(GL_TRIANGLES, kNumIndicesInQuad*mTextureInfo.currentSpriteCount, GL_UNSIGNED_BYTE, (void*)0);glDisableClientState(GL_VERTEX_ARRAY);glDisableClientState(GL_TEXTURE_COORD_ARRAY);glDisableClientState(GL_COLOR_ARRAY);glDisable(GL_BLEND);glDisable(GL_TEXTURE_2D);The above makes my textures a slightly different colour! Alpha doesn't seem to work at all.If I change the data in my structure to:textureStruct vertices[] ={{{minUV->x,maxUV->y},{topLeft.x,topLeft.y,topLeft.z},{0.2f,0.2f,0.2f,0.2f}},// ALL RGBA components now set to 0.2{{minUV->x,minUV->y},{bottomLeft.x,bottomLeft.y,bottomLeft.z},{0.2f,0.2f,0.2f,0.2f}},{{maxUV->x,maxUV->y},{topRight.x,topRight.y,topRight.z},{0.2f,0.2f,0.2f,0.2f}},{{maxUV->x,minUV->y},{bottomRight.x,bottomRight.y,bottomRight.z},{0.2f,0.2f,0.2f,0.2f}}}; , the alpha does work, but I still get the odd colours. I've literally trawled through hundreds of forums and websites in the last few days trying to understand what I'm doing wrong. I've tried all sorts of things, but everything I read either doesn't seem to work, is slightly different to what I want, or is just too complicated for my ageing grey cells!I know it may be a simple problem and I've missed something fundamental, but I really have tried everything I know before bothering you lovely people. Can anyone tell me what I need to do to get my textured quads fading in and out properly, with their correct colours? Please stop me going completely bald... it's cold in England!Thanks in advance for your help   
glVertexPointer(3, GL_FLOAT, sizeof(textureStruct), (void*)offsetof(textureStruct,vertices));Since you are now passing an alpha value, your glVertexPointer should be: glVertexPointer(4,...);  Hello Fugitive,Thanks for your reply. I tried that but it doesn't seem to work. It might very well be, though, that there are other problems as well, and that your solution would work if I fixed those!Can you explain why I'd need to do that? I thought the alpha data was stored in the colour pointer, not the vertex pointer, and I do add an offset of 4 for the colour pointer. Thanks again!;  You don't need to have glVertexPointer(4,...)because that means you are passing 4 bits of data for the Vertex. What you're actually doing is packing the data in one array such that you have3, 4, 3, 4, 3, 4.....Where the 3 is the the 3 values for the vertex, and the 4 are the colour values. Therefore you need to modify you glVertexPointer() and glColorPointer() code accordingly:glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(3, GL_FLOAT, 4,(void*)offsetof(textureStruct,vertices));glEnableClientState(GL_COLOR_ARRAY);glColorPointer(4, GL_FLOAT, 3, (void*)offsetof(colourStruct,colour));;  Hello,Sorry I haven't replied earlier - work's been hectic.Anyway just got back to this today. Thanks everyone for your answers... they were all very useful for getting insights into this.I found out that my problem was a cut-and-paste typo. :( When I call glColorPointer, the last parameter references 'colourStruct' when it should reference 'textureStruct'. Ooops. What a world of pain for such a stupid mistake. I also have a coloured quad drawing function which I must have copied and pasted from. Ah well it's a good feeling to fix it, and good to know I was otherwise on the right track.Thanks again everyone.   ;Quote:Original post by FugitiveglVertexPointer(3, GL_FLOAT, sizeof(textureStruct), (void*)offsetof(textureStruct,vertices));Since you are now passing an alpha value, your glVertexPointer should be: glVertexPointer(4,...)WTF?   