From 73192b3746e6d94a4a7f54aeaa996064928c0bdf Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 30 Apr 2014 13:38:50 +0400 Subject: [PATCH] 0024847: CLang warnings -Wdeprecated-writable-strings in OpenGl_Display Remove obsolete properties, remove OpenGl_Display class. Fix compilation on Linux --- src/InterfaceGraphic/FILES | 1 - .../InterfaceGraphic_Palette.c | 145 ---------------- src/InterfaceGraphic/InterfaceGraphic_WNT.hxx | 9 - src/OpenGl/FILES | 8 +- src/OpenGl/Handle_OpenGl_Display.hxx | 29 ---- src/OpenGl/OpenGl_Display.cxx | 159 ------------------ src/OpenGl/OpenGl_Display.hxx | 105 ------------ src/OpenGl/OpenGl_GraphicDriver.cxx | 79 +++++++++ src/OpenGl/OpenGl_GraphicDriver.hxx | 2 - src/OpenGl/OpenGl_GraphicDriver_1.cxx | 54 ------ src/OpenGl/OpenGl_GraphicDriver_2.cxx | 45 ----- src/OpenGl/OpenGl_GraphicDriver_7.cxx | 7 +- src/OpenGl/OpenGl_GraphicDriver_Layer.cxx | 28 ++- ...isplay_2.cxx => OpenGl_LineAttributes.cxx} | 155 +++++++++++------ src/OpenGl/OpenGl_LineAttributes.hxx | 55 ++++++ src/OpenGl/OpenGl_View.cxx | 1 - src/OpenGl/OpenGl_View.hxx | 13 +- src/OpenGl/OpenGl_View_2.cxx | 11 +- src/OpenGl/OpenGl_Window.cxx | 109 ++---------- src/OpenGl/OpenGl_Window.hxx | 27 +-- src/OpenGl/OpenGl_Window_1.mm | 21 +-- src/OpenGl/OpenGl_Workspace.cxx | 42 +++-- src/OpenGl/OpenGl_Workspace.hxx | 10 +- src/OpenGl/OpenGl_Workspace_2.cxx | 2 - src/OpenGl/OpenGl_Workspace_5.cxx | 6 +- 25 files changed, 330 insertions(+), 793 deletions(-) delete mode 100644 src/InterfaceGraphic/InterfaceGraphic_Palette.c delete mode 100644 src/OpenGl/Handle_OpenGl_Display.hxx delete mode 100644 src/OpenGl/OpenGl_Display.cxx delete mode 100644 src/OpenGl/OpenGl_Display.hxx delete mode 100644 src/OpenGl/OpenGl_GraphicDriver_1.cxx delete mode 100644 src/OpenGl/OpenGl_GraphicDriver_2.cxx rename src/OpenGl/{OpenGl_Display_2.cxx => OpenGl_LineAttributes.cxx} (69%) create mode 100644 src/OpenGl/OpenGl_LineAttributes.hxx diff --git a/src/InterfaceGraphic/FILES b/src/InterfaceGraphic/FILES index d3989999fd..ea3fe2cad5 100755 --- a/src/InterfaceGraphic/FILES +++ b/src/InterfaceGraphic/FILES @@ -8,6 +8,5 @@ InterfaceGraphic_Cocoa.hxx InterfaceGraphic_XWD.hxx InterfaceGraphic_wntio.hxx InterfaceGraphic_cPrintf.cxx -InterfaceGraphic_Palette.c InterfaceGraphic_telem.hxx InterfaceGraphic_tgl_all.hxx diff --git a/src/InterfaceGraphic/InterfaceGraphic_Palette.c b/src/InterfaceGraphic/InterfaceGraphic_Palette.c deleted file mode 100644 index 380b19b172..0000000000 --- a/src/InterfaceGraphic/InterfaceGraphic_Palette.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - Copyright (c) 1991-1999 Matra Datavision - Copyright (c) 1999-2014 OPEN CASCADE SAS - - This file is part of Open CASCADE Technology software library. - - This library is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License version 2.1 as published - by the Free Software Foundation, with special exception defined in the file - OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT - distribution for complete text of the license and disclaimer of any warranty. - - Alternatively, this file may be used under the terms of Open CASCADE - commercial license or contractual agreement. -*/ - -#ifndef WNT - -int _a_horreur_du_vide_a_la_compilation; - -#else - -#define STRICT -#include - -#pragma comment( lib, "user32.lib" ) -#pragma comment( lib, "gdi32.lib" ) - -#if WINVER >= 0x0400 -# define NB_STATIC_COLORS ( COLOR_INFOBK - COLOR_SCROLLBAR + 1 ) -#else -# define NB_STATIC_COLORS ( COLOR_BTNHIGHLIGHT - COLOR_SCROLLBAR + 1 ) -#endif /* WINVER . . . */ - -#define BLACK RGB( 0, 0, 0 ) -#define WHITE RGB( 255, 255, 255 ) - -static int s_sysPalIdx[ NB_STATIC_COLORS ] = { - - COLOR_SCROLLBAR, - COLOR_BACKGROUND, - COLOR_ACTIVECAPTION, - COLOR_INACTIVECAPTION, - COLOR_MENU, - COLOR_WINDOW, - COLOR_WINDOWFRAME, - COLOR_MENUTEXT, - COLOR_WINDOWTEXT, - COLOR_CAPTIONTEXT, - COLOR_ACTIVEBORDER, - COLOR_INACTIVEBORDER, - COLOR_APPWORKSPACE, - COLOR_HIGHLIGHT, - COLOR_HIGHLIGHTTEXT, - COLOR_BTNFACE, - COLOR_BTNSHADOW, - COLOR_GRAYTEXT, - COLOR_BTNTEXT, - COLOR_INACTIVECAPTIONTEXT, - COLOR_BTNHIGHLIGHT -#if WINVER >= 0x0400 - ,COLOR_3DDKSHADOW, - COLOR_3DLIGHT, - COLOR_INFOTEXT, - COLOR_INFOBK -#endif /* WINVER . . . */ -}; - -static COLORREF s_sysPalBW[ NB_STATIC_COLORS ] = { - - WHITE, /* COLOR_SCROLLBAR */ - BLACK, /* COLOR_BACKGROUND */ - BLACK, /* COLOR_ACTIVECAPTION */ - WHITE, /* COLOR_INACTIVECAPTION */ - WHITE, /* COLOR_MENU */ - WHITE, /* COLOR_WINDOW */ - BLACK, /* COLOR_WINDOWFRAME */ - BLACK, /* COLOR_MENUTEXT */ - BLACK, /* COLOR_WINDOWTEXT */ - WHITE, /* COLOR_CAPTIONTEXT */ - WHITE, /* COLOR_ACTIVEBORDER */ - WHITE, /* COLOR_INACTIVEBORDER */ - WHITE, /* COLOR_APPWORKSPACE */ - BLACK, /* COLOR_HIGHLIGHT */ - WHITE, /* COLOR_HIGHLIGHTTEXT */ - WHITE, /* COLOR_BTNFACE */ - BLACK, /* COLOR_BTNSHADOW */ - BLACK, /* COLOR_GRAYTEXT */ - BLACK, /* COLOR_BTNTEXT */ - BLACK, /* COLOR_INACTIVECAPTIONTEXT */ - BLACK /* COLOR_BTNHIGHLIGHT */ -#if WINVER >= 0x0400 - ,BLACK, /* BLACKCOLOR_3DDKSHADOW */ - BLACK, /* COLOR_3DLIGHT */ - BLACK, /* COLOR_INFOTEXT */ - BLACK /* COLOR_INFOBK */ -#endif /* WINVER . . . */ -}; - -static BOOL s_sysUse; -static COLORREF s_sysPal[ NB_STATIC_COLORS ]; - -__declspec( dllexport ) long InterfaceGraphic_RealizePalette ( HDC hdc, HPALETTE hPal, BOOL fBkg, BOOL fUseStatic ) { - - int i; - long retVal = 0; - - if ( fUseStatic ) { - - if ( !s_sysUse ) - - for ( i = 0; i < NB_STATIC_COLORS; ++i ) s_sysPal[ i ] = GetSysColor ( s_sysPalIdx[ i ] ); - - SetSystemPaletteUse ( hdc, fBkg ? SYSPAL_STATIC : SYSPAL_NOSTATIC ); - - if ( UnrealizeObject ( hPal ) && SelectPalette ( hdc, hPal, fBkg ) ) retVal = RealizePalette ( hdc ); - - if ( fBkg ) { - - SetSysColors ( NB_STATIC_COLORS, s_sysPalIdx, s_sysPal ); - s_sysUse = FALSE; - - } else { - - SetSysColors ( NB_STATIC_COLORS, s_sysPalIdx, s_sysPalBW ); - s_sysUse = TRUE; - - } // end else - -#pragma warning(push) -#pragma warning(disable:4306) /* level 4 warning on cast of int to HWND in HWND_BROADCAST macro */ - PostMessage ( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 ); -#pragma warning(pop) - - } else { - - SelectPalette ( hdc, hPal, FALSE ); - retVal = RealizePalette ( hdc ); - - } // end else - - return retVal; -} // end RealizePaletteNow - -#endif /* WNT */ diff --git a/src/InterfaceGraphic/InterfaceGraphic_WNT.hxx b/src/InterfaceGraphic/InterfaceGraphic_WNT.hxx index d0a544f4b4..4a879479d5 100644 --- a/src/InterfaceGraphic/InterfaceGraphic_WNT.hxx +++ b/src/InterfaceGraphic/InterfaceGraphic_WNT.hxx @@ -72,15 +72,6 @@ typedef struct font_data { } FONT_DATA; -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - __declspec( dllimport ) long InterfaceGraphic_RealizePalette ( HDC, HPALETTE, BOOL, BOOL ); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ #endif //WNT #endif /* __INTERFACE_GRAPHIC_WNT_HXX */ diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES index 9b31318456..2a8a56d1e2 100755 --- a/src/OpenGl/FILES +++ b/src/OpenGl/FILES @@ -3,8 +3,6 @@ OpenGl_CMPLRS.edl Handle_OpenGl_GraphicDriver.hxx OpenGl_GraphicDriver.hxx OpenGl_GraphicDriver.cxx -OpenGl_GraphicDriver_1.cxx -OpenGl_GraphicDriver_2.cxx OpenGl_GraphicDriver_4.cxx OpenGl_GraphicDriver_7.cxx OpenGl_GraphicDriver_713.cxx @@ -54,10 +52,8 @@ OpenGl_NamedStatus.hxx OpenGl_TextParam.hxx OpenGl_PrinterContext.hxx OpenGl_PrinterContext.cxx -Handle_OpenGl_Display.hxx -OpenGl_Display.hxx -OpenGl_Display.cxx -OpenGl_Display_2.cxx +OpenGl_LineAttributes.hxx +OpenGl_LineAttributes.cxx Handle_OpenGl_Window.hxx OpenGl_Window.hxx OpenGl_Window.cxx diff --git a/src/OpenGl/Handle_OpenGl_Display.hxx b/src/OpenGl/Handle_OpenGl_Display.hxx deleted file mode 100644 index 971d91de65..0000000000 --- a/src/OpenGl/Handle_OpenGl_Display.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// Created on: 2011-09-20 -// Created by: Sergey ZERCHANINOV -// Copyright (c) 2011-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Handle_OpenGl_Display_Header -#define _Handle_OpenGl_Display_Header - -#include -#include - -class OpenGl_Display; - -// Handle definition -// -DEFINE_STANDARD_HANDLE(OpenGl_Display,MMgt_TShared) - - -#endif //_Handle_OpenGl_Display_Header diff --git a/src/OpenGl/OpenGl_Display.cxx b/src/OpenGl/OpenGl_Display.cxx deleted file mode 100644 index ba3c8a0023..0000000000 --- a/src/OpenGl/OpenGl_Display.cxx +++ /dev/null @@ -1,159 +0,0 @@ -// Created on: 2011-09-20 -// Created by: Sergey ZERCHANINOV -// Copyright (c) 2011-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -#include -#include - -#include -#include -#include - -#if (!defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))) - #include // XOpenDisplay() -#endif - -IMPLEMENT_STANDARD_HANDLE(OpenGl_Display,MMgt_TShared) -IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Display,MMgt_TShared) - -namespace -{ - #if (defined(_WIN32) || defined(__WIN32__)) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX)) - static char* TheDummyDisplay = "DISPLAY"; - #endif - - static const OpenGl_Facilities myDefaultFacilities = { 1, 1, 1, 1, OpenGLMaxLights, 10000 }; -}; - -/*----------------------------------------------------------------------*/ -#if (defined(_WIN32) || defined(__WIN32__)) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX)) -OpenGl_Display::OpenGl_Display (const Handle(Aspect_DisplayConnection)& ) -#else -OpenGl_Display::OpenGl_Display (const Handle(Aspect_DisplayConnection)& theDisplayConnection) -#endif -: myDisplay(NULL), - myFacilities(myDefaultFacilities), - myDBuffer(Standard_True), - myDither(Standard_True), - myBackDither(Standard_False), - mySymPerspective(Standard_False), - myOffsetFactor(1.F), - myOffsetUnits(0.F), - myAntiAliasingMode(3), - myLinestyleBase(0), - myPatternBase(0) -{ -#if (defined(_WIN32) || defined(__WIN32__)) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX)) - myDisplay = TheDummyDisplay; -#else - myDisplay = theDisplayConnection->GetDisplay(); -#endif - - Init(); -} - -/*----------------------------------------------------------------------*/ - -OpenGl_Display::~OpenGl_Display () -{ - ReleaseAttributes (NULL); - myDisplay = NULL; -} - -void OpenGl_Display::ReleaseAttributes (const OpenGl_Context* theGlCtx) -{ - // Delete line styles - if (myLinestyleBase != 0) - { - if (theGlCtx->IsValid()) - { - glDeleteLists ((GLuint )myLinestyleBase, 5); - } - myLinestyleBase = 0; - } - // Delete surface patterns - if (myPatternBase != 0) - { - if (theGlCtx->IsValid()) - { - glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START); - } - myPatternBase = 0; - } -} - -/*----------------------------------------------------------------------*/ - -void OpenGl_Display::Init() -{ - if (myDisplay != NULL) - { - #if (!defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))) - XSynchronize ((Display* )myDisplay, (getenv("CALL_SYNCHRO_X") != NULL) ? 1 : 0); - - if (getenv("CSF_GraphicSync") != NULL) - XSynchronize ((Display* )myDisplay, 1); - - // does the server know about OpenGL & GLX? - int aDummy; - if (!XQueryExtension ((Display* )myDisplay, "GLX", &aDummy, &aDummy, &aDummy)) - { - #ifdef DEBUG - std::cerr << "This system doesn't appear to support OpenGL\n"; - #endif - } - #endif - } - else - { - TCollection_AsciiString msg("OpenGl_Display::Init"); - #if (!defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))) - msg += " : Cannot connect to X server "; - msg += XDisplayName ((char*) NULL); - #endif - Aspect_GraphicDeviceDefinitionError::Raise(msg.ToCString()); - } - - if (getenv("CALL_OPENGL_NO_DBF") != NULL) - myDBuffer = Standard_False; - - if (getenv("CALL_OPENGL_NO_DITHER") != NULL) - myDither = Standard_False; - - if (getenv("CALL_OPENGL_NO_BACKDITHER") != NULL) - myBackDither = Standard_False; - - /* OCC18942: Test if symmetric perspective projection should be turned on */ - if (getenv("CSF_SYM_PERSPECTIVE") != NULL) - mySymPerspective = Standard_True; - - const char* pvalue = getenv("CALL_OPENGL_POLYGON_OFFSET"); - if (pvalue) - { - float v1, v2; - const int n = sscanf(pvalue, "%f %f", &v1, &v2); - if (n > 0) myOffsetFactor = v1; - if (n > 1) myOffsetUnits = v2; - } - - pvalue = getenv("CALL_OPENGL_ANTIALIASING_MODE"); - if (pvalue) - { - int v; - if ( sscanf(pvalue,"%d",&v) > 0 ) myAntiAliasingMode = v; - } -} diff --git a/src/OpenGl/OpenGl_Display.hxx b/src/OpenGl/OpenGl_Display.hxx deleted file mode 100644 index 0590168288..0000000000 --- a/src/OpenGl/OpenGl_Display.hxx +++ /dev/null @@ -1,105 +0,0 @@ -// Created on: 2011-09-20 -// Created by: Sergey ZERCHANINOV -// Copyright (c) 2011-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _OpenGl_Display_Header -#define _OpenGl_Display_Header - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -struct OpenGl_Facilities -{ - int AntiAliasing; - int DepthCueing; - int DoubleBuffer; - int ZBuffer; - int MaxLights; - int MaxViews; -}; - -class OpenGl_Context; - -class OpenGl_Display : public MMgt_TShared -{ -public: - - OpenGl_Display (const Handle(Aspect_DisplayConnection)& theDisplayConnection); - virtual ~OpenGl_Display (); - - Aspect_Display GetDisplay () const { return myDisplay; } - - const OpenGl_Facilities & Facilities () const { return myFacilities; } - - Standard_Boolean DBuffer () const { return myDBuffer; } - Standard_Boolean Dither () const { return myDither; } - Standard_Boolean BackDither () const { return myBackDither; } - Standard_Boolean SymPerspective() const { return mySymPerspective; } - Standard_Boolean PolygonOffset (Standard_ShortReal &AFactor, Standard_ShortReal &AUnits) const - { - AFactor = myOffsetFactor; - AUnits = myOffsetUnits; - return Standard_True; - } - Standard_Integer AntiAliasingMode () const { return myAntiAliasingMode; } - - // System attributes - - void InitAttributes(); - void ReleaseAttributes (const OpenGl_Context* theGlCtx); - - void SetTypeOfLine (const Aspect_TypeOfLine AType) const; - - void SetTypeOfHatch (const int AType) const; - - friend class OpenGl_Window; - - // Type definition - // - DEFINE_STANDARD_RTTI(OpenGl_Display) - - protected: - - void Init (); - - Aspect_Display myDisplay; - OpenGl_Facilities myFacilities; - - Standard_Boolean myDBuffer; - Standard_Boolean myDither; - Standard_Boolean myBackDither; - Standard_Boolean mySymPerspective; - Standard_ShortReal myOffsetFactor; - Standard_ShortReal myOffsetUnits; - Standard_Integer myAntiAliasingMode; - - unsigned int myLinestyleBase; - unsigned int myPatternBase; - - public: - DEFINE_STANDARD_ALLOC -}; - -#endif // _OpenGl_Display_Header diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index 879e61f0aa..699065636e 100755 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -29,8 +29,13 @@ #include #include +#include #include +#if (!defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))) + #include // XOpenDisplay() +#endif + IMPLEMENT_STANDARD_HANDLE(OpenGl_GraphicDriver,Graphic3d_GraphicDriver) IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriver,Graphic3d_GraphicDriver) @@ -91,6 +96,80 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Standard_CString theShrName) // } +// ======================================================================= +// function : Begin +// purpose : +// ======================================================================= +Standard_Boolean OpenGl_GraphicDriver::Begin (const Handle(Aspect_DisplayConnection)& theDisplayConnection) +{ + myDisplayConnection = theDisplayConnection; + if (myDisplayConnection.IsNull()) + { + #if (!defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))) + //Aspect_GraphicDeviceDefinitionError::Raise ("OpenGl_GraphicDriver: cannot connect to X server!"); + return Standard_False; + #else + return Standard_True; + #endif + } + +#if (!defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))) + Display* aDisplay = myDisplayConnection->GetDisplay(); + Bool toSync = ::getenv ("CSF_GraphicSync") != NULL + || ::getenv ("CALL_SYNCHRO_X") != NULL; + XSynchronize (aDisplay, toSync); + + // does the server know about OpenGL & GLX? + int aDummy; + if (!XQueryExtension (aDisplay, "GLX", &aDummy, &aDummy, &aDummy)) + { + #ifdef DEBUG + std::cerr << "This system doesn't appear to support OpenGL\n"; + #endif + } +#endif + return Standard_True; +} + +// ======================================================================= +// function : End +// purpose : +// ======================================================================= +void OpenGl_GraphicDriver::End() +{ + // deprecated method + ///myDisplayConnection.Nullify(); +} + +// ======================================================================= +// function : InquireLightLimit +// purpose : +// ======================================================================= +Standard_Integer OpenGl_GraphicDriver::InquireLightLimit() +{ + return OpenGLMaxLights; +} + +// ======================================================================= +// function : InquireViewLimit +// purpose : +// ======================================================================= +Standard_Integer OpenGl_GraphicDriver::InquireViewLimit() +{ + return 10000; +} + +// ======================================================================= +// function : InquirePlaneLimit +// purpose : +// ======================================================================= +Standard_Integer OpenGl_GraphicDriver::InquirePlaneLimit() +{ + // NOTE the 2 first planes are reserved for ZClipping + const Handle(OpenGl_Context)& aCtx = GetSharedContext(); + return aCtx.IsNull() ? 0 : Max (aCtx->MaxClipPlanes() - 2, 0); +} + // ======================================================================= // function : UserDrawCallback // purpose : diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index e8e012f8a3..a82d358602 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -322,7 +321,6 @@ public: private: - Handle(OpenGl_Display) myGlDisplay; Handle(OpenGl_Caps) myCaps; NCollection_DataMap myMapOfView; NCollection_DataMap myMapOfWS; diff --git a/src/OpenGl/OpenGl_GraphicDriver_1.cxx b/src/OpenGl/OpenGl_GraphicDriver_1.cxx deleted file mode 100644 index 49f823daa8..0000000000 --- a/src/OpenGl/OpenGl_GraphicDriver_1.cxx +++ /dev/null @@ -1,54 +0,0 @@ -// Created on: 2011-10-20 -// Created by: Sergey ZERCHANINOV -// Copyright (c) 2011-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -#include - -#include -#include - -//======================================================================= -//function : Begin -//purpose : -//======================================================================= - -Standard_Boolean OpenGl_GraphicDriver::Begin (const Handle(Aspect_DisplayConnection)& theDisplayConnection) -{ - myDisplayConnection = theDisplayConnection; - try - { - myGlDisplay = new OpenGl_Display (myDisplayConnection); - return Standard_True; - } - catch (Standard_Failure) - { - } - return Standard_False; -} - -//======================================================================= -//function : End -//purpose : -//======================================================================= - -void OpenGl_GraphicDriver::End () -{ - // This is unsafe to realease global object here - // because noone guaranteed that only one instance of OpenGl_GraphicDriver is used! - // So we disable this destructor here until openglDisplay not moved to OpenGl_GraphicDriver class definition. - ///openglDisplay.Nullify(); -} diff --git a/src/OpenGl/OpenGl_GraphicDriver_2.cxx b/src/OpenGl/OpenGl_GraphicDriver_2.cxx deleted file mode 100644 index cac6e68b56..0000000000 --- a/src/OpenGl/OpenGl_GraphicDriver_2.cxx +++ /dev/null @@ -1,45 +0,0 @@ -// Created on: 2011-10-20 -// Created by: Sergey ZERCHANINOV -// Copyright (c) 2011-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include - -#include -#include - -Standard_Integer OpenGl_GraphicDriver::InquireLightLimit () -{ - return (myGlDisplay.IsNull() ? 0 : myGlDisplay->Facilities().MaxLights); -} - -Standard_Integer OpenGl_GraphicDriver::InquireViewLimit () -{ - return (myGlDisplay.IsNull() ? 0 : myGlDisplay->Facilities().MaxViews); -} - -Standard_Integer OpenGl_GraphicDriver::InquirePlaneLimit () -{ - GLint aMaxPlanes = 0; - if (GET_GL_CONTEXT()) - { - glGetIntegerv (GL_MAX_CLIP_PLANES, &aMaxPlanes); - aMaxPlanes -= 2; // NOTE the 2 first planes are reserved for ZClipping - if (aMaxPlanes < 0) - aMaxPlanes = 0; - } - return aMaxPlanes; -} - diff --git a/src/OpenGl/OpenGl_GraphicDriver_7.cxx b/src/OpenGl/OpenGl_GraphicDriver_7.cxx index 654f9ee41a..a7087e3094 100644 --- a/src/OpenGl/OpenGl_GraphicDriver_7.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_7.cxx @@ -19,7 +19,6 @@ #include #include -#include #include /*----------------------------------------------------------------------*/ @@ -402,7 +401,6 @@ void OpenGl_GraphicDriver::RemoveView (const Graphic3d_CView& theCView) aStruct->ReleaseGlResources (aCtx); } myTempText->Release (aCtx); - myGlDisplay->ReleaseAttributes (aCtx.operator->()); myDeviceLostFlag = !myMapOfStructure.IsEmpty(); } @@ -463,15 +461,14 @@ void OpenGl_GraphicDriver::Transparency (const Graphic3d_CView& ACView, const St Standard_Boolean OpenGl_GraphicDriver::View (Graphic3d_CView& theCView) { - if (myGlDisplay.IsNull() - || myMapOfView.IsBound (theCView.ViewId) + if (myMapOfView.IsBound (theCView.ViewId) || myMapOfWS .IsBound (theCView.WsId)) { return Standard_False; } Handle(OpenGl_Context) aShareCtx = GetSharedContext(); - Handle(OpenGl_Workspace) aWS = new OpenGl_Workspace (myGlDisplay, theCView.DefWindow, theCView.GContext, myCaps, aShareCtx); + Handle(OpenGl_Workspace) aWS = new OpenGl_Workspace (myDisplayConnection, theCView.DefWindow, theCView.GContext, myCaps, aShareCtx); Handle(OpenGl_View) aView = new OpenGl_View (theCView.Context, &myStateCounter); myMapOfWS .Bind (theCView.WsId, aWS); myMapOfView.Bind (theCView.ViewId, aView); diff --git a/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx b/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx index 4d5eb69066..999b8778c7 100644 --- a/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx @@ -19,10 +19,10 @@ #include -#include #include #include #include +#include /*----------------------------------------------------------------------*/ @@ -223,19 +223,29 @@ void OpenGl_GraphicDriver::UnsetTransparency () glDisable (GL_BLEND); } -void OpenGl_GraphicDriver::SetLineAttributes (const Standard_Integer Type, const Standard_ShortReal Width) +void OpenGl_GraphicDriver::SetLineAttributes (const Standard_Integer theType, + const Standard_ShortReal theWidth) { - if (!TheLayerProp.ListId || myGlDisplay.IsNull()) return; + const Handle(OpenGl_Context)& aCtx = GetSharedContext(); + if (!TheLayerProp.ListId + || aCtx.IsNull()) + { + return; + } - if (TheLayerProp.LineType != Type) + if (TheLayerProp.LineType != theType) { - TheLayerProp.LineType = Type; - myGlDisplay->SetTypeOfLine((Aspect_TypeOfLine) Type); + Handle(OpenGl_LineAttributes) aLineAttribs; + if (aCtx->GetResource ("OpenGl_LineAttributes", aLineAttribs)) + { + TheLayerProp.LineType = theType; + aLineAttribs->SetTypeOfLine ((Aspect_TypeOfLine )theType); + } } - if (TheLayerProp.LineWidth != Width) + if (TheLayerProp.LineWidth != theWidth) { - TheLayerProp.LineWidth = Width; - glLineWidth ((GLfloat) Width); + TheLayerProp.LineWidth = theWidth; + glLineWidth ((GLfloat )theWidth); } } diff --git a/src/OpenGl/OpenGl_Display_2.cxx b/src/OpenGl/OpenGl_LineAttributes.cxx similarity index 69% rename from src/OpenGl/OpenGl_Display_2.cxx rename to src/OpenGl/OpenGl_LineAttributes.cxx index c820fc8d46..58a745e79b 100644 --- a/src/OpenGl/OpenGl_Display_2.cxx +++ b/src/OpenGl/OpenGl_LineAttributes.cxx @@ -15,7 +15,8 @@ #include -#include +#include +#include #ifdef HAVE_CONFIG_H #include @@ -25,10 +26,10 @@ #include #endif -#define DOT_LS 0xCCCC -#define DASH_DOT_LS 0xFF18 -#define DASH_LS 0xFFC0 -#define DASH_DDOT_LS 0xFF24 +#define DOT_LS 0xCCCC +#define DASH_DOT_LS 0xFF18 +#define DASH_LS 0xFFC0 +#define DASH_DDOT_LS 0xFF24 static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = { @@ -489,83 +490,131 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = } }; -/*----------------------------------------------------------------------*/ +IMPLEMENT_STANDARD_HANDLE (OpenGl_LineAttributes, OpenGl_Resource) +IMPLEMENT_STANDARD_RTTIEXT(OpenGl_LineAttributes, OpenGl_Resource) -//TsmInitAttributes -void OpenGl_Display::InitAttributes () +// ======================================================================= +// function : OpenGl_LineAttributes +// purpose : +// ======================================================================= +OpenGl_LineAttributes::OpenGl_LineAttributes() +: myLinestyleBase(0), + myPatternBase(0) { - // Return if already initialized - if (myLinestyleBase) return; + // +} + +// ======================================================================= +// function : ~OpenGl_LineAttributes +// purpose : +// ======================================================================= +OpenGl_LineAttributes::~OpenGl_LineAttributes() +{ + Release (NULL); +} + +// ======================================================================= +// function : Release +// purpose : +// ======================================================================= +void OpenGl_LineAttributes::Release (const OpenGl_Context* theGlCtx) +{ + // Delete line styles + if (myLinestyleBase != 0) + { + if (theGlCtx->IsValid()) + { + glDeleteLists ((GLuint )myLinestyleBase, 5); + } + myLinestyleBase = 0; + } + // Delete surface patterns + if (myPatternBase != 0) + { + if (theGlCtx->IsValid()) + { + glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START); + } + myPatternBase = 0; + } +} - myLinestyleBase = glGenLists(5); +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx) +{ + // Return if already initialized + if (myLinestyleBase != 0) + { + return; + } - /* Line */ + myLinestyleBase = theGlCtx->core11->glGenLists (5); - glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DASH, GL_COMPILE ); - glLineStipple(1, DASH_LS ); + // Line + glNewList ((GLuint )myLinestyleBase + (GLuint )Aspect_TOL_DASH, GL_COMPILE); + glLineStipple (1, DASH_LS); glEndList(); - glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DOT, GL_COMPILE ); - glLineStipple(1, DOT_LS ); + glNewList ((GLuint )myLinestyleBase + (GLuint )Aspect_TOL_DOT, GL_COMPILE); + glLineStipple (1, DOT_LS); glEndList(); - glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DOTDASH, GL_COMPILE ); - glLineStipple(1, DASH_DOT_LS ); + glNewList ((GLuint )myLinestyleBase + (GLuint )Aspect_TOL_DOTDASH, GL_COMPILE); + glLineStipple (1, DASH_DOT_LS); glEndList(); - glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_USERDEFINED, GL_COMPILE ); - glLineStipple(1, DASH_DDOT_LS ); + glNewList ((GLuint )myLinestyleBase + (GLuint )Aspect_TOL_USERDEFINED, GL_COMPILE); + glLineStipple (1, DASH_DDOT_LS); glEndList(); - /* FSXXX - * GL_POLYGON_STIPPLE - * need 32x32 stipple patterns - */ - const int nbi = sizeof(myInteriors)/(32*sizeof(unsigned int)); + // GL_POLYGON_STIPPLE need 32x32 stipple patterns + const int nbi = sizeof(myInteriors) / (32 * sizeof(unsigned int)); myPatternBase = glGenLists(TEL_HS_USER_DEF_START); - int i; - for( i = 1; i < TEL_HS_USER_DEF_START; i++ ) + for (int i = 1; i < TEL_HS_USER_DEF_START; i++) { - glNewList( (GLuint)myPatternBase + i, GL_COMPILE ); - glPolygonStipple((const GLubyte *) (myInteriors[i + +#include +#include +#include + +class OpenGl_Context; +class Handle(OpenGl_Context); + +class OpenGl_LineAttributes : public OpenGl_Resource +{ +public: + + OpenGl_LineAttributes(); + virtual ~OpenGl_LineAttributes(); + + void Init (const Handle(OpenGl_Context)& theGlCtx); + virtual void Release (const OpenGl_Context* theGlCtx); + + void SetTypeOfLine (const Aspect_TypeOfLine theType) const; + + void SetTypeOfHatch (const int theType) const; + +protected: + + unsigned int myLinestyleBase; + unsigned int myPatternBase; + +public: + + DEFINE_STANDARD_RTTI(OpenGl_LineAttributes) + +}; + +DEFINE_STANDARD_HANDLE(OpenGl_LineAttributes, OpenGl_Resource) + +#endif // _OpenGl_LineAttributes_Header diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index d3c006bf33..100c0341a0 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -16,7 +16,6 @@ #include #include -#include #include #include #include diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 6eeaee4bcb..b1cbe18912 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -39,10 +39,10 @@ #include #include +#include #include #include -#include #include #include #include @@ -223,12 +223,13 @@ protected: const OpenGl_Matrix* theProjection, const OpenGl_Matrix* theOrientation); - Handle(OpenGl_Texture) myTextureEnv; - Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail - Standard_Integer myBackfacing; //WSBackfacing + Handle(OpenGl_LineAttributes) myLineAttribs; + Handle(OpenGl_Texture) myTextureEnv; + Visual3d_TypeOfSurfaceDetail mySurfaceDetail; + Standard_Integer myBackfacing; - OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture - OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient + OPENGL_BG_TEXTURE myBgTexture; + OPENGL_BG_GRADIENT myBgGradient; OPENGL_ZCLIP myZClip; diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index a7f29627c2..99b2266010 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -341,13 +340,9 @@ void OpenGl_View::DrawBackground (OpenGl_Workspace& theWorkspace) glPopAttrib(); //GL_ENABLE_BIT | GL_TEXTURE_BIT if (theWorkspace.UseZBuffer()) + { glEnable (GL_DEPTH_TEST); - - /* GL_DITHER on/off pour le trace */ - if (theWorkspace.Dither()) - glEnable (GL_DITHER); - else - glDisable (GL_DITHER); + } } } @@ -662,7 +657,7 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace) if ( (AWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) == 0 ) { - const int antiAliasingMode = AWorkspace->GetDisplay()->AntiAliasingMode(); + const int antiAliasingMode = AWorkspace->AntiAliasingMode(); if ( !myAntiAliasing ) { diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index ba9643585b..04013efd4b 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -127,28 +126,23 @@ namespace // function : OpenGl_Window // purpose : // ======================================================================= -OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, +OpenGl_Window::OpenGl_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection, const CALL_DEF_WINDOW& theCWindow, Aspect_RenderingContext theGContext, const Handle(OpenGl_Caps)& theCaps, const Handle(OpenGl_Context)& theShareCtx) -: myDisplay (theDisplay), - myGlContext (new OpenGl_Context (theCaps)), +: myGlContext (new OpenGl_Context (theCaps)), myOwnGContext (theGContext == 0), -#if defined(_WIN32) - mySysPalInUse (FALSE), -#endif myWidth ((Standard_Integer )theCWindow.dx), myHeight ((Standard_Integer )theCWindow.dy), - myBgColor (THE_DEFAULT_BG_COLOR), - myDither (theDisplay->Dither()), - myBackDither (theDisplay->BackDither()) + myBgColor (THE_DEFAULT_BG_COLOR) { myBgColor.rgb[0] = theCWindow.Background.r; myBgColor.rgb[1] = theCWindow.Background.g; myBgColor.rgb[2] = theCWindow.Background.b; #if defined(_WIN32) + (void )theDisplayConnection; HWND aWindow = (HWND )theCWindow.XWindow; HDC aWindowDC = GetDC (aWindow); HGLRC aGContext = (HGLRC )theGContext; @@ -195,23 +189,6 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, } DescribePixelFormat (aWindowDC, aPixelFrmtId, sizeof(aPixelFrmt), &aPixelFrmt); - if (aPixelFrmt.dwFlags & PFD_NEED_PALETTE) - { - WINDOW_DATA* aWndData = (WINDOW_DATA* )GetWindowLongPtr (aWindow, GWLP_USERDATA); - - mySysPalInUse = (aPixelFrmt.dwFlags & PFD_NEED_SYSTEM_PALETTE) ? TRUE : FALSE; - InterfaceGraphic_RealizePalette (aWindowDC, aWndData->hPal, FALSE, mySysPalInUse); - } - - if (myDither) - { - myDither = (aPixelFrmt.cColorBits <= 8); - } - - if (myBackDither) - { - myBackDither = (aPixelFrmt.cColorBits <= 8); - } HGLRC aSlaveCtx = !theShareCtx.IsNull() ? (HGLRC )theShareCtx->myGContext : NULL; if (aGContext == NULL) @@ -378,7 +355,8 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, #else WINDOW aParent = (WINDOW )theCWindow.XWindow; WINDOW aWindow = 0; - DISPLAY* aDisp = (DISPLAY* )myDisplay->GetDisplay(); + + Display* aDisp = theDisplayConnection->GetDisplay(); GLXContext aGContext = (GLXContext )theGContext; XWindowAttributes wattr; @@ -433,7 +411,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, aStencilSize = 0; if (!isGl || !aDepthSize || !isRGBA || !aStencilSize || - (isDoubleBuffer ? 1 : 0) != (myDisplay->DBuffer() ? 1 : 0) || + (isDoubleBuffer ? 1 : 0) != 1 || (isStereo ? 1 : 0) != (theCaps->contextStereo ? 1 : 0)) { XFree (aVis); @@ -463,8 +441,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, anAttribs[anIter++] = GLX_BLUE_SIZE; anAttribs[anIter++] = (wattr.depth <= 8) ? 0 : 1; - if (myDisplay->DBuffer()) - anAttribs[anIter++] = GLX_DOUBLEBUFFER; + anAttribs[anIter++] = GLX_DOUBLEBUFFER; // warning: this flag may be set to None, so it need to be last in anAttribs Standard_Integer aStereoFlagPos = anIter; @@ -548,31 +525,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, } } - /* - * Le BackDitherProp est utilise pour le clear du background - * Pour eviter une difference de couleurs avec la couleur choisie - * par l'application (XWindow) il faut desactiver le dithering - * au dessus de 8 plans. - * - * Pour le DitherProp: - * On cherchera a activer le Dithering que si le Visual a au moins - * 8 plans pour le GLX_RED_SIZE. Le test est plus sur car on peut - * avoir une profondeur superieure a 12 mais avoir besoin du dithering. - * (Carte Impact avec GLX_RED_SIZE a 5 par exemple) - */ - - int aValue; - glXGetConfig (aDisp, aVis, GLX_RED_SIZE, &aValue); - - if (myDither) - myDither = (aValue < 8); - - if (myBackDither) - myBackDither = (aVis->depth <= 8); - - XFree ((char* )aVis); - - myGlContext->Init ((Aspect_Drawable )aWindow, (Aspect_Display )myDisplay->GetDisplay(), (Aspect_RenderingContext )aGContext); + myGlContext->Init ((Aspect_Drawable )aWindow, (Aspect_Display )aDisp, (Aspect_RenderingContext )aGContext); #endif myGlContext->Share (theShareCtx); @@ -650,9 +603,11 @@ Standard_Boolean OpenGl_Window::Activate() // ======================================================================= void OpenGl_Window::Resize (const CALL_DEF_WINDOW& theCWindow) { - DISPLAY* aDisp = (DISPLAY* )myDisplay->GetDisplay(); +#if !defined(_WIN32) + Display* aDisp = (Display* )myGlContext->myDisplay; if (aDisp == NULL) return; +#endif // If the size is not changed - do nothing if ((myWidth == theCWindow.dx) && (myHeight == theCWindow.dy)) @@ -729,7 +684,7 @@ void OpenGl_Window::Init() unsigned int aDummyU; unsigned int aNewWidth = 0; unsigned int aNewHeight = 0; - DISPLAY* aDisp = (DISPLAY* )myDisplay->GetDisplay(); + Display* aDisp = (Display* )myGlContext->myDisplay; XGetGeometry (aDisp, myGlContext->myWindow, &aRootWin, &aDummy, &aDummy, &aNewWidth, &aNewHeight, &aDummyU, &aDummyU); myWidth = aNewWidth; myHeight = aNewHeight; @@ -744,39 +699,13 @@ void OpenGl_Window::Init() #endif // !__APPLE__ -// ======================================================================= -// function : EnablePolygonOffset -// purpose : call_subr_enable_polygon_offset -// ======================================================================= -void OpenGl_Window::EnablePolygonOffset() const -{ - Standard_ShortReal aFactor, aUnits; - myDisplay->PolygonOffset (aFactor, aUnits); - glPolygonOffset (aFactor, aUnits); - glEnable (GL_POLYGON_OFFSET_FILL); -} - -// ======================================================================= -// function : DisablePolygonOffset -// purpose : call_subr_disable_polygon_offset -// ======================================================================= -void OpenGl_Window::DisablePolygonOffset() const -{ - glDisable (GL_POLYGON_OFFSET_FILL); -} - // ======================================================================= // function : EnableFeatures // purpose : // ======================================================================= void OpenGl_Window::EnableFeatures() const { - /*glPixelTransferi (GL_MAP_COLOR, GL_TRUE);*/ - - if (myDither) - glEnable (GL_DITHER); - else - glDisable (GL_DITHER); + // } // ======================================================================= @@ -785,7 +714,6 @@ void OpenGl_Window::EnableFeatures() const // ======================================================================= void OpenGl_Window::DisableFeatures() const { - glDisable (GL_DITHER); glPixelTransferi (GL_MAP_COLOR, GL_FALSE); /* @@ -865,12 +793,3 @@ void OpenGl_Window::MakeBackBufCurrent() const { glDrawBuffer (GL_BACK); } - -// ======================================================================= -// function : GetGContext -// purpose : -// ======================================================================= -GLCONTEXT OpenGl_Window::GetGContext() const -{ - return (GLCONTEXT )myGlContext->myGContext; -} diff --git a/src/OpenGl/OpenGl_Window.hxx b/src/OpenGl/OpenGl_Window.hxx index 3266a1d2a2..7aac39f485 100644 --- a/src/OpenGl/OpenGl_Window.hxx +++ b/src/OpenGl/OpenGl_Window.hxx @@ -21,8 +21,8 @@ #include #include -#include #include +#include #include @@ -33,7 +33,7 @@ class OpenGl_Window : public MMgt_TShared public: //! Main constructor - prepare GL context for specified window. - OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, + OpenGl_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection, const CALL_DEF_WINDOW& theCWindow, Aspect_RenderingContext theGContext, const Handle(OpenGl_Caps)& theCaps, @@ -54,22 +54,12 @@ public: const Standard_ShortReal theG, const Standard_ShortReal theB); - void EnablePolygonOffset() const; - void DisablePolygonOffset() const; - Standard_Integer Width() const { return myWidth; } Standard_Integer Height() const { return myHeight; } const TEL_COLOUR& BackgroundColor() const { return myBgColor; } - Standard_Boolean Dither() const { return myDither; } - Standard_Boolean BackDither() const { return myBackDither; } - - const Handle(OpenGl_Display)& GetDisplay() const { return myDisplay; } const Handle(OpenGl_Context)& GetGlContext() const { return myGlContext; } - //! This method will be removed in future version! - GLCONTEXT GetGContext() const; - protected: //! Activates GL context and setup viewport. @@ -89,18 +79,11 @@ protected: protected: - Handle(OpenGl_Display) myDisplay; Handle(OpenGl_Context) myGlContext; Standard_Boolean myOwnGContext; //!< set to TRUE if GL context was not created by this class -#if (defined(_WIN32) || defined(__WIN32__)) - BOOL mySysPalInUse; -#endif - - Standard_Integer myWidth; // WSWidth - Standard_Integer myHeight; // WSHeight - TEL_COLOUR myBgColor; // WSBackground - Standard_Boolean myDither; - Standard_Boolean myBackDither; + Standard_Integer myWidth; //!< window width + Standard_Integer myHeight; //!< window height + TEL_COLOUR myBgColor; //!< background color public: diff --git a/src/OpenGl/OpenGl_Window_1.mm b/src/OpenGl/OpenGl_Window_1.mm index 297c5590b9..59444040ef 100644 --- a/src/OpenGl/OpenGl_Window_1.mm +++ b/src/OpenGl/OpenGl_Window_1.mm @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -38,19 +37,16 @@ namespace // function : OpenGl_Window // purpose : // ======================================================================= -OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, +OpenGl_Window::OpenGl_Window (const Handle(Aspect_DisplayConnection)& /*theDisplayConnection*/, const CALL_DEF_WINDOW& theCWindow, Aspect_RenderingContext theGContext, const Handle(OpenGl_Caps)& theCaps, const Handle(OpenGl_Context)& theShareCtx) -: myDisplay (theDisplay), - myGlContext (new OpenGl_Context (theCaps)), +: myGlContext (new OpenGl_Context (theCaps)), myOwnGContext (theGContext == 0), - myWidth ((Standard_Integer )theCWindow.dx), + myWidth ((Standard_Integer )theCWindow.dx), myHeight ((Standard_Integer )theCWindow.dy), - myBgColor (THE_DEFAULT_BG_COLOR), - myDither (theDisplay->Dither()), - myBackDither (theDisplay->BackDither()) + myBgColor (THE_DEFAULT_BG_COLOR) { myBgColor.rgb[0] = theCWindow.Background.r; myBgColor.rgb[1] = theCWindow.Background.g; @@ -122,14 +118,9 @@ OpenGl_Window::~OpenGl_Window() // ======================================================================= void OpenGl_Window::Resize (const CALL_DEF_WINDOW& theCWindow) { - DISPLAY* aDisp = (DISPLAY* )myDisplay->GetDisplay(); - if (aDisp == NULL) - { - return; - } - // If the size is not changed - do nothing - if ((myWidth == theCWindow.dx) && (myHeight == theCWindow.dy)) + if (myWidth == (Standard_Integer )theCWindow.dx + && myHeight == (Standard_Integer )theCWindow.dy) { return; } diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 1916a7acfb..825ac63037 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -137,12 +137,12 @@ void OpenGl_Material::Init (const OPENGL_SURF_PROP& theProp) // function : OpenGl_Workspace // purpose : // ======================================================================= -OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay, +OpenGl_Workspace::OpenGl_Workspace (const Handle(Aspect_DisplayConnection)& theDisplayConnection, const CALL_DEF_WINDOW& theCWindow, Aspect_RenderingContext theGContext, const Handle(OpenGl_Caps)& theCaps, const Handle(OpenGl_Context)& theShareCtx) -: OpenGl_Window (theDisplay, theCWindow, theGContext, theCaps, theShareCtx), +: OpenGl_Window (theDisplayConnection, theCWindow, theGContext, theCaps, theShareCtx), NamedStatus (0), HighlightColor (&THE_WHITE_COLOR), // @@ -152,6 +152,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay, myViewModificationStatus (0), myLayersModificationStatus (0), // + myAntiAliasingMode (3), myTransientDrawToFront (Standard_True), myBackBufferRestored (Standard_False), myIsImmediateDrawn (Standard_False), @@ -176,7 +177,15 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay, myModelViewMatrix (myDefaultMatrix), PolygonOffset_applied (NULL) { - theDisplay->InitAttributes(); + myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); + + if (!myGlContext->GetResource ("OpenGl_LineAttributes", myLineAttribs)) + { + // share and register for release once the resource is no longer used + myLineAttribs = new OpenGl_LineAttributes(); + myGlContext->ShareResource ("OpenGl_LineAttributes", myLineAttribs); + myLineAttribs->Init (myGlContext); + } // General initialization of the context @@ -190,8 +199,13 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay, glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST); glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST); - // Polygon Offset - EnablePolygonOffset(); + // AA mode + const char* anAaEnv = ::getenv ("CALL_OPENGL_ANTIALIASING_MODE"); + if (anAaEnv != NULL) + { + int v; + if (sscanf (anAaEnv, "%d", &v) > 0) myAntiAliasingMode = v; + } } // ======================================================================= @@ -211,6 +225,12 @@ Standard_Boolean OpenGl_Workspace::SetImmediateModeDrawToFront (const Standard_B // ======================================================================= OpenGl_Workspace::~OpenGl_Workspace() { + if (!myLineAttribs.IsNull()) + { + myLineAttribs.Nullify(); + myGlContext->ReleaseResource ("OpenGl_LineAttributes", Standard_True); + } + ReleaseRaytraceResources(); } @@ -618,7 +638,7 @@ void OpenGl_Workspace::redraw1 (const Graphic3d_CView& theCView, const Aspect_CLayer2d& theCOverLayer, const int theToSwap) { - if (myDisplay.IsNull() || myView.IsNull()) + if (myView.IsNull()) { return; } @@ -626,16 +646,6 @@ void OpenGl_Workspace::redraw1 (const Graphic3d_CView& theCView, // request reset of material NamedStatus |= OPENGL_NS_RESMAT; - // GL_DITHER on/off pour le background - if (myBackDither) - { - glEnable (GL_DITHER); - } - else - { - glDisable (GL_DITHER); - } - GLbitfield toClear = GL_COLOR_BUFFER_BIT; if (myUseZBuffer) { diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index 9c32f49c98..4a5e0d05ea 100755 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -41,7 +41,6 @@ #include #include -#include #include #include #include @@ -50,6 +49,7 @@ #include #include #include +#include #include #include @@ -98,7 +98,7 @@ class OpenGl_Workspace : public OpenGl_Window public: //! Main constructor - prepare GL context for specified window. - OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay, + OpenGl_Workspace (const Handle(Aspect_DisplayConnection)& theDisplayConnection, const CALL_DEF_WINDOW& theCWindow, Aspect_RenderingContext theGContext, const Handle(OpenGl_Caps)& theCaps, @@ -156,6 +156,8 @@ public: Standard_Boolean& UseDepthTest() { return myUseDepthTest; } Standard_Boolean& UseGLLight() { return myUseGLLight; } + Standard_Integer AntiAliasingMode() const { return myAntiAliasingMode; } + //// RELATED TO STATUS //// Standard_Integer NamedStatus; @@ -555,7 +557,9 @@ protected: //! @name fields related to ray-tracing protected: //! @name protected fields Handle(OpenGl_PrinterContext) myPrintContext; - Handle(OpenGl_View) myView; // WSViews - now just one view is supported + Handle(OpenGl_View) myView; + Handle(OpenGl_LineAttributes) myLineAttribs; + Standard_Integer myAntiAliasingMode; Standard_Boolean myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer) Standard_Boolean myBackBufferRestored; Standard_Boolean myIsImmediateDrawn; //!< flag indicates that immediate mode buffer contains some data diff --git a/src/OpenGl/OpenGl_Workspace_2.cxx b/src/OpenGl/OpenGl_Workspace_2.cxx index 6ab47d6ee7..833bb3f8c5 100644 --- a/src/OpenGl/OpenGl_Workspace_2.cxx +++ b/src/OpenGl/OpenGl_Workspace_2.cxx @@ -36,8 +36,6 @@ #include #include #include -#include - #ifdef _WIN32 diff --git a/src/OpenGl/OpenGl_Workspace_5.cxx b/src/OpenGl/OpenGl_Workspace_5.cxx index 3c626bd20a..6b5dc6575d 100644 --- a/src/OpenGl/OpenGl_Workspace_5.cxx +++ b/src/OpenGl/OpenGl_Workspace_5.cxx @@ -299,7 +299,7 @@ const OpenGl_AspectLine * OpenGl_Workspace::AspectLine(const Standard_Boolean Wi if ( !AspectLine_applied || (AspectLine_set->Type() != AspectLine_applied->Type() ) ) { - myDisplay->SetTypeOfLine(AspectLine_set->Type()); + myLineAttribs->SetTypeOfLine (AspectLine_set->Type()); } if ( !AspectLine_applied || ( AspectLine_set->Width() != AspectLine_applied->Width() ) ) @@ -386,7 +386,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th case Aspect_IS_HATCH: { glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); - myDisplay->SetTypeOfHatch (AspectFace_applied != NULL ? AspectFace_applied->Hatch() : TEL_HS_SOLID); + myLineAttribs->SetTypeOfHatch (AspectFace_applied != NULL ? AspectFace_applied->Hatch() : TEL_HS_SOLID); break; } case Aspect_IS_SOLID: @@ -409,7 +409,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th const Tint hatchstyle = AspectFace_set->Hatch(); if (AspectFace_applied == NULL || AspectFace_applied->Hatch() != hatchstyle) { - myDisplay->SetTypeOfHatch(hatchstyle); + myLineAttribs->SetTypeOfHatch (hatchstyle); } } -- 2.20.1