Page 1 of 1
Need help converting a macro for directx 9...
Posted: Tue Oct 14, 2003 6:00 pm
by Codemonger
Ok I finally worked out getting a triangle to display really great in d3d9 but I am moving on to transformation with matrices etc... so I'm in the middle of trying to get a macro converted. I'm lost on this one, if anyone can help I would appreciate it. Thanks
Here is part of the header I am trying to convert :
Code: Select all
typedef enum _D3DTRANSFORMSTATETYPE {
D3DTS_VIEW = 2,
D3DTS_PROJECTION = 3,
D3DTS_TEXTURE0 = 16,
D3DTS_TEXTURE1 = 17,
D3DTS_TEXTURE2 = 18,
D3DTS_TEXTURE3 = 19,
D3DTS_TEXTURE4 = 20,
D3DTS_TEXTURE5 = 21,
D3DTS_TEXTURE6 = 22,
D3DTS_TEXTURE7 = 23,
D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DTRANSFORMSTATETYPE;
#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
#define D3DTS_WORLD D3DTS_WORLDMATRIX(0)
I need D3DTS_WORLD which is defined as a macro ?? hmmm. any ideas of what it should look like...
Posted: Tue Oct 14, 2003 8:12 pm
by freak
_D3DTRANSFORMSTATETYPE is an enumeration, so you could convert it
to a PB Enumeration. But since all values are given, that doesn't make any sense.
In PB:
Code: Select all
#D3DTS_VIEW = 2
#D3DTS_PROJECTION = 3
#D3DTS_TEXTURE0 = 16
#D3DTS_TEXTURE1 = 17
#D3DTS_TEXTURE2 = 18
#D3DTS_TEXTURE3 = 19
#D3DTS_TEXTURE4 = 20
#D3DTS_TEXTURE5 = 21
#D3DTS_TEXTURE6 = 22
#D3DTS_TEXTURE7 = 23
D3DTS_FORCE_DWORD is not needed, as it is only there to make the
enumerationtype 32bit.
Macros are simple replacements, so if you replace one macro after the
other here, you end up with the value 256 for D3DTS_WORLD
Timo
Posted: Tue Oct 14, 2003 8:37 pm
by Codemonger
Thanks again Freak, I knew about the enumeration, but the macro I wasn't sure about the getting the end result. Anyway I'll try to plug in the value and see if I can get a matrix tutorial up and running. I have to clean my code up also, before I post it for everybody to try out.
Posted: Wed Oct 15, 2003 6:22 am
by Codemonger
Stumped on this structure ... it looks like it uses a multi-dimensional array in the structure, can this be done ? I tried with no luck.
typedef struct _D3DMATRIX {
union {
struct {
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
float _41, _42, _43, _44;
};
float m[4][4];
};
} D3DMATRIX;
Posted: Wed Oct 15, 2003 11:05 am
by Fred
For me, #define D3DTS_WORLD macro is like '#D3DTS_WORLD = 256' in PureBasic.
Posted: Wed Oct 15, 2003 12:21 pm
by traumatic
Codemonger wrote:
float m[4][4];
maybe like this?
Code: Select all
Structure M_HELP
m.f[4]
EndStructure
Structure D3DMATRIX
StructureUnion
_11.f : _12.f : _13.f : _14.f
_21.f : _22.f : _23.f : _24.f
_31.f : _32.f : _33.f : _34.f
_41.f : _42.f : _43.f : _44.f
m.M_HELP[4]
EndStructureUnion
EndStructure
myvar.D3DMATRIX
myvar\m[0]\m[0] = 0.1
myvar\m[1]\m[0] = 0.2
myvar\m[0]\m[1] = 0.3
Debug myvar\m[1]\m[0]
does this help?
Posted: Wed Oct 15, 2003 12:34 pm
by Pupil
No you would have to do something like this in PB to get a somewhat similar structure:
Code: Select all
Structure M_HELP
m.f[4]
EndStructure
Structure _help
_11.f : _12.f : _13.f : _14.f
_21.f : _22.f : _23.f : _24.f
_31.f : _32.f : _33.f : _34.f
_41.f : _42.f : _43.f : _44.f
EndStructure
Structure D3DMATRIX
StructureUnion
n._help
m.M_HELP[4]
EndStructureUnion
EndStructure
myvar.D3DMATRIX
myvar\m[0]\m[0] = 0.1
myvar\m[1]\m[0] = 0.2
myvar\m[0]\m[1] = 0.3
Debug myvar\m[1]\m[0]
Debug myvar\n\_21
Posted: Wed Oct 15, 2003 5:01 pm
by Codemonger
Thanks guys, but i think this is going to be a long haul so I'm going to throw the all the code up and make it open source , so people can test it and add more to it. I'll start something on one of my websites. Just too many little details and road blocks for me. Thanks for the help and I'll post a link up to a dedicated area for anyone that is interested in tackling DirectX 9 conversion
