I'm trying to make an messagesystem. It displays a message on screen when you encounter a door for example. The message"press x to open the door" will be displayed onscreen.
Since my game is 3d and the letters has to be on the screen i use the spritefunction to render a sprite onscreen. however i get this strange behaviour:
I have made the background blue so that why it is blue, but there are two things wrong, firstly the texture seems messed up. It should display some letters but it does not. Secondly the letters are not rendered on the screen but are rendered in the level.
does anybody has any idea what is going wrong?
here is the code i use:
Code: Select all
int MessageEngine::RenderMessages() {
if (MessageAvailable == 0) return 1; // if there is no message return
MessageLength--;
if (MessageLength <= 0) { MessageAvailable = 0; return 2; }
int BeginPos = 240 - (MessageLength*8); // set the begin x value of the string for centering in the screen
for(int i=0;i<MessageLength;i++) { // loop through the char array and render every letter
// get the value of the char :D
int Char = (int)Message[i];
int row, column;
if (Char == 32) {
//space char
row = 4;
column = 8;
} else if (Char == 33) {
// !
row = 4;
column = 3;
} else if (Char == 45) {
// -
row = 4;
column = 5;
} else if (Char == 63) {
// ?
row = 4;
column = 4;
} else {
Char = Char - 96;
if (Char < 9) {
// get image from first row
row = 1;
column = Char;
}
else if (Char < 17) {
// get image from second row
row = 2;
column = Char - 8;
}
else if (Char < 25) {
// get image from third row
row = 3;
column = Char - 16;
}
else {
row = 4;
column = Char - 24;
}
}
sceGuTexMode(GU_PSM_8888, 0 ,0 ,0);
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
sceGuTexFilter(GU_LINEAR, GU_LINEAR);
sceGuTexOffset(0.0f, 0.0f);
sceGuTexImage(0, Alphabet->textureWidth, Alphabet->textureHeight, Alphabet->textureWidth, (void*) Alphabet->data);
float u = 1.0f / ((float)Alphabet->textureWidth);
float v = 1.0f / ((float)Alphabet->textureHeight);
sceGuTexScale(u, v);
DisplayVertices[0].u = (column-1) * 16;
DisplayVertices[0].v = (row-1) * 16;
DisplayVertices[0].color = 0xffffffff;
DisplayVertices[0].x = BeginPos + (16*i);
DisplayVertices[0].y = 253;
DisplayVertices[0].z = 0;
DisplayVertices[1].u = (column) * 16;
DisplayVertices[1].v = (row) * 16;
DisplayVertices[1].color = 0xffffffff;
DisplayVertices[1].x = BeginPos + (16*(i+1));
DisplayVertices[1].y = 269;
DisplayVertices[1].z = 0;
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, DisplayVertices);
//blitImageToScreen((column-1) * 16 ,(row-1) * 16 ,16 , 16, Alphabet, BeginPos + (16*i), 253); // render the letters
}
return 0;
}