mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-05-16 10:54:53 +03:00
0022704: A method defining TKOpenGl.dll for Open CASCADE visualization toolkit not using GraphicShr variable.
This commit is contained in:
parent
a10fa81932
commit
6ff13c928b
@ -31,6 +31,13 @@ is
|
|||||||
-- Warning: Raises if something wrong.
|
-- Warning: Raises if something wrong.
|
||||||
raises GraphicDeviceDefinitionError from Aspect;
|
raises GraphicDeviceDefinitionError from Aspect;
|
||||||
|
|
||||||
|
Create ( graphicLib : CString from Standard )
|
||||||
|
returns mutable WNTGraphicDevice from Graphic3d
|
||||||
|
---Purpose: Creates a class instance and provide initialization
|
||||||
|
-- of the graphic library defined by "graphicLib".
|
||||||
|
-- Warning: Raises if something wrong.
|
||||||
|
raises GraphicDeviceDefinitionError from Aspect;
|
||||||
|
|
||||||
Destroy ( me : mutable )
|
Destroy ( me : mutable )
|
||||||
is redefined static;
|
is redefined static;
|
||||||
---Purpose: Destroys all resources attached to the graphic device.
|
---Purpose: Destroys all resources attached to the graphic device.
|
||||||
@ -47,6 +54,12 @@ is
|
|||||||
---Level: Internal
|
---Level: Internal
|
||||||
---Purpose: Sets the GraphicDriver.
|
---Purpose: Sets the GraphicDriver.
|
||||||
|
|
||||||
|
SetGraphicDriver ( me : mutable;
|
||||||
|
graphicLib : CString from Standard )
|
||||||
|
is private;
|
||||||
|
---Level: Internal
|
||||||
|
---Purpose: Sets the GraphicDriver defined by "graphicLib".
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
|
||||||
MyGraphicDriver : GraphicDriver from Graphic3d;
|
MyGraphicDriver : GraphicDriver from Graphic3d;
|
||||||
|
@ -1,98 +1,106 @@
|
|||||||
/*
|
// File: Graphic3d_WNTGraphicDevice.cxx
|
||||||
10-09-00 : GG ; NEW OpenGl driver loading specification
|
|
||||||
when nothing is defined the driver TKOpenGl.dll
|
|
||||||
is loaded from the current PATH.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XDESTROY
|
#if (defined(_WIN32) || defined(__WIN32__))
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <Graphic3d_WNTGraphicDevice.ixx>
|
||||||
#ifdef WNT
|
#include <InterfaceGraphic_wntio.hxx>
|
||||||
# include <Graphic3d_WNTGraphicDevice.ixx>
|
|
||||||
# include <InterfaceGraphic_wntio.hxx>
|
|
||||||
#include <OSD_Environment.hxx>
|
#include <OSD_Environment.hxx>
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
typedef Handle_Graphic3d_GraphicDriver ( *GET_DRIVER_PROC ) ( const char* );
|
// function : Graphic3d_WNTGraphicDevice
|
||||||
|
// purpose :
|
||||||
Graphic3d_WNTGraphicDevice::Graphic3d_WNTGraphicDevice (): WNT_GraphicDevice (Standard_True) {
|
// =======================================================================
|
||||||
|
Graphic3d_WNTGraphicDevice::Graphic3d_WNTGraphicDevice()
|
||||||
SetGraphicDriver ();
|
: WNT_GraphicDevice (Standard_True)
|
||||||
|
|
||||||
if (! MyGraphicDriver->Begin (""))
|
|
||||||
Aspect_GraphicDeviceDefinitionError::Raise
|
|
||||||
("Cannot connect to graphic library");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graphic3d_WNTGraphicDevice::Destroy () {
|
|
||||||
|
|
||||||
#ifdef DESTROY
|
|
||||||
cout << "Graphic3d_WNTGraphicDevice::Destroy ()\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MyGraphicDriver->End ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle(Aspect_GraphicDriver) Graphic3d_WNTGraphicDevice::GraphicDriver () const {
|
|
||||||
|
|
||||||
return MyGraphicDriver;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graphic3d_WNTGraphicDevice::SetGraphicDriver ()
|
|
||||||
{
|
{
|
||||||
|
SetGraphicDriver();
|
||||||
|
if (!MyGraphicDriver->Begin (""))
|
||||||
|
Aspect_GraphicDeviceDefinitionError::Raise ("Cannot connect to graphic library");
|
||||||
|
|
||||||
Standard_Boolean Result;
|
}
|
||||||
OSD_Function new_GLGraphicDriver;
|
|
||||||
Standard_CString TheShr = getenv("CSF_GraphicShr");
|
|
||||||
if ( ! TheShr || ( strlen( TheShr ) == 0 ) )
|
|
||||||
TheShr = "TKOpenGl.dll";
|
|
||||||
|
|
||||||
MySharedLibrary.SetName ( TheShr );
|
// =======================================================================
|
||||||
Result = MySharedLibrary.DlOpen (OSD_RTLD_LAZY);
|
// function : Graphic3d_WNTGraphicDevice
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
Graphic3d_WNTGraphicDevice::Graphic3d_WNTGraphicDevice (const Standard_CString theGraphicLib)
|
||||||
|
: WNT_GraphicDevice (Standard_True)
|
||||||
|
{
|
||||||
|
SetGraphicDriver (theGraphicLib);
|
||||||
|
if (!MyGraphicDriver->Begin (""))
|
||||||
|
Aspect_GraphicDeviceDefinitionError::Raise ("Cannot connect to graphic library");
|
||||||
|
}
|
||||||
|
|
||||||
if (! Result) {
|
// =======================================================================
|
||||||
Aspect_GraphicDeviceDefinitionError::Raise
|
// function : Destroy
|
||||||
(MySharedLibrary.DlError ());
|
// purpose :
|
||||||
}
|
// =======================================================================
|
||||||
else {
|
void Graphic3d_WNTGraphicDevice::Destroy()
|
||||||
// Management of traces
|
{
|
||||||
OSD_Environment beurk("CSF_GraphicTrace");
|
MyGraphicDriver->End();
|
||||||
TCollection_AsciiString val = beurk.Value();
|
}
|
||||||
if (val.Length() > 0 )
|
|
||||||
cout << "Information : " << TheShr << " loaded\n" << flush;
|
|
||||||
|
|
||||||
new_GLGraphicDriver =
|
// =======================================================================
|
||||||
MySharedLibrary.DlSymb ("MetaGraphicDriverFactory");
|
// function : GraphicDriver
|
||||||
if (! new_GLGraphicDriver) {
|
// purpose :
|
||||||
Aspect_GraphicDeviceDefinitionError::Raise
|
// =======================================================================
|
||||||
(MySharedLibrary.DlError ());
|
Handle(Aspect_GraphicDriver) Graphic3d_WNTGraphicDevice::GraphicDriver() const
|
||||||
}
|
{
|
||||||
else {
|
return MyGraphicDriver;
|
||||||
// Sequence :
|
}
|
||||||
// new_GLGraphicDriver is OSD_Function :
|
|
||||||
// typedef int (* OSD_Function)(...);
|
|
||||||
// wherefrom a good cast in GraphicDriver.
|
|
||||||
//Handle( Graphic3d_GraphicDriver ) ADriver = new Graphic3d_GraphicDriver ( TheShr );
|
|
||||||
|
|
||||||
GET_DRIVER_PROC fp = ( GET_DRIVER_PROC )new_GLGraphicDriver;
|
// =======================================================================
|
||||||
//ADriver = ( *fp ) ( TheShr );
|
// function : SetGraphicDriver
|
||||||
if (!fp)
|
// purpose :
|
||||||
Aspect_GraphicDeviceDefinitionError::Raise
|
// =======================================================================
|
||||||
(MySharedLibrary.DlError ());
|
void Graphic3d_WNTGraphicDevice::SetGraphicDriver()
|
||||||
MyGraphicDriver = ( *fp ) ( TheShr );
|
{
|
||||||
|
Standard_CString aLibPath = getenv ("CSF_GraphicShr");
|
||||||
|
if (aLibPath == NULL || strlen (aLibPath) == 0)
|
||||||
|
aLibPath = "TKOpenGl.dll";
|
||||||
|
|
||||||
// Management of traces
|
SetGraphicDriver (aLibPath);
|
||||||
if ( val.Length() > 0 && val.IsIntegerValue() )
|
}
|
||||||
MyGraphicDriver->SetTrace(val.IntegerValue());
|
|
||||||
}
|
// =======================================================================
|
||||||
|
// function : SetGraphicDriver
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void Graphic3d_WNTGraphicDevice::SetGraphicDriver (const Standard_CString theGraphicLib)
|
||||||
|
{
|
||||||
|
MyGraphicDriver.Nullify();
|
||||||
|
|
||||||
|
// load the library
|
||||||
|
MySharedLibrary.SetName (theGraphicLib);
|
||||||
|
if (!MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
|
||||||
|
{
|
||||||
|
Aspect_GraphicDeviceDefinitionError::Raise (MySharedLibrary.DlError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// management of traces
|
||||||
|
OSD_Environment aTraceEnv ("CSF_GraphicTrace");
|
||||||
|
TCollection_AsciiString aTrace = aTraceEnv.Value();
|
||||||
|
if (aTrace.Length() > 0)
|
||||||
|
cout << "Information : " << theGraphicLib << " loaded\n" << flush;
|
||||||
|
|
||||||
|
// retrieve factory function pointer
|
||||||
|
typedef Handle(Graphic3d_GraphicDriver) (*GET_DRIVER_PROC) (const char* );
|
||||||
|
GET_DRIVER_PROC aGraphicDriverConstructor = (GET_DRIVER_PROC )MySharedLibrary.DlSymb ("MetaGraphicDriverFactory");
|
||||||
|
if (aGraphicDriverConstructor == NULL)
|
||||||
|
{
|
||||||
|
Aspect_GraphicDeviceDefinitionError::Raise (MySharedLibrary.DlError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create driver instance
|
||||||
|
MyGraphicDriver = aGraphicDriverConstructor (theGraphicLib);
|
||||||
|
|
||||||
|
// management of traces
|
||||||
|
if (aTrace.Length() > 0 && aTrace.IsIntegerValue())
|
||||||
|
MyGraphicDriver->SetTrace (aTrace.IntegerValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // WNT
|
#endif // WNT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user