Direct3D how ?

J

JAM

I have noticed that you can add reference to
Microsoft.DirectX.Direct3D (no OpenGL :-( ). How one can use 3D in C#
program ? Is it possible to use it in Window Forms ? I'm an engineer
that would like to present some 3D data in my programs. so I care
less about games therefore XNA is not for me. However I'm just
mechanical engineer so interacting with Windows API is also not for
me. Native API's are just too complicated for me. I would like to use
DirectX in managed code if possbile and preferable in Window Forms so
I can build nice interface to data. I know that you can do some 3D in
WPF but I just don't like WPF. I prefer Window Forms. If it is
possible, is there a book that expalins how to use Direct3D in managed
code or some online resources that laymen can understand ?

JAM
 
P

Peter Duniho

JAM said:
I have noticed that you can add reference to
Microsoft.DirectX.Direct3D (no OpenGL :-( ). How one can use 3D in C#
program ? Is it possible to use it in Window Forms ? I'm an engineer
that would like to present some 3D data in my programs. so I care
less about games therefore XNA is not for me. However I'm just
mechanical engineer so interacting with Windows API is also not for
me. Native API's are just too complicated for me. I would like to use
DirectX in managed code if possbile

The managed DirectX API is really just a thin wrapper around the actual
DirectX API. If you find the native API too complicated, the managed
wrapper is not going to be any better. You still have to worry about
things like 3D devices, surfaces, etc.

The wrapper includes some helper stuff to assist in making Direct3D work
with the .NET classes, but that's just _extra_ stuff. They haven't
really simplified the API any as far as I can tell.
and preferable in Window Forms so
I can build nice interface to data.

I believe that with the managed DirectX wrapper, you can use windowed
mode rendering and have your rendering done into the window of a Form
(you can get the Form instances HWND from the Handle property). But as
I mentioned, this doesn't mean that the rest of the Direct3D stuff is
any simpler. It just means you can hook it into your Forms application
if you want.
I know that you can do some 3D in
WPF but I just don't like WPF. I prefer Window Forms.

I prefer the APIs I already know too. :) But really, if I were looking
to do 3D output today, I'd invest the time to learn WPF well enough to
get it to do what I want.

I suspect there's a limit to what WPF can do, but I also suspect that
within the limits of what WPF can do, you can do it a lot easier in WPF
than in Forms.
If it is
possible, is there a book that expalins how to use Direct3D in managed
code or some online resources that laymen can understand ?

Not that I'm aware of. But I'll bet Google can turn up what resources
do exist.

Pete
 
F

Fred Mellender

I used "Managed DirectX 9", by Tom Miller. It is now dated and so far as I
know has not been updated. It is pretty clear and I got a rather
complicated application to work.
 
N

not_a_commie

Microsoft dropped their managed DirectX support a few years back. It
was never finished. It was old .Net and only 32bit. Fortunately, some
good folk picked up the idea and wrote a real wrapper: SlimDX. Google
it. It works great. Their examples are all using WinForms.
 
T

Tom Shelton

Microsoft dropped their managed DirectX support a few years back. It
was never finished. It was old .Net and only 32bit. Fortunately, some
good folk picked up the idea and wrote a real wrapper: SlimDX. Google
it. It works great. Their examples are all using WinForms.

Hmmm... It's not as if they dropped dx support really, they just have moved
into other places :) WPF and XNA.
 
P

Peter Duniho

Fred said:
I used "Managed DirectX 9", by Tom Miller. It is now dated and so far
as I know has not been updated. It is pretty clear and I got a rather
complicated application to work.

In spite of its age, that book should still be relevant though. From
what I understand, Managed DirectX 2.0 got canned in lieu of XNA Game
Studio, and for now Microsoft seems to be ensuring MDX 1.1 remains fully
supported.

Given Microsoft's reputation for maintaining backward compatibility, I'd
guess a book based on DX9/MDX 1.1 should still be very useful for a long
time to come. :) Thanks for the recommendation!

