Hello
I'm going to start working on a 2d statagy game which won't be graphic intensive. I don't know weather it is worth learning directx/OpenGL or just using the GDI?
DirectX seams overly complicated and seams overkill for doing 2d graphics.
But the GDI isn't designed for games.
Is there a simple way to do 2d graphics in openGL?
I appreachiate all thoughts.
Posted on 2004-12-12 01:19:30 by QuantumMatrix1024
GDI: slow on most machines, thus unusable
DirectX 3D interface: easy to add cool alpha-effects, can save you prerendered rotation of bitmaps (imagine a turret that rotates, you'll understand)
DirectDraw: easy to start, alpha-effects will have to be drawn by you
OGL: the best choice, since it has all good stuff of the above ones, and nothing bad (imho). Easy coding, a bunch of effects and transformations, support for compressed images, direct support for keyboard and stuff. I haven't coded in OGL yet (but I have seen many examples) , so I can't give tutes and pointers. Soon in the following replies I'm sure you'll be given more info. :mrgreen:

http://www.thepixels.net/ has some tutes on other stuff that I liked, maybe it'll help a bit
Posted on 2004-12-12 08:51:21 by Ultrano
Stay away from OpenGL for 2D business... only ATi and NVidia have good OpenGL support, and ATi even lacks somewhat (try running blender3d on ATi hardware with recent detonators and you'll see what I mean).

DirectX, on the other hand, runs pretty well on all the hardware it supoprts, and is the natural choise for windows programming.
Posted on 2004-12-12 09:15:41 by f0dder
DirectX, on the other hand, is subject to far-reaching changes every six months or so, requiring a complete reworking of the includez.

I am ambivalent - DX or OGL are the choices you have. Note that you can use "3d aided 2d" - imagine your flat 2d tiles are flat 3d tiles, you can decide whether to view them head-on (orthographic projection, loks just like 2d) or whether to show them from an angle (isometric views etc)... and that if you choose to use this 3d-aided 2d stuff that you get access to texturemapping (UV coordinates for each corner of each "tile") which means you can stretch images to fit with zero code required, it'll all happen in hardware :) This can be one of the most expensive operations for regular 2d tile rendering :)
Posted on 2004-12-12 21:47:40 by Homer
I use DX DirectDraw for HostileEncounter game :D

It will run on most video cards with or without 3D acceleration... besides asking for 3D acceleration for a 2D game is kind of funny :D

If you use an Isometric or flat fixed projection you do not need to strectch any bitmap at all.

The only real problem wit Directdraw for 2D is the lack of alpha blending support (so you will have to code your own ASM routines)

And the fact that you must use DirectDraw 7
Posted on 2004-12-12 23:30:16 by BogdanOntanu
besides asking for 3D acceleration for a 2D game is kind of funny :D


No, it's not funny.. after all, once everything is said and done, the prime occupation of a graphic accelerator card is to throw 2D triangles at the video display. We can't forget this even if we only want to code 2D, we can and SHOULD take advantage of hardware acceleration even though it seems silly at first glance. It took a while before I realized that, but hey under DirectX you are likely benefiting from this via the HAL layer anyway (I assume you use the HAL rasterizer)

Also you totally missed my point about "stretching" images via UV mapping... we simply move the UV coordinates to use a partial texture (ie a tilebased texture) and/or to create zoom and rotation effects , all in hardware, and with effortless code.
Posted on 2004-12-12 23:34:23 by Homer
on the openGL speed: the only videocard I had where I preferred running games in DirectX mode is S3Trio3D2X with 4MB RAM. Then I got a GeForce2 and now - R9200, so I have forgotten how laggy OGL can be on old cards :) . But I still think everybody buys either an nVidia or ATI card :P

2D made in 3D isn't very ridiculous, as I learned after I made a few software 3D engines for PalmOS ;) . I know, it'll be damn harder for us 2D coders to do that :cry: , but think about how much 2D artwork and memory this can save to make 3D objects that can rotate in any direction. Rendering the 3D object in the game for me is much easier (and with smoother rotation) than having the object prerendered. I am doing all the artwork myself, so I'd like to save myself some work + if I can add semitransparency to the models, so much the better :wink: . But still, if you won't be needing much rotation and many cool effects, 2D is the choice.
Posted on 2004-12-13 00:22:37 by Ultrano

DirectX, on the other hand, is subject to far-reaching changes every six months or so, requiring a complete reworking of the includez.

Not necessary, unless you want to use bleeding-edge features... You can still happily use the ddraw2 interface even with dx9.0b :-)


