here are the code portions:
Code: Select all
Image* img_lancetta;
Image* img_tachimetro;
Vertex __attribute__((aligned(16))) lancetta[3*2] = {
{ 0, 1, color,-0.18f,-0.3f, 1.0f }, // Front
{ 1, 1, color, 0.18f,-0.3f, 1.0f },
{ 0, 0, color,-0.18f, 1.0f, 1.0f },
{ 0, 0, color,-0.18f, 1.0f, 1.0f },
{ 1, 1, color, 0.18f,-0.3f, 1.0f },
{ 1, 0, color, 0.18f, 1.0f, 1.0f }
};
Vertex __attribute__((aligned(16))) tachimetro[3*2] = {
{ 0, 1, color,-1.0f,-1.0f, -0.1f },
{ 1, 1, color, 1.0f,-1.0f, -0.1f },
{ 0, 0, color,-1.0f, 1.0f, -0.1f },
{ 0, 0, color,-1.0f, 1.0f, -0.1f },
{ 1, 1, color, 1.0f,-1.0f, -0.1f },
{ 1, 0, color, 1.0f, 1.0f, -0.1f }
};
[...main()....]
img_lancetta = loadImage("lancetta.png");
swizzle(img_lancetta);
img_tachimetro = loadImage("lancetta.png"); //note same png here
swizzle(img_tachimetro);
[...]
void InitGU( void )
{
// Init GU
sceKernelDcacheWritebackInvalidateAll(); //debug
sceGuInit();
sceGuStart( GU_DIRECT, dList );
// Set Buffers
sceGuDrawBuffer( GU_PSM_8888, fbp0, BUF_WIDTH );
sceGuDispBuffer( SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
sceGuDepthBuffer( (void*)0x110000, BUF_WIDTH);
sceGuOffset( 2048 - (SCR_WIDTH/2), 2048 - (SCR_HEIGHT/2));
sceGuViewport( 2048, 2048, SCR_WIDTH, SCR_HEIGHT);
sceGuDepthRange( 65535, 0);
// Set Render States
sceGuScissor( 0, 0, SCR_WIDTH, SCR_HEIGHT);
sceGuEnable( GU_SCISSOR_TEST );
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGuDepthFunc( GU_GEQUAL );
sceGuEnable( GU_DEPTH_TEST );
sceGuFrontFace( GU_CW );
sceGuShadeModel( GU_SMOOTH );
sceGuEnable(GU_CLIP_PLANES);//---
sceGuEnable(GU_TEXTURE_2D);
// setup texture (NEW)
// I set the swizzled parameter to true fixed as my pngs
//are all bigger than 32*32
sceGuTexMode( GU_PSM_8888, 0, 0, 1);
//sceGuTexImage(0,TEXW,TEXH,TEXBLOCKW,pointer_to_tex_data);
sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA); // Apply image as a decal (NEW)
sceGuTexFilter( GU_LINEAR, GU_LINEAR ); // Linear filtering (Good Quality) (NEW)
sceGuTexScale( 1.0f, 1.0f ); // No scaling
sceGuTexOffset( 0.0f, 0.0f );
//---
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
// finish
}
[....]
void Drawscene(void){
rtri=-(angle)*pi/180;
sceGuStart( GU_DIRECT, dList ); // Starts the display list
sceKernelDcacheWritebackInvalidateAll();
// clear screen
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // Clears the Color and Depth Buffer
sceGumMatrixMode(GU_MODEL); // Selects the Model Matrix
sceGumLoadIdentity(); // And Reset it
{ // Move 1.5 units left and 3 units back
ScePspFVector3 move = { 0.0f,0.0f, -3.0f };
sceGumTranslate( &move ); // Apply moving of the matrix
sceGumRotateZ( rtri ); // rotate from analog stick movement
}
sceGuTexImage( 0, img_lancetta->textureWidth, img_lancetta->textureHeight, img_lancetta->textureWidth,img_lancetta->data );
sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,3*2, 0, lancetta);
sceGumLoadIdentity(); // And Reset it
{ // Move 1.5 units left and 3 units back
ScePspFVector3 move = { 0.0f,0.0f, -3.1f };
sceGumTranslate( &move ); // Apply moving of the matrix
sceGumRotateZ( 0.01f ); // Rotate the triangle on the Y-axis (NEW)
}
sceGuTexImage( 0, img_tachimetro->textureWidth, img_tachimetro->textureHeight, img_tachimetro->textureWidth,img_tachimetro->data );
sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,3*2, 0, tachimetro);
sceGuFinish();
sceGuSync(0,0);
}
I'm a total newbie with opengl so it may be everything, from some parameters in InitGU or who knows, some code missing in Drawscene, or whatever.. If someone can give me some of his light .. ;D
Thanks in advance