Sign in to follow this  
Le_Danse_Macabre

Libraries

Recommended Posts

I use Win32 plain and simple (or Lean and Mean, depending on your fancy) and I was wondering if it would be a better idea to learn a library like SDL to do all my graphics and shizzy. Is Win32 good, or is something like SDL better?

Share this post


Link to post
Share on other sites
dave    2187
In short, yes it would be a very good idea to learn a library. Win32 is slow where as graphics libraries are designed to be a single layer between you and the hardware. They are much faster.

Go for it and good luck.

ace

Share this post


Link to post
Share on other sites
Spoonbender    1258
Depends on what you need, obviously. Win32 is made to draw windows. That means it's relatively effective when it comes to drawing static, nonchanging rectangles that are only occasionally moved or resized.

When you try to make something that's updated and changed 60 times a second, it'll grind your system to a halt though. ;)
So yes, another API would be a very good idea if you plan to make games.
(Although Win32 and GDI is excellent for Tetris, actually)

SDL is pretty popular, but I don't have much experience with it myself. It's supposed to be one of the easier ones to learn.
Althernatives would be OpenGL, Direct3D or DirectDraw (The first two are obviously made for 3D, but there's no reason you can't do 2D in them as well).

Share this post


Link to post
Share on other sites
dave    2187
I've heard many rumours as to SDL and OpenGL being the easiest to get started on. I use DirectX and i have been for a long time. With it, once you get used to the general approach to the problem and how COM works you are fine.

Also this is a good resource here.

EDIT: Direct Draw is not included with the current DirectX SDK. It has been made obselete but everything can be done with Direct3D in a slightly different way and more easily in my opinion.

ace

Share this post


Link to post
Share on other sites
AcePilot    252
I just have a little suggestion if you are planning on using DirectDraw.
DirectDraw is getting pretty old now, and i doubt it will be supported on
future hardware. So if you are interested in starting 2D programming, i
suggest you go with Direct3D. Direct3D defines an object called ID3DXSprite.
This amazing object allows you to have incredible control over 2D aspects
of your game (such as sprites) and it allows 2D objects like sprites to be
rendered with 3D acceleration, in other words, it lets the graphics card do
some of the work for you.


ID3DXSprite *mysprite;
D3DXCreateSprite(mydevice, &mysprite);

// this has been taken directly from the d3dx9 header files:

//////////////////////////////////////////////////////////////////////////////
// ID3DXSprite:
// ------------
// This object intends to provide an easy way to drawing sprites using D3D.
// (functions:)
// Begin -
// Prepares device for drawing sprites.
//
// Draw -
// Draws a sprite. Before transformation, the sprite is the size of
// SrcRect, with its top-left corner specified by Position. The color
// and alpha channels are modulated by Color.
//
// Flush -
// Forces all batched sprites to submitted to the device.
//
// End -
// Restores device state to how it was when Begin was called.
//
// OnLostDevice, OnResetDevice -
// Call OnLostDevice() on this object before calling Reset() on the
// device, so that this object can release any stateblocks and video
// memory resources. After Reset(), the call OnResetDevice().
//////////////////////////////////////////////////////////////////////////////

Share this post


Link to post
Share on other sites
Will F    1069
Quote:
Original post by ace_lovegrove
I've heard many rumours as to SDL and OpenGL being the easiest to get started on.


SDL is really easy to get started with. It's also cross platform (which is good for me as I do my development on Linux), but works great with windows. It's also really easy to set up OpenGL with SDL.

OpenGL is great, a little tough to get started with in that there is alot to learn, but really powerful (take a look at Doom 3 to see something it's capable of doing graphically). However, it might be a bit overkill for a 2D game (then again I've got a side project that is a 2D roguelike game which i'm using SDL and OpenGL for).

Share this post


Link to post
Share on other sites
fireside    122
I'll put in my usual pitch for clanlib. I really like it for 2d work. It has a great sprite library and resource management system using xml files. Lots of example code comes with it and 2 tutorials. If your familiar with c++ programming, it's great.

Share this post


Link to post
Share on other sites
chad_420    290
Allegro is a great begginers 2d graphics/game library though it is getting a little dated. In dev-cpp goto tools menu then package something or other and ittl let you download and install libraries like SDL, directx8, and allegro at the click of a mouse.

Share this post


Link to post
Share on other sites
EnemyBoss    223
Even for games using only 2D graphics, its better to use OpenGL or Direct3D. The reason is that you want to off-load as much of the graphics processing and image data onto the GPU and video memory as possible. Most computers are equipped with a 3D graphics card these days, so it makes sense to do this.

I don't know for certain how SDL handle's surfaces, whether they allocate memory from VRAM or general RAM. But lets say in a double buffered scheme, it draws on a surface in general RAM. Then every time it updates the screen, it must blit through the System/AGP bus to the video buffer on the graphics card.

So lets say you represent a sprite as a rectangle polygon with the sprite image as the texture. With these 3D APIs such as OpenGL, you can put sprite textures into VRAM, and you can compile instruction lists to move and transform these rectangles, which the GPU can process on its own. This way, all the graphics processing happens in the video card where it belongs, and you can free your system bus and dedicate your CPU to other important things. (Please correct me If I said anything wrong here. I'm still learning this stuff.)

If however you're doing 2D demo effects, or graphics processing where you would be changing or moving individual pixels in an image or video surface, then SDL is fine. SDL is also great for wrapping all the other DirectX elements such as keyboard, mouse and joystick handling and sound. Combined with OpenGL, you have a very good game library in a simple C interface.


Share this post


Link to post
Share on other sites
Daaark    3553
Quote:
Original post by chad_420
Allegro is a great begginers 2d graphics/game library though it is getting a little dated. In dev-cpp goto tools menu then package something or other and ittl let you download and install libraries like SDL, directx8, and allegro at the click of a mouse.


Chad speaks the truth. :) Allegro is good, and VERY easy to use.

www.allegro.cc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this