Share this post

Link to post

Share on other sites

It''s simple ... if you ever want to consider writing for more than just windows use OpenGL ... otherwise, (if you''re sensible) use OpenGL ... not that i''m biased at all ... but OpenGL is much easier to use, and you''re not restricted by microsoft!

0

Share this post

Link to post

Share on other sites

I also have a question..I know the choice is ours whether we use Opengl or Directx.. either one is usable, but I was wondering. Since Opengl is 3d Orientated is it possible to do exactly the same things, and/or the same quality as DirectDraw, or the 2d Side of D3d?

I''ll explain myself a little better...Say If I wanted to make a 2d RTS Game. Could I use Opengl for this? I would like to use Opengl seeing the code(in my opinion) looks simplier and easier to understand.But Would I have to use Directx? (2d through D3d now with Dx8) The main reason Im asking is, even though you guys have alot of Flame wars about DX Vs OGL, Most of you hardly mention whether its 2D or 3D your refering to. 3D though is mostly the obvious ''subject'' of them. Although I''d just like to know whether Opengl capabilities for 2D are just as good and worthwhile as 2D In Directx..

Thanks

-]Reaper[

0

Share this post

Link to post

Share on other sites

In terms of basic functionality, to be fair, there is very little between the 2 API''s ... they can both do the same thing ... but let me say this ... i am a VB programmer by trade (using the Windows API all the time) ... i know software ... i looked at both API''s, and basically shrugged off direct whatever as a waste of time ... it''s less intuitive than OpenGL, non transportable, and dependant open one vendor - Microsoft ... which to me is a BAD thing!

0

Share this post

Link to post

Share on other sites

You can use a 3D API such as OpenGL or Direct3D/DirectGraphics to draw 2D graphics. So, no, you don''t have to use DirectDraw. If you use a 3D API, you have the benefit of hardware acceleration for things like blending and interpolation. The downside is that you have to deal with texture issues (like the infernal 256x256 limitation imposed by many Voodoo cards), and actual drawing will be done in terms of polygons projected orthographically. So, to draw a "sprite" in a 3D API, you do something like this:

- Set up an orthographic projection (in OpenGL you can do this using the GL Utility Library function glOrtho2D)- Load a texture for the "sprite." The image should have an alpha channel to represent the transparent regions- Bind the texture to the active texture unit (in other words, use the "sprite" texture)- Enable a blending mode that will make the transparent regions in the "sprite" texture draw transparently (in OpenGL this would be done with glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA))- Draw a quadrilateral using the "sprite" as the texture

Again, the benefit of using a 3D API is that all of this will be done with full hardware acceleration. If you use a 2D API such as DirectDraw or Allegro, the steps are somewhat simpler:

- Load the sprite image into a surface which contains a certain color to represent the transparent regions- Tell the API which color will be treated as transparent- Blit (copy) the surface to the active screen buffer (the back buffer or inactive page)

While that looks simpler, consider that this will all be done in software, which means that the API has to test every pixel in the surface, deciding whether or not to draw it. Worse, you won''t get arbitrary levels of transparency like you can with a 3D API (well, you can, but it''s not something built into any 2D API I know of).

So, those are your choices. Honestly, I''d use a 3D API to do 2D stuff.

As for which 3D API is easiest...Honestly, they''re about the same by now. They didn''t start out that way; Direct3D used to be very messy and klunky, but has become increasingly OpenGL-like (in other words, is has become more procedural). It also used to require tons of initialization, but now that''s accomplished using some simple functions, so that initialization is about as simple as initializing OpenGL. But speaking strictly of the API, many programmers still feel that OpenGL is cleaner and programmer-friendly (John Carmack still holds this opinion, though he fully acknowledges that Direct3D 8 has become very good). Also, OpenGL has the potential to exploit features much sooner through its extension mechanism than in Direct3D.

My suggestion is to use OpenGL. It''s simple, friendly, platform-independent, and fast.

Share this post

Link to post

Share on other sites

One thing I really like about OpenGL is that it doesn''t require a bajillion classes to work. That makes creating OpenGL wrappers easier.

One thing that everyone says (and it is true) is that OpenGL and DirectX are tools. If you want to make a 2d game, pick the one that works the best.

