Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

Thread: Writing a game engine from the scratch

  1. #21

    re-

    If there is somebody here who could explain how to switch to another display-mode, could you please explain how this is done??

    Switch from windowed or full screen mode in a directx 8.x or above app is just a matter to destroy and recreate again the dx device with the correct parameters.

    The device object is define like this:

    D3DDEV8 : IDirect3DDevice8 = NIL

    Then you need few more parameters structures to fill.

    _d3dpp : TD3DPresent_Parameters;
    _d3ddm : TD3DDisplayMode;
    _dtype : TD3DDevType;


    The full screen mode select is defined in _d3dpp

    _d3dpp.windowed:=false; //false for full screen, true for windowed.
    _d3dpp.hDeviceWindow:=__hWnd; //form handle or custum window handle.
    _d3dpp.BackBufferWidth := _width; //full screen resolution desired.
    _d3dpp.BackBufferHeight := _height; //only full screen suported videocard resolution (640x480, 800x600, 1024x768 etc).
    _d3dpp.BackBufferFormat := D3DFMT_A8R8G8B8; //32 bit color format. (D3DFMT_R5G6B5 for 16 bit color format)
    _d3dpp.BackBufferCount := 2; //two backbuffer.
    _d3dpp.SwapEffect := D3DSWAPEFFECT_DISCARD;


    then you create the D3DDEV8 object like this:

    D3D8.CreateDevice(D3DADAPTER_DEFAULT, _dtype, _hWnd,
    D3DCREATE_SOFTWARE_VERTEXPROCESSING,
    _d3dpp, D3DDEV;

    //------------------------------------------

    It is important to note that when you setup that in a delphi form application (so you are using VCL), indee you run in full screen mode but your delphi VCL app "thinks" is running in windowed mode and it keeps handling all messages events like it is needed in a VCL app, the mouse pointer still visible and when you move it the paint form event is called and ugly artifact blinks in your full screen rendering.

    If you are going to use directx full screen app with delphi, then it is advised not to use VCL at all and just use windows API for create manually one window object and your own custom message loop with just the basic messages required by your game/application.

    good luck.

    tp.

  2. #22

    Writing a game engine from the scratch

    aah... thank you for this valueable information.

    I've quickly tested it with my current (VCL) d3d app and it worked fine. Later i will build my own window with message loop. I dont know how this is done. Does someone have a link to a good tutorial that covers windows message loops and handling

    Then you need few more parameters structures to fill.

    _d3dpp : TD3DPresent_Parameters;
    _d3ddm : TD3DDisplayMode;
    _dtype : TD3DDevType;
    What exactly is the advantage of filling the TD3DDevType?? I looked into the CD3DApplication code and it seems to be al lot of work.
    I just use D3DADAPTER_DEFAULT. :?

    Thanx again for your reply.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  3. #23
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Writing a game engine from the scratch

    Rendertargets need te reset to! donno why, but at my system I got problems when I create a rendertarget and render to an other form.
    NecroSOFT - End of line -

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

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