1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0023712: Remove dependency on Aspect_GraphicDevice from Aspect_Window

This commit is contained in:
dbv
2013-02-18 11:59:36 +04:00
parent 8db070a59d
commit dc3fe572ec
114 changed files with 809 additions and 10216 deletions

View File

@@ -46,7 +46,6 @@ Graphic3d_CTransPersStruct.hxx
Graphic3d_CTransPersStruct.cxx
Graphic3d_NListOfHAsciiString.hxx
Graphic3d_AspectText3d.cxx
Graphic3d_WNTGraphicDevice.cxx
Graphic3d_PtrFrameBuffer.hxx
Graphic3d_BufferType.hxx
Graphic3d_Vec2.hxx

View File

@@ -467,15 +467,6 @@ is
---Purpose: For grouping together primitives in a structure
---Category: Classes
class GraphicDevice;
---Purpose: Defines a physical graphic device allowing to
-- shares graphical ressources.
---Category: Classes
class WNTGraphicDevice;
---Purpose: Defines a physical graphic device for Windows NT
---Category: Classes
class MaterialAspect;
---Purpose: Aspect attributes of a 3d face.
---Category: Classes
@@ -615,4 +606,15 @@ is
end SortType;
----------------------------
-- Category: Package methods
----------------------------
InitGraphicDriver (theDisplayConnection: DisplayConnection_Handle from Aspect)
returns GraphicDriver from Graphic3d
raises DriverDefinitionError from Aspect;
---Purpose: Initialize graphic driver and returns Handle to it.
end Graphic3d;

View File

