Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Aug 2010
Offline Last Active May 23 2013 12:03 PM

Topics I've Started

How to best load images upfront?

23 April 2013 - 03:16 AM

I'm working on a 2D game and am starting to see some short lags caused by image decompression (I'm using rather large graphics to support high resolutions). I suppose I'll have to load all my textures upfront and show a loading screen, now I'm wondering how to best go about this. I can think of two approaches:


1. Instantiate all entities for a scene when the scene is being created (Every entity is currently loading its own texture when it is being instantiated, so that should do). The manual effort seems a bit error prone though (easy to forget), and might mess up the code a bit.


2. Have a mapping from image paths to image IDs and use the IDs to load images in the code. That way I can load all the image files when the game starts. But it's tedious to add a mapping for every image I use, and not very flexible as I cannot have loading screens for individual scenes.


I'm not particularly enthusiastic about either approach. How is this commonly being solved? I can find some literature on this that focuses on huge 3D games, but that doesn't seem to apply too well to my small 2D game.

Supporting both high and low resolutions in a 2D game

16 April 2013 - 07:48 AM

I want to support both low-end desktop resolutions (like 1024x768) and pretty large resolutions (that's 2880x1800 for the 15" Retina MBP).


My basic approach is this:

  • Use a large reference resolution (3200x1800) to position/size elements (it's a simulation game that's basically just GUI, so there is no world space, just screen space)
  • Use large artwork, specify its size relative to the reference resolution so that it's scaled at runtime
  • Draw everything scaled down to the actual resolution (using OpenGL's glScale)

But I'm not sure if it's a good approach. It's not a huge game, so I don't think asset size is going to be an issue, but I see some other red flags:

  1. It looks pretty scruffy on lower resolutions like 1280x720. Like as if there's no anti-aliasing. I suppose I could fix that with OpenGL, but it makes me wonder whether I should
  2. I render fonts (using FreeType) at huge sizes like 160 pt, just to scale them down again later. That wastes both memory and makes them look worse then they could. I'm thinking of not scaling fonts and instead calculating font sizes based on the difference between reference resolution and actual resolution, but that's not going to be very exact.

Is there a better approach than what I came up with?

Can't decide which math/physics basics book to get

04 March 2013 - 12:14 AM

I've been pondering which math/physics basics book to get for hours now.

  • My math basics are quite good from my BSc in CS. It's been a while though, and I would like a reference of things relevant to game development.
  • My physics basics are not very strong. I know some basic mechanics but that's about where it ends.
  • I'm mostly working on 2D games. I've worked on 3D games and would like to learn more about the graphics pipeline and rasterisation and such, but I can still get a specialised book on that.
  • I'm looking for information on collision detection and response algorithms.

There are several promising books, I've narrowed it down to just two:


Mathematics and Physics for Programmers

  • Very basic, starts at grade school level
  • More of a textbook than a reference, it seems
  • Covers all the relevant basic math topics: trigonometry, calculus, linear algebra
  • Seems to cover the relevant physics basics, but I can't tell for sure
  • Covers a broad range of topics, even some game theory and AI
  • Has a chapter on tile-based games, which is probably quite relevant to me
  • Uses lots of IMO rather difficult to read pseudo code
  • Uses slightly weird terminology, e.g. they're talking about "squares" instead of boxes when discussing collision detection, and of "collision resolution" instead of "collision response" (which gets much more relevant hits on Google at least)
  • Not well-known authors, doesn't get much praise

Essential Mathematics for Games and Interactive Applications

  • Seems appropriate for my level
  • Seems to use proper terminology
  • Does not cover trigonometry or calculus, doesn't even include a reference of the trigonometric identities
  • Covers linear algebra in much more depth
  • Covers rigid body physics
  • Has a highly interesting chapter on interpolation
  • Covers the graphics pipeline and shaders
  • Semi-popular authors, gets considerable praise
  • It's not on gamedev.net Books for some reason

I really am torn. Getting both seems wrong, as they cover much of the same ground.


MAPFP seems to be less known and less sophisticated, yet I could use a refresher on calculus and would like my reference to include trigonometry. It also has some interesting hands-on topics.


EMFGAIA seems more appropriate for my level, yet covers various things I don't really need right now, working on 2D games. But it seems to be more industry-connected, and at the same time more scientific/accurate.


So, what do you think, which one should I get? Or can you recommend another one appropriate for me?


Loading textures on Android and iOS: libpng or Bitmap/UIImage?

01 January 2013 - 03:23 AM

I'm in the process of porting a C++ SDL/OpenGL desktop game to both Android and iOS. While SDL 1.3 covers both platforms and works pretty well for me, I feel uncomfortable using some random untested Mercurial revision of it, so I've decided to handle the creation of the OpenGL context, input and image/audio loading myself.

The only way to load texture assets from native code in Android 2.2 seems to be opening the .apk with libzip and loading the image with libpng, which is what I've done. I've not started with the iOS port yet, but based on some research, it seems that I can just read the textures from storage and load them with libpng there as well.

While this works, it's a lot of code I don't fully understand yet, so I'm wondering if it isn't better to use each platform's canonical means of loading images, namely Bitmap in Android, UIImage in iOS and SDL_image on desktop. That sounds like inviting a bunch of platform-specific bugs though, I like the idea of having as much shared code as possible.

Does anybody have experiences with either approach? Can't decide which one to go with.

Only white textures on a Windows system with an Intel graphics card - How to debug?

01 November 2012 - 08:21 AM


I'm really stumped with an issue here: I'm working on a 2D game that uses SDL and OpenGL. But for some reason, all textures are white on one particular laptop, under Windows. It works fine under Linux on the very same laptop. It also works fine on another Windows system I have access to.

My only hunch is that it might have something to do with the graphics drivers. It's an older Dell laptop with a Intel 915GM/GMS graphics card, and the official drivers from the CD.

I have no idea how to debug this, what can I try?