move DLL loads to pipe
This commit is contained in:
parent
bd69f6a38c
commit
a899d41bdb
|
|
@ -29,6 +29,8 @@ TypeHandle wdxGraphicsPipe7::_type_handle;
|
|||
////////////////////////////////////////////////////////////////////
|
||||
wdxGraphicsPipe7::
|
||||
wdxGraphicsPipe7() {
|
||||
_hDDrawDLL = NULL;
|
||||
_is_valid = init();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -38,6 +40,10 @@ wdxGraphicsPipe7() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
wdxGraphicsPipe7::
|
||||
~wdxGraphicsPipe7() {
|
||||
if (_hDDrawDLL != NULL) {
|
||||
FreeLibrary(_hDDrawDLL);
|
||||
_hDDrawDLL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -76,3 +82,33 @@ PT(GraphicsWindow) wdxGraphicsPipe7::
|
|||
make_window() {
|
||||
return new wdxGraphicsWindow7(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsPipe7::init
|
||||
// Access: Private
|
||||
// Description: Performs some initialization steps to load up
|
||||
// function pointers from the relevant DLL's, and
|
||||
// determine the number and type of available graphics
|
||||
// adapters, etc. Returns true on success, false on
|
||||
// failure.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wdxGraphicsPipe7::
|
||||
init() {
|
||||
static const char * const ddraw_name = "ddraw.dll";
|
||||
_hDDrawDLL = LoadLibrary(ddraw_name);
|
||||
if(_hDDrawDLL == 0) {
|
||||
wdxdisplay7_cat.error()
|
||||
<< "can't locate " << ddraw_name << "!\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
_DirectDrawCreateEx =
|
||||
(LPDIRECTDRAWCREATEEX)GetProcAddress(_hDDrawDLL, "DirectDrawCreateEx");
|
||||
if (_DirectDrawCreateEx == NULL) {
|
||||
wdxdisplay7_cat.error()
|
||||
<< "GetProcAddr failed for DDCreateEx" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@ public:
|
|||
protected:
|
||||
virtual PT(GraphicsWindow) make_window();
|
||||
|
||||
private:
|
||||
bool init();
|
||||
|
||||
private:
|
||||
HINSTANCE _hDDrawDLL;
|
||||
|
||||
typedef HRESULT (WINAPI * LPDIRECTDRAWCREATEEX)(GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter);
|
||||
LPDIRECTDRAWCREATEEX _DirectDrawCreateEx;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
|
|
@ -54,6 +63,8 @@ public:
|
|||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
|
||||
friend class wdxGraphicsWindow7;
|
||||
};
|
||||
|
||||
#include "wdxGraphicsPipe7.I"
|
||||
|
|
|
|||
|
|
@ -108,9 +108,6 @@ EnumDisplayModesCallBack(LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext) {
|
|||
#define IS_ATI(DDDEVICEID) (DDDEVICEID.dwVendorId==0x1002)
|
||||
#define IS_MATROX(DDDEVICEID) (DDDEVICEID.dwVendorId==0x102B)
|
||||
|
||||
HINSTANCE wdxGraphicsWindow7::_hDDrawDLL = NULL;
|
||||
LPDIRECTDRAWCREATEEX wdxGraphicsWindow7::_pDDCreateEx = NULL;
|
||||
|
||||
TypeHandle wdxGraphicsWindow7::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -149,7 +146,6 @@ make_gsg() {
|
|||
// Tell the associated dxGSG about the window handle.
|
||||
_dxgsg->scrn.hWnd = _mwindow;
|
||||
|
||||
init_ddraw();
|
||||
if (!search_for_device(0, NULL)) {
|
||||
wdxdisplay7_cat.error()
|
||||
<< "Unable to find suitable rendering device.\n";
|
||||
|
|
@ -957,6 +953,9 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool wdxGraphicsWindow7::
|
||||
search_for_device(int devnum, DXDeviceInfo *pDevinfo) {
|
||||
wdxGraphicsPipe7 *dxpipe;
|
||||
DCAST_INTO_R(dxpipe, _pipe, false);
|
||||
|
||||
DWORD dwRenderWidth = get_properties().get_x_size();
|
||||
DWORD dwRenderHeight = get_properties().get_y_size();
|
||||
LPDIRECTDRAW7 pDD=NULL;
|
||||
|
|
@ -971,11 +970,11 @@ search_for_device(int devnum, DXDeviceInfo *pDevinfo) {
|
|||
pDDDeviceGUID = &pDevinfo->guidDeviceIdentifier;
|
||||
}
|
||||
|
||||
assert(_pDDCreateEx != NULL);
|
||||
assert(dxpipe->_DirectDrawCreateEx != NULL);
|
||||
|
||||
// Create the Direct Draw Objects
|
||||
hr = (*(_pDDCreateEx))(pDDDeviceGUID,(void **)&pDD,
|
||||
IID_IDirectDraw7, NULL);
|
||||
hr = (*dxpipe->_DirectDrawCreateEx)(pDDDeviceGUID, (void **)&pDD,
|
||||
IID_IDirectDraw7, NULL);
|
||||
if ((hr != DD_OK) || (pDD == NULL)) {
|
||||
wdxdisplay7_cat.fatal()
|
||||
<< "DirectDrawCreateEx failed for monitor(" << devnum
|
||||
|
|
@ -1301,31 +1300,3 @@ set_coop_levels_and_display_modes() {
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsWindow7::init_ddraw
|
||||
// Access: Private, Static
|
||||
// Description: Gets the pointer to the DirectDrawCreateEx function
|
||||
// from ddraw.dll, if it hasn't been retrieved already.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsWindow7::
|
||||
init_ddraw() {
|
||||
if (_hDDrawDLL != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
static const char * const ddraw_name = "ddraw.dll";
|
||||
_hDDrawDLL = LoadLibrary(ddraw_name);
|
||||
if(_hDDrawDLL == 0) {
|
||||
wdxdisplay7_cat.fatal()
|
||||
<< "can't locate " << ddraw_name <<"!\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
_pDDCreateEx = (LPDIRECTDRAWCREATEEX)GetProcAddress(_hDDrawDLL,"DirectDrawCreateEx");
|
||||
if(_pDDCreateEx == NULL) {
|
||||
wdxdisplay7_cat.fatal()
|
||||
<< "Panda currently requires at least DirectX 7.0!\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,13 +62,8 @@ private:
|
|||
bool search_for_device(int devnum, DXDeviceInfo *pDevinfo);
|
||||
void set_coop_levels_and_display_modes();
|
||||
|
||||
static void init_ddraw();
|
||||
|
||||
DXGraphicsStateGuardian7 *_dxgsg;
|
||||
|
||||
static HINSTANCE _hDDrawDLL;
|
||||
static LPDIRECTDRAWCREATEEX _pDDCreateEx;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
|
|
|
|||
Loading…
Reference in New Issue