[SDL] 2D with openGL & SDL
benang at cs.its.ac.id
benang at cs.its.ac.id
Wed Jul 18 19:48:28 PDT 2007
Well, I'm still going to try remaking my engine again. But not for the
current game because it will require a lot of redesigning. Whether it's
the game itself, the engine, or the artwork. Because the current artwork
is 1 BMP file for 1 sprite (except for the bitmap fonts). That's what the
artist usually do, so I just go with the flow and make my rendering engine
accommodate the artist's way to make assets.
Probably I'll just make a newer engine for the next project. And for this
new engine I'll ask the artist to make the each BMP file consists of
several sprites.
FYI, the next project is actually a 3D. But the project leader still
trying to determine whether we'll go pure 3D or a pre-rendered 3D assets
drawn in a 2D environment. For pure 3D he said we'll use Torque, but for
pre-rendered, I just have to remake my SDL engine.
Thanks a lot though.
Sean Middleditch said:
>
> On Wed, 2007-07-18 at 10:38 +0700, benang at cs.its.ac.id wrote:
>> Oh yeah, there's also that approach. As a matter of fact, actually my
>> current rendering engine already can blit sprites from an image file
>> with
>> multiple sprite images inside it. But I determined that the sprite
>> images
>> in the BMP file must be of the same width and height (eg. all must be
>> 16x16, 40x30, etc). I use this to blit my bitmap fonts. This probably
>> will
>> make the 2D artist complains. Well thanks anyway.
>
> ::sigh:: Think about it a little more. You're dismissing a very
> elegant and correct solution simply because it isn't the same as your
> existing solution.
>
> There is no reason that all of the sprites in one BMP have to be the
> same size. At all. As I said, each sprite can have its own width,
> height, and its own offset within the texture image. It takes a little
> more code than making everything the same size, but it's worth it.
>
> It doesn't take any real additional work on part of the artists, either,
> especially if you're already using packed sprite image files.
>
> Note that this is *exactly* how just about any 3D game handles model
> textures. Take a complex model like a medieval knight. Most engines
> will use a single texture bitmap which is packed with the required
> patches of chain maille, flesh, cloth, hair, eyes, etc. and map that
> single texture over the model's vertexes. Most professional 2D games
> (i.e, the actual SNES golden games) did the same thing. Most tiled/2D
> games get that wrong, because most tile rips you'll find of those old
> games are done with screenshots and an image editor, not the actual
> image packs from the ROM. There's a reason the old games did it that
> way - it worked, it was memory efficient, and it was easy for artists to
> handle.
>
>>
>> Sean Middleditch said:
>> >
>> > On Mon, 2007-07-16 at 22:08 -0700, Mike Powell wrote:
>> >> benang at cs.its.ac.id wrote:
>> >> > 4. AFAIK, to add a texture, the width & height of the image should
>> be
>> >> a
>> >> > power of 2. So how do I make a sprite with width and/or height not
>> of
>> >> > power of 2?
>> >>
>> >> This was true in the old versions of OpenGL, but I know it's been
>> >> fixed by OpenGL 2.0. Not sure, offhand, exactly which version made
>> the
>> >> shift, but if your version is up to date, you should be able to use
>> >> any texture size. Provided, of course, it's not larger then your
>> >> implementation's maximum texture size. These days, that's usually
>> >> either 512 or 1024, so you probably won't have a problem there.
>> >
>> > I think OpenGl 1.5 also has this restriction removed, and it's quite
>> > possible the driver supports 1.5 but not 2.0. (2.0 makes GLSL
>> > required.)
>> >
>> > There are various things you can do to alleviate the texture
>> > limitations, though. One trick is to pack multiple
>> > tiles/images/textures into a single OpenGL texture, which if done
>> > carefully, will let you use a max sized texture with little wasted
>> > space. You then just have to remember the texture ID, width, height,
>> > x/s offset, and y/t offset of your image in the texture, and pass
>> those
>> > various parameters in when rendering your quads. It can also help to
>> > just design your graphics around powers of two dimensions if at all
>> > possible. Especially if you're making a tile-based game and not some
>> > other kind of app, splitting up your tiles into smaller 16x16 or 32x32
>> > bits would be a good idea. (Few people realize this, but the tiles in
>> > old 2D Nintendo games were actually very very small - most of the tile
>> > "rips" you find online don't actually rip the tiles, but larger
>> squares
>> > made of multiple tiles, so a lot of people think they're bigger than
>> > they really are.)
>> >
>> >> _______________________________________________
>> >> SDL mailing list
>> >> SDL at lists.libsdl.org
>> >> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>> > --
>> > Sean Middleditch <elanthis at awesomeplay.com>
>> >
>> > _______________________________________________
>> > SDL mailing list
>> > SDL at lists.libsdl.org
>> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>> >
>>
>>
>> Fare thee well,
>> Bawenang R. P. P.
>>
>> ----------------
>> ERROR: Brain not found. Please insert a new brain!
>>
>> âDo nothing which is of no use.â - Miyamoto Musashi.
>>
>> "I live for my dream. And my dream is to live my life to the fullest."
>>
>>
>> _______________________________________________
>> SDL mailing list
>> SDL at lists.libsdl.org
>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> --
> Sean Middleditch <elanthis at awesomeplay.com>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
Fare thee well,
Bawenang R. P. P.
----------------
ERROR: Brain not found. Please insert a new brain!
Do nothing which is of no use. - Miyamoto Musashi.
"I live for my dream. And my dream is to live my life to the fullest."
More information about the SDL
mailing list