PDA

View Full Version : Handling the graphics inside a DLL



lostsoul
04-19-2004, 04:46 AM
Im currently writing a 3D-engine and i want it to be Graphics API-independent
so i want to put all the code for graphics-drawning in a DLL. I try to
CreateWindow() inside the DLL (i pass pointer to HWND, WndProc etc.) but i get
alot of invalid conversion errors. I don't have my code with me (ill post it
tommorow) but are there any good tutorials on the topic? There are alot of
information about OpenGL, Windows GDI etc. but i havent seen any on how to
do it inside a DLL.

Futhermore i found a great tutorial on flipcode.org
on how to load objects without .def-files so now i can load entire objects and
not just plain C-stuff :) .

plasmonster
04-21-2004, 10:16 PM
If you're trying to create a window in a dll, then you need to make sure you're using the instance sent to DllMain(...) to create the window. For example:

HINSTANCE myInstance;
INT WINAPI DllMain( HINSTANCE hInst, DWORD dwReason, void* pReserved ){
myInstance = hInst;
return 1;
}

then you would use myInstance when registering your window class, and creating your window. But remember, the window is still owned by the application, not the dll.

If you would like some good reading on this subject, I would recommend anything by Charles Petzold.