If you are going to make a tile based game with all your sprites being 64x64 or something, then 3d is definately a very good way to go. Of course, that doesn''t decide whether Direct3D or OpenGL is better.

If you want to do something freaky like rendering on the desktop, having sprites fly out your window (Like Catz or Dogz), or if you want to display sprites bigger than 256x256 and don''t want to worry about video cards not being supported, DirectDraw (Dx7)is probably simpler.

I''d try out both. There are people that use Direct3D, and there are people that use OpenGL, and both groups swear by that api. Therefore, I''m lead to assume that both apis are great, but they require different styles of programming, and Direct3D fits one groups style, and OpenGL fits the other group''s style.

Cons: You never could know what to expect from Microsoft; D3D it''s VERY unstable (unless you have a GeForce3), VERY messy (COM based) and with a painful learning curve and poor documentation (books and websites).

OpenGL:

Pros: portable; very easy and elegant in terms of codign; has a few characteristics that D3D cannot rival, like Display Lists and the use of extensions; I have made my own benchmarks and - at least on my system - it''s faster, has better magnification/minification filters, and a more accurate aspect ratio of the meshes displayed. And finally, has better documentation (books, websites).

The bottom line: I like more OpenGL and I think it will become better and better than D3D. Anyway, the best thing is to learn BOTH APIs and make your OWN choice.Anyway, if you stick with OpenGL, you would need (maybe) DirectInput, DirectPlay, DirectSound and DirectMusic, which are very cool and stable.

Share on other sites

- Direct3D/DirectGraphics (the analog to OpenGL) doesn''t have input or sound, either. - OpenGL and GLU have a lot of the functionality found in Direct3DX. What isn''t there is sufficiently easy to duplicate in extensions or combinations of existing functionality. And—as far as I know—no part of DirectX has anything to draw things like NURBS surfaces.

Share this post

Link to post

Share on other sites

Objects are a bad thing for games! objects are ok in a business environment, but if you interested in what is involved with object instantiation, look at any basic windows insider sites ... the number of CPU cycles involved when dealing with object is absolutley horrendus!!! if you want fast code, don''t go anywhere near objects!!! if you just want readable code, or code that is transportable to other apps, then objects are fine!

From a professional programmer!

Regards!

0

Share this post

Link to post

Share on other sites

Ok,I use openGL cause it is Extremely good for 3D Graphics and, if your a decent enough programmer you can do some good 2D stuff. Know, the really kicker. In a book called "Game Design : Secrets of the Sages", John Carmack ( Lead programmer for id Software, Quake III Arena, etc....) said this, "I believe DirectX is a disgustingly broken API". Considering that he is one of the best game programmers alive, I would listen to what he says. :-)

0

Share this post

Link to post

Share on other sites

Guest Anonymous Poster

Guest Anonymous Poster

quote:Shag wrote:the number of CPU cycles involved when dealing with object is absolutley horrendus!!!

That is such a common misconception. Calling (non-virtual) methods in an object is no more expensive than calling a regular function and passing a pointer as an argument, something that is very common in non-object oriented code. Calling a virtual method involves one extra pointer dereference, thus adding a _few_ cycles. The benefits of virtual methods can however often be worth the small overhead (typically not noticable unless you call them very often in a loop or similar).

And instantiating objects is not something you should do in the main loop (at least not in large quantities), so it''s not really time-critical; not that it''s particularly expensive, it''s simply a memory allocation and a function call (the constructor).

The thing that might get surprisingly expensive is allocating arrays of objects, since the constructor will have to be called for each object in the array. But as I said above, simply avoid doing this in your main loop, do it during init.

Btw, I didn''t mean this as a flame, even though it might sound so, I just meant it to be informative, and of course you and I might have different notions of what ''horrendous'' means

Share this post

Link to post

Share on other sites

That particular quote was from a long time ago, but Carmack still prefers OpenGL. I forget where I saw him say this, but he did. In a conference or something Brian Hook talked about the OpenGL vs. Direct3D issue (specifically Direct3D 8) and called OpenGL a "great enabler," essentially saying that he still prefered OpenGL because it was still just a little easier.