PDA

View Full Version : DirectX Question



Swenghk
June 24th, 2009, 04:18 PM
I need to know how I can use DirectX in Linux.

I use OpenGL to make the graphics for a game, but I need access to different DirectX things too, such as DirectInput or DirectSound...

Thank-you

milton1
June 24th, 2009, 04:21 PM
Can't. You need to find equivalent functions that are linux-native.

Swenghk
June 24th, 2009, 04:24 PM
I can't...I NEED DirectX

Well...looks like I'm off to Windows again

milton1
June 24th, 2009, 04:28 PM
I can't...I NEED DirectX

why?

jinksys
June 24th, 2009, 06:55 PM
I need access to different DirectX things too, such as DirectInput or DirectSound...

You can't access DirectX on linux as it is a set of Windows APIs. If you need a cross-platform way to access input, sound, and video, take a look at SDL.

http://www.libsdl.org/

Also, if you come to the forum for help, and then we give you straight answers, don't hit us up with guilt trip. "Looks like it's back to windows."

shadylookin
June 24th, 2009, 07:10 PM
You should consider SDL for event handling and SDL_mixer for sound. It's cross platform and integrates with opengl

in the repos their libsdl1.2-dev and libsdl-mixer1.2-dev

decoherence
June 24th, 2009, 07:18 PM
OP had an honest question and gave an honest response. I wouldn't read too much in to it. Or do I detect a little drawing library envy? ;)

Anyway, just to confirm, MS hasn't released DX for any other systems, so if you NEED it then you need Windows.

You could try doing whatever it is you want to do in Cedega. At least then you can use Linux for most things and use Windows for your DX stuff. That might be more trouble than it's worth for you, though. Depends on how desperate you are to get away from Windows.

Swenghk
June 25th, 2009, 05:52 PM
I wasn't trying to send you on a guilt trip

I was saying that in a depressed way..I just came back from Windows when I figured I could learn OpenGL in my favorite OS :]

And thanks for the suggestion to SDL *happy* Looks like I'm sticking with Linux!

But...is SDL a cross-platform API?
(Well, I know its cross-platform...but do you have to change the code for another OS)

Zugzwang
June 25th, 2009, 06:03 PM
But...is SDL a cross-platform API?
(Well, I know its cross-platform...but do you have to change the code for another OS)

SDL is no API, but rather a library that encapsulates the local native APIs into a unified, cross-platform way of accessing them.

This means that the code does not need to be changed, provided that you programmed correctly. As always with C or C++, you might make critical programming mistakes that will not have an effect on every machine. To give a SDL example, not every platform will "forget" some surfaces. So if you program on these platforms, the code might not work correctly on platforms that do sometimes forget surfaces (like Windows) if you do not do the handling correctly (or forget it).

Swenghk
June 25th, 2009, 07:49 PM
You should consider SDL for event handling and SDL_mixer for sound. It's cross platform and integrates with opengl

in the repos their libsdl1.2-dev and libsdl-mixer1.2-dev

I tried to install them, but it won't let me. I tried to install SDL before from another guide and it didn't work. Is there any way to start over?

shadylookin
June 25th, 2009, 11:40 PM
I tried to install them, but it won't let me. I tried to install SDL before from another guide and it didn't work. Is there any way to start over?

What do you mean by it won't let you? Does it give some sort of error when you try and download them from synaptic?

Sounds like you tried to manually install them and messed up your package management.

You might need to ask in another forum where they'll be able to help you better since I'm not really sure how to fix synaptic. when you search for libsdl1.2-dev and libsdl-mixer1.2-dev it should look like in the picture

then once you get it you include it in your source code with

#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>

then when you go to compile and link(assuming your naming it program and the source is program.c)

gcc -oprogram program.c -lSDL -lSDL_mixer