OSLib in XMB possible?
OSLib in XMB possible?
Is it possible to blit images to XMB with OSLib? I know that it is possible with GU, but it seems kind of hard to learn... So if you know something about it, please tell me
-
- Posts: 91
- Joined: Sun Feb 22, 2009 8:32 am
- Location: Melbourne Australia ZOMG
Well i just it could be done, but seems impossible. I tried GU, but can't get my image displayed, could you help? The screen just go blank and nothing happens...
Here is the loadPng() and drawSprite() functions:
http://codepad.org/Ey0YeArq
Code: Select all
#include <malloc.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pspgu.h>
#include <pspgum.h>
#include <psprtc.h>
#include <png.h>
#include "main.h"
#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
PSP_MODULE_INFO("Lesson1", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(10000);
void *dList;
void *fbp0;
void InitGU( void )
{
sceGuInit();
sceGuStart( GU_DIRECT, dList );
sceGuDrawBuffer(GU_PSM_8888,(void*)0,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(0xc350,0x2710);
sceGuScissor( 0, 0, SCR_WIDTH, SCR_HEIGHT);
sceGuEnable( GU_SCISSOR_TEST );
sceGuDepthFunc( GU_GEQUAL );
sceGuEnable( GU_DEPTH_TEST );
sceGuFrontFace( GU_CW );
sceGuShadeModel( GU_SMOOTH );
sceGuEnable( GU_CULL_FACE );
sceGuEnable( GU_CLIP_PLANES );
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
}
void SetupProjection( void )
{
sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumPerspective( 75.0f, 16.0f/9.0f, 0.5f, 1000.0f);
sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
sceGuClearColor( GU_COLOR( 0.0f, 0.0f, 0.0f, 1.0f ) );
sceGuClearDepth(0);
}
int main(int argc, char **argv)
{
pspDebugScreenInit();
SetupCallbacks();
sceRtcGetCurrentTick( &fpsTickLast );
tickResolution = sceRtcGetTickResolution();
dList = memalign( 16, 262144 );
fbp0 = 0;
InitGU();
SetupProjection();
Image *img=loadPng("ourImage.png");
sceKernelDcacheWritebackAll();
while( 1 )
{
if(!img) sceKernelExitGame();
else{
sceGuStart(GU_DIRECT,dList);
drawSprite(0,0,32,32,img,0,0);
sceGuFinish();
sceGuSync(0,0);
fbp0 = sceGuSwapBuffers();
pspDebugScreenSetOffset( (int)fbp0 );
}
sceDisplayWaitVblankStart();
}
sceGuTerm();
// Free Memory
free( dList );
free( fbp0 );
sceKernelExitGame();
return 0;
}
Here is the loadPng() and drawSprite() functions:
http://codepad.org/Ey0YeArq