I have this trianglestrip which is constructed with 4 vertices. No I want to fade out that trianglestrip which has a texture on it.
I can fade in and out trianglestrips without textures on it but as soon as I use textures it does not work anymore.
Now here is the code I try to use:
Code: Select all
int GraphicsObject::Render2DImageOn3D(float left, float top, const Image* texture, int alpha) {
vertexTCP* DisplayVertices = (vertexTCP*) sceGuGetMemory(4 * sizeof(vertexTCP));
sceGuDisable(GU_DEPTH_TEST);
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
sceGuTexMode(GU_PSM_8888, 0 ,0 ,0);
sceGuTexImage(0, texture->textureWidth, texture->textureHeight, texture->textureWidth, (void*) texture->data);
DisplayVertices[0].u = 0.0f;
DisplayVertices[0].v = 0.0f;
DisplayVertices[0].color = GU_RGBA(255, 255, 255, alpha);
DisplayVertices[0].x = left;
DisplayVertices[0].y = top;
DisplayVertices[0].z = 0.0f;
DisplayVertices[1].u = texture->textureWidth-1;
DisplayVertices[1].v = 0.0f;
DisplayVertices[1].color = GU_RGBA(255, 255, 255, alpha);
DisplayVertices[1].x = left + texture->textureWidth;
DisplayVertices[1].y = top;
DisplayVertices[1].z = 0.0f;
DisplayVertices[2].u = 0.0f;
DisplayVertices[2].v = texture->textureHeight-1;
DisplayVertices[2].color = GU_RGBA(255, 255, 255, alpha);
DisplayVertices[2].x = left;
DisplayVertices[2].y = top + texture->textureHeight;
DisplayVertices[2].z = 0.0f;
DisplayVertices[3].u = texture->textureWidth-1;
DisplayVertices[3].v = texture->textureHeight-1;
DisplayVertices[3].color = GU_RGBA(255, 255, 255, alpha);
DisplayVertices[3].x = left + texture->textureWidth;
DisplayVertices[3].y = top + texture->textureHeight;
DisplayVertices[3].z = 0.0f;
sceGuDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 4, 0, DisplayVertices);
sceGuEnable(GU_DEPTH_TEST);
return 0;
}
It always has the same alpha channel no matter what I pass for alpha as value(10 displays the same as 255)
Is there a flag I am forgetting or something? or is the blending function I use not correct? Does the color attribute of a triangle even have effect on the rendering when a texture is also applied?
I have tested with the sceGuBlendFunc() function but I can't seem to get it right, it does not seem to have that effect anyway.
Any ideas ?