so I have forgotten how laggy OGL can be on old cards :)

Unfortunately not just old cards - some 2D operations are slow even with a r9600 because of the drivers. Blender3D 2.33 is unusable on my system with catalyst 4.something because of this. I don't know how it is with the other non-nvidia cards - there's a few players on the market, including intel on-board chipsets.

If you want bleeding-edge, you'll want DirectX because it has the latest and greatest features. If you don't need bleeding-edge and want your software to run on older hardware, you'll want DirectX because it performs best on the widest range of hardware. Why would you want OpenGL, apart from portability and "it's somewhat easier to program"? :)
Posted on 2004-12-13 02:44:18 by f0dder
I'm going to go with directx but I was very tempted to use opengl because what I've seen so far of direct3d dosen't look so easy to understand. maybe it will become clear once I learn some 3d concepts.
anyway thanx for the help.
Posted on 2004-12-13 06:58:57 by QuantumMatrix1024
Having had some experience with 3D coding under both DirectX and OpenGL now, I feel qualified to make the following bold statement:
from a programmer's perspective, they are essentially the same animal.
Creating a render window for example is almost identical under both libraries.
Posted on 2004-12-13 22:44:21 by Homer
And remember that karmak (is writed like that ) normally uses OpenGL :D just for the shake that some of his games where of impact to the gamers community.


Dont know if Doom was, I guess no, but normally all the games by this guy are based on OpenGL.. pheraphs a strange attraction :D, nice guy, I also go in the side of OpenGL.


DirectX, on the other hand, runs pretty well on all the hardware it supoprts, and is the natural choise for windows programming.


Not is best to say that the HW suport the SW???, try run a DX 9 (sure with DX 9 installed) application in a old Graphic card and pheraphs that is the point, I havent done that but I guess the software cant suport the hardware :), pheraphs the HW developers follow some guidelines for suport in a best way DX or OpenGL.



Dont know, pheraphs there exist a real analisis (not comparations) in what are capable each one, analizing is interface, usability, expressionism (dont know how to say) easy to use and easy to read, and others things... you see semantics there ??? ;).
Posted on 2004-12-13 23:15:27 by rea
Original doom wasn't OpenGL, it was 100% software rendering. Quake1 didn't use OpenGL either, until GLQuake was released. And anyway, Carmack is quite the nutjob...


try run a DX 9 (sure with DX 9 installed) application in a old Graphic card and pheraphs that is the point, I havent done that but I guess the software cant suport the hardware

Of course that won't work, but neither would an OpenGL app using advanced features. Generally, if a software emulation path is followed in either API, your framerate drops to sub-zero. DirectX still tends to have the better support, though. Anybody remember the days of GL mini-drivers? >_<
Posted on 2004-12-14 00:52:19 by f0dder
Yep, I only whant to show that HW suport SW :) but SW can provide some guidelines pheraphs (?? dont know), dosent matter even DX or OpenGL, like I have readed a "simple" standar like the VESA extensions some times they are not well implemented or even suported :).

There is not a choice of the "library" used, is a selection of the vendor of the graphic card (to suport, not to suport or provide a litle suport), like I say, should be nice a real analisis of DX and a real analisis of OpenGL (not a comparation, but handle each one like is deserved for itself) provide them a virtual perfect GPU or CPU or a perfect virtual machine first for analize what do one and what do the other, whitouth matter if is well suported in the side of the HW. Then there you will know the specific things of each one (semantics), cohesion, readability, expandability dont know... .

After know each one of this monsters (in a good way) you can provide real life specs, ie, how many cost do a computation X in each one enviroment or what HW need be done for suport this computation, is like delete the virtual CPU and provide analisis for computation time.

In that way can you know what is what, but actually there is no way, because DX is most suported because MS is at the side and the market for the graphic vendors is more wide, but what happend if OpenGL o other one there is best in terms of the virtual CPU?, and because in the real life there is no vendor that suport this standar or library it can not be watched at all the light...?

Anyway, this is a extra and only supositions and sugestions :) you have made your choice only stay with your mind open :D.


-------

By the way I dont know the mini-drivers :).
Posted on 2004-12-14 01:17:21 by rea
I remember the minidrivers :(
I'm sure glad those days are behind us :)
Posted on 2004-12-14 09:31:50 by Homer
And I'm glad I've missed them (plus a lot other bad things like 8 or 16-bit code) :twisted: - started coding in 2001. :-D
Posted on 2004-12-14 15:05:13 by Ultrano