Results 1 to 11 of 11

Thread: Direct3D init --> using DirectX 8.1

  1. #1

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Question Direct3D init --> using DirectX 8.1

    VB Code:
    1. '// Initialise : This procedure kick starts the whole process.
    2. '// It'll return true for success, false if there was an error.
    3. Public Function Initialise() as Boolean
    4. On Error Goto ErrHandler:
    5.  
    6. Dim DispMode as D3DDISPLAYMODE '//Describes our Display Mode
    7. Dim D3DWindow as D3DPRESENT_PARAMETERS '//Describes our Viewport
    8.  
    9. Set Dx = New DirectX8 '//Create our Master Object
    10. Set D3D = Dx.Direct3DCreate() '//Make our Master Object create the Direct3D Interface
    11.  
    12. D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode '//Retrieve the current display Mode
    13.  
    14. D3DWindow.Windowed = 1 '//Tell it we're using Windowed Mode
    15. D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC '//We'll refresh when the monitor does
    16. D3DWindow.BackBufferFormat = DispMode.Format '//We'll use the format we just retrieved...
    17.  
    18. '//This line will be explained in detail in a minute...
    19. Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, FrmMain.Hwnd, _
    20.                                                      _ D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
    21.                                                      _ D3DWindow)
    22.  
    23. Initialise = True '//We succeeded
    24. Exit Function
    25. ErrHandler:
    26. '//We failed; for now we wont worry about why.
    27. Initialise = False
    28. End Function

    This code should work with DirectX 8.1 but ther's still a little
    problem left:

    D3DADAPTER_DEFAULT is not found anywhere in the DirectX libary.

    Mybe this code was written for 8.0?

    What can I use instead of D3DADAPTER_DEFAULT?

    Any ideas?

    thx!

  2. #2
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    have you tried 1 or 0?
    Sanity is a full time job

    Puh das war harter Stoff!

  3. #3
    Zaei
    Guest
    Did you add the DX8.1 type library to your references list? The constant is the same for 8.0 and 8.1.

    Z.

  4. #4

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    I found the problem:

    CONST_D3DCONST.D3DADAPTER_DEFAULT

    is the variable

    thx!

  5. #5
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    so what is it? not 1 or 0?
    Sanity is a full time job

    Puh das war harter Stoff!

  6. #6

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    don't know...

    I guess it's 0 because the reference says 0 is for 'unknown adapter'

  7. #7

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    but now there's a nice new problem:

    after direct3d init, the system crashes if I run
    the app in full-screen mode.

    when I run it windowed, all works fine.

    I guess that will also take some time to figure out.

  8. #8
    Zaei
    Guest
    Misan, D3DADAPTER_DEFAULT == 0.

    vbzero, Check your back buffer format. It is probably unsupported. Check in the DirectX Caps Viewer (it was installed where your SDK was installed, and its in the start menu). Check what back buffer formats your card supports, and use one of them. Also make sure you arent switching into a mode your monitor doesnt support.

    I would NOT advise working on your project and testing it in fullscreen. You may end up having to restart your computer A LOT. Just a word of advice.

    Z.

  9. #9

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    You're right!

    The problem is the backbuffer format. But isn't there a
    possibility to let the program find out which backbuffer
    is correct?

    How did they do that in commercial games?

    My backbuffer:

    VB Code:
    1. // Setting the new display format
    2.                 //
    3.                 D3DDispMode.Format          =   CONST_D3DFORMAT.D3DFMT_X8R8G8B8;
    4.                 D3DDispMode.Height          =   480;
    5.                 D3DDispMode.Width           =   640;
    6.                
    7.                 //
    8.                 // Setting the new window format
    9.                 //
    10.                 D3DWindow.Windowed          =   0;
    11.                 D3DWindow.SwapEffect        =   CONST_D3DSWAPEFFECT.D3DSWAPEFFECT_FLIP;
    12.                 D3DWindow.BackBufferCount   =   1;
    13.                 D3DWindow.BackBufferFormat  =   D3DDispMode.Format;
    14.                 D3DWindow.BackBufferHeight  =   480;
    15.                 D3DWindow.BackBufferWidth   =   640;
    16.                 D3DWindow.hDeviceWindow     =   Me.hWnd;

  10. #10
    Zaei
    Guest
    When you Query the adapter, you are querying the CURRENT settings. You need some extra code to do Caps Checks to find out which cards support which back buffer formats.

    Z.

  11. #11

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    I just found a tutorial to that...

    thx very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width