increase performance with SDL
Moderator: PC Supremacists
increase performance with SDL
Hi everyone, I am new developing a 2D game with C++/SDL for Linux, but not programming.
The target hardware where the game will be played isn't powerful, 256RAM at most. So, openGL is out of discussion.
I have sheet srpite file, it contains the character movements, and several files for the backround and other sprite files to put on a layered fashion way.
When the applications keeps simple, the character/sprite can jump, it moves to left, right, up and down, etc. It works fine.
By simple I mean: one background and the sheet sprite.
According I add more screens and sprite it desceases the speed in a unplaying way.
I think I did a bad choice: I upload the sprite sheet at the begining and the rest of the screen are loaded on demand from disk, but I think is very 'CPU expensive'.
I plan to upload more than one screen/file to memory and switch between them on demand. Is this the correct manner?.
I'll chek the bit format of the screen to be the correct SDL_Displayformat before bliting, and etc.
Any suggestion for the best strategy? or the format file to work with?
Thanks
Kovi
The target hardware where the game will be played isn't powerful, 256RAM at most. So, openGL is out of discussion.
I have sheet srpite file, it contains the character movements, and several files for the backround and other sprite files to put on a layered fashion way.
When the applications keeps simple, the character/sprite can jump, it moves to left, right, up and down, etc. It works fine.
By simple I mean: one background and the sheet sprite.
According I add more screens and sprite it desceases the speed in a unplaying way.
I think I did a bad choice: I upload the sprite sheet at the begining and the rest of the screen are loaded on demand from disk, but I think is very 'CPU expensive'.
I plan to upload more than one screen/file to memory and switch between them on demand. Is this the correct manner?.
I'll chek the bit format of the screen to be the correct SDL_Displayformat before bliting, and etc.
Any suggestion for the best strategy? or the format file to work with?
Thanks
Kovi
- Light-Dark
- Dreamcast Developer
- Posts: 307
- Joined: Sun Mar 13, 2011 7:57 pm
- Current Project: 2D RPG & NES Platformer
- Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
- Programming Language of Choice: C/++
- Location: Canada
Re: increase performance with SDL
first 2 sentences in and i see some problems, first you could elaborate on the hardware your using and by 256 ram what does that mean? it could mean 256 bits of ram, it could be 256 bytes,kilobytes,megabytes,gigabytes,etc, to sum it up could you be a little more specific and share some more details :S?kovicic wrote:Hi everyone, I am new developing a 2D game with C++/SDL for Linux, but not programming.
The target hardware where the game will be played isn't powerful, 256RAM at most. So, openGL is out of discussion.
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: increase performance with SDL
Considering it's Linux, 256 KB and 256 GB are both ridiculously unreasonable assumptions, leaving 256MB as the only one which makes sense. I honestly don't see how that was so complicated to figure out.Light-Dark wrote: first 2 sentences in and i see some problems, first you could elaborate on the hardware your using and by 256 ram what does that mean? it could mean 256 bits of ram, it could be 256 bytes,kilobytes,megabytes,gigabytes,etc, to sum it up could you be a little more specific and share some more details :S?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- Light-Dark
- Dreamcast Developer
- Posts: 307
- Joined: Sun Mar 13, 2011 7:57 pm
- Current Project: 2D RPG & NES Platformer
- Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
- Programming Language of Choice: C/++
- Location: Canada
Re: increase performance with SDL
just pointing out that it could be a little more specific thats all.dandymcgee wrote:Considering it's Linux, 256 KB and 256 GB are both ridiculously unreasonable assumptions, leaving 256MB as the only one which makes sense. I honestly don't see how that was so complicated to figure out.Light-Dark wrote: first 2 sentences in and i see some problems, first you could elaborate on the hardware your using and by 256 ram what does that mean? it could mean 256 bits of ram, it could be 256 bytes,kilobytes,megabytes,gigabytes,etc, to sum it up could you be a little more specific and share some more details :S?
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
- jakobnator
- Chaos Rift Newbie
- Posts: 20
- Joined: Thu Mar 31, 2011 8:14 pm
- Current Project: Black Jack
- Favorite Gaming Platforms: N64,DC,PC,360
- Programming Language of Choice: C++0x
- Location: (n): A particle place in physical space.
Re: increase performance with SDL
I am not sure how well SDL works with .jpeg but when it comes to the file format .jpeg will be the least intense on the CPU. What kind of sprites are these 16-bit? If so I think if you upload it as a jpg it should look fine. I for one have never had a problem loading all of the sprite sheets at the beginning. I really don't think its the art check the coding for memory leaks and what not.
Current Games:
Black Jack [WIP]
Tic Tac Toe [SDL]
Tic Tac Toe
- superLED
- Chaos Rift Junior
- Posts: 303
- Joined: Sun Nov 21, 2010 10:56 am
- Current Project: Engine
- Favorite Gaming Platforms: N64
- Programming Language of Choice: C++, PHP
- Location: Norway
Re: increase performance with SDL
Seriously? Is .jpeg more efficient than .bmp formats?jakobnator wrote:I am not sure how well SDL works with .jpeg but when it comes to the file format .jpeg will be the least intense on the CPU. What kind of sprites are these 16-bit? If so I think if you upload it as a jpg it should look fine. The sprite sheets I really have never had a problem loading all of the sprite sheets at the beginning. I really don't think its the art check your coding, most machines should handle a 2-D computer game.
And yes, modern computers can easily handle a 2D game, but I guess they are making a game for a somewhat old/limited system.
- Light-Dark
- Dreamcast Developer
- Posts: 307
- Joined: Sun Mar 13, 2011 7:57 pm
- Current Project: 2D RPG & NES Platformer
- Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
- Programming Language of Choice: C/++
- Location: Canada
Re: increase performance with SDL
i use png format, does sdl provide any documentation to which format is less CPU intesitve or is this from personal experince?superLED wrote:Seriously? Is .jpeg more efficient than .bmp formats?jakobnator wrote:I am not sure how well SDL works with .jpeg but when it comes to the file format .jpeg will be the least intense on the CPU. What kind of sprites are these 16-bit? If so I think if you upload it as a jpg it should look fine. The sprite sheets I really have never had a problem loading all of the sprite sheets at the beginning. I really don't think its the art check your coding, most machines should handle a 2-D computer game.
And yes, modern computers can easily handle a 2D game, but I guess they are making a game for a somewhat old/limited system.
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
- superLED
- Chaos Rift Junior
- Posts: 303
- Joined: Sun Nov 21, 2010 10:56 am
- Current Project: Engine
- Favorite Gaming Platforms: N64
- Programming Language of Choice: C++, PHP
- Location: Norway
Re: increase performance with SDL
Png is an easy format to work with. It has an Alpha Channel, compressed somewhere between .jpg and .bmp (correct me if I'm wrong). With the Alpha Channel, you don't need to paint pink color on the parts that should not be drawn. That way, you can also use different values of Alpha, like a fading-effect or similar.Light-Dark wrote:i use png format, does sdl provide any documentation to which format is less CPU intesitve or is this from personal experince?superLED wrote:Seriously? Is .jpeg more efficient than .bmp formats?jakobnator wrote:I am not sure how well SDL works with .jpeg but when it comes to the file format .jpeg will be the least intense on the CPU. What kind of sprites are these 16-bit? If so I think if you upload it as a jpg it should look fine. The sprite sheets I really have never had a problem loading all of the sprite sheets at the beginning. I really don't think its the art check your coding, most machines should handle a 2-D computer game.
And yes, modern computers can easily handle a 2D game, but I guess they are making a game for a somewhat old/limited system.
.bmp files are more compressed and space friendly, but the quality (the amount of colors) are not that good. Old computers was stricted to this format because it took up so little space.
I don't think .jpg formats have an Alpha Channel. Maybe some 'versions' but it's not the standard.
And I also think .png is the standard format on the web as well, due to its decent quality and the little space it takes, and the Alpha Channel.
This may not be 100% correct, and it may be outdated.
- jakobnator
- Chaos Rift Newbie
- Posts: 20
- Joined: Thu Mar 31, 2011 8:14 pm
- Current Project: Black Jack
- Favorite Gaming Platforms: N64,DC,PC,360
- Programming Language of Choice: C++0x
- Location: (n): A particle place in physical space.
Re: increase performance with SDL
Some versions of .bmp have an optional alpha channel, not sure if you can use it with SDL.
Current Games:
Black Jack [WIP]
Tic Tac Toe [SDL]
Tic Tac Toe
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: increase performance with SDL
SDL can do alpha blending, but it's very slow about it. This is primarily because SDL cannot take advantage of optimized array-copying techniques (memcpy is pretty good), and has to do extra processing for every pixel it blits.jakobnator wrote:Some versions of .bmp have an optional alpha channel, not sure if you can use it with SDL.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.