How does WoG show images?

28 replies [Last post]
Joined: 07/08/2011

Sorry if this has been asked already, but I'd love to know. Or is it part of the PopCap Games Framework? It's just that I don't see libpng or any png-loading library at all in the folder.

EDIT: Actually I'm thinking now that they might've just done it themselves.

Joined: 09/01/2009

I thought that DirectX had some kind of image-loading support in it? I have a DirectX book at home, but I haven't really read through it much.

Joined: 07/08/2011

Really? I thought it was for 3D layering.

Joined: 07/05/2011

WorldOfGoo.exe or ode.dll I think.

Joined: 09/01/2009

DirectX is basically a Windows-only equivalent to OpenGL, so it's a full-fledged 3D engine. And yah, after some quick googling, it has functions for loading PNG images.

@Mygod: ode.dll is the dynamic runtime for the Open Dynamics Engine, which is the physics engine World of Goo uses.

The readme for World of Goo says that it uses:
-ODE
-SDL
-PopCap Games Framework
-TinyXML
-AES (Advanced Encryption Standard)
-irrKlang
-libcurl

And it would be really foolish to write your own PNG-loading code, so I think they just use DirectX for it. Sometime if I have time, I can check the dependencies for the Linux version and see what it uses to load images, if you want.

Joined: 08/06/2010

But SDL can load PNGs and send them to other libraries or code.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.

Joined: 09/01/2009

Nope. Only SDL_image can do that, and there isn't an SDL_image.dll in that folder. Unless they compiled SDL_image together with SDL into their own .dll, which would be rather odd.

Joined: 07/08/2011

They haven't. The dll files in the folder are ones for separate, powerful libraries, but that might make a little sense considering SDl_image has like 5 dll files. Tongue

In other news, what do you use, MOM, for PNG-loading?

Joined: 09/01/2009

When I first started out adding PNG support for my game, it was Windows-only, and I had just been using standard .BMP bitmaps before. I was intrigued by the support that Windows had for .ico icons, as icons would just be 32x32 images only, and any other size I used was rescaled to 32x32. I ended up figuring out how to load and draw icons of any size, and then figured out how to create icons dynamically from bitmap data. I incorporated libpng to get the image data, and created the icons from the raw data, and used my previous code to draw it all to the screen. It was quite convoluted and complicated, but it surprisingly worked just fine.

I then chose to port my game to SDL for cross-platform support. And a simple call to an SDL_image function would do all the work for me. That's what I'm currently using.

I'm planning on porting my game to HGE or SFML sometime soon, and if I do so, I'll use one of their built-in functions to load images.

I've done a lot of stuff with images over the past months working on my game. I'm still dissatisfied with how I handle the images. If you load all the (hundreds of) images for your game up-front when the game first starts, it takes 20-30 seconds (on a Linux system; it takes longer on Windows). I'm planning on implementing a bitmap cache sometime soon so that images are only loaded as they're needed, and the cache is emptied as they aren't needed any more. This will cause the game to load in seconds, with the downside of each level having a couple seconds of load time. I'm not sure if HGE or SFML has some kind of caching code already, but if it does, it'll save me a lot of work, and will probably be more heavily optimized than something I myself could write. Whatever approach you use for images, be sure that it scales well. Loading images from a file, drawing the image, then destroying the loaded image is fine for a small test application, but when you've got 30 sprites on the screen running at 60 fps, it'll acually run about 10 fps. Max. Currently, I have a giant header file declaring global variables for hundreds of bitmaps, which stinks terribly as I add more and more and the file becomes bloated. 2DBoy made XML resource files for levels, and images are loaded when the level starts, which is a great idea. I'd encourage you to start with something set up in a way that scales well, or else you'll regret it later (Like me. Tongue). Otherwise, you'll end up hacking your own code to do something simple if you add more features later.

Joined: 01/07/2010

I don´t know a $#!@ about your conversation.

Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO

Joined: 09/01/2009

Then don't bother commenting.

Joined: 07/08/2011

I was actually going for having resource-listing files like how 2DBOY did it. I would use SDL_FreeSurface() to free all the images I'm using between maps, maybe keep one or two images open throughout for the in-between level-loading. It would load the images at the start of maps via those resource lists I was talking about earlier.

Joined: 08/06/2010

