using directx8 and c#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • colin

    using directx8 and c#

    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,

    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:: EnumDevicesBySe mantics from
    managed code.
    extern "C" HRESULT CallEnumDevices BySemantics(IDi rectInput8 *pDI,
    LPCTSTR lpsz, DIACTIONFORMAT *pDIAF,
    [MarshalAs(Unman agedType::Funct ionPtr)]
    Sunlight::Direc tX::Input::Dire ctInput::DIEnum DevicesBySemant icsCallbackDele gate
    *pd,
    LPVOID pvRef, DWORD dwFlags);
    // Helper function for calling IDirectInput8:: ConfigureDevice s from managed
    code.
    extern "C" HRESULT CallConfigureDe vices(IDirectIn put8 *pDI,
    [MarshalAs(Unman agedType::Funct ionPtr)]
    Sunlight::Direc tX::Input::Dire ctInput::DIConf igureDevicesCal lbackDelegate
    *pCallback,
    LPDICONFIGUREDE VICESPARAMS 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 CallConfigureDe vices(struct IDirectInput8W *,class
    Sunlight::Direc tX::Input::Dire ctInput::DIConf igureDevicesCal lbackDelegate
    ^,struct _DICONFIGUREDEV ICESPARAMSW *,unsigned long,void *)"
    (?CallConfigure Devices@@$$J0YM JPAUIDirectInpu t8W@@P$AAVDICon figureDevicesCa llbackDelegate@ DirectInput@Inp ut@DirectX@Sunl ight@@PAU_DICON FIGUREDEVICESPA RAMSW@@KPAX@Z);
    calling convention missing in metadata

    DirectInput.obj : error LNK2031: unable to generate p/invoke for "extern "C"
    long __clrcall CallEnumDevices BySemantics(str uct IDirectInput8W *,wchar_t
    const *,struct _DIACTIONFORMAT W *,class
    Sunlight::Direc tX::Input::Dire ctInput::DIEnum DevicesBySemant icsCallbackDele gate
    ^,void *,unsigned long)"
    (?CallEnumDevic esBySemantics@@ $$J0YMJPAUIDire ctInput8W@@PB_W PAU_DIACTIONFOR MATW@@P$AAVDIEn umDevicesBySema nticsCallbackDe legate@DirectIn put@Input@Direc tX@Sunlight@@PA XK@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 =^.^=


  • not_a_commie

    #2
    Re: using directx8 and c#

    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.

    Comment

    • colin

      #3
      Re: using directx8 and c#

      "not_a_comm ie" <notacommie@gma il.comwrote in message
      news:8da944de-55d4-4232-a7ba-a2ca95824ed6@e2 5g2000prg.googl egroups.com...
      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

      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.Direc tx .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 =^.^=


      Comment

      • not_a_commie

        #4
        Re: using directx8 and c#

        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.

        Comment

        • colin

          #5
          Re: using directx8 and c#

          "not_a_comm ie" <notacommie@gma il.comwrote in message
          news:dde54d46-5c9f-4419-a909-243df98df224@e6 g2000prf.google groups.com...
          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 =^.^=


          Comment

          Working...