I'm working on a game with a scrolling background. The problem is I'm using very very big images as textures in the background, and the iphone doesnt have enough memory to work with those images. I was wondering if it is possible to load textures dynamically in the animation loop, using gltexsubimage2d instead of glteximage2d.
I can run my program with 10 pictures instead of 20, but my levels would be kinda short. But even when I use 10 pics I have problems: the textures should be placed next to each other nicely, but between every texture there is a nasty line of unwelcome pixels... any idea how to fix this?
Dynamically loading/unloading the textures sounds like the thing to do. Can you just split your background into tiles and keep track of which ones are visible?
Dynamically loading/unloading the textures sounds like the thing to do. Can you just split your background into tiles and keep track of which ones are visible?
I solved my second problem (with the flashing lines between textures): just use GL_CLAMP_TO_EDGE as a parameter for glTexParameterf()
But one problem still remains: Dynamically loading textures would take away a lot of performance, and tiles are worthless for a game without repetition of textures. My background is different everywhere...
What I do not understand: it is said that the iphone has 30mb memory for my textures, but my texture ( which is 1024*10240 big, shame on me ) is only 500 kb big... Why cant it load the texture then?
Maybe I should load tiles instead, but I dont quite know what to do with that idea...
I know the solution to my problem now: pvrtc textures are a huge change. I always wanted to avoid that type as they seemed to be very ugly and they took a lot more ROM, but the uglyness wasnt as bad as I thought, and its very helpful for using less RAM. Anyone who has problems with big backgrounds (which are not made of tiles, cfr asterope) should use pvrtc.
And in addition, the time it takes to load 10 1024*1024 textures is very very small.
There is still one problem though: I now have a fuzzy group of pixels between two textures, and I am using GL_CLAMP_TO_EDGE...
I know the solution to my problem now: pvrtc textures are a huge change. I always wanted to avoid that type as they seemed to be very ugly and they took a lot more ROM, but the uglyness wasnt as bad as I thought, and its very helpful for using less RAM. Anyone who has problems with big backgrounds (which are not made of tiles, cfr asterope) should use pvrtc.
And in addition, the time it takes to load 10 1024*1024 textures is very very small.
There is still one problem though: I now have a fuzzy group of pixels between two textures, and I am using GL_CLAMP_TO_EDGE...
Quote:
What I do not understand: it is said that the iphone has 30mb memory for my textures, but my texture ( which is 1024*10240 big, shame on me ) is only 500 kb big... Why cant it load the texture then?
The iphone doesnt load the textures as png's, but as bmp's, which are much larger of course.
Veiledgames.com is a great website for learning bout pvrtc textures. Thanks to those guys I was able to solve all my problems.
Quote:
There is still one problem though: I now have a fuzzy group of pixels between two textures, and I am using GL_CLAMP_TO_EDGE...
I read at veiledgames.com that pvrtc textures do have a weird edge. The best solution is to overlap them with png textures (with a width of 32 pixels or less).
If you have problems just ask I may be able to help you as I searched for a solution during hours.
Last edited by Gal; 09-02-2009 at 12:15 PM.
Reason: I forgot to solve one of my problems
I am going to be implementing the scrolling background for my app soon, which means doing exactly as you have done. Where did you start? Where should I start? I am only animating the background in this way (I think anyway) the rest of the game, I have animated using UIImageView PNG animations etc. I am completely new to OpenGl and even how to begin using it.
I am going to be implementing the scrolling background for my app soon, which means doing exactly as you have done. Where did you start? Where should I start? I am only animating the background in this way (I think anyway) the rest of the game, I have animated using UIImageView PNG animations etc. I am completely new to OpenGl and even how to begin using it.
Thanks in advance for any help you can provide!
All right Im typing on my ipod so I cant post my code, but I can give you some advice now:
- simon maurice made a wonderful blog about opengl es: google ' simon maurice opengl' and you will find it.
- I made my scrolling background by making ten squares in space, each filled with a different texture. Then i move from left to right using gltranslatef (as described by simon maurice). Ill give you my code, but in the meantime you can have a look at the default opengl app in xcode. The important part is the drawview method, where everything is drawn.
For making 2d games youll need my code, but ill post it tomorrow (i dont know what time it is in your country but its 11 pm here).
Anyways what kind of app are you gonna make cuz it would be kinda annoying if you make the same app as mine I would be helping you to be my concurrent :S.
Just dont forget: simon maurice is THE reference for opengl es tutorials. I almost read all his lessons, but you can skip most of them.