Depending on how much XNA is like MDX (I haven't looked myself), it
could even be useful for someone who is eventually using XNA.

For what it's worth, after the OP's question, I did a little Googling,
and turned up some other resources:
http://www.mdxinfo.com/tutorials.php?view=The basics
http://www.drunkenhyena.com/cgi-bin/dx9_net.pl
http://www.kalme.de/index.php?option=com_content&task=section&id=4&Itemid=26

I haven't had a chance to look closely at the third at all, and only a
little at the first two. For sure, the first two are not problem free,
but they both include sample code that ostensibly works (I got one to
compile and run without any effort at all), and both provide at least a
bit of discussion of why the implementations are they way they are.
Using either of them, someone could probably get started using Managed
DirectX, especially if they can avoid copying verbatim weird code like this:

get { if(device != null) { return device; }
else { return null; }
}

(no, I have no idea why there's an "if" statement in that getter :) )

Pete
 
J

JAM

Hmmm...  It's not as if they dropped dx support really, they just have moved
into other places :) WPF and XNA.

Thank you guys for all answers.
WPF is a step back from Window Forms IMHO. I'm not interested in
browser applications and I can care less about WPF. Window Forms are
still superior in most cases for "native" Window application. I know
WPF allows to program for browser. Microsoft must be scared of online
applications threat, but they sacrificing native Windows applications
this way. I have tried XNA but this is for games, not for engineering
type applications. You either have to choose game environment or
Window Forms. Probably some geek can combine both but as I said I'm
not that good. I will definitely take a look at SlimDX. Getting handle
for a window does not scare me. You had to do similar trick to make
OpenGL work in Borland's VCL framework. Regarding Microsoft
"compatibility" it is great in some areas but it is inconsistent in
other. Programming is one example. Abandoned Visual Basic native
community is one example. Never finished Managed DirectX project that
was actually useful abandoned for XNA. Who really needs XNA ? Games
are made by corporations that invest zillion dollars. Nobody in the
right mind will be making managed .NET games that have any value.
Windows have two 3D engines build in - DirectX and OpenGL. Why
Microsoft practically ignores those tow pieces of API's in their .NET
framework ? Much poorer and smaller Borland was able to get you RAD
with it's VCL framework that was easily extended to native API's
including OpenGL etc. Unfortunately Borland sold their programming
tools to some obscure company that sells it only for $1000 per seat
(used to be $100). I'm amateur, I can't afford this kind of money for
a tool that I use for fun.

JAM
 
T

Tim Roberts

JAM said:
WPF is a step back from Window Forms IMHO.

I think you misunderstand what WPF is all about. Yes, it happens that you
can write web applications using a subset of WPF, but that's just gravy.
The problem is that WPF requires you to think about the GUI problem
somewhat differently than Forms, and because of that some programmers have
dismissed it. Remember, a WPF application **IS** a Direct3D application.
The whole window is a D3D app.
Window Forms are still superior in most cases for "native" Window
application.

No, that's just too simplistic. (Actually, I find that WTL is still
superior for "native" Windows applications, but that's another story.) WPF
is just as close to the low-level API as Windows Forms is, although it is a
different low-level API.
I know WPF allows to program for browser.

.... as an interesting side effect, not as it's primary purpose.
 
J

JAM

I think you misunderstand what WPF is all about.  Yes, it happens that you
can write web applications using a subset of WPF, but that's just gravy.
The problem is that WPF requires you to think about the GUI problem
somewhat differently than Forms, and because of that some programmers have
dismissed it.  Remember, a WPF application **IS** a Direct3D application.
The whole window is a D3D app.


No, that's just too simplistic.  (Actually, I find that WTL is still
superior for "native" Windows applications, but that's another story.)  WPF
is just as close to the low-level API as Windows Forms is, although it isa
different low-level API.


... as an interesting side effect, not as it's primary purpose.

Tim

Thank you for clarification. However I have tried WPF and found that
less user friendly in Visual Studio, lacking some components such as
calendar for example, more difficult to understand docking, anchor
etc. When compared to Window Forms or VCL I have found WPF to be
probably the worst at least for such amateur as I am.

JAM
 
T

Tom Shelton

Tim

Thank you for clarification. However I have tried WPF and found that
less user friendly in Visual Studio,

Hmmm... Seems ok to me in vs. Though, I think MS really wants you to by one
of their expression tools for wpf :)
lacking some components such as
calendar for example,

In the cases of missing controls, I've either found it simple to create my
own, find one that someelse made, or just host the winforms version...
more difficult to understand docking, anchor
etc. When compared to Window Forms or VCL I have found WPF to be
probably the worst at least for such amateur as I am.

Hmmm... Once you get used to it, I find layout to be much better - especially
since of the resolution independance and built it scaling.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top