Archived

This topic is now archived and is closed to further replies.

Mythomania

using d3d8 directly from dll

Recommended Posts

how can i do that? i know there are loadlibrary and getprocaddress, but how can i get the whole interfaces from the dll? i need to know this since i dont want to link to d3d8.lib (want to keep the exe small). thanx in advance Indifference will be the downfall of mankind. But who cares?

Share this post


Link to post
Share on other sites
d3d8.lib is just an import library. If you link to it, your program will still use the DLLs. There are no static DirectX libraries.

Share this post


Link to post
Share on other sites
I think he will just not use the .lib
The best is to use CoCreateInterface instead of getProcAddress.
But you need to learn a little COM look at DirectMusic example (it use COM )

Why English rules?? C pas très malin tout ça!

Share this post


Link to post
Share on other sites
d3d8.dll only exports 3 functions, so I guess you can use GetProcAddress to retrieve Direct3DCreate8 (the most-used one) if needed:

  
typedef IDirect3D8* (WINAPI* DIRECT3DCREATE8)(UINT nSDKVersion);

HINSTANCE hD3d = LoadLibrary("d3d8.dll");
DIRECT3DCREATE8 create = (DIRECT3DCREATE8)GetProcAddress("Direct3DCreate8");

// now you can use create to create d3d interface

// remember to free hD3d using FreeLibrary


Share this post


Link to post
Share on other sites
mutex: Ok, so I can get the Direct3DCreate8 function, but then? I can create a device, but can i call the member functions on it? Or do I have to do more?
jesterlecodeur: how does cocreateinterface work? cant find it in the win32.hlp unfortunately :-(
ill look in the msdn later...
thanx, you two

Share this post


Link to post
Share on other sites
You can use the methods provided by an interface regardless of how you obtained the interface (thats one of the purposes of COM).

You still have to include the .h files (obviously).

BTW the function is called CoCreateInstance, not CoCreateInterface (because you create an instance of an object supporting an interface).

So either link to the lib (doesn't cause any bloat since it doesn't import any code, only provides link-info about a few functions) or use CoCreateInstance or LoadLibrary/GetProcAddress/Direct3DCreate8 functions to obtain an interface.

Edited by - Dactylos on June 10, 2001 5:02:59 AM

Share this post


Link to post
Share on other sites
Ahhh, I see. I just read your "doesn''t cause any bloat" and thought "huh? what? why''s my exe half a MB big?" and i looked at the libs i link to. it''s the d3dx libs that make the exe that big, not the d3d8.lib *slaps his head with the flat hand*
Well, thanx anyway ;-)
I''ll try to load the dll function directly anyway, see what difference it makes...(and of course ill have to write the basic matrix functions and stuff myself now...)
(cause i wanna start writing 64k demos and 1 or 2 kb can matter a lot there...)

Indifference will be the downfall of mankind. But who cares?

Share this post


Link to post
Share on other sites
Just to let you know, while you can use CoCreateInstance with past versions of DX (as well as most COM objects), it does not work with DX8. You cannot create a D3D8 object via CoCreateInstance. There was a thread about this a while back on the DXDev mailing list.

Share this post


Link to post
Share on other sites