forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

whats the psp sdk graphics api like

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
binch



Joined: 04 Jul 2006
Posts: 28
Location: China

PostPosted: Mon May 14, 2007 10:41 pm    Post subject: whats the psp sdk graphics api like Reply with quote

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
View user's profile Send private message MSN Messenger
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Mon May 14, 2007 11:22 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
binch



Joined: 04 Jul 2006
Posts: 28
Location: China

PostPosted: Mon May 14, 2007 11:30 pm    Post subject: Reply with quote

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:

#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
View user's profile Send private message MSN Messenger
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Mon May 14, 2007 11:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Tue May 15, 2007 4:00 am    Post subject: Reply with quote

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
View user's profile Send private message
binch



Joined: 04 Jul 2006
Posts: 28
Location: China

PostPosted: Tue May 15, 2007 9:34 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
sturatt



Joined: 13 Jul 2006
Posts: 46

PostPosted: Wed May 16, 2007 4:28 am    Post subject: Reply with quote

sceGuSwapBuffers() returns the pointer to the new draw buffer
Back to top
View user's profile Send private message
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Wed May 16, 2007 8:42 am    Post subject: Reply with quote

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
View user's profile Send private message
binch



Joined: 04 Jul 2006
Posts: 28
Location: China

PostPosted: Wed May 16, 2007 11:56 am    Post subject: Reply with quote

sturatt wrote:
sceGuSwapBuffers() returns the pointer to the new draw buffer


i use this and cause the system die.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group