2D accelerated Sample ?

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

Moderators: cheriff, TyRaNiD

Post Reply
patpsp
Posts: 31
Joined: Tue Oct 25, 2005 5:24 pm

2D accelerated Sample ?

Post by patpsp »

Hello, i'm looking for a simple sample, showing how to display some png images, using the hardware acceleration.
It could be a simple pspgl sample.

This kind of sample can be very useful for beginning a 2d project.

I searched a lot but didn't find, so i post this request.

Thanks for your help.
User avatar
sherpya
Posts: 61
Joined: Mon Oct 03, 2005 5:49 pm

Post by sherpya »

you can use SDL, it's simple, iirc is not hw accelerated, but is enough fast anyway
patpsp
Posts: 31
Joined: Tue Oct 25, 2005 5:24 pm

Post by patpsp »

thanks for your answer

i like sdl, but i really think that it is a good idea to start a project using the more acceleration avalaible.
i know the dreamcast scene, and the first sdl libs weren't hardware accelerated. chui recently released a sdl lib with hardware acceleration and it's very fast.

I hope the psp-scene release a sdl - hardware accelerated, just as chui did.
User avatar
sherpya
Posts: 61
Joined: Mon Oct 03, 2005 5:49 pm

Post by sherpya »

you can start with it, so if psp sdl port will get acceleration you will have same code but faster
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

A hardware-accelerated SDL port has been sitting in our Subversion repo for months. The only major feature it's missing is OpenGL support (SDL's funky way of doing it).

SDL_image is also available, and there are over a half dozen games using SDL and related libraries in the pspware repo.
rinco
Posts: 255
Joined: Fri Jan 21, 2005 2:12 pm
Location: Canberra, Australia

Post by rinco »

The video hw acceleration in sdl (currently) only applies to rescaling odd resolutions and old-school bit depths.

A hw accelerated blit (sceGuCopyImage) could be easily added ... but the Gu is currently only initialised with a SWSURFACE. So for the blit to work, Gu must also be initialised with a HWSURFACE, any objections?
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

None from me :).
Garak
Posts: 46
Joined: Wed Jul 27, 2005 1:59 am

Post by Garak »

How would sceGuCopyImage allow hardware acceleration?

Would it only allow accelerated blits for images that do not use alpha blending or a transparency color? I thought to utilize eaither of those features, you had to use the GU, or a port of openGL and the likes.

Also, is there a hardware accelerated SDL revsion in the SVN somewhere, or was mrbrown only referring to the one that is limited in HW acceleration to scaling images at odd resolutions (the main copy)?

Garak
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

There's some stuff in the existing code that could be cleaned up a bit. For example GuUpdateRects should only update the rects it's passed, not the entire screen, and there's a bug I'd like to track down where the scaled screen is sometimes shifted right a few pixels, and sometimes doesn't show up at all (this is with 320x240x16, and it changes each time I run the program; I'll see if I can make an example). Also, what do you think about making the scaling configurable? Maybe SDL_FULLSCREEN could be used to indicate whether we want aspect ratio preserved.
rinco
Posts: 255
Joined: Fri Jan 21, 2005 2:12 pm
Location: Canberra, Australia

Post by rinco »

I'm with you on that generic GuUpdateRects. I've already split it into a GuStretchBlit function - as I reuse it for scaled hwsurface accelerated blits.

I propose an environment variable be used to preserve aspect ratio (other video drivers use getenv). X11 uses SDL_VIDEO_CENTERED and SDL_VIDEO_WINDOW_POS for instance. And DirectFB defines SDL_DIRECTFB_MGA_STRETCH to zoom. Perhaps the best name would be SDL_ASPECT_RATIO...?
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

rinco wrote:I propose an environment variable be used to preserve aspect ratio
I propose we make it even more flexible: SDL_VIDEO_WINDOW_POS=x1,y1,x2,y2. For example fullscreen is 0,0,479,271, 4:3 aspect ratio would be around 59,0,421,271, and an unscaled 320x240 is 80,16,400,256. Could specify a fullscreen rotated mode, too: 479,0,0,271
patpsp
Posts: 31
Joined: Tue Oct 25, 2005 5:24 pm

Post by patpsp »

great to see that you try to improve the 2d code !

please don't hesitate to release some demo code.
perhaps a good thing is a "benchmark" code, in which we can see the different framerates with the different solutions to render 2d

Thanks for your work !
DrDummy
Posts: 2
Joined: Mon Oct 24, 2005 5:30 pm

Re: 2D accelerated Sample ?

Post by DrDummy »

Here is my very simple sample for you. I cut the codes from the TV program I am working on.

It uses GU only (I still cant get SDL compile on pspsdk ...), sceGuCopyImage for drawing to vram, double buffered, do 60 fps atm (because it is very basic).

What ...
It keep drawing two BMPs into screen ..

Usage ..
TRIANGLE : show fps
CROSS : exit
any other buttons : pause the drawing.

Tools :
http://mach-one.uw.hu/index.php?stuffz=win/m1pspc
for convert bmps to c

GFX :
Thanks http://www.themepsp.com/ for the car images.

DL :
http://www.users.on.net/~froggy/

Hope it helps !!!

patpsp wrote:Hello, i'm looking for a simple sample, showing how to display some png images, using the hardware acceleration.
It could be a simple pspgl sample.

This kind of sample can be very useful for beginning a 2d project.

I searched a lot but didn't find, so i post this request.

Thanks for your help.
patpsp
Posts: 31
Joined: Tue Oct 25, 2005 5:24 pm

Post by patpsp »

thanks !
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Post by jsgf »

I put together a sample of layering a simple sprite library on top of PSPGL to get accelerated blitting performance. This goes beyond simple blitting, and makes the hardware's ability to also scale, rotate and tint sprites easily usable.

The demo draws a few dozen sprites of various sizes (up to half the screen size), all blended, without making the PSP break a sweat. 'Circle' pauses things so you can see what's going on.

You can download the executable from http://www.goop.org/psp/gl/sprite-test.zip.

Source is at http://hg.goop.org/pspgl/libsprite?cmd= ... p;type=zip; you'll need a current pspgl-jsgf as well (http://www.goop.org/psp/gl).
Post Reply