using directx8 and c#

C

colin

Hi,
Is there an easy way to do 3d drawing using drect3d8 devices in c# ?
please dont suggest using directx9 unless there is a way to use directx9 on
devices with only direct3d8 support.
the managed directx9 such as XNA does not support devices with direct3d8
only,
the software rasterizer works but is so mind numingly slow.

Im drawing 3d objects such as surfaces with textures,
created at run time for a wire mesh/model editor.
speed isnt essential but a 3 seconds update time makes panning
with a mouse imposible.

Im trying a few samples but im running into problems,
http://sunlightd.com/Archive/Windows/DirectX.NET/Default.aspx
this one was made for directx8 before directx9 was out
but although it sugests it would work on
directx9 the directx8 sdk doesn not seem to have certian directx8 include
files
such as "d3dx8.h" i managed to get hold of a copy of directx8 sdk.

the c# sample uses a c++ library wrapper for directx8
wich is cuasing the problem :-
the c++ library seems destined for vc7,
the c++ it doesnt seem to work properly on vc8 and I only have vc8 or vc6,

the error I get with vc8 is in the section of unmanaged c++ code.
..........
#pragma unmanaged
// Helper function for calling IDirectInput8::EnumDevicesBySemantics from
managed code.
extern "C" HRESULT CallEnumDevicesBySemantics(IDirectInput8 *pDI,
LPCTSTR lpsz, DIACTIONFORMAT *pDIAF,
[MarshalAs(UnmanagedType::FunctionPtr)]
Sunlight::DirectX::Input::DirectInput::DIEnumDevicesBySemanticsCallbackDelegate
*pd,
LPVOID pvRef, DWORD dwFlags);
// Helper function for calling IDirectInput8::ConfigureDevices from managed
code.
extern "C" HRESULT CallConfigureDevices(IDirectInput8 *pDI,
[MarshalAs(UnmanagedType::FunctionPtr)]
Sunlight::DirectX::Input::DirectInput::DIConfigureDevicesCallbackDelegate
*pCallback,
LPDICONFIGUREDEVICESPARAMS lpdiCDParams, DWORD dwFlags, LPVOID pvRef);
#pragma managed
..............

..\DirectInput.cpp(52) : error C3821: 'FunctionPtr': managed type or function
cannot be used in an unmanaged function
..\DirectInput.cpp(56) : error C3821: 'FunctionPtr': managed type or function
cannot be used in an unmanaged function

if I comment out the pragmas it compiles but then I get link errors

.........
DirectInput.obj : error LNK2031: unable to generate p/invoke for "extern "C"
long __clrcall CallConfigureDevices(struct IDirectInput8W *,class
Sunlight::DirectX::Input::DirectInput::DIConfigureDevicesCallbackDelegate
^,struct _DICONFIGUREDEVICESPARAMSW *,unsigned long,void *)"
(?CallConfigureDevices@@$$J0YMJPAUIDirectInput8W@@P$AAVDIConfigureDevicesCallbackDelegate@DirectInput@Input@DirectX@Sunlight@@PAU_DICONFIGUREDEVICESPARAMSW@@KPAX@Z);
calling convention missing in metadata

DirectInput.obj : error LNK2031: unable to generate p/invoke for "extern "C"
long __clrcall CallEnumDevicesBySemantics(struct IDirectInput8W *,wchar_t
const *,struct _DIACTIONFORMATW *,class
Sunlight::DirectX::Input::DirectInput::DIEnumDevicesBySemanticsCallbackDelegate
^,void *,unsigned long)"
(?CallEnumDevicesBySemantics@@$$J0YMJPAUIDirectInput8W@@PB_WPAU_DIACTIONFORMATW@@P$AAVDIEnumDevicesBySemanticsCallbackDelegate@DirectInput@Input@DirectX@Sunlight@@PAXK@Z);
calling convention missing in metadata
...........

unfortunatly although I know c++ and mfc,
I never got into managed c++ before I moved onto c#
ive spent all day getting this far, but think this is a bit over my head

thanks
Colin =^.^=
 
N

not_a_commie

As I understand it, DirectX 8 vs DirectX 9 support is based upon the
driver. It is your driver's responsibility to take advantage of as
much hardware support as possible. If you're only using features that
were available in DirectX8 with your DirectX9 code you should get
reasonable performance. When a video card claims DirectX 8 support, it
means that they had hardware acceleration for everything that was part
of the DirectX8 standard. Most of that standard is still used in
DirectX9. What GPU are you using? What operating system?

As far as your code above, there are attributes to declare the call
type, though I don't know what they are off the top of my head.
 
C

colin

