Click to See Complete Forum and Search --> : API for 2d Emulator programming


teleplayr
April 28th, 2006, 04:27 PM
Hey all. I've got an emulator I used DirectDraw/DirectSound for when I originally wrote it 5 years ago. Since then, DirectDraw has been gathering dust, and is causing problems on some newer video cards. I'd like to bring the emu into the 21st century.

As the emu engine runs, it creates a bitmap of what should be displayed on screen. What I'm doing now is Lock()ing an offscreen buffer, and copying this bitmap in, then Blit()ting the offscreen buffer to the main screen.

So, I'm looking at one of 3 options, and I'd like to hear opinions from those of you more experienced:

Direct3D
OpenGL
SDL

D3D would be good, because I wouldn't have to change the sound system. It would be bad because using it for 2d is a completely different paradigm from what I'm doing now.

SDL would be good because it's portable (I may want to go Linux one day), and looks a lot like DirectDraw (if I don't use OpenGL through it). Is there any performance difference if I use OpenGL with SDL, rather than just using native SDL interfaces?

I don't know much about OpenGL. Is it more portable than D3D?

Thanks in advance,

-Joe

nolxev
April 29th, 2006, 06:24 AM
OpenGL run everywhere but if your target is 2D go SDL.

aewarnick
May 2nd, 2006, 04:42 PM
I think SDL is just a wrapper around DirectDraw and optionally OpenGL.
D3D portable?!!! Think M$. Microsoft does not create their stuff to be portable.

Personally, I'd go OpenGL because of it's extreme portability.

Do not worry about 3-D. OpenGL will draw 2-D and graphics cards today are supporting mostly 3-D api's anyway.

teleplayr
May 5th, 2006, 10:42 AM
I think SDL is just a wrapper around DirectDraw and optionally OpenGL.

I'm pretty sure DirectDraw is my problem. I'll have to peek into SDL's code and see what it's using under the hood.

How tough is OpenGL to learn for doing 2d only? I don't need anything fancy. I've got a 2d array of RGB values that I just want to slap on the screen 60 times per second. That's it. No sprites, no transformations. Maybe stretching to fill the screen.

Thanks,

-Joe

Mitsukai
May 5th, 2006, 11:32 AM
open gl has alot of 3d features that might come in handy your 2d app, like lighting, fog etc. these culd perfectly be fit in an 2d app and wuld look pretty neat inmho

using the Z position is very handy for the layers, combined with fog/lighting looks awesome. the only hard part culd be the the viewpoint and view angel to slap em to the right position... good luck

philkr
May 5th, 2006, 11:48 AM
the only hard part culd be the the viewpoint and view angel to slap em to the right position... good luck
You simply use a so called "orthogonal projection" for 2D.

nolxev
May 5th, 2006, 11:55 AM
I agree with Mitsukai but if the target is pure 2D, setup the ortho mode would be the best thing ;)

Mitsukai
May 6th, 2006, 01:53 PM
I agree with Mitsukai but if the target is pure 2D, setup the ortho mode would be the best thing ;)
that depends on the situation. If want Z axis to be an pure layer index then it is. By this i mean the layer doesnt appear to be further away. If you do care about objects seeming to be further away, then ortho is pretty much useless

nolxev
May 6th, 2006, 03:16 PM
He said before <<...it would be bad because using it for 2d is a completely different paradigm from what I'm doing now.>>

The problem with a z-position-fixed scene is that you hve not entire control of the unity, if you fix the scene at -2.0F you have to use a quad 0.2F wide to simulate a 100 pixel quad (for example). With ortho mode he can use his images and care only about pixel size, it's more suitable, if you have a picture 150 pixel wide you can specify 150.0 as quad wide; Sure with z-fixed scene it also works but you have to take a headache. It's also possible compose multiple layer also with ortho mode.

teleplayr
July 6th, 2006, 09:09 AM
open gl has alot of 3d features that might come in handy your 2d app, like lighting, fog etc. these culd perfectly be fit in an 2d app and wuld look pretty neat inmho
For my front end that might be nifty, but for the actual game, what I require is very, very simple.

The emulator's engine gives me an NxM pixel bitmap. I just need to slap that bitmap onto the screen at 60fps. The only special thing I might need is hardware stretching.

The bitmap generation has to be done in the engine, as the game code can read the video memory directly if it chooses.

So it sounds like Open GL with Ortho mode would be the fastest/easiest way to go about it?

-Joe

nolxev
July 10th, 2006, 04:53 AM
The choose is your, you can use SDL or OGL.