Results 1 to 8 of 8

Thread: What does "Force DWORD" mean?

  1. #1

    What does "Force DWORD" mean?

    Hi everyone

    I'm looking at the code for HGE (Game engine) and i noticed this:

    [pascal]
    THGEIntState = (
    HGE_SCREENWIDTH = 9, // int screen width (default: 800)
    HGE_SCREENHEIGHT = 10, // int screen height (default: 600)
    HGE_SCREENBPP = 11, // int screen bitdepth (default: 32) (desktop bpp in windowed mode)

    HGE_SAMPLERATE = 19, // int sample rate (default: 44100)
    HGE_FXVOLUME = 20, // int global fx volume (default: 100)
    HGE_MUSVOLUME = 21, // int global music volume (default: 100)

    HGE_FPS = 23, // int fixed fps (default: HGEFPS_UNLIMITED)

    HGEINTSTATE_FORCE_DWORD = $7FFFFFF
    );
    [/pascal]

    Notice the HGEINTSTATE_FORCE_DWORD. What does it do??

    I've also seen this in the Direct3d headers. Here is the C++ def for D3DCULL:
    Code:
    typedef enum D3DCULL
    {
        D3DCULL_NONE = 1,
        D3DCULL_CW = 2,
        D3DCULL_CCW = 3,
        D3DCULL_FORCE_DWORD = 0x7fffffff,
    } D3DCULL, *LPD3DCULL;
    Can someone explain what FORCE_DWORD is for?

    thank you.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    What does "Force DWORD" mean?

    The value of "Force DWORD" is used as a trick to force the enumeration to occupy 32 bits.

    The above example uses values from 9 to 23, so it could be packed in smaller structure (byte, for instance). However, the author wanted the enumaration to be 4 bytes long and thus, an additional very large value was added.

  3. #3

    What does "Force DWORD" mean?

    Okay.. so it is used to force the compiler to make every value inside the enum a DWORD.

    but why is this neccesary?
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4

    What does "Force DWORD" mean?

    Quote Originally Posted by chronozphere
    Okay.. so it is used to force the compiler to make every value inside the enum a DWORD.

    but why is this neccesary?
    memory alignment?
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  5. #5

    What does "Force DWORD" mean?

    Delphi version 7 and above have a compiler diretive to force "memory" alignment... but i prefer to use "Consts" and declare THGEIntState = DWORD/Cardinal...

    {$Z4} or {$MINENUMSIZE 4} = if an enumerated type is declared in the {
    $Z4} state, it is stored as an unsigned double word. (much clean that the force_dword trick)

  6. #6

    What does "Force DWORD" mean?

    As far as I know Delphi aligns to dword automatically.

    @chronozphere: This is done because the dword is the 32-Bit-CPUs
    native size. Accessing a dword is much faster than accessing a smaller
    value. Also some Hardware (like the GPU) depends on specially aligned
    data, sometimes.

  7. #7

    What does "Force DWORD" mean?

    Okay.. thanks for the explanation
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  8. #8

    What does "Force DWORD" mean?

    Quote Originally Posted by waran
    As far as I know Delphi aligns to dword automatically.

    @chronozphere: This is done because the dword is the 32-Bit-CPUs
    native size. Accessing a dword is much faster than accessing a smaller
    value. Also some Hardware (like the GPU) depends on specially aligned
    data, sometimes.
    so its faster to evaluate integers (longbool) them evaluate boolean (byte) ?
    From brazil (:

    Pascal pownz!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
http://flippulseimages.com/Dogs/origamy.html