| View previous topic :: View next topic |
| Author |
Message |
binch
Joined: 04 Jul 2006 Posts: 28 Location: China
|
Posted: Mon May 14, 2007 10:41 pm Post subject: whats the psp sdk graphics api like |
|
|
if i want to buy a text to study how to programming this graphics engine, can i just buy a opengl book?
thx. |
|
| Back to top |
|
 |
Cpasjuste
Joined: 29 May 2005 Posts: 214
|
|
| Back to top |
|
 |
binch
Joined: 04 Jul 2006 Posts: 28 Location: China
|
Posted: Mon May 14, 2007 11:30 pm Post subject: |
|
|
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: |
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <string.h>
PSP_MODULE_INFO("Test by Chen Bin", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main(void)
{
SceCtrlData pad_data;
pspDebugScreenSetBackColor(0xFFFFFFFF);
pspDebugScreenSetTextColor(0);
pspDebugScreenInit();
SetupCallbacks();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(1);
sceCtrlReadBufferPositive(&pad_data, 1);
int i;
int j;
char **fp = sceGuSwapBuffers();
while (1) {
for (i = 0;i < 100;i++) {
for (j = 0;j < 100;j++) {
fp[j][i] = 0xFF;
}
}
fp = sceGuSwapBuffers();
sleep(1);
for (i = 0;i < 100;i++) {
for (j = 0;j < 100;j++) {
fp[j][i] = 0x00;
}
}
}
sceKernelExitDeleteThread(0);
return 0;
}
|
|
|
| Back to top |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Mon May 14, 2007 11:43 pm Post subject: |
|
|
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: | | char **fp = sceGuSwapBuffers(); | 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 |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Tue May 15, 2007 4:00 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
binch
Joined: 04 Jul 2006 Posts: 28 Location: China
|
Posted: Tue May 15, 2007 9:34 am Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
sturatt
Joined: 13 Jul 2006 Posts: 46
|
Posted: Wed May 16, 2007 4:28 am Post subject: |
|
|
| sceGuSwapBuffers() returns the pointer to the new draw buffer |
|
| Back to top |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Wed May 16, 2007 8:42 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
binch
Joined: 04 Jul 2006 Posts: 28 Location: China
|
Posted: Wed May 16, 2007 11:56 am Post subject: |
|
|
| sturatt wrote: | | sceGuSwapBuffers() returns the pointer to the new draw buffer |
i use this and cause the system die. |
|
| Back to top |
|
 |
|