00001 // Filename: wdxGraphicsPipe7.cxx 00002 // Created by: drose (20Dec02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "wdxGraphicsPipe7.h" 00020 #include "wdxGraphicsWindow7.h" 00021 #include "config_dxgsg7.h" 00022 00023 TypeHandle wdxGraphicsPipe7::_type_handle; 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: wdxGraphicsPipe7::Constructor 00027 // Access: Public 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 wdxGraphicsPipe7:: 00031 wdxGraphicsPipe7() { 00032 _hDDrawDLL = NULL; 00033 _is_valid = init(); 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: wdxGraphicsPipe7::Destructor 00038 // Access: Public, Virtual 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 wdxGraphicsPipe7:: 00042 ~wdxGraphicsPipe7() { 00043 SAFE_FREELIB(_hDDrawDLL); 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: wdxGraphicsPipe7::get_interface_name 00048 // Access: Published, Virtual 00049 // Description: Returns the name of the rendering interface 00050 // associated with this GraphicsPipe. This is used to 00051 // present to the user to allow him/her to choose 00052 // between several possible GraphicsPipes available on a 00053 // particular platform, so the name should be meaningful 00054 // and unique for a given platform. 00055 //////////////////////////////////////////////////////////////////// 00056 string wdxGraphicsPipe7:: 00057 get_interface_name() const { 00058 return "DirectX7"; 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: wdxGraphicsPipe7::pipe_constructor 00063 // Access: Public, Static 00064 // Description: This function is passed to the GraphicsPipeSelection 00065 // object to allow the user to make a default 00066 // wdxGraphicsPipe7. 00067 //////////////////////////////////////////////////////////////////// 00068 PT(GraphicsPipe) wdxGraphicsPipe7:: 00069 pipe_constructor() { 00070 return new wdxGraphicsPipe7; 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: wdxGraphicsPipe7::make_window 00075 // Access: Protected, Virtual 00076 // Description: Creates a new window on the pipe, if possible. 00077 //////////////////////////////////////////////////////////////////// 00078 PT(GraphicsWindow) wdxGraphicsPipe7:: 00079 make_window(GraphicsStateGuardian *gsg) { 00080 // thanks to the dumb threading requirements this constructor actually does nothing but create an empty c++ object 00081 // no windows are really opened until wdxGraphicsWindow8->open_window() is called 00082 00083 return new wdxGraphicsWindow7(this, gsg); 00084 } 00085 00086 00087 PT(GraphicsStateGuardian) wdxGraphicsPipe7:: 00088 make_gsg(const FrameBufferProperties &properties) { 00089 00090 // FrameBufferProperties really belongs as part of the window/renderbuffer specification 00091 // put here because of GLX multithreading requirement 00092 PT(DXGraphicsStateGuardian7) gsg = new DXGraphicsStateGuardian7(properties); 00093 return gsg.p(); 00094 } 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function: wdxGraphicsPipe7::init 00098 // Access: Private 00099 // Description: Performs some initialization steps to load up 00100 // function pointers from the relevant DLL's, and 00101 // determine the number and type of available graphics 00102 // adapters, etc. Returns true on success, false on 00103 // failure. 00104 //////////////////////////////////////////////////////////////////// 00105 bool wdxGraphicsPipe7:: 00106 init() { 00107 00108 if(!MyLoadLib(_hDDrawDLL,"ddraw.dll")) { 00109 goto error; 00110 } 00111 00112 if(!MyGetProcAddr(_hDDrawDLL, (FARPROC*)&_DirectDrawCreateEx, "DirectDrawCreateEx")) { 00113 goto error; 00114 } 00115 00116 return true; 00117 00118 error: 00119 return false; 00120 }