Results 1 to 9 of 9

Thread: Direct3D Engine Initialising

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Angry Direct3D Engine Initialising

    I've finished the sounds & hardware finding tutorials fo DirectX (8.1), now I'm trying my hand at the graphics side (which I left 'till last on purpose)!

    I've tried "lesson 1" of the graphics tutorials on directx4vb.com, & the first routine (which I need for more or less everything I do in DX) doesn't work!!! I've tried this on 2 pc's now & can't see why this screws up. Any help'll be majorly appriciated! Cheers!
    VB Code:
    1. Public Function Initialise() As Boolean
    2.     Dim DispMode As D3DDISPLAYMODE
    3.     Dim D3DWindow As D3DPRESENT_PARAMETERS
    4.    
    5.     Set Dx = New DirectX8
    6.     Set D3D = Dx.Direct3DCreate()
    7.  
    8.     ' Windowed Mode
    9.     D3D.GetAdapterDisplayMode CONST_D3DCONST.D3DADAPTER_DEFAULT, DispMode
    10.    
    11.     With D3DWindow
    12.         .Windowed = 1
    13.         .SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
    14.         .BackBufferFormat = DispMode.Format
    15.     End With
    16.    
    17.     Set D3DDevice = D3D.CreateDevice(0, D3DDEVTYPE_REF, frmMain.hWnd, _
    18.     D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
    19. End Function

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Perhaps ypu are missing this:
    Code:
    D3DPresentParams.hDeviceWindow = hWnd
    Also, REF devices are too slow to be used for ANYTHING except driver testing. Use a HAL device.

    Z.

  3. #3

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Weird, thanks Zaei, I got it working on one pc, but the one I'm on at the moment refuses to take it, even though it supports HAL & the DX Dialog tests for Direct3D work in the windows control panel.

    Would there be any reason this pc won't take it?
    Cheers.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Check device formats. If you run in windowed mode, and your back buffer format does not match the current screen resolution, it will NOT work. If you are in fullscreen, you need to make sure that the format you want is supported. Use the DX Caps Viewer that comes with the SDK to test.

    Z.

  5. #5

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    I just wanna put a quick note up here, firstly so I don't forget it secondly for anyone else trying those tutorials with the same problem.

    Both the fullscreen and windowed versions of the code were failing on the "format" parameter specified. The ones in the tutorial didn't work on all the computers I tried it on & I ended up changing these lines:
    VB Code:
    1. WindowedModeVariable.BackBufferFormat = DispMode.Format
    2. FullScreenModeVariable.Format = D3DFMT_X8R8G8B8
    to another of the CONST_D3DFORMAT constant values. (In the end, the D3DFMT_R5G6B5 value worked for me).

    Ta!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    But isnt that something unique for each and every monitor/video card? You will have to use .getcaps function to get the formats. (or something similar) look at the help file that comes with dx sdk
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  7. #7
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Yup, you have to enumerate for each card.

    Z.

  8. #8

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    True, I just guessed that as this is a crappy video card maybe that was the lowest setting which'd work for most other cards.
    Myself, I've written a function where I pass this value in to the initialisation after the enumeration bit.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  9. #9
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    The color settings will not work on all video cards.
    Its not like the resolution which has a standard "lowest" which all computers can work with... no no..

    The colorformats are not standard, and all different on different video cards. So just call a function to get you the color formats right after you initialize the primary surface. Because whatever color format the primary surface has, thats what all other surfaces will have anyways, right? Well im not so sure but most of my code for this worked fine so far...

    Also if you are using C/C++ to do this... you might run into a problem... but i think vb takes care of all of this for you if you use the get/set pixel methods.

    I mihgt be lost by now, but thats just my 2 cents right there.

    Regards,
    MoMad the NoMad
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

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