not_a_commie said:
As I understand it, DirectX 8 vs DirectX 9 support is based upon the
driver. It is your driver's responsibility to take advantage of as
much hardware support as possible. If you're only using features that
were available in DirectX8 with your DirectX9 code you should get
reasonable performance. When a video card claims DirectX 8 support, it
means that they had hardware acceleration for everything that was part
of the DirectX8 standard. Most of that standard is still used in
DirectX9. What GPU are you using? What operating system?

As far as your code above, there are attributes to declare the call
type, though I don't know what they are off the top of my head.

Hi
thanks,
yes I agree its the driver that doesnt support directx9.
the card in question is GeForce4 Ti 4200,
this belongs to someone I am hoping will do some pre alpha testing,
the drivers support directx8 but not dx9,
although dx9.c is installed on that machine ok.

XNA gives up saying its no direct3d9 device found

it doesnt need stunningly fast graphics so
I dont want to restrict it to fairly new graphics cards.

im using winxp sp2 with a ati9800 with no problems,
but im not sure what OS or machine the other card is used on
and I dont want to place hardware/OS restrictions more than a bare minimum.

XNA was a cool environment to get started in,
but with the problems using it in a Forms control panel
its not so atractive.

Ive recently found an excelent c# directx9 sample
http://www.riemers.net/eng/Tutorials/DirectX/Csharp/Series1/tut13.php
wich works fine but I cant seem to find out what the requirments
wil be whether this will still require a direct3d9 device
or will allow me to use whatever features are available in
directx8.

I know directx9 is supposed to include all of directx8 but
I realy dont know if using the Microsoft.Directx .net lib
from c# wich is only available in dx9 allows use of directx8 only cards.

as im not sure if its just xna that requires a direct3d9 device or
the managed access to directx9 wich xna uses and wich is what alows acces
from c#.

ofc If i had easy access to a machine with a direct8 only card i could suck
it and see,
but I wont for a few days.

Colin =^.^=
 
N

not_a_commie

nVidia's drivers definitely support a DirectX9 interface to a TI 4200.
The target machine just needs to have the DirectX9 runtime installed
along with the current GeForce driver from nVidia.com.
 
C

colin

not_a_commie said:
nVidia's drivers definitely support a DirectX9 interface to a TI 4200.
The target machine just needs to have the DirectX9 runtime installed
along with the current GeForce driver from nVidia.com.

thanks il pass that on,
itl be useful if it does and it works with xna,
it reports it has pixel shader 1.1 or higher so it should do.

I duno why I didnt check if they had latest drivers.
most of the hits for ti 4200 mention only directx8 support,
but I gues they are just old pages.

Colin =^.^=
 
C

colin

not_a_commie said:
nVidia's drivers definitely support a DirectX9 interface to a TI 4200.
The target machine just needs to have the DirectX9 runtime installed
along with the current GeForce driver from nVidia.com.

thanks, it seems theres some problem with the latest nvidia drivers for that
card,
wich cuase other combination of hardware software to not all work all at the
same time.
(uses winxp/vitual machine etc...) some time has been spent trying to get to
the bottom
of that but no success. but direct9.0c is installed.

seems like an upgrade is in order, but I was hoping to make my program work
on
the most basic of machines however I gues directx9 driver support
wouldnt rule out much exept maybe this one machine.

however I wrote a simple dx9 prog to test, (well actualy copied a sample)
wich just clears the screen and draws a triangle.

however on the ti 4200 card it clears the window but doesnt draw the
triangle,
theres no exceptions and seems to be no return value to test,
I dont know if theres some error code to check somewhere is there ?

I also dumped the device.DeviceCaps to a file, and compared the results with
my card,
much if it I havnt got a clue wether it makes a difference to it working or
not
but this line is puzzling .
PixelShaderVersion: 0.0
VertexShaderVersion: 3.0

does this mean it doesnt have a pixel shader I find this hard to beleive.
or is it that the dx8 pixel shader cant be accessed via dx9?
or is it just a case of bad driver install/setup ?
I would of thought pixel shading is easier than vertex shading.

if it clears the screen shouldnt there be a way to get it to paint
lines/points ?
cant beleive this is being so

After reading a fair bit about possible problems,
I read there are some diference between drivers and cards,
some of wich requirte certain things to be set to perform a draw
others dont, but this has been for far more advanced stuff.

My program is a fairly simple wire frame/solid model editor with realtime
viewing of changes to bsp stuff etc.

I have tried the directx software renderer but its unbeleivablye slow,
im sure I could work out each pixel in my code a bit faster,
but ive got a lot of work cut out with the rest of the editing code
than to write my own software graphics device.
or time to try and delve into driver problems on a machine
i dont even have access to lol.

are there any good directx8 samples wich compile with vs2005 ?
or simple directx8 test apps?

any ideas apreciated
thanks
Colin =^.^=
 

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