OSLib in XMB possible?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
zydeoN
Posts: 45
Joined: Sat May 09, 2009 4:01 am

OSLib in XMB possible?

Post by zydeoN »

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
slasher2661996
Posts: 91
Joined: Sun Feb 22, 2009 8:32 am
Location: Melbourne Australia ZOMG

Post by slasher2661996 »

Not without some usage of assembly or the gu
zydeoN
Posts: 45
Joined: Sat May 09, 2009 4:01 am

Post by zydeoN »

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...

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 &#40;512&#41;
#define SCR_WIDTH &#40;480&#41;
#define SCR_HEIGHT &#40;272&#41;

PSP_MODULE_INFO&#40;"Lesson1", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER&#41;;
PSP_HEAP_SIZE_KB&#40;10000&#41;;
 
void *dList;		
void *fbp0;		
 

void InitGU&#40; void &#41;
&#123;
	
	sceGuInit&#40;&#41;;
        sceGuStart&#40; GU_DIRECT, dList &#41;;
	
	sceGuDrawBuffer&#40;GU_PSM_8888,&#40;void*&#41;0,BUF_WIDTH&#41;;
	sceGuDispBuffer&#40; SCR_WIDTH, SCR_HEIGHT, &#40;void*&#41;0x88000, BUF_WIDTH&#41;;
	sceGuDepthBuffer&#40; &#40;void*&#41;0x110000, BUF_WIDTH&#41;;
 
	sceGuOffset&#40; 2048 - &#40;SCR_WIDTH/2&#41;, 2048 - &#40;SCR_HEIGHT/2&#41;&#41;;
	sceGuViewport&#40; 2048, 2048, SCR_WIDTH, SCR_HEIGHT&#41;;
	sceGuDepthRange&#40;0xc350,0x2710&#41;;
	
	sceGuScissor&#40; 0, 0, SCR_WIDTH, SCR_HEIGHT&#41;;
	sceGuEnable&#40; GU_SCISSOR_TEST &#41;;
	sceGuDepthFunc&#40; GU_GEQUAL &#41;;
	sceGuEnable&#40; GU_DEPTH_TEST &#41;;
	sceGuFrontFace&#40; GU_CW &#41;;
	sceGuShadeModel&#40; GU_SMOOTH &#41;;
	sceGuEnable&#40; GU_CULL_FACE &#41;;
	sceGuEnable&#40; GU_CLIP_PLANES &#41;;
        sceGuFinish&#40;&#41;;
	sceGuSync&#40;0,0&#41;;
 
	sceDisplayWaitVblankStart&#40;&#41;;
	sceGuDisplay&#40;GU_TRUE&#41;;
	
&#125;

void SetupProjection&#40; void &#41;
&#123;
	
	sceGumMatrixMode&#40;GU_PROJECTION&#41;;
	sceGumLoadIdentity&#40;&#41;;
	sceGumPerspective&#40; 75.0f, 16.0f/9.0f, 0.5f, 1000.0f&#41;;
 
        sceGumMatrixMode&#40;GU_VIEW&#41;;
	sceGumLoadIdentity&#40;&#41;;
 
	sceGuClearColor&#40; GU_COLOR&#40; 0.0f, 0.0f, 0.0f, 1.0f &#41; &#41;; 
	sceGuClearDepth&#40;0&#41;;	
&#125;

int main&#40;int argc, char **argv&#41;
&#123;
	pspDebugScreenInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;

	sceRtcGetCurrentTick&#40; &fpsTickLast &#41;;
	tickResolution = sceRtcGetTickResolution&#40;&#41;;
 
	dList = memalign&#40; 16, 262144 &#41;;
	fbp0  = 0;
 
	InitGU&#40;&#41;;
	SetupProjection&#40;&#41;;
 
	Image *img=loadPng&#40;"ourImage.png"&#41;;
	sceKernelDcacheWritebackAll&#40;&#41;;

	while&#40; 1 &#41;
	&#123;
		if&#40;!img&#41; sceKernelExitGame&#40;&#41;;
		else&#123;
			sceGuStart&#40;GU_DIRECT,dList&#41;;
			drawSprite&#40;0,0,32,32,img,0,0&#41;;
			sceGuFinish&#40;&#41;;
			sceGuSync&#40;0,0&#41;;
			fbp0 = sceGuSwapBuffers&#40;&#41;;
			pspDebugScreenSetOffset&#40; &#40;int&#41;fbp0 &#41;;
			&#125;
		sceDisplayWaitVblankStart&#40;&#41;;

        &#125;
 
	sceGuTerm&#40;&#41;;			
 
	// Free Memory
	free&#40; dList &#41;;
	free&#40; fbp0 &#41;;
 
	sceKernelExitGame&#40;&#41;;	
	return 0;
&#125;

Here is the loadPng() and drawSprite() functions:
http://codepad.org/Ey0YeArq
Post Reply