Yes, resource lists are a good idea. Monsters, etc. would probably have to be hard-coded unless we invent something like a BSP file.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.

Joined: 09/01/2009

Good call. Looks like you know what you're doing. I'll shut up, then, unless you have specific questions. Smile

Some games have external files that handle monsters and such. Supertux has a sprite-defining file for each object in the game, which is a good idea and all, but kind of gets silly when you have a really simplistic item with only one animation frame, and the file is practically empty as a result. Of course, World of Goo also has a couple of files per Goo Ball, but even the simplest of Goo Balls is quite complex. Aquaria is an interesting example, since Lua scripts are used for each object, and thus fairly complex enemy AI is relatively straightforward. Whatever works best and scales well is a good idea, and if it's in an external file, chances are it'll be fairly easy to mod, especially if you use something user-friendly like XML. Sounds like you know what you're doing, RedTheGreen, so good luck. Smile

Joined: 08/06/2010

For the resource list format, could it be something similar to 2D Boy's, with some modifications:

<Resources>
<SetDefaults format="image" extension=".png" path="./terrain/snow/" />
<Image id="snowtile1" frames="5" />
</Resources>

or
<Resources>
<SetDefaults format="image" extension=".png" path="./terrain/snow/" />
<Image id="snowtile1" />
   <Frame>
      <path>snowtile1_1</path>
   </Frame>
   <Frame show="2.0"> <!--show for 2 seconds-->
      <path>snowtile1_2</path>
   </Frame>
   <Options>
      <option key="color" value="255 255 0" />
  </Options>
</Image>
</Resources>

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.

Joined: 07/08/2011

At the moment, I'm not going for XML. Really, I'm trying to figure out my own system. Like I said before, it'd focus around events, with action flags for said events. Those events can be called by map-data files, monster-data files, etc.

I'm not quite finished with the documentation for it, but the page I have for describing events is copied/pasted as follows:
EDIT: Nevermind. The html formatting on this site is messed up. I can't use normal html escape sequences like <

Link to Events Page: http://project-yami.redthegreen.com/documentation/file-hierarchy/res-fol...

Please note the Documentation is EXTREMELY UNFINISHED and that is one of the few pages I have actually finished. There will be many more, to display information such as how to write files that call the events.

Joined: 08/06/2010

Could you add me to the site? AlbinoPokey is my google account name.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.

Joined: 07/08/2011

Add you to the site? Why?

And I would need your email you signed up with.

Joined: 08/06/2010

I mean the Google Code site, sorry.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.

Joined: 07/08/2011

The Google Code site is not going to be used by me. I originally thought of using the repository functions, but I was confused on how to set it up. The site project-yami.redthegreen.com will be primary for now, unless you have a better idea for a site.

Joined: 11/04/2008

World of Goo uses libpng under Windows and Linux (statically linked 1.2.34).

Joined: 07/08/2011

How hard is it to use libpng over SDL_Image? I think it might be better to switch.

Joined: 09/01/2009

imo, they're relatively equivalent. SDL_Image uses libpng behind the scenes (I think), so if you're using SDL for the rest of the game, just use SDL_Image. It'll save you work converting pnglib's image representation into SDL_Surfaces.

Joined: 07/08/2011

So zlib1.dll is only for SDL_Image? Or would you need it for just plain libpng use? I understand it's probably easier. Eh. At least I found out I can delete those dll's that I don't need. (like the ones for gif and jpeg)

Joined: 02/20/2011

davidc, what is this site run on? maybe red can use the same for the site.

-_-

Joined: 08/06/2010

Drupal.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.

Joined: 07/08/2011

This site? If I have to register a new domain (I probably won´t spend any money. A .com domain would have to either be my own or someone else´s.) it would probably be with Google Sites. It limits html functionality, which is absurd, but you can easily create a full wiki and forum in just a few minutes.

Joined: 07/05/2011

I found this in the console output of World of Goo.
WARNING: D3DXGetImageInfoFromFile failed for 'res/images/islandicon_6.png'
D3DXERR_INVALIDDATA
Invalid data
[t=0.00] could not load texture: res/images/islandicon_6.png

Joined: 08/06/2010

It doesn't exist...but it's trying to load it?

Another hardcoded remnant of Chapter 0, I guess.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.