whats the psp sdk graphics api like

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

Moderators: cheriff, TyRaNiD

Post Reply
binch
Posts: 28
Joined: Tue Jul 04, 2006 4:17 pm
Location: China

whats the psp sdk graphics api like

Post by binch »

if i want to buy a text to study how to programming this graphics engine, can i just buy a opengl book?

thx.
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Hi binch, since pspgl have been ported to the psp, and that pspgu functions seems similars (i'm not a guru coder but it seems), i think it could be a good idea yes. You can also take a look at the nice nehe opengl tutorials online that helped me on a few things :

http://nehe.gamedev.net/

And you can find some of them ported to the psp here :

http://edorul.free.fr/psp/NeheTutorials1-10_v0.1.rar
http://edorul.free.fr/psp/NeheTutorials11-20.rar
binch
Posts: 28
Joined: Tue Jul 04, 2006 4:17 pm
Location: China

Post by binch »

Cpasjuste wrote:Hi binch, since pspgl have been ported to the psp, and that pspgu functions seems similars (i'm not a guru coder but it seems), i think it could be a good idea yes. You can also take a look at the nice nehe opengl tutorials online that helped me on a few things :

http://nehe.gamedev.net/

And you can find some of them ported to the psp here :

http://edorul.free.fr/psp/NeheTutorials1-10_v0.1.rar
http://edorul.free.fr/psp/NeheTutorials11-20.rar
Thanks.
I am not a graphics programmer(actually an experienced wireless/kernel developer). I wrote a simple program but cause the PSP crash, whats wrong with my code? I just want to periodically flash a part of screen black and white, is the VRAM can't be directly accessed?

Thanks again!

Bin

Code: Select all

#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>

#include <string.h>

PSP_MODULE_INFO&#40;"Test by Chen Bin", 0, 1, 1&#41;;

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	sceKernelExitGame&#40;&#41;;

	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;

	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
	&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;

int main&#40;void&#41;
&#123;
	SceCtrlData pad_data;

	pspDebugScreenSetBackColor&#40;0xFFFFFFFF&#41;;
	pspDebugScreenSetTextColor&#40;0&#41;;
	pspDebugScreenInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;
	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;1&#41;;

	sceCtrlReadBufferPositive&#40;&pad_data, 1&#41;;

	int i;
	int j;

	char **fp = sceGuSwapBuffers&#40;&#41;;
	while &#40;1&#41; &#123;
		for &#40;i = 0;i < 100;i++&#41; &#123;
			for &#40;j = 0;j < 100;j++&#41; &#123;
				fp&#91;j&#93;&#91;i&#93; = 0xFF;
			&#125;
		&#125;

		fp = sceGuSwapBuffers&#40;&#41;;

		sleep&#40;1&#41;;
		for &#40;i = 0;i < 100;i++&#41; &#123;
			for &#40;j = 0;j < 100;j++&#41; &#123;
				fp&#91;j&#93;&#91;i&#93; = 0x00;
			&#125;
		&#125;
	&#125;

	sceKernelExitDeleteThread&#40;0&#41;;
	return 0;
&#125;
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

First, you do no initialization of the GU system at all, so calling sceGuSwapBuffers() will have undefined behaviour. Look at the PSPSDK samples how to start the GU library. If you don't want to use that library, use the proper methods in pspdisplay to flip buffers instead.

Second, you do no yielding of the task in your while (1)-loop, which means the PSP watchdog will kill your thread in 10 seconds.

Third,

Code: Select all

char **fp = sceGuSwapBuffers&#40;&#41;;
This will turn into a pointer to an array of pointers, which is not what you want, since it will try to read a pointer from VRAM, and then use that one and write to whatever it might point to. Access it using the datatype depending on what graphics format you've setup (like u16* or u32*).
GE Dominator
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Might as well learn GU over PSPGL to be honest.

GU is very similar to OpenGL anyway, so the book would be a good entry point.

There's also lots of samples for GU in the SDK.
binch
Posts: 28
Joined: Tue Jul 04, 2006 4:17 pm
Location: China

Post by binch »

Insert_witty_name wrote:Might as well learn GU over PSPGL to be honest.

GU is very similar to OpenGL anyway, so the book would be a good entry point.

There's also lots of samples for GU in the SDK.
Is there a example for obtaining the VRAM address and ploting single pixel?
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

Post by sturatt »

sceGuSwapBuffers() returns the pointer to the new draw buffer
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

But that pointer is relative to VRAM start, and it's not what he wanted. sceGeEdramGetAddr() will return the address to the video memory. sceDisplaySetFrameBuf() will set where the LCD should fetch its data from. Look up their functionality in the SDK.
GE Dominator
binch
Posts: 28
Joined: Tue Jul 04, 2006 4:17 pm
Location: China

Post by binch »

sturatt wrote:sceGuSwapBuffers() returns the pointer to the new draw buffer
i use this and cause the system die.
Post Reply