@@ -0,0 +1,83 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Graphic3d.ixx>
#include <Aspect_DisplayConnection.hxx>
#include <Aspect_DriverDefinitionError.hxx>
#include <OSD_Environment.hxx>
//=======================================================================
//function : InitGraphicDriver
//purpose :
//=======================================================================
Handle(Graphic3d_GraphicDriver) Graphic3d::InitGraphicDriver (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
{
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
if (theDisplayConnection.IsNull())
{
Aspect_DriverDefinitionError::Raise ("Null display connection.");
}
#endif
TCollection_AsciiString aGraphicLibName;
// Setting the library name. Depends on the platform.
#if defined(_WIN32) || defined(__WIN32__)
aGraphicLibName = "TKOpenGl.dll";
#elif defined(__hpux) || defined(HPUX)
aGraphicLibName = "libTKOpenGl.sl";
#elif defined(__APPLE__)
aGraphicLibName = "libTKOpenGl.dylib";
#else
aGraphicLibName = "libTKOpenGl.so";
#endif
// Loading the library.
OSD_SharedLibrary aSharedLibrary (aGraphicLibName.ToCString());
if (!aSharedLibrary.DlOpen (OSD_RTLD_LAZY))
{
Aspect_DriverDefinitionError::Raise (aSharedLibrary.DlError());
}
// Retrieving factory function pointer.
typedef Handle(Graphic3d_GraphicDriver) (*GraphicDriverFactoryPointer) (Standard_CString);
GraphicDriverFactoryPointer aGraphicDriverConstructor = (GraphicDriverFactoryPointer )aSharedLibrary.DlSymb ("MetaGraphicDriverFactory");
if (aGraphicDriverConstructor == NULL)
{
Aspect_DriverDefinitionError::Raise (aSharedLibrary.DlError());
}
// Creating driver instance.
Handle(Graphic3d_GraphicDriver) aGraphicDriver = aGraphicDriverConstructor (aSharedLibrary.Name());
// Management of traces.
OSD_Environment aTraceEnv ("CSF_GraphicTrace");
TCollection_AsciiString aTrace = aTraceEnv.Value();
if (aTrace.IsIntegerValue())
{
aGraphicDriver->SetTrace (aTrace.IntegerValue());
}
// Starting graphic driver.
if (!aGraphicDriver->Begin (theDisplayConnection))
{
Aspect_DriverDefinitionError::Raise ("Cannot connect to graphic library.");
}
return aGraphicDriver;
}

View File

@@ -1,94 +0,0 @@
-- Created on: 1994-01-19
-- Created by: CAL
-- Copyright (c) 1994-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
-- Modified: GG RIC120302 add new constructor to pass Display structure
-- directly instead the connexion name.
class GraphicDevice from Graphic3d inherits GraphicDevice from Xw
---Purpose: This class allows the definition of the Advanced
-- Graphic Device
-- Warning: An Graphic Device is defined by a connexion
-- "host:server.screen"
uses
SharedLibrary from OSD,
GraphicDriver from Aspect,
Display from Aspect,
GraphicDriver from Graphic3d,
TypeOfMapping from Xw,
AsciiString from TCollection
raises
GraphicDeviceDefinitionError from Aspect
is
Create ( Connexion : CString from Standard;
Mapping : TypeOfMapping from Xw = Xw_TOM_COLORCUBE;
Ncolors : Integer from Standard = 0;
UseDefault : Boolean from Standard = Standard_True )
returns mutable GraphicDevice from Graphic3d
---Level: Public
---Purpose: Creates a GraphicDevice
---Warning: Raises if the Device is badly defined
raises GraphicDeviceDefinitionError from Aspect;
Create ( DisplayHandle : Display from Aspect)
returns mutable GraphicDevice from Graphic3d
---Level: Public
---Purpose: Creates a GraphicDevice from the Display structure
---Warning: Raises if the Device is badly defined
raises GraphicDeviceDefinitionError from Aspect;
Destroy ( me : mutable )
is redefined static;
---Level: Public
---Purpose: Deletes the GraphicDevice <me>.
---C++: alias ~
GraphicDriver ( me )
returns GraphicDriver from Aspect
is redefined static;
---Level: Public
---Purpose: Returns the GraphicDriver.
SetGraphicDriver ( me : mutable )
is private;
---Level: Internal
---Purpose: Sets the GraphicDriver.
ShrEnvString ( me )
returns AsciiString from TCollection
is private;
---Level: Internal
---Purpose: Returns the environment string for loading shared graphics library.
-- The string can be defined in environment by corresponding variables,
-- or default value will be used for loading from system library path
-- Environment variables : CSF_GraphicShr
fields
MyGraphicDriver : GraphicDriver from Graphic3d;
end GraphicDevice from Graphic3d;

View File

@@ -1,205 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
/***********************************************************************
FONCTION :
----------
Classe Graphic3d_GraphicDevice.cxx :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
Janvier 1994 : CAL ; Creation.
04-02-97 : FMN ; Suppression appel call_tox_set_colormap_mapping()
10-09-00 : GG ; NEW OpenGl driver loading specification
when nothing is defined the driver libTKOpenGl[.so|.sl]
is loading from the current PATH
************************************************************************/
#if (!defined(_WIN32) && !defined(__WIN32__))
#include <stdio.h>
#include <sys/utsname.h>
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <Graphic3d_GraphicDevice.ixx>
#include <Graphic3d_GraphicDriver.hxx>
#include <OSD_Function.hxx>
#include <OSD_Environment.hxx>
#include <TCollection_AsciiString.hxx>
#include <Xw_Cextern.hxx>
//-Static data definitions
static char LocalMessag[80] ;
//-Aliases
//-Global data definitions
//-Constructor
Graphic3d_GraphicDevice::Graphic3d_GraphicDevice (const Standard_CString Connexion, const Xw_TypeOfMapping /*Mapping*/, const Standard_Integer Ncolors, const Standard_Boolean UseDefault ):
Xw_GraphicDevice () {
Standard_CString connexion = (Connexion) ? Connexion : Standard_CString("") ;
Standard_Boolean status ;
MyExtendedDisplay = Xw_open_display((Standard_PCharacter)connexion) ;
if( !MyExtendedDisplay ) {
sprintf(LocalMessag,"Cannot connect to server '%s'",connexion) ;
Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
}
SetGraphicDriver ();
status = MyGraphicDriver->Begin (connexion);
if( !status ) {
sprintf(LocalMessag,"Cannot connect to graphic library from '%s'",
connexion) ;
Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
}
this->InitMaps (connexion,Xw_TOM_READONLY,Ncolors,UseDefault);
}
Graphic3d_GraphicDevice::Graphic3d_GraphicDevice (const Aspect_Display pdisplay)
: Xw_GraphicDevice ()
{
Standard_Boolean status ;
if( !pdisplay )
Aspect_GraphicDeviceDefinitionError::Raise ("Bad display pointer");
MyExtendedDisplay = Xw_set_display(pdisplay) ;
Standard_CString connexion = Xw_get_display_name(MyExtendedDisplay);
if( !MyExtendedDisplay ) {
if( connexion )
sprintf(LocalMessag,"Cannot connect to server '%s'",connexion) ;
else
sprintf(LocalMessag,"Cannot connect to an UNKNOWN server") ;
Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
}
SetGraphicDriver ();
status = MyGraphicDriver->Begin (pdisplay);
if( !status ) {
sprintf(LocalMessag,"Cannot connect to graphic library from '%s'",
connexion) ;
Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
}
this->InitMaps (connexion,Xw_TOM_READONLY,0,Standard_True);
}
// Destructor
void Graphic3d_GraphicDevice::Destroy()
{
MyGraphicDriver->End();
}
// Methods in order
Handle(Aspect_GraphicDriver) Graphic3d_GraphicDevice::GraphicDriver () const {
return MyGraphicDriver;
}
void Graphic3d_GraphicDevice::SetGraphicDriver () {
TCollection_AsciiString aShr = ShrEnvString ();
OSD_SharedLibrary TheSharedLibrary (aShr.ToCString());
Standard_Boolean Result = TheSharedLibrary.DlOpen (OSD_RTLD_LAZY);
if (! Result) {
Aspect_GraphicDeviceDefinitionError::Raise
(TheSharedLibrary.DlError ());
}
else {
// Management of traces
char *tracevalue = NULL;
tracevalue = (char *)(getenv ("CSF_GraphicTrace"));
if (tracevalue)
cout << "Information : " << aShr << " loaded\n" << flush;
OSD_Function new_GLGraphicDriver =
TheSharedLibrary.DlSymb ("MetaGraphicDriverFactory");
if (tracevalue)
cout << "Information : MetaGraphicDriverFactory "
<< (new_GLGraphicDriver ? "found\n" : "not found\n") << flush;
if (! new_GLGraphicDriver) {
Aspect_GraphicDeviceDefinitionError::Raise
(TheSharedLibrary.DlError ());
}
else {
// Sequence :
// new_GLGraphicDriver is OSD_Function :
// typedef int (* OSD_Function)(...);
// that is why good cast in GraphicDriver.
Handle(Graphic3d_GraphicDriver)
(*fp) (Standard_CString) = NULL;
fp = (Handle(Graphic3d_GraphicDriver)
(*) (Standard_CString)) new_GLGraphicDriver;
if (tracevalue) cout << "FP == "<<(void *) fp<<endl;
Standard_CString aSharedName = TheSharedLibrary.Name ();
MyGraphicDriver = (*fp) (aSharedName);
// MyGraphicDriver = (*fp) (TheSharedLibrary.Name ());
// Management of traces
if (tracevalue)
MyGraphicDriver->SetTrace
((Standard_Integer) atoi (tracevalue));
}
}
}
TCollection_AsciiString Graphic3d_GraphicDevice::ShrEnvString() const
{
OSD_Environment aEnvShr ("CSF_GraphicShr");
if (!aEnvShr.Value().IsEmpty())
{
return aEnvShr.Value();
}
// load TKOpenGl using default searching mechanisms in system
#if defined(__hpux) || defined(HPUX)
return TCollection_AsciiString ("libTKOpenGl.sl");
#elif defined(__APPLE__)
return TCollection_AsciiString ("libTKOpenGl.dylib");
#else
return TCollection_AsciiString ("libTKOpenGl.so");
#endif
}
#endif // !WNT

View File

@@ -57,6 +57,7 @@ uses
Handle from Aspect,
Display from Aspect,
PrintAlgo from Aspect,
DisplayConnection_Handle from Aspect,
AspectLine3d from Graphic3d,
AspectMarker3d from Graphic3d,
@@ -107,17 +108,11 @@ is
-- Category: Init methods
-------------------------
Begin ( me : mutable;
ADisplay : CString from Standard )
returns Boolean from Standard
is deferred;
---Purpose: call_togl_begin
Begin ( me : mutable;
ADisplay : Display from Aspect )
returns Boolean from Standard
is deferred;
---Purpose: call_togl_begin_display
Begin (me: mutable;
theDisplayConnection: DisplayConnection_Handle from Aspect)
returns Boolean from Standard
is deferred;
---Purpose: Starts graphic driver with given connection
End ( me : mutable )
is deferred;
@@ -1071,9 +1066,16 @@ is
-- returns Standard_False if fails
-- ABD Integration support of system fonts (using FTGL and FreeType)
GetDisplayConnection (me)
returns DisplayConnection_Handle from Aspect;
---C++: return const &
---Purpose: returns Handle to display connection
fields
MyTraceLevel : Integer from Standard is protected;
MySharedLibrary : SharedLibrary from OSD is protected;
MyTraceLevel : Integer from Standard is protected;
MySharedLibrary : SharedLibrary from OSD is protected;
myDisplayConnection: DisplayConnection_Handle from Aspect is protected;
end GraphicDriver from Graphic3d;

View File

@@ -237,3 +237,8 @@ Standard_Integer Graphic3d_GraphicDriver::Trace () const {
return MyTraceLevel;
}
const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
{
return myDisplayConnection;
}

View File

@@ -39,7 +39,6 @@
#include <Graphic3d_Group.ixx>
#include <Graphic3d_Group.pxx>
#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransModeFlags.hxx>
@@ -101,10 +100,8 @@ MyListOfPArray()
MyCGroup.PickId.IsSet = 0,
MyCGroup.PickId.Value = 0;
Handle(Aspect_GraphicDriver) agd =
((MyStructure->StructureManager ())->GraphicDevice ())->GraphicDriver ();
MyGraphicDriver = (MyStructure->StructureManager())->GraphicDriver();
MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
MyGraphicDriver->Group (MyCGroup);

View File

@@ -90,7 +90,6 @@
#include <Graphic3d_Structure.ixx>
#include <Graphic3d_Structure.pxx>
#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_MaterialAspect.hxx>
@@ -191,11 +190,8 @@ MyHighlightColor (Quantity_NOC_WHITE)
MyCStructure.TransformPersistence.Point.y = 0.0;
MyCStructure.TransformPersistence.Point.z = 0.0;
/* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
Handle(Aspect_GraphicDriver) agd =
(AManager->GraphicDevice ())->GraphicDriver ();
MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
MyGraphicDriver = AManager->GraphicDriver();
MyGraphicDriver->Structure (MyCStructure);
#ifdef TRACE

View File

@@ -41,7 +41,6 @@ uses
SequenceOfInteger from TColStd,
GenId from Aspect,
GraphicDevice from Aspect,
TypeOfHighlightMethod from Aspect,
TypeOfUpdate from Aspect,
@@ -52,7 +51,8 @@ uses
AspectText3d from Graphic3d,
Structure from Graphic3d,
MapOfStructure from Graphic3d,
SequenceOfStructure from Graphic3d
SequenceOfStructure from Graphic3d,
GraphicDriver from Graphic3d
raises
@@ -60,7 +60,7 @@ raises
is
Initialize ( aDevice : GraphicDevice from Aspect )
Initialize ( theDriver: GraphicDriver from Graphic3d )
---Level: Public
---Purpose: Initialises the ViewManager.
-- Currently creating of more than 100 viewer instances
@@ -411,11 +411,12 @@ is
---Purpose: Transforms the structure <AStructure>.
---Category: Private methods
GraphicDevice ( me )
returns GraphicDevice from Aspect;
GraphicDriver ( me )
returns GraphicDriver from Graphic3d;
---Level: Internal
---Purpose: Returns the graphic device of <me>.
---Purpose: Returns the graphic driver of <me>.
---Category: Private methods
---C++: return const &
Invisible ( me : mutable;
AStructure : Structure from Graphic3d )
@@ -530,7 +531,7 @@ fields
MyStructGenId : GenId from Aspect is protected;
MyGraphicDevice : GraphicDevice from Aspect is protected;
MyGraphicDriver : GraphicDriver from Graphic3d is protected;
friends

View File

@@ -77,7 +77,7 @@ static Standard_Integer StructureManager_CurrentId = 0;
//-Constructors
Graphic3d_StructureManager::Graphic3d_StructureManager (const Handle(Aspect_GraphicDevice)& aDevice):
Graphic3d_StructureManager::Graphic3d_StructureManager (const Handle(Graphic3d_GraphicDriver)& theDriver):
MyDisplayedStructure (),
MyHighlightedStructure (),
MyVisibleStructure (),
@@ -130,7 +130,7 @@ Standard_Integer Limit = Graphic3d_StructureManager::Limit ();
MyAspectFillArea3d = new Graphic3d_AspectFillArea3d ();
MyUpdateMode = Aspect_TOU_WAIT;
MyGraphicDevice = aDevice;
MyGraphicDriver = theDriver;
}
@@ -392,8 +392,8 @@ Standard_Integer Graphic3d_StructureManager::CurrentId () {
}
Handle(Aspect_GraphicDevice) Graphic3d_StructureManager::GraphicDevice () const {
const Handle(Graphic3d_GraphicDriver)& Graphic3d_StructureManager::GraphicDriver () const {
return (MyGraphicDevice);
return (MyGraphicDriver);
}

View File

@@ -19,7 +19,6 @@
// and conditions governing the rights and limitations under the License.
#include <Graphic3d_TextureRoot.ixx>
#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Image_AlienPixMap.hxx>

View File

@@ -1,82 +0,0 @@
-- Created on: 1996-02-15
-- Created by: PLOTNIKOV Eugeny
-- Copyright (c) 1996-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class WNTGraphicDevice from Graphic3d inherits GraphicDevice from WNT
---Purpose: This class initializes a Windows NT Graphic Device.
uses
Color from Quantity,
ColorRef from WNT,
Long from WNT,
SharedLibrary from OSD,
GraphicDriver from Aspect,
GraphicDriver from Graphic3d
raises
GraphicDeviceDefinitionError from Aspect
is
Create
returns mutable WNTGraphicDevice from Graphic3d
---Purpose: Creates a class instance and provide initialization
-- of the graphic library.
-- Warning: Raises if something wrong.
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 )
is redefined static;
---Purpose: Destroys all resources attached to the graphic device.
---C++: alias~
GraphicDriver ( me )
returns GraphicDriver from Aspect
is redefined static;
---Level: Public
---Purpose: Returns the GraphicDriver.
SetGraphicDriver ( me : mutable )
is private;
---Level: Internal
---Purpose: Sets the GraphicDriver.
SetGraphicDriver ( me : mutable;
graphicLib : CString from Standard )
is private;
---Level: Internal
---Purpose: Sets the GraphicDriver defined by "graphicLib".
fields
MyGraphicDriver : GraphicDriver from Graphic3d;
MySharedLibrary : SharedLibrary from OSD;
end WNTGraphicDevice;

View File

@@ -1,123 +0,0 @@
// Copyright (c) 1996-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#if (defined(_WIN32) || defined(__WIN32__))
#include <stdlib.h>
#include <Graphic3d_WNTGraphicDevice.ixx>
#include <InterfaceGraphic_wntio.hxx>
#include <OSD_Environment.hxx>
#include <TCollection_AsciiString.hxx>
// =======================================================================
// function : Graphic3d_WNTGraphicDevice
// purpose :
// =======================================================================
Graphic3d_WNTGraphicDevice::Graphic3d_WNTGraphicDevice()
: WNT_GraphicDevice (Standard_True)
{
SetGraphicDriver();
if (!MyGraphicDriver->Begin (""))
Aspect_GraphicDeviceDefinitionError::Raise ("Cannot connect to graphic library");
}
// =======================================================================
// 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");
}
// =======================================================================
// function : Destroy
// purpose :
// =======================================================================
void Graphic3d_WNTGraphicDevice::Destroy()
{
MyGraphicDriver->End();
}
// =======================================================================
// function : GraphicDriver
// purpose :
// =======================================================================
Handle(Aspect_GraphicDriver) Graphic3d_WNTGraphicDevice::GraphicDriver() const
{
return MyGraphicDriver;
}
// =======================================================================
// function : SetGraphicDriver
// purpose :
// =======================================================================
void Graphic3d_WNTGraphicDevice::SetGraphicDriver()
{
Standard_CString aLibPath = getenv ("CSF_GraphicShr");
if (aLibPath == NULL || strlen (aLibPath) == 0)
aLibPath = "TKOpenGl.dll";
SetGraphicDriver (aLibPath);
}
// =======================================================================
// 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