3D graphics in C#

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
BlackAura
DC Developer
DC Developer
Posts: 9951
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

3D graphics in C#

Post by BlackAura »

Not entirely (or at all) related to Dreamcast programming, but what the hell...

For a project thingy I'm doing at Uni, I need to do a 3D graphing thingy. Nothing particularly flash (and I think that they have rather low expectations of us - the rest of my team seem to have really low expectations of what we can do), but there is basically nothing out there that already does the job (we're using NPlot for 2D graphs), so we need to write one from scratch.

Okay, nothing too difficult. Ignoring the fact that the rest of the bloody thing is a terribly designed pile of garbage (not my fault - everybody else started hacking at it before we'd even discussed what it needed to do), I have about two days (Sunday, Tuesday) to do it, and I've never done anything really substantial in C#, and I have absolutely no idea about how to do 3D stuff in C#.

So, taking a rough guess (Managed DirectX) I'm looking into using Direct3D. Three things come to mind.

First, is there any (sane, simple) way to put the output from a Direct3D thingy into a Windows.Forms control? So, can I display a 3D graph rendered with Direct3D inside a component on a form? Everything I've seen involves rendering to a full-screen app or a dedicated window, and the initialisation code is absolutely evil. Especially after having written a load of OpenGL apps using SDL and GLUT...

Second, is it possible to print stuff rendered with Direct3D (I imagine the answer would be no, since Direct3D is not designed for this kind of thing). OpenGL can't really do it either, so I'm probably going to have to implement a 2D renderer (to GDI# or something) at some point, but I really don't have time to do that now.

Third... Is the Direct3D API really that bad? Just a simple bit of code to draw a cube is ten times the size of the equivalent OpenGL, and each line of code is an absolute mess. The PVR API is a little complex / verbose / difficult to use, but at least there's a reason for it - you're directly controlling the hardware. In the case of Direct3D, there is absolutely no direct mapping to the underlying hardware, so why the hell does it feel like the PVR API, rather than something more abstract / nicer to work with like OpenGL?

Alternatively, is there any way I can just use OpenGL? It'd probably end up being much simpler.
User avatar
mankrip
DCEmu Ex-Mod
DCEmu Ex-Mod
Posts: 3712
Joined: Sun Nov 04, 2001 5:12 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by mankrip »

Is the Direct3D API really that bad? Just a simple bit of code to draw a cube is ten times the size of the equivalent OpenGL, and each line of code is an absolute mess.
Well, quoting John Carmack: "For years, I?ve had misgivings about people learning programming on Win32 (unix / X would be even worse), where it takes a lot of arcane crap just to get to the point of drawing something on the screen and responding to input. I assume most beginners wind up with a lot of block copied code that they don?t really understand."

May the GeForce be with you...
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
Image
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

Can you use the The Tao Framework for Mono and .NET. ?
http://www.mono-project.com/Tao

Sorry Im just starting to learn C# and .NET , I'v made it through Hello World so far :)

Troy
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

Ah, neat. It appears to have disappeared inside Mono, but I can grab a version of it from Mono's Subversion repositories. Thanks.

It seems to work fine under Mono / Linux, but I've not been able to get it to run on Windows yet. All of the examples require FreeGLUT (which I can't find / build a working copy of for Windows), and the included SimpleOpenGlControl doesn't seem to work (doesn't initialize properly, or something). I'll have to hack around with it some more later.
Sanchez
DCEmu Ex-Admin
DCEmu Ex-Admin
Posts: 1098
Joined: Wed Oct 17, 2001 7:44 pm
Has thanked: 0
Been thanked: 0

Post by Sanchez »

Take a look at:

http://www.gotdotnet.com/Community/User ... 3D665FFCD0

It's a CML viewer with DX on a WinForm...
"This is worse than when the Raccoon got in the copier!"
Post Reply