7fd59977 |
1 | /* |
2 | 10-09-00 : GG ; NEW OpenGl driver loading specification |
3 | when nothing is defined the driver TKOpenGl.dll |
4 | is loaded from the current PATH. |
5 | */ |
6 | |
7 | #define XDESTROY |
8 | |
9 | #include <stdlib.h> |
10 | |
11 | |
12 | #ifdef WNT |
13 | # include <Graphic3d_WNTGraphicDevice.ixx> |
14 | # include <InterfaceGraphic_wntio.hxx> |
15 | #include <OSD_Environment.hxx> |
16 | #include <TCollection_AsciiString.hxx> |
17 | |
18 | |
19 | typedef Handle_Graphic3d_GraphicDriver ( *GET_DRIVER_PROC ) ( const char* ); |
20 | |
21 | Graphic3d_WNTGraphicDevice::Graphic3d_WNTGraphicDevice (): WNT_GraphicDevice (Standard_True) { |
22 | |
23 | SetGraphicDriver (); |
24 | |
25 | if (! MyGraphicDriver->Begin ("")) |
26 | Aspect_GraphicDeviceDefinitionError::Raise |
27 | ("Cannot connect to graphic library"); |
28 | |
29 | } |
30 | |
31 | void Graphic3d_WNTGraphicDevice::Destroy () { |
32 | |
33 | #ifdef DESTROY |
34 | cout << "Graphic3d_WNTGraphicDevice::Destroy ()\n"; |
35 | #endif |
36 | |
37 | MyGraphicDriver->End (); |
38 | |
39 | } |
40 | |
41 | Handle(Aspect_GraphicDriver) Graphic3d_WNTGraphicDevice::GraphicDriver () const { |
42 | |
43 | return MyGraphicDriver; |
44 | |
45 | } |
46 | |
47 | void Graphic3d_WNTGraphicDevice::SetGraphicDriver () |
48 | { |
49 | |
50 | Standard_Boolean Result; |
51 | OSD_Function new_GLGraphicDriver; |
52 | Standard_CString TheShr = getenv("CSF_GraphicShr"); |
53 | if ( ! TheShr || ( strlen( TheShr ) == 0 ) ) |
54 | TheShr = "TKOpenGl.dll"; |
55 | |
56 | MySharedLibrary.SetName ( TheShr ); |
57 | Result = MySharedLibrary.DlOpen (OSD_RTLD_LAZY); |
58 | |
59 | if (! Result) { |
60 | Aspect_GraphicDeviceDefinitionError::Raise |
61 | (MySharedLibrary.DlError ()); |
62 | } |
63 | else { |
81bba717 |
64 | // Management of traces |
7fd59977 |
65 | OSD_Environment beurk("CSF_GraphicTrace"); |
66 | TCollection_AsciiString val = beurk.Value(); |
67 | if (val.Length() > 0 ) |
68 | cout << "Information : " << TheShr << " loaded\n" << flush; |
69 | |
70 | new_GLGraphicDriver = |
71 | MySharedLibrary.DlSymb ("MetaGraphicDriverFactory"); |
72 | if (! new_GLGraphicDriver) { |
73 | Aspect_GraphicDeviceDefinitionError::Raise |
74 | (MySharedLibrary.DlError ()); |
75 | } |
76 | else { |
81bba717 |
77 | // Sequence : |
78 | // new_GLGraphicDriver is OSD_Function : |
7fd59977 |
79 | // typedef int (* OSD_Function)(...); |
81bba717 |
80 | // wherefrom a good cast in GraphicDriver. |
7fd59977 |
81 | //Handle( Graphic3d_GraphicDriver ) ADriver = new Graphic3d_GraphicDriver ( TheShr ); |
82 | |
83 | GET_DRIVER_PROC fp = ( GET_DRIVER_PROC )new_GLGraphicDriver; |
84 | //ADriver = ( *fp ) ( TheShr ); |
85 | if (!fp) |
86 | Aspect_GraphicDeviceDefinitionError::Raise |
87 | (MySharedLibrary.DlError ()); |
88 | MyGraphicDriver = ( *fp ) ( TheShr ); |
89 | |
81bba717 |
90 | // Management of traces |
7fd59977 |
91 | if ( val.Length() > 0 && val.IsIntegerValue() ) |
92 | MyGraphicDriver->SetTrace(val.IntegerValue()); |
93 | } |
94 | } |
95 | |
96 | } |
97 | |
98 | #endif // WNT |