Best Way ? (Directx Related)

Started by
14 comments, last by Luke1 21 years, 1 month ago
I would guess that you are not including the correct library files, or you are not including d3dx8.h in your files
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Advertisement
nope i have all the correct headers and libraries so thats not it.
I dont understand totally how you are calling your funcitons

can you give me an example of a function that is having problems?

If you have lets say a DirectX class where you do all your setup etc, and in that class you have

public:
LPDIRECT3DDEVCICE8 Device;

And another class say SkyDome and you have a function calles

InitDome(int size, LPDIRECT3DDEVICE8 Device)
{
Device->CreatVertexBuffer();
...
}
You should have no problems passing the device to that function.

[edited by - RhoneRanger on March 8, 2003 10:58:35 AM]
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Ok ive managed to get it working and this is what ive come up with(*note it works), feel free to tell me how i can improve it

*this is my actual code but its the same layout:
cEng.h

      class cEng{public:LPDIRECT3D8 D3D;LPDIRECT3DDEVICE8 D3DDevice;void cEng::SetVars(LPDIRECT3D8 g_D3D, LPDIRECT3DDEVICE8 g_D3DDevice)HRESULT cEng::StartD3D(HWND Hwnd)};  

cEng.cpp

  void cEng::SetVars(LPDIRECT3D8 g_D3D, LPDIRECT3DDEVICE8 g_D3DDevice){D3D = g_D3D;D3DDevice = g_D3DDevice;}HRESULT cEng::StartD3D(HWND Hwnd){...CreateDevice(...,...,D3DDevice)...}      


[edited by - Luke1 on March 8, 2003 11:14:42 AM]

[edited by - Luke1 on March 8, 2003 11:15:30 AM]
Put a pointer in every class.
The pointer is ALWAYS updated, cuz it''s a pointer.
You pass it in the INITIALIZATION functions, and keep a pointer.

.lick
OKAY

I would make D3D private and Device public.

Look at this line

void cEng::SetVars(LPDIRECT3D8 g_D3D, LPDIRECT3DDEVICE8 g_D3DDevice)

since g_D3D and g_D3DDevice are already class members, you dont pass them via functions.

Here is how I would handle things based on your class
cEng.h

      class cEng{private:    LPDIRECT3D8 D3D;public:    cEng();    ~cEng();    LPDIRECT3DDEVICE8 D3DDevice;    HRESULT  StartD3D(HWND Hwnd);   };      




EDIT: You should learn about classes before you try to do this!

[edited by - RhoneRanger on March 8, 2003 11:24:25 AM]
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno

This topic is closed to new replies.

Advertisement