mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0023544: Texture management in TKOpenGl should be redesigned
Structures Graphic3d_CView, Graphic3d_CStructure, Graphic3d_CGroup become classes and their definitions moved from InterfaceGraphic to Graphic3d. Introduced new class OpenGl_Texture as replacement for OpenGl_ResourceTexture class and static functions in OpenGl_TextureBox. Graphic3d_TextureRoot now no more communicate within Graphic3d_GraphicalDriver. Instead class returns image through GetImage() method. OpenGl_AspectFace - avoid possible NULL-dereference OpenGl_Texture::Init() - check gluBuild2DMipmaps() return value OpenGl_Texture - check GL_BGRA_EXT for compatibility OpenGl_Texture - scale NPOT image when required Added more description to Graphic3d_TextureRoot class OpenGl_Texture - added missing break statement for ImgBGR32 case OpenGl_Workspace::setTextureParams() - fixed local variable aFilterMin overrides visibility of early declared variable OpenGl_Workspace::DisableTexture() - reset texture matrix FTGL do not reset texture matrix and corrupt text could be rendered if custom texture has not identity texture matrix.
This commit is contained in:
parent
ab8fcacf28
commit
bf75be9867
3
.gitignore
vendored
3
.gitignore
vendored
@ -15,7 +15,8 @@
|
||||
|
||||
# project files and artifacts
|
||||
/adm/msvc
|
||||
/adm/wnt/cbp
|
||||
/adm/wnt
|
||||
/adm/lin
|
||||
/adm/mac
|
||||
/adm/make
|
||||
*.vcproj*user
|
||||
|
@ -177,7 +177,7 @@ void AIS_TexturedShape::EnableTextureModulate()
|
||||
|
||||
//=======================================================================
|
||||
//function : DisableTextureModulate
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_TexturedShape::DisableTextureModulate()
|
||||
@ -192,7 +192,6 @@ void AIS_TexturedShape::DisableTextureModulate()
|
||||
|
||||
void AIS_TexturedShape::UpdateAttributes()
|
||||
{
|
||||
Handle(Graphic3d_StructureManager) aStrucMana = GetContext()->MainPrsMgr()->StructureManager();
|
||||
Prs3d_ShadingAspect aDummy;
|
||||
myAspect = aDummy.Aspect();
|
||||
Handle(Prs3d_Presentation) aPrs = Presentation();
|
||||
@ -203,9 +202,9 @@ void AIS_TexturedShape::UpdateAttributes()
|
||||
}
|
||||
|
||||
if (myPredefTexture != -1)
|
||||
mytexture = new Graphic3d_Texture2Dmanual (aStrucMana, myPredefTexture);
|
||||
mytexture = new Graphic3d_Texture2Dmanual (myPredefTexture);
|
||||
else
|
||||
mytexture = new Graphic3d_Texture2Dmanual (aStrucMana, myTextureFile.ToCString());
|
||||
mytexture = new Graphic3d_Texture2Dmanual (myTextureFile.ToCString());
|
||||
|
||||
myAspect->SetTextureMapOn();
|
||||
|
||||
@ -323,7 +322,6 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
|
||||
BRepTools::Clean (myshape);
|
||||
BRepTools::Update (myshape);
|
||||
|
||||
Handle(Graphic3d_StructureManager) aStrucMana = GetContext()->MainPrsMgr()->StructureManager();
|
||||
{
|
||||
Handle(Prs3d_ShadingAspect) aPrs3d_ShadingAspect = new Prs3d_ShadingAspect();
|
||||
myAspect = aPrs3d_ShadingAspect->Aspect();
|
||||
@ -345,9 +343,9 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
|
||||
myAspect->SetTextureMapOn();
|
||||
|
||||
if (myPredefTexture != -1)
|
||||
mytexture = new Graphic3d_Texture2Dmanual (aStrucMana, myPredefTexture);
|
||||
mytexture = new Graphic3d_Texture2Dmanual (myPredefTexture);
|
||||
else
|
||||
mytexture = new Graphic3d_Texture2Dmanual (aStrucMana, myTextureFile.ToCString());
|
||||
mytexture = new Graphic3d_Texture2Dmanual (myTextureFile.ToCString());
|
||||
|
||||
if (!mytexture->IsDone())
|
||||
{
|
||||
|
@ -10,8 +10,6 @@ Graphic3d_CBitFields8.cxx
|
||||
Graphic3d_CBitFields8.hxx
|
||||
Graphic3d_CBitFields4.cxx
|
||||
Graphic3d_CBitFields4.hxx
|
||||
Graphic3d_CInitTexture.cxx
|
||||
Graphic3d_CInitTexture.hxx
|
||||
Graphic3d_CTexture.cxx
|
||||
Graphic3d_CTexture.hxx
|
||||
Graphic3d_CLight.cxx
|
||||
@ -53,3 +51,6 @@ Graphic3d_AspectText3d.cxx
|
||||
Graphic3d_WNTGraphicDevice.cxx
|
||||
Graphic3d_PtrFrameBuffer.hxx
|
||||
Graphic3d_BufferType.hxx
|
||||
Graphic3d_Vec2.hxx
|
||||
Graphic3d_Vec3.hxx
|
||||
Graphic3d_Vec4.hxx
|
||||
|
@ -220,6 +220,21 @@ is
|
||||
---Purpose: Type of the texture projection.
|
||||
---Category: Enumerations
|
||||
|
||||
enumeration TypeOfTextureFilter is TOTF_NEAREST,
|
||||
TOTF_BILINEAR,
|
||||
TOTF_TRILINEAR;
|
||||
---Purpose: Type of the texture filter.
|
||||
-- Notice that for textures without mipmaps linear interpolation will be used instead of TOTF_BILINEAR and TOTF_TRILINEAR.
|
||||
---Category: Enumerations
|
||||
|
||||
enumeration LevelOfTextureAnisotropy is LOTA_OFF,
|
||||
LOTA_FAST,
|
||||
LOTA_MIDDLE,
|
||||
LOTA_QUALITY;
|
||||
---Purpose: Level of anisotropy filter.
|
||||
-- Notice that actual quality depends on hardware capabilities!
|
||||
---Category: Enumerations
|
||||
|
||||
enumeration NameOfTexturePlane is NOTP_XY,
|
||||
NOTP_YZ,
|
||||
NOTP_ZX,
|
||||
@ -384,15 +399,15 @@ is
|
||||
---Purpose: Defines the C structure of a graduated trihedron.
|
||||
---Category: Imported types
|
||||
|
||||
imported CInitTexture;
|
||||
imported CTexture;
|
||||
|
||||
-- ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate )
|
||||
imported CTransPersStruct;
|
||||
imported TransModeFlags;
|
||||
-- ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate )
|
||||
imported CTransPersStruct;
|
||||
imported TransModeFlags;
|
||||
|
||||
primitive PtrFrameBuffer;
|
||||
primitive Vec2;
|
||||
primitive Vec3;
|
||||
primitive Vec4;
|
||||
|
||||
--------------------
|
||||
-- Category: Classes
|
||||
@ -614,12 +629,12 @@ is
|
||||
imported NListOfHAsciiString;
|
||||
---Category: Instantiated classes
|
||||
|
||||
|
||||
deferred class TextureRoot from Graphic3d;
|
||||
deferred class TextureRoot from Graphic3d;
|
||||
deferred class TextureMap from Graphic3d;
|
||||
deferred class Texture1D from Graphic3d;
|
||||
deferred class Texture2D from Graphic3d;
|
||||
|
||||
class TextureParams from Graphic3d;
|
||||
class TextureEnv from Graphic3d;
|
||||
class Texture1Dmanual from Graphic3d;
|
||||
class Texture1Dsegment from Graphic3d;
|
||||
|
@ -16,24 +16,100 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*============================================================================*/
|
||||
/*==== Titre: Graphic3d_CGroup.hxx */
|
||||
/*==== Role : The header file of primitive type "CGroup" from Graphic3d */
|
||||
/*==== */
|
||||
/*==== Implementation: This is a primitive type implemented with typedef */
|
||||
/*============================================================================*/
|
||||
|
||||
#ifndef _Graphic3d_CGroup_HeaderFile
|
||||
#define _Graphic3d_CGroup_HeaderFile
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
typedef CALL_DEF_GROUP Graphic3d_CGroup;
|
||||
#include <InterfaceGraphic_Visual3d.hxx>
|
||||
#include <Graphic3d_CTexture.hxx>
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
/*==== Definition de Type ====================================================*/
|
||||
#include <Standard_Type.hxx>
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CGroup);
|
||||
/*============================================================================*/
|
||||
class Graphic3d_CStructure;
|
||||
|
||||
#endif
|
||||
#endif /*Graphic3d_CGroup_HeaderFile*/
|
||||
class CALL_DEF_CONTEXTFILLAREA
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
CALL_DEF_CONTEXTFILLAREA()
|
||||
: IsDef (0),
|
||||
IsSet (0),
|
||||
Style (0),
|
||||
LineType (0),
|
||||
Width (0.0f),
|
||||
Hatch (0),
|
||||
Distinguish (0),
|
||||
BackFace (0),
|
||||
Edge (0),
|
||||
DegenerationMode (0),
|
||||
SkipRatio (0.0f),
|
||||
PolygonOffsetMode (0),
|
||||
PolygonOffsetFactor (0.0f),
|
||||
PolygonOffsetUnits (0.0f)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
int IsDef;
|
||||
|
||||
int IsSet;
|
||||
|
||||
int Style;
|
||||
|
||||
CALL_DEF_COLOR IntColor;
|
||||
CALL_DEF_COLOR BackIntColor;
|
||||
CALL_DEF_COLOR EdgeColor;
|
||||
|
||||
int LineType;
|
||||
|
||||
float Width;
|
||||
|
||||
int Hatch;
|
||||
|
||||
int Distinguish;
|
||||
int BackFace;
|
||||
|
||||
int Edge;
|
||||
|
||||
CALL_DEF_MATERIAL Front;
|
||||
CALL_DEF_MATERIAL Back;
|
||||
|
||||
Graphic3d_CTexture Texture;
|
||||
|
||||
int DegenerationMode;
|
||||
float SkipRatio;
|
||||
|
||||
int PolygonOffsetMode;
|
||||
float PolygonOffsetFactor;
|
||||
float PolygonOffsetUnits;
|
||||
|
||||
};
|
||||
|
||||
class Graphic3d_CGroup
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
int LabelBegin;
|
||||
int LabelEnd;
|
||||
void* ptrGroup;
|
||||
|
||||
int StructureEnd;
|
||||
|
||||
CALL_DEF_CONTEXTLINE ContextLine;
|
||||
CALL_DEF_CONTEXTFILLAREA ContextFillArea;
|
||||
CALL_DEF_CONTEXTMARKER ContextMarker;
|
||||
CALL_DEF_CONTEXTTEXT ContextText;
|
||||
|
||||
Graphic3d_CStructure* Struct;
|
||||
|
||||
CALL_DEF_PICKID PickId;
|
||||
|
||||
unsigned IsDeleted : 1;
|
||||
unsigned IsOpen : 1;
|
||||
|
||||
};
|
||||
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CGroup);
|
||||
|
||||
#endif // Graphic3d_CGroup_HeaderFile
|
||||
|
@ -1,40 +0,0 @@
|
||||
// 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.
|
||||
|
||||
/*============================================================================*/
|
||||
/*==== Titre: Graphic3d_CInitTexture.hxx */
|
||||
/*==== Role : The header file of primitive type "CInitTexture" from Graphic3d */
|
||||
/*==== */
|
||||
/*==== Implementation: This is a primitive type implemented with typedef */
|
||||
/*==== Created: 1/07/97 ; PCT : texture mapping */
|
||||
/*============================================================================*/
|
||||
|
||||
#ifndef _Graphic3d_CInitTexture_HeaderFile
|
||||
#define _Graphic3d_CInitTexture_HeaderFile
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <InterfaceGraphic_Visual3d.hxx>
|
||||
typedef CALL_DEF_INIT_TEXTURE Graphic3d_CInitTexture;
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
/*==== Definition de Type ====================================================*/
|
||||
#include <Standard_Type.hxx>
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CInitTexture);
|
||||
/*============================================================================*/
|
||||
|
||||
#endif
|
||||
#endif /*Graphic3d_CInitTexture_HeaderFile*/
|
@ -16,25 +16,51 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*============================================================================*/
|
||||
/*==== Titre: Graphic3d_CStructure.hxx */
|
||||
/*==== Role : The header file of primitive type "CStructure" from Graphic3d */
|
||||
/*==== */
|
||||
/*==== Implementation: This is a primitive type implemented with typedef */
|
||||
/*============================================================================*/
|
||||
|
||||
#ifndef _Graphic3d_CStructure_HeaderFile
|
||||
#define _Graphic3d_CStructure_HeaderFile
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
typedef CALL_DEF_STRUCTURE Graphic3d_CStructure;
|
||||
#include <Graphic3d_CGroup.hxx>
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
/*==== Definition de Type ====================================================*/
|
||||
class Graphic3d_CStructure
|
||||
{
|
||||
|
||||
#include <Standard_Type.hxx>
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CStructure) ;
|
||||
/*============================================================================*/
|
||||
public:
|
||||
|
||||
#endif
|
||||
#endif /*Graphic3d_CStructure_HeaderFile*/
|
||||
int Id;
|
||||
void* ptrStructure;
|
||||
|
||||
int Priority;
|
||||
int PreviousPriority;
|
||||
int GroupBegin;
|
||||
int GroupEnd;
|
||||
|
||||
CALL_DEF_CONTEXTLINE ContextLine;
|
||||
CALL_DEF_CONTEXTFILLAREA ContextFillArea;
|
||||
CALL_DEF_CONTEXTMARKER ContextMarker;
|
||||
CALL_DEF_CONTEXTTEXT ContextText;
|
||||
|
||||
CALL_DEF_BOUNDBOX BoundBox;
|
||||
|
||||
float Transformation[4][4];
|
||||
int Composition;
|
||||
|
||||
int ContainsFacet;
|
||||
|
||||
unsigned IsDeleted : 1;
|
||||
unsigned IsOpen : 1;
|
||||
unsigned IsInfinite : 1;
|
||||
unsigned stick : 1;
|
||||
unsigned highlight : 1;
|
||||
unsigned visible : 1;
|
||||
unsigned pick : 1;
|
||||
unsigned HLRValidation : 1;
|
||||
|
||||
CALL_DEF_TRANSFORM_PERSISTENCE TransformPersistence;
|
||||
|
||||
};
|
||||
|
||||
///typedef Graphic3d_CStructure CALL_DEF_STRUCTURE;
|
||||
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CStructure);
|
||||
|
||||
#endif // Graphic3d_CStructure_HeaderFile
|
||||
|
@ -15,26 +15,30 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*============================================================================*/
|
||||
/*==== Titre: Graphic3d_CTexture.hxx */
|
||||
/*==== Role : The header file of primitive type "CTexture" from Graphic3d */
|
||||
/*==== */
|
||||
/*==== Implementation: This is a primitive type implemented with typedef */
|
||||
/*==== created: 1/07/97 ; PCT : texture mapping */
|
||||
/*============================================================================*/
|
||||
|
||||
#ifndef _Graphic3d_CTexture_HeaderFile
|
||||
#define _Graphic3d_CTexture_HeaderFile
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <InterfaceGraphic_Visual3d.hxx>
|
||||
typedef CALL_DEF_TEXTURE Graphic3d_CTexture;
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
/*==== Definition de Type ====================================================*/
|
||||
#include <Handle_Graphic3d_TextureMap.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CTexture);
|
||||
/*============================================================================*/
|
||||
|
||||
#endif
|
||||
#endif /*Graphic3d_CTexture_HeaderFile*/
|
||||
class Graphic3d_CTexture
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Graphic3d_CTexture()
|
||||
: doTextureMap (0)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Handle(Graphic3d_TextureMap) TextureMap; //!< handle to texture
|
||||
int doTextureMap; //!< flag indicates to use texture or not
|
||||
|
||||
};
|
||||
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CTexture);
|
||||
|
||||
#endif // Graphic3d_CTexture_HeaderFile
|
||||
|
@ -15,25 +15,130 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*============================================================================*/
|
||||
/*==== Titre: Graphic3d_CView.hxx */
|
||||
/*==== Role : The header file of primitive type "CView" from Graphic3d */
|
||||
/*==== */
|
||||
/*==== Implementation: This is a primitive type implemented with typedef */
|
||||
/*============================================================================*/
|
||||
|
||||
#ifndef _Graphic3d_CView_HeaderFile
|
||||
#define _Graphic3d_CView_HeaderFile
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <InterfaceGraphic_Visual3d.hxx>
|
||||
typedef CALL_DEF_VIEW Graphic3d_CView;
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
/*==== Definition de Type ====================================================*/
|
||||
#include <Handle_Graphic3d_TextureEnv.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CView);
|
||||
/*============================================================================*/
|
||||
|
||||
#endif
|
||||
#endif /*Graphic3d_CView_HeaderFile*/
|
||||
class CALL_DEF_VIEWCONTEXT
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
CALL_DEF_VIEWCONTEXT()
|
||||
: Aliasing (0),
|
||||
BackZClipping (0),
|
||||
FrontZClipping (0),
|
||||
DepthCueing (0),
|
||||
ZClipFrontPlane (0.0f),
|
||||
ZClipBackPlane (0.0f),
|
||||
DepthFrontPlane (0.0f),
|
||||
DepthBackPlane (0.0f),
|
||||
ZBufferActivity (0),
|
||||
Model (0),
|
||||
Visualization (0),
|
||||
NbActiveLight (0),
|
||||
ActiveLight (NULL),
|
||||
NbActivePlane (0),
|
||||
ActivePlane (NULL),
|
||||
SurfaceDetail (0)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
int Aliasing;
|
||||
|
||||
int BackZClipping;
|
||||
int FrontZClipping;
|
||||
|
||||
int DepthCueing;
|
||||
|
||||
float ZClipFrontPlane;
|
||||
float ZClipBackPlane;
|
||||
|
||||
float DepthFrontPlane;
|
||||
float DepthBackPlane;
|
||||
|
||||
int ZBufferActivity;
|
||||
int Model;
|
||||
int Visualization;
|
||||
|
||||
int NbActiveLight;
|
||||
CALL_DEF_LIGHT* ActiveLight;
|
||||
|
||||
int NbActivePlane;
|
||||
CALL_DEF_PLANE* ActivePlane;
|
||||
|
||||
Handle(Graphic3d_TextureEnv) TextureEnv;
|
||||
int SurfaceDetail;
|
||||
|
||||
};
|
||||
|
||||
class Graphic3d_CView
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Graphic3d_CView()
|
||||
: WsId (-1),
|
||||
ViewId (0),
|
||||
ptrView (NULL),
|
||||
IsDeleted (0),
|
||||
IsOpen (0),
|
||||
Active (0),
|
||||
ptrUnderLayer (NULL),
|
||||
ptrOverLayer (NULL),
|
||||
IsDegenerates (0),
|
||||
IsDegeneratesPrev (0),
|
||||
Backfacing (0),
|
||||
GDisplayCB (NULL),
|
||||
GClientData (NULL),
|
||||
ptrFBO (NULL)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
int WsId;
|
||||
int ViewId;
|
||||
void* ptrView;
|
||||
|
||||
int IsDeleted;
|
||||
int IsOpen;
|
||||
|
||||
int Active;
|
||||
|
||||
CALL_DEF_VIEWORIENTATION Orientation;
|
||||
CALL_DEF_VIEWMAPPING Mapping;
|
||||
|
||||
CALL_DEF_VIEWORIENTATION OrientationReset;
|
||||
CALL_DEF_VIEWMAPPING MappingReset;
|
||||
|
||||
CALL_DEF_VIEWCONTEXT Context;
|
||||
|
||||
CALL_DEF_WINDOW DefWindow;
|
||||
|
||||
void* ptrUnderLayer;
|
||||
void* ptrOverLayer;
|
||||
|
||||
int IsDegenerates;
|
||||
int IsDegeneratesPrev;
|
||||
int Backfacing;
|
||||
|
||||
Aspect_RenderingContext GContext;
|
||||
Aspect_GraphicCallbackProc GDisplayCB;
|
||||
void* GClientData;
|
||||
|
||||
void* ptrFBO;
|
||||
|
||||
};
|
||||
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CView);
|
||||
|
||||
#endif // Graphic3d_CView_HeaderFile
|
||||
|
@ -18,30 +18,6 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
-- Modified: 01/08/97 ; PCT : ajout texture mapping
|
||||
-- 07/08/97 ; PCT : ajout texture environnante
|
||||
-- 27/08/97 ; PCT : ajout coordonnee texture
|
||||
-- 00/11/97 ; CAL : retrait de la dependance avec math
|
||||
-- 00/11/97 ; CAL : ajout polyline par 2 points
|
||||
-- 16-09-98 ; BGN : Points d'entree du Triedre (S3819, Phase 1)
|
||||
-- 22-09-98 ; BGN : S3989 (anciennement S3819)
|
||||
-- TypeOfTriedron* from Aspect(et pas Graphic3d)
|
||||
-- 03-11-98 ; CAL : Introduction de Visual3d_LayerManager.
|
||||
-- 07-10-99 : EUG : Degeneration support (G003)
|
||||
-- Add DegenerateStructure() and
|
||||
-- SetBackFacingModel() methods.
|
||||
-- 10-11-99 ; GG : PRO19603 Change Redraw( ) method
|
||||
-- 16-06-2000 : ATS,GG : G005 - method PrimitiveArray, which are interface of OpenGl
|
||||
-- package, and used to initialize internal fields
|
||||
-- of primitives (Convert high level data to internal presentation).
|
||||
-- 17/08/00 ; THA ; Thomas HARTL <t-hartl@muenchen.matra-dtv.fr>
|
||||
-- -> Add Print methods (works only under Windows).
|
||||
-- 27/03/02 ; GG ; RIC120302 Add new method Begin(Aspect_Display)
|
||||
-- 28/05/02 ; VSV : New trihedron
|
||||
-- 23/12/02 ; SAV : Added methods to set background image and its
|
||||
-- appearence style
|
||||
-- 20/01/09 ; ABD : Integration support of system fonts (using FTGL and FreeType)
|
||||
|
||||
deferred class GraphicDriver from Graphic3d inherits GraphicDriver from Aspect
|
||||
|
||||
---Version:
|
||||
@ -114,8 +90,6 @@ uses
|
||||
Array2OfVertexNC from Graphic3d,
|
||||
VertexNC from Graphic3d,
|
||||
VerticalTextAlignment from Graphic3d,
|
||||
CInitTexture from Graphic3d,
|
||||
TypeOfTexture from Graphic3d,
|
||||
VertexNT from Graphic3d,
|
||||
Array1OfVertexNT from Graphic3d,
|
||||
Array2OfVertexNT from Graphic3d,
|
||||
@ -800,30 +774,6 @@ is
|
||||
is deferred;
|
||||
---Purpose: call_togl_transform
|
||||
|
||||
-----------------------------
|
||||
-- Category: Textures methods
|
||||
-----------------------------
|
||||
|
||||
CreateTexture ( me;
|
||||
theType : TypeOfTexture from Graphic3d;
|
||||
theImage : PixMap from Image;
|
||||
theFileName : CString from Standard;
|
||||
theTexUpperBounds : HArray1OfReal from TColStd )
|
||||
returns Integer from Standard
|
||||
is deferred;
|
||||
---Purpose:
|
||||
|
||||
DestroyTexture ( me;
|
||||
TexId : Integer from Standard )
|
||||
is deferred;
|
||||
---Purpose:
|
||||
|
||||
ModifyTexture ( me;
|
||||
TexId : Integer from Standard;
|
||||
AValue : CInitTexture from Graphic3d )
|
||||
is deferred;
|
||||
---Purpose:
|
||||
|
||||
-------------------------------
|
||||
-- Category: Layer mode methods
|
||||
-------------------------------
|
||||
|
@ -21,7 +21,7 @@
|
||||
// 11/97 ; CAL : retrait DownCast
|
||||
|
||||
|
||||
//-Version
|
||||
//-Version
|
||||
|
||||
//-Design Declaration of variables specific to groups
|
||||
// of primitives
|
||||
@ -29,7 +29,7 @@
|
||||
//-Warning A group is definedv in a structure
|
||||
// This is the smallest editable entity
|
||||
|
||||
//-References
|
||||
//-References
|
||||
|
||||
//-Language C++ 2.0
|
||||
|
||||
@ -87,7 +87,7 @@ Standard_Integer TheLabelBegin, TheLabelEnd;
|
||||
MyContainsFacet = Standard_False,
|
||||
MyIsEmpty = Standard_True;
|
||||
|
||||
MyCGroup.Struct = (CALL_DEF_STRUCTURE *) (MyStructure->CStructure ());
|
||||
MyCGroup.Struct = MyStructure->CStructure();
|
||||
MyCGroup.Struct->Id = int (MyStructure->Identification ());
|
||||
MyCGroup.IsDeleted = 0;
|
||||
MyCGroup.IsOpen = 0;
|
||||
|
@ -21,11 +21,11 @@
|
||||
// modified: 1/07/97 ; PCT : ajout texture mapping
|
||||
// 20/07/97 ; PCT : ajout transparence texture
|
||||
// 08/04/98 ; FGU : Ajout emission surface
|
||||
// 30/11/98 ; FMN : S4069. Textes always visible.
|
||||
// 30/11/98 ; FMN : S4069. Textes always visible.
|
||||
// 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets */
|
||||
|
||||
|
||||
//-Version
|
||||
//-Version
|
||||
|
||||
//-Design Declaration des variables specifiques aux groupes
|
||||
// de primitives
|
||||
@ -33,7 +33,7 @@
|
||||
//-Warning Un groupe est defini dans une structure
|
||||
// Il s'agit de la plus petite entite editable
|
||||
|
||||
//-References
|
||||
//-References
|
||||
|
||||
//-Language C++ 2.0
|
||||
|
||||
@ -136,7 +136,7 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFil
|
||||
MyCGroup.ContextFillArea.Back.Emission =
|
||||
float ((CTX->BackMaterial ()).Emissive ());
|
||||
|
||||
// Reflection mode
|
||||
// Reflection mode
|
||||
MyCGroup.ContextFillArea.Back.IsAmbient =
|
||||
( (CTX->BackMaterial ()).ReflectionMode
|
||||
(Graphic3d_TOR_AMBIENT) ? 1 : 0 );
|
||||
@ -150,13 +150,13 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFil
|
||||
( (CTX->BackMaterial ()).ReflectionMode
|
||||
(Graphic3d_TOR_EMISSION) ? 1 : 0 );
|
||||
|
||||
// Material type
|
||||
// Material type
|
||||
//JR/Hp
|
||||
const Graphic3d_MaterialAspect ama = CTX->BackMaterial () ;
|
||||
Standard_Boolean amt = ama.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
|
||||
MyCGroup.ContextFillArea.Back.IsPhysic = ( amt ? 1 : 0 );
|
||||
|
||||
// Specular color
|
||||
// Specular color
|
||||
MyCGroup.ContextFillArea.Back.ColorSpec.r =
|
||||
float (((CTX->BackMaterial ()).SpecularColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Back.ColorSpec.g =
|
||||
@ -189,7 +189,7 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFil
|
||||
MyCGroup.ContextFillArea.Back.ColorEms.b =
|
||||
float (((CTX->BackMaterial ()).EmissiveColor ()).Blue ());
|
||||
|
||||
MyCGroup.ContextFillArea.Back.EnvReflexion =
|
||||
MyCGroup.ContextFillArea.Back.EnvReflexion =
|
||||
float ((CTX->BackMaterial ()).EnvReflexion());
|
||||
|
||||
/*** Front Material ***/
|
||||
@ -205,9 +205,9 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFil
|
||||
MyCGroup.ContextFillArea.Front.Transparency =
|
||||
float ((CTX->FrontMaterial ()).Transparency ());
|
||||
MyCGroup.ContextFillArea.Front.Emission =
|
||||
float ((CTX->FrontMaterial ()).Emissive ());
|
||||
float ((CTX->FrontMaterial ()).Emissive ());
|
||||
|
||||
// Reflection mode
|
||||
// Reflection mode
|
||||
MyCGroup.ContextFillArea.Front.IsAmbient =
|
||||
( (CTX->FrontMaterial ()).ReflectionMode
|
||||
(Graphic3d_TOR_AMBIENT) ? 1 : 0 );
|
||||
@ -227,7 +227,7 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFil
|
||||
Standard_Boolean amty = amas.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
|
||||
MyCGroup.ContextFillArea.Front.IsPhysic = ( amty ? 1 : 0 );
|
||||
|
||||
// Specular color
|
||||
// Specular color
|
||||
MyCGroup.ContextFillArea.Front.ColorSpec.r =
|
||||
float (((CTX->FrontMaterial ()).SpecularColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Front.ColorSpec.g =
|
||||
@ -235,7 +235,7 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFil
|
||||
MyCGroup.ContextFillArea.Front.ColorSpec.b =
|
||||
float (((CTX->FrontMaterial ()).SpecularColor ()).Blue ());
|
||||
|
||||
// Ambient color
|
||||
// Ambient color
|
||||
MyCGroup.ContextFillArea.Front.ColorAmb.r =
|
||||
float (((CTX->FrontMaterial ()).AmbientColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Front.ColorAmb.g =
|
||||
@ -243,7 +243,7 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFil
|
||||
MyCGroup.ContextFillArea.Front.ColorAmb.b =
|
||||
float (((CTX->FrontMaterial ()).AmbientColor ()).Blue ());
|
||||
|
||||
// Diffuse color
|
||||
// Diffuse color
|
||||
MyCGroup.ContextFillArea.Front.ColorDif.r =
|
||||
float (((CTX->FrontMaterial ()).DiffuseColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Front.ColorDif.g =
|
||||
@ -259,31 +259,23 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFil
|
||||
MyCGroup.ContextFillArea.Front.ColorEms.b =
|
||||
float (((CTX->FrontMaterial ()).EmissiveColor ()).Blue ());
|
||||
|
||||
MyCGroup.ContextFillArea.Front.EnvReflexion =
|
||||
MyCGroup.ContextFillArea.Front.EnvReflexion =
|
||||
float ((CTX->FrontMaterial ()).EnvReflexion());
|
||||
|
||||
MyCGroup.ContextFillArea.IsDef = 1; // Definition material ok
|
||||
|
||||
/*** Texture map ***/
|
||||
Handle(Graphic3d_TextureMap) GroupTextureMap = CTX->TextureMap();
|
||||
if (! GroupTextureMap.IsNull() ) {
|
||||
MyCGroup.ContextFillArea.Texture.TexId = GroupTextureMap->TextureId();
|
||||
MyCGroup.ContextFillArea.Texture.doTextureMap =
|
||||
CTX->TextureMapState () ? 1 : 0;
|
||||
}
|
||||
else {
|
||||
MyCGroup.ContextFillArea.Texture.TexId = -1;
|
||||
MyCGroup.ContextFillArea.Texture.doTextureMap = 0;
|
||||
}
|
||||
MyCGroup.ContextFillArea.Texture.TextureMap = CTX->TextureMap();
|
||||
MyCGroup.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1 : 0;
|
||||
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
Standard_Integer aPolyMode;
|
||||
Standard_ShortReal aPolyFactor, aPolyUnits;
|
||||
CTX->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits);
|
||||
MyCGroup.ContextFillArea.PolygonOffsetMode = aPolyMode;
|
||||
MyCGroup.ContextFillArea.PolygonOffsetFactor = aPolyFactor;
|
||||
MyCGroup.ContextFillArea.PolygonOffsetUnits = aPolyUnits;
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
|
||||
int noinsert = 1;
|
||||
MyGraphicDriver->FaceContextGroup (MyCGroup, noinsert);
|
||||
@ -361,8 +353,8 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectTex
|
||||
MyCGroup.ContextText.ColorSubTitle.r = float (Rs);
|
||||
MyCGroup.ContextText.ColorSubTitle.g = float (Gs);
|
||||
MyCGroup.ContextText.ColorSubTitle.b = float (Bs);
|
||||
MyCGroup.ContextText.TextZoomable = ATextZoomable;
|
||||
MyCGroup.ContextText.TextAngle = float (ATextAngle);
|
||||
MyCGroup.ContextText.TextZoomable = ATextZoomable;
|
||||
MyCGroup.ContextText.TextAngle = float (ATextAngle);
|
||||
MyCGroup.ContextText.TextFontAspect = (int)ATextFontAspect;
|
||||
|
||||
MyCGroup.ContextText.IsDef = 1;
|
||||
@ -423,7 +415,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.IntColor.r = float (R);
|
||||
MyCGroup.ContextFillArea.IntColor.g = float (G);
|
||||
MyCGroup.ContextFillArea.IntColor.b = float (B);
|
||||
#ifdef OCC1174
|
||||
#ifdef OCC1174
|
||||
if ( CTX->Distinguish() )
|
||||
BackIntColor.Values( R, G, B, Quantity_TOC_RGB );
|
||||
#endif
|
||||
@ -458,9 +450,9 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.Back.Transparency =
|
||||
float ((CTX->BackMaterial ()).Transparency ());
|
||||
MyCGroup.ContextFillArea.Back.Emission =
|
||||
float ((CTX->BackMaterial ()).Emissive ());
|
||||
float ((CTX->BackMaterial ()).Emissive ());
|
||||
|
||||
// Reflection mode
|
||||
// Reflection mode
|
||||
MyCGroup.ContextFillArea.Back.IsAmbient =
|
||||
( (CTX->BackMaterial ()).ReflectionMode
|
||||
(Graphic3d_TOR_AMBIENT) ? 1 : 0 );
|
||||
@ -480,7 +472,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
Standard_Boolean amt = ama.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
|
||||
MyCGroup.ContextFillArea.Back.IsPhysic = ( amt ? 1 : 0 );
|
||||
|
||||
// Specular color
|
||||
// Specular color
|
||||
MyCGroup.ContextFillArea.Back.ColorSpec.r =
|
||||
float (((CTX->BackMaterial ()).SpecularColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Back.ColorSpec.g =
|
||||
@ -488,7 +480,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.Back.ColorSpec.b =
|
||||
float (((CTX->BackMaterial ()).SpecularColor ()).Blue ());
|
||||
|
||||
// Ambient color
|
||||
// Ambient color
|
||||
MyCGroup.ContextFillArea.Back.ColorAmb.r =
|
||||
float (((CTX->BackMaterial ()).AmbientColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Back.ColorAmb.g =
|
||||
@ -496,7 +488,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.Back.ColorAmb.b =
|
||||
float (((CTX->BackMaterial ()).AmbientColor ()).Blue ());
|
||||
|
||||
// Diffuse color
|
||||
// Diffuse color
|
||||
MyCGroup.ContextFillArea.Back.ColorDif.r =
|
||||
float (((CTX->BackMaterial ()).DiffuseColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Back.ColorDif.g =
|
||||
@ -512,7 +504,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.Back.ColorEms.b =
|
||||
float (((CTX->BackMaterial ()).EmissiveColor ()).Blue ());
|
||||
|
||||
MyCGroup.ContextFillArea.Back.EnvReflexion =
|
||||
MyCGroup.ContextFillArea.Back.EnvReflexion =
|
||||
float ((CTX->BackMaterial ()).EnvReflexion());
|
||||
|
||||
/*** Front Material ***/
|
||||
@ -528,9 +520,9 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.Front.Transparency =
|
||||
float ((CTX->FrontMaterial ()).Transparency ());
|
||||
MyCGroup.ContextFillArea.Front.Emission =
|
||||
float ((CTX->FrontMaterial ()).Emissive ());
|
||||
float ((CTX->FrontMaterial ()).Emissive ());
|
||||
|
||||
// Reflection mode
|
||||
// Reflection mode
|
||||
MyCGroup.ContextFillArea.Front.IsAmbient =
|
||||
( (CTX->FrontMaterial ()).ReflectionMode
|
||||
(Graphic3d_TOR_AMBIENT) ? 1 : 0 );
|
||||
@ -550,7 +542,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
Standard_Boolean amty = amas.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
|
||||
MyCGroup.ContextFillArea.Front.IsPhysic = ( amty ? 1 : 0 );
|
||||
|
||||
// Specular color
|
||||
// Specular color
|
||||
MyCGroup.ContextFillArea.Front.ColorSpec.r =
|
||||
float (((CTX->FrontMaterial ()).SpecularColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Front.ColorSpec.g =
|
||||
@ -558,7 +550,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.Front.ColorSpec.b =
|
||||
float (((CTX->FrontMaterial ()).SpecularColor ()).Blue ());
|
||||
|
||||
// Ambient color
|
||||
// Ambient color
|
||||
MyCGroup.ContextFillArea.Front.ColorAmb.r =
|
||||
float (((CTX->FrontMaterial ()).AmbientColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Front.ColorAmb.g =
|
||||
@ -566,7 +558,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.Front.ColorAmb.b =
|
||||
float (((CTX->FrontMaterial ()).AmbientColor ()).Blue ());
|
||||
|
||||
// Diffuse color
|
||||
// Diffuse color
|
||||
MyCGroup.ContextFillArea.Front.ColorDif.r =
|
||||
float (((CTX->FrontMaterial ()).DiffuseColor ()).Red ());
|
||||
MyCGroup.ContextFillArea.Front.ColorDif.g =
|
||||
@ -582,21 +574,15 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea
|
||||
MyCGroup.ContextFillArea.Front.ColorEms.b =
|
||||
float (((CTX->FrontMaterial ()).EmissiveColor ()).Blue ());
|
||||
|
||||
MyCGroup.ContextFillArea.Front.EnvReflexion =
|
||||
MyCGroup.ContextFillArea.Front.EnvReflexion =
|
||||
float ((CTX->FrontMaterial ()).EnvReflexion());
|
||||
|
||||
MyCGroup.ContextFillArea.IsDef = 1; // Material definition ok
|
||||
|
||||
Handle(Graphic3d_TextureMap) GroupTextureMap = CTX->TextureMap();
|
||||
if (! GroupTextureMap.IsNull() )
|
||||
MyCGroup.ContextFillArea.Texture.TexId = GroupTextureMap->TextureId();
|
||||
else
|
||||
MyCGroup.ContextFillArea.Texture.TexId = -1;
|
||||
MyCGroup.ContextFillArea.Texture.TextureMap = CTX->TextureMap();
|
||||
MyCGroup.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1 : 0;
|
||||
|
||||
MyCGroup.ContextFillArea.Texture.doTextureMap =
|
||||
CTX->TextureMapState () ? 1 : 0;
|
||||
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
Standard_Integer aPolyMode;
|
||||
Standard_ShortReal aPolyFactor, aPolyUnits;
|
||||
CTX->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits);
|
||||
@ -661,7 +647,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)&
|
||||
Quantity_Color AColor;
|
||||
Aspect_TypeOfStyleText AStyle;
|
||||
Aspect_TypeOfDisplayText ADisplayType;
|
||||
Quantity_Color AColorSubTitle;
|
||||
Quantity_Color AColorSubTitle;
|
||||
Standard_Boolean ATextZoomable;
|
||||
Standard_Real ATextAngle;
|
||||
Font_FontAspect ATextFontAspect;
|
||||
@ -681,9 +667,9 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)&
|
||||
MyCGroup.ContextText.ColorSubTitle.r = float (Rs);
|
||||
MyCGroup.ContextText.ColorSubTitle.g = float (Gs);
|
||||
MyCGroup.ContextText.ColorSubTitle.b = float (Bs);
|
||||
MyCGroup.ContextText.TextZoomable = ATextZoomable;
|
||||
MyCGroup.ContextText.TextAngle = float (ATextAngle);
|
||||
MyCGroup.ContextText.TextFontAspect = (int)ATextFontAspect;
|
||||
MyCGroup.ContextText.TextZoomable = ATextZoomable;
|
||||
MyCGroup.ContextText.TextAngle = float (ATextAngle);
|
||||
MyCGroup.ContextText.TextFontAspect = (int)ATextFontAspect;
|
||||
MyCGroup.ContextText.IsDef = 1;
|
||||
|
||||
int noinsert = 0;
|
||||
@ -703,7 +689,7 @@ Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_Gr
|
||||
case Graphic3d_ASPECT_FILL_AREA: return MyCGroup.ContextFillArea.IsSet;
|
||||
default: return Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF) const {
|
||||
@ -947,19 +933,21 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
|
||||
else
|
||||
CTXF->AllowBackFace ();
|
||||
// Texture
|
||||
// Pb sur les textures
|
||||
//if (MyCGroup.ContextFillArea.Texture.TexId == -1)
|
||||
//else
|
||||
CTXF->SetTextureMap (MyCGroup.ContextFillArea.Texture.TextureMap);
|
||||
if (MyCGroup.ContextFillArea.Texture.doTextureMap == 1)
|
||||
CTXF->SetTextureMapOn ();
|
||||
{
|
||||
CTXF->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
CTXF->SetTextureMapOff ();
|
||||
{
|
||||
CTXF->SetTextureMapOff();
|
||||
}
|
||||
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
CTXF->SetPolygonOffsets(MyCGroup.ContextFillArea.PolygonOffsetMode,
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
CTXF->SetPolygonOffsets(MyCGroup.ContextFillArea.PolygonOffsetMode,
|
||||
MyCGroup.ContextFillArea.PolygonOffsetFactor,
|
||||
MyCGroup.ContextFillArea.PolygonOffsetUnits);
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
}
|
||||
else {
|
||||
// Interior
|
||||
@ -1097,16 +1085,21 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
|
||||
else
|
||||
CTXF->AllowBackFace ();
|
||||
// Texture
|
||||
CTXF->SetTextureMap (MyCGroup.Struct->ContextFillArea.Texture.TextureMap);
|
||||
if (MyCGroup.Struct->ContextFillArea.Texture.doTextureMap == 1)
|
||||
CTXF->SetTextureMapOn ();
|
||||
{
|
||||
CTXF->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
CTXF->SetTextureMapOff ();
|
||||
{
|
||||
CTXF->SetTextureMapOff();
|
||||
}
|
||||
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
CTXF->SetPolygonOffsets(MyCGroup.Struct->ContextFillArea.PolygonOffsetMode,
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
CTXF->SetPolygonOffsets(MyCGroup.Struct->ContextFillArea.PolygonOffsetMode,
|
||||
MyCGroup.Struct->ContextFillArea.PolygonOffsetFactor,
|
||||
MyCGroup.Struct->ContextFillArea.PolygonOffsetUnits);
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
}
|
||||
CTXF->SetInteriorStyle (AStyle);
|
||||
CTXF->SetInteriorColor (AnIntColor);
|
||||
|
@ -971,16 +971,13 @@ is
|
||||
---Purpose: Updates the c structure associated to <me>.
|
||||
---Category: Private methods
|
||||
|
||||
CStructure ( me )
|
||||
returns Address from Standard
|
||||
CStructure ( me : mutable )
|
||||
returns CStructure from Graphic3d
|
||||
is static;
|
||||
---Level: Internal
|
||||
---Purpose: Returns the c structure associated to <me>.
|
||||
---Category: Private methods
|
||||
|
||||
--
|
||||
|
||||
--
|
||||
---C++: return *
|
||||
|
||||
fields
|
||||
|
||||
|
@ -742,18 +742,14 @@ void Graphic3d_Structure::GraphicClear (const Standard_Boolean WithDestruction)
|
||||
}
|
||||
}
|
||||
|
||||
void Graphic3d_Structure::GraphicConnect (const Handle(Graphic3d_Structure)& ADaughter) {
|
||||
|
||||
MyGraphicDriver->Connect
|
||||
(MyCStructure, *((CALL_DEF_STRUCTURE *)ADaughter->CStructure()));
|
||||
|
||||
void Graphic3d_Structure::GraphicConnect (const Handle(Graphic3d_Structure)& theDaughter)
|
||||
{
|
||||
MyGraphicDriver->Connect (MyCStructure, theDaughter->MyCStructure);
|
||||
}
|
||||
|
||||
void Graphic3d_Structure::GraphicDisconnect (const Handle(Graphic3d_Structure)& ADaughter) {
|
||||
|
||||
MyGraphicDriver->Disconnect
|
||||
(MyCStructure, *((CALL_DEF_STRUCTURE *)ADaughter->CStructure()));
|
||||
|
||||
void Graphic3d_Structure::GraphicDisconnect (const Handle(Graphic3d_Structure)& theDaughter)
|
||||
{
|
||||
MyGraphicDriver->Disconnect (MyCStructure, theDaughter->MyCStructure);
|
||||
}
|
||||
|
||||
Handle(Graphic3d_AspectLine3d) Graphic3d_Structure::Line3dAspect () const {
|
||||
@ -996,13 +992,15 @@ Graphic3d_MATERIAL_PHYSIC : Graphic3d_MATERIAL_ASPECT;
|
||||
else
|
||||
CTXF->AllowBackFace ();
|
||||
// Texture
|
||||
// Pb sur les textures
|
||||
//if (MyCStructure.ContextFillArea.Texture.TexId == -1)
|
||||
//else
|
||||
CTXF->SetTextureMap (MyCStructure.ContextFillArea.Texture.TextureMap);
|
||||
if (MyCStructure.ContextFillArea.Texture.doTextureMap == 1)
|
||||
CTXF->SetTextureMapOn ();
|
||||
{
|
||||
CTXF->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
CTXF->SetTextureMapOff ();
|
||||
{
|
||||
CTXF->SetTextureMapOff();
|
||||
}
|
||||
#ifdef G003
|
||||
Aspect_TypeOfDegenerateModel dMode = Aspect_TypeOfDegenerateModel(
|
||||
MyCStructure.ContextFillArea.DegenerationMode);
|
||||
@ -1245,13 +1243,8 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectFill
|
||||
|
||||
MyCStructure.ContextFillArea.IsDef = 1; // Definition material ok
|
||||
|
||||
Handle(Graphic3d_TextureMap) TempTextureMap = CTX->TextureMap();
|
||||
if (! TempTextureMap.IsNull() )
|
||||
MyCStructure.ContextFillArea.Texture.TexId = TempTextureMap->TextureId();
|
||||
else
|
||||
MyCStructure.ContextFillArea.Texture.TexId = -1;
|
||||
|
||||
MyCStructure.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1:0;
|
||||
MyCStructure.ContextFillArea.Texture.TextureMap = CTX->TextureMap();
|
||||
MyCStructure.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1 : 0;
|
||||
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
Standard_Integer aPolyMode;
|
||||
@ -2322,13 +2315,8 @@ void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)&
|
||||
MyCStructure.ContextFillArea.Front.EnvReflexion =
|
||||
float ((CTXF->FrontMaterial ()).EnvReflexion());
|
||||
|
||||
Handle(Graphic3d_TextureMap) TempTextureMap = CTXF->TextureMap();
|
||||
if (! TempTextureMap.IsNull() )
|
||||
MyCStructure.ContextFillArea.Texture.TexId = TempTextureMap->TextureId();
|
||||
else
|
||||
MyCStructure.ContextFillArea.Texture.TexId = -1;
|
||||
|
||||
MyCStructure.ContextFillArea.Texture.doTextureMap = CTXF->TextureMapState() ? 1:0;
|
||||
MyCStructure.ContextFillArea.Texture.TextureMap = CTXF->TextureMap();
|
||||
MyCStructure.ContextFillArea.Texture.doTextureMap = CTXF->TextureMapState() ? 1 : 0;
|
||||
|
||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||
Standard_Integer aPolyMode;
|
||||
@ -2517,10 +2505,14 @@ Standard_Boolean Graphic3d_Structure::HLRValidation () const {
|
||||
|
||||
}
|
||||
|
||||
Standard_Address Graphic3d_Structure::CStructure () const {
|
||||
|
||||
return Standard_Address (&MyCStructure);
|
||||
//=======================================================================
|
||||
//function : CStructure
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Graphic3d_CStructure* Graphic3d_Structure::CStructure()
|
||||
{
|
||||
return &MyCStructure;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -18,57 +18,51 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
-- Modified : GG 10/01/2000 IMP
|
||||
-- Add NumberOfTextures() and TextureName() methods
|
||||
-- Add Name(),IsSmoothed() and ISModulate() methods
|
||||
-- GG IMP140300
|
||||
-- Add Repeat methods.
|
||||
deferred class Texture1D from Graphic3d
|
||||
|
||||
deferred class Texture1D from Graphic3d
|
||||
|
||||
inherits TextureMap from Graphic3d
|
||||
inherits TextureMap from Graphic3d
|
||||
|
||||
|
||||
---Purpose: This is an abstract class for managing 1D textures.
|
||||
---Purpose: This is an abstract class for managing 1D textures.
|
||||
|
||||
uses
|
||||
TypeOfTexture from Graphic3d,
|
||||
NameOfTexture1D from Graphic3d,
|
||||
StructureManager from Graphic3d
|
||||
uses
|
||||
|
||||
TypeOfTexture from Graphic3d,
|
||||
NameOfTexture1D from Graphic3d,
|
||||
AsciiString from TCollection
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
Initialize(SM : StructureManager from Graphic3d;
|
||||
aFileName: CString from Standard;
|
||||
aType : TypeOfTexture from Graphic3d);
|
||||
|
||||
Initialize(SM : StructureManager from Graphic3d;
|
||||
aName : NameOfTexture1D from Graphic3d;
|
||||
aType : TypeOfTexture from Graphic3d);
|
||||
|
||||
OutOfRange from Standard
|
||||
|
||||
Name(me) returns NameOfTexture1D from Graphic3d;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined textures or NOT_1D_UNKNOWN
|
||||
-- when the name is given as a filename.
|
||||
---Level: Public
|
||||
is
|
||||
|
||||
NumberOfTextures(myclass) returns Integer from Standard;
|
||||
---Purpose:
|
||||
-- Returns the number of predefined textures.
|
||||
---Level: Public
|
||||
Initialize (theFileName : AsciiString from TCollection;
|
||||
theType : TypeOfTexture from Graphic3d);
|
||||
|
||||
TextureName(myclass; aRank: Integer from Standard)
|
||||
returns CString from Standard
|
||||
raises OutOfRange from Standard;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined texture of rank <aRank>
|
||||
---Trigger: when <aRank> is < 1 or > NumberOfTextures.
|
||||
---Level: Public
|
||||
Initialize (theName : NameOfTexture1D from Graphic3d;
|
||||
theType : TypeOfTexture from Graphic3d);
|
||||
|
||||
Name (me) returns NameOfTexture1D from Graphic3d;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined textures or NOT_1D_UNKNOWN
|
||||
-- when the name is given as a filename.
|
||||
---Level: Public
|
||||
|
||||
NumberOfTextures (myclass) returns Integer from Standard;
|
||||
---Purpose:
|
||||
-- Returns the number of predefined textures.
|
||||
---Level: Public
|
||||
|
||||
TextureName (myclass; aRank: Integer from Standard)
|
||||
returns AsciiString from TCollection
|
||||
raises OutOfRange from Standard;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined texture of rank <aRank>
|
||||
---Trigger: when <aRank> is < 1 or > NumberOfTextures.
|
||||
---Level: Public
|
||||
|
||||
fields
|
||||
myName: NameOfTexture1D from Graphic3d;
|
||||
|
||||
end Texture1D;
|
||||
myName : NameOfTexture1D from Graphic3d;
|
||||
|
||||
end Texture1D;
|
||||
|
@ -18,106 +18,69 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
// Modified 22-12-97 : FMN ; Ajout Modulate
|
||||
|
||||
// Modified : GG 10/01/2000 IMP
|
||||
// Adds Name(),NumberOfTextures() and TextureName() methods
|
||||
|
||||
#include <Graphic3d_Texture1D.ixx>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
|
||||
static const char *NameOfTexture_to_FileName[] =
|
||||
static const char *NameOfTexture_to_FileName[] =
|
||||
{
|
||||
"1d_elevation.rgb"
|
||||
};
|
||||
|
||||
|
||||
static TCollection_AsciiString GetEnvir ( ) {
|
||||
|
||||
static Standard_Boolean IsDefined=Standard_False ;
|
||||
static TCollection_AsciiString VarName;
|
||||
if ( !IsDefined ) {
|
||||
char *envir, *casroot ;
|
||||
envir = getenv("CSF_MDTVTexturesDirectory") ;
|
||||
|
||||
Standard_Boolean HasDefinition = Standard_False ;
|
||||
if ( !envir ) {
|
||||
casroot = getenv("CASROOT");
|
||||
if ( casroot ) {
|
||||
VarName = TCollection_AsciiString (casroot);
|
||||
VarName += "/src/Textures" ;
|
||||
HasDefinition = Standard_True ;
|
||||
}
|
||||
} else {
|
||||
VarName = TCollection_AsciiString (envir);
|
||||
HasDefinition = Standard_True ;
|
||||
}
|
||||
if ( HasDefinition ) {
|
||||
OSD_Path aPath ( VarName );
|
||||
OSD_Directory aDir(aPath);
|
||||
if ( aDir.Exists () ) {
|
||||
TCollection_AsciiString aTexture = VarName + "/2d_MatraDatavision.rgb" ;
|
||||
OSD_File TextureFile ( aTexture );
|
||||
if ( !TextureFile.Exists() ) {
|
||||
cout << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << endl;
|
||||
cout << " not all files are found in : "<<VarName.ToCString() << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory or CASROOT not correctly setted " );
|
||||
}
|
||||
} else {
|
||||
cout << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << endl;
|
||||
cout << " Directory : "<< VarName.ToCString() << " not exist " << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory or CASROOT not correctly setted " );
|
||||
}
|
||||
return VarName ;
|
||||
} else {
|
||||
cout << " CSF_MDTVTexturesDirectory and CASROOT not setted " << endl;
|
||||
cout << " one of these variable are mandatory to use this fonctionnality" << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory and CASROOT not setted " );
|
||||
|
||||
}
|
||||
IsDefined = Standard_True ;
|
||||
}
|
||||
return VarName ;
|
||||
}
|
||||
|
||||
Graphic3d_Texture1D::Graphic3d_Texture1D(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString FileName,const Graphic3d_TypeOfTexture Type)
|
||||
: Graphic3d_TextureMap(SM,"", FileName, Type),
|
||||
myName(Graphic3d_NOT_1D_UNKNOWN)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture1D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1D::Graphic3d_Texture1D (const TCollection_AsciiString& theFileName,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
: Graphic3d_TextureMap (theFileName, theType),
|
||||
myName (Graphic3d_NOT_1D_UNKNOWN)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Graphic3d_Texture1D::Graphic3d_Texture1D(const Handle(Graphic3d_StructureManager)& SM,const Graphic3d_NameOfTexture1D NOT, const Graphic3d_TypeOfTexture Type)
|
||||
: Graphic3d_TextureMap(SM, GetEnvir().ToCString(), NameOfTexture_to_FileName[NOT], Type),
|
||||
myName(NOT)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture1D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1D::Graphic3d_Texture1D (const Graphic3d_NameOfTexture1D theNOT,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
: Graphic3d_TextureMap (NameOfTexture_to_FileName[theNOT], theType),
|
||||
myName (theNOT)
|
||||
{
|
||||
myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
|
||||
myTexId = TCollection_AsciiString ("Graphic3d_Texture1D_")
|
||||
+ NameOfTexture_to_FileName[theNOT];
|
||||
}
|
||||
|
||||
Graphic3d_NameOfTexture1D Graphic3d_Texture1D::Name() const {
|
||||
|
||||
// =======================================================================
|
||||
// function : Name
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_NameOfTexture1D Graphic3d_Texture1D::Name() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
Standard_Integer Graphic3d_Texture1D::NumberOfTextures() {
|
||||
|
||||
// =======================================================================
|
||||
// function : NumberOfTextures
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Graphic3d_Texture1D::NumberOfTextures()
|
||||
{
|
||||
return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
|
||||
}
|
||||
|
||||
Standard_CString Graphic3d_Texture1D::TextureName(const Standard_Integer aRank)
|
||||
{
|
||||
// =======================================================================
|
||||
// function : TextureName
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Graphic3d_Texture1D::TextureName (const Standard_Integer theRank)
|
||||
{
|
||||
if (theRank < 1 || theRank > NumberOfTextures())
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD index of texture");
|
||||
}
|
||||
|
||||
if( aRank < 1 || aRank > NumberOfTextures() )
|
||||
Standard_OutOfRange::Raise(" BAD index of texture");
|
||||
TCollection_AsciiString filename(NameOfTexture_to_FileName[aRank-1]);
|
||||
Standard_Integer i = filename.SearchFromEnd(".");
|
||||
|
||||
static TCollection_AsciiString name;
|
||||
name = filename.SubString(4,i-1);
|
||||
return name.ToCString();
|
||||
TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
|
||||
Standard_Integer i = aFileName.SearchFromEnd (".");
|
||||
return aFileName.SubString (4, i - 1);
|
||||
}
|
||||
|
||||
|
@ -18,31 +18,24 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
class Texture1Dmanual from Graphic3d
|
||||
|
||||
class Texture1Dmanual from Graphic3d
|
||||
inherits Texture1D from Graphic3d
|
||||
|
||||
inherits Texture1D from Graphic3d
|
||||
|
||||
---Purpose: This class provides the implementation of
|
||||
-- a manual 1D texture.
|
||||
-- you MUST provides texture coordinates on
|
||||
-- your facets if you want to see your
|
||||
-- texture.
|
||||
---Purpose: This class provides the implementation of a manual 1D texture.
|
||||
-- you MUST provides texture coordinates on your facets if you want to see your texture.
|
||||
|
||||
uses
|
||||
|
||||
uses
|
||||
NameOfTexture1D from Graphic3d,
|
||||
StructureManager from Graphic3d
|
||||
NameOfTexture1D from Graphic3d,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
Create(SM : StructureManager from Graphic3d;
|
||||
FileName : CString from Standard) returns mutable Texture1Dmanual from Graphic3d;
|
||||
---Purpose: Creates a texture from the file FileName.
|
||||
is
|
||||
|
||||
Create (theFileName : AsciiString from TCollection) returns mutable Texture1Dmanual from Graphic3d;
|
||||
---Purpose: Creates a texture from the file FileName.
|
||||
|
||||
Create(SM : StructureManager from Graphic3d;
|
||||
NOT : NameOfTexture1D from Graphic3d) returns mutable Texture1Dmanual from Graphic3d;
|
||||
---Purpose: Create a texture from a predefined texture name set.
|
||||
|
||||
end Texture1Dmanual;
|
||||
Create (theNOT : NameOfTexture1D from Graphic3d) returns mutable Texture1Dmanual from Graphic3d;
|
||||
---Purpose: Create a texture from a predefined texture name set.
|
||||
|
||||
end Texture1Dmanual;
|
||||
|
@ -18,54 +18,25 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
|
||||
#include <Graphic3d_Texture1Dmanual.ixx>
|
||||
#include <Graphic3d_TypeOfTextureMode.hxx>
|
||||
|
||||
Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString FileName)
|
||||
: Graphic3d_Texture1D(SM, FileName, Graphic3d_TOT_1D)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture1Dmanual
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_Texture1D (theFileName, Graphic3d_TOT_1D)
|
||||
{
|
||||
MyCInitTexture.doModulate = 0;
|
||||
MyCInitTexture.doRepeat = 0;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_MANUAL;
|
||||
MyCInitTexture.doLinear = 0;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual(const Handle(Graphic3d_StructureManager)& SM,const Graphic3d_NameOfTexture1D NOT)
|
||||
: Graphic3d_Texture1D(SM, NOT, Graphic3d_TOT_1D)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture1Dmanual
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual (const Graphic3d_NameOfTexture1D theNOT)
|
||||
: Graphic3d_Texture1D (theNOT, Graphic3d_TOT_1D)
|
||||
{
|
||||
MyCInitTexture.doModulate = 0;
|
||||
MyCInitTexture.doRepeat = 0;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_MANUAL;
|
||||
MyCInitTexture.doLinear = 0;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
//
|
||||
}
|
||||
|
@ -18,50 +18,46 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
class Texture1Dsegment from Graphic3d
|
||||
|
||||
class Texture1Dsegment from Graphic3d
|
||||
|
||||
inherits Texture1D from Graphic3d
|
||||
inherits Texture1D from Graphic3d
|
||||
|
||||
|
||||
---Purpose: This class provides the implementation
|
||||
-- of a 1D texture applyable along a segment.
|
||||
-- You might use the SetSegment() method
|
||||
-- to set the way the texture is "streched" on facets.
|
||||
---Purpose: This class provides the implementation
|
||||
-- of a 1D texture applyable along a segment.
|
||||
-- You might use the SetSegment() method
|
||||
-- to set the way the texture is "streched" on facets.
|
||||
|
||||
uses
|
||||
|
||||
uses
|
||||
NameOfTexture1D from Graphic3d,
|
||||
StructureManager from Graphic3d
|
||||
NameOfTexture1D from Graphic3d,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
Create(VM : StructureManager from Graphic3d;
|
||||
FileName : CString from Standard) returns mutable Texture1Dsegment from Graphic3d;
|
||||
---Purpose: Creates a texture from a file
|
||||
is
|
||||
|
||||
Create (theFileName : AsciiString from TCollection) returns mutable Texture1Dsegment from Graphic3d;
|
||||
---Purpose: Creates a texture from a file
|
||||
|
||||
Create(VM : StructureManager from Graphic3d;
|
||||
NOT : NameOfTexture1D from Graphic3d) returns mutable Texture1Dsegment from Graphic3d;
|
||||
---Purpose: Creates a texture from a predefined texture name set.
|
||||
|
||||
SetSegment(me : mutable;
|
||||
X1,Y1,Z1 : ShortReal from Standard;
|
||||
X2,Y2,Z2 : ShortReal from Standard);
|
||||
---Purpose: Sets the texture application bounds. Defines the way
|
||||
-- the texture is stretched across facets.
|
||||
-- Default values are <0.0, 0.0, 0.0> , <0.0, 0.0, 1.0>
|
||||
Create (theNOT : NameOfTexture1D from Graphic3d) returns mutable Texture1Dsegment from Graphic3d;
|
||||
---Purpose: Creates a texture from a predefined texture name set.
|
||||
|
||||
|
||||
--
|
||||
-- inquire methods
|
||||
--
|
||||
Segment(me;
|
||||
X1,Y1,Z1, X2,Y2,Z2 : out ShortReal from Standard);
|
||||
---Purpose: Returns the values of the current segment X1, Y1, Z1 , X2, Y2, Z2.
|
||||
|
||||
fields
|
||||
MyX1,MyY1,MyZ1 : ShortReal from Standard;
|
||||
MyX2,MyY2,MyZ2 : ShortReal from Standard;
|
||||
SetSegment (me : mutable;
|
||||
theX1, theY1, theZ1 : ShortReal from Standard;
|
||||
theX2, theY2, theZ2 : ShortReal from Standard);
|
||||
---Purpose: Sets the texture application bounds. Defines the way
|
||||
-- the texture is stretched across facets.
|
||||
-- Default values are <0.0, 0.0, 0.0> , <0.0, 0.0, 1.0>
|
||||
|
||||
--
|
||||
-- inquire methods
|
||||
--
|
||||
Segment (me;
|
||||
theX1, theY1, theZ1 : out ShortReal from Standard;
|
||||
theX2, theY2, theZ2 : out ShortReal from Standard);
|
||||
---Purpose: Returns the values of the current segment X1, Y1, Z1 , X2, Y2, Z2.
|
||||
|
||||
fields
|
||||
|
||||
myX1, myY1, myZ1 : ShortReal from Standard;
|
||||
myX2, myY2, myZ2 : ShortReal from Standard;
|
||||
|
||||
end Texture1Dsegment;
|
||||
|
||||
end Texture1Dsegment;
|
||||
|
@ -18,96 +18,97 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <Graphic3d_Texture1Dsegment.ixx>
|
||||
#include <Graphic3d_TypeOfTextureMode.hxx>
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
|
||||
|
||||
Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString FileName)
|
||||
: Graphic3d_Texture1D(SM, FileName, Graphic3d_TOT_1D)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture1Dsegment
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_Texture1D (theFileName, Graphic3d_TOT_1D),
|
||||
myX1 (0.0f),
|
||||
myY1 (0.0f),
|
||||
myZ1 (0.0f),
|
||||
myX2 (0.0f),
|
||||
myY2 (0.0f),
|
||||
myZ2 (0.0f)
|
||||
{
|
||||
MyCInitTexture.doModulate = 0;
|
||||
MyCInitTexture.doRepeat = 1;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_OBJECT;
|
||||
MyCInitTexture.doLinear = 0;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 1.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment(const Handle(Graphic3d_StructureManager)& SM,const Graphic3d_NameOfTexture1D NOT)
|
||||
: Graphic3d_Texture1D(SM, NOT, Graphic3d_TOT_1D)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture1Dsegment
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const Graphic3d_NameOfTexture1D theNOT)
|
||||
: Graphic3d_Texture1D (theNOT, Graphic3d_TOT_1D),
|
||||
myX1 (0.0f),
|
||||
myY1 (0.0f),
|
||||
myZ1 (0.0f),
|
||||
myX2 (0.0f),
|
||||
myY2 (0.0f),
|
||||
myZ2 (0.0f)
|
||||
{
|
||||
MyCInitTexture.doModulate = 0;
|
||||
MyCInitTexture.doRepeat = 1;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_OBJECT;
|
||||
MyCInitTexture.doLinear = 0;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 1.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture1Dsegment::SetSegment(const Standard_ShortReal X1,const Standard_ShortReal Y1,const Standard_ShortReal Z1,const Standard_ShortReal X2,const Standard_ShortReal Y2,const Standard_ShortReal Z2)
|
||||
// =======================================================================
|
||||
// function : SetSegment
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture1Dsegment::SetSegment (const Standard_ShortReal X1,
|
||||
const Standard_ShortReal Y1,
|
||||
const Standard_ShortReal Z1,
|
||||
const Standard_ShortReal X2,
|
||||
const Standard_ShortReal Y2,
|
||||
const Standard_ShortReal Z2)
|
||||
{
|
||||
Standard_ShortReal sq_norme;
|
||||
myX1 = X1;
|
||||
myY1 = Y1;
|
||||
myZ1 = Z1;
|
||||
myX2 = X2;
|
||||
myY2 = Y2;
|
||||
myZ2 = Z2;
|
||||
Graphic3d_Vec4 aPlaneX (X2 - X1, Y2 - Y1, Z2 - Z1, 0.0f);
|
||||
|
||||
MyX1 = X1;
|
||||
MyY1 = Y1;
|
||||
MyZ1 = Z1;
|
||||
MyX2 = X2;
|
||||
MyY2 = Y2;
|
||||
MyZ2 = Z2;
|
||||
Standard_ShortReal aSqNorm = aPlaneX.x() * aPlaneX.x()
|
||||
+ aPlaneX.y() * aPlaneX.y()
|
||||
+ aPlaneX.z() * aPlaneX.z();
|
||||
aPlaneX.x() /= aSqNorm;
|
||||
aPlaneX.y() /= aSqNorm;
|
||||
aPlaneX.z() /= aSqNorm;
|
||||
aPlaneX.w() = -aPlaneX.x() * X1
|
||||
-aPlaneX.y() * Y1
|
||||
-aPlaneX.z() * Z1;
|
||||
|
||||
MyCInitTexture.sparams[0] = X2-X1;
|
||||
MyCInitTexture.sparams[1] = Y2-Y1;
|
||||
MyCInitTexture.sparams[2] = Z2-Z1;
|
||||
sq_norme = MyCInitTexture.sparams[0]*MyCInitTexture.sparams[0]
|
||||
+ MyCInitTexture.sparams[1]*MyCInitTexture.sparams[1]
|
||||
+ MyCInitTexture.sparams[2]*MyCInitTexture.sparams[2];
|
||||
|
||||
MyCInitTexture.sparams[0] /= sq_norme;
|
||||
MyCInitTexture.sparams[1] /= sq_norme;
|
||||
MyCInitTexture.sparams[2] /= sq_norme;
|
||||
|
||||
MyCInitTexture.sparams[3] = - MyCInitTexture.sparams[0]*X1
|
||||
- MyCInitTexture.sparams[1]*Y1
|
||||
- MyCInitTexture.sparams[2]*Z1;
|
||||
|
||||
Update();
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
aPlaneX,
|
||||
Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Graphic3d_Texture1Dsegment::Segment(Standard_ShortReal& X1,Standard_ShortReal& Y1,Standard_ShortReal& Z1,Standard_ShortReal& X2,Standard_ShortReal& Y2,Standard_ShortReal& Z2) const
|
||||
// =======================================================================
|
||||
// function : Segment
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture1Dsegment::Segment (Standard_ShortReal& X1,
|
||||
Standard_ShortReal& Y1,
|
||||
Standard_ShortReal& Z1,
|
||||
Standard_ShortReal& X2,
|
||||
Standard_ShortReal& Y2,
|
||||
Standard_ShortReal& Z2) const
|
||||
{
|
||||
X1 = MyX1;
|
||||
Y1 = MyY1;
|
||||
Z1 = MyZ1;
|
||||
X2 = MyX2;
|
||||
Y2 = MyY2;
|
||||
Z2 = MyZ2;
|
||||
X1 = myX1;
|
||||
Y1 = myY1;
|
||||
Z1 = myZ1;
|
||||
X2 = myX2;
|
||||
Y2 = myY2;
|
||||
Z2 = myZ2;
|
||||
}
|
||||
|
@ -18,55 +18,50 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
-- Modified : GG 10/01/2000 IMP
|
||||
-- Add NumberOfTextures() and TextureName() methods
|
||||
-- Add Name() and IsRepeat() method
|
||||
deferred class Texture2D from Graphic3d
|
||||
|
||||
deferred class Texture2D from Graphic3d
|
||||
|
||||
inherits TextureMap from Graphic3d
|
||||
inherits TextureMap from Graphic3d
|
||||
|
||||
---Purpose: This abstract class for managing 2D textures
|
||||
---Purpose: This abstract class for managing 2D textures
|
||||
|
||||
uses
|
||||
TypeOfTexture from Graphic3d,
|
||||
NameOfTexture2D from Graphic3d,
|
||||
StructureManager from Graphic3d
|
||||
uses
|
||||
|
||||
TypeOfTexture from Graphic3d,
|
||||
NameOfTexture2D from Graphic3d,
|
||||
AsciiString from TCollection
|
||||
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
Initialize(SM : StructureManager from Graphic3d;
|
||||
aFileName : CString from Standard;
|
||||
aType : TypeOfTexture from Graphic3d);
|
||||
|
||||
Initialize(SM : StructureManager from Graphic3d;
|
||||
aName : NameOfTexture2D from Graphic3d;
|
||||
aType : TypeOfTexture from Graphic3d);
|
||||
|
||||
Name(me) returns NameOfTexture2D from Graphic3d;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined textures or NOT_2D_UNKNOWN
|
||||
-- when the name is given as a filename.
|
||||
---Level: Public
|
||||
OutOfRange from Standard
|
||||
|
||||
NumberOfTextures(myclass) returns Integer from Standard;
|
||||
---Purpose:
|
||||
-- Returns the number of predefined textures.
|
||||
---Level: Public
|
||||
is
|
||||
|
||||
TextureName(myclass; aRank: Integer from Standard)
|
||||
returns CString from Standard
|
||||
raises OutOfRange from Standard;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined texture of rank <aRank>
|
||||
---Trigger: when <aRank> is < 1 or > NumberOfTextures.
|
||||
---Level: Public
|
||||
Initialize (theFileName : AsciiString from TCollection;
|
||||
theType : TypeOfTexture from Graphic3d);
|
||||
|
||||
Initialize (theName : NameOfTexture2D from Graphic3d;
|
||||
theType : TypeOfTexture from Graphic3d);
|
||||
|
||||
Name (me) returns NameOfTexture2D from Graphic3d;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined textures or NOT_2D_UNKNOWN
|
||||
-- when the name is given as a filename.
|
||||
---Level: Public
|
||||
|
||||
NumberOfTextures (myclass) returns Integer from Standard;
|
||||
---Purpose:
|
||||
-- Returns the number of predefined textures.
|
||||
---Level: Public
|
||||
|
||||
TextureName (myclass; theRank: Integer from Standard) returns AsciiString from TCollection
|
||||
raises OutOfRange from Standard;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined texture of rank <aRank>
|
||||
---Trigger: when <aRank> is < 1 or > NumberOfTextures.
|
||||
---Level: Public
|
||||
|
||||
fields
|
||||
myName: NameOfTexture2D from Graphic3d;
|
||||
|
||||
end Texture2D;
|
||||
myName : NameOfTexture2D from Graphic3d;
|
||||
|
||||
end Texture2D;
|
||||
|
@ -18,69 +18,8 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
// Modified : GG 10/01/2000 IMP
|
||||
// Adds Name(),NumberOfTextures() and TextureName() methods
|
||||
|
||||
|
||||
|
||||
#include <Graphic3d_Texture2D.ixx>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
|
||||
static TCollection_AsciiString GetEnvir ( ) {
|
||||
|
||||
static Standard_Boolean IsDefined=Standard_False ;
|
||||
static TCollection_AsciiString VarName;
|
||||
if ( !IsDefined ) {
|
||||
char *envir, *casroot ;
|
||||
envir = getenv("CSF_MDTVTexturesDirectory") ;
|
||||
|
||||
Standard_Boolean HasDefinition = Standard_False ;
|
||||
if ( !envir ) {
|
||||
casroot = getenv("CASROOT");
|
||||
if ( casroot ) {
|
||||
VarName = TCollection_AsciiString (casroot);
|
||||
VarName += "/src/Textures" ;
|
||||
HasDefinition = Standard_True ;
|
||||
}
|
||||
} else {
|
||||
VarName = TCollection_AsciiString (envir);
|
||||
HasDefinition = Standard_True ;
|
||||
}
|
||||
if ( HasDefinition ) {
|
||||
OSD_Path aPath ( VarName );
|
||||
OSD_Directory aDir(aPath);
|
||||
if ( aDir.Exists () ) {
|
||||
TCollection_AsciiString aTexture = VarName + "/2d_MatraDatavision.rgb" ;
|
||||
OSD_File TextureFile ( aTexture );
|
||||
if ( !TextureFile.Exists() ) {
|
||||
cout << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << endl;
|
||||
cout << " not all files are found in : "<<VarName.ToCString() << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory or CASROOT not correctly setted " );
|
||||
}
|
||||
} else {
|
||||
cout << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << endl;
|
||||
cout << " Directory : "<< VarName.ToCString() << " not exist " << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory or CASROOT not correctly setted " );
|
||||
}
|
||||
return VarName ;
|
||||
} else {
|
||||
cout << " CSF_MDTVTexturesDirectory and CASROOT not setted " << endl;
|
||||
cout << " one of these variable are mandatory to use this fonctionnality" << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory and CASROOT not setted " );
|
||||
}
|
||||
IsDefined = Standard_True ;
|
||||
}
|
||||
return VarName ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char *NameOfTexture_to_FileName[] =
|
||||
{
|
||||
@ -107,40 +46,61 @@ static const char *NameOfTexture_to_FileName[] =
|
||||
"2d_rain.rgb"
|
||||
};
|
||||
|
||||
|
||||
Graphic3d_Texture2D::Graphic3d_Texture2D(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString FileName,const Graphic3d_TypeOfTexture Type)
|
||||
: Graphic3d_TextureMap(SM, "", FileName, Type),
|
||||
myName(Graphic3d_NOT_2D_UNKNOWN)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2D::Graphic3d_Texture2D (const TCollection_AsciiString& theFileName,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
: Graphic3d_TextureMap (theFileName, theType),
|
||||
myName (Graphic3d_NOT_2D_UNKNOWN)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Graphic3d_Texture2D::Graphic3d_Texture2D(const Handle(Graphic3d_StructureManager)& SM,const Graphic3d_NameOfTexture2D NOT, const Graphic3d_TypeOfTexture Type)
|
||||
: Graphic3d_TextureMap(SM, GetEnvir().ToCString() , NameOfTexture_to_FileName[NOT], Type),
|
||||
myName(NOT)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2D::Graphic3d_Texture2D (const Graphic3d_NameOfTexture2D theNOT,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
: Graphic3d_TextureMap (NameOfTexture_to_FileName[theNOT], theType),
|
||||
myName (theNOT)
|
||||
{
|
||||
myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
|
||||
myTexId = TCollection_AsciiString ("Graphic3d_Texture2D_")
|
||||
+ NameOfTexture_to_FileName[theNOT];
|
||||
}
|
||||
|
||||
Standard_Integer Graphic3d_Texture2D::NumberOfTextures() {
|
||||
|
||||
// =======================================================================
|
||||
// function : NumberOfTextures
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Graphic3d_Texture2D::NumberOfTextures()
|
||||
{
|
||||
return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
|
||||
}
|
||||
|
||||
Graphic3d_NameOfTexture2D Graphic3d_Texture2D::Name() const {
|
||||
|
||||
// =======================================================================
|
||||
// function : Name
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_NameOfTexture2D Graphic3d_Texture2D::Name() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
Standard_CString Graphic3d_Texture2D::TextureName(const Standard_Integer aRank)
|
||||
{
|
||||
// =======================================================================
|
||||
// function : TextureName
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Graphic3d_Texture2D::TextureName (const Standard_Integer theRank)
|
||||
{
|
||||
if (theRank < 1 || theRank > NumberOfTextures())
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD index of texture");
|
||||
}
|
||||
|
||||
if( aRank < 1 || aRank > NumberOfTextures() )
|
||||
Standard_OutOfRange::Raise(" BAD index of texture");
|
||||
TCollection_AsciiString filename(NameOfTexture_to_FileName[aRank-1]);
|
||||
Standard_Integer i = filename.SearchFromEnd(".");
|
||||
|
||||
static TCollection_AsciiString name;
|
||||
|
||||
name = filename.SubString(4,i-1);
|
||||
return name.ToCString();
|
||||
TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
|
||||
Standard_Integer i = aFileName.SearchFromEnd (".");
|
||||
return aFileName.SubString (4, i - 1);
|
||||
}
|
||||
|
@ -18,27 +18,25 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
class Texture2Dmanual from Graphic3d
|
||||
|
||||
class Texture2Dmanual from Graphic3d
|
||||
inherits Texture2D from Graphic3d
|
||||
|
||||
|
||||
inherits Texture2D from Graphic3d
|
||||
---Purpose: This class defined a manual texture 2D
|
||||
-- facets MUST define texture coordinate
|
||||
-- if you want to see somethings on.
|
||||
---Purpose: This class defined a manual texture 2D
|
||||
-- facets MUST define texture coordinate
|
||||
-- if you want to see somethings on.
|
||||
|
||||
uses
|
||||
NameOfTexture2D from Graphic3d,
|
||||
StructureManager from Graphic3d
|
||||
uses
|
||||
|
||||
NameOfTexture2D from Graphic3d,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
Create(SM : StructureManager from Graphic3d;
|
||||
FileName : CString from Standard) returns mutable Texture2Dmanual from Graphic3d;
|
||||
---Purpose: Creates a texture from a file
|
||||
|
||||
Create(SM : StructureManager from Graphic3d;
|
||||
NOT : NameOfTexture2D from Graphic3d) returns mutable Texture2Dmanual from Graphic3d;
|
||||
---Purpose: Creates a texture from a predefined texture name set.
|
||||
|
||||
end Texture2Dmanual;
|
||||
is
|
||||
|
||||
Create (theFileName : AsciiString from TCollection) returns mutable Texture2Dmanual from Graphic3d;
|
||||
---Purpose: Creates a texture from a file
|
||||
|
||||
Create (theNOT : NameOfTexture2D from Graphic3d) returns mutable Texture2Dmanual from Graphic3d;
|
||||
---Purpose: Creates a texture from a predefined texture name set.
|
||||
|
||||
end Texture2Dmanual;
|
||||
|
@ -18,56 +18,30 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
|
||||
#include <Graphic3d_Texture2Dmanual.ixx>
|
||||
#include <Graphic3d_TypeOfTextureMode.hxx>
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
|
||||
|
||||
Graphic3d_Texture2Dmanual::Graphic3d_Texture2Dmanual(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString FileName)
|
||||
: Graphic3d_Texture2D(SM, FileName, Graphic3d_TOT_2D_MIPMAP)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2Dmanual
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dmanual::Graphic3d_Texture2Dmanual (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_Texture2D (theFileName, Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
MyCInitTexture.doModulate = 1;
|
||||
MyCInitTexture.doRepeat = 1;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_MANUAL;
|
||||
MyCInitTexture.doLinear = 1;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
|
||||
Graphic3d_Texture2Dmanual::Graphic3d_Texture2Dmanual(const Handle(Graphic3d_StructureManager)& SM,const Graphic3d_NameOfTexture2D NOT)
|
||||
: Graphic3d_Texture2D(SM, NOT, Graphic3d_TOT_2D_MIPMAP)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2Dmanual
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dmanual::Graphic3d_Texture2Dmanual (const Graphic3d_NameOfTexture2D theNOT)
|
||||
: Graphic3d_Texture2D (theNOT, Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
MyCInitTexture.doModulate = 1;
|
||||
MyCInitTexture.doRepeat = 1;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_MANUAL;
|
||||
MyCInitTexture.doLinear = 1;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
|
@ -18,115 +18,103 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
-- Modified : GG IMP280200
|
||||
-- Add Plane(),ScaleT(),ScaleS() methods
|
||||
class Texture2Dplane from Graphic3d
|
||||
|
||||
class Texture2Dplane from Graphic3d
|
||||
|
||||
|
||||
inherits Texture2D from Graphic3d
|
||||
inherits Texture2D from Graphic3d
|
||||
|
||||
---Purpose: This class allows the management of a 2D texture defined from a plane equation
|
||||
-- Use the SetXXX() methods for positioning the texture as you want.
|
||||
---Purpose: This class allows the management of a 2D texture defined from a plane equation
|
||||
-- Use the SetXXX() methods for positioning the texture as you want.
|
||||
|
||||
uses
|
||||
NameOfTexture2D from Graphic3d,
|
||||
NameOfTexturePlane from Graphic3d,
|
||||
StructureManager from Graphic3d
|
||||
uses
|
||||
|
||||
NameOfTexture2D from Graphic3d,
|
||||
NameOfTexturePlane from Graphic3d,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
Create(SM : StructureManager from Graphic3d;
|
||||
FileName : CString from Standard) returns mutable Texture2Dplane from Graphic3d;
|
||||
---Purpose: Creates a texture from a file
|
||||
is
|
||||
|
||||
Create (theFileName : AsciiString from TCollection) returns mutable Texture2Dplane from Graphic3d;
|
||||
---Purpose: Creates a texture from a file
|
||||
|
||||
Create(SM : StructureManager from Graphic3d;
|
||||
NOT : NameOfTexture2D from Graphic3d) returns mutable Texture2Dplane from Graphic3d;
|
||||
---Purpose: Creates a texture from a predefined texture name set.
|
||||
|
||||
Create (theNOT : NameOfTexture2D from Graphic3d) returns mutable Texture2Dplane from Graphic3d;
|
||||
---Purpose: Creates a texture from a predefined texture name set.
|
||||
|
||||
SetPlaneS(me : mutable; A,B,C,D : ShortReal from Standard);
|
||||
---Purpose: Defines the texture projection plane for texture coordinate S
|
||||
-- default is <1.0, 0.0, 0.0, 0.0>
|
||||
SetPlaneS (me : mutable; A, B, C, D : ShortReal from Standard);
|
||||
---Purpose: Defines the texture projection plane for texture coordinate S
|
||||
-- default is <1.0, 0.0, 0.0, 0.0>
|
||||
|
||||
SetPlaneT(me : mutable; A,B,C,D : ShortReal from Standard);
|
||||
---Purpose: Defines the texture projection plane for texture coordinate T
|
||||
-- default is <0.0, 1.0, 0.0, 0.0>
|
||||
SetPlaneT (me : mutable; A, B, C, D : ShortReal from Standard);
|
||||
---Purpose: Defines the texture projection plane for texture coordinate T
|
||||
-- default is <0.0, 1.0, 0.0, 0.0>
|
||||
|
||||
SetPlane(me : mutable; APlane : NameOfTexturePlane from Graphic3d);
|
||||
---Purpose: Defines the texture projection plane for both S and T texture coordinate
|
||||
-- default is NOTP_XY meaning:
|
||||
-- <1.0, 0.0, 0.0, 0.0> for S
|
||||
-- and <0.0, 1.0, 0.0, 0.0> for T
|
||||
|
||||
SetScaleS(me : mutable; val : ShortReal from Standard);
|
||||
---Purpose: Defines the texture scale for the S texture coordinate
|
||||
-- much easier than recomputing the S plane equation
|
||||
-- but the result is the same
|
||||
-- default to 1.0
|
||||
SetPlane (me : mutable; thePlane : NameOfTexturePlane from Graphic3d);
|
||||
---Purpose: Defines the texture projection plane for both S and T texture coordinate
|
||||
-- default is NOTP_XY meaning:
|
||||
-- <1.0, 0.0, 0.0, 0.0> for S
|
||||
-- and <0.0, 1.0, 0.0, 0.0> for T
|
||||
|
||||
SetScaleT(me : mutable; val : ShortReal from Standard);
|
||||
---Purpose: Defines the texture scale for the T texture coordinate
|
||||
-- much easier than recompution the T plane equation
|
||||
-- but the result is the same
|
||||
-- default to 1.0
|
||||
|
||||
SetTranslateS(me : mutable; val : ShortReal from Standard);
|
||||
---Purpose: Defines the texture translation for the S texture coordinate
|
||||
-- you can obtain the same effect by modifying the S plane
|
||||
-- equation but its not easier.
|
||||
-- default to 0.0
|
||||
SetScaleS (me : mutable; theVal : ShortReal from Standard);
|
||||
---Purpose: Defines the texture scale for the S texture coordinate
|
||||
-- much easier than recomputing the S plane equation
|
||||
-- but the result is the same
|
||||
-- default to 1.0
|
||||
|
||||
SetTranslateT(me : mutable; val : ShortReal from Standard);
|
||||
---Purpose: Defines the texture translation for the T texture coordinate
|
||||
-- you can obtain the same effect by modifying the T plane
|
||||
-- equation but its not easier.
|
||||
-- default to 0.0
|
||||
|
||||
SetRotation(me : mutable; val : ShortReal from Standard);
|
||||
---Purpose: Sets the rotation angle of the whole texture.
|
||||
-- the same result might be achieved by recomputing the
|
||||
-- S and T plane equation but it's not the easiest way...
|
||||
-- the angle is expressed in degres
|
||||
-- default is 0.0
|
||||
SetScaleT (me : mutable; theVal : ShortReal from Standard);
|
||||
---Purpose: Defines the texture scale for the T texture coordinate
|
||||
-- much easier than recompution the T plane equation
|
||||
-- but the result is the same
|
||||
-- default to 1.0
|
||||
|
||||
SetTranslateS (me : mutable; theVal : ShortReal from Standard);
|
||||
---Purpose: Defines the texture translation for the S texture coordinate
|
||||
-- you can obtain the same effect by modifying the S plane
|
||||
-- equation but its not easier.
|
||||
-- default to 0.0
|
||||
|
||||
SetTranslateT (me : mutable; theVal : ShortReal from Standard);
|
||||
---Purpose: Defines the texture translation for the T texture coordinate
|
||||
-- you can obtain the same effect by modifying the T plane
|
||||
-- equation but its not easier.
|
||||
-- default to 0.0
|
||||
|
||||
SetRotation (me : mutable; theVal : ShortReal from Standard);
|
||||
---Purpose: Sets the rotation angle of the whole texture.
|
||||
-- the same result might be achieved by recomputing the
|
||||
-- S and T plane equation but it's not the easiest way...
|
||||
-- the angle is expressed in degrees
|
||||
-- default is 0.0
|
||||
|
||||
--
|
||||
-- inquire methods
|
||||
--
|
||||
--
|
||||
-- inquire methods
|
||||
--
|
||||
|
||||
Plane(me) returns NameOfTexturePlane from Graphic3d;
|
||||
---Purpose: Returns the current texture plane name or NOTP_UNKNOWN
|
||||
-- when the plane is user defined.
|
||||
Plane (me) returns NameOfTexturePlane from Graphic3d;
|
||||
---Purpose: Returns the current texture plane name or NOTP_UNKNOWN
|
||||
-- when the plane is user defined.
|
||||
|
||||
PlaneS(me; A,B,C,D : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture plane S equation
|
||||
PlaneS (me; A, B, C, D : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture plane S equation
|
||||
|
||||
PlaneT(me; A,B,C,D : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture plane T equation
|
||||
PlaneT (me; A, B, C, D : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture plane T equation
|
||||
|
||||
TranslateS(me; val : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture S translation value
|
||||
TranslateS (me; theVal : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture S translation value
|
||||
|
||||
TranslateT(me; val : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture T translation value
|
||||
TranslateT (me; theVal : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture T translation value
|
||||
|
||||
ScaleS(me; val : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture S scale value
|
||||
ScaleS (me; theVal : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture S scale value
|
||||
|
||||
ScaleT(me; val : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture T scale value
|
||||
ScaleT (me; theVal : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture T scale value
|
||||
|
||||
Rotation(me; val : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture rotation angle
|
||||
Rotation (me; theVal : out ShortReal from Standard);
|
||||
---Purpose: Returns the current texture rotation angle
|
||||
|
||||
fields
|
||||
|
||||
myPlaneName: NameOfTexturePlane from Graphic3d;
|
||||
|
||||
|
||||
end Texture2Dplane;
|
||||
myPlaneName : NameOfTexturePlane from Graphic3d;
|
||||
|
||||
end Texture2Dplane;
|
||||
|
@ -18,218 +18,240 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#define IMP280200 //GG Add Plane(),ScaleT(),ScaleS() methods
|
||||
|
||||
#include <Graphic3d_Texture2Dplane.ixx>
|
||||
#include <Graphic3d_TypeOfTextureMode.hxx>
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
|
||||
|
||||
Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString FileName)
|
||||
: Graphic3d_Texture2D(SM, FileName, Graphic3d_TOT_2D_MIPMAP)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2Dplane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_Texture2D (theFileName, Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
MyCInitTexture.doModulate = 1;
|
||||
MyCInitTexture.doRepeat = 1;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_OBJECT;
|
||||
MyCInitTexture.doLinear = 1;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 1.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 1.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane(const Handle(Graphic3d_StructureManager)& SM,const Graphic3d_NameOfTexture2D NOT)
|
||||
: Graphic3d_Texture2D(SM, NOT, Graphic3d_TOT_2D_MIPMAP)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2Dplane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Graphic3d_NameOfTexture2D theNOT)
|
||||
: Graphic3d_Texture2D (theNOT, Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
MyCInitTexture.doModulate = 1;
|
||||
MyCInitTexture.doRepeat = 1;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_OBJECT;
|
||||
MyCInitTexture.doLinear = 1;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 1.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 1.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture2Dplane::SetPlaneS(const Standard_ShortReal A,const Standard_ShortReal B,const Standard_ShortReal C,const Standard_ShortReal D)
|
||||
// =======================================================================
|
||||
// function : SetPlaneS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::SetPlaneS (const Standard_ShortReal theA,
|
||||
const Standard_ShortReal theB,
|
||||
const Standard_ShortReal theC,
|
||||
const Standard_ShortReal theD)
|
||||
{
|
||||
MyCInitTexture.sparams[0] = A;
|
||||
MyCInitTexture.sparams[1] = B;
|
||||
MyCInitTexture.sparams[2] = C;
|
||||
MyCInitTexture.sparams[3] = D;
|
||||
#ifdef IMP280200
|
||||
const Graphic3d_Vec4 aPlaneS (theA, theB, theC, theD);
|
||||
const Graphic3d_Vec4 aPlaneT = myParams->GenPlaneT();
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT);
|
||||
myPlaneName = Graphic3d_NOTP_UNKNOWN;
|
||||
#endif
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture2Dplane::SetPlaneT(const Standard_ShortReal A,const Standard_ShortReal B,const Standard_ShortReal C,const Standard_ShortReal D)
|
||||
// =======================================================================
|
||||
// function : SetPlaneT
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::SetPlaneT (const Standard_ShortReal theA,
|
||||
const Standard_ShortReal theB,
|
||||
const Standard_ShortReal theC,
|
||||
const Standard_ShortReal theD)
|
||||
{
|
||||
MyCInitTexture.tparams[0] = A;
|
||||
MyCInitTexture.tparams[1] = B;
|
||||
MyCInitTexture.tparams[2] = C;
|
||||
MyCInitTexture.tparams[3] = D;
|
||||
#ifdef IMP280200
|
||||
const Graphic3d_Vec4 aPlaneS = myParams->GenPlaneS();
|
||||
const Graphic3d_Vec4 aPlaneT (theA, theB, theC, theD);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT);
|
||||
myPlaneName = Graphic3d_NOTP_UNKNOWN;
|
||||
#endif
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture2Dplane::SetPlane(const Graphic3d_NameOfTexturePlane APlane)
|
||||
// =======================================================================
|
||||
// function : SetPlane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::SetPlane (const Graphic3d_NameOfTexturePlane thePlane)
|
||||
{
|
||||
switch (APlane)
|
||||
{
|
||||
switch (thePlane)
|
||||
{
|
||||
case Graphic3d_NOTP_XY:
|
||||
MyCInitTexture.sparams[0] = 1.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 1.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
break;
|
||||
|
||||
case Graphic3d_NOTP_YZ:
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 1.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 1.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
break;
|
||||
|
||||
case Graphic3d_NOTP_ZX:
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 1.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 1.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
|
||||
break;
|
||||
}
|
||||
case Graphic3d_NOTP_YZ:
|
||||
{
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
}
|
||||
case Graphic3d_NOTP_ZX:
|
||||
{
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f),
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f));
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
#ifdef IMP280200
|
||||
myPlaneName = APlane;
|
||||
#endif
|
||||
|
||||
Update();
|
||||
myPlaneName = thePlane;
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture2Dplane::SetScaleS(const Standard_ShortReal val)
|
||||
// =======================================================================
|
||||
// function : SetScaleS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::SetScaleS (const Standard_ShortReal theVal)
|
||||
{
|
||||
MyCInitTexture.sx = val;
|
||||
Update();
|
||||
Graphic3d_Vec2 aScale = myParams->Scale();
|
||||
aScale.x() = theVal;
|
||||
myParams->SetScale (aScale);
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture2Dplane::SetScaleT(const Standard_ShortReal val)
|
||||
// =======================================================================
|
||||
// function : SetScaleT
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::SetScaleT (const Standard_ShortReal theVal)
|
||||
{
|
||||
MyCInitTexture.sy = val;
|
||||
Update();
|
||||
Graphic3d_Vec2 aScale = myParams->Scale();
|
||||
aScale.y() = theVal;
|
||||
myParams->SetScale (aScale);
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture2Dplane::SetTranslateS(const Standard_ShortReal val)
|
||||
// =======================================================================
|
||||
// function : SetTranslateS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::SetTranslateS (const Standard_ShortReal theVal)
|
||||
{
|
||||
MyCInitTexture.tx = val;
|
||||
Update();
|
||||
Graphic3d_Vec2 aVec = myParams->Translation();
|
||||
aVec.x() = theVal;
|
||||
myParams->SetTranslation (aVec);
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture2Dplane::SetTranslateT(const Standard_ShortReal val)
|
||||
// =======================================================================
|
||||
// function : SetTranslateT
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::SetTranslateT (const Standard_ShortReal theVal)
|
||||
{
|
||||
MyCInitTexture.ty = val;
|
||||
Update();
|
||||
Graphic3d_Vec2 aVec = myParams->Translation();
|
||||
aVec.y() = theVal;
|
||||
myParams->SetTranslation (aVec);
|
||||
}
|
||||
|
||||
|
||||
void Graphic3d_Texture2Dplane::SetRotation(const Standard_ShortReal val)
|
||||
// =======================================================================
|
||||
// function : SetRotation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::SetRotation (const Standard_ShortReal theAngleDegrees)
|
||||
{
|
||||
MyCInitTexture.angle = val;
|
||||
Update();
|
||||
myParams->SetRotation (theAngleDegrees);
|
||||
}
|
||||
|
||||
void Graphic3d_Texture2Dplane::PlaneS(Standard_ShortReal& A,Standard_ShortReal& B,Standard_ShortReal& C,Standard_ShortReal& D) const
|
||||
// =======================================================================
|
||||
// function : PlaneS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::PlaneS (Standard_ShortReal& theA,
|
||||
Standard_ShortReal& theB,
|
||||
Standard_ShortReal& theC,
|
||||
Standard_ShortReal& theD) const
|
||||
{
|
||||
A = MyCInitTexture.sparams[0];
|
||||
B = MyCInitTexture.sparams[1];
|
||||
C = MyCInitTexture.sparams[2];
|
||||
D = MyCInitTexture.sparams[3];
|
||||
const Graphic3d_Vec4& aPlaneS = myParams->GenPlaneS();
|
||||
theA = aPlaneS.x();
|
||||
theB = aPlaneS.y();
|
||||
theC = aPlaneS.z();
|
||||
theD = aPlaneS.w();
|
||||
}
|
||||
|
||||
void Graphic3d_Texture2Dplane::PlaneT(Standard_ShortReal& A,Standard_ShortReal& B,Standard_ShortReal& C,Standard_ShortReal& D) const
|
||||
// =======================================================================
|
||||
// function : PlaneT
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::PlaneT (Standard_ShortReal& theA,
|
||||
Standard_ShortReal& theB,
|
||||
Standard_ShortReal& theC,
|
||||
Standard_ShortReal& theD) const
|
||||
{
|
||||
A = MyCInitTexture.tparams[0];
|
||||
B = MyCInitTexture.tparams[1];
|
||||
C = MyCInitTexture.tparams[2];
|
||||
D = MyCInitTexture.tparams[3];
|
||||
const Graphic3d_Vec4& aPlaneT = myParams->GenPlaneT();
|
||||
theA = aPlaneT.x();
|
||||
theB = aPlaneT.y();
|
||||
theC = aPlaneT.z();
|
||||
theD = aPlaneT.w();
|
||||
}
|
||||
|
||||
void Graphic3d_Texture2Dplane::TranslateS(Standard_ShortReal& val) const
|
||||
// =======================================================================
|
||||
// function : TranslateS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::TranslateS (Standard_ShortReal& theVal) const
|
||||
{
|
||||
val = MyCInitTexture.tx;
|
||||
theVal = myParams->Translation().x();
|
||||
}
|
||||
|
||||
void Graphic3d_Texture2Dplane::TranslateT(Standard_ShortReal& val) const
|
||||
// =======================================================================
|
||||
// function : TranslateT
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::TranslateT (Standard_ShortReal& theVal) const
|
||||
{
|
||||
val = MyCInitTexture.ty;
|
||||
theVal = myParams->Translation().y();
|
||||
}
|
||||
|
||||
void Graphic3d_Texture2Dplane::Rotation(Standard_ShortReal& val) const
|
||||
// =======================================================================
|
||||
// function : Rotation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::Rotation (Standard_ShortReal& theVal) const
|
||||
{
|
||||
val = MyCInitTexture.angle;
|
||||
theVal = myParams->Rotation();
|
||||
}
|
||||
|
||||
#ifdef IMP280200
|
||||
Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const {
|
||||
|
||||
// =======================================================================
|
||||
// function : Plane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const
|
||||
{
|
||||
return myPlaneName;
|
||||
}
|
||||
|
||||
void Graphic3d_Texture2Dplane::ScaleS(Standard_ShortReal& val) const
|
||||
// =======================================================================
|
||||
// function : ScaleS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::ScaleS (Standard_ShortReal& theVal) const
|
||||
{
|
||||
val = MyCInitTexture.sx;
|
||||
theVal = myParams->Scale().x();
|
||||
}
|
||||
|
||||
void Graphic3d_Texture2Dplane::ScaleT(Standard_ShortReal& val) const
|
||||
// =======================================================================
|
||||
// function : ScaleT
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture2Dplane::ScaleT (Standard_ShortReal& theVal) const
|
||||
{
|
||||
val = MyCInitTexture.sy;
|
||||
theVal = myParams->Scale().y();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -18,56 +18,50 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
-- Modified : GG 10/01/2000 IMP
|
||||
-- Add NumberOfTextures() and TextureName() methods
|
||||
-- Add Name() method
|
||||
class TextureEnv from Graphic3d
|
||||
|
||||
class TextureEnv from Graphic3d
|
||||
|
||||
inherits TextureRoot from Graphic3d
|
||||
|
||||
inherits TextureRoot from Graphic3d
|
||||
|
||||
---Purpose: This class provides environment texture usable only in Visual3d_ContextView
|
||||
---Purpose: This class provides environment texture usable only in Visual3d_ContextView
|
||||
|
||||
uses
|
||||
NameOfTextureEnv from Graphic3d,
|
||||
StructureManager from Graphic3d
|
||||
uses
|
||||
|
||||
NameOfTextureEnv from Graphic3d,
|
||||
AsciiString from TCollection
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
Create(SM : StructureManager from Graphic3d;
|
||||
aFileName : CString from Standard)
|
||||
returns mutable TextureEnv from Graphic3d;
|
||||
---Purpose: Creates an environment texture from a file
|
||||
OutOfRange from Standard
|
||||
|
||||
Create(SM : StructureManager from Graphic3d;
|
||||
aName: NameOfTextureEnv from Graphic3d)
|
||||
returns mutable TextureEnv from Graphic3d;
|
||||
---Purpose: Creates an environment texture from a predefined texture name set.
|
||||
is
|
||||
|
||||
Name(me) returns NameOfTextureEnv from Graphic3d;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined textures or NOT_ENV_UNKNOWN
|
||||
-- when the name is given as a filename.
|
||||
---Level: Public
|
||||
Create (theFileName : AsciiString from TCollection) returns mutable TextureEnv from Graphic3d;
|
||||
---Purpose: Creates an environment texture from a file.
|
||||
|
||||
NumberOfTextures(myclass) returns Integer from Standard;
|
||||
---Purpose:
|
||||
-- Returns the number of predefined textures.
|
||||
---Level: Public
|
||||
Create (theName : NameOfTextureEnv from Graphic3d) returns mutable TextureEnv from Graphic3d;
|
||||
---Purpose: Creates an environment texture from a predefined texture name set.
|
||||
|
||||
TextureName(myclass; aRank: Integer from Standard)
|
||||
returns CString from Standard
|
||||
raises OutOfRange from Standard;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined texture of rank <aRank>
|
||||
---Trigger: when <aRank> is < 1 or > NumberOfTextures.
|
||||
---Level: Public
|
||||
Name (me) returns NameOfTextureEnv from Graphic3d;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined textures or NOT_ENV_UNKNOWN
|
||||
-- when the name is given as a filename.
|
||||
---Level: Public
|
||||
|
||||
NumberOfTextures (myclass) returns Integer from Standard;
|
||||
---Purpose:
|
||||
-- Returns the number of predefined textures.
|
||||
---Level: Public
|
||||
|
||||
TextureName (myclass; theRank: Integer from Standard)
|
||||
returns AsciiString from TCollection
|
||||
raises OutOfRange from Standard;
|
||||
---Purpose:
|
||||
-- Returns the name of the predefined texture of rank <aRank>
|
||||
---Trigger: when <aRank> is < 1 or > NumberOfTextures.
|
||||
---Level: Public
|
||||
|
||||
fields
|
||||
myName: NameOfTextureEnv from Graphic3d;
|
||||
|
||||
end TextureEnv;
|
||||
|
||||
myName : NameOfTextureEnv from Graphic3d;
|
||||
|
||||
end TextureEnv;
|
||||
|
@ -18,69 +18,11 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
// Modified : GG 10/01/2000 IMP
|
||||
// Adds Name(),NumberOfTextures() and TextureName() methods
|
||||
|
||||
#include <Graphic3d_TextureEnv.ixx>
|
||||
#include <Graphic3d_TypeOfTexture.hxx>
|
||||
#include <Graphic3d_TypeOfTextureMode.hxx>
|
||||
|
||||
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static TCollection_AsciiString GetEnvir ( ) {
|
||||
|
||||
static Standard_Boolean IsDefined=Standard_False ;
|
||||
static TCollection_AsciiString VarName;
|
||||
if ( !IsDefined ) {
|
||||
char *envir, *casroot ;
|
||||
envir = getenv("CSF_MDTVTexturesDirectory") ;
|
||||
|
||||
Standard_Boolean HasDefinition = Standard_False ;
|
||||
if ( !envir ) {
|
||||
casroot = getenv("CASROOT");
|
||||
if ( casroot ) {
|
||||
VarName = TCollection_AsciiString (casroot);
|
||||
VarName += "/src/Textures" ;
|
||||
HasDefinition = Standard_True ;
|
||||
}
|
||||
} else {
|
||||
VarName = TCollection_AsciiString (envir);
|
||||
HasDefinition = Standard_True ;
|
||||
}
|
||||
if ( HasDefinition ) {
|
||||
OSD_Path aPath ( VarName );
|
||||
OSD_Directory aDir(aPath);
|
||||
if ( aDir.Exists () ) {
|
||||
TCollection_AsciiString aTexture = VarName + "/2d_MatraDatavision.rgb" ;
|
||||
OSD_File TextureFile ( aTexture );
|
||||
if ( !TextureFile.Exists() ) {
|
||||
cout << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << endl;
|
||||
cout << " not all files are found in : "<<VarName.ToCString() << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory or CASROOT not correctly setted " );
|
||||
}
|
||||
} else {
|
||||
cout << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << endl;
|
||||
cout << " Directory : "<< VarName.ToCString() << " not exist " << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory or CASROOT not correctly setted " );
|
||||
}
|
||||
return VarName ;
|
||||
} else {
|
||||
cout << " CSF_MDTVTexturesDirectory and CASROOT not setted " << endl;
|
||||
cout << " one of these variable are mandatory to use this fonctionnality" << endl;
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory and CASROOT not setted " );
|
||||
}
|
||||
IsDefined = Standard_True ;
|
||||
}
|
||||
return VarName ;
|
||||
|
||||
}
|
||||
|
||||
static const char *NameOfTexture_to_FileName[] =
|
||||
{
|
||||
@ -94,74 +36,68 @@ static const char *NameOfTexture_to_FileName[] =
|
||||
"env_road.rgb"
|
||||
};
|
||||
|
||||
|
||||
Graphic3d_TextureEnv::Graphic3d_TextureEnv(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString FileName)
|
||||
: Graphic3d_TextureRoot(SM, "", FileName, Graphic3d_TOT_2D_MIPMAP),
|
||||
myName(Graphic3d_NOT_ENV_UNKNOWN)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_TextureEnv
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TextureEnv::Graphic3d_TextureEnv (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_TextureRoot (theFileName, Graphic3d_TOT_2D_MIPMAP),
|
||||
myName (Graphic3d_NOT_ENV_UNKNOWN)
|
||||
{
|
||||
MyCInitTexture.doModulate = 0;
|
||||
MyCInitTexture.doRepeat = 0;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_SPHERE;
|
||||
MyCInitTexture.doLinear = 1;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 1.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 1.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
Graphic3d_TextureEnv::Graphic3d_TextureEnv(const Handle(Graphic3d_StructureManager)& SM,const Graphic3d_NameOfTextureEnv NOT)
|
||||
: Graphic3d_TextureRoot(SM, GetEnvir().ToCString() , NameOfTexture_to_FileName[NOT], Graphic3d_TOT_2D_MIPMAP),
|
||||
myName(NOT)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_TextureEnv
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Graphic3d_NameOfTextureEnv theNOT)
|
||||
: Graphic3d_TextureRoot (NameOfTexture_to_FileName[theNOT], Graphic3d_TOT_2D_MIPMAP),
|
||||
myName (theNOT)
|
||||
{
|
||||
MyCInitTexture.doModulate = 0;
|
||||
MyCInitTexture.doRepeat = 0;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_SPHERE;
|
||||
MyCInitTexture.doLinear = 1;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 1.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 1.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
|
||||
myTexId = TCollection_AsciiString ("Graphic3d_TextureEnv_")
|
||||
+ NameOfTexture_to_FileName[theNOT];
|
||||
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
Graphic3d_NameOfTextureEnv Graphic3d_TextureEnv::Name() const {
|
||||
|
||||
// =======================================================================
|
||||
// function : Name
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_NameOfTextureEnv Graphic3d_TextureEnv::Name() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
Standard_Integer Graphic3d_TextureEnv::NumberOfTextures() {
|
||||
|
||||
// =======================================================================
|
||||
// function : NumberOfTextures
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Graphic3d_TextureEnv::NumberOfTextures()
|
||||
{
|
||||
return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
|
||||
}
|
||||
|
||||
Standard_CString Graphic3d_TextureEnv::TextureName(const Standard_Integer aRank) {
|
||||
// =======================================================================
|
||||
// function : TextureName
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Graphic3d_TextureEnv::TextureName (const Standard_Integer theRank)
|
||||
{
|
||||
if(theRank < 1 || theRank > NumberOfTextures())
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD index of texture");
|
||||
}
|
||||
|
||||
if( aRank < 1 || aRank > NumberOfTextures() )
|
||||
Standard_OutOfRange::Raise(" BAD index of texture");
|
||||
TCollection_AsciiString filename(NameOfTexture_to_FileName[aRank-1]);
|
||||
Standard_Integer i = filename.SearchFromEnd(".");
|
||||
|
||||
static TCollection_AsciiString name;
|
||||
name = filename.SubString(5,i-1);
|
||||
return name.ToCString();
|
||||
TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
|
||||
Standard_Integer i = aFileName.SearchFromEnd(".");
|
||||
return aFileName.SubString (5, i - 1);
|
||||
}
|
||||
|
@ -18,71 +18,81 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
deferred class TextureMap from Graphic3d
|
||||
|
||||
deferred class TextureMap from Graphic3d
|
||||
|
||||
inherits TextureRoot from Graphic3d
|
||||
---Purpose: This is an abstract class for managing texture applyable on polygons.
|
||||
inherits TextureRoot from Graphic3d
|
||||
|
||||
---Purpose: This is an abstract class for managing texture applyable on polygons.
|
||||
|
||||
uses
|
||||
TypeOfTexture from Graphic3d,
|
||||
StructureManager from Graphic3d
|
||||
|
||||
TypeOfTexture from Graphic3d,
|
||||
TextureParams from Graphic3d,
|
||||
LevelOfTextureAnisotropy from Graphic3d,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
Initialize(SM : StructureManager from Graphic3d;
|
||||
Path : CString from Standard;
|
||||
FileName : CString from Standard;
|
||||
Type : TypeOfTexture from Graphic3d);
|
||||
|
||||
EnableSmooth(me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- enable texture smoothing
|
||||
is
|
||||
|
||||
IsSmoothed(me) returns Boolean from Standard;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns TRUE if the texture is smoothed.
|
||||
|
||||
DisableSmooth(me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- disable texture smoothing
|
||||
Initialize (theFileName : AsciiString from TCollection;
|
||||
theType : TypeOfTexture from Graphic3d);
|
||||
|
||||
EnableModulate(me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- enable texture modulate mode.
|
||||
-- the image is modulate with the shading of the surface.
|
||||
EnableSmooth (me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- enable texture smoothing
|
||||
|
||||
DisableModulate(me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- disable texture modulate mode.
|
||||
-- the image is directly decal on the surface.
|
||||
IsSmoothed (me) returns Boolean from Standard;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns TRUE if the texture is smoothed.
|
||||
|
||||
IsModulate(me) returns Boolean from Standard;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns TRUE if the texture is modulate.
|
||||
DisableSmooth (me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- disable texture smoothing
|
||||
|
||||
EnableRepeat(me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- use this methods if you want to enable
|
||||
-- texture repetition on your objects.
|
||||
EnableModulate (me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- enable texture modulate mode.
|
||||
-- the image is modulate with the shading of the surface.
|
||||
|
||||
DisableRepeat(me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- use this methods if you want to disable
|
||||
-- texture repetition on your objects.
|
||||
DisableModulate (me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- disable texture modulate mode.
|
||||
-- the image is directly decal on the surface.
|
||||
|
||||
IsRepeat(me) returns Boolean from Standard;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns TRUE if the texture repeat is enable.
|
||||
IsModulate (me) returns Boolean from Standard;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns TRUE if the texture is modulate.
|
||||
|
||||
end TextureMap from Graphic3d;
|
||||
EnableRepeat (me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- use this methods if you want to enable
|
||||
-- texture repetition on your objects.
|
||||
|
||||
DisableRepeat (me : mutable);
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- use this methods if you want to disable
|
||||
-- texture repetition on your objects.
|
||||
|
||||
IsRepeat (me) returns Boolean from Standard;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns TRUE if the texture repeat is enable.
|
||||
|
||||
AnisoFilter (me) returns LevelOfTextureAnisotropy from Graphic3d;
|
||||
---Level : public
|
||||
---Purpose : @return level of anisontropy texture filter.
|
||||
-- Default value is Graphic3d_LOTA_OFF.
|
||||
|
||||
SetAnisoFilter (me : mutable;
|
||||
theLevel : LevelOfTextureAnisotropy from Graphic3d);
|
||||
---Level : public
|
||||
---Purpose : @param theLevel level of anisontropy texture filter.
|
||||
|
||||
end TextureMap from Graphic3d;
|
||||
|
@ -18,56 +18,114 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
// Modified : GG 09/11/00 smooth,modulate,repeat texture attributes
|
||||
// must be available both for textures 1D & 2D.
|
||||
|
||||
|
||||
#include <Graphic3d_TextureMap.ixx>
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
|
||||
Graphic3d_TextureMap::Graphic3d_TextureMap(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString Path,const Standard_CString FileName,const Graphic3d_TypeOfTexture Type)
|
||||
: Graphic3d_TextureRoot(SM, Path, FileName, Type)
|
||||
// =======================================================================
|
||||
// function : Graphic3d_TextureMap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TextureMap::Graphic3d_TextureMap (const TCollection_AsciiString& theFileName,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
: Graphic3d_TextureRoot (theFileName, theType)
|
||||
{
|
||||
}
|
||||
|
||||
void Graphic3d_TextureMap::EnableSmooth() {
|
||||
MyCInitTexture.doLinear = 1;
|
||||
Update();
|
||||
// =======================================================================
|
||||
// function : EnableSmooth
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureMap::EnableSmooth()
|
||||
{
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
void Graphic3d_TextureMap::DisableSmooth() {
|
||||
MyCInitTexture.doLinear = 0;
|
||||
Update();
|
||||
// =======================================================================
|
||||
// function : DisableSmooth
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureMap::DisableSmooth()
|
||||
{
|
||||
myParams->SetFilter (Graphic3d_TOTF_NEAREST);
|
||||
}
|
||||
|
||||
Standard_Boolean Graphic3d_TextureMap::IsSmoothed() const {
|
||||
return (MyCInitTexture.doLinear != 0);
|
||||
// =======================================================================
|
||||
// function : IsSmoothed
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_TextureMap::IsSmoothed() const
|
||||
{
|
||||
return myParams->Filter() != Graphic3d_TOTF_NEAREST;
|
||||
}
|
||||
|
||||
void Graphic3d_TextureMap::EnableModulate() {
|
||||
MyCInitTexture.doModulate = 1;
|
||||
Update();
|
||||
// =======================================================================
|
||||
// function : EnableModulate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureMap::EnableModulate()
|
||||
{
|
||||
myParams->SetModulate (Standard_True);
|
||||
}
|
||||
|
||||
void Graphic3d_TextureMap::DisableModulate() {
|
||||
MyCInitTexture.doModulate = 0;
|
||||
Update();
|
||||
// =======================================================================
|
||||
// function : DisableModulate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureMap::DisableModulate()
|
||||
{
|
||||
myParams->SetModulate (Standard_False);
|
||||
}
|
||||
|
||||
Standard_Boolean Graphic3d_TextureMap::IsModulate() const {
|
||||
return (MyCInitTexture.doModulate != 0);
|
||||
// =======================================================================
|
||||
// function : IsModulate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_TextureMap::IsModulate() const
|
||||
{
|
||||
return myParams->IsModulate();
|
||||
}
|
||||
|
||||
void Graphic3d_TextureMap::EnableRepeat() {
|
||||
MyCInitTexture.doRepeat = 1;
|
||||
Update();
|
||||
// =======================================================================
|
||||
// function : EnableRepeat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureMap::EnableRepeat()
|
||||
{
|
||||
myParams->SetRepeat (Standard_True);
|
||||
}
|
||||
|
||||
void Graphic3d_TextureMap::DisableRepeat() {
|
||||
MyCInitTexture.doRepeat = 0;
|
||||
Update();
|
||||
// =======================================================================
|
||||
// function : DisableRepeat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureMap::DisableRepeat()
|
||||
{
|
||||
myParams->SetRepeat (Standard_False);
|
||||
}
|
||||
|
||||
Standard_Boolean Graphic3d_TextureMap::IsRepeat() const {
|
||||
return (MyCInitTexture.doRepeat != 0);
|
||||
// =======================================================================
|
||||
// function : IsRepeat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_TextureMap::IsRepeat() const
|
||||
{
|
||||
return myParams->IsRepeat();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AnisoFilter
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_LevelOfTextureAnisotropy Graphic3d_TextureMap::AnisoFilter() const
|
||||
{
|
||||
return myParams->AnisoFilter();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAnisoFilter
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureMap::SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel)
|
||||
{
|
||||
myParams->SetAnisoFilter (theLevel);
|
||||
}
|
||||
|
171
src/Graphic3d/Graphic3d_TextureParams.cdl
Executable file
171
src/Graphic3d/Graphic3d_TextureParams.cdl
Executable file
@ -0,0 +1,171 @@
|
||||
-- Copyright (c) 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 TextureParams from Graphic3d
|
||||
|
||||
inherits Transient from Standard
|
||||
|
||||
---Purpose: This class describes texture parameters.
|
||||
|
||||
uses
|
||||
|
||||
Vec2 from Graphic3d,
|
||||
Vec4 from Graphic3d,
|
||||
TypeOfTextureMode from Graphic3d,
|
||||
TypeOfTextureFilter from Graphic3d,
|
||||
LevelOfTextureAnisotropy from Graphic3d
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
returns TextureParams from Graphic3d;
|
||||
---Purpose: Default constructor.
|
||||
|
||||
Destroy (me);
|
||||
---C++ : alias ~
|
||||
|
||||
--
|
||||
-- public methods
|
||||
--
|
||||
|
||||
IsModulate (me) returns Boolean from Standard;
|
||||
---Level : public
|
||||
---Purpose : @return TRUE if the texture is modulate.
|
||||
-- Default value is FALSE.
|
||||
|
||||
SetModulate (me : mutable;
|
||||
theToModulate : Boolean from Standard);
|
||||
---Level : public
|
||||
---Purpose : @param theToModulate turn modulation on/off.
|
||||
|
||||
IsRepeat (me) returns Boolean from Standard;
|
||||
---Level : public
|
||||
---Purpose : @return TRUE if the texture repeat is enabled.
|
||||
-- Default value is FALSE.
|
||||
|
||||
SetRepeat (me : mutable;
|
||||
theToRepeat : Boolean from Standard);
|
||||
---Level : public
|
||||
---Purpose : @param theToRepeat turn texture repeat mode ON or OFF (clamping).
|
||||
|
||||
Filter (me) returns TypeOfTextureFilter from Graphic3d;
|
||||
---Level : public
|
||||
---Purpose : @return texture interpolation filter.
|
||||
-- Default value is Graphic3d_TOTF_NEAREST.
|
||||
|
||||
SetFilter (me : mutable;
|
||||
theFilter : TypeOfTextureFilter from Graphic3d);
|
||||
---Level : public
|
||||
---Purpose : @param theFilter texture interpolation filter.
|
||||
|
||||
AnisoFilter (me) returns LevelOfTextureAnisotropy from Graphic3d;
|
||||
---Level : public
|
||||
---Purpose : @return level of anisontropy texture filter.
|
||||
-- Default value is Graphic3d_LOTA_OFF.
|
||||
|
||||
SetAnisoFilter (me : mutable;
|
||||
theLevel : LevelOfTextureAnisotropy from Graphic3d);
|
||||
---Level : public
|
||||
---Purpose : @param theLevel level of anisontropy texture filter.
|
||||
|
||||
Rotation (me) returns ShortReal from Standard;
|
||||
---Level : public
|
||||
---Purpose : @return rotation angle in degrees
|
||||
-- Default value is 0.
|
||||
|
||||
SetRotation (me : mutable;
|
||||
theAngleDegrees : ShortReal from Standard);
|
||||
---Level : public
|
||||
---Purpose : @param theAngleDegrees rotation angle.
|
||||
|
||||
Scale (me) returns Vec2 from Graphic3d;
|
||||
---Level : public
|
||||
---Purpose : @return scale factor
|
||||
-- Default value is no scaling (1.0; 1.0).
|
||||
---C++ : return const &
|
||||
|
||||
SetScale (me : mutable;
|
||||
theScale : Vec2 from Graphic3d);
|
||||
---Level : public
|
||||
---Purpose : @param theScale scale factor.
|
||||
|
||||
Translation (me) returns Vec2 from Graphic3d;
|
||||
---Level : public
|
||||
---Purpose : @return translation vector
|
||||
-- Default value is no translation (0.0; 0.0).
|
||||
---C++ : return const &
|
||||
|
||||
SetTranslation (me : mutable;
|
||||
theVec : Vec2 from Graphic3d);
|
||||
---Level : public
|
||||
---Purpose : @param theVec translation vector.
|
||||
|
||||
GenMode (me) returns TypeOfTextureMode from Graphic3d;
|
||||
---Level : public
|
||||
---Purpose : @return texture coordinates generation mode.
|
||||
-- Default value is Graphic3d_TOTM_MANUAL.
|
||||
|
||||
GenPlaneS (me) returns Vec4 from Graphic3d;
|
||||
---Level : public
|
||||
---Purpose : @return texture coordinates generation plane S.
|
||||
---C++ : return const &
|
||||
|
||||
GenPlaneT (me) returns Vec4 from Graphic3d;
|
||||
---Level : public
|
||||
---Purpose : @return texture coordinates generation plane T.
|
||||
---C++ : return const &
|
||||
|
||||
SetGenMode (me : mutable;
|
||||
theMode : TypeOfTextureMode from Graphic3d;
|
||||
thePlaneS : Vec4 from Graphic3d;
|
||||
thePlaneT : Vec4 from Graphic3d);
|
||||
---Level : public
|
||||
---Purpose : Setup texture coordinates generation mode.
|
||||
|
||||
fields
|
||||
|
||||
-- apply lighting on texture or not
|
||||
myToModulate : Boolean from Standard;
|
||||
|
||||
-- texture wrapping mode
|
||||
myToRepeat : Boolean from Standard;
|
||||
|
||||
-- texture filter
|
||||
myFilter : TypeOfTextureFilter from Graphic3d;
|
||||
|
||||
-- level of anisontropy texture filter
|
||||
myAnisoLevel : LevelOfTextureAnisotropy from Graphic3d;
|
||||
|
||||
-- texture mapping - rotation angle in degrees around OZ axis
|
||||
myRotAngle : ShortReal from Standard;
|
||||
|
||||
-- texture coordinate scale factor
|
||||
myScale : Vec2 from Graphic3d;
|
||||
|
||||
-- texture coordinate translation vector
|
||||
myTranslation: Vec2 from Graphic3d;
|
||||
|
||||
-- texture coordinates generation mode
|
||||
myGenMode : TypeOfTextureMode from Graphic3d;
|
||||
|
||||
-- plane definition for s(x) coordinate (for Graphic3d_TOTM_EYE and Graphic3d_TOTM_OBJECT generation modes)
|
||||
myGenPlaneS : Vec4 from Graphic3d;
|
||||
|
||||
-- plane definition for t(y) coordinate (for Graphic3d_TOTM_EYE and Graphic3d_TOTM_OBJECT generation modes)
|
||||
myGenPlaneT : Vec4 from Graphic3d;
|
||||
|
||||
end TextureParams;
|
212
src/Graphic3d/Graphic3d_TextureParams.cxx
Executable file
212
src/Graphic3d/Graphic3d_TextureParams.cxx
Executable file
@ -0,0 +1,212 @@
|
||||
// Copyright (c) 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.
|
||||
|
||||
#include <Graphic3d_TextureParams.ixx>
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_TextureParams
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TextureParams::Graphic3d_TextureParams()
|
||||
: myToModulate (Standard_False),
|
||||
myToRepeat (Standard_False),
|
||||
myFilter (Graphic3d_TOTF_NEAREST),
|
||||
myAnisoLevel (Graphic3d_LOTA_OFF),
|
||||
myRotAngle (0.0f),
|
||||
myScale (1.0f, 1.0f),
|
||||
myTranslation(0.0f, 0.0f),
|
||||
myGenMode (Graphic3d_TOTM_MANUAL),
|
||||
myGenPlaneS (0.0f, 0.0f, 0.0f, 0.0f),
|
||||
myGenPlaneT (0.0f, 0.0f, 0.0f, 0.0f)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Destroy
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::Destroy() const
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsModulate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_TextureParams::IsModulate() const
|
||||
{
|
||||
return myToModulate;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetModulate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::SetModulate (const Standard_Boolean theToModulate)
|
||||
{
|
||||
myToModulate = theToModulate;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsRepeat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_TextureParams::IsRepeat() const
|
||||
{
|
||||
return myToRepeat;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetRepeat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::SetRepeat (const Standard_Boolean theToRepeat)
|
||||
{
|
||||
myToRepeat = theToRepeat;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Filter
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TypeOfTextureFilter Graphic3d_TextureParams::Filter() const
|
||||
{
|
||||
return myFilter;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetFilter
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::SetFilter (const Graphic3d_TypeOfTextureFilter theFilter)
|
||||
{
|
||||
myFilter = theFilter;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AnisoFilter
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_LevelOfTextureAnisotropy Graphic3d_TextureParams::AnisoFilter() const
|
||||
{
|
||||
return myAnisoLevel;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAnisoFilter
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel)
|
||||
{
|
||||
myAnisoLevel = theLevel;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Rotation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_ShortReal Graphic3d_TextureParams::Rotation() const
|
||||
{
|
||||
return myRotAngle;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetRotation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::SetRotation (const Standard_ShortReal theAngleDegrees)
|
||||
{
|
||||
myRotAngle = theAngleDegrees;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Scale
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_Vec2& Graphic3d_TextureParams::Scale() const
|
||||
{
|
||||
return myScale;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetScale
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::SetScale (const Graphic3d_Vec2 theScale)
|
||||
{
|
||||
myScale = theScale;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Translation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_Vec2& Graphic3d_TextureParams::Translation() const
|
||||
{
|
||||
return myTranslation;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetTranslation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::SetTranslation (const Graphic3d_Vec2 theVec)
|
||||
{
|
||||
myTranslation = theVec;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GenMode
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TypeOfTextureMode Graphic3d_TextureParams::GenMode() const
|
||||
{
|
||||
return myGenMode;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GenPlaneS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_Vec4& Graphic3d_TextureParams::GenPlaneS() const
|
||||
{
|
||||
return myGenPlaneS;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GenPlaneT
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_Vec4& Graphic3d_TextureParams::GenPlaneT() const
|
||||
{
|
||||
return myGenPlaneT;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetGenMode
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureParams::SetGenMode (const Graphic3d_TypeOfTextureMode theMode,
|
||||
const Graphic3d_Vec4 thePlaneS,
|
||||
const Graphic3d_Vec4 thePlaneT)
|
||||
{
|
||||
myGenMode = theMode;
|
||||
myGenPlaneS = thePlaneS;
|
||||
myGenPlaneT = thePlaneT;
|
||||
}
|
@ -22,87 +22,93 @@ deferred class TextureRoot from Graphic3d
|
||||
|
||||
inherits TShared from MMgt
|
||||
|
||||
---Purpose: This is the texture root class enable the dialog with the GraphicDriver
|
||||
-- allows the loading of texture.
|
||||
---Purpose: This is the texture root class enable the dialog with the GraphicDriver allows the loading of texture.
|
||||
|
||||
uses
|
||||
|
||||
CInitTexture from Graphic3d,
|
||||
GraphicDriver from Graphic3d,
|
||||
StructureManager from Graphic3d,
|
||||
TypeOfTexture from Graphic3d,
|
||||
PixMap from Image,
|
||||
Path from OSD,
|
||||
HArray1OfReal from TColStd
|
||||
TextureParams from Graphic3d,
|
||||
TypeOfTexture from Graphic3d,
|
||||
PixMap from Image,
|
||||
PixMap_Handle from Image,
|
||||
Path from OSD,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Initialize (theSM : StructureManager from Graphic3d;
|
||||
thePath : CString from Standard;
|
||||
theFileName : CString from Standard;
|
||||
theType : TypeOfTexture from Graphic3d);
|
||||
---Purpose: Creates a texture from a file
|
||||
-- Warning: Note that if <FileName> is NULL the texture must be realized
|
||||
-- using LoadTexture(image) method.
|
||||
Initialize (theFileName : AsciiString from TCollection;
|
||||
theType : TypeOfTexture from Graphic3d);
|
||||
---Purpose: Creates a texture from a file
|
||||
-- Warning: Note that if <FileName> is NULL the texture must be realized
|
||||
-- using LoadTexture(image) method.
|
||||
|
||||
Destroy (me);
|
||||
---C++ : alias ~
|
||||
Destroy (me);
|
||||
---C++ : alias ~
|
||||
|
||||
--
|
||||
-- public methods
|
||||
--
|
||||
--
|
||||
-- public methods
|
||||
--
|
||||
|
||||
IsDone (me) returns Boolean from Standard;
|
||||
---Level: public
|
||||
---Purpose: Checks if a texture class is valid or not
|
||||
-- returns true if the construction of the class is correct
|
||||
IsDone (me) returns Boolean from Standard
|
||||
is virtual;
|
||||
---Level: public
|
||||
---Purpose: Checks if a texture class is valid or not.
|
||||
-- @return true if the construction of the class is correct
|
||||
|
||||
IsValid (me) returns Boolean from Standard;
|
||||
---Level: public
|
||||
---Purpose: Checks if a texture class is valid or not
|
||||
-- returns true if the construction of the class is correct
|
||||
Path (me) returns Path from OSD;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns the full path of the defined texture.
|
||||
-- It could be empty path if GetImage() is overridden to load image not from file.
|
||||
---C++: return const &
|
||||
|
||||
Path (me) returns Path from OSD;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns the full path of the defined texture.
|
||||
---C++: return const &
|
||||
Type (me) returns TypeOfTexture from Graphic3d;
|
||||
---Level: public
|
||||
---Purpose: @return the texture type.
|
||||
|
||||
Type (me) returns TypeOfTexture from Graphic3d;
|
||||
---Level: public
|
||||
---Purpose:
|
||||
-- Returns the texture type.
|
||||
GetId (me) returns AsciiString from TCollection;
|
||||
---Level: advanced
|
||||
---Purpose:
|
||||
-- This ID will be used to manage resource in graphic driver.
|
||||
-- .
|
||||
-- Default implementation generates unique ID although inheritors may re-initialize it.
|
||||
-- .
|
||||
-- Multiple Graphic3d_TextureRoot instancies with same ID
|
||||
-- will be treated as single texture with different parameters
|
||||
-- to optimize memory usage though this will be more natural
|
||||
-- to use same instance of Graphic3d_TextureRoot when possible.
|
||||
-- .
|
||||
-- Notice that inheritor may set this ID to empty string.
|
||||
-- In this case independent graphical resource will be created
|
||||
-- for each instance of Graphic3d_AspectFillArea3d where texture will be used.
|
||||
-- .
|
||||
-- @return texture identifier.
|
||||
|
||||
LoadTexture (me : mutable; theImage : PixMap from Image) returns Boolean from Standard;
|
||||
---Level: advanced
|
||||
---Purpose:
|
||||
-- Updates the current texture from a requested image.
|
||||
GetImage (me) returns PixMap_Handle from Image
|
||||
is virtual;
|
||||
---Level : Public
|
||||
---Purpose :
|
||||
-- This method will be called by graphic driver each time when texture resource should be created.
|
||||
-- Default implementation will dynamically load image from specified path within this method
|
||||
-- (and no copy will be preserved in this class instance).
|
||||
-- Inheritors may dynamically generate the image or return cached instance.
|
||||
-- @return the image for texture.
|
||||
|
||||
TextureId (me) returns Integer from Standard;
|
||||
---Level: advanced
|
||||
---Purpose:
|
||||
-- returns the Texture ID which references the
|
||||
-- texture to use for drawing. Used by the graphic driver.
|
||||
GetParams (me) returns TextureParams from Graphic3d;
|
||||
---Level: public
|
||||
---Purpose: @return low-level texture parameters
|
||||
---C++: return const &
|
||||
|
||||
GetTexUpperBounds(me) returns HArray1OfReal from TColStd;
|
||||
---Level: advanced
|
||||
---Purpose:
|
||||
---Gets upper bounds of texture coordinates. This is used when sizes
|
||||
---of texture are not equal to the powers of two
|
||||
|
||||
--
|
||||
-- private methods
|
||||
--
|
||||
|
||||
Update (me) is protected;
|
||||
TexturesFolder (myclass) returns AsciiString from TCollection;
|
||||
---Level : Public
|
||||
---Purpose :
|
||||
-- The path to textures determined from CSF_MDTVTexturesDirectory or CASROOT environment variables.
|
||||
-- @return the root folder with default textures.
|
||||
|
||||
fields
|
||||
|
||||
myGraphicDriver : GraphicDriver from Graphic3d;
|
||||
myTexId : Integer from Standard;
|
||||
MyCInitTexture : CInitTexture from Graphic3d is protected;
|
||||
myPath : Path from OSD;
|
||||
myType : TypeOfTexture from Graphic3d;
|
||||
myTexUpperBounds : HArray1OfReal from TColStd;
|
||||
myParams : TextureParams from Graphic3d is protected;
|
||||
myTexId : AsciiString from TCollection is protected;
|
||||
myPath : Path from OSD is protected;
|
||||
myType : TypeOfTexture from Graphic3d;
|
||||
|
||||
end TextureRoot;
|
||||
|
@ -24,44 +24,76 @@
|
||||
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <OSD_Protection.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <stdio.h>
|
||||
#include <Standard_Atomic.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
static volatile Standard_Integer THE_TEXTURE_COUNTER = 0;
|
||||
};
|
||||
|
||||
// =======================================================================
|
||||
// function : TexturesFolder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Graphic3d_TextureRoot::TexturesFolder()
|
||||
{
|
||||
static Standard_Boolean IsDefined = Standard_False;
|
||||
static TCollection_AsciiString VarName;
|
||||
if (!IsDefined)
|
||||
{
|
||||
IsDefined = Standard_True;
|
||||
OSD_Environment aTexDirEnv ("CSF_MDTVTexturesDirectory");
|
||||
VarName = aTexDirEnv.Value();
|
||||
if (VarName.IsEmpty())
|
||||
{
|
||||
OSD_Environment aCasRootEnv ("CASROOT");
|
||||
VarName = aCasRootEnv.Value();
|
||||
if (!VarName.IsEmpty())
|
||||
{
|
||||
VarName += "/src/Textures";
|
||||
}
|
||||
}
|
||||
|
||||
if (VarName.IsEmpty())
|
||||
{
|
||||
std::cerr << " CSF_MDTVTexturesDirectory and CASROOT not setted\n";
|
||||
std::cerr << " one of these variable are mandatory to use this functionality\n";
|
||||
Standard_Failure::Raise ("CSF_MDTVTexturesDirectory and CASROOT not setted");
|
||||
return VarName;
|
||||
}
|
||||
|
||||
const OSD_Path aDirPath (VarName);
|
||||
OSD_Directory aDir (aDirPath);
|
||||
const TCollection_AsciiString aTexture = VarName + "/2d_MatraDatavision.rgb";
|
||||
OSD_File aTextureFile (aTexture);
|
||||
if (!aDir.Exists() || !aTextureFile.Exists())
|
||||
{
|
||||
std::cerr << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted\n";
|
||||
std::cerr << " not all files are found in : "<< VarName.ToCString() << std::endl;
|
||||
Standard_Failure::Raise ("CSF_MDTVTexturesDirectory or CASROOT not correctly setted");
|
||||
return VarName;
|
||||
}
|
||||
}
|
||||
return VarName;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_TextureRoot
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TextureRoot::Graphic3d_TextureRoot (const Handle(Graphic3d_StructureManager)& theSM,
|
||||
const Standard_CString thePath,
|
||||
const Standard_CString theFileName,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
: myGraphicDriver (Handle(Graphic3d_GraphicDriver)::DownCast (theSM->GraphicDevice()->GraphicDriver())),
|
||||
myTexId (-1),
|
||||
myPath (theFileName),
|
||||
myType (theType),
|
||||
myTexUpperBounds (new TColStd_HArray1OfReal (1, 2)) // currently always allocating an array for two texture bounds...
|
||||
Graphic3d_TextureRoot::Graphic3d_TextureRoot (const TCollection_AsciiString& theFileName,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
: myParams (new Graphic3d_TextureParams()),
|
||||
myPath (theFileName),
|
||||
myType (theType)
|
||||
{
|
||||
if (thePath != NULL && (strlen (thePath) > 0))
|
||||
{
|
||||
myPath.SetTrek (TCollection_AsciiString (thePath));
|
||||
}
|
||||
|
||||
if (theFileName == NULL || (strlen (theFileName) <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aFilePath;
|
||||
myPath.SystemName (aFilePath);
|
||||
Image_AlienPixMap anImage;
|
||||
if (!anImage.Load (aFilePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myTexId = myGraphicDriver->CreateTexture (myType, anImage, theFileName, myTexUpperBounds);
|
||||
Update();
|
||||
myTexId = TCollection_AsciiString ("Graphic3d_TextureRoot_") //DynamicType()->Name()
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_TEXTURE_COUNTER));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -70,40 +102,47 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const Handle(Graphic3d_StructureMa
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureRoot::Destroy() const
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
myGraphicDriver->DestroyTexture (myTexId);
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : TextureId
|
||||
// function : GetId
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Graphic3d_TextureRoot::TextureId() const
|
||||
TCollection_AsciiString Graphic3d_TextureRoot::GetId() const
|
||||
{
|
||||
return myTexId;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Update
|
||||
// function : GetParams
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_TextureRoot::Update() const
|
||||
const Handle(Graphic3d_TextureParams)& Graphic3d_TextureRoot::GetParams() const
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
myGraphicDriver->ModifyTexture (myTexId, MyCInitTexture);
|
||||
}
|
||||
return myParams;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsValid
|
||||
// function : GetImage
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_TextureRoot::IsValid() const
|
||||
Handle(Image_PixMap) Graphic3d_TextureRoot::GetImage() const
|
||||
{
|
||||
return myTexId >= 0;
|
||||
TCollection_AsciiString aFilePath;
|
||||
myPath.SystemName (aFilePath);
|
||||
if (aFilePath.IsEmpty())
|
||||
{
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
|
||||
if (!anImage->Load (aFilePath))
|
||||
{
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
return anImage;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -112,23 +151,8 @@ Standard_Boolean Graphic3d_TextureRoot::IsValid() const
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_TextureRoot::IsDone() const
|
||||
{
|
||||
return myTexId >= 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : LoadTexture
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_TextureRoot::LoadTexture (const Image_PixMap& theImage)
|
||||
{
|
||||
if (myTexId >= 0)
|
||||
{
|
||||
myGraphicDriver->DestroyTexture (myTexId);
|
||||
}
|
||||
|
||||
myTexId = myGraphicDriver->CreateTexture (myType, theImage, "", myTexUpperBounds);
|
||||
Update();
|
||||
return IsValid();
|
||||
OSD_File aTextureFile (myPath);
|
||||
return aTextureFile.Exists();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -148,12 +172,3 @@ Graphic3d_TypeOfTexture Graphic3d_TextureRoot::Type() const
|
||||
{
|
||||
return myType;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetTexUpperBounds
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(TColStd_HArray1OfReal) Graphic3d_TextureRoot::GetTexUpperBounds() const
|
||||
{
|
||||
return myTexUpperBounds;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
// Copyright (c) 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
|
||||
@ -15,13 +15,12 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#ifndef _Graphic3d_Vec2_HeaderFile
|
||||
#define _Graphic3d_Vec2_HeaderFile
|
||||
|
||||
#include <NCollection_Vec2.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
#include <Graphic3d_CInitTexture.hxx>
|
||||
typedef NCollection_Vec2<Standard_ShortReal> Graphic3d_Vec2;
|
||||
|
||||
const Handle(Standard_Type)& TYPE(Graphic3d_CInitTexture)
|
||||
{
|
||||
static Handle(Standard_Type) _atype =
|
||||
new Standard_Type ("Graphic3d_CInitTexture", sizeof (Graphic3d_CInitTexture));
|
||||
return _atype;
|
||||
}
|
||||
#endif // _Graphic3d_Vec2_HeaderFile
|
26
src/Graphic3d/Graphic3d_Vec3.hxx
Executable file
26
src/Graphic3d/Graphic3d_Vec3.hxx
Executable file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) 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.
|
||||
|
||||
#ifndef _Graphic3d_Vec3_HeaderFile
|
||||
#define _Graphic3d_Vec3_HeaderFile
|
||||
|
||||
#include <NCollection_Vec3.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
typedef NCollection_Vec3<Standard_ShortReal> Graphic3d_Vec3;
|
||||
|
||||
#endif // _Graphic3d_Vec3_HeaderFile
|
26
src/Graphic3d/Graphic3d_Vec4.hxx
Executable file
26
src/Graphic3d/Graphic3d_Vec4.hxx
Executable file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) 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.
|
||||
|
||||
#ifndef _Graphic3d_Vec4_HeaderFile
|
||||
#define _Graphic3d_Vec4_HeaderFile
|
||||
|
||||
#include <NCollection_Vec4.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
typedef NCollection_Vec4<Standard_ShortReal> Graphic3d_Vec4;
|
||||
|
||||
#endif // _Graphic3d_Vec4_HeaderFile
|
@ -8,6 +8,7 @@ Image.edl
|
||||
Image_CMPLRS.edl
|
||||
Image_PixMap.hxx
|
||||
Image_PixMap.cxx
|
||||
Image_PixMap_Handle.hxx
|
||||
Image_PixMapData.hxx
|
||||
Image_Color.hxx
|
||||
Image_AlienPixMap.hxx
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define _Image_PixMap_H__
|
||||
|
||||
#include <Image_PixMapData.hxx>
|
||||
#include <Image_PixMap_Handle.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
@ -289,6 +290,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Image_PixMap, Standard_Transient)
|
||||
|
||||
#endif // _Image_PixMap_H__
|
||||
|
28
src/Image/Image_PixMap_Handle.hxx
Normal file
28
src/Image/Image_PixMap_Handle.hxx
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 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.
|
||||
|
||||
#ifndef _Image_PixMap_Handle_H__
|
||||
#define _Image_PixMap_Handle_H__
|
||||
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <Handle_Standard_Transient.hxx>
|
||||
|
||||
class Image_PixMap;
|
||||
DEFINE_STANDARD_HANDLE(Image_PixMap, Standard_Transient)
|
||||
typedef Handle(Image_PixMap) Image_PixMap_Handle;
|
||||
|
||||
#endif // _Image_PixMap_Handle_H__
|
@ -16,31 +16,14 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*
|
||||
* modified 27/08/97 ; PCT : ajout texture mapping
|
||||
* modified 08/04/98 ; FGU : ajout parametres d emission (CALL_DEF_MATERIAL)
|
||||
* modified 30/11/98 ; FMN : ajout parametres pour les textes visibles
|
||||
* modified 24/01/00 ; EUG : G003 add DegenerationMode flag and SkipRatio value in
|
||||
* CALL_DEF_STRUCTURE.
|
||||
* modified 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef InterfaceGraphic_Graphic3dHeader
|
||||
#define InterfaceGraphic_Graphic3dHeader
|
||||
|
||||
#include <InterfaceGraphic_PrimitiveArray.hxx>
|
||||
|
||||
#define G003 /*EUG 26-01-00 Degeneration management
|
||||
*/
|
||||
|
||||
#define OCC1174 /*SAV 08/01/03 CONTEXTFILLAREA extended with back face interior color*/
|
||||
|
||||
#define OCC2934 /* SAN 22/01/04 Texture mapped fonts on WNT */
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
#ifdef THIS
|
||||
#undef THIS
|
||||
#undef THIS
|
||||
#endif
|
||||
|
||||
#define CALL_DEF_STRUCTHIGHLIGHTED 1
|
||||
@ -259,7 +242,7 @@ typedef struct {
|
||||
int HAlign;
|
||||
|
||||
int VAlign;
|
||||
|
||||
|
||||
bool Zoomable;
|
||||
|
||||
} CALL_DEF_TEXT;
|
||||
@ -378,90 +361,16 @@ typedef struct {
|
||||
float Shininess;
|
||||
|
||||
float EnvReflexion;
|
||||
|
||||
|
||||
int IsPhysic;
|
||||
|
||||
/* Attribut couleur eclairage */
|
||||
CALL_DEF_COLOR ColorAmb, ColorDif, ColorSpec, ColorEms, Color;
|
||||
|
||||
CALL_DEF_COLOR ColorAmb, ColorDif, ColorSpec, ColorEms, Color;
|
||||
|
||||
|
||||
} CALL_DEF_MATERIAL;
|
||||
|
||||
|
||||
/* TEXTURE */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int doModulate;
|
||||
int doRepeat;
|
||||
int Mode;
|
||||
int doLinear;
|
||||
float sx, sy;
|
||||
float tx, ty;
|
||||
float angle;
|
||||
|
||||
float sparams[4];
|
||||
float tparams[4];
|
||||
|
||||
} CALL_DEF_INIT_TEXTURE;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int TexId;
|
||||
int doTextureMap;
|
||||
|
||||
} CALL_DEF_TEXTURE;
|
||||
|
||||
|
||||
|
||||
/* CONTEXTE POLYGONE */
|
||||
|
||||
typedef struct {
|
||||
|
||||
int IsDef;
|
||||
|
||||
int IsSet;
|
||||
|
||||
int Style;
|
||||
|
||||
CALL_DEF_COLOR IntColor;
|
||||
|
||||
#ifdef OCC1174
|
||||
CALL_DEF_COLOR BackIntColor;
|
||||
#endif
|
||||
|
||||
CALL_DEF_COLOR EdgeColor;
|
||||
|
||||
int LineType;
|
||||
|
||||
float Width;
|
||||
|
||||
int Hatch;
|
||||
|
||||
int Distinguish;
|
||||
int BackFace;
|
||||
|
||||
int Edge;
|
||||
|
||||
CALL_DEF_MATERIAL Front;
|
||||
CALL_DEF_MATERIAL Back;
|
||||
|
||||
CALL_DEF_TEXTURE Texture;
|
||||
|
||||
#ifdef G003
|
||||
int DegenerationMode;
|
||||
float SkipRatio;
|
||||
#endif
|
||||
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
|
||||
int PolygonOffsetMode;
|
||||
float PolygonOffsetFactor;
|
||||
float PolygonOffsetUnits;
|
||||
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
|
||||
|
||||
} CALL_DEF_CONTEXTFILLAREA;
|
||||
|
||||
|
||||
/* CONTEXTE MARKER */
|
||||
|
||||
typedef struct {
|
||||
@ -494,20 +403,20 @@ typedef struct {
|
||||
float Expan;
|
||||
|
||||
CALL_DEF_COLOR Color;
|
||||
|
||||
|
||||
int Style;
|
||||
|
||||
|
||||
int DisplayType;
|
||||
|
||||
CALL_DEF_COLOR ColorSubTitle;
|
||||
|
||||
int TextZoomable;
|
||||
|
||||
|
||||
float TextAngle;
|
||||
|
||||
int TextFontAspect;
|
||||
|
||||
|
||||
|
||||
|
||||
} CALL_DEF_CONTEXTTEXT;
|
||||
|
||||
/* Transform persistence struct */
|
||||
@ -519,72 +428,6 @@ typedef struct
|
||||
CALL_DEF_POINT Point;
|
||||
} CALL_DEF_TRANSFORM_PERSISTENCE;
|
||||
|
||||
/* STRUCTURE */
|
||||
|
||||
typedef struct {
|
||||
|
||||
int Id;
|
||||
void *ptrStructure;
|
||||
|
||||
int Priority;
|
||||
int PreviousPriority;
|
||||
int GroupBegin;
|
||||
int GroupEnd;
|
||||
|
||||
CALL_DEF_CONTEXTLINE ContextLine;
|
||||
CALL_DEF_CONTEXTFILLAREA ContextFillArea;
|
||||
CALL_DEF_CONTEXTMARKER ContextMarker;
|
||||
CALL_DEF_CONTEXTTEXT ContextText;
|
||||
|
||||
CALL_DEF_BOUNDBOX BoundBox;
|
||||
|
||||
float Transformation[4][4];
|
||||
int Composition;
|
||||
|
||||
int ContainsFacet;
|
||||
|
||||
unsigned IsDeleted :1;
|
||||
unsigned IsOpen :1;
|
||||
unsigned IsInfinite :1;
|
||||
unsigned stick :1;
|
||||
unsigned highlight :1;
|
||||
unsigned visible :1;
|
||||
unsigned pick :1;
|
||||
unsigned HLRValidation :1;
|
||||
/* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
|
||||
/*int TransformPersistenceFlag;
|
||||
CALL_DEF_POINT TransformPersistencePoint;
|
||||
*/
|
||||
CALL_DEF_TRANSFORM_PERSISTENCE TransformPersistence;
|
||||
/* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
|
||||
} CALL_DEF_STRUCTURE;
|
||||
|
||||
|
||||
/* GROUPE */
|
||||
|
||||
typedef struct {
|
||||
|
||||
int LabelBegin;
|
||||
int LabelEnd;
|
||||
void *ptrGroup;
|
||||
|
||||
int StructureEnd;
|
||||
|
||||
CALL_DEF_CONTEXTLINE ContextLine;
|
||||
CALL_DEF_CONTEXTFILLAREA ContextFillArea;
|
||||
CALL_DEF_CONTEXTMARKER ContextMarker;
|
||||
CALL_DEF_CONTEXTTEXT ContextText;
|
||||
|
||||
CALL_DEF_STRUCTURE *Struct;
|
||||
|
||||
CALL_DEF_PICKID PickId;
|
||||
|
||||
unsigned IsDeleted :1;
|
||||
unsigned IsOpen :1;
|
||||
/*int TransformPersistenceFlag;*/
|
||||
|
||||
} CALL_DEF_GROUP;
|
||||
|
||||
/* BOUNDING BOX */
|
||||
|
||||
typedef struct {
|
||||
@ -592,7 +435,7 @@ typedef struct {
|
||||
float XMin;
|
||||
float YMin;
|
||||
float ZMin;
|
||||
|
||||
|
||||
float XMax;
|
||||
float YMax;
|
||||
float ZMax;
|
||||
|
@ -16,40 +16,14 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef InterfaceGraphic_Visual3dHeader
|
||||
#define InterfaceGraphic_Visual3dHeader
|
||||
|
||||
/* CAL 02/08/94
|
||||
* #include <InterfaceGraphic_X11.hxx>
|
||||
* Retrait de InterfaceGraphic_X11.hxx et declaration de Window
|
||||
* a la mode X11 dans les structures CALL_DEF_VIEW et CALL_DEF_PICK.
|
||||
* En effet, un #define Opposite 4 se trouve dans X11/X.h
|
||||
* et rentre en conflit avec la methode Opposite de math_Matrix.
|
||||
*
|
||||
* PCT 05/08/97
|
||||
* ajout support texture mapping
|
||||
*
|
||||
* EUG 21/09/99 G003
|
||||
* degenerated mode support
|
||||
Add fields IsDegenerates,IsDegeneratesPrev,Backfacing
|
||||
in CALL_DEF_VIEW structure.
|
||||
* VKH 25/01/00 G004
|
||||
* Dump a view
|
||||
Add CALL_DEF_BITMAP reference in CALL_DEF_VIEW
|
||||
*/
|
||||
|
||||
#ifndef RIC120302
|
||||
#define RIC120302 /*GG Add NEW fields in CALL_DEF_VIEW structure
|
||||
// to manage graphic context and call back
|
||||
*/
|
||||
#endif
|
||||
|
||||
#include <InterfaceGraphic_Aspect.hxx>
|
||||
#ifdef RIC120302
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <Aspect_RenderingContext.hxx>
|
||||
#include <Aspect_GraphicCallbackProc.hxx>
|
||||
#endif
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
typedef float CALL_DEF_MATRIX4X4[4][4];
|
||||
|
||||
@ -151,80 +125,6 @@ typedef struct {
|
||||
|
||||
} CALL_DEF_VIEWMAPPING;
|
||||
|
||||
|
||||
/* CONTEXT */
|
||||
|
||||
typedef struct {
|
||||
|
||||
int Aliasing;
|
||||
|
||||
int BackZClipping;
|
||||
int FrontZClipping;
|
||||
|
||||
int DepthCueing;
|
||||
|
||||
float ZClipFrontPlane;
|
||||
float ZClipBackPlane;
|
||||
|
||||
float DepthFrontPlane;
|
||||
float DepthBackPlane;
|
||||
|
||||
int ZBufferActivity;
|
||||
int Model;
|
||||
int Visualization;
|
||||
|
||||
int NbActiveLight;
|
||||
CALL_DEF_LIGHT *ActiveLight;
|
||||
|
||||
int NbActivePlane;
|
||||
CALL_DEF_PLANE *ActivePlane;
|
||||
|
||||
int TexEnvId;
|
||||
int SurfaceDetail;
|
||||
|
||||
} CALL_DEF_VIEWCONTEXT;
|
||||
|
||||
|
||||
/* VUE */
|
||||
|
||||
typedef struct {
|
||||
|
||||
int WsId;
|
||||
int ViewId;
|
||||
void *ptrView;
|
||||
|
||||
int IsDeleted;
|
||||
int IsOpen;
|
||||
|
||||
int Active;
|
||||
|
||||
CALL_DEF_VIEWORIENTATION Orientation;
|
||||
CALL_DEF_VIEWMAPPING Mapping;
|
||||
|
||||
CALL_DEF_VIEWORIENTATION OrientationReset;
|
||||
CALL_DEF_VIEWMAPPING MappingReset;
|
||||
|
||||
CALL_DEF_VIEWCONTEXT Context;
|
||||
|
||||
CALL_DEF_WINDOW DefWindow;
|
||||
|
||||
void *ptrUnderLayer;
|
||||
void *ptrOverLayer;
|
||||
|
||||
int IsDegenerates;
|
||||
int IsDegeneratesPrev;
|
||||
int Backfacing;
|
||||
#ifdef RIC120302
|
||||
Aspect_RenderingContext GContext;
|
||||
Aspect_GraphicCallbackProc GDisplayCB;
|
||||
void* GClientData;
|
||||
#endif
|
||||
|
||||
void *ptrFBO;
|
||||
|
||||
} CALL_DEF_VIEW;
|
||||
|
||||
|
||||
/* REPERAGE */
|
||||
|
||||
typedef struct {
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
@ -69,48 +70,46 @@
|
||||
*/
|
||||
class MeshVS_ImageTexture2D : public Graphic3d_Texture2D
|
||||
{
|
||||
public:
|
||||
MeshVS_ImageTexture2D (Handle(Graphic3d_StructureManager) theSM,
|
||||
const Image_PixMap& theImg);
|
||||
virtual ~MeshVS_ImageTexture2D();
|
||||
|
||||
public:
|
||||
|
||||
MeshVS_ImageTexture2D (const Handle(Image_PixMap)& theImg)
|
||||
: Graphic3d_Texture2D ("", Graphic3d_TOT_2D),
|
||||
myImage (theImg)
|
||||
{
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_BILINEAR);
|
||||
}
|
||||
|
||||
virtual ~MeshVS_ImageTexture2D()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
virtual Standard_Boolean IsDone() const
|
||||
{
|
||||
return !myImage.IsNull() && !myImage->IsEmpty();
|
||||
}
|
||||
|
||||
virtual Handle(Image_PixMap) GetImage() const
|
||||
{
|
||||
return myImage;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Handle(Image_PixMap) myImage;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(MeshVS_ImageTexture2D)
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (MeshVS_ImageTexture2D, Graphic3d_Texture2D)
|
||||
IMPLEMENT_STANDARD_HANDLE (MeshVS_ImageTexture2D, Graphic3d_Texture2D)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(MeshVS_ImageTexture2D, Graphic3d_Texture2D)
|
||||
|
||||
MeshVS_ImageTexture2D::MeshVS_ImageTexture2D (Handle(Graphic3d_StructureManager) theSM,
|
||||
const Image_PixMap& theImg)
|
||||
: Graphic3d_Texture2D (theSM, "", Graphic3d_TOT_2D)
|
||||
{
|
||||
MyCInitTexture.doModulate = 1;
|
||||
MyCInitTexture.doRepeat = 0;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_MANUAL;
|
||||
MyCInitTexture.doLinear = 1;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
LoadTexture(theImg);
|
||||
}
|
||||
|
||||
MeshVS_ImageTexture2D::~MeshVS_ImageTexture2D()
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : getNearestPow2
|
||||
// Purpose : Returns the nearest power of two greater than the
|
||||
@ -723,21 +722,15 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Handle(PrsMgr_PresentationManager3d) aPrsMgr = GetPresentationManager();
|
||||
if (aPrsMgr.IsNull())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// create and fill image with colors
|
||||
Image_PixMap anImage;
|
||||
if (!anImage.InitTrash (Image_PixMap::ImgRGBA, Standard_Size(getNearestPow2 (aColorsNb)), 2))
|
||||
Handle(Image_PixMap) anImage = new Image_PixMap();
|
||||
if (!anImage->InitTrash (Image_PixMap::ImgRGBA, Standard_Size(getNearestPow2 (aColorsNb)), 2))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
anImage.SetTopDown (false);
|
||||
Image_PixMapData<Image_ColorRGBA>& aData = anImage.EditData<Image_ColorRGBA>();
|
||||
anImage->SetTopDown (false);
|
||||
Image_PixMapData<Image_ColorRGBA>& aData = anImage->EditData<Image_ColorRGBA>();
|
||||
for (Standard_Size aCol = 0; aCol < Standard_Size(aColorsNb); ++aCol)
|
||||
{
|
||||
const Quantity_Color& aSrcColor = myTextureColorMap.Value (Standard_Integer(aCol) + 1);
|
||||
@ -759,7 +752,7 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const
|
||||
}};
|
||||
|
||||
// fill second row
|
||||
for (Standard_Size aCol = (Standard_Size )aColorsNb; aCol < anImage.SizeX(); ++aCol)
|
||||
for (Standard_Size aCol = (Standard_Size )aColorsNb; aCol < anImage->SizeX(); ++aCol)
|
||||
{
|
||||
aData.ChangeValue (0, aCol) = aLastColor;
|
||||
}
|
||||
@ -771,11 +764,11 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const
|
||||
int(255.0 * myInvalidColor.Blue()),
|
||||
0xFF
|
||||
}};
|
||||
for (Standard_Size aCol = 0; aCol < anImage.SizeX(); ++aCol)
|
||||
for (Standard_Size aCol = 0; aCol < anImage->SizeX(); ++aCol)
|
||||
{
|
||||
aData.ChangeValue (1, aCol) = anInvalidColor;
|
||||
}
|
||||
|
||||
// create texture
|
||||
return new MeshVS_ImageTexture2D (aPrsMgr->StructureManager(), anImage);
|
||||
return new MeshVS_ImageTexture2D (anImage);
|
||||
}
|
||||
|
@ -19,11 +19,13 @@
|
||||
#ifndef _NCollection_Vec2_H__
|
||||
#define _NCollection_Vec2_H__
|
||||
|
||||
#include <cmath> // std::sqrt()
|
||||
|
||||
//! Auxiliary macros to define couple of similar access components as vector methods.
|
||||
//! @return 2 components by their names in specified order
|
||||
#define NCOLLECTION_VEC_COMPONENTS_2D(theX, theY) \
|
||||
const NCollection_Vec2<Element_t> theX##theY##() const { return NCollection_Vec2<Element_t>(theX##(), theY##()); } \
|
||||
const NCollection_Vec2<Element_t> theY##theX##() const { return NCollection_Vec2<Element_t>(theY##(), theX##()); }
|
||||
const NCollection_Vec2<Element_t> theX##theY() const { return NCollection_Vec2<Element_t>(theX(), theY()); } \
|
||||
const NCollection_Vec2<Element_t> theY##theX() const { return NCollection_Vec2<Element_t>(theY(), theX()); }
|
||||
|
||||
//! Defines the 2D-vector template.
|
||||
//! The main target for this class - to handle raw low-level arrays (from/to graphic driver etc.).
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
//! Auxiliary macros to define couple of similar access components as vector methods
|
||||
#define NCOLLECTION_VEC_COMPONENTS_3D(theX, theY, theZ) \
|
||||
const NCollection_Vec3<Element_t> theX##theY##theZ##() const { return NCollection_Vec3<Element_t>(theX##(), theY##(), theZ##()); } \
|
||||
const NCollection_Vec3<Element_t> theX##theZ##theY##() const { return NCollection_Vec3<Element_t>(theX##(), theZ##(), theY##()); } \
|
||||
const NCollection_Vec3<Element_t> theY##theX##theZ##() const { return NCollection_Vec3<Element_t>(theY##(), theX##(), theZ##()); } \
|
||||
const NCollection_Vec3<Element_t> theY##theZ##theX##() const { return NCollection_Vec3<Element_t>(theY##(), theZ##(), theX##()); } \
|
||||
const NCollection_Vec3<Element_t> theZ##theY##theX##() const { return NCollection_Vec3<Element_t>(theZ##(), theY##(), theX##()); } \
|
||||
const NCollection_Vec3<Element_t> theZ##theX##theY##() const { return NCollection_Vec3<Element_t>(theZ##(), theX##(), theY##()); }
|
||||
const NCollection_Vec3<Element_t> theX##theY##theZ() const { return NCollection_Vec3<Element_t>(theX(), theY(), theZ()); } \
|
||||
const NCollection_Vec3<Element_t> theX##theZ##theY() const { return NCollection_Vec3<Element_t>(theX(), theZ(), theY()); } \
|
||||
const NCollection_Vec3<Element_t> theY##theX##theZ() const { return NCollection_Vec3<Element_t>(theY(), theX(), theZ()); } \
|
||||
const NCollection_Vec3<Element_t> theY##theZ##theX() const { return NCollection_Vec3<Element_t>(theY(), theZ(), theX()); } \
|
||||
const NCollection_Vec3<Element_t> theZ##theY##theX() const { return NCollection_Vec3<Element_t>(theZ(), theY(), theX()); } \
|
||||
const NCollection_Vec3<Element_t> theZ##theX##theY() const { return NCollection_Vec3<Element_t>(theZ(), theX(), theY()); }
|
||||
|
||||
//! Generic 3-components vector.
|
||||
//! To be used as RGB color pixel or XYZ 3D-point.
|
||||
|
@ -86,12 +86,11 @@ OpenGl_telem_view.cxx
|
||||
OpenGl_telem_view.hxx
|
||||
OpenGl_FrameBuffer.hxx
|
||||
OpenGl_FrameBuffer.cxx
|
||||
OpenGl_TextureBox.cxx
|
||||
OpenGl_TextureBox.hxx
|
||||
OpenGl_Texture.cxx
|
||||
OpenGl_Texture.hxx
|
||||
Handle_OpenGl_Texture.hxx
|
||||
OpenGl_Resource.hxx
|
||||
OpenGl_Resource.cxx
|
||||
OpenGl_ResourceTexture.hxx
|
||||
OpenGl_ResourceTexture.cxx
|
||||
OpenGl_telem_util.hxx
|
||||
OpenGl_telem_util.cxx
|
||||
OpenGl_transform_persistence.hxx
|
||||
|
43
src/OpenGl/OpenGl_ResourceTexture.hxx → src/OpenGl/Handle_OpenGl_Texture.hxx
Executable file → Normal file
43
src/OpenGl/OpenGl_ResourceTexture.hxx → src/OpenGl/Handle_OpenGl_Texture.hxx
Executable file → Normal file
@ -1,6 +1,4 @@
|
||||
// Created on: 2011-03-18
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2011-2012 OPEN CASCADE SAS
|
||||
// Copyright (c) 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
|
||||
@ -17,41 +15,12 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef _OPENGL_RESOURCETEXTURE_H
|
||||
#define _OPENGL_RESOURCETEXTURE_H
|
||||
#ifndef _Handle_OpenGl_Texture_Header
|
||||
#define _Handle_OpenGl_Texture_Header
|
||||
|
||||
#include <OpenGl_Resource.hxx>
|
||||
#include <Standard.hxx>
|
||||
|
||||
class OpenGl_Resource;
|
||||
class OpenGl_Texture;
|
||||
DEFINE_STANDARD_HANDLE(OpenGl_Texture, OpenGl_Resource)
|
||||
|
||||
//! OpenGl_ResourceTexture represents the texture resource
|
||||
//! for OpenGl_ResourceCleaner
|
||||
class OpenGl_ResourceTexture : public OpenGl_Resource
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT OpenGl_ResourceTexture (const GLuint theId);
|
||||
|
||||
//! Destructor
|
||||
Standard_EXPORT virtual ~OpenGl_ResourceTexture();
|
||||
|
||||
//! Destroy object - will release GPU memory if any.
|
||||
Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx);
|
||||
|
||||
protected:
|
||||
|
||||
GLuint myTextureId; //!< Texture name (index)
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(OpenGl_ResourceTexture) // Type definition
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(OpenGl_ResourceTexture,OpenGl_Resource)
|
||||
|
||||
#endif
|
||||
#endif // _Handle_OpenGl_Texture_Header
|
@ -17,219 +17,275 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_AspectFace.hxx>
|
||||
#include <OpenGl_Texture.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <Aspect_PolygonOffsetMode.hxx>
|
||||
#include <Graphic3d_CGroup.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
static const TEL_CONTEXT_FACE myDefaultAspectFace =
|
||||
namespace
|
||||
{
|
||||
Aspect_IS_SOLID,
|
||||
TOn, TEL_HS_SOLID, TOn, TelCullNone,
|
||||
{ 0.2F, 0.8F, 0.1F, 0.0F, /* amb, diff, spec, emsv */
|
||||
1.0F, 10.0F, 0.0F, /* trans, shine, env_reflexion */
|
||||
0, /* isphysic */
|
||||
(OPENGL_AMBIENT_MASK | OPENGL_DIFFUSE_MASK | OPENGL_SPECULAR_MASK), /* color_mask */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, /* ambient color */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, /* diffuse color */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, /* specular color */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, /* emissive color */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }} /* material color */
|
||||
},
|
||||
{ 0.2F, 0.8F, 0.1F, 0.0F, /* amb, diff, spec, emsv */
|
||||
1.0F, 10.0F, 0.0F, /* trans, shine, env_reflexion */
|
||||
0, /* isphysic */
|
||||
(OPENGL_AMBIENT_MASK | OPENGL_DIFFUSE_MASK | OPENGL_SPECULAR_MASK), /* color_mask */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, /* ambient color */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, /* diffuse color */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, /* specular color */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, /* emissive color */
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }} /* material color */
|
||||
},
|
||||
0, -1, { Aspect_POM_Fill, 1.0F, 0.0F }
|
||||
|
||||
static OPENGL_SURF_PROP THE_DEFAULT_MATERIAL =
|
||||
{
|
||||
0.2F, 0.8F, 0.1F, 0.0F, // amb, diff, spec, emsv
|
||||
1.0F, 10.0F, 0.0F, // trans, shine, env_reflexion
|
||||
0, // isphysic
|
||||
(OPENGL_AMBIENT_MASK | OPENGL_DIFFUSE_MASK | OPENGL_SPECULAR_MASK), // color_mask
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, // ambient color
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, // diffuse color
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, // specular color
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, // emissive color
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }} // material color
|
||||
};
|
||||
|
||||
static TEL_POFFSET_PARAM THE_DEFAULT_POFFSET = { Aspect_POM_Fill, 1.0F, 0.0F };
|
||||
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
static void ConvertMaterial (const CALL_DEF_MATERIAL &material, OPENGL_SURF_PROP &surface)
|
||||
// =======================================================================
|
||||
// function : convertMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_AspectFace::convertMaterial (const CALL_DEF_MATERIAL& theMat,
|
||||
OPENGL_SURF_PROP& theSurf)
|
||||
{
|
||||
/* Cas par cas pour l evaluation */
|
||||
surface.amb = material.IsAmbient? material.Ambient : 0.F;
|
||||
surface.diff = material.IsDiffuse? material.Diffuse : 0.F;
|
||||
surface.spec = material.IsSpecular? material.Specular : 0.F;
|
||||
surface.emsv = material.IsEmission? material.Emission : 0.F;
|
||||
theSurf.amb = theMat.IsAmbient ? theMat.Ambient : 0.0f;
|
||||
theSurf.diff = theMat.IsDiffuse ? theMat.Diffuse : 0.0f;
|
||||
theSurf.spec = theMat.IsSpecular ? theMat.Specular : 0.0f;
|
||||
theSurf.emsv = theMat.IsEmission ? theMat.Emission : 0.0f;
|
||||
|
||||
/* type de materiel */
|
||||
surface.isphysic = material.IsPhysic? 1 : 0;
|
||||
theSurf.isphysic = theMat.IsPhysic ? 1 : 0; // type of material
|
||||
|
||||
/* Couleur du materiel */
|
||||
surface.color_mask = 0;
|
||||
if ( material.IsAmbient )
|
||||
surface.color_mask |= OPENGL_AMBIENT_MASK;
|
||||
if ( material.IsDiffuse )
|
||||
surface.color_mask |= OPENGL_DIFFUSE_MASK;
|
||||
if ( material.IsSpecular )
|
||||
surface.color_mask |= OPENGL_SPECULAR_MASK;
|
||||
if ( material.IsEmission )
|
||||
surface.color_mask |= OPENGL_EMISSIVE_MASK;
|
||||
// color of material
|
||||
theSurf.color_mask = 0;
|
||||
if (theMat.IsAmbient)
|
||||
{
|
||||
theSurf.color_mask |= OPENGL_AMBIENT_MASK;
|
||||
}
|
||||
if (theMat.IsDiffuse)
|
||||
{
|
||||
theSurf.color_mask |= OPENGL_DIFFUSE_MASK;
|
||||
}
|
||||
if (theMat.IsSpecular)
|
||||
{
|
||||
theSurf.color_mask |= OPENGL_SPECULAR_MASK;
|
||||
}
|
||||
if (theMat.IsEmission)
|
||||
{
|
||||
theSurf.color_mask |= OPENGL_EMISSIVE_MASK;
|
||||
}
|
||||
|
||||
/* Couleur eclairage ambient */
|
||||
surface.ambcol.rgb[0] = material.ColorAmb.r;
|
||||
surface.ambcol.rgb[1] = material.ColorAmb.g;
|
||||
surface.ambcol.rgb[2] = material.ColorAmb.b;
|
||||
surface.ambcol.rgb[3] = 1.F;
|
||||
// ambient color
|
||||
theSurf.ambcol.rgb[0] = theMat.ColorAmb.r;
|
||||
theSurf.ambcol.rgb[1] = theMat.ColorAmb.g;
|
||||
theSurf.ambcol.rgb[2] = theMat.ColorAmb.b;
|
||||
theSurf.ambcol.rgb[3] = 1.0f;
|
||||
|
||||
/* Couleur eclairage diffus */
|
||||
surface.difcol.rgb[0] = material.ColorDif.r;
|
||||
surface.difcol.rgb[1] = material.ColorDif.g;
|
||||
surface.difcol.rgb[2] = material.ColorDif.b;
|
||||
surface.difcol.rgb[3] = 1.F;
|
||||
// diffuse color
|
||||
theSurf.difcol.rgb[0] = theMat.ColorDif.r;
|
||||
theSurf.difcol.rgb[1] = theMat.ColorDif.g;
|
||||
theSurf.difcol.rgb[2] = theMat.ColorDif.b;
|
||||
theSurf.difcol.rgb[3] = 1.0f;
|
||||
|
||||
/* Couleur eclairage speculaire */
|
||||
surface.speccol.rgb[0] = material.ColorSpec.r;
|
||||
surface.speccol.rgb[1] = material.ColorSpec.g;
|
||||
surface.speccol.rgb[2] = material.ColorSpec.b;
|
||||
surface.speccol.rgb[3] = 1.F;
|
||||
// specular color
|
||||
theSurf.speccol.rgb[0] = theMat.ColorSpec.r;
|
||||
theSurf.speccol.rgb[1] = theMat.ColorSpec.g;
|
||||
theSurf.speccol.rgb[2] = theMat.ColorSpec.b;
|
||||
theSurf.speccol.rgb[3] = 1.0f;
|
||||
|
||||
/* Couleur d emission */
|
||||
surface.emscol.rgb[0] = material.ColorEms.r;
|
||||
surface.emscol.rgb[1] = material.ColorEms.g;
|
||||
surface.emscol.rgb[2] = material.ColorEms.b;
|
||||
surface.emscol.rgb[3] = 1.F;
|
||||
// emission color
|
||||
theSurf.emscol.rgb[0] = theMat.ColorEms.r;
|
||||
theSurf.emscol.rgb[1] = theMat.ColorEms.g;
|
||||
theSurf.emscol.rgb[2] = theMat.ColorEms.b;
|
||||
theSurf.emscol.rgb[3] = 1.0f;
|
||||
|
||||
surface.shine = ( float )128 * material.Shininess;
|
||||
surface.env_reflexion = material.EnvReflexion;
|
||||
theSurf.shine = 128.0f * float(theMat.Shininess);
|
||||
theSurf.env_reflexion = theMat.EnvReflexion;
|
||||
|
||||
/* Dans la couche C++ :
|
||||
* prop->trans = 0. => opaque
|
||||
* prop->trans = 1. => transparent
|
||||
* in OpenGl it is opposite.
|
||||
*/
|
||||
surface.trans = 1.0F - material.Transparency;
|
||||
// trans = 0. => opaque
|
||||
// trans = 1. => transparent
|
||||
// in OpenGl it is opposite.
|
||||
theSurf.trans = 1.0f - theMat.Transparency;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
OpenGl_AspectFace::OpenGl_AspectFace ()
|
||||
: myContext(myDefaultAspectFace)
|
||||
{}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void OpenGl_AspectFace::SetContext (const CALL_DEF_CONTEXTFILLAREA &AContext)
|
||||
// =======================================================================
|
||||
// function : OpenGl_AspectFace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_AspectFace::OpenGl_AspectFace()
|
||||
: InteriorStyle (Aspect_IS_SOLID),
|
||||
Edge (Aspect_IS_SOLID),
|
||||
Hatch (TOn),
|
||||
DistinguishingMode (TEL_HS_SOLID),
|
||||
CullingMode (TelCullNone),
|
||||
doTextureMap (0)
|
||||
{
|
||||
//TelInteriorStyle
|
||||
myContext.InteriorStyle = (Aspect_InteriorStyle) AContext.Style;
|
||||
IntFront = THE_DEFAULT_MATERIAL;
|
||||
IntBack = THE_DEFAULT_MATERIAL;
|
||||
PolygonOffset = THE_DEFAULT_POFFSET;
|
||||
}
|
||||
|
||||
//TelEdgeFlag
|
||||
myContext.Edge = AContext.Edge ? TOn : TOff;
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_AspectFace::Init (const Handle(OpenGl_Context)& theContext,
|
||||
const CALL_DEF_CONTEXTFILLAREA& theAspect)
|
||||
{
|
||||
InteriorStyle = (Aspect_InteriorStyle )theAspect.Style;
|
||||
Edge = theAspect.Edge ? TOn : TOff;
|
||||
|
||||
//TelInteriorStyleIndex
|
||||
switch( AContext.Hatch )
|
||||
switch (theAspect.Hatch)
|
||||
{
|
||||
case 0 : /* Aspect_HS_HORIZONTAL */
|
||||
myContext.Hatch = TEL_HS_HORIZONTAL;
|
||||
case 0: /* Aspect_HS_HORIZONTAL */
|
||||
Hatch = TEL_HS_HORIZONTAL;
|
||||
break;
|
||||
case 1 : /* Aspect_HS_HORIZONTAL_WIDE */
|
||||
myContext.Hatch = TEL_HS_HORIZONTAL_SPARSE;
|
||||
case 1: /* Aspect_HS_HORIZONTAL_WIDE */
|
||||
Hatch = TEL_HS_HORIZONTAL_SPARSE;
|
||||
break;
|
||||
case 2 : /* Aspect_HS_VERTICAL */
|
||||
myContext.Hatch = TEL_HS_VERTICAL;
|
||||
case 2: /* Aspect_HS_VERTICAL */
|
||||
Hatch = TEL_HS_VERTICAL;
|
||||
break;
|
||||
case 3 : /* Aspect_HS_VERTICAL_WIDE */
|
||||
myContext.Hatch = TEL_HS_VERTICAL_SPARSE;
|
||||
case 3: /* Aspect_HS_VERTICAL_WIDE */
|
||||
Hatch = TEL_HS_VERTICAL_SPARSE;
|
||||
break;
|
||||
case 4 : /* Aspect_HS_DIAGONAL_45 */
|
||||
myContext.Hatch = TEL_HS_DIAG_45;
|
||||
case 4: /* Aspect_HS_DIAGONAL_45 */
|
||||
Hatch = TEL_HS_DIAG_45;
|
||||
break;
|
||||
case 5 : /* Aspect_HS_DIAGONAL_45_WIDE */
|
||||
myContext.Hatch = TEL_HS_DIAG_45_SPARSE;
|
||||
case 5: /* Aspect_HS_DIAGONAL_45_WIDE */
|
||||
Hatch = TEL_HS_DIAG_45_SPARSE;
|
||||
break;
|
||||
case 6 : /* Aspect_HS_DIAGONAL_135 */
|
||||
myContext.Hatch = TEL_HS_DIAG_135;
|
||||
case 6: /* Aspect_HS_DIAGONAL_135 */
|
||||
Hatch = TEL_HS_DIAG_135;
|
||||
break;
|
||||
case 7 : /* Aspect_HS_DIAGONAL_135_WIDE */
|
||||
myContext.Hatch = TEL_HS_DIAG_135_SPARSE;
|
||||
case 7: /* Aspect_HS_DIAGONAL_135_WIDE */
|
||||
Hatch = TEL_HS_DIAG_135_SPARSE;
|
||||
break;
|
||||
case 8 : /* Aspect_HS_GRID */
|
||||
myContext.Hatch = TEL_HS_GRID;
|
||||
case 8: /* Aspect_HS_GRID */
|
||||
Hatch = TEL_HS_GRID;
|
||||
break;
|
||||
case 9 : /* Aspect_HS_GRID_WIDE */
|
||||
myContext.Hatch = TEL_HS_GRID_SPARSE;
|
||||
case 9: /* Aspect_HS_GRID_WIDE */
|
||||
Hatch = TEL_HS_GRID_SPARSE;
|
||||
break;
|
||||
case 10 : /* Aspect_HS_GRID_DIAGONAL */
|
||||
myContext.Hatch = TEL_HS_CROSS;
|
||||
case 10: /* Aspect_HS_GRID_DIAGONAL */
|
||||
Hatch = TEL_HS_CROSS;
|
||||
break;
|
||||
case 11 : /* Aspect_HS_GRID_DIAGONAL_WIDE */
|
||||
myContext.Hatch = TEL_HS_CROSS_SPARSE;
|
||||
case 11: /* Aspect_HS_GRID_DIAGONAL_WIDE */
|
||||
Hatch = TEL_HS_CROSS_SPARSE;
|
||||
break;
|
||||
default :
|
||||
myContext.Hatch = 0;
|
||||
default:
|
||||
Hatch = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
//TelFaceDistinguishingMode
|
||||
myContext.DistinguishingMode = AContext.Distinguish ? TOn : TOff;
|
||||
DistinguishingMode = theAspect.Distinguish ? TOn : TOff;
|
||||
CullingMode = theAspect.BackFace ? TelCullBack : TelCullNone;
|
||||
|
||||
//TelFaceCullingMode
|
||||
myContext.CullingMode = AContext.BackFace ? TelCullBack : TelCullNone;
|
||||
|
||||
//TelSurfaceAreaProperties
|
||||
ConvertMaterial(AContext.Front,myContext.IntFront);
|
||||
|
||||
//TelBackSurfaceAreaProperties
|
||||
ConvertMaterial(AContext.Back,myContext.IntBack);
|
||||
convertMaterial (theAspect.Front, IntFront);
|
||||
convertMaterial (theAspect.Back, IntBack);
|
||||
|
||||
//TelInteriorColour
|
||||
myContext.IntFront.matcol.rgb[0] = (float) AContext.IntColor.r;
|
||||
myContext.IntFront.matcol.rgb[1] = (float) AContext.IntColor.g;
|
||||
myContext.IntFront.matcol.rgb[2] = (float) AContext.IntColor.b;
|
||||
myContext.IntFront.matcol.rgb[3] = 1.f;
|
||||
IntFront.matcol.rgb[0] = (float )theAspect.IntColor.r;
|
||||
IntFront.matcol.rgb[1] = (float )theAspect.IntColor.g;
|
||||
IntFront.matcol.rgb[2] = (float )theAspect.IntColor.b;
|
||||
IntFront.matcol.rgb[3] = 1.0f;
|
||||
|
||||
//TelBackInteriorColour
|
||||
myContext.IntBack.matcol.rgb[0] = (float) AContext.BackIntColor.r;
|
||||
myContext.IntBack.matcol.rgb[1] = (float) AContext.BackIntColor.g;
|
||||
myContext.IntBack.matcol.rgb[2] = (float) AContext.BackIntColor.b;
|
||||
myContext.IntBack.matcol.rgb[3] = 1.f;
|
||||
IntBack.matcol.rgb[0] = (float )theAspect.BackIntColor.r;
|
||||
IntBack.matcol.rgb[1] = (float )theAspect.BackIntColor.g;
|
||||
IntBack.matcol.rgb[2] = (float )theAspect.BackIntColor.b;
|
||||
IntBack.matcol.rgb[3] = 1.0f;
|
||||
|
||||
//TelDoTextureMap
|
||||
myContext.doTextureMap = AContext.Texture.doTextureMap;
|
||||
// setup texture
|
||||
doTextureMap = theAspect.Texture.doTextureMap;
|
||||
const Handle(Graphic3d_TextureMap)& aNewTexture = theAspect.Texture.TextureMap;
|
||||
TCollection_AsciiString aNewKey = aNewTexture.IsNull() ? TCollection_AsciiString() : aNewTexture->GetId();
|
||||
TextureParams = aNewTexture.IsNull() ? NULL : aNewTexture->GetParams();
|
||||
if (aNewKey.IsEmpty()
|
||||
|| myTextureId != aNewKey)
|
||||
{
|
||||
if (!TextureRes.IsNull())
|
||||
{
|
||||
if (myTextureId.IsEmpty())
|
||||
{
|
||||
theContext->DelayedRelease (TextureRes);
|
||||
TextureRes.Nullify();
|
||||
}
|
||||
else
|
||||
{
|
||||
TextureRes.Nullify(); // we need nullify all handles before ReleaseResource() call
|
||||
theContext->ReleaseResource (myTextureId);
|
||||
}
|
||||
}
|
||||
myTextureId = aNewKey;
|
||||
|
||||
//TelTextureId
|
||||
myContext.TexId = AContext.Texture.TexId;
|
||||
if (!aNewTexture.IsNull())
|
||||
{
|
||||
if (aNewKey.IsEmpty() || !theContext->GetResource<Handle(OpenGl_Texture)> (aNewKey, TextureRes))
|
||||
{
|
||||
TextureRes = new OpenGl_Texture (TextureParams);
|
||||
Handle(Image_PixMap) anImage = aNewTexture->GetImage();
|
||||
if (!anImage.IsNull())
|
||||
{
|
||||
TextureRes->Init (theContext, *anImage.operator->(), aNewTexture->Type());
|
||||
}
|
||||
if (!aNewKey.IsEmpty())
|
||||
{
|
||||
theContext->ShareResource (aNewKey, TextureRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TelPolygonOffset
|
||||
myContext.PolygonOffset.mode = (Aspect_PolygonOffsetMode) AContext.PolygonOffsetMode;
|
||||
myContext.PolygonOffset.factor = AContext.PolygonOffsetFactor;
|
||||
myContext.PolygonOffset.units = AContext.PolygonOffsetUnits;
|
||||
PolygonOffset.mode = (Aspect_PolygonOffsetMode )theAspect.PolygonOffsetMode;
|
||||
PolygonOffset.factor = theAspect.PolygonOffsetFactor;
|
||||
PolygonOffset.units = theAspect.PolygonOffsetUnits;
|
||||
|
||||
CALL_DEF_CONTEXTLINE anEdgeContext;
|
||||
|
||||
//TelEdgeColour
|
||||
anEdgeContext.Color.r = (float) AContext.EdgeColor.r;
|
||||
anEdgeContext.Color.g = (float) AContext.EdgeColor.g;
|
||||
anEdgeContext.Color.b = (float) AContext.EdgeColor.b;
|
||||
|
||||
//TelEdgeType
|
||||
anEdgeContext.LineType = (Aspect_TypeOfLine) AContext.LineType;
|
||||
|
||||
//TelEdgeWidth
|
||||
anEdgeContext.Width = (float) AContext.Width;
|
||||
|
||||
myAspectEdge.SetContext(anEdgeContext);
|
||||
anEdgeContext.Color.r = (float )theAspect.EdgeColor.r;
|
||||
anEdgeContext.Color.g = (float )theAspect.EdgeColor.g;
|
||||
anEdgeContext.Color.b = (float )theAspect.EdgeColor.b;
|
||||
anEdgeContext.LineType = (Aspect_TypeOfLine )theAspect.LineType;
|
||||
anEdgeContext.Width = (float )theAspect.Width;
|
||||
myAspectEdge.SetContext (anEdgeContext);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
// =======================================================================
|
||||
// function : Render
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_AspectFace::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
theWorkspace->SetAspectFace (this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Release
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_AspectFace::Release (const Handle(OpenGl_Context)& theContext)
|
||||
{
|
||||
//
|
||||
if (!TextureRes.IsNull())
|
||||
{
|
||||
if (!theContext.IsNull())
|
||||
{
|
||||
if (myTextureId.IsEmpty())
|
||||
{
|
||||
theContext->DelayedRelease (TextureRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextureRes.Nullify(); // we need nullify all handles before ReleaseResource() call
|
||||
theContext->ReleaseResource (myTextureId);
|
||||
}
|
||||
}
|
||||
TextureRes.Nullify();
|
||||
}
|
||||
myTextureId.Clear();
|
||||
}
|
||||
|
@ -17,20 +17,25 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef _OpenGl_AspectFace_Header
|
||||
#define _OpenGl_AspectFace_Header
|
||||
|
||||
#include <InterfaceGraphic_telem.hxx>
|
||||
#include <Aspect_InteriorStyle.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Handle_Graphic3d_TextureParams.hxx>
|
||||
|
||||
#include <OpenGl_AspectLine.hxx>
|
||||
#include <OpenGl_Element.hxx>
|
||||
#include <Handle_OpenGl_Texture.hxx>
|
||||
|
||||
#define OPENGL_AMBIENT_MASK (1<<0)
|
||||
#define OPENGL_DIFFUSE_MASK (1<<1)
|
||||
#define OPENGL_SPECULAR_MASK (1<<2)
|
||||
#define OPENGL_EMISSIVE_MASK (1<<3)
|
||||
|
||||
class CALL_DEF_CONTEXTFILLAREA;
|
||||
|
||||
struct OPENGL_SURF_PROP
|
||||
{
|
||||
float amb, diff, spec, emsv;
|
||||
@ -42,47 +47,52 @@ struct OPENGL_SURF_PROP
|
||||
DEFINE_STANDARD_ALLOC
|
||||
};
|
||||
|
||||
struct TEL_CONTEXT_FACE
|
||||
{
|
||||
Aspect_InteriorStyle InteriorStyle;
|
||||
int Edge;
|
||||
int Hatch;
|
||||
int DistinguishingMode;
|
||||
int CullingMode;
|
||||
OPENGL_SURF_PROP IntFront;
|
||||
OPENGL_SURF_PROP IntBack;
|
||||
int doTextureMap;
|
||||
int TexId;
|
||||
TEL_POFFSET_PARAM PolygonOffset;
|
||||
DEFINE_STANDARD_ALLOC
|
||||
};
|
||||
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
||||
class OpenGl_AspectFace : public OpenGl_Element
|
||||
{
|
||||
public:
|
||||
|
||||
OpenGl_AspectFace ();
|
||||
public:
|
||||
|
||||
void SetContext (const CALL_DEF_CONTEXTFILLAREA &AContext);
|
||||
OpenGl_AspectFace();
|
||||
|
||||
void SetContext (const TEL_CONTEXT_FACE &AContext) { myContext = AContext; }
|
||||
void SetAspectEdge (const OpenGl_AspectLine * AnAspectEdge) { myAspectEdge = *AnAspectEdge; }
|
||||
void Init (const Handle(OpenGl_Context)& theContext,
|
||||
const CALL_DEF_CONTEXTFILLAREA& theAspect);
|
||||
|
||||
const TEL_CONTEXT_FACE & Context() const { return myContext; }
|
||||
const OpenGl_AspectLine * AspectEdge() const { return &myAspectEdge; }
|
||||
void SetAspectEdge (const OpenGl_AspectLine* theAspectEdge) { myAspectEdge = *theAspectEdge; }
|
||||
|
||||
const OpenGl_AspectLine* AspectEdge() const { return &myAspectEdge; }
|
||||
|
||||
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
virtual void Release (const Handle(OpenGl_Context)& theContext);
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
TEL_CONTEXT_FACE myContext;
|
||||
OpenGl_AspectLine myAspectEdge;
|
||||
void convertMaterial (const CALL_DEF_MATERIAL& theMat,
|
||||
OPENGL_SURF_PROP& theSurf);
|
||||
|
||||
public:
|
||||
|
||||
Aspect_InteriorStyle InteriorStyle;
|
||||
int Edge;
|
||||
int Hatch;
|
||||
int DistinguishingMode;
|
||||
int CullingMode;
|
||||
OPENGL_SURF_PROP IntFront;
|
||||
OPENGL_SURF_PROP IntBack;
|
||||
TEL_POFFSET_PARAM PolygonOffset;
|
||||
|
||||
int doTextureMap;
|
||||
Handle(OpenGl_Texture) TextureRes;
|
||||
Handle(Graphic3d_TextureParams) TextureParams;
|
||||
|
||||
protected:
|
||||
|
||||
TCollection_AsciiString myTextureId;
|
||||
OpenGl_AspectLine myAspectEdge;
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
};
|
||||
|
||||
#endif //_OpenGl_AspectFace_Header
|
||||
|
@ -17,8 +17,8 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_AspectLine.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }};
|
||||
|
||||
|
@ -17,11 +17,10 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef _OpenGl_AspectLine_Header
|
||||
#define _OpenGl_AspectLine_Header
|
||||
|
||||
#include <InterfaceGraphic_telem.hxx>
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
@ -17,8 +17,8 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_AspectMarker.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }};
|
||||
|
||||
|
@ -17,11 +17,10 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef OpenGl_AspectMarker_Header
|
||||
#define OpenGl_AspectMarker_Header
|
||||
|
||||
#include <InterfaceGraphic_telem.hxx>
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
@ -17,8 +17,8 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_AspectText.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }};
|
||||
|
||||
|
@ -17,11 +17,10 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef OpenGl_AspectText_Header
|
||||
#define OpenGl_AspectText_Header
|
||||
|
||||
#include <InterfaceGraphic_telem.hxx>
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <Font_FontAspect.hxx>
|
||||
#include <Aspect_TypeOfStyleText.hxx>
|
||||
#include <Aspect_TypeOfDisplayText.hxx>
|
||||
|
@ -74,17 +74,22 @@ OpenGl_Context::OpenGl_Context()
|
||||
core14 (NULL),
|
||||
core15 (NULL),
|
||||
core20 (NULL),
|
||||
arbNPTW(Standard_False),
|
||||
arbVBO (NULL),
|
||||
arbTBO (NULL),
|
||||
arbIns (NULL),
|
||||
extFBO (NULL),
|
||||
extGS (NULL),
|
||||
extBgra(Standard_False),
|
||||
extAnis(Standard_False),
|
||||
atiMem (Standard_False),
|
||||
nvxMem (Standard_False),
|
||||
mySharedResources (new OpenGl_ResourcesMap()),
|
||||
myReleaseQueue (new OpenGl_ResourcesQueue()),
|
||||
myGlLibHandle (NULL),
|
||||
myGlCore20 (NULL),
|
||||
myMaxTexDim (1024),
|
||||
myAnisoMax (1),
|
||||
myGlVerMajor (0),
|
||||
myGlVerMinor (0),
|
||||
myIsFeedback (Standard_False),
|
||||
@ -130,6 +135,24 @@ OpenGl_Context::~OpenGl_Context()
|
||||
delete extGS;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : MaxDegreeOfAnisotropy
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer OpenGl_Context::MaxDegreeOfAnisotropy() const
|
||||
{
|
||||
return myAnisoMax;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : MaxTextureSize
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer OpenGl_Context::MaxTextureSize() const
|
||||
{
|
||||
return myMaxTexDim;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Share
|
||||
// purpose :
|
||||
@ -474,8 +497,17 @@ void OpenGl_Context::init()
|
||||
// read version
|
||||
readGlVersion();
|
||||
|
||||
atiMem = CheckExtension ("GL_ATI_meminfo");
|
||||
nvxMem = CheckExtension ("GL_NVX_gpu_memory_info");
|
||||
arbNPTW = CheckExtension ("GL_ARB_texture_non_power_of_two");
|
||||
extBgra = CheckExtension ("GL_EXT_bgra");
|
||||
extAnis = CheckExtension ("GL_EXT_texture_filter_anisotropic");
|
||||
atiMem = CheckExtension ("GL_ATI_meminfo");
|
||||
nvxMem = CheckExtension ("GL_NVX_gpu_memory_info");
|
||||
|
||||
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &myMaxTexDim);
|
||||
if (extAnis)
|
||||
{
|
||||
glGetIntegerv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &myAnisoMax);
|
||||
}
|
||||
|
||||
// initialize VBO extension (ARB)
|
||||
if (CheckExtension ("GL_ARB_vertex_buffer_object"))
|
||||
|
@ -17,7 +17,6 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef _OpenGl_Context_H__
|
||||
#define _OpenGl_Context_H__
|
||||
|
||||
@ -210,6 +209,12 @@ public:
|
||||
//! Clean up the delayed release queue.
|
||||
Standard_EXPORT void ReleaseDelayed();
|
||||
|
||||
//! @return maximum degree of anisotropy texture filter
|
||||
Standard_EXPORT Standard_Integer MaxDegreeOfAnisotropy() const;
|
||||
|
||||
//! @return value for GL_MAX_TEXTURE_SIZE
|
||||
Standard_EXPORT Standard_Integer MaxTextureSize() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Wrapper to system function to retrieve GL function pointer by name.
|
||||
@ -231,13 +236,16 @@ public: // core profiles
|
||||
|
||||
public: // extensions
|
||||
|
||||
OpenGl_ArbVBO* arbVBO; //!< GL_ARB_vertex_buffer_object
|
||||
OpenGl_ArbTBO* arbTBO; //!< GL_ARB_texture_buffer_object
|
||||
OpenGl_ArbIns* arbIns; //!< GL_ARB_draw_instanced
|
||||
OpenGl_ExtFBO* extFBO; //!< GL_EXT_framebuffer_object
|
||||
OpenGl_ExtGS* extGS; //!< GL_EXT_geometry_shader4
|
||||
Standard_Boolean atiMem; //!< GL_ATI_meminfo
|
||||
Standard_Boolean nvxMem; //!< GL_NVX_gpu_memory_info
|
||||
Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two
|
||||
OpenGl_ArbVBO* arbVBO; //!< GL_ARB_vertex_buffer_object
|
||||
OpenGl_ArbTBO* arbTBO; //!< GL_ARB_texture_buffer_object
|
||||
OpenGl_ArbIns* arbIns; //!< GL_ARB_draw_instanced
|
||||
OpenGl_ExtFBO* extFBO; //!< GL_EXT_framebuffer_object
|
||||
OpenGl_ExtGS* extGS; //!< GL_EXT_geometry_shader4
|
||||
Standard_Boolean extBgra; //!< GL_EXT_bgra
|
||||
Standard_Boolean extAnis; //!< GL_EXT_texture_filter_anisotropic
|
||||
Standard_Boolean atiMem; //!< GL_ATI_meminfo
|
||||
Standard_Boolean nvxMem; //!< GL_NVX_gpu_memory_info
|
||||
|
||||
private: // system-dependent fields
|
||||
|
||||
@ -263,6 +271,8 @@ private: // context info
|
||||
|
||||
void* myGlLibHandle; //!< optional handle to GL library
|
||||
OpenGl_GlCore20* myGlCore20; //!< common structure for GL core functions upto 2.0
|
||||
Standard_Integer myAnisoMax; //!< maximum level of anisotropy texture filter
|
||||
Standard_Integer myMaxTexDim; //!< value for GL_MAX_TEXTURE_SIZE
|
||||
Standard_Integer myGlVerMajor; //!< cached GL version major number
|
||||
Standard_Integer myGlVerMinor; //!< cached GL version minor number
|
||||
Standard_Boolean myIsFeedback; //!< flag indicates GL_FEEDBACK mode
|
||||
|
@ -21,7 +21,8 @@
|
||||
#ifndef OpenGl_Element_Header
|
||||
#define OpenGl_Element_Header
|
||||
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <Handle_OpenGl_Context.hxx>
|
||||
#include <Handle_OpenGl_Workspace.hxx>
|
||||
|
||||
class OpenGl_Element
|
||||
{
|
||||
|
@ -17,7 +17,6 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef _OpenGl_GraphicDriver_HeaderFile
|
||||
#define _OpenGl_GraphicDriver_HeaderFile
|
||||
|
||||
@ -32,6 +31,7 @@
|
||||
#include <Quantity_PlaneAngle.hxx>
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <Handle_AlienImage_AlienImage.hxx>
|
||||
#include <Handle_OpenGl_View.hxx>
|
||||
|
||||
#include <Aspect_Display.hxx>
|
||||
#include <Aspect_GradientFillMethod.hxx>
|
||||
@ -55,8 +55,6 @@
|
||||
#include <Graphic3d_CUserDraw.hxx>
|
||||
#include <Graphic3d_CGraduatedTrihedron.hxx>
|
||||
#include <Graphic3d_TypeOfComposition.hxx>
|
||||
#include <Graphic3d_TypeOfTexture.hxx>
|
||||
#include <Graphic3d_CInitTexture.hxx>
|
||||
#include <Graphic3d_ExportFormat.hxx>
|
||||
#include <Graphic3d_SortType.hxx>
|
||||
#include <Graphic3d_PtrFrameBuffer.hxx>
|
||||
@ -84,7 +82,6 @@ class TCollection_ExtendedString;
|
||||
class AlienImage_AlienImage;
|
||||
class Image_PixMap;
|
||||
class TColStd_HArray1OfReal;
|
||||
class Handle(OpenGl_View);
|
||||
class Handle(OpenGl_Workspace);
|
||||
class OpenGl_Element;
|
||||
class OpenGl_Structure;
|
||||
@ -92,7 +89,7 @@ class OpenGl_Structure;
|
||||
//! This class defines an OpenGl graphic driver <br>
|
||||
class OpenGl_GraphicDriver : public Graphic3d_GraphicDriver
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT OpenGl_GraphicDriver (const Standard_CString theShrName);
|
||||
@ -272,12 +269,6 @@ public:
|
||||
//! This method is internal and should be used by Graphic3d_Group only. <br>
|
||||
Standard_EXPORT void RemovePrimitiveArray(const Graphic3d_CGroup& theCGroup,const Graphic3d_PrimitiveArray& thePArray);
|
||||
Standard_EXPORT Standard_Integer InquirePlaneLimit();
|
||||
Standard_EXPORT Standard_Integer CreateTexture (const Graphic3d_TypeOfTexture theType,
|
||||
const Image_PixMap& theImage,
|
||||
const Standard_CString theFileName,
|
||||
const Handle(TColStd_HArray1OfReal)& theTexUpperBounds) const;
|
||||
Standard_EXPORT void DestroyTexture(const Standard_Integer TexId) const;
|
||||
Standard_EXPORT void ModifyTexture(const Standard_Integer TexId,const Graphic3d_CInitTexture& AValue) const;
|
||||
Standard_EXPORT Standard_ShortReal DefaultTextHeight() const;
|
||||
Standard_EXPORT void FBOGetDimensions(const Graphic3d_CView& view,const Graphic3d_PtrFrameBuffer fboPtr,Standard_Integer& width,Standard_Integer& height,Standard_Integer& widthMax,Standard_Integer& heightMax);
|
||||
Standard_EXPORT void FBOChangeViewport(const Graphic3d_CView& view,Graphic3d_PtrFrameBuffer& fboPtr,const Standard_Integer width,const Standard_Integer height);
|
||||
|
@ -45,7 +45,7 @@ void OpenGl_GraphicDriver::FaceContextGroup (const Graphic3d_CGroup& theCGroup,
|
||||
if (!theCGroup.ContextFillArea.IsDef || theCGroup.ptrGroup == NULL)
|
||||
return;
|
||||
|
||||
((OpenGl_Group* )theCGroup.ptrGroup)->SetAspectFace (theCGroup.ContextFillArea, theNoInsert);
|
||||
((OpenGl_Group* )theCGroup.ptrGroup)->SetAspectFace (GetSharedContext(), theCGroup.ContextFillArea, theNoInsert);
|
||||
InvalidateAllWorkspaces();
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ void OpenGl_GraphicDriver::MarkerContextGroup (const Graphic3d_CGroup& theCGroup
|
||||
InvalidateAllWorkspaces();
|
||||
}
|
||||
|
||||
void OpenGl_GraphicDriver::MarkerContextGroup (const Graphic3d_CGroup& theCGroup,
|
||||
void OpenGl_GraphicDriver::MarkerContextGroup (const Graphic3d_CGroup& theCGroup,
|
||||
const Standard_Integer theNoInsert,
|
||||
const Standard_Integer theMarkWidth,
|
||||
const Standard_Integer theMarkHeight,
|
||||
|
@ -46,7 +46,7 @@ void OpenGl_GraphicDriver::ContextStructure (const Graphic3d_CStructure& theCStr
|
||||
aStructure->SetAspectLine (theCStructure.ContextLine);
|
||||
|
||||
if (theCStructure.ContextFillArea.IsDef)
|
||||
aStructure->SetAspectFace (theCStructure.ContextFillArea);
|
||||
aStructure->SetAspectFace (GetSharedContext(), theCStructure.ContextFillArea);
|
||||
|
||||
if (theCStructure.ContextMarker.IsDef)
|
||||
aStructure->SetAspectMarker (theCStructure.ContextMarker);
|
||||
|
@ -168,7 +168,7 @@ Standard_Boolean OpenGl_GraphicDriver::UnProjectRaster (const Graphic3d_CView& A
|
||||
const Standard_Integer aHeight = aCView->WS->Height();
|
||||
|
||||
/*
|
||||
Patched by P.Dolbey: the window pixel height decreased by one
|
||||
Patched by P.Dolbey: the window pixel height decreased by one
|
||||
in order for yr to remain within valid coordinate range [0; Ym -1]
|
||||
where Ym means window pixel height.
|
||||
*/
|
||||
@ -430,7 +430,8 @@ void OpenGl_GraphicDriver::RemoveView (const Graphic3d_CView& theCView)
|
||||
}
|
||||
}
|
||||
|
||||
OpenGl_CView *aCView = (OpenGl_CView *)theCView.ptrView;
|
||||
OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView;
|
||||
aCView->View->ReleaseGlResources (aShareCtx);
|
||||
delete aCView;
|
||||
((Graphic3d_CView *)&theCView)->ptrView = NULL;
|
||||
}
|
||||
@ -554,7 +555,7 @@ void OpenGl_GraphicDriver::SetBackFacingModel (const Graphic3d_CView& ACView)
|
||||
|
||||
//=======================================================================
|
||||
//function : AddZLayer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void OpenGl_GraphicDriver::AddZLayer (const Graphic3d_CView& theCView,
|
||||
|
@ -21,21 +21,18 @@
|
||||
#include <OpenGl_CView.hxx>
|
||||
#include <OpenGl_Trihedron.hxx>
|
||||
#include <OpenGl_GraduatedTrihedron.hxx>
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
#include <OpenGl_tgl_funcs.hxx>
|
||||
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <Image_Image.hxx>
|
||||
|
||||
void OpenGl_GraphicDriver::Environment(const Graphic3d_CView& ACView)
|
||||
void OpenGl_GraphicDriver::Environment(const Graphic3d_CView& theCView)
|
||||
{
|
||||
const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
|
||||
if (aCView)
|
||||
const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
|
||||
if (aCView == NULL)
|
||||
{
|
||||
aCView->View->SetTextureEnv(ACView.Context.TexEnvId);
|
||||
aCView->View->SetSurfaceDetail((Visual3d_TypeOfSurfaceDetail)ACView.Context.SurfaceDetail);
|
||||
return;
|
||||
}
|
||||
|
||||
aCView->View->SetTextureEnv (GetSharedContext(), theCView.Context.TextureEnv);
|
||||
aCView->View->SetSurfaceDetail ((Visual3d_TypeOfSurfaceDetail)theCView.Context.SurfaceDetail);
|
||||
}
|
||||
|
||||
//
|
||||
@ -138,138 +135,3 @@ void OpenGl_GraphicDriver::GraduatedTrihedronMinMaxValues(const Standard_ShortRe
|
||||
{
|
||||
OpenGl_GraduatedTrihedron::SetMinMax(xmin, ymin, zmin, xmax, ymax, zmax);
|
||||
}
|
||||
|
||||
// Helper function, returns the nearest power of two greater than the argument value
|
||||
inline Standard_Integer GetNearestPow2(Standard_Integer theValue)
|
||||
{
|
||||
// Precaution against overflow
|
||||
Standard_Integer aHalfMax = IntegerLast() >> 1, aRes = 1;
|
||||
if ( theValue > aHalfMax ) theValue = aHalfMax;
|
||||
while ( aRes < theValue ) aRes <<= 1;
|
||||
return aRes;
|
||||
}
|
||||
|
||||
Standard_Integer OpenGl_GraphicDriver::CreateTexture (const Graphic3d_TypeOfTexture theType,
|
||||
const Image_PixMap& theImage,
|
||||
const Standard_CString theFileName,
|
||||
const Handle(TColStd_HArray1OfReal)& theTexUpperBounds) const
|
||||
{
|
||||
if (theImage.IsEmpty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
Standard_Integer aGlWidth = (Standard_Integer )theImage.Width();
|
||||
Standard_Integer aGlHeight = (Standard_Integer )theImage.Height();
|
||||
if (theType != Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
aGlWidth = GetNearestPow2 (aGlWidth);
|
||||
aGlHeight = GetNearestPow2 (aGlHeight);
|
||||
}
|
||||
theTexUpperBounds->SetValue (1, Standard_Real(theImage.Width()) / Standard_Real(aGlWidth));
|
||||
theTexUpperBounds->SetValue (2, Standard_Real(theImage.Height()) / Standard_Real(aGlHeight));
|
||||
|
||||
Image_PixMap anImage;
|
||||
if (!anImage.InitTrash (Image_PixMap::ImgRGBA, Standard_Size(aGlWidth), Standard_Size(aGlHeight)))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
anImage.SetTopDown (false);
|
||||
Image_PixMapData<Image_ColorRGBA>& aDataNew = anImage.EditData<Image_ColorRGBA>();
|
||||
Quantity_Color aSrcColor;
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
{
|
||||
aSrcColor = theImage.PixelColor (aCol, aRow);
|
||||
Image_ColorRGBA& aColor = aDataNew.ChangeValue (aRow, aCol);
|
||||
aColor.r() = int(255.0 * aSrcColor.Red());
|
||||
aColor.g() = int(255.0 * aSrcColor.Green());
|
||||
aColor.b() = int(255.0 * aSrcColor.Blue());
|
||||
aColor.a() = 0xFF;
|
||||
}
|
||||
|
||||
for (Standard_Size aCol = theImage.SizeX(); aCol < anImage.SizeX(); ++aCol)
|
||||
{
|
||||
Image_ColorRGBA& aColor = aDataNew.ChangeValue (aRow, aCol);
|
||||
aColor.r() = 0x00;
|
||||
aColor.g() = 0x00;
|
||||
aColor.b() = 0x00;
|
||||
aColor.a() = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
// Padding the lower part of the texture with black
|
||||
for (Standard_Size aRow = theImage.SizeY(); aRow < anImage.SizeY(); ++aRow)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < anImage.SizeX(); ++aCol)
|
||||
{
|
||||
Image_ColorRGBA& aColor = aDataNew.ChangeValue (aRow, aCol);
|
||||
aColor.r() = 0x00;
|
||||
aColor.g() = 0x00;
|
||||
aColor.b() = 0x00;
|
||||
aColor.a() = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Integer TheTextureRank = 0;
|
||||
char aTextureStrId[255];
|
||||
sprintf (aTextureStrId, "Tex%d", ++TheTextureRank);
|
||||
|
||||
switch (theType)
|
||||
{
|
||||
case Graphic3d_TOT_1D: return GetTextureData1D (aTextureStrId, aGlWidth, aGlHeight, anImage.Data());
|
||||
case Graphic3d_TOT_2D: return GetTextureData2D (aTextureStrId, aGlWidth, aGlHeight, anImage.Data());
|
||||
case Graphic3d_TOT_2D_MIPMAP: return GetTextureData2DMipMap (aTextureStrId, aGlWidth, aGlHeight, anImage.Data());
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGl_GraphicDriver::DestroyTexture (const Standard_Integer theTexId) const
|
||||
{
|
||||
FreeTexture (GetSharedContext(), theTexId);
|
||||
}
|
||||
|
||||
void OpenGl_GraphicDriver::ModifyTexture (const Standard_Integer theTexId,
|
||||
const Graphic3d_CInitTexture& theInfo) const
|
||||
{
|
||||
if (theInfo.doModulate)
|
||||
SetTextureModulate (theTexId);
|
||||
else
|
||||
SetTextureDecal (theTexId);
|
||||
|
||||
if (theInfo.doRepeat)
|
||||
SetTextureRepeat (theTexId);
|
||||
else
|
||||
SetTextureClamp (theTexId);
|
||||
|
||||
switch (theInfo.Mode)
|
||||
{
|
||||
case 0:
|
||||
SetModeObject (theTexId, theInfo.sparams, theInfo.tparams);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
SetModeSphere (theTexId);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
SetModeEye (theTexId, theInfo.sparams, theInfo.tparams);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
SetModeManual (theTexId);
|
||||
break;
|
||||
}
|
||||
|
||||
if (theInfo.doLinear)
|
||||
SetRenderLinear (theTexId);
|
||||
else
|
||||
SetRenderNearest (theTexId);
|
||||
|
||||
SetTexturePosition (theTexId,
|
||||
theInfo.sx, theInfo.sy,
|
||||
theInfo.tx, theInfo.ty,
|
||||
theInfo.angle);
|
||||
}
|
||||
|
@ -17,11 +17,10 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_Group.hxx>
|
||||
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
#include <OpenGl_PrimitiveArray.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@ -60,19 +59,22 @@ void OpenGl_Group::SetAspectLine (const CALL_DEF_CONTEXTLINE& theContext,
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void OpenGl_Group::SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theContext,
|
||||
const Standard_Boolean theIsGlobal)
|
||||
void OpenGl_Group::SetAspectFace (const Handle(OpenGl_Context)& theCtx,
|
||||
const CALL_DEF_CONTEXTFILLAREA& theAspect,
|
||||
const Standard_Boolean theIsGlobal)
|
||||
{
|
||||
if (theIsGlobal || myFirst == NULL)
|
||||
{
|
||||
if (myAspectFace == NULL)
|
||||
{
|
||||
myAspectFace = new OpenGl_AspectFace();
|
||||
myAspectFace->SetContext (theContext);
|
||||
}
|
||||
myAspectFace->Init (theCtx, theAspect);
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace();
|
||||
anAspectFace->SetContext (theContext);
|
||||
anAspectFace->Init (theCtx, theAspect);
|
||||
AddElement (TelNil/*TelAspectFace*/, anAspectFace);
|
||||
}
|
||||
}
|
||||
@ -141,7 +143,7 @@ void OpenGl_Group::RemovePrimitiveArray (const Handle(OpenGl_Context)& theGlCtx,
|
||||
CALL_DEF_PARRAY* aCurPArray = ((const OpenGl_PrimitiveArray* )node->elem)->PArray();
|
||||
|
||||
// validate for correct pointer
|
||||
if (aCurPArray->num_bounds == thePArray->num_bounds &&
|
||||
if (aCurPArray->num_bounds == thePArray->num_bounds &&
|
||||
aCurPArray->num_edges == thePArray->num_edges &&
|
||||
aCurPArray->num_vertexs == thePArray->num_vertexs &&
|
||||
aCurPArray->type == thePArray->type)
|
||||
@ -160,54 +162,69 @@ void OpenGl_Group::RemovePrimitiveArray (const Handle(OpenGl_Context)& theGlCtx,
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void OpenGl_Group::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
// Is rendering in ADD or IMMEDIATE mode?
|
||||
const Standard_Boolean isImmediate = (AWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0;
|
||||
const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0;
|
||||
|
||||
// Setup aspects
|
||||
const OpenGl_AspectLine *aspect_line = AWorkspace->AspectLine(Standard_False);
|
||||
const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace(Standard_False);
|
||||
const OpenGl_AspectMarker *aspect_marker = AWorkspace->AspectMarker(Standard_False);
|
||||
const OpenGl_AspectText *aspect_text = AWorkspace->AspectText(Standard_False);
|
||||
const OpenGl_AspectLine* aBackAspectLine = theWorkspace->AspectLine (Standard_False);
|
||||
const OpenGl_AspectFace* aBackAspectFace = theWorkspace->AspectFace (Standard_False);
|
||||
const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker (Standard_False);
|
||||
const OpenGl_AspectText* aBackAspectText = theWorkspace->AspectText (Standard_False);
|
||||
if (myAspectLine)
|
||||
AWorkspace->SetAspectLine(myAspectLine);
|
||||
{
|
||||
theWorkspace->SetAspectLine (myAspectLine);
|
||||
}
|
||||
if (myAspectFace)
|
||||
AWorkspace->SetAspectFace(myAspectFace);
|
||||
{
|
||||
theWorkspace->SetAspectFace (myAspectFace);
|
||||
}
|
||||
if (myAspectMarker)
|
||||
AWorkspace->SetAspectMarker(myAspectMarker);
|
||||
{
|
||||
theWorkspace->SetAspectMarker (myAspectMarker);
|
||||
}
|
||||
if (myAspectText)
|
||||
AWorkspace->SetAspectText(myAspectText);
|
||||
{
|
||||
theWorkspace->SetAspectText (myAspectText);
|
||||
}
|
||||
|
||||
// Render group elements
|
||||
OpenGl_ElementNode *node = myFirst;
|
||||
while (node)
|
||||
Handle(OpenGl_Texture) aPrevTexture; // temporary disabled texture
|
||||
for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
||||
{
|
||||
switch (node->type)
|
||||
switch (aNodeIter->type)
|
||||
{
|
||||
case TelPolyline:
|
||||
case TelMarker:
|
||||
case TelMarkerSet:
|
||||
case TelText:
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable (GL_LIGHTING);
|
||||
|
||||
if (isImmediate)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
glDepthMask (GL_FALSE);
|
||||
}
|
||||
else if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) != 0 &&
|
||||
(AWorkspace->NamedStatus & OPENGL_NS_WIREFRAME) == 0 &&
|
||||
AWorkspace->DegenerateModel != 0 )
|
||||
else if ((theWorkspace->NamedStatus & OPENGL_NS_ANIMATION) != 0 &&
|
||||
(theWorkspace->NamedStatus & OPENGL_NS_WIREFRAME) == 0 &&
|
||||
theWorkspace->DegenerateModel != 0)
|
||||
{
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
if ( AWorkspace->NamedStatus & OPENGL_NS_TEXTURE ) DisableTexture();
|
||||
AWorkspace->NamedStatus |= OPENGL_NS_WIREFRAME;
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
if (theWorkspace->NamedStatus & OPENGL_NS_TEXTURE)
|
||||
{
|
||||
aPrevTexture = theWorkspace->DisableTexture();
|
||||
}
|
||||
theWorkspace->NamedStatus |= OPENGL_NS_WIREFRAME;
|
||||
}
|
||||
|
||||
node->elem->Render( AWorkspace );
|
||||
if (!aPrevTexture.IsNull())
|
||||
{
|
||||
theWorkspace->EnableTexture (aPrevTexture);
|
||||
aPrevTexture.Nullify();
|
||||
}
|
||||
|
||||
if ( !isImmediate && (AWorkspace->NamedStatus & OPENGL_NS_TEXTURE) != 0 ) EnableTexture();
|
||||
aNodeIter->elem->Render (theWorkspace);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -220,40 +237,41 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
else if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) != 0 &&
|
||||
(AWorkspace->NamedStatus & OPENGL_NS_WIREFRAME) != 0 &&
|
||||
AWorkspace->DegenerateModel < 2 )
|
||||
else if ((theWorkspace->NamedStatus & OPENGL_NS_ANIMATION) != 0 &&
|
||||
(theWorkspace->NamedStatus & OPENGL_NS_WIREFRAME) != 0 &&
|
||||
theWorkspace->DegenerateModel < 2)
|
||||
{
|
||||
if ( AWorkspace->NamedStatus & OPENGL_NS_TEXTURE ) EnableTexture ();
|
||||
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
AWorkspace->NamedStatus &= ~OPENGL_NS_WIREFRAME;
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
theWorkspace->NamedStatus &= ~OPENGL_NS_WIREFRAME;
|
||||
}
|
||||
|
||||
if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
|
||||
AWorkspace->DisablePolygonOffset();
|
||||
if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
|
||||
{
|
||||
theWorkspace->DisablePolygonOffset();
|
||||
}
|
||||
|
||||
node->elem->Render( AWorkspace );
|
||||
aNodeIter->elem->Render (theWorkspace);
|
||||
|
||||
if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
|
||||
AWorkspace->EnablePolygonOffset();
|
||||
if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
|
||||
{
|
||||
theWorkspace->EnablePolygonOffset();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
node->elem->Render( AWorkspace );
|
||||
aNodeIter->elem->Render (theWorkspace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
// Restore aspects
|
||||
AWorkspace->SetAspectLine(aspect_line);
|
||||
AWorkspace->SetAspectFace(aspect_face);
|
||||
AWorkspace->SetAspectMarker(aspect_marker);
|
||||
AWorkspace->SetAspectText(aspect_text);
|
||||
theWorkspace->SetAspectLine (aBackAspectLine);
|
||||
theWorkspace->SetAspectFace (aBackAspectFace);
|
||||
theWorkspace->SetAspectMarker (aBackAspectMarker);
|
||||
theWorkspace->SetAspectText (aBackAspectText);
|
||||
}
|
||||
|
||||
void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
|
||||
|
@ -17,7 +17,6 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef _OpenGl_Group_Header
|
||||
#define _OpenGl_Group_Header
|
||||
|
||||
@ -48,7 +47,9 @@ public:
|
||||
OpenGl_Group();
|
||||
|
||||
void SetAspectLine (const CALL_DEF_CONTEXTLINE &AContext, const Standard_Boolean IsGlobal = Standard_True);
|
||||
void SetAspectFace (const CALL_DEF_CONTEXTFILLAREA &AContext, const Standard_Boolean IsGlobal = Standard_True);
|
||||
void SetAspectFace (const Handle(OpenGl_Context)& theCtx,
|
||||
const CALL_DEF_CONTEXTFILLAREA& theAspect,
|
||||
const Standard_Boolean IsGlobal = Standard_True);
|
||||
void SetAspectMarker (const CALL_DEF_CONTEXTMARKER &AContext, const Standard_Boolean IsGlobal = Standard_True);
|
||||
void SetAspectText (const CALL_DEF_CONTEXTTEXT &AContext, const Standard_Boolean IsGlobal = Standard_True);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <OpenGl_AspectMarker.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_Display.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@ -85,7 +86,7 @@ void OpenGl_Marker::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
break;
|
||||
}
|
||||
case Aspect_TOM_USERDEFINED :
|
||||
{
|
||||
{
|
||||
glCallList( openglDisplay->GetUserMarkerListIndex( (int)aspect_marker->Scale() ) );
|
||||
break;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
@ -26,6 +25,7 @@
|
||||
#include <OpenGl_AspectMarker.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_Display.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
@ -17,16 +17,15 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
|
||||
#include <OpenGl_Polygon.hxx>
|
||||
|
||||
#include <OpenGl_telem_util.hxx>
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
|
||||
#include <OpenGl_AspectFace.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
#include <GL/glu.h>
|
||||
|
||||
@ -113,7 +112,7 @@ void OpenGl_Polygon::draw_polygon (const Handle(OpenGl_Workspace) &AWorkspace, T
|
||||
{
|
||||
glNormal3fv( pvn[i].xyz );
|
||||
glVertex3fv( ptr->xyz );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -140,7 +139,7 @@ void OpenGl_Polygon::draw_polygon (const Handle(OpenGl_Workspace) &AWorkspace, T
|
||||
glVertex3fv( ptr->xyz );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
if( myData.reverse_order ) glFrontFace( GL_CCW );
|
||||
|
||||
@ -283,7 +282,7 @@ bgntriangulate(const TEL_POLYGON_DATA *d, void ( APIENTRY * out_ver)() )
|
||||
gluTessCallback( tripak, GLU_TESS_END, out_endtmesh );
|
||||
gluTessCallback( tripak, GLU_TESS_ERROR, (_GLUfuncptr)(out_error) );
|
||||
gluTessCallback( tripak, GLU_TESS_COMBINE, (_GLUfuncptr)(mycombine) );
|
||||
#else
|
||||
#else
|
||||
gluTessCallback( tripak, GLU_TESS_BEGIN, (void (APIENTRY*)())out_bgntmesh );
|
||||
gluTessCallback( tripak, GLU_TESS_VERTEX, (void (APIENTRY*)())out_ver );
|
||||
gluTessCallback( tripak, GLU_TESS_END, (void (APIENTRY*)())out_endtmesh );
|
||||
@ -360,7 +359,7 @@ void OpenGl_Polygon::draw_polygon_concav (const Handle(OpenGl_Workspace) &AWorks
|
||||
{
|
||||
xyz[0] = ptr->xyz[0];
|
||||
xyz[1] = ptr->xyz[1];
|
||||
xyz[2] = ptr->xyz[2];
|
||||
xyz[2] = ptr->xyz[2];
|
||||
#ifndef WNT
|
||||
gluTessVertex( tripak, xyz,(void * ) i );
|
||||
#else
|
||||
@ -373,8 +372,8 @@ void OpenGl_Polygon::draw_polygon_concav (const Handle(OpenGl_Workspace) &AWorks
|
||||
gluTessEndContour( tripak );
|
||||
gluTessEndPolygon( tripak );
|
||||
endtriangulate();
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if( front_lighting_model )
|
||||
{
|
||||
@ -391,37 +390,39 @@ void OpenGl_Polygon::draw_polygon_concav (const Handle(OpenGl_Workspace) &AWorks
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void OpenGl_Polygon::draw_edges (const TEL_COLOUR *edge_colour, const Aspect_InteriorStyle interior_style, const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
void OpenGl_Polygon::draw_edges (const TEL_COLOUR* theEdgeColor,
|
||||
const Aspect_InteriorStyle theInteriorStyle,
|
||||
const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
|
||||
const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace (Standard_True);
|
||||
|
||||
if ( interior_style != Aspect_IS_HIDDENLINE && aspect_face->Context().Edge == TOff )
|
||||
if (theInteriorStyle != Aspect_IS_HIDDENLINE
|
||||
&& anAspectFace->Edge == TOff)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
const GLboolean texture_on = IsTextureEnabled();
|
||||
if (texture_on) DisableTexture();
|
||||
glDisable (GL_LIGHTING);
|
||||
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
|
||||
|
||||
// Setup line aspect
|
||||
const OpenGl_AspectLine *aspect_line_old = AWorkspace->SetAspectLine( aspect_face->AspectEdge() );
|
||||
AWorkspace->AspectLine( Standard_True );
|
||||
const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->SetAspectLine (anAspectFace->AspectEdge());
|
||||
theWorkspace->AspectLine (Standard_True);
|
||||
|
||||
Tint i;
|
||||
glColor3fv (theEdgeColor->rgb);
|
||||
|
||||
glBegin (GL_LINE_LOOP);
|
||||
tel_point ptr = myData.vertices;
|
||||
|
||||
glColor3fv( edge_colour->rgb );
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for( i=0; i<myData.num_vertices; i++, ptr++ )
|
||||
for (Tint i = 0; i < myData.num_vertices; i++, ptr++)
|
||||
{
|
||||
glVertex3fv( ptr->xyz );
|
||||
glVertex3fv (ptr->xyz);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
// Restore line context
|
||||
AWorkspace->SetAspectLine( aspect_line_old );
|
||||
theWorkspace->SetAspectLine (aPrevAspectLine);
|
||||
|
||||
if (texture_on) EnableTexture();
|
||||
theWorkspace->EnableTexture (aPrevTexture);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@ -578,20 +579,20 @@ void OpenGl_Polygon::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
{
|
||||
const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
|
||||
|
||||
Tint front_lighting_model = aspect_face->Context().IntFront.color_mask;
|
||||
const Aspect_InteriorStyle interior_style = aspect_face->Context().InteriorStyle;
|
||||
const TEL_COLOUR *interior_colour = &aspect_face->Context().IntFront.matcol;
|
||||
Tint front_lighting_model = aspect_face->IntFront.color_mask;
|
||||
const Aspect_InteriorStyle interior_style = aspect_face->InteriorStyle;
|
||||
const TEL_COLOUR *interior_colour = &aspect_face->IntFront.matcol;
|
||||
const TEL_COLOUR *edge_colour = &aspect_face->AspectEdge()->Color();
|
||||
|
||||
// Use highlight colous
|
||||
if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
|
||||
{
|
||||
{
|
||||
edge_colour = interior_colour = AWorkspace->HighlightColor;
|
||||
front_lighting_model = 0;
|
||||
}
|
||||
|
||||
if( interior_style != Aspect_IS_EMPTY && AWorkspace->DegenerateModel < 2 )
|
||||
{
|
||||
{
|
||||
if ( front_lighting_model )
|
||||
glEnable(GL_LIGHTING);
|
||||
else
|
||||
|
@ -17,13 +17,13 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
|
||||
#include <OpenGl_Polyline.hxx>
|
||||
|
||||
#include <OpenGl_AspectLine.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <OpenGl_AspectFace.hxx>
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
#include <InterfaceGraphic_PrimitiveArray.hxx>
|
||||
|
||||
@ -157,10 +157,10 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
for (i = 0; i < myPArray->num_vertexs; ++i)
|
||||
{
|
||||
transp = int(theFaceProp->trans * 255.0f);
|
||||
#if defined (sparc) || defined (__sparc__) || defined (__sparc)
|
||||
#if defined (sparc) || defined (__sparc__) || defined (__sparc)
|
||||
pvc[i] = (pvc[i] & 0xffffff00);
|
||||
pvc[i] += transp;
|
||||
#else
|
||||
#else
|
||||
pvc[i] = (pvc[i] & 0x00ffffff);
|
||||
pvc[i] += transp << 24;
|
||||
#endif
|
||||
@ -210,7 +210,7 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
}
|
||||
|
||||
// Sometimes the GL_LIGHTING mode is activated here
|
||||
// without glEnable(GL_LIGHTING) call for an unknown reason, so it is necessary
|
||||
// without glEnable(GL_LIGHTING) call for an unknown reason, so it is necessary
|
||||
// to call glEnable(GL_LIGHTING) to synchronize Light On/Off mechanism*
|
||||
if (theLightingModel == 0 || myDrawMode <= GL_LINE_STRIP)
|
||||
glDisable (GL_LIGHTING);
|
||||
@ -279,7 +279,7 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
for (i = 0; i < myPArray->num_bounds; ++i)
|
||||
{
|
||||
glDrawElements (myDrawMode, myPArray->bounds[i], myVbos[VBOEdges]->GetDataType(), anOffset);
|
||||
anOffset += myPArray->bounds[i];
|
||||
anOffset += myPArray->bounds[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -318,7 +318,7 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
glDisable (GL_COLOR_MATERIAL);
|
||||
theWorkspace->NamedStatus |= OPENGL_NS_RESMAT; // Reset material
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myPArray->num_bounds > 0)
|
||||
@ -384,13 +384,13 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
switch (theWorkspace->DegenerateModel)
|
||||
{
|
||||
default: // XXX_TDM_NODE or TINY
|
||||
// On some NVIDIA graphic cards, using glEdgeFlagPointer() in
|
||||
// On some NVIDIA graphic cards, using glEdgeFlagPointer() in
|
||||
// combination with VBO ( edge flag data put into a VBO buffer)
|
||||
// leads to a crash in a driver. Therefore, edge flags are simply
|
||||
// igonored when VBOs are enabled, so all the edges are drawn if
|
||||
// edge visibility is turned on. In order to draw edges selectively,
|
||||
// either disable VBO or turn off edge visibilty in the current
|
||||
// primitive array and create a separate primitive array (segments)
|
||||
// leads to a crash in a driver. Therefore, edge flags are simply
|
||||
// igonored when VBOs are enabled, so all the edges are drawn if
|
||||
// edge visibility is turned on. In order to draw edges selectively,
|
||||
// either disable VBO or turn off edge visibilty in the current
|
||||
// primitive array and create a separate primitive array (segments)
|
||||
// and put edges to be drawn into it.
|
||||
if (myDrawMode > GL_LINE_STRIP)
|
||||
{
|
||||
@ -444,7 +444,7 @@ void OpenGl_PrimitiveArray::DrawEdges (const TEL_COLOUR* theEdgeCo
|
||||
/// 2) draw elements from vertice array, when bounds defines count of primitive's verts.
|
||||
/// 3) draw primitive's edges by vertexes if no edges and bounds array is specified
|
||||
if (toDrawVbo())
|
||||
{
|
||||
{
|
||||
myVbos[VBOVertices]->BindFixed (aGlContext, GL_VERTEX_ARRAY);
|
||||
glColor3fv (theEdgeColour->rgb);
|
||||
if (!myVbos[VBOEdges].IsNull())
|
||||
@ -521,7 +521,7 @@ void OpenGl_PrimitiveArray::DrawEdges (const TEL_COLOUR* theEdgeCo
|
||||
n += myPArray->bounds[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (myPArray->num_edges > 0)
|
||||
{
|
||||
if (myPArray->edge_vis)
|
||||
@ -558,7 +558,7 @@ void OpenGl_PrimitiveArray::DrawEdges (const TEL_COLOUR* theEdgeCo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::DrawDegeneratesPointsAsPoints() const
|
||||
{
|
||||
{
|
||||
tel_point pv = myPArray->vertices;
|
||||
for (Tint aVertId = 0; aVertId < myPArray->num_vertexs; ++aVertId)
|
||||
{
|
||||
@ -589,7 +589,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesLinesAsPoints() const
|
||||
pt[2] *= 0.5f;
|
||||
glVertex3fv (pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : DrawDegeneratesTrianglesAsPoints
|
||||
@ -648,7 +648,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesTrianglesAsPoints() const
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::DrawDegeneratesTrianglestripsAsPoints() const
|
||||
{
|
||||
{
|
||||
Tint i, j, k, n;
|
||||
GLfloat pt[ 3 ];
|
||||
tel_point pv = myPArray->vertices;
|
||||
@ -702,7 +702,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesTrianglestripsAsPoints() const
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::DrawDegeneratesPolygonsAsPoints() const
|
||||
{
|
||||
{
|
||||
Tint j, k, n, iv;
|
||||
GLfloat pt[3];
|
||||
tel_point pv = myPArray->vertices;
|
||||
@ -823,14 +823,14 @@ void OpenGl_PrimitiveArray::DrawDegeneratesQuadranglesAsPoints() const
|
||||
glVertex3fv (pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : DrawDegeneratesAsPoints
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::DrawDegeneratesQuadranglestripsAsPoints() const
|
||||
{
|
||||
{
|
||||
Tint i, j, k, n;
|
||||
GLfloat pt[3];
|
||||
tel_point pv = myPArray->vertices;
|
||||
@ -888,7 +888,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesAsPoints (const TEL_COLOUR* theEdgeCo
|
||||
GLboolean zbuff_state = glIsEnabled (GL_DEPTH_TEST);
|
||||
glDisable (GL_LIGHTING);
|
||||
if (zbuff_state)
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glColor3fv (theEdgeColour->rgb);
|
||||
|
||||
glBegin (GL_POINTS);
|
||||
@ -1014,7 +1014,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesLinesAsLines (const float theSkipRati
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::DrawDegeneratesTrianglesAsLines (const float theSkipRatio) const
|
||||
{
|
||||
{
|
||||
Tint i, iv;
|
||||
tel_point pv = myPArray->vertices;
|
||||
|
||||
@ -1032,7 +1032,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesTrianglesAsLines (const float theSkip
|
||||
{
|
||||
iv = myPArray->edges[j];
|
||||
if (myPArray->keys[iv] < 0)
|
||||
{
|
||||
{
|
||||
myPArray->keys[iv] = -myPArray->keys[iv];
|
||||
glBegin (GL_LINE_LOOP);
|
||||
for (i = 0; i < 3; ++i)
|
||||
@ -1067,7 +1067,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesTrianglesAsLines (const float theSkip
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::DrawDegeneratesTrianglestripsAsLines (const float theSkipRatio) const
|
||||
{
|
||||
{
|
||||
Tint i, j, k, n, ni;
|
||||
tel_point pv = myPArray->vertices;
|
||||
|
||||
@ -1126,7 +1126,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesTrianglestripsAsLines (const float th
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::DrawDegeneratesPolygonsAsLines (const float theSkipRatio) const
|
||||
{
|
||||
{
|
||||
Tint i, iv;
|
||||
tel_point pv = myPArray->vertices;
|
||||
|
||||
@ -1203,7 +1203,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesPolygonsAsLines (const float theSkipR
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : DrawDegeneratesQuadranglesAsLines
|
||||
@ -1263,7 +1263,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesQuadranglesAsLines (const float theSk
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::DrawDegeneratesQuadranglestripsAsLines (const float theSkipRatio) const
|
||||
{
|
||||
{
|
||||
Tint i, j, k, n, ni;
|
||||
tel_point pv = myPArray->vertices;
|
||||
|
||||
@ -1333,7 +1333,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesAsLines (const TEL_COLOUR*
|
||||
glDisable (GL_LIGHTING);
|
||||
|
||||
if (zbuff_state)
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
|
||||
glColor3fv (theEdgeColour->rgb);
|
||||
|
||||
@ -1433,8 +1433,8 @@ void OpenGl_PrimitiveArray::DrawDegeneratesAsLines (const TEL_COLOUR*
|
||||
}
|
||||
|
||||
if (zbuff_state)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : DrawDegeneratesAsBBoxs
|
||||
@ -1567,7 +1567,9 @@ void OpenGl_PrimitiveArray::Release (const Handle(OpenGl_Context)& theContext)
|
||||
void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
if (myPArray == NULL || myDrawMode == DRAW_MODE_NONE || myPArray->num_vertexs <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// create VBOs on first render call
|
||||
if (!myIsVboInit && OpenGl_GraphicDriver::ToUseVBO() && theWorkspace->GetGlContext()->core15 != NULL)
|
||||
@ -1576,6 +1578,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
myIsVboInit = Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean toDisableTexture = Standard_False;
|
||||
switch (myPArray->type)
|
||||
{
|
||||
case TelPointsArrayType:
|
||||
@ -1589,8 +1592,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
theWorkspace->DegenerateModel)
|
||||
{
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
if (theWorkspace->NamedStatus & OPENGL_NS_TEXTURE)
|
||||
DisableTexture();
|
||||
toDisableTexture = (theWorkspace->NamedStatus & OPENGL_NS_TEXTURE);
|
||||
theWorkspace->NamedStatus |= OPENGL_NS_WIREFRAME;
|
||||
}
|
||||
break;
|
||||
@ -1606,8 +1608,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
(theWorkspace->NamedStatus & OPENGL_NS_WIREFRAME) != 0 &&
|
||||
theWorkspace->DegenerateModel < 2)
|
||||
{
|
||||
if (theWorkspace->NamedStatus & OPENGL_NS_TEXTURE)
|
||||
EnableTexture();
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
theWorkspace->NamedStatus &= ~OPENGL_NS_WIREFRAME;
|
||||
}
|
||||
@ -1617,39 +1617,38 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
break;
|
||||
}
|
||||
|
||||
Handle(OpenGl_Texture) aPrevTexture;
|
||||
const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace (Standard_True);
|
||||
const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
|
||||
const OpenGl_AspectMarker* anAspectMarker = theWorkspace->AspectMarker (myPArray->type == TelPointsArrayType);
|
||||
if (toDisableTexture)
|
||||
{
|
||||
aPrevTexture = theWorkspace->DisableTexture();
|
||||
}
|
||||
|
||||
Tint aFrontLightingModel = anAspectFace->Context().IntFront.color_mask;
|
||||
const TEL_COLOUR* anInteriorColor = &anAspectFace->Context().IntFront.matcol;
|
||||
Tint aFrontLightingModel = anAspectFace->IntFront.color_mask;
|
||||
const TEL_COLOUR* anInteriorColor = &anAspectFace->IntFront.matcol;
|
||||
const TEL_COLOUR* anEdgeColor = &anAspectFace->AspectEdge()->Color();
|
||||
const TEL_COLOUR* aLineColor = (myPArray->type == TelPointsArrayType) ? &anAspectMarker->Color() : &anAspectLine->Color();
|
||||
|
||||
// Use highlight colors
|
||||
if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
|
||||
{
|
||||
{
|
||||
anEdgeColor = anInteriorColor = aLineColor = theWorkspace->HighlightColor;
|
||||
aFrontLightingModel = 0;
|
||||
}
|
||||
|
||||
DrawArray (aFrontLightingModel,
|
||||
anAspectFace->Context().InteriorStyle,
|
||||
anAspectFace->Context().Edge,
|
||||
anAspectFace->InteriorStyle,
|
||||
anAspectFace->Edge,
|
||||
anInteriorColor,
|
||||
aLineColor,
|
||||
anEdgeColor,
|
||||
&anAspectFace->Context().IntFront,
|
||||
&anAspectFace->IntFront,
|
||||
theWorkspace);
|
||||
|
||||
switch (myPArray->type)
|
||||
if (!aPrevTexture.IsNull())
|
||||
{
|
||||
case TelPointsArrayType:
|
||||
case TelPolylinesArrayType:
|
||||
case TelSegmentsArrayType:
|
||||
{
|
||||
if (theWorkspace->NamedStatus & OPENGL_NS_TEXTURE)
|
||||
EnableTexture();
|
||||
}
|
||||
theWorkspace->EnableTexture (aPrevTexture);
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,12 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef OpenGl_PrimitiveArray_Header
|
||||
#define OpenGl_PrimitiveArray_Header
|
||||
|
||||
#include <OpenGl_VertexBuffer.hxx>
|
||||
|
||||
#include <InterfaceGraphic_telem.hxx>
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <Aspect_InteriorStyle.hxx>
|
||||
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
@ -1,58 +0,0 @@
|
||||
// Created on: 2011-03-18
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2011-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.
|
||||
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_ResourceTexture.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE (OpenGl_ResourceTexture, OpenGl_Resource)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ResourceTexture, OpenGl_Resource)
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenGl_ResourceTexture
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
OpenGl_ResourceTexture::OpenGl_ResourceTexture (const GLuint theId)
|
||||
: myTextureId (theId)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ~OpenGl_ResourceTexture
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
OpenGl_ResourceTexture::~OpenGl_ResourceTexture()
|
||||
{
|
||||
Release (NULL);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Release
|
||||
//purpose : free OpenGl memory allocated for texture resource
|
||||
//=======================================================================
|
||||
void OpenGl_ResourceTexture::Release (const OpenGl_Context* theGlCtx)
|
||||
{
|
||||
if (myTextureId != 0 && theGlCtx != NULL)
|
||||
{
|
||||
glDeleteTextures (1, &myTextureId);
|
||||
myTextureId = 0;
|
||||
}
|
||||
}
|
@ -112,11 +112,14 @@ void OpenGl_Structure::SetAspectLine (const CALL_DEF_CONTEXTLINE &AContext)
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void OpenGl_Structure::SetAspectFace (const CALL_DEF_CONTEXTFILLAREA &AContext)
|
||||
void OpenGl_Structure::SetAspectFace (const Handle(OpenGl_Context)& theCtx,
|
||||
const CALL_DEF_CONTEXTFILLAREA& theAspect)
|
||||
{
|
||||
if (!myAspectFace)
|
||||
{
|
||||
myAspectFace = new OpenGl_AspectFace();
|
||||
myAspectFace->SetContext( AContext );
|
||||
}
|
||||
myAspectFace->Init (theCtx, theAspect);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@ -485,7 +488,7 @@ void OpenGl_Structure::ReleaseGlResources (const Handle(OpenGl_Context)& theGlCt
|
||||
|
||||
//=======================================================================
|
||||
//function : SetZLayer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void OpenGl_Structure::SetZLayer (const Standard_Integer theLayerIndex)
|
||||
@ -495,7 +498,7 @@ void OpenGl_Structure::SetZLayer (const Standard_Integer theLayerIndex)
|
||||
|
||||
//=======================================================================
|
||||
//function : GetZLayer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer OpenGl_Structure::GetZLayer () const
|
||||
|
@ -17,7 +17,6 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef OpenGl_Structure_Header
|
||||
#define OpenGl_Structure_Header
|
||||
|
||||
@ -32,8 +31,10 @@
|
||||
#include <OpenGl_Group.hxx>
|
||||
#include <OpenGl_Matrix.hxx>
|
||||
|
||||
typedef NCollection_List<const OpenGl_Structure *> OpenGl_ListOfStructure;
|
||||
typedef NCollection_List<const OpenGl_Group *> OpenGl_ListOfGroup;
|
||||
class OpenGl_Structure;
|
||||
|
||||
typedef NCollection_List<const OpenGl_Structure* > OpenGl_ListOfStructure;
|
||||
typedef NCollection_List<const OpenGl_Group* > OpenGl_ListOfGroup;
|
||||
|
||||
class OpenGl_Structure : public OpenGl_Element
|
||||
{
|
||||
@ -49,7 +50,8 @@ public:
|
||||
void SetDegenerateModel (const Standard_Integer AMode, const float ASkipRatio);
|
||||
|
||||
void SetAspectLine (const CALL_DEF_CONTEXTLINE &AContext);
|
||||
void SetAspectFace (const CALL_DEF_CONTEXTFILLAREA &AContext);
|
||||
void SetAspectFace (const Handle(OpenGl_Context)& theCtx,
|
||||
const CALL_DEF_CONTEXTFILLAREA& theAspect);
|
||||
void SetAspectMarker (const CALL_DEF_CONTEXTMARKER &AContext);
|
||||
void SetAspectText (const CALL_DEF_CONTEXTTEXT &AContext);
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_Text.hxx>
|
||||
#include <OpenGl_AspectText.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
#include <GL/glu.h> // gluUnProject()
|
||||
|
||||
@ -79,7 +79,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
|
||||
// Use highlight colours
|
||||
if( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
|
||||
{
|
||||
{
|
||||
tcolor = scolor = AWorkspace->HighlightColor;
|
||||
}
|
||||
else
|
||||
@ -128,33 +128,33 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
int sWidth, sAscent, sDescent;
|
||||
AWorkspace->StringSize(myString, sWidth, sAscent, sDescent);
|
||||
|
||||
objrefX = (float)myAttachPnt.xyz[0];
|
||||
objrefY = (float)myAttachPnt.xyz[1];
|
||||
objrefX = (float)myAttachPnt.xyz[0];
|
||||
objrefY = (float)myAttachPnt.xyz[1];
|
||||
objrefZ = (float)myAttachPnt.xyz[2];
|
||||
status = gluProject (objrefX, objrefY, objrefZ, modelMatrix, projMatrix, viewport,
|
||||
&winx1, &winy1, &winz1);
|
||||
|
||||
winx = winx1;
|
||||
winy = winy1-sDescent;
|
||||
winz = winz1+0.00001;
|
||||
winz = winz1+0.00001;
|
||||
status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
|
||||
&objX, &objY, &objZ);
|
||||
|
||||
winx = winx1 + sWidth;
|
||||
winy = winy1-sDescent;
|
||||
winz = winz1+0.00001; /* il vaut mieux F+B / 1000000 ? */
|
||||
winz = winz1+0.00001; /* il vaut mieux F+B / 1000000 ? */
|
||||
status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
|
||||
&obj1X, &obj1Y, &obj1Z);
|
||||
|
||||
winx = winx1 + sWidth;
|
||||
winy = winy1 + sAscent;
|
||||
winz = winz1+0.00001;
|
||||
winz = winz1+0.00001;
|
||||
status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
|
||||
&obj2X, &obj2Y, &obj2Z);
|
||||
|
||||
winx = winx1;
|
||||
winy = winy1+ sAscent;
|
||||
winz = winz1+0.00001;
|
||||
winz = winz1+0.00001;
|
||||
status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
|
||||
&obj3X, &obj3Y, &obj3Z);
|
||||
|
||||
@ -169,15 +169,15 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
}
|
||||
|
||||
case Aspect_TODT_DEKALE:
|
||||
objrefX = (float)myAttachPnt.xyz[0];
|
||||
objrefY = (float)myAttachPnt.xyz[1];
|
||||
objrefX = (float)myAttachPnt.xyz[0];
|
||||
objrefY = (float)myAttachPnt.xyz[1];
|
||||
objrefZ = (float)myAttachPnt.xyz[2];
|
||||
status = gluProject (objrefX, objrefY, objrefZ, modelMatrix, projMatrix, viewport,
|
||||
&winx1, &winy1, &winz1);
|
||||
|
||||
winx = winx1+1;
|
||||
winy = winy1+1;
|
||||
winz = winz1+0.00001;
|
||||
winz = winz1+0.00001;
|
||||
status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
|
||||
&objX, &objY, &objZ);
|
||||
|
||||
@ -192,7 +192,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
winx = winx1-1;
|
||||
winy = winy1+1;
|
||||
status = gluUnProject (winx, winy, winz, modelMatrix, projMatrix, viewport,
|
||||
&objX, &objY, &objZ);
|
||||
&objX, &objY, &objZ);
|
||||
|
||||
AWorkspace->RenderText( myString, 0, (float)objX, (float)objY,(float)objZ );
|
||||
winx = winx1+1;
|
||||
|
412
src/OpenGl/OpenGl_Texture.cxx
Normal file
412
src/OpenGl/OpenGl_Texture.cxx
Normal file
@ -0,0 +1,412 @@
|
||||
// Created by: Kirill GAVRILOV
|
||||
// Copyright (c) 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.
|
||||
|
||||
#include <OpenGl_Texture.hxx>
|
||||
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
#include <Standard_Assert.hxx>
|
||||
#include <Image_PixMap.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE (OpenGl_Texture, OpenGl_Resource)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Texture, OpenGl_Resource)
|
||||
|
||||
//! Function for getting power of to number larger or equal to input number.
|
||||
//! @param theNumber number to 'power of two'
|
||||
//! @param theThreshold upper threshold
|
||||
//! @return power of two number
|
||||
inline GLsizei getPowerOfTwo (const GLsizei theNumber,
|
||||
const GLsizei theThreshold)
|
||||
{
|
||||
for (GLsizei p2 = 2; p2 <= theThreshold; p2 <<= 1)
|
||||
{
|
||||
if (theNumber <= p2)
|
||||
{
|
||||
return p2;
|
||||
}
|
||||
}
|
||||
return theThreshold;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_Texture
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_Texture::OpenGl_Texture (const Handle(Graphic3d_TextureParams)& theParams)
|
||||
: OpenGl_Resource(),
|
||||
myTextureId (NO_TEXTURE),
|
||||
myTarget (GL_TEXTURE_2D),
|
||||
mySizeX (0),
|
||||
mySizeY (0),
|
||||
myTextFormat (GL_FLOAT),
|
||||
myHasMipmaps (Standard_False),
|
||||
myParams (theParams)
|
||||
{
|
||||
if (myParams.IsNull())
|
||||
{
|
||||
myParams = new Graphic3d_TextureParams();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ~OpenGl_Texture
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_Texture::~OpenGl_Texture()
|
||||
{
|
||||
Release (NULL);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HasMipmaps
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Standard_Boolean OpenGl_Texture::HasMipmaps() const
|
||||
{
|
||||
return myHasMipmaps;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetParams
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Handle(Graphic3d_TextureParams)& OpenGl_Texture::GetParams() const
|
||||
{
|
||||
return myParams;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetParams
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Texture::SetParams (const Handle(Graphic3d_TextureParams)& theParams)
|
||||
{
|
||||
myParams = theParams;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Create
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_Texture::Create (const Handle(OpenGl_Context)& )
|
||||
{
|
||||
if (myTextureId == NO_TEXTURE)
|
||||
{
|
||||
glGenTextures (1, &myTextureId);
|
||||
}
|
||||
return myTextureId != NO_TEXTURE;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Release
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Texture::Release (const OpenGl_Context* theGlCtx)
|
||||
{
|
||||
if (myTextureId == NO_TEXTURE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// application can not handle this case by exception - this is bug in code
|
||||
Standard_ASSERT_RETURN (theGlCtx != NULL,
|
||||
"OpenGl_Texture destroyed without GL context! Possible GPU memory leakage...",);
|
||||
|
||||
glDeleteTextures (1, &myTextureId);
|
||||
myTextureId = NO_TEXTURE;
|
||||
mySizeX = mySizeY = 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Bind
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Texture::Bind (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLenum theTextureUnit) const
|
||||
{
|
||||
if (theCtx->IsGlGreaterEqual (1, 3))
|
||||
{
|
||||
theCtx->core13->glActiveTexture (theTextureUnit);
|
||||
}
|
||||
glBindTexture (myTarget, myTextureId);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Unbind
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Texture::Unbind (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLenum theTextureUnit) const
|
||||
{
|
||||
if (theCtx->IsGlGreaterEqual (1, 3))
|
||||
{
|
||||
theCtx->core13->glActiveTexture (theTextureUnit);
|
||||
}
|
||||
glBindTexture (myTarget, NO_TEXTURE);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theImage,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
{
|
||||
myHasMipmaps = Standard_False;
|
||||
if (theImage.IsEmpty() || !Create (theCtx))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GLenum aTextureFormat = GL_RGBA8;
|
||||
GLenum aPixelFormat = 0;
|
||||
GLenum aDataType = 0;
|
||||
switch (theImage.Format())
|
||||
{
|
||||
case Image_PixMap::ImgGrayF:
|
||||
{
|
||||
aTextureFormat = GL_ALPHA8; // GL_R8, GL_R32F
|
||||
aPixelFormat = GL_ALPHA; // GL_RED
|
||||
aDataType = GL_FLOAT;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgRGBAF:
|
||||
{
|
||||
aTextureFormat = GL_RGBA8; // GL_RGBA32F
|
||||
aPixelFormat = GL_RGBA;
|
||||
aDataType = GL_FLOAT;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgBGRAF:
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
aTextureFormat = GL_RGBA8; // GL_RGBA32F
|
||||
aPixelFormat = GL_BGRA; // equals to GL_BGRA_EXT
|
||||
aDataType = GL_FLOAT;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgRGBF:
|
||||
{
|
||||
aTextureFormat = GL_RGB8; // GL_RGB32F
|
||||
aPixelFormat = GL_RGB;
|
||||
aDataType = GL_FLOAT;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgBGRF:
|
||||
{
|
||||
aTextureFormat = GL_RGB8; // GL_RGB32F
|
||||
aPixelFormat = GL_BGR; // equals to GL_BGR_EXT
|
||||
aDataType = GL_FLOAT;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgRGBA:
|
||||
{
|
||||
aTextureFormat = GL_RGBA8;
|
||||
aPixelFormat = GL_RGBA;
|
||||
aDataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgBGRA:
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
aTextureFormat = GL_RGBA8;
|
||||
aPixelFormat = GL_BGRA; // equals to GL_BGRA_EXT
|
||||
aDataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgRGB32:
|
||||
{
|
||||
aTextureFormat = GL_RGB8;
|
||||
aPixelFormat = GL_RGBA;
|
||||
aDataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgBGR32:
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
aTextureFormat = GL_RGB8;
|
||||
aPixelFormat = GL_BGRA; // equals to GL_BGRA_EXT
|
||||
aDataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgRGB:
|
||||
{
|
||||
aTextureFormat = GL_RGB8;
|
||||
aPixelFormat = GL_RGB;
|
||||
aDataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgBGR:
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
aTextureFormat = GL_RGB8;
|
||||
aPixelFormat = GL_BGR; // equals to GL_BGR_EXT
|
||||
aDataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
case Image_PixMap::ImgGray:
|
||||
{
|
||||
aTextureFormat = GL_ALPHA8; // GL_R8
|
||||
aPixelFormat = GL_ALPHA; // GL_RED
|
||||
aDataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const GLsizei aMaxSize = theCtx->MaxTextureSize();
|
||||
const GLsizei aWidth = (GLsizei )theImage.SizeX();
|
||||
const GLsizei aHeight = (GLsizei )theImage.SizeY();
|
||||
|
||||
// Notice that formally general NPOT textures are required by OpenGL 2.0 specifications
|
||||
// however some hardware (NV30 - GeForce FX, RadeOn 9xxx and Xxxx) supports GLSL but not NPOT!
|
||||
// Trying to create NPOT rextures on such hardware will not fail
|
||||
// but driver will fall back into software rendering,
|
||||
const bool toForceP2 = !theCtx->IsGlGreaterEqual (3, 0) && !theCtx->arbNPTW;
|
||||
const GLsizei aWidthOut = toForceP2 ? getPowerOfTwo (aWidth, aMaxSize) : Min (aWidth, aMaxSize);
|
||||
const GLsizei aHeightOut = toForceP2 ? getPowerOfTwo (aHeight, aMaxSize) : Min (aHeight, aMaxSize);
|
||||
|
||||
GLint aTestWidth = 0;
|
||||
GLint aTestHeight = 0;
|
||||
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1); // ensure alignment will not screw up the party
|
||||
switch (theType)
|
||||
{
|
||||
case Graphic3d_TOT_1D:
|
||||
{
|
||||
myTarget = GL_TEXTURE_1D;
|
||||
Bind (theCtx);
|
||||
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
Image_PixMap aCopy;
|
||||
GLvoid* aDataPtr = (GLvoid* )theImage.Data();
|
||||
if (aWidth != aWidthOut)
|
||||
{
|
||||
if (!aCopy.InitTrash (theImage.Format(), Standard_Size(aWidthOut), 1)
|
||||
|| gluScaleImage (aPixelFormat,
|
||||
aWidth, 1, aDataType, theImage.Data(),
|
||||
aWidthOut, 1, aDataType, aCopy.ChangeData()) != 0)
|
||||
{
|
||||
Unbind (theCtx);
|
||||
return false;
|
||||
}
|
||||
|
||||
aDataPtr = (GLvoid* )aCopy.Data();
|
||||
}
|
||||
|
||||
// use proxy to check texture could be created or not
|
||||
glTexImage1D (GL_PROXY_TEXTURE_1D, 0, aTextureFormat,
|
||||
aWidthOut, 0,
|
||||
aPixelFormat, aDataType, NULL);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
|
||||
if (aTestWidth == 0)
|
||||
{
|
||||
// no memory or broken input parameters
|
||||
Unbind (theCtx);
|
||||
return false;
|
||||
}
|
||||
|
||||
glTexImage1D (GL_TEXTURE_1D, 0, aTextureFormat,
|
||||
aWidthOut, 0,
|
||||
aPixelFormat, aDataType, aDataPtr);
|
||||
|
||||
Unbind (theCtx);
|
||||
return true;
|
||||
}
|
||||
case Graphic3d_TOT_2D:
|
||||
{
|
||||
myTarget = GL_TEXTURE_2D;
|
||||
Bind (theCtx);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
Image_PixMap aCopy;
|
||||
GLvoid* aDataPtr = (GLvoid* )theImage.Data();
|
||||
if (aWidth != aWidthOut || aHeight != aHeightOut)
|
||||
{
|
||||
// scale texture
|
||||
|
||||
if (!aCopy.InitTrash (theImage.Format(), Standard_Size(aWidthOut), Standard_Size(aHeightOut))
|
||||
|| gluScaleImage (aPixelFormat,
|
||||
aWidth, aHeight, aDataType, theImage.Data(),
|
||||
aWidthOut, aHeightOut, aDataType, aCopy.ChangeData()) != 0)
|
||||
{
|
||||
Unbind (theCtx);
|
||||
return false;
|
||||
}
|
||||
|
||||
aDataPtr = (GLvoid* )aCopy.Data();
|
||||
}
|
||||
|
||||
// use proxy to check texture could be created or not
|
||||
glTexImage2D (GL_PROXY_TEXTURE_2D, 0, aTextureFormat,
|
||||
aWidthOut, aHeightOut, 0,
|
||||
aPixelFormat, aDataType, NULL);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight);
|
||||
if (aTestWidth == 0 || aTestHeight == 0)
|
||||
{
|
||||
// no memory or broken input parameters
|
||||
Unbind (theCtx);
|
||||
return false;
|
||||
}
|
||||
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, aTextureFormat,
|
||||
aWidthOut, aHeightOut, 0,
|
||||
aPixelFormat, aDataType, aDataPtr);
|
||||
|
||||
Unbind (theCtx);
|
||||
return true;
|
||||
}
|
||||
case Graphic3d_TOT_2D_MIPMAP:
|
||||
{
|
||||
myTarget = GL_TEXTURE_2D;
|
||||
myHasMipmaps = Standard_True;
|
||||
Bind (theCtx);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
bool isCreated = gluBuild2DMipmaps (GL_TEXTURE_2D, aTextureFormat,
|
||||
aWidth, aHeight,
|
||||
aPixelFormat, aDataType, theImage.Data()) == 0;
|
||||
Unbind (theCtx);
|
||||
return isCreated;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
107
src/OpenGl/OpenGl_Texture.hxx
Normal file
107
src/OpenGl/OpenGl_Texture.hxx
Normal file
@ -0,0 +1,107 @@
|
||||
// Created by: Kirill GAVRILOV
|
||||
// Copyright (c) 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.
|
||||
|
||||
#ifndef _OpenGl_Texture_H__
|
||||
#define _OpenGl_Texture_H__
|
||||
|
||||
#include <OpenGl_GlCore13.hxx>
|
||||
#include <OpenGl_Resource.hxx>
|
||||
#include <Handle_OpenGl_Texture.hxx>
|
||||
#include <Graphic3d_TypeOfTexture.hxx>
|
||||
#include <Handle_Graphic3d_TextureParams.hxx>
|
||||
|
||||
class Handle(OpenGl_Context);
|
||||
class OpenGl_Context;
|
||||
class Image_PixMap;
|
||||
|
||||
//! Texture resource.
|
||||
class OpenGl_Texture : public OpenGl_Resource
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Helpful constants
|
||||
static const GLuint NO_TEXTURE = 0;
|
||||
|
||||
public:
|
||||
|
||||
//! Create uninitialized VBO.
|
||||
Standard_EXPORT OpenGl_Texture (const Handle(Graphic3d_TextureParams)& theParams = NULL);
|
||||
|
||||
//! Destroy object.
|
||||
Standard_EXPORT virtual ~OpenGl_Texture();
|
||||
|
||||
//! @return true if current object was initialized
|
||||
inline bool IsValid() const
|
||||
{
|
||||
return myTextureId != NO_TEXTURE;
|
||||
}
|
||||
|
||||
//! @return target to which the texture is bound (GL_TEXTURE_1D, GL_TEXTURE_2D)
|
||||
inline GLenum GetTarget() const
|
||||
{
|
||||
return myTarget;
|
||||
}
|
||||
|
||||
//! Creates Texture id if not yet generated.
|
||||
//! Data should be initialized by another method.
|
||||
Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theCtx);
|
||||
|
||||
//! Destroy object - will release GPU memory if any.
|
||||
Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
|
||||
|
||||
//! Bind this Texture to specified unit.
|
||||
Standard_EXPORT void Bind (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLenum theTextureUnit = GL_TEXTURE0) const;
|
||||
|
||||
//! Unbind texture from specified unit.
|
||||
Standard_EXPORT void Unbind (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLenum theTextureUnit = GL_TEXTURE0) const;
|
||||
|
||||
//! Notice that texture will be unbound after this call.
|
||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theImage,
|
||||
const Graphic3d_TypeOfTexture theType);
|
||||
|
||||
//! @return true if texture was generated within mipmaps
|
||||
Standard_EXPORT const Standard_Boolean HasMipmaps() const;
|
||||
|
||||
//! @return assigned texture parameters (not necessary applied)
|
||||
Standard_EXPORT const Handle(Graphic3d_TextureParams)& GetParams() const;
|
||||
|
||||
//! @param texture parameters
|
||||
Standard_EXPORT void SetParams (const Handle(Graphic3d_TextureParams)& theParams);
|
||||
|
||||
protected:
|
||||
|
||||
GLuint myTextureId; //!< GL resource ID
|
||||
GLenum myTarget; //!< GL_TEXTURE_1D/GL_TEXTURE_2D
|
||||
GLsizei mySizeX; //!< texture width
|
||||
GLsizei mySizeY; //!< texture height
|
||||
GLint myTextFormat; //!< texture format - GL_RGB, GL_RGBA,...
|
||||
Standard_Boolean myHasMipmaps; //!< flag indicates that texture was uploaded with mipmaps
|
||||
|
||||
Handle(Graphic3d_TextureParams) myParams; //!< texture parameters
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(OpenGl_Texture) // Type definition
|
||||
|
||||
};
|
||||
|
||||
#endif // _OpenGl_Texture_H__
|
@ -1,847 +0,0 @@
|
||||
// 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
|
||||
* ~~~~~~~~
|
||||
* Gestion des textures sous OpenGL
|
||||
*
|
||||
*
|
||||
* Notes
|
||||
* ~~~~~
|
||||
* Les textures sont toujours initialisee avec des parametres par defaut
|
||||
* texture 1D: WRAP_S = CLAMP
|
||||
* MAG_FILTER = NEAREST
|
||||
* generation de texture automatique en OBJECT_LINEAR
|
||||
* rendu avec DECAL
|
||||
*
|
||||
* texture 2D: WRAP_S/T = REPEAT
|
||||
* MAG/MIN_FILTER = LINEAR
|
||||
* generation de texture automatique en OBJECT_LINEAR
|
||||
* rendu avec MODULATE
|
||||
*
|
||||
* texture 2D MipMap: WRAP_S/T = REPEAT
|
||||
* MAG_FILTER = LINEAR
|
||||
* MIN_FILTER = LINEAR_MIPMAP_NEAREST
|
||||
* generation de texture automatique en OBJECT_LINEAR
|
||||
* rendu avec MODULATE
|
||||
*
|
||||
* Historique des modifications
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* 22-05-97: PCT ; Creation
|
||||
* 18-06-97: FMN ; Ajout entete
|
||||
* 20-06-97: PCT ; Correction bug parametres par defaut texture 1D
|
||||
* 30-06-97: PCT ; Correction bug rechargement de la texture courante
|
||||
* 04-07-97: PCT ; suppression de l'utilisation de libimage.a de SGI
|
||||
* 01-08-97: PCT ; suppression InitializeTextureBox()
|
||||
* 04-08-97: FMN,PCT ; Portage WNT
|
||||
* 05-08-97: FMN ; ajout GetTextureData...
|
||||
* 10-09-97: PCT ; ajout commentaires. GetTexture() ne doit pas
|
||||
* etre utilisee dans Cas.Cade ( le chargement est
|
||||
* fait par Graphic3d )
|
||||
* 06-10-97: FMN ; Portage HP
|
||||
* 14-10-97: FMN ; Ajout OpenGl_Extension
|
||||
* 22-10-97: FMN ; Meilleure gestion de l'extension glXGetCurrentDisplayEXT
|
||||
* 04-11-97: FMN ; Gestion des differentes versions GLX
|
||||
* 19-11-97: FMN ; Ajout GetCurrentDisplay plus simple que glXGetCurrentDisplayEXT
|
||||
* 04-12-97: FMN ; On suppose que l'on travaille en OpenGL1.1 (cf OpenGl_Extension)
|
||||
* 17-12-97: FMN ; Probleme compilation SGI
|
||||
* 17-12-97: FMN ; Probleme sur Optimisation sur MyBindTextureEXT()
|
||||
* Le test sur la texture courante doit tenir compte du contexte.
|
||||
* 22-07-98: FGU ; Ajout fonctions TransferTexture_To_Data() et TransferData_To_Texture()
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_Display.hxx>
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
#include <OpenGl_ResourceTexture.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
#include <GL/glu.h> // gluBuild2DMipmaps()
|
||||
|
||||
#include <NCollection_Vector.hxx>
|
||||
|
||||
typedef enum {TEXDATA_NONE, TEXDATA_1D, TEXDATA_2D, TEXDATA_2DMM} texDataStatus;
|
||||
typedef enum {TEX_NONE, TEX_ALLOCATED} texStatus;
|
||||
|
||||
typedef GLfloat SizeType[4];
|
||||
|
||||
typedef int TextureDataID;
|
||||
#define TEXTUREDATA_ERROR -1
|
||||
|
||||
struct texData
|
||||
{
|
||||
char imageFileName[128];
|
||||
int imageWidth, imageHeight;
|
||||
GLubyte *image;
|
||||
texDataStatus status;
|
||||
GLint type;
|
||||
int share_count;
|
||||
DEFINE_STANDARD_ALLOC
|
||||
};
|
||||
|
||||
struct contextData
|
||||
{
|
||||
GLuint number;
|
||||
GLDRAWABLE drawable;
|
||||
GLCONTEXT context;
|
||||
};
|
||||
|
||||
struct texDraw
|
||||
{
|
||||
TextureDataID data;
|
||||
NCollection_Vector<contextData> contextdata;
|
||||
texStatus status;
|
||||
|
||||
GLint Gen;
|
||||
GLint Light;
|
||||
GLint Wrap;
|
||||
GLfloat Plane1[4];
|
||||
GLfloat Plane2[4];
|
||||
GLint Render;
|
||||
GLfloat scalex, scaley;
|
||||
GLfloat transx, transy;
|
||||
GLfloat angle;
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Variables statiques
|
||||
*/
|
||||
|
||||
static NCollection_Vector<texDraw> textab;
|
||||
|
||||
static NCollection_Vector<texData> texdata;
|
||||
|
||||
static TextureDataID current_texture_data = TEXTUREDATA_ERROR;
|
||||
static TextureID current_texture = TEXTUREBOX_ERROR;
|
||||
|
||||
static GLfloat sgenparams[] = { 1.0 ,0.0 ,0.0 ,0.0};
|
||||
static GLfloat tgenparams[] = { 0.0 ,1.0 ,0.0 ,0.0};
|
||||
|
||||
static GLenum status2type[] = { GL_NONE, GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_2D };
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Fonctions privees
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* recherche l'existence de datas de texture par son nom
|
||||
*/
|
||||
static TextureDataID FindTextureData(char *FileName)
|
||||
{
|
||||
for (int i = 0; i < texdata.Length(); i++)
|
||||
{
|
||||
if ( texdata(i).status != TEXDATA_NONE && strcmp(FileName, texdata(i).imageFileName) == 0 )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return TEXTUREDATA_ERROR;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* recherche un emplacement de data texture libre
|
||||
*/
|
||||
static TextureDataID FindFreeTextureData(void)
|
||||
{
|
||||
for (int i = 0; i < texdata.Length(); i++)
|
||||
{
|
||||
if (texdata(i).status == TEXDATA_NONE)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
texData aTexData;
|
||||
texdata.Append(aTexData);
|
||||
return texdata.Length() - 1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* recherche un emplacement de texture libre
|
||||
*/
|
||||
static TextureID FindFreeTexture(void)
|
||||
{
|
||||
for (int i = 0; i < textab.Length(); i++)
|
||||
{
|
||||
if (textab(i).status == TEX_NONE)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
texDraw aTexDraw;
|
||||
textab.Append(aTexDraw);
|
||||
return textab.Length() - 1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* regarde si la texture a ete definie pour le contexte courant
|
||||
*/
|
||||
static int FindTextureContext(TextureID ID)
|
||||
{
|
||||
int i;
|
||||
|
||||
GLCONTEXT cur = GET_GL_CONTEXT();
|
||||
for (i=0; i<textab(ID).contextdata.Length(); i++)
|
||||
if (textab(ID).contextdata(i).context == cur)
|
||||
return i;
|
||||
|
||||
return TEXTUREBOX_ERROR;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* chargement d'une texture suivant son type
|
||||
*/
|
||||
static void LoadTexture(TextureID ID)
|
||||
{
|
||||
TextureDataID data;
|
||||
|
||||
data = textab(ID).data;
|
||||
switch (texdata(data).status)
|
||||
{
|
||||
case TEXDATA_1D:
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, 4,
|
||||
texdata(data).imageWidth, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, texdata(data).image);
|
||||
break;
|
||||
|
||||
case TEXDATA_2D:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 4,
|
||||
texdata(data).imageWidth, texdata(data).imageHeight, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, texdata(data).image);
|
||||
break;
|
||||
|
||||
case TEXDATA_2DMM:
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, 4,
|
||||
texdata(data).imageWidth,
|
||||
texdata(data).imageHeight,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, texdata(data).image);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* les parametres d'initialisation d'une texture
|
||||
* NE PAS METTRE DANS UNE DISPLAY LIST POUR L'INSTANT ( pb avec les matrices )
|
||||
*/
|
||||
static void SetTextureParam(TextureID ID)
|
||||
{
|
||||
GLint cur_matrix;
|
||||
TextureDataID data;
|
||||
|
||||
|
||||
data = textab(ID).data;
|
||||
glGetIntegerv(GL_MATRIX_MODE, &cur_matrix);
|
||||
|
||||
/*
|
||||
* MISE EN PLACE DE LA MATRICE DE TEXTURE
|
||||
*/
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
/* if (textab(ID).Gen != GL_SPHERE_MAP)
|
||||
{*/
|
||||
glScalef(textab(ID).scalex, textab(ID).scaley, 1.0);
|
||||
glTranslatef(-textab(ID).transx, -textab(ID).transy, 0.0);
|
||||
glRotatef(-textab(ID).angle, 0.0, 0.0, 1.0);
|
||||
/*}*/
|
||||
|
||||
|
||||
/*
|
||||
* GENERATION AUTOMATIQUE DE TEXTURE
|
||||
*/
|
||||
switch (textab(ID).Gen)
|
||||
{
|
||||
case GL_OBJECT_LINEAR:
|
||||
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
|
||||
glTexGenfv(GL_S, GL_OBJECT_PLANE, textab(ID).Plane1);
|
||||
if (texdata(data).status != TEXDATA_1D)
|
||||
{
|
||||
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
|
||||
glTexGenfv(GL_T, GL_OBJECT_PLANE, textab(ID).Plane2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_SPHERE_MAP:
|
||||
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
if (texdata(data).status != TEXDATA_1D)
|
||||
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
break;
|
||||
|
||||
case GL_EYE_LINEAR:
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
|
||||
glTexGenfv(GL_S, GL_EYE_PLANE, textab(ID).Plane1);
|
||||
|
||||
if (texdata(data).status != TEXDATA_1D)
|
||||
{
|
||||
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
|
||||
glTexGenfv(GL_T, GL_EYE_PLANE, textab(ID).Plane2);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* RENDU DE LA TEXTURE AVEC LES LUMIERES
|
||||
*/
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textab(ID).Light);
|
||||
|
||||
|
||||
/*
|
||||
* LISSAGE DE LA TEXTURE
|
||||
*/
|
||||
switch (texdata(data).status)
|
||||
{
|
||||
case TEXDATA_1D:
|
||||
case TEXDATA_2D:
|
||||
glTexParameteri(texdata(data).type, GL_TEXTURE_MAG_FILTER, textab(ID).Render);
|
||||
glTexParameteri(texdata(data).type, GL_TEXTURE_MIN_FILTER, textab(ID).Render);
|
||||
break;
|
||||
|
||||
case TEXDATA_2DMM:
|
||||
if (textab(ID).Render == GL_NEAREST)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* WRAP DE LA TEXTURE
|
||||
*/
|
||||
switch (texdata(data).status)
|
||||
{
|
||||
case TEXDATA_1D:
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, textab(ID).Wrap);
|
||||
break;
|
||||
|
||||
case TEXDATA_2D:
|
||||
case TEXDATA_2DMM:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textab(ID).Wrap);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textab(ID).Wrap);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
glMatrixMode(cur_matrix);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* simulation du glGenTexturesEXT pour un context
|
||||
*/
|
||||
static void MyGenTextureEXT (TextureID ID)
|
||||
{
|
||||
TextureDataID data = textab(ID).data;
|
||||
contextData aContextData;
|
||||
|
||||
aContextData.context = GET_GL_CONTEXT();
|
||||
aContextData.drawable = GET_GLDEV_CONTEXT();
|
||||
glGenTextures (1, &aContextData.number);
|
||||
textab(ID).contextdata.Append(aContextData);
|
||||
glBindTexture (texdata(data).type, aContextData.number);
|
||||
LoadTexture (ID);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* simulation du glBindTextureEXT
|
||||
*/
|
||||
static void MyBindTextureEXT (TextureID ID, int Context)
|
||||
{
|
||||
TextureDataID data = textab(ID).data;
|
||||
if (texdata(data).status == TEXDATA_NONE)
|
||||
return;
|
||||
|
||||
GLenum aParamName = texdata(data).status == TEXDATA_1D ?
|
||||
GL_TEXTURE_BINDING_1D : GL_TEXTURE_BINDING_2D;
|
||||
|
||||
GLint aCurrTex = -1;
|
||||
glGetIntegerv (aParamName, &aCurrTex);
|
||||
if (textab(ID).contextdata(Context).number != aCurrTex)
|
||||
{
|
||||
glBindTexture (texdata(data).type, textab(ID).contextdata(Context).number);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* installation de la texture pour le dernier contexte
|
||||
*/
|
||||
static int InstallTextureInContext(TextureID ID)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("InstallTextureInContext::installation de la texture dans le context\n");
|
||||
#endif
|
||||
MyGenTextureEXT(ID);
|
||||
SetTextureParam(ID);
|
||||
#ifdef PRINT
|
||||
printf("InstallTextureInContext::context ok\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static TextureID GetTextureData(char *FileName, texDataStatus status, const GLint width, const GLint height, const void *data)
|
||||
{
|
||||
TextureDataID i;
|
||||
TextureID j;
|
||||
|
||||
/* essait de trouver la texture */
|
||||
i = FindTextureData(FileName);
|
||||
if (i == TEXTUREDATA_ERROR)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTextureData::la texture %s n'existe pas => chargement\n", FileName);
|
||||
#endif
|
||||
/* creation d'une texture */
|
||||
i = FindFreeTextureData();
|
||||
if (i == TEXTUREDATA_ERROR) return TEXTUREBOX_ERROR;
|
||||
|
||||
texdata(i).share_count = 0;
|
||||
strcpy(texdata(i).imageFileName, FileName);
|
||||
texdata(i).image = new GLubyte[width*height*4];
|
||||
memcpy(texdata(i).image, data, (width*height*4));
|
||||
texdata(i).imageWidth = width;
|
||||
texdata(i).imageHeight = height;
|
||||
|
||||
if (texdata(i).image == NULL) return TEXTUREBOX_ERROR;
|
||||
|
||||
texdata(i).status = status;
|
||||
texdata(i).type = status2type[status];
|
||||
}
|
||||
|
||||
j = FindFreeTexture();
|
||||
if (j != TEXTUREBOX_ERROR)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTextureData::installation texture pour obj %d\n", j);
|
||||
#endif
|
||||
textab(j).contextdata.Clear();
|
||||
textab(j).data = i;
|
||||
textab(j).status = TEX_ALLOCATED;
|
||||
texdata(i).share_count++;
|
||||
|
||||
SetTextureDefaultParams(j);
|
||||
|
||||
#ifdef PRINT
|
||||
printf("GetTextureData::texture %s(%d) texture %d count=%d\n", texdata(i).imageFileName, i, j, texdata(i).share_count);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if (texdata(i).share_count != 0)
|
||||
delete [] texdata(i).image;
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Fonctions publiques
|
||||
*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
GLboolean IsTextureValid(TextureID ID)
|
||||
{
|
||||
if ( (ID < 0) || (ID >= textab.Length()) )
|
||||
return GL_FALSE;
|
||||
|
||||
if (textab.Length() > 0)
|
||||
{
|
||||
return textab(ID).status == TEX_ALLOCATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTextureData1D::loading 1d %s \n", FileName);
|
||||
#endif
|
||||
return GetTextureData(FileName, TEXDATA_1D, width, height, data);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
TextureID GetTextureData2D(char *FileName, const GLint width, const GLint height, const void *data)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTextureData2D::loading 2d %s \n", FileName);
|
||||
#endif
|
||||
return GetTextureData(FileName, TEXDATA_2D, width, height, data);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
TextureID GetTextureData2DMipMap(char *FileName, const GLint width, const GLint height, const void *data)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTextureData2DMipMap::loading 2dmm %s \n", FileName);
|
||||
#endif
|
||||
return GetTextureData(FileName, TEXDATA_2DMM, width, height, data);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetCurrentTexture(TextureID ID)
|
||||
{
|
||||
int context;
|
||||
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
context = FindTextureContext(ID);
|
||||
|
||||
/* la texture n'existe pas dans ce contexte */
|
||||
if (context == TEXTUREBOX_ERROR)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("SetCurrentTexture::installation texture %d dans context\n", ID);
|
||||
#endif
|
||||
/* si on a une erreur pendant l'installation dans le context
|
||||
* alors on installe la texture sans bind */
|
||||
if (InstallTextureInContext(ID) == TEXTUREBOX_ERROR)
|
||||
{
|
||||
LoadTexture(ID);
|
||||
SetTextureParam(ID);
|
||||
}
|
||||
}
|
||||
|
||||
/*oui, alors on bind directement */
|
||||
else
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("SetCurrentTexture: utilisation du bind %d\n", ID);
|
||||
#endif
|
||||
MyBindTextureEXT(ID, context);
|
||||
SetTextureParam(ID);
|
||||
}
|
||||
|
||||
current_texture = ID;
|
||||
current_texture_data = textab(ID).data;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void FreeTexture (const Handle(OpenGl_Context)& theContext,
|
||||
TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid (ID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TextureDataID data = textab(ID).data;
|
||||
texdata(data).share_count--;
|
||||
if (texdata(data).share_count == 0)
|
||||
{
|
||||
// release texture data
|
||||
delete [] texdata(data).image;
|
||||
|
||||
// liberation de la texture dans tous les contextes
|
||||
for (int i = 0; i < textab(ID).contextdata.Length(); ++i)
|
||||
{
|
||||
Handle(OpenGl_ResourceTexture) aResource = new OpenGl_ResourceTexture (textab(ID).contextdata(i).number);
|
||||
|
||||
if (!theContext.IsNull())
|
||||
{
|
||||
theContext->DelayedRelease (aResource);
|
||||
}
|
||||
}
|
||||
|
||||
texdata(data).status = TEXDATA_NONE;
|
||||
|
||||
textab(ID).contextdata.Clear();
|
||||
}
|
||||
|
||||
textab(ID).status = TEX_NONE;
|
||||
|
||||
current_texture_data = TEXTUREDATA_ERROR;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void EnableTexture(void)
|
||||
{
|
||||
if (!IsTextureValid(current_texture)) return;
|
||||
|
||||
switch (texdata(current_texture_data).status)
|
||||
{
|
||||
case TEXDATA_1D:
|
||||
if (textab(current_texture).Gen != GL_NONE)
|
||||
glEnable(GL_TEXTURE_GEN_S);
|
||||
glEnable(GL_TEXTURE_1D);
|
||||
break;
|
||||
|
||||
case TEXDATA_2D:
|
||||
case TEXDATA_2DMM:
|
||||
if (textab(current_texture).Gen != GL_NONE)
|
||||
{
|
||||
glEnable(GL_TEXTURE_GEN_S);
|
||||
glEnable(GL_TEXTURE_GEN_T);
|
||||
}
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void DisableTexture(void)
|
||||
{
|
||||
if ( !IsTextureEnabled() )
|
||||
return;
|
||||
if ( !IsTextureValid( current_texture ) )
|
||||
return;
|
||||
|
||||
switch (texdata(current_texture_data).status)
|
||||
{
|
||||
case TEXDATA_1D:
|
||||
if (textab(current_texture).Gen != GL_NONE)
|
||||
glDisable(GL_TEXTURE_GEN_S);
|
||||
glDisable(GL_TEXTURE_1D);
|
||||
break;
|
||||
|
||||
case TEXDATA_2D:
|
||||
case TEXDATA_2DMM:
|
||||
if (textab(current_texture).Gen != GL_NONE)
|
||||
{
|
||||
glDisable(GL_TEXTURE_GEN_S);
|
||||
glDisable(GL_TEXTURE_GEN_T);
|
||||
}
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
GLboolean IsTextureEnabled(void)
|
||||
{
|
||||
GLboolean isEnabled1D= GL_FALSE, isEnabled2D= GL_FALSE;
|
||||
glGetBooleanv( GL_TEXTURE_1D, &isEnabled1D );
|
||||
glGetBooleanv( GL_TEXTURE_2D, &isEnabled2D );
|
||||
return isEnabled1D || isEnabled2D;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetTextureModulate(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Light = GL_MODULATE;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetTextureDecal(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Light = GL_DECAL;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetTextureClamp(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Wrap = GL_CLAMP;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetTextureRepeat(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Wrap = GL_REPEAT;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/* gestion de la facon d'appliquer la texture */
|
||||
void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4])
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Gen = GL_OBJECT_LINEAR;
|
||||
if (sparams != NULL) memcpy(textab(ID).Plane1, sparams, sizeof(sgenparams));
|
||||
else memcpy(textab(ID).Plane1, sgenparams, sizeof(sgenparams));
|
||||
|
||||
if (texdata(textab(ID).data).status != TEXDATA_1D) {
|
||||
if (tparams != NULL) memcpy(textab(ID).Plane2, tparams, sizeof(tgenparams));
|
||||
else memcpy(textab(ID).Plane2, tgenparams, sizeof(tgenparams));
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetModeSphere(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Gen = GL_SPHERE_MAP;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4])
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Gen = GL_EYE_LINEAR;
|
||||
if (sparams != NULL) memcpy(textab(ID).Plane1, sparams, sizeof(sgenparams));
|
||||
else memcpy(textab(ID).Plane1, sgenparams, sizeof(sgenparams));
|
||||
|
||||
if (texdata(textab(ID).data).status != TEXDATA_1D) {
|
||||
if (tparams != NULL) memcpy(textab(ID).Plane2, tparams, sizeof(tgenparams));
|
||||
else memcpy(textab(ID).Plane2, tgenparams, sizeof(tgenparams));
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetModeManual(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Gen = GL_NONE;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetRenderNearest(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Render = GL_NEAREST;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetRenderLinear(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Render = GL_LINEAR;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetTexturePosition(TextureID ID,
|
||||
GLfloat scalex, GLfloat scaley,
|
||||
GLfloat transx, GLfloat transy,
|
||||
GLfloat angle)
|
||||
{
|
||||
textab(ID).scalex = scalex;
|
||||
textab(ID).scaley = scaley;
|
||||
textab(ID).transx = transx;
|
||||
textab(ID).transy = transy;
|
||||
textab(ID).angle = angle;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetTextureDefaultParams(TextureID ID)
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
#ifdef PRINT
|
||||
printf("SetTextureDefaultParams::set parm par defaut textures\n");
|
||||
#endif
|
||||
|
||||
|
||||
textab(ID).scalex = 1.0;
|
||||
textab(ID).scaley = 1.0;
|
||||
textab(ID).transx = 0.0;
|
||||
textab(ID).transy = 0.0;
|
||||
textab(ID).angle = 0.0;
|
||||
|
||||
textab(ID).Gen = GL_OBJECT_LINEAR;
|
||||
textab(ID).Light = texdata(textab(ID).data).status == TEXDATA_1D ? GL_DECAL : GL_MODULATE;
|
||||
textab(ID).Wrap = texdata(textab(ID).data).status == TEXDATA_1D ? GL_CLAMP : GL_REPEAT;
|
||||
memcpy(textab(ID).Plane1, sgenparams, sizeof(sgenparams));
|
||||
memcpy(textab(ID).Plane2, tgenparams, sizeof(tgenparams));
|
||||
textab(ID).Render = texdata(textab(ID).data).status == TEXDATA_1D ? GL_NEAREST : GL_LINEAR;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* Transfere de donnee des donnees internes a la structure TransferData */
|
||||
void TransferTexture_To_Data(TextureID ID, TextureData *TransfDt)
|
||||
{
|
||||
/* affectations */
|
||||
strcpy(TransfDt->path, texdata(textab(ID).data).imageFileName);
|
||||
TransfDt->gen = textab(ID).Gen;
|
||||
TransfDt->wrap = textab(ID).Wrap;
|
||||
TransfDt->render = textab(ID).Light;
|
||||
TransfDt->scalex = textab(ID).scalex;
|
||||
TransfDt->scaley = textab(ID).scaley;
|
||||
TransfDt->transx = textab(ID).transx;
|
||||
TransfDt->transy = textab(ID).transy;
|
||||
TransfDt->angle = textab(ID).angle;
|
||||
memcpy(TransfDt->plane1, textab(ID).Plane1, sizeof(SizeType));
|
||||
memcpy(TransfDt->plane2, textab(ID).Plane2, sizeof(SizeType));
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
// 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
|
||||
* ~~~~~~~~
|
||||
* Gestion des textures sous OpenGL
|
||||
*
|
||||
*
|
||||
* Notes
|
||||
* ~~~~~
|
||||
* Les textures sont toujours initialisee avec des parametres par defaut
|
||||
* texture 1D: WRAP_S = CLAMP
|
||||
* MAG_FILTER = NEAREST
|
||||
* generation de texture automatique en OBJECT_LINEAR
|
||||
* rendu avec DECAL
|
||||
*
|
||||
* texture 2D: WRAP_S/T = REPEAT
|
||||
* MAG/MIN_FILTER = LINEAR
|
||||
* generation de texture automatique en OBJECT_LINEAR
|
||||
* rendu avec MODULATE
|
||||
*
|
||||
* texture 2D MipMap: WRAP_S/T = REPEAT
|
||||
* MAG_FILTER = LINEAR
|
||||
* MIN_FILTER = LINEAR_MIPMAP_NEAREST
|
||||
* generation de texture automatique en OBJECT_LINEAR
|
||||
* rendu avec MODULATE
|
||||
*
|
||||
*
|
||||
* Attention:
|
||||
* ~~~~~~~~~~~
|
||||
* Ce package a ete teste sur SGI, OSF, SUN, HP et WNT.
|
||||
*
|
||||
*
|
||||
* Historique des modifications
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* 22-05-97: PCT ; creation
|
||||
* 01-08-97: PCT ; suppression InitializeTextureBox()
|
||||
* 05-08-97: FMN ; ajout GetTextureData...
|
||||
* 19-06-98: FMN ; Portage Optimizer (C++)
|
||||
* 22-07-98: FGU ; ajout stucture TextureData
|
||||
*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _OPENGL_TEXTUREBOX_H_
|
||||
#define _OPENGL_TEXTUREBOX_H_
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
|
||||
typedef int TextureID;
|
||||
#define TEXTUREBOX_ERROR ((TextureID)-1)
|
||||
|
||||
/*
|
||||
* Structure
|
||||
*/
|
||||
struct _TextureData
|
||||
{
|
||||
/* Donnees propre au fichier */
|
||||
char path[256];
|
||||
|
||||
/* Donnees propre a la texture */
|
||||
GLint gen;
|
||||
GLint wrap;
|
||||
GLfloat plane1[4], plane2[4];
|
||||
GLint render;
|
||||
GLfloat scalex, scaley;
|
||||
GLfloat transx, transy;
|
||||
GLfloat angle;
|
||||
DEFINE_STANDARD_ALLOC
|
||||
};
|
||||
typedef _TextureData TextureData;
|
||||
|
||||
/*
|
||||
* Gestion des textures
|
||||
*/
|
||||
|
||||
/* Get texture a partir des donnees (format RGBA) GLubyte data[width][height][4]
|
||||
* Le nom est utiliser pour la gesiton en interne, il permet d'eviter de charger
|
||||
* plusieurs textures avec le meme noms.
|
||||
*/
|
||||
TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data);
|
||||
TextureID GetTextureData2D(char *FileName, const GLint width, const GLint height, const void *data);
|
||||
TextureID GetTextureData2DMipMap(char *FileName, const GLint width, const GLint height, const void *data);
|
||||
|
||||
class Handle(OpenGl_Context);
|
||||
void FreeTexture (const Handle(OpenGl_Context)& theContext,
|
||||
TextureID ID);
|
||||
|
||||
void SetCurrentTexture(TextureID ID);
|
||||
GLboolean IsTextureValid(TextureID ID);
|
||||
|
||||
void EnableTexture(void);
|
||||
void DisableTexture(void);
|
||||
GLboolean IsTextureEnabled(void);
|
||||
|
||||
/*
|
||||
* Configuration d'une texture
|
||||
*/
|
||||
|
||||
void SetTextureModulate(TextureID ID);
|
||||
void SetTextureDecal(TextureID ID);
|
||||
|
||||
void SetTextureClamp(TextureID ID);
|
||||
void SetTextureRepeat(TextureID ID);
|
||||
|
||||
void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
|
||||
void SetModeSphere(TextureID ID);
|
||||
void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
|
||||
void SetModeManual(TextureID ID);
|
||||
|
||||
void SetRenderNearest(TextureID ID);
|
||||
void SetRenderLinear(TextureID ID);
|
||||
|
||||
|
||||
void SetTexturePosition(TextureID ID,
|
||||
GLfloat scalex, GLfloat scaley,
|
||||
GLfloat transx, GLfloat transy,
|
||||
GLfloat angle);
|
||||
|
||||
|
||||
void SetTextureDefaultParams(TextureID ID);
|
||||
|
||||
void TransferTexture_To_Data(TextureID, TextureData *);
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#endif /* _OPENGL_TEXTUREBOX_H_ */
|
@ -24,8 +24,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx> /* pour CALL_DEF_STRUCTURE */
|
||||
#include <InterfaceGraphic_Aspect.hxx> /* pour CALL_DEF_VIEW */
|
||||
#include <InterfaceGraphic_Visual3d.hxx>
|
||||
@ -99,7 +97,7 @@ void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
const Standard_Real V = AWorkspace->ActiveView()->Width();
|
||||
|
||||
/* la taille des axes est 1 proportion (fixee a l'init du triedre) */
|
||||
/* de la dimension la plus petite de la window. */
|
||||
/* de la dimension la plus petite de la window. */
|
||||
const GLdouble L = ( U < V ? U : V ) * myScale;
|
||||
|
||||
/*
|
||||
@ -158,18 +156,18 @@ void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creation du triedre
|
||||
/*
|
||||
* Creation du triedre
|
||||
*/
|
||||
const OpenGl_AspectLine *AspectLine = AWorkspace->AspectLine( Standard_True );
|
||||
|
||||
/* Fotis Sioutis 2007-11-14 15:06
|
||||
I have also seen in previous posts that the view trihedron in V3d_WIREFRAME mode
|
||||
changes colors depending on the state of the view. This behaviour can be easily
|
||||
/* Fotis Sioutis 2007-11-14 15:06
|
||||
I have also seen in previous posts that the view trihedron in V3d_WIREFRAME mode
|
||||
changes colors depending on the state of the view. This behaviour can be easily
|
||||
corrected by altering call_triedron_redraw function in OpenGl_triedron.c of TKOpengl.
|
||||
The only change needed is to erase glDisable(GL_LIGHTING) that is called before the
|
||||
The only change needed is to erase glDisable(GL_LIGHTING) that is called before the
|
||||
Axis name drawing and move this function call just before the initial axis drawing.
|
||||
Below is the code portion with the modification.I don't know if this is considered to
|
||||
Below is the code portion with the modification.I don't know if this is considered to
|
||||
be a bug but anyway i believe it might help some of you out there.*/
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
@ -259,10 +257,10 @@ void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
TriedronCoord[1] = rayon * cos(ii * Angle1);
|
||||
glVertex3dv( TriedronCoord );
|
||||
ii--;
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/*
|
||||
/*
|
||||
* Noms des axes et de l'origine
|
||||
*/
|
||||
const OpenGl_AspectText *AspectText = AWorkspace->AspectText( Standard_True );
|
||||
@ -272,7 +270,7 @@ void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
AWorkspace->RenderText (L"Y", 0, float(rayon), float(L + 3.0 * rayon), float(2.0 * rayon));
|
||||
AWorkspace->RenderText (L"Z", 0, float(-2.0 * rayon), float(0.5 * rayon), float(L + 3.0 * rayon));
|
||||
|
||||
/*
|
||||
/*
|
||||
* restauration du contexte des matrices
|
||||
*/
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
@ -304,7 +302,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
GLboolean isWithinView = GL_FALSE;
|
||||
|
||||
/* la taille des axes est 1 proportion (fixee a l'init du triedre) */
|
||||
/* de la dimension la plus petite de la window. */
|
||||
/* de la dimension la plus petite de la window. */
|
||||
GLdouble L = ( U < V ? U : V ) * myScale;
|
||||
|
||||
if (!isWithinView)
|
||||
@ -332,7 +330,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
*/
|
||||
switch (myPos)
|
||||
{
|
||||
case Aspect_TOTP_LEFT_LOWER :
|
||||
case Aspect_TOTP_LEFT_LOWER :
|
||||
glTranslated( -0.5*U + L , -0.5*V + L , 0. );
|
||||
break;
|
||||
|
||||
@ -358,7 +356,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
const OpenGl_AspectLine *AspectLine = AWorkspace->AspectLine( Standard_True );
|
||||
const TEL_COLOUR &aLineColor = AspectLine->Color();
|
||||
|
||||
/*
|
||||
/*
|
||||
* Creation the trihedron
|
||||
*/
|
||||
#define CYLINDER_LENGTH 0.75f
|
||||
@ -373,7 +371,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
/* GL_DEPTH_WRITEMASK is not a valid argument to glIsEnabled, the */
|
||||
/* original code is shown to be broken when run under an OpenGL debugger */
|
||||
/* like GLIntercept. This is the correct way to retrieve the mask value. */
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &aIsDepthMaskEnabled);
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &aIsDepthMaskEnabled);
|
||||
|
||||
const GLdouble aCylinderLength = L * CYLINDER_LENGTH;
|
||||
const GLdouble aCylinderDiametr = L * myDiameter;
|
||||
@ -411,21 +409,21 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
/*Fotis Sioutis | 2008-01-21 10:55
|
||||
In the function call_zbuffer_triedron_redraw of TKOpengl,
|
||||
the z buffered trihedron changes colors in case there
|
||||
is an object in the scene that has an explicit material
|
||||
attached to it.In the trihedron display loop,
|
||||
GL_COLOR_MATERIAL is enabled, but only the GL_DIFFUSE
|
||||
In the function call_zbuffer_triedron_redraw of TKOpengl,
|
||||
the z buffered trihedron changes colors in case there
|
||||
is an object in the scene that has an explicit material
|
||||
attached to it.In the trihedron display loop,
|
||||
GL_COLOR_MATERIAL is enabled, but only the GL_DIFFUSE
|
||||
parameter is utilized in glColorMaterial(...).
|
||||
This causes the last ambient,specular and emission values
|
||||
This causes the last ambient,specular and emission values
|
||||
used, to stay at the stack and applied to the trihedron
|
||||
(which causes the color change).
|
||||
A fix is proposed , to change GL_DIFFUSE to
|
||||
GL_AMBIENT_AND_DIFFUSE in glColorMaterial call in
|
||||
line 946.The above of course will leave unchanged
|
||||
A fix is proposed , to change GL_DIFFUSE to
|
||||
GL_AMBIENT_AND_DIFFUSE in glColorMaterial call in
|
||||
line 946.The above of course will leave unchanged
|
||||
the SPECULAR and EMISSION values.
|
||||
Another proposal which would fix 100% the problem
|
||||
is to use glMaterial instead of glColor on the trihedron
|
||||
Another proposal which would fix 100% the problem
|
||||
is to use glMaterial instead of glColor on the trihedron
|
||||
drawing loop. */
|
||||
const GLfloat aNULLColor[] = { 0.f, 0.f, 0.f, 0.f }; /* FS 21/01/08 */
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, aNULLColor);
|
||||
@ -459,18 +457,18 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
|
||||
/* PCD 17/06/07 */
|
||||
GLint df;
|
||||
glGetIntegerv (GL_DEPTH_FUNC, &df);
|
||||
glGetIntegerv (GL_DEPTH_FUNC, &df);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 2; i++) /* PCD 11/02/08 Two pass method */
|
||||
{
|
||||
if (i == 0) /* First pass */
|
||||
{
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
{
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
@ -486,7 +484,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
glTranslated(0, 0, L * CYLINDER_LENGTH);
|
||||
glCallList(startList + 3);
|
||||
glCallList(startList + 1);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
|
||||
// X axis
|
||||
glRotated(90.0, TriedronAxeY[0], TriedronAxeY[1], TriedronAxeY[2]);
|
||||
@ -495,7 +493,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
glTranslated(0, 0, L * CYLINDER_LENGTH);
|
||||
glCallList(startList + 3);
|
||||
glCallList(startList + 1);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
|
||||
// Y axis
|
||||
glRotated(-90.0, TriedronAxeX[0], TriedronAxeX[1], TriedronAxeX[2]);
|
||||
@ -507,7 +505,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if (!aIsDepthEnabled)
|
||||
if (!aIsDepthEnabled)
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
if (!aIsDepthMaskEnabled)
|
||||
@ -520,7 +518,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
glColor3fv (aLineColor.rgb);
|
||||
|
||||
/* Always write the text */
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
|
||||
glPopAttrib();
|
||||
|
||||
@ -529,11 +527,11 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
const GLdouble rayon = L/30. ; /* rayon de la base du cone */
|
||||
//const double Angle = 2. * M_PI/ myNbFacettes;
|
||||
|
||||
glDeleteLists(startList, 4);
|
||||
glDeleteLists(startList, 4);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
/*
|
||||
/*
|
||||
* origine names
|
||||
*/
|
||||
const OpenGl_AspectText *AspectText = AWorkspace->AspectText( Standard_True );
|
||||
@ -559,7 +557,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Fonctions publiques
|
||||
* Fonctions publiques
|
||||
*/
|
||||
|
||||
|
||||
@ -614,44 +612,51 @@ OpenGl_Trihedron::~OpenGl_Trihedron ()
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* affichage d'un triedre non zoomable dans la wks awsid
|
||||
* affichage d'un triedre non zoomable dans la wks awsid
|
||||
*
|
||||
* Triedre = Objet non Zoomable;
|
||||
* on cree cette fonction pour pouvoir travailler par les structures
|
||||
* on cree cette fonction pour pouvoir travailler par les structures
|
||||
* utilisees par les fonctions Tsm* et TEL_VIEW_REP
|
||||
*
|
||||
*/
|
||||
|
||||
//call_triedron_redraw_from_wsid
|
||||
void OpenGl_Trihedron::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
void OpenGl_Trihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
const OpenGl_AspectLine *oldAspectLine = AWorkspace->SetAspectLine(&myAspectLine);
|
||||
const OpenGl_AspectText *oldAspectText = AWorkspace->SetAspectText(&myAspectText);
|
||||
const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->SetAspectLine (&myAspectLine);
|
||||
const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectText);
|
||||
|
||||
/* check if GL_LIGHTING should be disabled
|
||||
no enabling 'cause it will be done (if necessary: kinda Polygon types )
|
||||
no enabling 'cause it will be done (if necessary: kinda Polygon types )
|
||||
during redrawing structures
|
||||
*/
|
||||
if (!AWorkspace->UseGLLight())
|
||||
glDisable( GL_LIGHTING );
|
||||
if (!theWorkspace->UseGLLight())
|
||||
{
|
||||
glDisable (GL_LIGHTING);
|
||||
}
|
||||
|
||||
/* sauvegarde du contexte (on reste dans le buffer courant) */
|
||||
const GLboolean save_texture_state = IsTextureEnabled();
|
||||
DisableTexture();
|
||||
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
|
||||
|
||||
/* affichage du Triedre Non Zoomable */
|
||||
AWorkspace->ActiveView()->EndTransformPersistence();
|
||||
theWorkspace->ActiveView()->EndTransformPersistence();
|
||||
|
||||
if (myIsWireframe)
|
||||
Redraw (AWorkspace);
|
||||
{
|
||||
Redraw (theWorkspace);
|
||||
}
|
||||
else
|
||||
RedrawZBuffer (AWorkspace);
|
||||
{
|
||||
RedrawZBuffer (theWorkspace);
|
||||
}
|
||||
|
||||
/* restauration du contexte */
|
||||
if (save_texture_state) EnableTexture();
|
||||
// restore aspects
|
||||
if (!aPrevTexture.IsNull())
|
||||
{
|
||||
theWorkspace->EnableTexture (aPrevTexture);
|
||||
}
|
||||
|
||||
AWorkspace->SetAspectText(oldAspectText);
|
||||
AWorkspace->SetAspectLine(oldAspectLine);
|
||||
theWorkspace->SetAspectText (aPrevAspectText);
|
||||
theWorkspace->SetAspectLine (aPrevAspectLine);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
@ -21,16 +21,18 @@
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
|
||||
#include <OpenGl_View.hxx>
|
||||
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <OpenGl_Display.hxx>
|
||||
|
||||
#include <OpenGl_Display.hxx>
|
||||
#include <OpenGl_Texture.hxx>
|
||||
#include <OpenGl_Trihedron.hxx>
|
||||
#include <OpenGl_GraduatedTrihedron.hxx>
|
||||
|
||||
#include <OpenGl_transform_persistence.hxx>
|
||||
|
||||
#include <Graphic3d_TextureEnv.hxx>
|
||||
|
||||
#include <GL/glu.h> // gluUnProject()
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE(OpenGl_View,MMgt_TShared)
|
||||
@ -77,8 +79,7 @@ static const TEL_TRANSFORM_PERSISTENCE myDefaultTransPers = { 0, 0.F, 0.F, 0.F }
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
OpenGl_View::OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext)
|
||||
: myTextureEnv(0),
|
||||
mySurfaceDetail(Visual3d_TOD_NONE),
|
||||
: mySurfaceDetail(Visual3d_TOD_NONE),
|
||||
myBackfacing(0),
|
||||
myBgTexture(myDefaultBgTexture),
|
||||
myBgGradient(myDefaultBgGradient),
|
||||
@ -122,11 +123,45 @@ OpenGl_View::OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext)
|
||||
|
||||
OpenGl_View::~OpenGl_View ()
|
||||
{
|
||||
if (myAnimationListIndex)
|
||||
glDeleteLists((GLuint)myAnimationListIndex,1);
|
||||
ReleaseGlResources (NULL); // ensure ReleaseGlResources() was called within valid context
|
||||
}
|
||||
|
||||
if ( myBgTexture.TexId != 0 )
|
||||
glDeleteTextures( 1, (GLuint*)&(myBgTexture.TexId) );
|
||||
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
if (!myTextureEnv.IsNull())
|
||||
{
|
||||
theCtx->DelayedRelease (myTextureEnv);
|
||||
myTextureEnv.Nullify();
|
||||
}
|
||||
if (myBgTexture.TexId != 0)
|
||||
{
|
||||
glDeleteTextures (1, (GLuint*)&(myBgTexture.TexId));
|
||||
myBgTexture.TexId = 0;
|
||||
}
|
||||
if (myAnimationListIndex)
|
||||
{
|
||||
glDeleteLists ((GLuint )myAnimationListIndex, 1);
|
||||
myAnimationListIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGl_View::SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_TextureEnv)& theTexture)
|
||||
{
|
||||
if (!myTextureEnv.IsNull())
|
||||
{
|
||||
theCtx->DelayedRelease (myTextureEnv);
|
||||
myTextureEnv.Nullify();
|
||||
}
|
||||
|
||||
if (theTexture.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myTextureEnv = new OpenGl_Texture (theTexture->GetParams());
|
||||
Handle(Image_PixMap) anImage = theTexture->GetImage();
|
||||
myTextureEnv->Init (theCtx, *anImage.operator->(), theTexture->Type());
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@ -214,7 +249,7 @@ void OpenGl_View::SetClippingPlanes (const CALL_DEF_VIEWCONTEXT &AContext)
|
||||
{
|
||||
// clear clipping planes information
|
||||
myClippingPlanes.Clear();
|
||||
// update information
|
||||
// update information
|
||||
int i = 0;
|
||||
for (; i < AContext.NbActivePlane; i++)
|
||||
{
|
||||
@ -253,42 +288,42 @@ void OpenGl_View::SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext)
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
//call_togl_cliplimit
|
||||
void OpenGl_View::SetClipLimit (const CALL_DEF_VIEW &ACView)
|
||||
void OpenGl_View::SetClipLimit (const Graphic3d_CView& theCView)
|
||||
{
|
||||
myZClip.Back.Limit =
|
||||
( ACView.Context.ZClipBackPlane - ACView.Mapping.BackPlaneDistance ) /
|
||||
( ACView.Mapping.FrontPlaneDistance - ACView.Mapping.BackPlaneDistance );
|
||||
(theCView.Context.ZClipBackPlane - theCView.Mapping.BackPlaneDistance) /
|
||||
(theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
|
||||
myZClip.Front.Limit =
|
||||
( ACView.Context.ZClipFrontPlane - ACView.Mapping.BackPlaneDistance ) /
|
||||
( ACView.Mapping.FrontPlaneDistance - ACView.Mapping.BackPlaneDistance );
|
||||
if ( myZClip.Back.Limit < 0.F )
|
||||
myZClip.Back.Limit = 0.F;
|
||||
if ( myZClip.Front.Limit > 1.F )
|
||||
myZClip.Front.Limit = 1.F;
|
||||
if ( myZClip.Back.Limit > myZClip.Front.Limit )
|
||||
(theCView.Context.ZClipFrontPlane - theCView.Mapping.BackPlaneDistance) /
|
||||
(theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
|
||||
if (myZClip.Back.Limit < 0.0f)
|
||||
myZClip.Back.Limit = 0.0f;
|
||||
if (myZClip.Front.Limit > 1.0f)
|
||||
myZClip.Front.Limit = 1.0f;
|
||||
if (myZClip.Back.Limit > myZClip.Front.Limit)
|
||||
{
|
||||
myZClip.Back.Limit = 0.F;
|
||||
myZClip.Front.Limit = 1.F;
|
||||
myZClip.Back.Limit = 0.0f;
|
||||
myZClip.Front.Limit = 1.0f;
|
||||
}
|
||||
|
||||
myZClip.Back.IsOn = (ACView.Context.BackZClipping != 0);
|
||||
myZClip.Front.IsOn = (ACView.Context.FrontZClipping != 0);
|
||||
myZClip.Back.IsOn = (theCView.Context.BackZClipping != 0);
|
||||
myZClip.Front.IsOn = (theCView.Context.FrontZClipping != 0);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
//call_togl_viewmapping
|
||||
void OpenGl_View::SetMapping (const CALL_DEF_VIEW &ACView)
|
||||
void OpenGl_View::SetMapping (const Graphic3d_CView& theCView)
|
||||
{
|
||||
const float ratio = ACView.DefWindow.dy / ACView.DefWindow.dx;
|
||||
const float r_ratio = ACView.DefWindow.dx / ACView.DefWindow.dy;
|
||||
const float ratio = theCView.DefWindow.dy / theCView.DefWindow.dx;
|
||||
const float r_ratio = theCView.DefWindow.dx / theCView.DefWindow.dy;
|
||||
|
||||
TEL_VIEW_MAPPING Map;
|
||||
|
||||
Map.window.xmin = ACView.Mapping.WindowLimit.um;
|
||||
Map.window.ymin = ACView.Mapping.WindowLimit.vm;
|
||||
Map.window.xmax = ACView.Mapping.WindowLimit.uM;
|
||||
Map.window.ymax = ACView.Mapping.WindowLimit.vM;
|
||||
Map.window.xmin = theCView.Mapping.WindowLimit.um;
|
||||
Map.window.ymin = theCView.Mapping.WindowLimit.vm;
|
||||
Map.window.xmax = theCView.Mapping.WindowLimit.uM;
|
||||
Map.window.ymax = theCView.Mapping.WindowLimit.vM;
|
||||
|
||||
Map.viewport.xmin = 0.F;
|
||||
Map.viewport.xmax = ( 1.F < r_ratio ? 1.F : r_ratio );
|
||||
@ -297,8 +332,8 @@ void OpenGl_View::SetMapping (const CALL_DEF_VIEW &ACView)
|
||||
Map.viewport.zmin = 0.F;
|
||||
Map.viewport.zmax = 1.F;
|
||||
|
||||
/* projection type */
|
||||
switch( ACView.Mapping.Projection )
|
||||
// projection type
|
||||
switch (theCView.Mapping.Projection)
|
||||
{
|
||||
case 0 :
|
||||
Map.proj = TelPerspective;
|
||||
@ -308,79 +343,81 @@ void OpenGl_View::SetMapping (const CALL_DEF_VIEW &ACView)
|
||||
break;
|
||||
}
|
||||
|
||||
/* projection reference point */
|
||||
Map.prp[0] = ACView.Mapping.ProjectionReferencePoint.x;
|
||||
Map.prp[1] = ACView.Mapping.ProjectionReferencePoint.y;
|
||||
Map.prp[2] = ACView.Mapping.ProjectionReferencePoint.z;
|
||||
// projection reference point
|
||||
Map.prp[0] = theCView.Mapping.ProjectionReferencePoint.x;
|
||||
Map.prp[1] = theCView.Mapping.ProjectionReferencePoint.y;
|
||||
Map.prp[2] = theCView.Mapping.ProjectionReferencePoint.z;
|
||||
if (!openglDisplay.IsNull() && !openglDisplay->Walkthrough())
|
||||
Map.prp[2] += ACView.Mapping.FrontPlaneDistance;
|
||||
Map.prp[2] += theCView.Mapping.FrontPlaneDistance;
|
||||
|
||||
/* view plane distance */
|
||||
Map.vpd = ACView.Mapping.ViewPlaneDistance;
|
||||
// view plane distance
|
||||
Map.vpd = theCView.Mapping.ViewPlaneDistance;
|
||||
|
||||
/* back plane distance */
|
||||
Map.bpd = ACView.Mapping.BackPlaneDistance;
|
||||
// back plane distance
|
||||
Map.bpd = theCView.Mapping.BackPlaneDistance;
|
||||
|
||||
/* front plane distance */
|
||||
Map.fpd = ACView.Mapping.FrontPlaneDistance;
|
||||
// front plane distance
|
||||
Map.fpd = theCView.Mapping.FrontPlaneDistance;
|
||||
|
||||
Tint err_ind = 0;
|
||||
|
||||
/* use user-defined matrix */
|
||||
if ( ACView.Mapping.IsCustomMatrix )
|
||||
// use user-defined matrix
|
||||
if (theCView.Mapping.IsCustomMatrix)
|
||||
{
|
||||
int i, j;
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( j = 0; j < 4; j++ )
|
||||
myMappingMatrix[i][j] = ACView.Mapping.ProjectionMatrix[i][j];
|
||||
myMappingMatrix[i][j] = theCView.Mapping.ProjectionMatrix[i][j];
|
||||
}
|
||||
else
|
||||
else
|
||||
TelEvalViewMappingMatrix( &Map, &err_ind, myMappingMatrix );
|
||||
|
||||
if ( !err_ind )
|
||||
if (!err_ind)
|
||||
myExtra.map = Map;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
//call_togl_vieworientation
|
||||
void OpenGl_View::SetOrientation (const CALL_DEF_VIEW &ACView)
|
||||
void OpenGl_View::SetOrientation (const Graphic3d_CView& theCView)
|
||||
{
|
||||
Tfloat Vrp[3];
|
||||
Tfloat Vpn[3];
|
||||
Tfloat Vup[3];
|
||||
Tfloat ScaleFactors[3];
|
||||
|
||||
Vrp[0] = ACView.Orientation.ViewReferencePoint.x;
|
||||
Vrp[1] = ACView.Orientation.ViewReferencePoint.y;
|
||||
Vrp[2] = ACView.Orientation.ViewReferencePoint.z;
|
||||
Vrp[0] = theCView.Orientation.ViewReferencePoint.x;
|
||||
Vrp[1] = theCView.Orientation.ViewReferencePoint.y;
|
||||
Vrp[2] = theCView.Orientation.ViewReferencePoint.z;
|
||||
|
||||
Vpn[0] = ACView.Orientation.ViewReferencePlane.x;
|
||||
Vpn[1] = ACView.Orientation.ViewReferencePlane.y;
|
||||
Vpn[2] = ACView.Orientation.ViewReferencePlane.z;
|
||||
Vpn[0] = theCView.Orientation.ViewReferencePlane.x;
|
||||
Vpn[1] = theCView.Orientation.ViewReferencePlane.y;
|
||||
Vpn[2] = theCView.Orientation.ViewReferencePlane.z;
|
||||
|
||||
Vup[0] = ACView.Orientation.ViewReferenceUp.x;
|
||||
Vup[1] = ACView.Orientation.ViewReferenceUp.y;
|
||||
Vup[2] = ACView.Orientation.ViewReferenceUp.z;
|
||||
Vup[0] = theCView.Orientation.ViewReferenceUp.x;
|
||||
Vup[1] = theCView.Orientation.ViewReferenceUp.y;
|
||||
Vup[2] = theCView.Orientation.ViewReferenceUp.z;
|
||||
|
||||
ScaleFactors[0] = ACView.Orientation.ViewScaleX;
|
||||
ScaleFactors[1] = ACView.Orientation.ViewScaleY;
|
||||
ScaleFactors[2] = ACView.Orientation.ViewScaleZ;
|
||||
ScaleFactors[0] = theCView.Orientation.ViewScaleX;
|
||||
ScaleFactors[1] = theCView.Orientation.ViewScaleY;
|
||||
ScaleFactors[2] = theCView.Orientation.ViewScaleZ;
|
||||
|
||||
Tint err_ind = 0;
|
||||
|
||||
// use user-defined matrix
|
||||
if ( ACView.Orientation.IsCustomMatrix )
|
||||
if (theCView.Orientation.IsCustomMatrix)
|
||||
{
|
||||
int i, j;
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( j = 0; j < 4; j++ )
|
||||
myOrientationMatrix[i][j] = ACView.Orientation.ModelViewMatrix[i][j];
|
||||
myOrientationMatrix[i][j] = theCView.Orientation.ModelViewMatrix[i][j];
|
||||
}
|
||||
else
|
||||
TelEvalViewOrientationMatrix( Vrp, Vpn, Vup, ScaleFactors, &err_ind, myOrientationMatrix );
|
||||
{
|
||||
TelEvalViewOrientationMatrix (Vrp, Vpn, Vup, ScaleFactors, &err_ind, myOrientationMatrix);
|
||||
}
|
||||
|
||||
if ( !err_ind )
|
||||
if (!err_ind)
|
||||
{
|
||||
myExtra.vrp[0] = Vrp[0];
|
||||
myExtra.vrp[1] = Vrp[1];
|
||||
@ -402,9 +439,10 @@ void OpenGl_View::SetOrientation (const CALL_DEF_VIEW &ACView)
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void OpenGl_View::SetFog (const CALL_DEF_VIEW &ACView, const Standard_Boolean AFlag)
|
||||
void OpenGl_View::SetFog (const Graphic3d_CView& theCView,
|
||||
const Standard_Boolean theFlag)
|
||||
{
|
||||
if( !AFlag )
|
||||
if (!theFlag)
|
||||
{
|
||||
myFog.IsOn = Standard_False;
|
||||
}
|
||||
@ -413,12 +451,12 @@ void OpenGl_View::SetFog (const CALL_DEF_VIEW &ACView, const Standard_Boolean AF
|
||||
myFog.IsOn = Standard_True;
|
||||
|
||||
myFog.Front =
|
||||
(ACView.Context.DepthFrontPlane - ACView.Mapping.BackPlaneDistance) /
|
||||
(ACView.Mapping.FrontPlaneDistance - ACView.Mapping.BackPlaneDistance);
|
||||
(theCView.Context.DepthFrontPlane - theCView.Mapping.BackPlaneDistance) /
|
||||
(theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
|
||||
|
||||
myFog.Back =
|
||||
(ACView.Context.DepthBackPlane - ACView.Mapping.BackPlaneDistance) /
|
||||
(ACView.Mapping.FrontPlaneDistance - ACView.Mapping.BackPlaneDistance);
|
||||
(theCView.Context.DepthBackPlane - theCView.Mapping.BackPlaneDistance) /
|
||||
(theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
|
||||
|
||||
if (myFog.Front < 0.F)
|
||||
myFog.Front = 0.F;
|
||||
@ -436,10 +474,10 @@ void OpenGl_View::SetFog (const CALL_DEF_VIEW &ACView, const Standard_Boolean AF
|
||||
myFog.Back = 0.F;
|
||||
}
|
||||
|
||||
myFog.Color.rgb[0] = ACView.DefWindow.Background.r;
|
||||
myFog.Color.rgb[1] = ACView.DefWindow.Background.g;
|
||||
myFog.Color.rgb[2] = ACView.DefWindow.Background.b;
|
||||
myFog.Color.rgb[3] = 1.F;
|
||||
myFog.Color.rgb[0] = theCView.DefWindow.Background.r;
|
||||
myFog.Color.rgb[1] = theCView.DefWindow.Background.g;
|
||||
myFog.Color.rgb[2] = theCView.DefWindow.Background.b;
|
||||
myFog.Color.rgb[3] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,7 +524,7 @@ void OpenGl_View::EndTransformPersistence ()
|
||||
glPopMatrix ();
|
||||
myIsTransPers = Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@ -586,7 +624,7 @@ const TEL_TRANSFORM_PERSISTENCE * OpenGl_View::BeginTransformPersistence (const
|
||||
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
glTranslated( ATransPers->pointX, ATransPers->pointY, ATransPers->pointZ );
|
||||
glTranslated( ATransPers->pointX, ATransPers->pointY, ATransPers->pointZ );
|
||||
}
|
||||
|
||||
if( ATransPers->mode == TPF_TRIEDRON )
|
||||
|
@ -17,7 +17,6 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef _OpenGl_View_Header
|
||||
#define _OpenGl_View_Header
|
||||
|
||||
@ -44,10 +43,12 @@
|
||||
#include <OpenGl_LayerList.hxx>
|
||||
#include <OpenGl_Light.hxx>
|
||||
|
||||
#include <Handle_OpenGl_Context.hxx>
|
||||
#include <Handle_OpenGl_Trihedron.hxx>
|
||||
#include <Handle_OpenGl_GraduatedTrihedron.hxx>
|
||||
#include <Handle_OpenGl_Workspace.hxx>
|
||||
#include <Handle_OpenGl_View.hxx>
|
||||
#include <Handle_OpenGl_Texture.hxx>
|
||||
|
||||
struct OPENGL_BG_TEXTURE
|
||||
{
|
||||
@ -107,7 +108,10 @@ class OpenGl_View : public MMgt_TShared
|
||||
OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext);
|
||||
virtual ~OpenGl_View ();
|
||||
|
||||
void SetTextureEnv (const Standard_Integer AId) { myTextureEnv = AId; }
|
||||
void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
|
||||
|
||||
void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_TextureEnv)& theTexture);
|
||||
void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode) { mySurfaceDetail = AMode; }
|
||||
void SetBackfacing (const Standard_Integer AMode);
|
||||
void SetLights (const CALL_DEF_VIEWCONTEXT &AContext);
|
||||
@ -115,11 +119,11 @@ class OpenGl_View : public MMgt_TShared
|
||||
void SetClippingPlanes (const CALL_DEF_VIEWCONTEXT &AContext);
|
||||
void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
|
||||
|
||||
void SetClipLimit (const CALL_DEF_VIEW &ACView);
|
||||
void SetMapping (const CALL_DEF_VIEW &ACView);
|
||||
void SetOrientation (const CALL_DEF_VIEW &ACView);
|
||||
void SetClipLimit (const Graphic3d_CView& theCView);
|
||||
void SetMapping (const Graphic3d_CView& theCView);
|
||||
void SetOrientation (const Graphic3d_CView& theCView);
|
||||
|
||||
void SetFog (const CALL_DEF_VIEW &ACView, const Standard_Boolean AFlag);
|
||||
void SetFog (const Graphic3d_CView& theCView, const Standard_Boolean theFlag);
|
||||
|
||||
void TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition, const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe);
|
||||
void TriedronErase ();
|
||||
@ -190,7 +194,7 @@ class OpenGl_View : public MMgt_TShared
|
||||
void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace);
|
||||
void RedrawLayer2d (const Handle(OpenGl_Workspace) &AWorkspace, const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACLayer);
|
||||
|
||||
Standard_Integer myTextureEnv; //WSTextureEnv
|
||||
Handle(OpenGl_Texture) myTextureEnv;
|
||||
Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail
|
||||
Standard_Integer myBackfacing; //WSBackfacing
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_tgl_funcs.hxx>
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <Visual3d_Layer.hxx>
|
||||
@ -1111,18 +1110,17 @@ D = -[Px,Py,Pz] dot |Nx|
|
||||
{
|
||||
case Visual3d_TOD_NONE:
|
||||
AWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
|
||||
DisableTexture();
|
||||
AWorkspace->DisableTexture();
|
||||
// Render the view
|
||||
RenderStructs(AWorkspace);
|
||||
break;
|
||||
|
||||
case Visual3d_TOD_ENVIRONMENT:
|
||||
AWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
|
||||
SetCurrentTexture(myTextureEnv);
|
||||
EnableTexture();
|
||||
AWorkspace->EnableTexture (myTextureEnv);
|
||||
// Render the view
|
||||
RenderStructs(AWorkspace);
|
||||
DisableTexture();
|
||||
AWorkspace->DisableTexture();
|
||||
break;
|
||||
|
||||
case Visual3d_TOD_ALL:
|
||||
@ -1130,14 +1128,13 @@ D = -[Px,Py,Pz] dot |Nx|
|
||||
AWorkspace->NamedStatus &= ~OPENGL_NS_FORBIDSETTEX;
|
||||
// Render the view
|
||||
RenderStructs(AWorkspace);
|
||||
DisableTexture();
|
||||
AWorkspace->DisableTexture();
|
||||
|
||||
// Second pass
|
||||
if (AWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED)
|
||||
{
|
||||
AWorkspace->NamedStatus |= OPENGL_NS_2NDPASSDO;
|
||||
SetCurrentTexture(myTextureEnv);
|
||||
EnableTexture();
|
||||
AWorkspace->EnableTexture (myTextureEnv);
|
||||
|
||||
/* sauvegarde de quelques parametres OpenGL */
|
||||
GLint blend_dst, blend_src;
|
||||
@ -1161,7 +1158,7 @@ D = -[Px,Py,Pz] dot |Nx|
|
||||
|
||||
// Render the view
|
||||
RenderStructs(AWorkspace);
|
||||
DisableTexture();
|
||||
AWorkspace->DisableTexture();
|
||||
|
||||
/* restauration des parametres OpenGL */
|
||||
glBlendFunc(blend_src, blend_dst);
|
||||
|
@ -17,8 +17,7 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_GlCore12.hxx>
|
||||
|
||||
#include <InterfaceGraphic.hxx>
|
||||
|
||||
@ -28,8 +27,11 @@
|
||||
#include <OpenGl_AspectFace.hxx>
|
||||
#include <OpenGl_AspectMarker.hxx>
|
||||
#include <OpenGl_AspectText.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
#include <OpenGl_Texture.hxx>
|
||||
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE(OpenGl_Workspace,OpenGl_Window)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,OpenGl_Window)
|
||||
@ -55,6 +57,7 @@ namespace
|
||||
{ 0.0F, 0.0F, 1.0F, 0.0F },
|
||||
{ 0.0F, 0.0F, 0.0F, 1.0F }}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// =======================================================================
|
||||
@ -99,7 +102,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay,
|
||||
|
||||
// Eviter d'avoir les faces mal orientees en noir.
|
||||
// Pourrait etre utiliser pour detecter les problemes d'orientation
|
||||
glLightModeli ((GLenum )GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
|
||||
glLightModeli ((GLenum )GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
|
||||
|
||||
// Optimisation pour le Fog et l'antialiasing
|
||||
glHint (GL_FOG_HINT, GL_FASTEST);
|
||||
@ -157,7 +160,7 @@ void OpenGl_Workspace::UseTransparency (const Standard_Boolean theFlag)
|
||||
//=======================================================================
|
||||
void OpenGl_Workspace::ResetAppliedAspect()
|
||||
{
|
||||
NamedStatus = IsTextureEnabled() ? OPENGL_NS_TEXTURE : 0;
|
||||
NamedStatus = !myTextureBound.IsNull() ? OPENGL_NS_TEXTURE : 0;
|
||||
HighlightColor = &myDefaultHighlightColor;
|
||||
AspectLine_set = &myDefaultAspectLine;
|
||||
AspectLine_applied = NULL;
|
||||
@ -176,3 +179,246 @@ void OpenGl_Workspace::ResetAppliedAspect()
|
||||
AspectMarker(Standard_True);
|
||||
AspectText(Standard_True);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : DisableTexture
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(OpenGl_Texture) OpenGl_Workspace::DisableTexture()
|
||||
{
|
||||
if (myTextureBound.IsNull())
|
||||
{
|
||||
return myTextureBound;
|
||||
}
|
||||
|
||||
// reset texture matrix because some code may expect it is identity
|
||||
GLint aMatrixMode = GL_TEXTURE;
|
||||
glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode);
|
||||
glMatrixMode (GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glMatrixMode (aMatrixMode);
|
||||
|
||||
myTextureBound->Unbind (myGlContext);
|
||||
switch (myTextureBound->GetTarget())
|
||||
{
|
||||
case GL_TEXTURE_1D:
|
||||
{
|
||||
if (myTextureBound->GetParams()->GenMode() != GL_NONE)
|
||||
{
|
||||
glDisable (GL_TEXTURE_GEN_S);
|
||||
}
|
||||
glDisable (GL_TEXTURE_1D);
|
||||
break;
|
||||
}
|
||||
case GL_TEXTURE_2D:
|
||||
{
|
||||
if (myTextureBound->GetParams()->GenMode() != GL_NONE)
|
||||
{
|
||||
glDisable (GL_TEXTURE_GEN_S);
|
||||
glDisable (GL_TEXTURE_GEN_T);
|
||||
}
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
Handle(OpenGl_Texture) aPrevTexture = myTextureBound;
|
||||
myTextureBound.Nullify();
|
||||
return aPrevTexture;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setTextureParams
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)& theTexture,
|
||||
const Handle(Graphic3d_TextureParams)& theParams)
|
||||
{
|
||||
const Handle(Graphic3d_TextureParams)& aParams = theParams.IsNull() ? theTexture->GetParams() : theParams;
|
||||
if (aParams.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GLint aMatrixMode = GL_TEXTURE;
|
||||
glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode);
|
||||
|
||||
// setup texture matrix
|
||||
glMatrixMode (GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
const Graphic3d_Vec2& aScale = aParams->Scale();
|
||||
const Graphic3d_Vec2& aTrans = aParams->Translation();
|
||||
glScalef ( aScale.x(), aScale.y(), 1.0f);
|
||||
glTranslatef (-aTrans.x(), -aTrans.y(), 0.0f);
|
||||
glRotatef (-aParams->Rotation(), 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// setup generation of texture coordinates
|
||||
switch (aParams->GenMode())
|
||||
{
|
||||
case Graphic3d_TOTM_OBJECT:
|
||||
{
|
||||
glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
|
||||
glTexGenfv (GL_S, GL_OBJECT_PLANE, aParams->GenPlaneS().GetData());
|
||||
if (theTexture->GetTarget() != GL_TEXTURE_1D)
|
||||
{
|
||||
glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
|
||||
glTexGenfv (GL_T, GL_OBJECT_PLANE, aParams->GenPlaneT().GetData());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOTM_SPHERE:
|
||||
{
|
||||
glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
if (theTexture->GetTarget() != GL_TEXTURE_1D)
|
||||
{
|
||||
glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOTM_EYE:
|
||||
{
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
|
||||
glTexGenfv (GL_S, GL_EYE_PLANE, aParams->GenPlaneS().GetData());
|
||||
|
||||
if (theTexture->GetTarget() != GL_TEXTURE_1D)
|
||||
{
|
||||
glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
|
||||
glTexGenfv (GL_T, GL_EYE_PLANE, aParams->GenPlaneT().GetData());
|
||||
}
|
||||
glPopMatrix();
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOTM_MANUAL:
|
||||
default: break;
|
||||
}
|
||||
|
||||
// setup lighting
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aParams->IsModulate() ? GL_MODULATE : GL_DECAL);
|
||||
|
||||
// setup texture filtering and wrapping
|
||||
//if (theTexture->GetParams() != theParams)
|
||||
const GLenum aFilter = (aParams->Filter() == Graphic3d_TOTF_NEAREST) ? GL_NEAREST : GL_LINEAR;
|
||||
const GLenum aWrapMode = aParams->IsRepeat() ? GL_REPEAT : GL_CLAMP;
|
||||
switch (theTexture->GetTarget())
|
||||
{
|
||||
case GL_TEXTURE_1D:
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, aFilter);
|
||||
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, aFilter);
|
||||
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, aWrapMode);
|
||||
break;
|
||||
}
|
||||
case GL_TEXTURE_2D:
|
||||
{
|
||||
GLenum aFilterMin = aFilter;
|
||||
if (theTexture->HasMipmaps())
|
||||
{
|
||||
aFilterMin = GL_NEAREST_MIPMAP_NEAREST;
|
||||
if (aParams->Filter() == Graphic3d_TOTF_BILINEAR)
|
||||
{
|
||||
aFilterMin = GL_LINEAR_MIPMAP_NEAREST;
|
||||
}
|
||||
else if (aParams->Filter() == Graphic3d_TOTF_TRILINEAR)
|
||||
{
|
||||
aFilterMin = GL_LINEAR_MIPMAP_LINEAR;
|
||||
}
|
||||
|
||||
if (myGlContext->extAnis)
|
||||
{
|
||||
// setup degree of anisotropy filter
|
||||
const GLint aMaxDegree = myGlContext->MaxDegreeOfAnisotropy();
|
||||
switch (aParams->AnisoFilter())
|
||||
{
|
||||
case Graphic3d_LOTA_QUALITY:
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aMaxDegree);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_LOTA_MIDDLE:
|
||||
{
|
||||
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (aMaxDegree <= 4) ? 2 : (aMaxDegree / 2));
|
||||
break;
|
||||
}
|
||||
case Graphic3d_LOTA_FAST:
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_LOTA_OFF:
|
||||
default:
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, aFilterMin);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, aFilter);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, aWrapMode);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, aWrapMode);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch (theTexture->GetTarget())
|
||||
{
|
||||
case GL_TEXTURE_1D:
|
||||
{
|
||||
if (aParams->GenMode() != Graphic3d_TOTM_MANUAL)
|
||||
{
|
||||
glEnable (GL_TEXTURE_GEN_S);
|
||||
}
|
||||
glEnable (GL_TEXTURE_1D);
|
||||
break;
|
||||
}
|
||||
case GL_TEXTURE_2D:
|
||||
{
|
||||
if (aParams->GenMode() != Graphic3d_TOTM_MANUAL)
|
||||
{
|
||||
glEnable (GL_TEXTURE_GEN_S);
|
||||
glEnable (GL_TEXTURE_GEN_T);
|
||||
}
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
glMatrixMode (aMatrixMode); // turn back active matrix
|
||||
theTexture->SetParams (aParams);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : EnableTexture
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(OpenGl_Texture) OpenGl_Workspace::EnableTexture (const Handle(OpenGl_Texture)& theTexture,
|
||||
const Handle(Graphic3d_TextureParams)& theParams)
|
||||
{
|
||||
if (theTexture.IsNull() || !theTexture->IsValid())
|
||||
{
|
||||
return DisableTexture();
|
||||
}
|
||||
|
||||
if (myTextureBound.IsNull() && myTextureBound == theTexture)
|
||||
{
|
||||
Handle(OpenGl_Texture) aPrevTexture = myTextureBound;
|
||||
myTextureBound = theTexture;
|
||||
return aPrevTexture;
|
||||
}
|
||||
|
||||
Handle(OpenGl_Texture) aPrevTexture = DisableTexture();
|
||||
myTextureBound = theTexture;
|
||||
myTextureBound->Bind (myGlContext);
|
||||
setTextureParams (myTextureBound, theParams);
|
||||
|
||||
return aPrevTexture;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#ifndef _OpenGl_Workspace_Header
|
||||
#define _OpenGl_Workspace_Header
|
||||
|
||||
@ -26,29 +25,32 @@
|
||||
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <Graphic3d_TypeOfComposition.hxx>
|
||||
|
||||
#include <Graphic3d_CView.hxx>
|
||||
#include <Graphic3d_TypeOfComposition.hxx>
|
||||
#include <Graphic3d_TypeOfTexture.hxx>
|
||||
#include <Graphic3d_PtrFrameBuffer.hxx>
|
||||
#include <Graphic3d_BufferType.hxx>
|
||||
#include <Handle_Graphic3d_TextureParams.hxx>
|
||||
|
||||
#include <Aspect_CLayer2d.hxx>
|
||||
#include <Aspect_Handle.hxx>
|
||||
#include <Aspect_PrintAlgo.hxx>
|
||||
#include <Graphic3d_PtrFrameBuffer.hxx>
|
||||
#include <Graphic3d_BufferType.hxx>
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <InterfaceGraphic_Visual3d.hxx>
|
||||
|
||||
#include <OpenGl_tsm.hxx>
|
||||
|
||||
#include <OpenGl_AspectFace.hxx>
|
||||
#include <OpenGl_Display.hxx>
|
||||
#include <OpenGl_Matrix.hxx>
|
||||
#include <OpenGl_NamedStatus.hxx>
|
||||
#include <OpenGl_TextParam.hxx>
|
||||
|
||||
#include <Handle_OpenGl_View.hxx>
|
||||
#include <Handle_OpenGl_Texture.hxx>
|
||||
|
||||
class OpenGl_AspectLine;
|
||||
class OpenGl_AspectFace;
|
||||
class OpenGl_AspectMarker;
|
||||
class OpenGl_AspectText;
|
||||
class OpenGl_FrameBuffer;
|
||||
@ -88,8 +90,8 @@ public:
|
||||
|
||||
//! Special method to perform printing.
|
||||
//! System-specific and currently only Win platform implemented.
|
||||
Standard_Boolean Print (const Graphic3d_CView& theCView,
|
||||
const Aspect_CLayer2d& theCUnderLayer,
|
||||
Standard_Boolean Print (const Graphic3d_CView& theCView,
|
||||
const Aspect_CLayer2d& theCUnderLayer,
|
||||
const Aspect_CLayer2d& theCOverLayer,
|
||||
const Aspect_Handle theHPrintDC,
|
||||
const Standard_Boolean theToShowBackground,
|
||||
@ -101,7 +103,7 @@ public:
|
||||
|
||||
// szvgl: defined in OpenGl_Workspace_1.cxx
|
||||
void BeginAnimation (const Standard_Boolean theUseDegeneration,
|
||||
const Standard_Boolean theUpdateAM);
|
||||
const Standard_Boolean theUpdateAM);
|
||||
void EndAnimation();
|
||||
void EraseAnimation();
|
||||
|
||||
@ -165,6 +167,10 @@ public:
|
||||
//! Clear the applied aspect state.
|
||||
void ResetAppliedAspect();
|
||||
|
||||
Standard_EXPORT Handle(OpenGl_Texture) DisableTexture();
|
||||
Standard_EXPORT Handle(OpenGl_Texture) EnableTexture (const Handle(OpenGl_Texture)& theTexture,
|
||||
const Handle(Graphic3d_TextureParams)& theParams = NULL);
|
||||
|
||||
//// RELATED TO FONTS ////
|
||||
|
||||
int FindFont (const char* theFontName,
|
||||
@ -198,28 +204,32 @@ protected:
|
||||
virtual Standard_Boolean Activate();
|
||||
|
||||
// TEMPORARY!!!
|
||||
void Redraw1 (const Graphic3d_CView& theCView,
|
||||
const Aspect_CLayer2d& theCUnderLayer,
|
||||
void Redraw1 (const Graphic3d_CView& theCView,
|
||||
const Aspect_CLayer2d& theCUnderLayer,
|
||||
const Aspect_CLayer2d& theCOverLayer,
|
||||
const int theToSwap);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(OpenGl_View) myView; // WSViews - now just one view is supported
|
||||
Tint myTransientList; // WSTransient
|
||||
Standard_Boolean myIsTransientOpen; // transientOpen
|
||||
Tint myRetainMode; // WSRetainMode
|
||||
|
||||
Standard_Boolean myUseTransparency;
|
||||
Standard_Boolean myUseZBuffer;
|
||||
Standard_Boolean myUseDepthTest;
|
||||
Standard_Boolean myUseGLLight;
|
||||
Standard_Boolean myBackBufferRestored;
|
||||
|
||||
//// RELATED TO STATUS ////
|
||||
|
||||
void UpdateMaterial (const int flag);
|
||||
|
||||
void setTextureParams (Handle(OpenGl_Texture)& theTexture,
|
||||
const Handle(Graphic3d_TextureParams)& theParams);
|
||||
|
||||
protected: //! @name protected fields
|
||||
|
||||
Handle(OpenGl_View) myView; // WSViews - now just one view is supported
|
||||
Tint myTransientList; // WSTransient
|
||||
Standard_Boolean myIsTransientOpen; // transientOpen
|
||||
Tint myRetainMode; // WSRetainMode
|
||||
|
||||
Standard_Boolean myUseTransparency;
|
||||
Standard_Boolean myUseZBuffer;
|
||||
Standard_Boolean myUseDepthTest;
|
||||
Standard_Boolean myUseGLLight;
|
||||
Standard_Boolean myBackBufferRestored;
|
||||
|
||||
protected: //! @name fields related to status
|
||||
|
||||
Handle(OpenGl_Texture) myTextureBound; //!< currently bound texture (managed by OpenGl_AspectFace and OpenGl_View environment texture)
|
||||
const OpenGl_AspectLine *AspectLine_set, *AspectLine_applied;
|
||||
const OpenGl_AspectFace *AspectFace_set, *AspectFace_applied;
|
||||
const OpenGl_AspectMarker *AspectMarker_set, *AspectMarker_applied;
|
||||
@ -232,11 +242,13 @@ protected:
|
||||
|
||||
const TEL_POFFSET_PARAM* PolygonOffset_applied;
|
||||
|
||||
public:
|
||||
OpenGl_AspectFace myAspectFaceHl; // Hiddenline aspect
|
||||
|
||||
DEFINE_STANDARD_RTTI(OpenGl_Workspace) // Type definition
|
||||
public: //! @name type definition
|
||||
|
||||
DEFINE_STANDARD_RTTI(OpenGl_Workspace)
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
};
|
||||
|
||||
#endif //_OpenGl_Workspace_Header
|
||||
#endif // _OpenGl_Workspace_Header
|
||||
|
@ -17,7 +17,6 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -26,6 +25,7 @@
|
||||
#include <OpenGl_telem_util.hxx>
|
||||
#include <OpenGl_AspectLine.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
@ -44,7 +44,7 @@ static void call_util_transform_pt (float *x, float *y, float *z);
|
||||
static void call_util_transpose_mat (float tmat[16], float mat[4][4]);
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
/*
|
||||
* Variables statiques
|
||||
*/
|
||||
|
||||
@ -162,7 +162,7 @@ void OpenGl_Workspace::RedrawImmediatMode ()
|
||||
/* FMN necessaire pour l'affichage sur WNT */
|
||||
glFlush();
|
||||
MakeBackBufCurrent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,7 +328,7 @@ void OpenGl_Workspace::Move (const Standard_ShortReal X, const Standard_ShortRea
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
//call_togl_set_linecolor
|
||||
void OpenGl_Workspace::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
|
||||
void OpenGl_Workspace::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
|
||||
{
|
||||
if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
|
||||
{
|
||||
|
@ -34,14 +34,13 @@
|
||||
/* OCC22218 NOTE: project dependency on gl2ps is specified by macro */
|
||||
#ifdef HAVE_GL2PS
|
||||
#include <gl2ps.h>
|
||||
/* OCC22216 NOTE: linker dependency can be switched off by undefining macro.
|
||||
Pragma comment for gl2ps.lib is defined only here. */
|
||||
#ifdef _MSC_VER
|
||||
/* OCC22216 NOTE: linker dependency can be switched off by undefining macro.
|
||||
Pragma comment for gl2ps.lib is defined only here. */
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment( lib, "gl2ps.lib" )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
#include <Aspect_PolygonOffsetMode.hxx>
|
||||
#include <OpenGl_View.hxx>
|
||||
|
||||
@ -51,7 +50,7 @@ static void TelUpdatePolygonOffsets( const TEL_POFFSET_PARAM *pdata )
|
||||
{
|
||||
if ( ( pdata->mode & Aspect_POM_Fill ) == Aspect_POM_Fill )
|
||||
glEnable ( GL_POLYGON_OFFSET_FILL );
|
||||
else
|
||||
else
|
||||
glDisable ( GL_POLYGON_OFFSET_FILL );
|
||||
|
||||
if ( ( pdata->mode & Aspect_POM_Line ) == Aspect_POM_Line )
|
||||
@ -72,22 +71,14 @@ static void TelUpdatePolygonOffsets( const TEL_POFFSET_PARAM *pdata )
|
||||
void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
{
|
||||
// Case of Hiddenline
|
||||
if (AspectFace_set->Context().InteriorStyle == Aspect_IS_HIDDENLINE)
|
||||
if (AspectFace_set->InteriorStyle == Aspect_IS_HIDDENLINE)
|
||||
{
|
||||
/* szvgl - IMPORTANT!!! */
|
||||
static TEL_CONTEXT_FACE hl_context_face;
|
||||
static OpenGl_AspectFace hl_aspect_face;
|
||||
myAspectFaceHl = *AspectFace_set; // copy all values including line edge aspect
|
||||
myAspectFaceHl.IntFront.matcol = BackgroundColor();
|
||||
myAspectFaceHl.IntFront.color_mask = 0;
|
||||
myAspectFaceHl.IntBack.color_mask = 0;
|
||||
|
||||
hl_context_face = AspectFace_set->Context();
|
||||
|
||||
hl_context_face.IntFront.matcol = BackgroundColor();
|
||||
hl_context_face.IntFront.color_mask = 0;
|
||||
hl_context_face.IntBack.color_mask = 0;
|
||||
|
||||
hl_aspect_face.SetContext(hl_context_face);
|
||||
hl_aspect_face.SetAspectEdge(AspectFace_set->AspectEdge());
|
||||
|
||||
AspectFace_set = &hl_aspect_face;
|
||||
AspectFace_set = &myAspectFaceHl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -95,12 +86,12 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
GLenum face = 0;
|
||||
if ( flag == TEL_FRONT_MATERIAL )
|
||||
{
|
||||
prop = &AspectFace_set->Context().IntFront;
|
||||
prop = &AspectFace_set->IntFront;
|
||||
face = GL_FRONT_AND_BACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop = &AspectFace_set->Context().IntBack;
|
||||
prop = &AspectFace_set->IntBack;
|
||||
face = GL_BACK;
|
||||
}
|
||||
|
||||
@ -114,11 +105,11 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
if ( myUseTransparency && prop->trans != 1.0F )
|
||||
{
|
||||
// Render transparent
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable (GL_BLEND);
|
||||
glDepthMask (GL_FALSE);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// Render opaque
|
||||
if ( (NamedStatus & OPENGL_NS_ANTIALIASING) == 0 )
|
||||
@ -127,7 +118,7 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
glDisable (GL_BLEND);
|
||||
}
|
||||
glDepthMask (GL_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static float mAmb[4];
|
||||
@ -140,7 +131,7 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
|
||||
// Reset material
|
||||
if ( NamedStatus & OPENGL_NS_RESMAT )
|
||||
{
|
||||
{
|
||||
// Ambient component
|
||||
if( rm & OPENGL_AMBIENT_MASK )
|
||||
{
|
||||
@ -177,7 +168,7 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
|
||||
if (NamedStatus & OPENGL_NS_2NDPASSDO)
|
||||
{
|
||||
mDiff[3] = prop->env_reflexion;
|
||||
mDiff[3] = prop->env_reflexion;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -194,7 +185,7 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
mSpec[0] = prop->spec * c[0];
|
||||
mSpec[1] = prop->spec * c[1];
|
||||
mSpec[2] = prop->spec * c[2];
|
||||
}
|
||||
}
|
||||
else {
|
||||
mSpec[0] = 0.F;
|
||||
mSpec[1] = 0.F;
|
||||
@ -204,7 +195,7 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
|
||||
// Emissive component
|
||||
if( rm & OPENGL_EMISSIVE_MASK )
|
||||
{
|
||||
{
|
||||
const float *c = prop->isphysic? prop->emscol.rgb : prop->matcol.rgb;
|
||||
|
||||
mEmsv[0] = prop->emsv * c[0];
|
||||
@ -228,10 +219,10 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
glMaterialf(face, GL_SHININESS, mShin);
|
||||
|
||||
NamedStatus &= ~OPENGL_NS_RESMAT;
|
||||
}
|
||||
}
|
||||
|
||||
// Set Material Optimize
|
||||
else
|
||||
else
|
||||
{
|
||||
// Ambient component
|
||||
if( rm & OPENGL_AMBIENT_MASK )
|
||||
@ -280,7 +271,7 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
|
||||
if (NamedStatus & OPENGL_NS_2NDPASSDO)
|
||||
{
|
||||
mDiff[3] = prop->env_reflexion;
|
||||
mDiff[3] = prop->env_reflexion;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -298,7 +289,7 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
|
||||
if (NamedStatus & OPENGL_NS_2NDPASSDO)
|
||||
{
|
||||
newDiff3 = prop->env_reflexion;
|
||||
newDiff3 = prop->env_reflexion;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -323,7 +314,7 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
|
||||
// Specular component
|
||||
if( rm & OPENGL_SPECULAR_MASK )
|
||||
{
|
||||
{
|
||||
const float *c = prop->isphysic? prop->speccol.rgb : defspeccol;
|
||||
|
||||
if (mSpec[0] != prop->spec * c[0] ||
|
||||
@ -368,8 +359,8 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
|
||||
glMaterialfv(face, GL_EMISSION, mEmsv);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
if ( mEmsv[0] != 0.F || mEmsv[1] != 0.F || mEmsv[2] != 0.F )
|
||||
{
|
||||
mEmsv[0] = 0.F;
|
||||
@ -502,97 +493,115 @@ const OpenGl_AspectLine * OpenGl_Workspace::AspectLine(const Standard_Boolean Wi
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
const OpenGl_AspectFace * OpenGl_Workspace::AspectFace(const Standard_Boolean WithApply)
|
||||
const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean theToApply)
|
||||
{
|
||||
if ( WithApply && (AspectFace_set != AspectFace_applied) )
|
||||
if (!theToApply || (AspectFace_set == AspectFace_applied))
|
||||
{
|
||||
const Aspect_InteriorStyle intstyle = AspectFace_set->Context().InteriorStyle;
|
||||
if ( !AspectFace_applied || AspectFace_applied->Context().InteriorStyle != intstyle )
|
||||
return AspectFace_set;
|
||||
}
|
||||
|
||||
const Aspect_InteriorStyle anIntstyle = AspectFace_set->InteriorStyle;
|
||||
if (AspectFace_applied == NULL || AspectFace_applied->InteriorStyle != anIntstyle)
|
||||
{
|
||||
switch (anIntstyle)
|
||||
{
|
||||
switch( intstyle )
|
||||
case Aspect_IS_EMPTY:
|
||||
case Aspect_IS_HOLLOW:
|
||||
{
|
||||
case Aspect_IS_EMPTY:
|
||||
case Aspect_IS_HOLLOW:
|
||||
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
|
||||
break;
|
||||
|
||||
case Aspect_IS_HATCH:
|
||||
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
||||
myDisplay->SetTypeOfHatch(AspectFace_applied? AspectFace_applied->Context().Hatch : TEL_HS_SOLID);
|
||||
break;
|
||||
|
||||
case Aspect_IS_SOLID:
|
||||
case Aspect_IS_HIDDENLINE:
|
||||
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
||||
glDisable(GL_POLYGON_STIPPLE);
|
||||
break;
|
||||
|
||||
case 5: //szvgl - no corresponding enumeration item Aspect_IS_POINT
|
||||
glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
|
||||
break;
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
||||
break;
|
||||
}
|
||||
case Aspect_IS_HATCH:
|
||||
{
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
||||
myDisplay->SetTypeOfHatch (AspectFace_applied != NULL ? AspectFace_applied->Hatch : TEL_HS_SOLID);
|
||||
break;
|
||||
}
|
||||
case Aspect_IS_SOLID:
|
||||
case Aspect_IS_HIDDENLINE:
|
||||
{
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
||||
glDisable (GL_POLYGON_STIPPLE);
|
||||
break;
|
||||
}
|
||||
case 5: //szvgl - no corresponding enumeration item Aspect_IS_POINT
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( intstyle == Aspect_IS_HATCH )
|
||||
}
|
||||
|
||||
if (anIntstyle == Aspect_IS_HATCH)
|
||||
{
|
||||
const Tint hatchstyle = AspectFace_set->Hatch;
|
||||
if (AspectFace_applied == NULL || AspectFace_applied->Hatch != hatchstyle)
|
||||
{
|
||||
const Tint hatchstyle = AspectFace_set->Context().Hatch;
|
||||
if( !AspectFace_applied || AspectFace_applied->Context().Hatch != hatchstyle )
|
||||
{
|
||||
myDisplay->SetTypeOfHatch(hatchstyle);
|
||||
}
|
||||
myDisplay->SetTypeOfHatch(hatchstyle);
|
||||
}
|
||||
if ( !ActiveView()->Backfacing() )
|
||||
}
|
||||
|
||||
if (!ActiveView()->Backfacing())
|
||||
{
|
||||
const Tint aCullingMode = AspectFace_set->CullingMode;
|
||||
if (AspectFace_applied == NULL || AspectFace_applied->CullingMode != aCullingMode)
|
||||
{
|
||||
const Tint mode = AspectFace_set->Context().CullingMode;
|
||||
if( !AspectFace_applied || AspectFace_applied->Context().CullingMode != mode )
|
||||
switch ((TelCullMode )aCullingMode)
|
||||
{
|
||||
switch( (TelCullMode)mode )
|
||||
case TelCullNone:
|
||||
{
|
||||
case TelCullNone:
|
||||
glDisable(GL_CULL_FACE);
|
||||
break;
|
||||
|
||||
case TelCullFront:
|
||||
glCullFace(GL_FRONT);
|
||||
glEnable(GL_CULL_FACE);
|
||||
break;
|
||||
|
||||
case TelCullBack:
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_CULL_FACE);
|
||||
break;
|
||||
glDisable (GL_CULL_FACE);
|
||||
break;
|
||||
}
|
||||
case TelCullFront:
|
||||
{
|
||||
glCullFace (GL_FRONT);
|
||||
glEnable (GL_CULL_FACE);
|
||||
break;
|
||||
}
|
||||
case TelCullBack:
|
||||
{
|
||||
glCullFace (GL_BACK);
|
||||
glEnable (GL_CULL_FACE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Aspect_POM_None means: do not change current settings
|
||||
if ( ( AspectFace_set->Context().PolygonOffset.mode & Aspect_POM_None ) != Aspect_POM_None )
|
||||
// Aspect_POM_None means: do not change current settings
|
||||
if ((AspectFace_set->PolygonOffset.mode & Aspect_POM_None) != Aspect_POM_None)
|
||||
{
|
||||
if (PolygonOffset_applied == NULL
|
||||
|| PolygonOffset_applied->mode != AspectFace_set->PolygonOffset.mode
|
||||
|| PolygonOffset_applied->factor != AspectFace_set->PolygonOffset.factor
|
||||
|| PolygonOffset_applied->units != AspectFace_set->PolygonOffset.units)
|
||||
{
|
||||
if ( !PolygonOffset_applied ||
|
||||
PolygonOffset_applied->mode != AspectFace_set->Context().PolygonOffset.mode ||
|
||||
PolygonOffset_applied->factor != AspectFace_set->Context().PolygonOffset.factor ||
|
||||
PolygonOffset_applied->units != AspectFace_set->Context().PolygonOffset.units )
|
||||
{
|
||||
PolygonOffset_applied = &AspectFace_set->Context().PolygonOffset;
|
||||
TelUpdatePolygonOffsets( PolygonOffset_applied );
|
||||
}
|
||||
PolygonOffset_applied = &AspectFace_set->PolygonOffset;
|
||||
TelUpdatePolygonOffsets (PolygonOffset_applied);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateMaterial( TEL_FRONT_MATERIAL );
|
||||
if (AspectFace_set->Context().DistinguishingMode == TOn)
|
||||
UpdateMaterial( TEL_BACK_MATERIAL );
|
||||
UpdateMaterial (TEL_FRONT_MATERIAL);
|
||||
if (AspectFace_set->DistinguishingMode == TOn)
|
||||
{
|
||||
UpdateMaterial (TEL_BACK_MATERIAL);
|
||||
}
|
||||
|
||||
if ((NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0)
|
||||
if ((NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0)
|
||||
{
|
||||
if (AspectFace_set->doTextureMap)
|
||||
{
|
||||
EnableTexture (AspectFace_set->TextureRes,
|
||||
AspectFace_set->TextureParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisableTexture();
|
||||
if (AspectFace_set->Context().doTextureMap)
|
||||
{
|
||||
SetCurrentTexture(AspectFace_set->Context().TexId);
|
||||
EnableTexture();
|
||||
}
|
||||
}
|
||||
|
||||
AspectFace_applied = AspectFace_set;
|
||||
}
|
||||
|
||||
AspectFace_applied = AspectFace_set;
|
||||
return AspectFace_set;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <Aspect_InteriorStyle.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_TextureRoot.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
|
||||
@ -1786,61 +1787,6 @@ static int VDisplayAll( Draw_Interpretor& di, Standard_Integer argc, const char*
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//#######################################################################################################
|
||||
|
||||
|
||||
static TCollection_AsciiString GetEnvir (Draw_Interpretor& di) {
|
||||
|
||||
static Standard_Boolean IsDefined=Standard_False ;
|
||||
static TCollection_AsciiString VarName;
|
||||
if ( !IsDefined ) {
|
||||
const char *envir, *casroot ;
|
||||
envir = getenv("CSF_MDTVTexturesDirectory") ;
|
||||
|
||||
Standard_Boolean HasDefinition = Standard_False ;
|
||||
if ( !envir ) {
|
||||
casroot = getenv("CASROOT");
|
||||
if ( casroot ) {
|
||||
VarName = TCollection_AsciiString (casroot);
|
||||
VarName += "/src/Textures" ;
|
||||
HasDefinition = Standard_True ;
|
||||
}
|
||||
} else {
|
||||
VarName = TCollection_AsciiString (envir);
|
||||
HasDefinition = Standard_True ;
|
||||
}
|
||||
if ( HasDefinition ) {
|
||||
OSD_Path aPath ( VarName );
|
||||
OSD_Directory aDir(aPath);
|
||||
if ( aDir.Exists () ) {
|
||||
TCollection_AsciiString aTexture = VarName + "/2d_MatraDatavision.rgb" ;
|
||||
OSD_File TextureFile ( aTexture );
|
||||
if ( !TextureFile.Exists() ) {
|
||||
di << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << "\n";
|
||||
di << " not all files are found in : "<<VarName.ToCString() << "\n";
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory or CASROOT not correctly setted " );
|
||||
}
|
||||
} else {
|
||||
di << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << "\n";
|
||||
di << " Directory : "<< VarName.ToCString() << " not exist " << "\n";
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory or CASROOT not correctly setted " );
|
||||
}
|
||||
return VarName ;
|
||||
} else {
|
||||
di << " CSF_MDTVTexturesDirectory and CASROOT not setted " << "\n";
|
||||
di << " one of these variable are mandatory to use this fonctionnality" << "\n";
|
||||
Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory and CASROOT not setted " );
|
||||
}
|
||||
IsDefined = Standard_True ;
|
||||
}
|
||||
return VarName ;
|
||||
|
||||
}
|
||||
|
||||
//#######################################################################################################
|
||||
|
||||
|
||||
//#######################################################################################################
|
||||
|
||||
//## VTexture
|
||||
@ -1909,8 +1855,7 @@ Standard_Integer VTexture (Draw_Interpretor& di,Standard_Integer argc, const cha
|
||||
{
|
||||
if(strcasecmp(argv[2],"?")==0)
|
||||
{
|
||||
TCollection_AsciiString monPath = GetEnvir (di) ;
|
||||
|
||||
TCollection_AsciiString monPath = Graphic3d_TextureRoot::TexturesFolder();
|
||||
di<<"\n Files in current directory : \n"<<"\n";
|
||||
TCollection_AsciiString Cmnd ("glob -nocomplain *");
|
||||
di.Eval(Cmnd.ToCString());
|
||||
|
@ -171,7 +171,6 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
// To test linking against OpenGl_Workspace and all aspect classes
|
||||
const OpenGl_AspectLine* aLA = theWorkspace->AspectLine(0);
|
||||
const OpenGl_AspectFace* aFA = theWorkspace->AspectFace(0);
|
||||
aFA->Context();
|
||||
const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker(0);
|
||||
aMA->Type();
|
||||
const OpenGl_AspectText* aTA = theWorkspace->AspectText(0);
|
||||
|
@ -46,11 +46,6 @@
|
||||
|
||||
************************************************************************/
|
||||
|
||||
#define IMP190100 //GG
|
||||
// -> Enable to have overlapped BeginDraw() EndDraw().
|
||||
// -> Don't redraw the scene at ClearDraw()
|
||||
// but erase only the immediat draw stuff.
|
||||
|
||||
// for the class
|
||||
#include <Visual3d_TransientManager.ixx>
|
||||
#include <Visual3d_ViewPtr.hxx>
|
||||
@ -68,18 +63,14 @@
|
||||
#define DEBUG_PRO4022
|
||||
#define DEBUG_TEMPO_FOR_ROB
|
||||
|
||||
enum TypeOfImmediat {
|
||||
enum TypeOfImmediat {
|
||||
Immediat_None,
|
||||
Immediat_Transient,
|
||||
Immediat_Ajout
|
||||
};
|
||||
|
||||
//-Global data definitions
|
||||
#ifdef IMP190100
|
||||
static Standard_Integer theDrawingState = 0;
|
||||
#else
|
||||
static Standard_Boolean theDrawingState = Standard_False;
|
||||
#endif
|
||||
static Standard_Real theMinX,theMinY,theMinZ,theMaxX,theMaxY,theMaxZ;
|
||||
static TypeOfImmediat theImmediatState = Immediat_None;
|
||||
static Graphic3d_TypeOfPrimitive theTypeOfPrimitive = Graphic3d_TOP_UNDEFINED;
|
||||
@ -91,7 +82,7 @@ return theGraphicDriver;
|
||||
#define theGraphicDriver _theGraphicDriver()
|
||||
|
||||
static Graphic3d_CView& _theCView() {
|
||||
static Graphic3d_CView theCView;
|
||||
static Graphic3d_CView theCView;
|
||||
return theCView;
|
||||
}
|
||||
#define theCView _theCView()
|
||||
@ -117,17 +108,13 @@ void Visual3d_TransientManager::Destroy () {
|
||||
|
||||
Standard_Boolean Visual3d_TransientManager::BeginDraw (const Handle(Visual3d_View)& AView, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode) {
|
||||
|
||||
#ifdef IMP190100
|
||||
if (theDrawingState > 0) {
|
||||
CALL_DEF_VIEW* pview = (CALL_DEF_VIEW*) AView->CView();
|
||||
Graphic3d_CView* pview = (Graphic3d_CView*) AView->CView();
|
||||
if( theImmediatState == Immediat_Transient &&
|
||||
pview->ViewId == theCView.ViewId ) {
|
||||
theDrawingState++;
|
||||
return theDrawingState;
|
||||
} else
|
||||
#else
|
||||
if (theDrawingState) {
|
||||
#endif
|
||||
Visual3d_TransientDefinitionError::Raise
|
||||
("Drawing in progress !");
|
||||
}
|
||||
@ -135,7 +122,7 @@ Standard_Boolean Visual3d_TransientManager::BeginDraw (const Handle(Visual3d_Vie
|
||||
Handle(Visual3d_Layer) OverLayer = AView->OverLayer ();
|
||||
Handle(Visual3d_Layer) UnderLayer = AView->UnderLayer ();
|
||||
OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
|
||||
theCView = *(CALL_DEF_VIEW *)AView->CView ();
|
||||
theCView = *(Graphic3d_CView* )AView->CView ();
|
||||
|
||||
if (! UnderLayer.IsNull ()){
|
||||
UnderCLayer = UnderLayer->CLayer();
|
||||
@ -153,11 +140,7 @@ Handle(Visual3d_Layer) UnderLayer = AView->UnderLayer ();
|
||||
|
||||
if (theGraphicDriver->BeginImmediatMode
|
||||
(theCView, UnderCLayer, OverCLayer, DoubleBuffer, RetainMode)) {
|
||||
#ifdef IMP190100
|
||||
theDrawingState++;
|
||||
#else
|
||||
theDrawingState = Standard_True;
|
||||
#endif
|
||||
theTypeOfPrimitive = Graphic3d_TOP_UNDEFINED;
|
||||
theImmediatState = Immediat_Transient;
|
||||
// Reset MinMax
|
||||
@ -174,19 +157,11 @@ Handle(Visual3d_Layer) UnderLayer = AView->UnderLayer ();
|
||||
|
||||
void Visual3d_TransientManager::EndDraw (const Standard_Boolean Synchronize) {
|
||||
|
||||
#ifdef IMP190100
|
||||
if( theDrawingState <= 0 )
|
||||
#else
|
||||
if( !theDrawingState )
|
||||
#endif
|
||||
Visual3d_TransientDefinitionError::Raise ("Drawing not started !");
|
||||
|
||||
#ifdef IMP190100
|
||||
theDrawingState--;
|
||||
if( theDrawingState > 0 ) return;
|
||||
#else
|
||||
theDrawingState = Standard_False;
|
||||
#endif
|
||||
theImmediatState = Immediat_None;
|
||||
|
||||
// Flush all graphics
|
||||
@ -196,17 +171,12 @@ void Visual3d_TransientManager::EndDraw (const Standard_Boolean Synchronize) {
|
||||
void Visual3d_TransientManager::ClearDraw (const Handle(Visual3d_View)& AView,
|
||||
const Standard_Boolean aFlush)
|
||||
{
|
||||
|
||||
#ifdef IMP190100
|
||||
if (theDrawingState > 0)
|
||||
#else
|
||||
if (theDrawingState)
|
||||
#endif
|
||||
Visual3d_TransientDefinitionError::Raise
|
||||
("Drawing in progress !");
|
||||
|
||||
// Begin rendering
|
||||
theCView = *(CALL_DEF_VIEW *)AView->CView ();
|
||||
theCView = *(Graphic3d_CView* )AView->CView ();
|
||||
if (!AView->UnderLayer().IsNull()) {
|
||||
UnderCLayer = AView->UnderLayer()->CLayer();
|
||||
theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer;
|
||||
@ -220,11 +190,6 @@ void Visual3d_TransientManager::ClearDraw (const Handle(Visual3d_View)& AView,
|
||||
theGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
|
||||
|
||||
theGraphicDriver->ClearImmediatMode (theCView, aFlush);
|
||||
|
||||
#ifndef IMP190100
|
||||
// Reaffichage
|
||||
AView->Redraw ();
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
@ -232,24 +197,19 @@ void Visual3d_TransientManager::ClearDraw (const Handle(Visual3d_View)& AView,
|
||||
//
|
||||
|
||||
Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_View)& AView) {
|
||||
|
||||
#ifdef IMP190100
|
||||
if (theDrawingState > 0) {
|
||||
CALL_DEF_VIEW* pview = (CALL_DEF_VIEW*) AView->CView();
|
||||
Graphic3d_CView* pview = (Graphic3d_CView* )AView->CView();
|
||||
if( theImmediatState == Immediat_Ajout &&
|
||||
pview->ViewId == theCView.ViewId ) {
|
||||
theDrawingState++;
|
||||
return theDrawingState;
|
||||
} else
|
||||
#else
|
||||
if (theDrawingState) {
|
||||
#endif
|
||||
Visual3d_TransientDefinitionError::Raise
|
||||
("Drawing in progress !");
|
||||
}
|
||||
|
||||
// Begin rendering
|
||||
theCView = *(CALL_DEF_VIEW *)AView->CView ();
|
||||
theCView = *(Graphic3d_CView* )AView->CView ();
|
||||
if (!AView->UnderLayer().IsNull()) {
|
||||
UnderCLayer = AView->UnderLayer()->CLayer();
|
||||
theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer;
|
||||
@ -263,11 +223,7 @@ Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_
|
||||
theGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
|
||||
|
||||
if (theGraphicDriver->BeginAddMode (theCView)) {
|
||||
#ifdef IMP190100
|
||||
theDrawingState++;
|
||||
#else
|
||||
theDrawingState = Standard_True;
|
||||
#endif
|
||||
theTypeOfPrimitive = Graphic3d_TOP_UNDEFINED;
|
||||
theImmediatState = Immediat_Ajout;
|
||||
// Reset MinMax
|
||||
@ -284,19 +240,11 @@ Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_
|
||||
|
||||
void Visual3d_TransientManager::EndAddDraw () {
|
||||
|
||||
#ifdef IMP190100
|
||||
if( theDrawingState <= 0 )
|
||||
#else
|
||||
if( !theDrawingState )
|
||||
#endif
|
||||
Visual3d_TransientDefinitionError::Raise ("Drawing not started !");
|
||||
|
||||
#ifdef IMP190100
|
||||
theDrawingState--;
|
||||
if( theDrawingState > 0 ) return;
|
||||
#else
|
||||
theDrawingState = Standard_False;
|
||||
#endif
|
||||
theImmediatState = Immediat_None;
|
||||
// Flush all graphics
|
||||
theGraphicDriver->EndAddMode();
|
||||
@ -540,8 +488,7 @@ Standard_ShortReal SRF = ShortRealFirst ();
|
||||
theGraphicDriver->SetMinMax (x1, y1, z1, x2, y2, z2);
|
||||
#endif /* DEBUG_PRO4022 */
|
||||
|
||||
theGraphicDriver->DrawStructure
|
||||
(*(CALL_DEF_STRUCTURE *)AStructure->CStructure ());
|
||||
theGraphicDriver->DrawStructure (*AStructure->CStructure());
|
||||
}
|
||||
|
||||
}
|
||||
@ -604,7 +551,7 @@ Quantity_Color AColor;
|
||||
Aspect_TypeOfMarker AType;
|
||||
|
||||
CTX->Values (AColor,AType,AScale);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Visual3d_TransientManager::SetTransform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType) {
|
||||
@ -625,7 +572,7 @@ Standard_Integer lr, ur, lc, uc;
|
||||
("Visual3d_TransientManager::SetTransform, Bad Transformation matrix !");
|
||||
|
||||
theGraphicDriver->Transform (AMatrix, AType);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Visual3d_TransientManager::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) {
|
||||
|
@ -85,8 +85,6 @@
|
||||
|
||||
#define GER61454 //GG 14-09-99 Activates model clipping planes
|
||||
|
||||
#define IMP140100 //GG14-01-00 Add ViewManager( ) method
|
||||
|
||||
#define G003 //EUG 30-09-00 Degeneration management
|
||||
// Backfacing management
|
||||
|
||||
@ -196,24 +194,18 @@ MyDisplayedStructure ()
|
||||
{
|
||||
Standard_Integer i, j;
|
||||
|
||||
#ifdef IMP140100
|
||||
MyPtrViewManager = AManager.operator->();
|
||||
#else
|
||||
MyPtrViewManager = (void *) AManager.operator->();
|
||||
#endif
|
||||
|
||||
memset (&MyCView, 0, sizeof(MyCView));
|
||||
MyCView.ViewId = int (AManager->Identification (this));
|
||||
MyCView.Active = 0;
|
||||
MyCView.IsDeleted = 0;
|
||||
|
||||
MyCView.WsId = -1;
|
||||
MyCView.DefWindow.IsDefined = 0;
|
||||
MyCView.WsId = -1;
|
||||
MyCView.DefWindow.IsDefined = 0;
|
||||
|
||||
MyCView.Context.NbActiveLight = 0;
|
||||
MyCView.Context.NbActivePlane = 0;
|
||||
MyCView.Context.NbActiveLight = 0;
|
||||
MyCView.Context.NbActivePlane = 0;
|
||||
#ifdef GER61454
|
||||
MyCView.Context.ActivePlane = NULL;
|
||||
MyCView.Context.ActivePlane = NULL;
|
||||
#endif
|
||||
|
||||
for (i=0; i<=3; i++)
|
||||
@ -319,28 +311,22 @@ MyDisplayedStructure ()
|
||||
{
|
||||
Standard_Integer i, j;
|
||||
|
||||
#ifdef IMP140100
|
||||
MyPtrViewManager = AManager.operator->();
|
||||
#else
|
||||
MyPtrViewManager = (void *) AManager.operator->();
|
||||
#endif
|
||||
|
||||
MyViewOrientation = VO;
|
||||
MyViewMapping = VM;
|
||||
MyContext = CTX;
|
||||
MyViewOrientationReset = VO;
|
||||
MyViewMappingReset = VM;
|
||||
|
||||
memset (&MyCView, 0, sizeof(MyCView));
|
||||
MyCView.ViewId = int (AManager->Identification (this));
|
||||
MyCView.Active = 0;
|
||||
MyCView.IsDeleted = 0;
|
||||
|
||||
MyCView.WsId = -1;
|
||||
MyCView.DefWindow.IsDefined = 0;
|
||||
MyCView.WsId = -1;
|
||||
MyCView.DefWindow.IsDefined = 0;
|
||||
|
||||
MyCView.Context.NbActiveLight = 0;
|
||||
MyCView.Context.NbActivePlane = 0;
|
||||
MyCView.Context.NbActiveLight = 0;
|
||||
MyCView.Context.NbActivePlane = 0;
|
||||
#ifdef GER61454
|
||||
MyCView.Context.ActivePlane = NULL;
|
||||
#endif
|
||||
@ -533,7 +519,7 @@ const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow;
|
||||
// Update planses of model clipping
|
||||
UpdatePlanes ();
|
||||
|
||||
// Update light sources
|
||||
// Update light sources
|
||||
UpdateLights ();
|
||||
|
||||
/*
|
||||
@ -907,7 +893,7 @@ CALL_DEF_PLANE *planes=NULL;
|
||||
|
||||
if (MyCView.Context.NbActivePlane > 0) {
|
||||
|
||||
// Dynamic Allocation
|
||||
// Dynamic Allocation
|
||||
#ifdef GER61454 //Keep the plane address for the next Update !
|
||||
if( !MyCView.Context.ActivePlane )
|
||||
MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j];
|
||||
@ -1462,7 +1448,7 @@ void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
|
||||
Visual3d_TypeOfVisualization OldVisualMode;
|
||||
Visual3d_TypeOfVisualization NewVisualMode;
|
||||
|
||||
// To manage display only in case of
|
||||
// To manage display only in case of
|
||||
// change of visualisation mode.
|
||||
OldVisualMode = MyContext.Visualization ();
|
||||
NewVisualMode = CTX.Visualization ();
|
||||
@ -1470,7 +1456,7 @@ Visual3d_TypeOfVisualization NewVisualMode;
|
||||
Visual3d_TypeOfModel OldModel;
|
||||
Visual3d_TypeOfModel NewModel;
|
||||
|
||||
// To manage change of visualisation only in case
|
||||
// To manage change of visualisation only in case
|
||||
// of change of mode of visualisation or of type of shading.
|
||||
OldModel = MyContext.Model ();
|
||||
NewModel = CTX.Model ();
|
||||
@ -1520,22 +1506,11 @@ Standard_Real NewZClippingBackPlane;
|
||||
OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
|
||||
NewZClippingBackPlane = CTX.ZClippingBackPlane ();
|
||||
|
||||
Standard_Integer OldTexEnvId;
|
||||
Standard_Integer NewTexEnvId;
|
||||
Visual3d_TypeOfSurfaceDetail OldSurfaceDetail;
|
||||
Visual3d_TypeOfSurfaceDetail NewSurfaceDetail;
|
||||
Handle(Graphic3d_TextureEnv) aTexEnvOld = MyContext.TextureEnv();
|
||||
Handle(Graphic3d_TextureEnv) aTexEnvNew = CTX.TextureEnv();
|
||||
|
||||
Handle(Graphic3d_TextureEnv) TempTextureEnv1 = MyContext.TextureEnv();
|
||||
if (! TempTextureEnv1.IsNull()) OldTexEnvId = TempTextureEnv1->TextureId();
|
||||
else OldTexEnvId = -1;
|
||||
|
||||
Handle(Graphic3d_TextureEnv) TempTextureEnv2 = CTX.TextureEnv();
|
||||
|
||||
if (! TempTextureEnv2.IsNull()) NewTexEnvId = TempTextureEnv2->TextureId();
|
||||
else NewTexEnvId = -1;
|
||||
|
||||
OldSurfaceDetail = MyContext.SurfaceDetail();
|
||||
NewSurfaceDetail = CTX.SurfaceDetail();
|
||||
Visual3d_TypeOfSurfaceDetail OldSurfaceDetail = MyContext.SurfaceDetail();
|
||||
Visual3d_TypeOfSurfaceDetail NewSurfaceDetail = CTX.SurfaceDetail();
|
||||
|
||||
MyContext = CTX;
|
||||
|
||||
@ -1580,14 +1555,15 @@ Standard_Boolean AWait = Standard_False; // => immediate update
|
||||
}
|
||||
|
||||
// management of textures
|
||||
if ( (OldTexEnvId != NewTexEnvId) ||
|
||||
(OldSurfaceDetail != NewSurfaceDetail) )
|
||||
if ((aTexEnvOld != aTexEnvNew) || (OldSurfaceDetail != NewSurfaceDetail))
|
||||
{
|
||||
MyGraphicDriver->Environment(MyCView);
|
||||
}
|
||||
|
||||
// Update of planes of model clipping
|
||||
UpdatePlanes ();
|
||||
|
||||
// Update of light sources
|
||||
// Update of light sources
|
||||
UpdateLights ();
|
||||
}
|
||||
|
||||
@ -1610,7 +1586,7 @@ Graphic3d_SequenceOfStructure FooSequence;
|
||||
|
||||
while (S1Iterator.More ()) {
|
||||
Answer = AcceptDisplay (S1Iterator.Key ());
|
||||
// If the structure can't be displayed in the
|
||||
// If the structure can't be displayed in the
|
||||
// new context of the view, it is removed.
|
||||
if ((Answer == Visual3d_TOA_NO) ||
|
||||
(Answer == Visual3d_TOA_COMPUTE))
|
||||
@ -1629,10 +1605,10 @@ Standard_Integer Length = FooSequence.Length ();
|
||||
|
||||
/*
|
||||
* Change of context =>
|
||||
* Display structures that can be displayed
|
||||
* Display structures that can be displayed
|
||||
* with the new visualisation mode.
|
||||
* All structures with status Displayed are removed from the ViewManager
|
||||
* and displayed in the view directly, if the structure is not already
|
||||
* All structures with status Displayed are removed from the ViewManager
|
||||
* and displayed in the view directly, if the structure is not already
|
||||
* displayed and if the view accepts it in its context.
|
||||
*/
|
||||
|
||||
@ -1645,7 +1621,7 @@ Standard_Integer Length = FooSequence.Length ();
|
||||
Handle(Graphic3d_Structure) SG = it.Key();
|
||||
if (! IsDisplayed (SG)) {
|
||||
Answer = AcceptDisplay(SG);
|
||||
// If the structure can be displayed in the
|
||||
// If the structure can be displayed in the
|
||||
// new context of the view, it is displayed.
|
||||
if ((Answer == Visual3d_TOA_YES) ||
|
||||
(Answer == Visual3d_TOA_COMPUTE))
|
||||
@ -1708,8 +1684,8 @@ void Visual3d_View::Activate () {
|
||||
* Activation of a new view =>
|
||||
* Display structures that can be displayed in this new view.
|
||||
* All structures with status
|
||||
* Displayed in ViewManager are returned and displayed in
|
||||
* the view directly, if the structure is not already
|
||||
* Displayed in ViewManager are returned and displayed in
|
||||
* the view directly, if the structure is not already
|
||||
* displayed and if the view accepts it in its context.
|
||||
*/
|
||||
|
||||
@ -1777,8 +1753,8 @@ void Visual3d_View::Deactivate () {
|
||||
* Deactivation of a view =>
|
||||
* Removal of structures displayed in this view.
|
||||
* All structures with status
|
||||
* Displayed in ViewManager are returned and removed from
|
||||
* the view directly, if the structure is not already
|
||||
* Displayed in ViewManager are returned and removed from
|
||||
* the view directly, if the structure is not already
|
||||
* displayed and if the view accepts it in its context.
|
||||
*/
|
||||
|
||||
@ -2118,7 +2094,7 @@ void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, cons
|
||||
if (! IsActive ()) return;
|
||||
|
||||
// If Display on a structure present in the list
|
||||
// of calculated structures while it is not
|
||||
// of calculated structures while it is not
|
||||
// or more, of calculated type =>
|
||||
// - removes it as well as the associated old computed
|
||||
// THis happens when hlhsr becomes again of type e
|
||||
@ -2263,7 +2239,7 @@ Standard_Integer OldStructId =
|
||||
|
||||
// Cas COMPUTED invalid, WITHOUT a valid of replacement
|
||||
else {
|
||||
// COMPUTED is removed if displayed
|
||||
// COMPUTED is removed if displayed
|
||||
if (IsDisplayed (AStructure))
|
||||
MyGraphicDriver->EraseStructure (
|
||||
MyCView,
|
||||
@ -2374,7 +2350,7 @@ Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
|
||||
cout << flush;
|
||||
#endif
|
||||
|
||||
// It is displayed only if the calculated structure
|
||||
// It is displayed only if the calculated structure
|
||||
// has a proper type corresponding to the one of the view.
|
||||
if (Answer != Visual3d_TOA_NO) {
|
||||
if (! IsDisplayed (AStructure))
|
||||
@ -2403,7 +2379,7 @@ Standard_Integer StructId;
|
||||
|
||||
if (IsDeleted ()) return;
|
||||
|
||||
// No test on window as the structure is displayed only if
|
||||
// No test on window as the structure is displayed only if
|
||||
// the window exists, so only one test is enough.
|
||||
if (IsDisplayed (AStructure)) {
|
||||
Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
|
||||
@ -2602,7 +2578,7 @@ Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
|
||||
Result =
|
||||
(((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
|
||||
|
||||
// Iterator.Next () is located on the
|
||||
// Iterator.Next () is located on the
|
||||
// next structure
|
||||
Iterator.Next ();
|
||||
}
|
||||
@ -2687,7 +2663,7 @@ void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard
|
||||
if ( ZM != RealLast() && ZM > ZMax )
|
||||
ZMax = ZM ;
|
||||
}
|
||||
// Only non-empty and non-infinite structures
|
||||
// Only non-empty and non-infinite structures
|
||||
// are taken into account for calculation of MinMax
|
||||
if (! (Iterator.Key ())->IsInfinite () &&
|
||||
! (Iterator.Key ())->IsEmpty ()) {
|
||||
@ -3053,9 +3029,7 @@ void Visual3d_View::UpdateView () {
|
||||
MyCView.Context.Model = int (MyContext.Model ());
|
||||
MyCView.Context.Visualization = int (MyContext.Visualization ());
|
||||
|
||||
Handle(Graphic3d_TextureEnv) TempTextureEnv = MyContext.TextureEnv();
|
||||
if (! TempTextureEnv.IsNull()) MyCView.Context.TexEnvId = TempTextureEnv->TextureId();
|
||||
else MyCView.Context.TexEnvId = -1;
|
||||
MyCView.Context.TextureEnv = MyContext.TextureEnv();
|
||||
MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
|
||||
|
||||
}
|
||||
@ -3093,7 +3067,7 @@ Standard_Integer Length = MyCOMPUTEDSequence.Length ();
|
||||
* previous orientation.
|
||||
* Recalculation of new structures.
|
||||
* Passage of the degenerated mode ON to OFF =>
|
||||
* Remove structures that were calculated before
|
||||
* Remove structures that were calculated before
|
||||
* the degenerated mode passed to ON.
|
||||
* Recalculate new structures.
|
||||
*/
|
||||
@ -3261,7 +3235,7 @@ Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
|
||||
<< "\n" << flush;
|
||||
#endif
|
||||
|
||||
// hlhsr and the new associated compute are removed
|
||||
// hlhsr and the new associated compute are removed
|
||||
|
||||
MyTOCOMPUTESequence.Remove (Index);
|
||||
MyCOMPUTEDSequence.Remove (Index);
|
||||
@ -3343,7 +3317,7 @@ Standard_Integer StructId;
|
||||
while (S1Iterator.More ()) {
|
||||
|
||||
Answer = AcceptDisplay (S1Iterator.Key ());
|
||||
// If the structure was calculated, the previous one is
|
||||
// If the structure was calculated, the previous one is
|
||||
// removed and the new one is displayed
|
||||
// (This is the role of passage into degenerated mode)
|
||||
|
||||
@ -3414,10 +3388,10 @@ Standard_Integer StructId;
|
||||
while (S1Iterator.More ()) {
|
||||
|
||||
Answer = AcceptDisplay (S1Iterator.Key ());
|
||||
// If the structure was calculated, the previous one is
|
||||
// If the structure was calculated, the previous one is
|
||||
// removed and the new one is displayed
|
||||
// (This is the role of passage into degenerated mode)
|
||||
|
||||
|
||||
if (Answer == Visual3d_TOA_COMPUTE) {
|
||||
Standard_Integer Index = IsComputed (S1Iterator.Key ());
|
||||
if (Index != 0) {
|
||||
@ -3452,7 +3426,7 @@ Standard_Integer Index = IsComputed (S1Iterator.Key ());
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Else is impossible
|
||||
// Else is impossible
|
||||
// Degenerated mode was activated before display of the
|
||||
// structure. So the structure was displayed in the
|
||||
// degenerated mode, but the calculated structure didn't exist.
|
||||
@ -3589,7 +3563,7 @@ Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
|
||||
else {
|
||||
Standard_Integer Index = IsComputed (S1Iterator.Key ());
|
||||
// As the mode is not degenerated the displayed structure
|
||||
// is plotted as if it was not calculated, otherwise the
|
||||
// is plotted as if it was not calculated, otherwise the
|
||||
// associated calculated structure is plotted.
|
||||
if (Index == 0)
|
||||
(S1Iterator.Key ())->Plot (APlotter);
|
||||
@ -3608,7 +3582,7 @@ Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structu
|
||||
Standard_Integer Result = 0;
|
||||
Standard_Integer Length = MyTOCOMPUTESequence.Length ();
|
||||
|
||||
// Find in the sequence of already calculated structures
|
||||
// Find in the sequence of already calculated structures
|
||||
// 1/ Structure with the same Owner as <AStructure>
|
||||
// 2/ Which is not <AStructure>
|
||||
// 3/ COMPUTED which of is valid
|
||||
@ -3749,15 +3723,15 @@ Standard_Boolean Visual3d_View::GetGraduatedTrihedron
|
||||
|
||||
/* Names of axes */
|
||||
xname = MyGTrihedron.xname;
|
||||
yname = MyGTrihedron.yname;
|
||||
yname = MyGTrihedron.yname;
|
||||
zname = MyGTrihedron.zname;
|
||||
/* Draw names */
|
||||
xdrawname = MyGTrihedron.xdrawname;
|
||||
ydrawname = MyGTrihedron.ydrawname;
|
||||
xdrawname = MyGTrihedron.xdrawname;
|
||||
ydrawname = MyGTrihedron.ydrawname;
|
||||
zdrawname = MyGTrihedron.zdrawname;
|
||||
/* Draw values */
|
||||
xdrawvalues = MyGTrihedron.xdrawvalues;
|
||||
ydrawvalues = MyGTrihedron.ydrawvalues;
|
||||
xdrawvalues = MyGTrihedron.xdrawvalues;
|
||||
ydrawvalues = MyGTrihedron.ydrawvalues;
|
||||
zdrawvalues = MyGTrihedron.zdrawvalues;
|
||||
/* Draw grid */
|
||||
drawgrid = MyGTrihedron.drawgrid;
|
||||
@ -3965,12 +3939,10 @@ Standard_Integer Visual3d_View::PlaneLimit() const {
|
||||
return maxplane;
|
||||
}
|
||||
|
||||
#ifdef IMP140100
|
||||
Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const {
|
||||
|
||||
return MyPtrViewManager;
|
||||
Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
|
||||
{
|
||||
return MyPtrViewManager;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef G003
|
||||
void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) {
|
||||
@ -4339,7 +4311,7 @@ void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveZLayer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
|
||||
@ -4349,7 +4321,7 @@ void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeZLayer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
|
||||
|
@ -35,7 +35,7 @@
|
||||
24-10-97 : CAL ; Retrait de DownCast.
|
||||
20-11-97 : CAL ; Disparition de la dependance avec math
|
||||
01-12-97 : CAL ; Retrait du test IsActive sur l'Update et le Redraw
|
||||
31-12-97 : CAL ; Disparition de MathGra
|
||||
31-12-97 : CAL ; Disparition de MathGra
|
||||
16-01-98 : CAL ; Ajout du SetTransform sur une TOS_COMPUTED
|
||||
11-03-98 : CAL ; Visual3d_ViewManager::Remove ()
|
||||
20-05-98 : CAL ; Perfs. Connection entre structures COMPUTED.
|
||||
@ -161,7 +161,7 @@ void Visual3d_ViewManager::ChangeDisplayPriority (const Handle(Graphic3d_Structu
|
||||
// Change structure priority in all defined views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->ChangeDisplayPriority
|
||||
(AStructure, OldPriority, NewPriority);
|
||||
@ -172,14 +172,14 @@ void Visual3d_ViewManager::ChangeDisplayPriority (const Handle(Graphic3d_Structu
|
||||
|
||||
}
|
||||
|
||||
void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
|
||||
void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
|
||||
|
||||
//Standard_Integer LengthD = MyDisplayedStructure.Extent() ();
|
||||
|
||||
// Even if physically the structure cannot
|
||||
// be displayed (pb of visualisation type)
|
||||
// it has status Displayed.
|
||||
|
||||
|
||||
if (!MyDisplayedStructure.Contains(AStructure))
|
||||
return;
|
||||
|
||||
@ -187,19 +187,19 @@ void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStruct
|
||||
// Recompute structure in all activated views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->ReCompute (AStructure);
|
||||
|
||||
// MyIterator.Next () is located on the next view
|
||||
MyIterator.Next ();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStructure,
|
||||
const Handle(Graphic3d_DataStructureManager)& AProjector)
|
||||
{
|
||||
void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStructure,
|
||||
const Handle(Graphic3d_DataStructureManager)& AProjector)
|
||||
{
|
||||
|
||||
if (! AProjector->IsKind (STANDARD_TYPE (Visual3d_View))) return;
|
||||
|
||||
@ -215,12 +215,12 @@ void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStruct
|
||||
// it has status Displayed.
|
||||
if (!MyDisplayedStructure.Contains(AStructure))
|
||||
return;
|
||||
|
||||
|
||||
//
|
||||
// Recompute structure in all activated views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
if ((MyIterator.Value ())->Identification () == ViewId)
|
||||
theView->ReCompute (AStructure);
|
||||
@ -234,7 +234,7 @@ void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStruct
|
||||
void Visual3d_ViewManager::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
|
||||
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->Clear (AStructure, WithDestruction);
|
||||
|
||||
@ -247,7 +247,7 @@ void Visual3d_ViewManager::Clear (const Handle(Graphic3d_Structure)& AStructure,
|
||||
void Visual3d_ViewManager::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
|
||||
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->Connect (AMother, ADaughter);
|
||||
|
||||
@ -260,7 +260,7 @@ void Visual3d_ViewManager::Connect (const Handle(Graphic3d_Structure)& AMother,
|
||||
void Visual3d_ViewManager::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
|
||||
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->Disconnect (AMother, ADaughter);
|
||||
|
||||
@ -270,7 +270,7 @@ void Visual3d_ViewManager::Disconnect (const Handle(Graphic3d_Structure)& AMothe
|
||||
|
||||
}
|
||||
|
||||
void Visual3d_ViewManager::Display (const Handle(Graphic3d_Structure)& AStructure) {
|
||||
void Visual3d_ViewManager::Display (const Handle(Graphic3d_Structure)& AStructure) {
|
||||
|
||||
|
||||
// Even if physically the structure cannot
|
||||
@ -283,7 +283,7 @@ void Visual3d_ViewManager::Display (const Handle(Graphic3d_Structure)& AStructur
|
||||
// Display structure in all activated views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->Display (AStructure);
|
||||
|
||||
@ -308,7 +308,7 @@ void Visual3d_ViewManager::Erase (const Handle(Graphic3d_Structure)& AStructure)
|
||||
// Erase structure in all defined views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->Erase (AStructure);
|
||||
|
||||
@ -325,7 +325,7 @@ void Visual3d_ViewManager::Erase (const Handle(Graphic3d_Structure)& AStructure)
|
||||
void Visual3d_ViewManager::Erase () {
|
||||
|
||||
Graphic3d_MapIteratorOfMapOfStructure it( MyDisplayedStructure);
|
||||
|
||||
|
||||
for (; it.More(); it.Next()) {
|
||||
Handle(Graphic3d_Structure) SG = it.Key();
|
||||
SG->Erase();
|
||||
@ -341,7 +341,7 @@ void Visual3d_ViewManager::Highlight (const Handle(Graphic3d_Structure)& AStruct
|
||||
// Highlight in all activated views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->Highlight (AStructure, AMethod);
|
||||
|
||||
@ -354,7 +354,7 @@ void Visual3d_ViewManager::Highlight (const Handle(Graphic3d_Structure)& AStruct
|
||||
void Visual3d_ViewManager::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
|
||||
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->SetTransform (AStructure, ATrsf);
|
||||
|
||||
@ -367,7 +367,7 @@ void Visual3d_ViewManager::SetTransform (const Handle(Graphic3d_Structure)& AStr
|
||||
void Visual3d_ViewManager::UnHighlight () {
|
||||
|
||||
Graphic3d_MapIteratorOfMapOfStructure it(MyHighlightedStructure);
|
||||
|
||||
|
||||
for (; it.More(); it.Next()) {
|
||||
Handle(Graphic3d_Structure) SG = it.Key();
|
||||
SG->UnHighlight ();
|
||||
@ -385,7 +385,7 @@ void Visual3d_ViewManager::UnHighlight (const Handle(Graphic3d_Structure)& AStru
|
||||
// UnHighlight in all activated views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->UnHighlight (AStructure);
|
||||
|
||||
@ -407,7 +407,7 @@ Standard_Integer Dx, Dy;
|
||||
Standard_Integer j = MyDefinedView.Extent ();
|
||||
if (j == 0) return;
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ()) {
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->Window ()->Size (Dx, Dy);
|
||||
@ -422,7 +422,7 @@ Standard_Integer Dx, Dy;
|
||||
if (! MyOverLayer.IsNull ())
|
||||
MyOverLayer->SetViewport (MaxDx, MaxDy);
|
||||
}
|
||||
|
||||
|
||||
if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ())
|
||||
MyIterator.Initialize (MyDefinedView);
|
||||
while (MyIterator.More ()) {
|
||||
@ -442,7 +442,7 @@ void Visual3d_ViewManager::Update () const {
|
||||
Standard_Integer j = MyDefinedView.Extent ();
|
||||
if (j == 0) return;
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
(MyIterator.Value ())->Update (MyUnderLayer, MyOverLayer);
|
||||
|
||||
@ -537,7 +537,7 @@ Standard_Real Dx, Dy, Ratio;
|
||||
|
||||
AVertex.Coord (AX, AY, AZ);
|
||||
|
||||
Result = MyGraphicDriver->ProjectRaster (TheCView,
|
||||
Result = MyGraphicDriver->ProjectRaster (TheCView,
|
||||
Standard_ShortReal (AX), Standard_ShortReal (AY), Standard_ShortReal (AZ),
|
||||
AU, AV);
|
||||
|
||||
@ -985,7 +985,7 @@ const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AspectWindow;
|
||||
// Comparaison on window IDs
|
||||
if (TheWindowIdOfView == TheSpecifiedWindowId) {
|
||||
Exist = Standard_True;
|
||||
TheCView = *(CALL_DEF_VIEW *)(MyIterator.Value ())->CView ();
|
||||
TheCView = *(Graphic3d_CView* )(MyIterator.Value())->CView();
|
||||
}
|
||||
} /* if ((MyIterator.Value ())->IsDefined ()) */
|
||||
|
||||
@ -1003,7 +1003,7 @@ void Visual3d_ViewManager::Activate () {
|
||||
// Activates all deactivated views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
if (! (MyIterator.Value ())->IsActive ())
|
||||
(MyIterator.Value ())->Activate ();
|
||||
@ -1020,7 +1020,7 @@ void Visual3d_ViewManager::Deactivate () {
|
||||
// Deactivates all activated views
|
||||
//
|
||||
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
|
||||
|
||||
|
||||
while (MyIterator.More ()) {
|
||||
if ((MyIterator.Value ())->IsActive ())
|
||||
(MyIterator.Value ())->Deactivate ();
|
||||
@ -1047,7 +1047,7 @@ Handle(Graphic3d_Structure) Visual3d_ViewManager::Identification (const Standard
|
||||
}
|
||||
|
||||
Standard_Integer Visual3d_ViewManager::Identification () const {
|
||||
|
||||
|
||||
return (Graphic3d_StructureManager::Identification ());
|
||||
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ void Visual3d_ViewManager::SetZBufferAuto (const Standard_Boolean AFlag) {
|
||||
if (! MyZBufferAuto && ! AFlag) return;
|
||||
|
||||
// if pass from False to True :
|
||||
// no problem, at the next view update, it
|
||||
// no problem, at the next view update, it
|
||||
// will properly ask questions to answer (SetVisualisation)
|
||||
// if pass from True to False :
|
||||
// it is necessary to modify ZBufferActivity at each view so that
|
||||
@ -1158,7 +1158,7 @@ const Handle(Visual3d_Layer)& Visual3d_ViewManager::OverLayer () const {
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeZLayer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Visual3d_ViewManager::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
|
||||
@ -1166,7 +1166,7 @@ void Visual3d_ViewManager::ChangeZLayer (const Handle(Graphic3d_Structure)& theS
|
||||
{
|
||||
if (!myLayerIds.Contains (theLayerId))
|
||||
return;
|
||||
|
||||
|
||||
// change display layer for structure in all views
|
||||
if (MyDisplayedStructure.Contains (theStructure))
|
||||
{
|
||||
@ -1174,7 +1174,7 @@ void Visual3d_ViewManager::ChangeZLayer (const Handle(Graphic3d_Structure)& theS
|
||||
for ( ; aViewIt.More (); aViewIt.Next ())
|
||||
(aViewIt.Value ())->ChangeZLayer (theStructure, theLayerId);
|
||||
}
|
||||
|
||||
|
||||
// tell graphic driver to update the structure's display layer
|
||||
MyGraphicDriver->ChangeZLayer (
|
||||
(*(Graphic3d_CStructure*)theStructure->CStructure ()), theLayerId);
|
||||
@ -1223,7 +1223,7 @@ Standard_Boolean Visual3d_ViewManager::AddZLayer (Standard_Integer& theLayerId)
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveZLayer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Visual3d_ViewManager::RemoveZLayer (const Standard_Integer theLayerId)
|
||||
@ -1282,7 +1282,7 @@ void Visual3d_ViewManager::InstallZLayers(const Handle(Visual3d_View)& theView)
|
||||
{
|
||||
if (!MyDefinedView.Contains (theView))
|
||||
return;
|
||||
|
||||
|
||||
// erase and insert layers iteratively to provide the same layer order as
|
||||
// in the view manager's sequence. This approach bases on the layer insertion
|
||||
// order: the new layers are always appended to the end of the list
|
||||
|
Loading…
x
Reference in New Issue
Block a user