![]() |
|
|
|
Thread Tools | Display Modes |
|
(#1)
|
|
|
Member
Posts: 82
Join Date: 2009.03
Location: Sheffield, UK
|
Loading in PNG's (and other) bitmaps. -
2010.02.03, 08:08 PM
Hello,
I'm pretty new to iPhone dev (but quite looking forward to getting stuck in), I'm a bit unsure what the best practice is, and options are, in regards to loading in bitmap textures in to video ram for use with OpenGL. I've come across PVRTC compression (using 'texturetool'), but I believe that's not going to retain an alpha channel. Some of my sprites will make use of Alpha channel, and if I was on PC or Mac, they'd be 32bit PNG's etc. From what (limited) knowledge I have currently, I imagine the PVRTC textures, and compressed in to a format ready to go straight in to VRAM; while regular PNG's will require unpacking in to normal iPhone RAM, before uploading to VRAM (taking up 32bpp, compared to the 2 or 4bpp of the PVRTCs). There's good chance I'm missing something here! Are there any good tutorials, or sources of information etc; detailing the various ways, and relative merits, of getting bitmap files in to VRAM on iPhone. Hope someone can shed a little light, many thanks, Jamie. ![]() |
|
|
|
|
(#2)
|
|
|
Moderator
Posts: 3,541
Join Date: 2003.06
Location: usa
|
2010.02.03, 08:21 PM
You can search around the forums here for plenty of examples of how to load textures on iPhone.
AFAICT, I think most of us pretty much just use regular ol' 32 bit PNGs for images on iPhone for most purposes. If you're using a lot of RAM then you can drop down to PVRTC, which does also have alpha, but it kinda sucks on the edges. I tend to use PVRTC for backgrounds and animated sprite frames, but everything else PNG. Non-alpha images work great with PVRTC though. Yes, PVRTC is just a blob of pixels that you upload directly from disk to the GL without any processing/unpacking. PNGs you will probably just use some OS routines if you don't care about premultiplied alpha, otherwise you can use libpng or a small variant of SOIL (sorry I don't have the name or link handy, but search the forums for SOIL on iPhone and you're bound to find it). |
|
|
|
|
(#3)
|
|
|
Member
Posts: 82
Join Date: 2009.03
Location: Sheffield, UK
|
2010.02.03, 08:45 PM
Ah, thanks Jake, that's really useful, and clears things up a lot!
![]() I imagine you use PVRTC for animating sprites, as the player won't get to pay so much attention to each individual frame of animation etc; and can also imagine them being good for backgrounds, and solid background tiles etc. I really don't want my sprites with pre-multiplied alpha (all the semi transparent pixels must look wrong?), so I guess that means no OS routines for loading in and unpacking PNG's in to RAM.. Someone was suggesting: "load them as an image (UIImage or CGImage), create a bitmap context, draw them into the bitmap, then use an opengl call to make a texture out of that bitmap" ... and I've been looking at some code which seems to do that, but I think it uses OS routines (CGImageCreateWithPNGDataProvider and other CGImage* stuff). I'm guessing a combination of the PVRTCs (esp, if my game wants to put a lot in to VRAM), and 32 bit PNG's, that I need to use libPNG or SOIL to unpack etc; will work best for me. Thanks once again, Jamie. ![]() EDIT: I assume, if a game isn't cramming so much in to VRAM, then there's not so much need to use PVRTCs, as you get pretty good compression with normal PNG files (so it wouldn't be an issue in terms of your games' install file bundle thingy)? |
|
|
|
|
(#4)
|
||||||
|
Moderator
Posts: 3,541
Join Date: 2003.06
Location: usa
|
2010.02.03, 09:30 PM
Quote:
Quote:
Quote:
The CGImageCreateWithPNGDataProvider stuff is what I use, as it is the same code to load on the Mac.Quote:
Quote:
Sounds like you're right on track. ![]() |
|||||
|
|
|
|
(#5)
|
|
|
Member
Posts: 82
Join Date: 2009.03
Location: Sheffield, UK
|
2010.02.04, 08:03 AM
Ah cool, things are getting a lot clearer thanks!
I'm using a custom tool (which runs as a command line app, not sure what you'd call those in OSX) to generate texture atlases, and I'd like to call texturetool from within this app, to generate PVRTC textures etc. So something like running a string, as if it's been typed in terminal, but from within an app. Is that kind of thing possible? Thanks, |
|
|
|
|
(#6)
|
|
|
Member
Posts: 231
Join Date: 2008.10
Location: Valencia
|
2010.02.04, 08:51 AM
BTW, PVR is just a container, as DDS, actually you can store textures inside PVR files without compresion of any type, as BMP.
My program only uses PVR textures, but some of them are compressed (specially those ones wo alpha) and for animations I compress them. Actually I realised compressed PVR only have a bad quality when there is an alpha channel, but not in other case, especially when developing a 2D game. I recommend you download a tool from http://www.imgtec.com/ called PVRTexToolGUI. Hope this helps. |
|
|
|
|
(#7)
|
||
|
Moderator
Posts: 3,541
Join Date: 2003.06
Location: usa
|
2010.02.04, 11:59 AM
Quote:
|
|
|
|
|
| Thread Tools | |
| Display Modes | |
|
|