1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0029074: Visualization, TKOpenGl - support Geometry Shader definition

Graphic3d_TypeOfShaderObject enumeration has been extended by Geometry shader object type.
OpenGl_ShaderProgram::Initialize() processes new shader object types when supported by OpenGL version.
Declarations.glsl has been fixed so that occFragColor is defined only for
Fragment Shader object only (by handling new FRAGMENT_SHADER macros).

Improved documentation of Graphic3d_ArrayOfPrimitives class.

vshader Draw Harness command has been extended to support definition
of Shader Object types other than Vertex and Fragment shader.
This commit is contained in:
kgv 2017-09-01 17:45:49 +03:00 committed by bugmaster
parent 3ed88facdb
commit 8e0a2b19ab
60 changed files with 1190 additions and 1210 deletions

View File

@ -1,22 +1,13 @@
Graphic3d_ArrayOfPoints.cxx
Graphic3d_ArrayOfPoints.hxx
Graphic3d_ArrayOfPolygons.cxx
Graphic3d_ArrayOfPolygons.hxx
Graphic3d_ArrayOfPolylines.cxx
Graphic3d_ArrayOfPolylines.hxx
Graphic3d_ArrayOfPrimitives.cxx
Graphic3d_ArrayOfPrimitives.hxx
Graphic3d_ArrayOfQuadrangles.cxx
Graphic3d_ArrayOfQuadrangles.hxx
Graphic3d_ArrayOfQuadrangleStrips.cxx
Graphic3d_ArrayOfQuadrangleStrips.hxx
Graphic3d_ArrayOfSegments.cxx
Graphic3d_ArrayOfSegments.hxx
Graphic3d_ArrayOfTriangleFans.cxx
Graphic3d_ArrayOfTriangleFans.hxx
Graphic3d_ArrayOfTriangles.cxx
Graphic3d_ArrayOfTriangles.hxx
Graphic3d_ArrayOfTriangleStrips.cxx
Graphic3d_ArrayOfTriangleStrips.hxx
Graphic3d_AspectFillArea3d.cxx
Graphic3d_AspectFillArea3d.hxx

View File

@ -1,25 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfPoints,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfPoints::Graphic3d_ArrayOfPoints (const Standard_Integer theMaxVertexs,
const Standard_Boolean theHasVColors,
const Standard_Boolean theHasVNormals)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POINTS, theMaxVertexs, 0, 0, theHasVNormals, theHasVColors, Standard_False, Standard_False)
{}

View File

@ -15,52 +15,25 @@
#ifndef _Graphic3d_ArrayOfPoints_HeaderFile
#define _Graphic3d_ArrayOfPoints_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Graphic3d_ArrayOfPoints;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfPoints, Graphic3d_ArrayOfPrimitives)
//! Contains points array definition
//! Contains points array definition.
class Graphic3d_ArrayOfPoints : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfPoints, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of points,
//! a single pixel point is drawn at each vertex.
//! Creates an array of points, a single pixel point is drawn at each vertex.
//! The array must be filled using the AddVertex(Point) method.
//! When <hasVColors> is TRUE , you must use only AddVertex(Point,Color) method.
//! When <hasVNormals> is TRUE , you must use only AddVertex(Point,Normal) method.
Standard_EXPORT Graphic3d_ArrayOfPoints(const Standard_Integer maxVertexs, const Standard_Boolean hasVColors = Standard_False, const Standard_Boolean hasVNormals = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfPoints,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! @param theHasVColors when TRUE, AddVertex(Point,Color) should be used for specifying vertex color
//! @param theHasVNormals when TRUE, AddVertex(Point,Normal) should be used for specifying vertex normal
Graphic3d_ArrayOfPoints (const Standard_Integer theMaxVertexs,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasVNormals = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POINTS, theMaxVertexs, 0, 0, theHasVNormals, theHasVColors, Standard_False, Standard_False) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfPoints, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfPoints_HeaderFile

View File

@ -1,29 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfPolygons.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfPolygons,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfPolygons::Graphic3d_ArrayOfPolygons (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxBounds,
const Standard_Integer theMaxEdges,
const Standard_Boolean theHasVNormals,
const Standard_Boolean theHasVColors,
const Standard_Boolean theHasFColors,
const Standard_Boolean theHasVTexels)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYGONS, theMaxVertexs, theMaxBounds, theMaxEdges, theHasVNormals, theHasVColors, theHasFColors, theHasVTexels)
{}

View File

@ -15,130 +15,91 @@
#ifndef _Graphic3d_ArrayOfPolygons_HeaderFile
#define _Graphic3d_ArrayOfPolygons_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Graphic3d_ArrayOfPolygons;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfPolygons, Graphic3d_ArrayOfPrimitives)
//! Contains polygons array definition
//! Contains polygons array definition.
//! WARNING! Polygon primitives might be unsupported by graphics library.
//! Triangulation should be used instead of quads for better compatibility.
class Graphic3d_ArrayOfPolygons : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfPolygons, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of polygons,
//! a polygon can be filled as:
//! 1) creating a single polygon defined with his vertexs.
//! i.e:
//! myArray = Graphic3d_ArrayOfPolygons(7)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x7,y7,z7)
//! 2) creating separate polygons defined with a predefined
//! number of bounds and the number of vertex per bound.
//! i.e:
//! myArray = Graphic3d_ArrayOfPolygons(7,2)
//! myArray->AddBound(4)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddBound(3)
//! myArray->AddVertex(x5,y5,z5)
//! ....
//! myArray->AddVertex(x7,y7,z7)
//! 3) creating a single indexed polygon defined with his vertex
//! ans edges.
//! i.e:
//! myArray = Graphic3d_ArrayOfPolygons(4,0,6)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(4)
//! 4) creating separate polygons defined with a predefined
//! number of bounds and the number of edges per bound.
//! i.e:
//! myArray = Graphic3d_ArrayOfPolygons(6,4,14)
//! myArray->AddBound(3)
//! myArray->AddVertex(x1,y1,z1)
//! myArray->AddVertex(x2,y2,z2)
//! myArray->AddVertex(x3,y3,z3)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddBound(3)
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddVertex(x5,y5,z5)
//! myArray->AddVertex(x6,y6,z6)
//! myArray->AddEdge(4)
//! myArray->AddEdge(5)
//! myArray->AddEdge(6)
//! myArray->AddBound(4)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddEdge(5)
//! myArray->AddEdge(6)
//! myArray->AddBound(4)
//! myArray->AddEdge(1)
//! myArray->AddEdge(3)
//! myArray->AddEdge(5)
//! myArray->AddEdge(4)
//! <maxVertexs> defined the maximun allowed vertex number in the array.
//! <maxBounds> defined the maximun allowed bound number in the array.
//! <maxEdges> defined the maximun allowed edge number in the array.
//! Warning:
//! When <hasVNormals> is TRUE , you must use one of
//! AddVertex(Point,Normal)
//! or AddVertex(Point,Normal,Color)
//! or AddVertex(Point,Normal,Texel) methods.
//! When <hasVColors> is TRUE , you must use one of
//! AddVertex(Point,Color)
//! or AddVertex(Point,Normal,Color) methods.
//! When <hasTexels> is TRUE , you must use one of
//! AddVertex(Point,Texel)
//! or AddVertex(Point,Normal,Texel) methods.
//! When <hasBColors> is TRUE , <maxBounds> must be > 0 and
//! you must use the
//! AddBound(number,Color) method.
//! Warning:
//! the user is responsible about the orientation of the polygon
//! depending of the order of the created vertex or edges and this
//! orientation must be coherent with the vertex normal optionnaly
//! given at each vertex (See the Orientate() methods).
Standard_EXPORT Graphic3d_ArrayOfPolygons(const Standard_Integer maxVertexs, const Standard_Integer maxBounds = 0, const Standard_Integer maxEdges = 0, const Standard_Boolean hasVNormals = Standard_False, const Standard_Boolean hasVColors = Standard_False, const Standard_Boolean hasBColors = Standard_False, const Standard_Boolean hasTexels = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfPolygons,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! Creates an array of polygons, a polygon can be filled as:
//! 1) Creating a single polygon defined with his vertexes, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfPolygons (7);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x7, y7, z7);
//! @endcode
//! 2) Creating separate polygons defined with a predefined number of bounds and the number of vertex per bound, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfPolygons (7, 2);
//! myArray->AddBound (4);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddBound (3);
//! myArray->AddVertex (x5, y5, z5);
//! ....
//! myArray->AddVertex (x7, y7, z7);
//! @endcode
//! 3) Creating a single indexed polygon defined with his vertex ans edges, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfPolygons (4, 0, 6);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (4);
//! @endcode
//! 4) Creating separate polygons defined with a predefined number of bounds and the number of edges per bound, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfPolygons (6, 4, 14);
//! myArray->AddBound (3);
//! myArray->AddVertex (x1, y1, z1);
//! myArray->AddVertex (x2, y2, z2);
//! myArray->AddVertex (x3, y3, z3);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddBound (3);
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddVertex (x5, y5, z5);
//! myArray->AddVertex (x6, y6, z6);
//! myArray->AddEdge (4);
//! myArray->AddEdge (5);
//! myArray->AddEdge (6);
//! myArray->AddBound (4);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddEdge (5);
//! myArray->AddEdge (6);
//! myArray->AddBound (4);
//! myArray->AddEdge (1);
//! myArray->AddEdge (3);
//! myArray->AddEdge (5);
//! myArray->AddEdge (4);
//! @endcode
//! @param theMaxVertexs defines the maximum allowed vertex number in the array
//! @param theMaxBounds defines the maximum allowed bound number in the array
//! @param theMaxEdges defines the maximum allowed edge number in the array
Graphic3d_ArrayOfPolygons (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxBounds = 0,
const Standard_Integer theMaxEdges = 0,
const Standard_Boolean theHasVNormals = Standard_False,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasBColors = Standard_False,
const Standard_Boolean theHasVTexels = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYGONS, theMaxVertexs, theMaxBounds, theMaxEdges, theHasVNormals, theHasVColors, theHasBColors, theHasVTexels) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfPolygons, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfPolygons_HeaderFile

View File

@ -1,27 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfPolylines,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfPolylines::Graphic3d_ArrayOfPolylines (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxBounds,
const Standard_Integer theMaxEdges,
const Standard_Boolean theHasVColors,
const Standard_Boolean theHasFColors)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYLINES, theMaxVertexs, theMaxBounds, theMaxEdges, Standard_False, theHasVColors, theHasFColors, Standard_False)
{}

View File

@ -15,119 +15,89 @@
#ifndef _Graphic3d_ArrayOfPolylines_HeaderFile
#define _Graphic3d_ArrayOfPolylines_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Graphic3d_ArrayOfPolylines;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfPolylines, Graphic3d_ArrayOfPrimitives)
//! Contains polylines array definition
//! Contains polylines array definition.
class Graphic3d_ArrayOfPolylines : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfPolylines, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of polylines,
//! a polyline can be filled as:
//! 1) creating a single polyline defined with his vertexs.
//! i.e:
//! myArray = Graphic3d_ArrayOfPolylines(7)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x7,y7,z7)
//! 2) creating separate polylines defined with a predefined
//! number of bounds and the number of vertex per bound.
//! i.e:
//! myArray = Graphic3d_ArrayOfPolylines(7,2)
//! myArray->AddBound(4)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddBound(3)
//! myArray->AddVertex(x5,y5,z5)
//! ....
//! myArray->AddVertex(x7,y7,z7)
//! 3) creating a single indexed polyline defined with his vertex
//! ans edges.
//! i.e:
//! myArray = Graphic3d_ArrayOfPolylines(4,0,6)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(4)
//! 4) creating separate polylines defined with a predefined
//! number of bounds and the number of edges per bound.
//! i.e:
//! myArray = Graphic3d_ArrayOfPolylines(6,4,14)
//! myArray->AddBound(3)
//! myArray->AddVertex(x1,y1,z1)
//! myArray->AddVertex(x2,y2,z2)
//! myArray->AddVertex(x3,y3,z3)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddBound(3)
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddVertex(x5,y5,z5)
//! myArray->AddVertex(x6,y6,z6)
//! myArray->AddEdge(4)
//! myArray->AddEdge(5)
//! myArray->AddEdge(6)
//! myArray->AddBound(4)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddEdge(5)
//! myArray->AddEdge(6)
//! myArray->AddBound(4)
//! myArray->AddEdge(1)
//! myArray->AddEdge(3)
//! myArray->AddEdge(5)
//! myArray->AddEdge(4)
//!
//! <maxVertexs> defined the maximun allowed vertex number in the array.
//! <maxBounds> defined the maximun allowed bound number in the array.
//! <maxEdges> defined the maximun allowed edge number in the array.
//! Warning:
//! When <hasVColors> is TRUE , you must use one of
//! AddVertex(Point,Color)
//! or AddVertex(Point,Normal,Color) methods.
//! When <hasBColors> is TRUE , <maxBounds> must be > 0 and
//! you must use the
//! AddBound(number,Color) method.
Standard_EXPORT Graphic3d_ArrayOfPolylines(const Standard_Integer maxVertexs, const Standard_Integer maxBounds = 0, const Standard_Integer maxEdges = 0, const Standard_Boolean hasVColors = Standard_False, const Standard_Boolean hasBColors = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfPolylines,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! Creates an array of polylines, a polyline can be filled as:
//! 1) Creating a single polyline defined with his vertexes, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfPolylines (7);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x7, y7, z7);
//! @endcode
//! 2) Creating separate polylines defined with a predefined number of bounds and the number of vertex per bound, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfPolylines (7, 2);
//! myArray->AddBound (4);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddBound (3);
//! myArray->AddVertex (x5, y5, z5);
//! ....
//! myArray->AddVertex (x7, y7, z7);
//! @endcode
//! 3) Creating a single indexed polyline defined with his vertex and edges, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfPolylines (4, 0, 6);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (4);
//! @endcode
//! 4) creating separate polylines defined with a predefined number of bounds and the number of edges per bound, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfPolylines (6, 4, 14);
//! myArray->AddBound (3);
//! myArray->AddVertex (x1, y1, z1);
//! myArray->AddVertex (x2, y2, z2);
//! myArray->AddVertex (x3, y3, z3);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddBound (3);
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddVertex (x5, y5, z5);
//! myArray->AddVertex (x6, y6, z6);
//! myArray->AddEdge (4);
//! myArray->AddEdge (5);
//! myArray->AddEdge (6);
//! myArray->AddBound (4);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddEdge (5);
//! myArray->AddEdge (6);
//! myArray->AddBound (4);
//! myArray->AddEdge (1);
//! myArray->AddEdge (3);
//! myArray->AddEdge (5);
//! myArray->AddEdge (4);
//! @endcode
//! @param theMaxVertexs defines the maximum allowed vertex number in the array
//! @param theMaxBounds defines the maximum allowed bound number in the array
//! @param theMaxEdges defines the maximum allowed edge number in the array
//! @param theHasVColors when TRUE AddVertex(Point,Color) or AddVertex(Point,Normal,Color) should be used to specify per-vertex color values
//! @param theHasBColors when TRUE AddBound(number,Color) should be used to specify sub-group color
Graphic3d_ArrayOfPolylines (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxBounds = 0,
const Standard_Integer theMaxEdges = 0,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasBColors = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYLINES, theMaxVertexs, theMaxBounds, theMaxEdges, Standard_False, theHasVColors, theHasBColors, Standard_False) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfPolylines, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfPolylines_HeaderFile

View File

@ -14,6 +14,16 @@
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_ArrayOfTriangleStrips.hxx>
#include <Graphic3d_ArrayOfTriangleFans.hxx>
#include <Graphic3d_ArrayOfQuadrangles.hxx>
#include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
#include <Graphic3d_ArrayOfPolygons.hxx>
#include <NCollection_AlignedAllocator.hxx>
#include <TCollection_AsciiString.hxx>
@ -22,6 +32,16 @@
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfPrimitives, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfPoints, Graphic3d_ArrayOfPrimitives)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfSegments, Graphic3d_ArrayOfPrimitives)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfPolylines, Graphic3d_ArrayOfPrimitives)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangles, Graphic3d_ArrayOfPrimitives)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangleStrips, Graphic3d_ArrayOfPrimitives)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangleFans, Graphic3d_ArrayOfPrimitives)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfQuadrangles, Graphic3d_ArrayOfPrimitives)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfQuadrangleStrips, Graphic3d_ArrayOfPrimitives)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfPolygons, Graphic3d_ArrayOfPrimitives)
// =======================================================================
// function : Graphic3d_ArrayOfPrimitives
// purpose :
@ -246,14 +266,18 @@ Standard_CString Graphic3d_ArrayOfPrimitives::StringType() const
switch (myType)
{
case Graphic3d_TOPA_POINTS: return "ArrayOfPoints";
case Graphic3d_TOPA_POLYLINES: return "ArrayOfPolylines";
case Graphic3d_TOPA_SEGMENTS: return "ArrayOfSegments";
case Graphic3d_TOPA_POLYGONS: return "ArrayOfPolygons";
case Graphic3d_TOPA_POLYLINES: return "ArrayOfPolylines";
case Graphic3d_TOPA_TRIANGLES: return "ArrayOfTriangles";
case Graphic3d_TOPA_QUADRANGLES: return "ArrayOfQuadrangles";
case Graphic3d_TOPA_TRIANGLESTRIPS: return "ArrayOfTriangleStrips";
case Graphic3d_TOPA_QUADRANGLESTRIPS: return "ArrayOfQuadrangleStrips";
case Graphic3d_TOPA_TRIANGLEFANS: return "ArrayOfTriangleFans";
case Graphic3d_TOPA_LINES_ADJACENCY: return "ArrayOfLinesAdjacency";
case Graphic3d_TOPA_LINE_STRIP_ADJACENCY: return "ArrayOfLineStripAdjacency";
case Graphic3d_TOPA_TRIANGLES_ADJACENCY: return "ArrayOfTrianglesAdjacency";
case Graphic3d_TOPA_TRIANGLE_STRIP_ADJACENCY: return "ArrayOfTriangleStripAdjacency";
case Graphic3d_TOPA_QUADRANGLES: return "ArrayOfQuadrangles";
case Graphic3d_TOPA_QUADRANGLESTRIPS: return "ArrayOfQuadrangleStrips";
case Graphic3d_TOPA_POLYGONS: return "ArrayOfPolygons";
case Graphic3d_TOPA_UNDEFINED: return "UndefinedArray";
}
return "UndefinedArray";
@ -293,6 +317,18 @@ Standard_Integer Graphic3d_ArrayOfPrimitives::ItemNumber() const
case Graphic3d_TOPA_TRIANGLEFANS: return !myBounds.IsNull()
? myAttribs->NbElements - 2 * myBounds->NbBounds
: myAttribs->NbElements - 2;
case Graphic3d_TOPA_LINES_ADJACENCY: return myIndices.IsNull() || myIndices->NbElements < 1
? myAttribs->NbElements / 4
: myIndices->NbElements / 4;
case Graphic3d_TOPA_LINE_STRIP_ADJACENCY: return !myBounds.IsNull()
? myAttribs->NbElements - 4 * myBounds->NbBounds
: myAttribs->NbElements - 4;
case Graphic3d_TOPA_TRIANGLES_ADJACENCY: return myIndices.IsNull() || myIndices->NbElements < 1
? myAttribs->NbElements / 6
: myIndices->NbElements / 6;
case Graphic3d_TOPA_TRIANGLE_STRIP_ADJACENCY: return !myBounds.IsNull()
? myAttribs->NbElements - 4 * myBounds->NbBounds
: myAttribs->NbElements - 4;
case Graphic3d_TOPA_UNDEFINED: return -1;
}
return -1;
@ -407,6 +443,20 @@ Standard_Boolean Graphic3d_ArrayOfPrimitives::IsValid()
return Standard_False;
}
break;
case Graphic3d_TOPA_LINES_ADJACENCY:
case Graphic3d_TOPA_LINE_STRIP_ADJACENCY:
if (nvertexs < 4)
{
return Standard_False;
}
break;
case Graphic3d_TOPA_TRIANGLES_ADJACENCY:
case Graphic3d_TOPA_TRIANGLE_STRIP_ADJACENCY:
if (nvertexs < 6)
{
return Standard_False;
}
break;
case Graphic3d_TOPA_UNDEFINED:
default:
return Standard_False;

View File

@ -24,28 +24,41 @@
#include <Standard_OutOfRange.hxx>
#include <Quantity_Color.hxx>
class Quantity_Color;
class Graphic3d_ArrayOfPrimitives;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfPrimitives, Standard_Transient)
//! This class furnish services to defined and fill an
//! array of primitives compatible with the use of
//! the OPENGl glDrawArrays() or glDrawElements() functions.
//! NOTE that the main goal of this kind of primitive
//! is to avoid multiple copies of datas between
//! each layer of the software.
//! So the array datas exist only one time and the use
//! of SetXxxxxx() methods enable to change dynamically
//! the aspect of this primitive.
//! This class furnish services to defined and fill an array of primitives
//! which can be passed directly to graphics rendering API.
//!
//! Advantages are :
//! 1) Decrease strongly the loading time.
//! 2) Decrease strongly the display time using optimized Opengl
//! primitives.
//! 3) Enable to change dynamically the components of the primitive
//! (vertice,normal,color,texture coordinates).
//! 4) Add true triangle and quadrangle strips or fans capabilities.
//! The basic interface consists of the following parts:
//! 1) Specifying primitive type.
//! WARNING! Particular primitive types might be unsupported by specific hardware/graphics API (like quads and polygons).
//! It is always preferred using one of basic types having maximum compatibility:
//! Point, Triangle (or Triangle strip), Segment aka Lines (or Polyline aka Line Strip).
//! Primitive strip types can be used to reduce memory usage as alternative to Indexed arrays.
//! 2) Vertex array.
//! - Specifying the (maximum) number of vertexes within array.
//! - Specifying the vertex attributes, complementary to mandatory vertex Position (normal, color, UV texture coordinates).
//! - Defining vertex values by using various versions of AddVertex() or SetVertex*() methods.
//! 3) Index array (optional).
//! - Specifying the (maximum) number of indexes (edges).
//! - Defining index values by using AddEdge() method; the index value should be within number of defined Vertexes.
//!
//! Indexed array allows sharing vertex data across Primitives and thus reducing memory usage,
//! since index size is much smaller then size of vertex with all its attributes.
//! It is a preferred way for defining primitive array and main alternative to Primitive Strips for optimal memory usage,
//! although it is also possible (but unusual) defining Indexed Primitive Strip.
//! Note that it is NOT possible sharing Vertex Attributes partially (e.g. share Position, but have different Normals);
//! in such cases Vertex should be entirely duplicated with all Attributes.
//! 4) Bounds array (optional).
//! - Specifying the (maximum) number of bounds.
//! - Defining bounds using AddBound() methods.
//!
//! Bounds allow splitting Primitive Array into sub-groups.
//! This is useful only in two cases - for specifying per-group color and for restarting Primitive Strips.
//! WARNING! Bounds within Primitive Array break rendering batches into parts (additional for loops),
//! affecting rendering performance negatively (increasing CPU load).
class Graphic3d_ArrayOfPrimitives : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfPrimitives, Standard_Transient)

View File

@ -1,28 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfQuadrangleStrips,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfQuadrangleStrips::Graphic3d_ArrayOfQuadrangleStrips (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxStrips,
const Standard_Boolean theHasVNormals,
const Standard_Boolean theHasVColors,
const Standard_Boolean theHasSColors,
const Standard_Boolean theHasVTexels)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLESTRIPS, theMaxVertexs, theMaxStrips, 0, theHasVNormals, theHasVColors, theHasSColors, theHasVTexels)
{}

View File

@ -15,72 +15,49 @@
#ifndef _Graphic3d_ArrayOfQuadrangleStrips_HeaderFile
#define _Graphic3d_ArrayOfQuadrangleStrips_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Graphic3d_ArrayOfQuadrangleStrips;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfQuadrangleStrips, Graphic3d_ArrayOfPrimitives)
//! Contains quadrangles strip array definition
//! Contains quadrangles strip array definition.
//! WARNING! Quadrangle primitives might be unsupported by graphics library.
//! Triangulation should be used instead of quads for better compatibility.
class Graphic3d_ArrayOfQuadrangleStrips : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfQuadrangleStrips, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of quadrangle strips,
//! a polygon can be filled as:
//! 1) creating a single strip defined with his vertexs.
//! i.e:
//! myArray = Graphic3d_ArrayOfQuadrangleStrips(7)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x7,y7,z7)
//! 2) creating separate strips defined with a predefined
//! number of strips and the number of vertex per strip.
//! i.e:
//! myArray = Graphic3d_ArrayOfQuadrangleStrips(8,2)
//! myArray->AddBound(4)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddBound(4)
//! myArray->AddVertex(x5,y5,z5)
//! ....
//! myArray->AddVertex(x8,y8,z8)
//!
//! <maxVertexs> defined the maximun allowed vertex number in the array.
//! <maxStrips> defined the maximun allowed strip number in the array.
//! The number of quadrangle really drawn is :
//! VertexNumber()/2-Min(1,BoundNumber())
Standard_EXPORT Graphic3d_ArrayOfQuadrangleStrips(const Standard_Integer maxVertexs, const Standard_Integer maxStrips = 0, const Standard_Boolean hasVNormals = Standard_False, const Standard_Boolean hasVColors = Standard_False, const Standard_Boolean hasSColors = Standard_False, const Standard_Boolean hasTexels = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfQuadrangleStrips,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! Creates an array of quadrangle strips, a polygon can be filled as:
//! 1) Creating a single strip defined with his vertexes, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfQuadrangleStrips (7);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x7, y7, z7);
//! @endcode
//! 2) Creating separate strips defined with a predefined number of strips and the number of vertex per strip, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfQuadrangleStrips (8, 2);
//! myArray->AddBound (4);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddBound (4);
//! myArray->AddVertex (x5, y5, z5);
//! ....
//! myArray->AddVertex (x8, y8, z8);
//! @endcode
//! @param theMaxVertexs defines the maximum allowed vertex number in the array
//! @param theMaxStrips defines the maximum allowed strip number in the array
//! The number of quadrangle really drawn is: VertexNumber()/2 - Min(1, BoundNumber()).
Graphic3d_ArrayOfQuadrangleStrips (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxStrips = 0,
const Standard_Boolean theHasVNormals = Standard_False,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasSColors = Standard_False,
const Standard_Boolean theHasVTexels = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLESTRIPS, theMaxVertexs, theMaxStrips, 0, theHasVNormals, theHasVColors, theHasSColors, theHasVTexels) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfQuadrangleStrips, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfQuadrangleStrips_HeaderFile

View File

@ -1,28 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfQuadrangles.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfQuadrangles,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfQuadrangles::Graphic3d_ArrayOfQuadrangles (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxEdges,
const Standard_Boolean theHasVNormals,
const Standard_Boolean theHasVColors,
const Standard_Boolean theHasVTexels)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLES, theMaxVertexs, 0, theMaxEdges, theHasVNormals, theHasVColors, Standard_False, theHasVTexels)
{}

View File

@ -15,90 +15,50 @@
#ifndef _Graphic3d_ArrayOfQuadrangles_HeaderFile
#define _Graphic3d_ArrayOfQuadrangles_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Standard_OutOfRange;
class Graphic3d_ArrayOfQuadrangles;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfQuadrangles, Graphic3d_ArrayOfPrimitives)
//! Contains quatrangles array definition
//! Contains quadrangles array definition.
//! WARNING! Quadrangle primitives might be unsupported by graphics library.
//! Triangulation should be used instead of quads for better compatibility.
class Graphic3d_ArrayOfQuadrangles : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfQuadrangles, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of quadrangles,
//! a quadrangle can be filled as:
//! 1) creating a set of quadrangles defined with his vertexs.
//! i.e:
//! myArray = Graphic3d_ArrayOfQuadrangles(8)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x8,y8,z8)
//! 3) creating a set of indexed quadrangles defined with his vertex
//! ans edges.
//! i.e:
//! myArray = Graphic3d_ArrayOfQuadrangles(6,8)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x6,y6,z6)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddEdge(4)
//! myArray->AddEdge(3)
//! myArray->AddEdge(4)
//! myArray->AddEdge(5)
//! myArray->AddEdge(6)
//!
//! <maxVertexs> defined the maximun allowed vertex number in the array.
//! <maxEdges> defined the maximun allowed edge number in the array.
//! Warning:
//! When <hasVNormals> is TRUE , you must use one of
//! AddVertex(Point,Normal)
//! or AddVertex(Point,Normal,Color)
//! or AddVertex(Point,Normal,Texel) methods.
//! When <hasVColors> is TRUE , you must use one of
//! AddVertex(Point,Color)
//! or AddVertex(Point,Normal,Color) methods.
//! When <hasTexels> is TRUE , you must use one of
//! AddVertex(Point,Texel)
//! or AddVertex(Point,Normal,Texel) methods.
//! Warning:
//! the user is responsible about the orientation of the quadrangle
//! depending of the order of the created vertex or edges and this
//! orientation must be coherent with the vertex normal optionnaly
//! given at each vertex (See the Orientate() methods).
Standard_EXPORT Graphic3d_ArrayOfQuadrangles(const Standard_Integer maxVertexs, const Standard_Integer maxEdges = 0, const Standard_Boolean hasVNormals = Standard_False, const Standard_Boolean hasVColors = Standard_False, const Standard_Boolean hasTexels = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfQuadrangles,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! Creates an array of quadrangles, a quadrangle can be filled as:
//! 1) Creating a set of quadrangles defined with his vertexes, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfQuadrangles (8);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x8, y8, z8);
//! @endcode
//! 2) Creating a set of indexed quadrangles defined with his vertex ans edges, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfQuadrangles (6, 8);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x6, y6, z6);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddEdge (4);
//! myArray->AddEdge (3);
//! myArray->AddEdge (4);
//! myArray->AddEdge (5);
//! myArray->AddEdge (6);
//! @endcode
//! @param theMaxVertexs defines the maximum allowed vertex number in the array
//! @param theMaxEdges defines the maximum allowed edge number in the array (for indexed array)
Graphic3d_ArrayOfQuadrangles (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxEdges = 0,
const Standard_Boolean theHasVNormals = Standard_False,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasVTexels = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLES, theMaxVertexs, 0, theMaxEdges, theHasVNormals, theHasVColors, Standard_False, theHasVTexels) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfQuadrangles, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfQuadrangles_HeaderFile

View File

@ -1,25 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfSegments,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfSegments::Graphic3d_ArrayOfSegments (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxEdges,
const Standard_Boolean theHasVColors)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_SEGMENTS, theMaxVertexs, 0, theMaxEdges, Standard_False, theHasVColors, Standard_False, Standard_False)
{}

View File

@ -15,76 +15,47 @@
#ifndef _Graphic3d_ArrayOfSegments_HeaderFile
#define _Graphic3d_ArrayOfSegments_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Graphic3d_ArrayOfSegments;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfSegments, Graphic3d_ArrayOfPrimitives)
//! Contains segments array definition
//! Contains segments array definition.
class Graphic3d_ArrayOfSegments : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfSegments, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of segments,
//! a segment can be filled as:
//! 1) creating a set of segments defined with his vertexs.
//! i.e:
//! myArray = Graphic3d_ArrayOfSegments(4)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! 2) creating a set of indexed segments defined with his vertex
//! ans edges.
//! i.e:
//! myArray = Graphic3d_ArrayOfSegments(4,0,8)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddEdge(4)
//! myArray->AddEdge(2)
//! myArray->AddEdge(4)
//! myArray->AddEdge(1)
//! myArray->AddEdge(3)
//!
//! <maxVertexs> defined the maximun allowed vertex number in the array.
//! <maxEdges> defined the maximun allowed edge number in the array.
//! Warning:
//! When <hasVColors> is TRUE , you must use only
//! AddVertex(Point,Color) method
Standard_EXPORT Graphic3d_ArrayOfSegments(const Standard_Integer maxVertexs, const Standard_Integer maxEdges = 0, const Standard_Boolean hasVColors = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfSegments,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! Creates an array of segments, a segment can be filled as:
//! 1) Creating a set of segments defined with his vertexes, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfSegments (4);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! @endcode
//! 2) Creating a set of indexed segments defined with his vertex and edges, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfSegments (4, 0, 8);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddEdge (4);
//! myArray->AddEdge (2);
//! myArray->AddEdge (4);
//! myArray->AddEdge (1);
//! myArray->AddEdge (3);
//! @endcode
//! @param theMaxVertexs defines the maximum allowed vertex number in the array
//! @param theMaxEdges defines the maximum allowed edge number in the array
//! @param theHasVColors when TRUE, AddVertex(Point,Color) should be used for specifying vertex color
Graphic3d_ArrayOfSegments (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxEdges = 0,
const Standard_Boolean theHasVColors = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_SEGMENTS, theMaxVertexs, 0, theMaxEdges, Standard_False, theHasVColors, Standard_False, Standard_False) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfSegments, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfSegments_HeaderFile

View File

@ -1,28 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfTriangleFans.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangleFans,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfTriangleFans::Graphic3d_ArrayOfTriangleFans (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxFans,
const Standard_Boolean theHasVNormals,
const Standard_Boolean theHasVColors,
const Standard_Boolean theHasFColors,
const Standard_Boolean theHasVTexels)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLEFANS, theMaxVertexs, theMaxFans, 0, theHasVNormals, theHasVColors, theHasFColors, theHasVTexels)
{}

View File

@ -15,72 +15,47 @@
#ifndef _Graphic3d_ArrayOfTriangleFans_HeaderFile
#define _Graphic3d_ArrayOfTriangleFans_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Graphic3d_ArrayOfTriangleFans;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfTriangleFans, Graphic3d_ArrayOfPrimitives)
//! Contains triangles fan array definition
class Graphic3d_ArrayOfTriangleFans : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangleFans, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of triangle fans,
//! a polygon can be filled as:
//! 1) creating a single fan defined with his vertexs.
//! i.e:
//! myArray = Graphic3d_ArrayOfTriangleFans(7)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x7,y7,z7)
//! 2) creating separate fans defined with a predefined
//! number of fans and the number of vertex per fan.
//! i.e:
//! myArray = Graphic3d_ArrayOfTriangleFans(8,2)
//! myArray->AddBound(4)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddBound(4)
//! myArray->AddVertex(x5,y5,z5)
//! ....
//! myArray->AddVertex(x8,y8,z8)
//!
//! <maxVertexs> defined the maximun allowed vertex number in the array.
//! <maxFans> defined the maximun allowed fan number in the array.
//! The number of triangle really drawn is :
//! VertexNumber()-2*Min(1,BoundNumber())
Standard_EXPORT Graphic3d_ArrayOfTriangleFans(const Standard_Integer maxVertexs, const Standard_Integer maxFans = 0, const Standard_Boolean hasVNormals = Standard_False, const Standard_Boolean hasVColors = Standard_False, const Standard_Boolean hasFColors = Standard_False, const Standard_Boolean hasTexels = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangleFans,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! Creates an array of triangle fans, a polygon can be filled as:
//! 1) Creating a single fan defined with his vertexes, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfTriangleFans (7);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x7, y7, z7);
//! @endcode
//! 2) creating separate fans defined with a predefined number of fans and the number of vertex per fan, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfTriangleFans (8, 2);
//! myArray->AddBound (4);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddBound (4);
//! myArray->AddVertex (x5, y5, z5);
//! ....
//! myArray->AddVertex (x8, y8, z8);
//! @endcode
//! @param theMaxVertexs defines the maximum allowed vertex number in the array
//! @param theMaxFans defines the maximum allowed fan number in the array
//! The number of triangle really drawn is: VertexNumber() - 2 * Min(1, BoundNumber())
Graphic3d_ArrayOfTriangleFans (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxFans = 0,
const Standard_Boolean theHasVNormals = Standard_False,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasBColors = Standard_False,
const Standard_Boolean theHasVTexels = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLEFANS, theMaxVertexs, theMaxFans, 0, theHasVNormals, theHasVColors, theHasBColors, theHasVTexels) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfTriangleFans, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfTriangleFans_HeaderFile

View File

@ -1,28 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfTriangleStrips.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangleStrips,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfTriangleStrips::Graphic3d_ArrayOfTriangleStrips (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxStrips,
const Standard_Boolean theHasVNormals,
const Standard_Boolean theHasVColors,
const Standard_Boolean theHasSColors,
const Standard_Boolean theHasVTexels)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLESTRIPS, theMaxVertexs, theMaxStrips, 0, theHasVNormals, theHasVColors, theHasSColors, theHasVTexels)
{}

View File

@ -15,91 +15,52 @@
#ifndef _Graphic3d_ArrayOfTriangleStrips_HeaderFile
#define _Graphic3d_ArrayOfTriangleStrips_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Graphic3d_ArrayOfTriangleStrips;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfTriangleStrips, Graphic3d_ArrayOfPrimitives)
//! Contains triangles strip array definition
//! Contains triangles strip array definition.
class Graphic3d_ArrayOfTriangleStrips : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangleStrips, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of triangle strips,
//! a polygon can be filled as:
//! 1) creating a single strip defined with his vertexs.
//! i.e:
//! myArray = Graphic3d_ArrayOfTriangleStrips(7)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x7,y7,z7)
//! 2) creating separate strips defined with a predefined
//! number of strips and the number of vertex per strip.
//! i.e:
//! myArray = Graphic3d_ArrayOfTriangleStrips(8,2)
//! myArray->AddBound(4)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddBound(4)
//! myArray->AddVertex(x5,y5,z5)
//! ....
//! myArray->AddVertex(x8,y8,z8)
//!
//! <maxVertexs> defined the maximun allowed vertex number in the array.
//! <maxStrips> defined the maximun allowed strip number in the array.
//! The number of triangle really drawn is :
//! VertexNumber()-2*Min(1,BoundNumber())
//! Warning:
//! When <hasVNormals> is TRUE , you must use one of
//! AddVertex(Point,Normal)
//! or AddVertex(Point,Normal,Color)
//! or AddVertex(Point,Normal,Texel) methods.
//! When <hasVColors> is TRUE , you must use one of
//! AddVertex(Point,Color)
//! or AddVertex(Point,Normal,Color) methods.
//! When <hasTexels> is TRUE , you must use one of
//! AddVertex(Point,Texel)
//! or AddVertex(Point,Normal,Texel) methods.
//! When <hasBColors> is TRUE , <maxBounds> must be > 0 and
//! you must use the
//! AddBound(number,Color) method.
//! Warning:
//! the user is responsible about the orientation of the strip
//! depending of the order of the created vertex and this
//! orientation must be coherent with the vertex normal optionnaly
//! given at each vertex (See the Orientate() methods).
Standard_EXPORT Graphic3d_ArrayOfTriangleStrips(const Standard_Integer maxVertexs, const Standard_Integer maxStrips = 0, const Standard_Boolean hasVNormals = Standard_False, const Standard_Boolean hasVColors = Standard_False, const Standard_Boolean hasSColors = Standard_False, const Standard_Boolean hasTexels = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangleStrips,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! Creates an array of triangle strips, a polygon can be filled as:
//! 1) Creating a single strip defined with his vertexes, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfTriangleStrips (7);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x7, y7, z7);
//! @endcode
//! 2) Creating separate strips defined with a predefined number of strips and the number of vertex per strip, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfTriangleStrips (8, 2);
//! myArray->AddBound (4);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddBound (4);
//! myArray->AddVertex (x5, y5, z5);
//! ....
//! myArray->AddVertex (x8, y8, z8);
//! @endcode
//! @param theMaxVertexs defines the maximum allowed vertex number in the array
//! @param theMaxStrips defines the maximum allowed strip number in the array;
//! the number of triangle really drawn is: VertexNumber() - 2 * Min(1, BoundNumber())
//! @param theHasVNormals when TRUE, AddVertex(Point,Normal), AddVertex(Point,Normal,Color) or AddVertex(Point,Normal,Texel) should be used to specify vertex normal;
//! vertex normals should be specified coherent to triangle orientation (defined by order of vertexes within triangle) for proper rendering
//! @param theHasVColors when TRUE, AddVertex(Point,Color) or AddVertex(Point,Normal,Color) should be used to specify vertex color
//! @param theHasBColors when TRUE, AddBound(number,Color) should be used to specify sub-group color
//! @param theHasVTexels when TRUE, AddVertex(Point,Texel) or AddVertex(Point,Normal,Texel) should be used to specify vertex UV coordinates
Graphic3d_ArrayOfTriangleStrips (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxStrips = 0,
const Standard_Boolean theHasVNormals = Standard_False,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasBColors = Standard_False,
const Standard_Boolean theHasVTexels = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLESTRIPS, theMaxVertexs, theMaxStrips, 0, theHasVNormals, theHasVColors, theHasBColors, theHasVTexels) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfTriangleStrips, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfTriangleStrips_HeaderFile

View File

@ -1,27 +0,0 @@
// Created on: 2001-01-04
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangles,Graphic3d_ArrayOfPrimitives)
Graphic3d_ArrayOfTriangles::Graphic3d_ArrayOfTriangles (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxEdges,
const Standard_Boolean theHasVNormals,
const Standard_Boolean theHasVColors,
const Standard_Boolean theHasVTexels)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLES, theMaxVertexs, 0, theMaxEdges, theHasVNormals, theHasVColors, Standard_False, theHasVTexels)
{}

View File

@ -15,87 +15,50 @@
#ifndef _Graphic3d_ArrayOfTriangles_HeaderFile
#define _Graphic3d_ArrayOfTriangles_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Graphic3d_ArrayOfTriangles;
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfTriangles, Graphic3d_ArrayOfPrimitives)
//! Contains triangles array definition
class Graphic3d_ArrayOfTriangles : public Graphic3d_ArrayOfPrimitives
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangles, Graphic3d_ArrayOfPrimitives)
public:
//! Creates an array of triangles,
//! a triangle can be filled as:
//! 1) creating a set of triangles defined with his vertexs.
//! i.e:
//! myArray = Graphic3d_ArrayOfTriangles(6)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x6,y6,z6)
//! 3) creating a set of indexed triangles defined with his vertex
//! ans edges.
//! i.e:
//! myArray = Graphic3d_ArrayOfTriangles(4,6)
//! myArray->AddVertex(x1,y1,z1)
//! ....
//! myArray->AddVertex(x4,y4,z4)
//! myArray->AddEdge(1)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddEdge(2)
//! myArray->AddEdge(3)
//! myArray->AddEdge(4)
//!
//! <maxVertexs> defined the maximun allowed vertex number in the array.
//! <maxEdges> defined the maximun allowed edge number in the array.
//! Warning:
//! When <hasVNormals> is TRUE , you must use one of
//! AddVertex(Point,Normal)
//! or AddVertex(Point,Normal,Color)
//! or AddVertex(Point,Normal,Texel) methods.
//! When <hasVColors> is TRUE , you must use one of
//! AddVertex(Point,Color)
//! or AddVertex(Point,Normal,Color) methods.
//! When <hasTexels> is TRUE , you must use one of
//! AddVertex(Point,Texel)
//! or AddVertex(Point,Normal,Texel) methods.
//! Warning:
//! the user is responsible about the orientation of the triangle
//! depending of the order of the created vertex or edges and this
//! orientation must be coherent with the vertex normal optionnaly
//! given at each vertex (See the Orientate() methods).
Standard_EXPORT Graphic3d_ArrayOfTriangles(const Standard_Integer maxVertexs, const Standard_Integer maxEdges = 0, const Standard_Boolean hasVNormals = Standard_False, const Standard_Boolean hasVColors = Standard_False, const Standard_Boolean hasTexels = Standard_False);
DEFINE_STANDARD_RTTIEXT(Graphic3d_ArrayOfTriangles,Graphic3d_ArrayOfPrimitives)
protected:
private:
//! Creates an array of triangles, a triangle can be filled as:
//! 1) Creating a set of triangles defined with his vertexes, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfTriangles (6);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x6, y6, z6);
//! @endcode
//! 3) Creating a set of indexed triangles defined with his vertex and edges, i.e:
//! @code
//! myArray = Graphic3d_ArrayOfTriangles (4, 6);
//! myArray->AddVertex (x1, y1, z1);
//! ....
//! myArray->AddVertex (x4, y4, z4);
//! myArray->AddEdge (1);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddEdge (2);
//! myArray->AddEdge (3);
//! myArray->AddEdge (4);
//! @endcode
//! @param theMaxVertexs defines the maximum allowed vertex number in the array
//! @param theMaxEdges defines the maximum allowed edge number in the array
//! @param theHasVNormals when TRUE, AddVertex(Point,Normal), AddVertex(Point,Normal,Color) or AddVertex(Point,Normal,Texel) should be used to specify vertex normal;
//! vertex normals should be specified coherent to triangle orientation (defined by order of vertexes within triangle) for proper rendering
//! @param theHasVColors when TRUE, AddVertex(Point,Color) or AddVertex(Point,Normal,Color) should be used to specify vertex color
//! @param theHasVTexels when TRUE, AddVertex(Point,Texel) or AddVertex(Point,Normal,Texel) should be used to specify vertex UV coordinates
Graphic3d_ArrayOfTriangles (const Standard_Integer theMaxVertexs,
const Standard_Integer theMaxEdges = 0,
const Standard_Boolean theHasVNormals = Standard_False,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasVTexels = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLES, theMaxVertexs, 0, theMaxEdges, theHasVNormals, theHasVColors, Standard_False, theHasVTexels) {}
};
DEFINE_STANDARD_HANDLE(Graphic3d_ArrayOfTriangles, Graphic3d_ArrayOfPrimitives)
#endif // _Graphic3d_ArrayOfTriangles_HeaderFile

View File

@ -20,16 +20,29 @@
//! The type of primitive array in a group in a structure.
enum Graphic3d_TypeOfPrimitiveArray
{
Graphic3d_TOPA_UNDEFINED,
Graphic3d_TOPA_POINTS,
Graphic3d_TOPA_POLYLINES,
Graphic3d_TOPA_SEGMENTS,
Graphic3d_TOPA_POLYGONS,
Graphic3d_TOPA_TRIANGLES,
Graphic3d_TOPA_QUADRANGLES,
Graphic3d_TOPA_TRIANGLESTRIPS,
Graphic3d_TOPA_QUADRANGLESTRIPS,
Graphic3d_TOPA_TRIANGLEFANS
Graphic3d_TOPA_UNDEFINED, //!< undefined primitive type
// main rendering types
Graphic3d_TOPA_POINTS, //!< individual points
Graphic3d_TOPA_SEGMENTS, //!< segments array - each 2 vertexes define 1 segment
Graphic3d_TOPA_POLYLINES, //!< line strip - each new vertex in array defines segment with previous one
Graphic3d_TOPA_TRIANGLES, //!< triangle array - each 3 vertexes define 1 triangle
Graphic3d_TOPA_TRIANGLESTRIPS, //!< triangle strip - each new vertex in array defines triangle with 2 previous vertexes
Graphic3d_TOPA_TRIANGLEFANS, //!< triangle fan - each new vertex in array define triangle with the previous vertex and the very first vertex (fan center)
// rendering type with auxiliary adjacent info (can be accessed only within Geometry shader)
Graphic3d_TOPA_LINES_ADJACENCY, //!< ADVANCED - same as Graphic3d_TOPA_SEGMENTS, but each pair of vertexes defining 1 segment
//! is preceded by 1 extra vertex and followed by 1 extra vertex which are not actually rendered
Graphic3d_TOPA_LINE_STRIP_ADJACENCY, //!< ADVANCED - same as Graphic3d_TOPA_POLYLINES, but each sequence of vertexes defining 1 polyline
//! is preceded by 1 extra vertex and followed by 1 extra vertex which are not actually rendered
Graphic3d_TOPA_TRIANGLES_ADJACENCY, //!< ADVANCED - same as Graphic3d_TOPA_TRIANGLES, but each vertex defining of triangle
//! is followed by 1 extra adjacent vertex which is not actually rendered
Graphic3d_TOPA_TRIANGLE_STRIP_ADJACENCY, //!< ADVANCED - same as Graphic3d_TOPA_TRIANGLESTRIPS, but with extra adjacent vertexes
// deprecated types, unsupported by mobile hardware
Graphic3d_TOPA_QUADRANGLES, //!< DEPRECATED - triangle array should be used instead;
//! array of quads - each 4 vertexes define single quad
Graphic3d_TOPA_QUADRANGLESTRIPS, //!< DEPRECATED - triangle array should be used instead;
//! quad strip - each 2 new vertexes define a quad shared 2 more vertexes of previous quad
Graphic3d_TOPA_POLYGONS //!< DEPRECATED - triangle array should be used instead;
//! array defines a polygon
};
#endif // _Graphic3d_TypeOfPrimitiveArray_HeaderFile

View File

@ -16,11 +16,17 @@
#ifndef _Graphic3d_TypeOfShaderObject_HeaderFile
#define _Graphic3d_TypeOfShaderObject_HeaderFile
//! Type of the shader object (may be extended).
//! Type of the shader object.
enum Graphic3d_TypeOfShaderObject
{
Graphic3d_TOS_VERTEX,
Graphic3d_TOS_FRAGMENT
// rendering shaders
Graphic3d_TOS_VERTEX = 0x01, //!< vertex shader object, mandatory
Graphic3d_TOS_TESS_CONTROL = 0x02, //!< tessellation control shader object, optional
Graphic3d_TOS_TESS_EVALUATION = 0x04, //!< tessellation evaluation shader object, optional
Graphic3d_TOS_GEOMETRY = 0x08, //!< geometry shader object, optional
Graphic3d_TOS_FRAGMENT = 0x10, //!< fragment shader object, mandatory
// general-purpose compute shader
Graphic3d_TOS_COMPUTE = 0x20 //!< compute shader object, should be used as alternative to shader object types for rendering
};
#endif

View File

@ -230,6 +230,5 @@ Standard_Boolean OpenGl_CappingAlgoFilter::ShouldRender (const Handle(OpenGl_Wor
const OpenGl_PrimitiveArray* aPArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theGlElement);
return aPArray != NULL
&& aPArray->DrawMode() >= OpenGl_PrimitiveArray::THE_FILLPRIM_FROM
&& aPArray->DrawMode() <= OpenGl_PrimitiveArray::THE_FILLPRIM_TO;
&& aPArray->IsFillDrawMode();
}

View File

@ -198,6 +198,19 @@
// OpenGL ES 3.0+ or OES_texture_half_float
#define GL_HALF_FLOAT 0x140B
#define GL_HALF_FLOAT_OES 0x8D61
// OpenGL ES 3.1+
#define GL_COMPUTE_SHADER 0x91B9
// OpenGL ES 3.2+
#define GL_GEOMETRY_SHADER 0x8DD9
#define GL_TESS_CONTROL_SHADER 0x8E88
#define GL_TESS_EVALUATION_SHADER 0x8E87
#define GL_LINES_ADJACENCY 0x000A
#define GL_LINE_STRIP_ADJACENCY 0x000B
#define GL_TRIANGLES_ADJACENCY 0x000C
#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
#define GL_PATCHES 0x000E
#endif
#if !defined(HAVE_EGL) && (defined(__ANDROID__) || defined(__QNX__) || defined(HAVE_GLES2) || defined(OCCT_UWP))

View File

@ -665,8 +665,7 @@ Standard_Boolean OpenGl_LayerList::OpenGl_OpaqueFilter::ShouldRender (const Hand
const OpenGl_PrimitiveArray* aPArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theGlElement);
if (aPArray == NULL
|| aPArray->DrawMode() < OpenGl_PrimitiveArray::THE_FILLPRIM_FROM
|| aPArray->DrawMode() > OpenGl_PrimitiveArray::THE_FILLPRIM_TO)
|| !aPArray->IsFillDrawMode())
{
return Standard_True;
}
@ -697,8 +696,7 @@ Standard_Boolean OpenGl_LayerList::OpenGl_TransparentFilter::ShouldRender (const
const OpenGl_PrimitiveArray* aPArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theGlElement);
if (aPArray == NULL
|| aPArray->DrawMode() < OpenGl_PrimitiveArray::THE_FILLPRIM_FROM
|| aPArray->DrawMode() > OpenGl_PrimitiveArray::THE_FILLPRIM_TO)
|| !aPArray->IsFillDrawMode())
{
return dynamic_cast<const OpenGl_AspectFace*> (theGlElement) != NULL;
}

View File

@ -373,8 +373,12 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
return;
}
const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
const bool toHilight = theWorkspace->ToHighlight();
const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
const bool toHilight = theWorkspace->ToHighlight();
const GLenum aDrawMode = !aGlContext->ActiveProgram().IsNull()
&& aGlContext->ActiveProgram()->HasTessellationStage()
? GL_PATCHES
: myDrawMode;
myVboAttribs->BindAllAttributes (aGlContext);
if (theHasVertColor && toHilight)
{
@ -393,14 +397,14 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
{
const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter];
if (theFaceColors != NULL) aGlContext->SetColor4fv (theFaceColors[aGroupIter]);
glDrawElements (myDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset);
glDrawElements (aDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset);
anOffset += aStride * aNbElemsInGroup;
}
}
else
{
// draw one (or sequential) primitive by the indices
glDrawElements (myDrawMode, myVboIndices->GetElemsNb(), myVboIndices->GetDataType(), anOffset);
glDrawElements (aDrawMode, myVboIndices->GetElemsNb(), myVboIndices->GetDataType(), anOffset);
}
myVboIndices->Unbind (aGlContext);
}
@ -411,7 +415,7 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
{
const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter];
if (theFaceColors != NULL) aGlContext->SetColor4fv (theFaceColors[aGroupIter]);
glDrawArrays (myDrawMode, aFirstElem, aNbElemsInGroup);
glDrawArrays (aDrawMode, aFirstElem, aNbElemsInGroup);
aFirstElem += aNbElemsInGroup;
}
}
@ -423,7 +427,7 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
}
else
{
glDrawArrays (myDrawMode, 0, myVboAttribs->GetElemsNb());
glDrawArrays (aDrawMode, 0, myVboAttribs->GetElemsNb());
}
}
@ -466,6 +470,10 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
Standard_False,
anAspect->ShaderProgramRes (aGlContext));
}
const GLenum aDrawMode = !aGlContext->ActiveProgram().IsNull()
&& aGlContext->ActiveProgram()->HasTessellationStage()
? GL_PATCHES
: myDrawMode;
/// OCC22236 NOTE: draw edges for all situations:
/// 1) draw elements with GL_LINE style as edges from myPArray->bufferVBO[VBOEdges] indices array
@ -489,14 +497,14 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
for (Standard_Integer aGroupIter = 0; aGroupIter < myBounds->NbBounds; ++aGroupIter)
{
const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter];
glDrawElements (myDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset);
glDrawElements (aDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset);
anOffset += aStride * aNbElemsInGroup;
}
}
// draw one (or sequential) primitive by the indices
else
{
glDrawElements (myDrawMode, myVboIndices->GetElemsNb(), myVboIndices->GetDataType(), anOffset);
glDrawElements (aDrawMode, myVboIndices->GetElemsNb(), myVboIndices->GetDataType(), anOffset);
}
myVboIndices->Unbind (aGlContext);
}
@ -506,13 +514,13 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
for (Standard_Integer aGroupIter = 0; aGroupIter < myBounds->NbBounds; ++aGroupIter)
{
const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter];
glDrawArrays (myDrawMode, aFirstElem, aNbElemsInGroup);
glDrawArrays (aDrawMode, aFirstElem, aNbElemsInGroup);
aFirstElem += aNbElemsInGroup;
}
}
else
{
glDrawArrays (myDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements);
glDrawArrays (aDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements);
}
// unbind buffers
@ -528,8 +536,13 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
// =======================================================================
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const OpenGl_AspectMarker* anAspectMarker = theWorkspace->ApplyAspectMarker();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const OpenGl_AspectMarker* anAspectMarker = theWorkspace->ApplyAspectMarker();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
&& aCtx->ActiveProgram()->HasTessellationStage()
? GL_PATCHES
: myDrawMode;
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectMarker->SpriteRes (aCtx);
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
if (aSpriteNorm != NULL
@ -549,7 +562,7 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
aCtx->core11fwd->glEnable (GL_BLEND);
aCtx->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
aCtx->core11fwd->glDrawArrays (myDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements);
aCtx->core11fwd->glDrawArrays (aDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements);
aCtx->core11fwd->glDisable (GL_BLEND);
#if !defined(GL_ES_VERSION_2_0)
@ -564,7 +577,7 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
else if (anAspectMarker->Aspect()->Type() == Aspect_TOM_POINT)
{
aCtx->SetPointSize (anAspectMarker->MarkerSize());
aCtx->core11fwd->glDrawArrays (myDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements);
aCtx->core11fwd->glDrawArrays (aDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements);
aCtx->SetPointSize (1.0f);
}
#if !defined(GL_ES_VERSION_2_0)
@ -600,6 +613,7 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
OpenGl_PrimitiveArray::OpenGl_PrimitiveArray (const OpenGl_GraphicDriver* theDriver)
: myDrawMode (DRAW_MODE_NONE),
myIsFillType(Standard_False),
myIsVboInit (Standard_False)
{
if (theDriver != NULL)
@ -622,6 +636,7 @@ OpenGl_PrimitiveArray::OpenGl_PrimitiveArray (const OpenGl_GraphicDriver*
myAttribs (theAttribs),
myBounds (theBounds),
myDrawMode (DRAW_MODE_NONE),
myIsFillType(Standard_False),
myIsVboInit (Standard_False)
{
if (!myIndices.IsNull()
@ -876,45 +891,75 @@ void OpenGl_PrimitiveArray::setDrawMode (const Graphic3d_TypeOfPrimitiveArray th
if (myAttribs.IsNull())
{
myDrawMode = DRAW_MODE_NONE;
myIsFillType = false;
return;
}
switch (theType)
{
case Graphic3d_TOPA_POINTS:
myDrawMode = GL_POINTS;
break;
case Graphic3d_TOPA_POLYLINES:
myDrawMode = GL_LINE_STRIP;
myDrawMode = GL_POINTS;
myIsFillType = false;
break;
case Graphic3d_TOPA_SEGMENTS:
myDrawMode = GL_LINES;
myDrawMode = GL_LINES;
myIsFillType = false;
break;
case Graphic3d_TOPA_POLYLINES:
myDrawMode = GL_LINE_STRIP;
myIsFillType = false;
break;
case Graphic3d_TOPA_TRIANGLES:
myDrawMode = GL_TRIANGLES;
myDrawMode = GL_TRIANGLES;
myIsFillType = true;
break;
case Graphic3d_TOPA_TRIANGLESTRIPS:
myDrawMode = GL_TRIANGLE_STRIP;
myDrawMode = GL_TRIANGLE_STRIP;
myIsFillType = true;
break;
case Graphic3d_TOPA_TRIANGLEFANS:
myDrawMode = GL_TRIANGLE_FAN;
myDrawMode = GL_TRIANGLE_FAN;
myIsFillType = true;
break;
//
case Graphic3d_TOPA_LINES_ADJACENCY:
myDrawMode = GL_LINES_ADJACENCY;
myIsFillType = false;
break;
case Graphic3d_TOPA_LINE_STRIP_ADJACENCY:
myDrawMode = GL_LINE_STRIP_ADJACENCY;
myIsFillType = false;
break;
case Graphic3d_TOPA_TRIANGLES_ADJACENCY:
myDrawMode = GL_TRIANGLES_ADJACENCY;
myIsFillType = true;
break;
case Graphic3d_TOPA_TRIANGLE_STRIP_ADJACENCY:
myDrawMode = GL_TRIANGLE_STRIP_ADJACENCY;
myIsFillType = true;
break;
//
#if !defined(GL_ES_VERSION_2_0)
case Graphic3d_TOPA_POLYGONS:
myDrawMode = GL_POLYGON;
break;
case Graphic3d_TOPA_QUADRANGLES:
myDrawMode = GL_QUADS;
myDrawMode = GL_QUADS;
myIsFillType = true;
break;
case Graphic3d_TOPA_QUADRANGLESTRIPS:
myDrawMode = GL_QUAD_STRIP;
myDrawMode = GL_QUAD_STRIP;
myIsFillType = true;
break;
case Graphic3d_TOPA_POLYGONS:
myDrawMode = GL_POLYGON;
myIsFillType = true;
break;
#else
case Graphic3d_TOPA_POLYGONS:
case Graphic3d_TOPA_QUADRANGLES:
case Graphic3d_TOPA_QUADRANGLESTRIPS:
case Graphic3d_TOPA_POLYGONS:
#endif
case Graphic3d_TOPA_UNDEFINED:
myDrawMode = DRAW_MODE_NONE;
myIsFillType = false;
break;
}
}

View File

@ -32,22 +32,13 @@ class OpenGl_GraphicDriver;
class OpenGl_PrimitiveArray : public OpenGl_Element
{
public:
// OpenGL does not provide a constant for "none" draw mode.
// So we define our own one that does not conflict with GL constants
// and utilizes common GL invalid value
//! OpenGL does not provide a constant for "none" draw mode.
//! So we define our own one that does not conflict with GL constants and utilizes common GL invalid value.
enum
{
DRAW_MODE_NONE = -1
};
#if !defined(GL_ES_VERSION_2_0)
static const GLint THE_FILLPRIM_FROM = GL_TRIANGLES;
static const GLint THE_FILLPRIM_TO = GL_POLYGON;
#else
static const GLint THE_FILLPRIM_FROM = GL_TRIANGLES;
static const GLint THE_FILLPRIM_TO = GL_TRIANGLE_FAN;
#endif
//! Empty constructor
Standard_EXPORT OpenGl_PrimitiveArray (const OpenGl_GraphicDriver* theDriver);
@ -78,6 +69,9 @@ public:
//! @return primitive type (GL_LINES, GL_TRIANGLES and others)
GLint DrawMode() const { return myDrawMode; }
//! Return TRUE if primitive type generates shaded triangulation.
Standard_Boolean IsFillDrawMode() const { return myIsFillType; }
//! @return indices array
const Handle(Graphic3d_IndexBuffer)& Indices() const { return myIndices; }
@ -139,7 +133,8 @@ protected:
mutable Handle(Graphic3d_IndexBuffer) myIndices;
mutable Handle(Graphic3d_Buffer) myAttribs;
mutable Handle(Graphic3d_BoundBuffer) myBounds;
GLint myDrawMode;
GLshort myDrawMode;
mutable Standard_Boolean myIsFillType;
mutable Standard_Boolean myIsVboInit;
Standard_Size myUID; //!< Unique ID of primitive array.

View File

@ -76,6 +76,24 @@ Standard_CString OpenGl_ShaderProgram::PredefinedKeywords[] =
"occPointSize" // OpenGl_OCCT_POINT_SIZE
};
namespace
{
//! Convert Graphic3d_TypeOfShaderObject enumeration into OpenGL enumeration.
static GLenum shaderTypeToGl (Graphic3d_TypeOfShaderObject theType)
{
switch (theType)
{
case Graphic3d_TOS_VERTEX: return GL_VERTEX_SHADER;
case Graphic3d_TOS_FRAGMENT: return GL_FRAGMENT_SHADER;
case Graphic3d_TOS_GEOMETRY: return GL_GEOMETRY_SHADER;
case Graphic3d_TOS_TESS_CONTROL: return GL_TESS_CONTROL_SHADER;
case Graphic3d_TOS_TESS_EVALUATION: return GL_TESS_EVALUATION_SHADER;
case Graphic3d_TOS_COMPUTE: return GL_COMPUTE_SHADER;
}
return 0;
}
}
// =======================================================================
// function : OpenGl_VariableSetterSelector
// purpose : Creates new variable setter selector
@ -130,7 +148,8 @@ OpenGl_ShaderProgram::OpenGl_ShaderProgram (const Handle(Graphic3d_ShaderProgram
: OpenGl_NamedResource (!theProxy.IsNull() ? theProxy->GetId() : ""),
myProgramID (NO_PROGRAM),
myProxy (theProxy),
myShareCount(1)
myShareCount(1),
myHasTessShader (false)
{
memset (myCurrentState, 0, sizeof (myCurrentState));
for (GLint aVar = 0; aVar < OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES; ++aVar)
@ -146,66 +165,113 @@ OpenGl_ShaderProgram::OpenGl_ShaderProgram (const Handle(Graphic3d_ShaderProgram
Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)& theCtx,
const Graphic3d_ShaderObjectList& theShaders)
{
myHasTessShader = false;
if (theCtx.IsNull() || !Create (theCtx))
{
return Standard_False;
}
TCollection_AsciiString aHeader = !myProxy.IsNull() && !myProxy->Header().IsEmpty()
? (myProxy->Header() + "\n")
: TCollection_AsciiString();
TCollection_AsciiString aHeaderVer = !myProxy.IsNull() ? myProxy->Header() : TCollection_AsciiString();
int aShaderMask = 0;
for (Graphic3d_ShaderObjectList::Iterator anIter (theShaders); anIter.More(); anIter.Next())
{
aShaderMask |= anIter.Value()->Type();
}
myHasTessShader = (aShaderMask & (Graphic3d_TOS_TESS_CONTROL | Graphic3d_TOS_TESS_EVALUATION)) != 0;
TCollection_AsciiString aDeclarations = Shaders_Declarations_glsl;
TCollection_AsciiString aDeclImpl = Shaders_DeclarationsImpl_glsl;
// detect the minimum GLSL version required for defined Shader Objects
#if defined(GL_ES_VERSION_2_0)
if (myHasTessShader
|| (aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
{
if (!theCtx->IsGlGreaterEqual (3, 2))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
"Error! Geometry and Tessellation shaders require OpenGL ES 3.2+");
return false;
}
else if (aHeaderVer.IsEmpty())
{
aHeaderVer = "#version 320 es";
}
}
else if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0)
{
if (!theCtx->IsGlGreaterEqual (3, 1))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
"Error! Compute shaders require OpenGL ES 3.1+");
return false;
}
else if (aHeaderVer.IsEmpty())
{
aHeaderVer = "#version 310 es";
}
}
#else
if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0)
{
if (!theCtx->IsGlGreaterEqual (4, 3))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
"Error! Compute shaders require OpenGL 4.3+");
return 0;
}
else if (aHeaderVer.IsEmpty())
{
aHeaderVer = "#version 430";
}
}
else if (myHasTessShader)
{
if (!theCtx->IsGlGreaterEqual (4, 0))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
"Error! Tessellation shaders require OpenGL 4.0+");
return 0;
}
else if (aHeaderVer.IsEmpty())
{
aHeaderVer = "#version 400";
}
}
else if ((aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
{
if (!theCtx->IsGlGreaterEqual (3, 2))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
"Error! Geometry shaders require OpenGL 3.2+");
return 0;
}
else if (aHeaderVer.IsEmpty())
{
aHeaderVer = "#version 150";
}
}
#endif
aDeclarations += aDeclImpl;
for (Graphic3d_ShaderObjectList::Iterator anIter (theShaders);
anIter.More(); anIter.Next())
for (Graphic3d_ShaderObjectList::Iterator anIter (theShaders); anIter.More(); anIter.Next())
{
if (!anIter.Value()->IsDone())
{
const TCollection_ExtendedString aMsg = "Error! Failed to get shader source";
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_ERROR,
0,
GL_DEBUG_SEVERITY_HIGH,
aMsg);
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
return Standard_False;
}
Handle(OpenGl_ShaderObject) aShader;
// Note: Add support of other shader types here
switch (anIter.Value()->Type())
const GLenum aShaderType = shaderTypeToGl (anIter.Value()->Type());
if (aShaderType == 0)
{
case Graphic3d_TOS_VERTEX:
aShader = new OpenGl_ShaderObject (GL_VERTEX_SHADER);
break;
case Graphic3d_TOS_FRAGMENT:
aShader = new OpenGl_ShaderObject (GL_FRAGMENT_SHADER);
break;
}
// Is unsupported shader type?
if (aShader.IsNull())
{
TCollection_ExtendedString aMsg = "Error! Unsupported shader type";
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_ERROR,
0,
GL_DEBUG_SEVERITY_HIGH,
aMsg);
return Standard_False;
}
Handle(OpenGl_ShaderObject) aShader = new OpenGl_ShaderObject (aShaderType);
if (!aShader->Create (theCtx))
{
aShader->Release (theCtx.operator->());
return Standard_False;
}
TCollection_AsciiString aSource = aDeclarations + anIter.Value()->Source();
TCollection_AsciiString anExtensions = "// Enable extensions used in OCCT GLSL programs\n";
if (theCtx->hasDrawBuffers)
{
@ -238,29 +304,37 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
#endif
}
switch (anIter.Value()->Type())
TCollection_AsciiString aPrecisionHeader;
if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT)
{
case Graphic3d_TOS_VERTEX:
{
aSource = aHeader + TCollection_AsciiString ("#define VERTEX_SHADER\n") + anExtensions + aSource;
break;
}
case Graphic3d_TOS_FRAGMENT:
{
#if defined(GL_ES_VERSION_2_0)
TCollection_AsciiString aPrefix (theCtx->hasHighp
? "precision highp float;\n"
"precision highp int;\n"
: "precision mediump float;\n"
"precision mediump int;\n");
aSource = aHeader + anExtensions + aPrefix + aSource;
#else
aSource = aHeader + anExtensions + aSource;
#endif
break;
}
#if defined(GL_ES_VERSION_2_0)
aPrecisionHeader = theCtx->hasHighp
? "precision highp float;\n"
"precision highp int;\n"
: "precision mediump float;\n"
"precision mediump int;\n";
#endif
}
TCollection_AsciiString aHeaderType;
switch (anIter.Value()->Type())
{
case Graphic3d_TOS_COMPUTE: { aHeaderType = "#define COMPUTE_SHADER\n"; break; }
case Graphic3d_TOS_VERTEX: { aHeaderType = "#define VERTEX_SHADER\n"; break; }
case Graphic3d_TOS_TESS_CONTROL: { aHeaderType = "#define TESS_CONTROL_SHADER\n"; break; }
case Graphic3d_TOS_TESS_EVALUATION: { aHeaderType = "#define TESS_EVALUATION_SHADER\n"; break; }
case Graphic3d_TOS_GEOMETRY: { aHeaderType = "#define GEOMETRY_SHADER\n"; break; }
case Graphic3d_TOS_FRAGMENT: { aHeaderType = "#define FRAGMENT_SHADER\n"; break; }
}
const TCollection_AsciiString aSource = aHeaderVer // #version - header defining GLSL version, should be first
+ (!aHeaderVer.IsEmpty() ? "\n" : "")
+ anExtensions // #extension - list of enabled extensions, should be second
+ aPrecisionHeader // precision - default precision qualifiers, should be before any code
+ aHeaderType // auxiliary macros defining a shader stage (type)
+ Shaders_Declarations_glsl // common declarations (global constants and Vertex Shader inputs)
+ Shaders_DeclarationsImpl_glsl
+ anIter.Value()->Source(); // the source code itself (defining main() function)
if (!aShader->LoadSource (theCtx, aSource))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aSource);

View File

@ -210,6 +210,9 @@ public:
return myProgramID;
}
//! Return TRUE if program defines tessellation stage.
Standard_Boolean HasTessellationStage() const { return myHasTessShader; }
private:
//! Returns index of last modification of variables of specified state type.
@ -551,6 +554,7 @@ protected:
OpenGl_ShaderList myShaderObjects; //!< List of attached shader objects
Handle(Graphic3d_ShaderProgram) myProxy; //!< Proxy shader program (from application layer)
Standard_Integer myShareCount; //!< program users count, initialized with 1 (already shared by one user)
Standard_Boolean myHasTessShader; //!< flag indicating that program defines tessellation stage
protected:

View File

@ -1089,10 +1089,11 @@ inline void setAspectProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
// function : SetShaderProgram
// purpose :
// =======================================================================
void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
const Graphic3d_GroupAspect theAspect,
const bool theToOverrideDefaults)
{
bool isUpdateNeeded = false;
switch (theAspect)
{
case Graphic3d_ASPECT_LINE:
@ -1101,6 +1102,7 @@ void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
{
if (!myHasOwnUIsoAspect)
{
isUpdateNeeded = true;
Handle(Prs3d_IsoAspect) anAspect = UIsoAspect();
if (!myLink.IsNull())
{
@ -1112,6 +1114,7 @@ void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
}
if (!myHasOwnVIsoAspect)
{
isUpdateNeeded = true;
Handle(Prs3d_IsoAspect) anAspect = VIsoAspect();
if (!myLink.IsNull())
{
@ -1123,62 +1126,74 @@ void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
}
if (!myHasOwnWireAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, myWireAspect, WireAspect());
myHasOwnWireAspect = true;
}
if (!myHasOwnLineAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, myLineAspect, LineAspect());
myHasOwnLineAspect = true;
}
if (!myHasOwnSeenLineAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, mySeenLineAspect, SeenLineAspect());
myHasOwnSeenLineAspect = true;
}
if (!myHasOwnHiddenLineAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, myHiddenLineAspect, HiddenLineAspect());
myHasOwnHiddenLineAspect = true;
}
if (!myHasOwnVectorAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, myVectorAspect, VectorAspect());
myHasOwnVectorAspect = true;
}
if (!myHasOwnSectionAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, mySectionAspect, SectionAspect());
myHasOwnSectionAspect = true;
}
if (!myHasOwnFreeBoundaryAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, myFreeBoundaryAspect, FreeBoundaryAspect());
myHasOwnFreeBoundaryAspect = true;
}
if (!myHasOwnUnFreeBoundaryAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, myUnFreeBoundaryAspect, UnFreeBoundaryAspect());
myHasOwnUnFreeBoundaryAspect = true;
}
if (!myHasOwnFaceBoundaryAspect)
{
isUpdateNeeded = true;
copyLineAspect (myLink, myFaceBoundaryAspect, FaceBoundaryAspect());
myHasOwnFaceBoundaryAspect = true;
}
if (!myHasOwnPlaneAspect)
{
isUpdateNeeded = true;
myPlaneAspect = new Prs3d_PlaneAspect();
myHasOwnPlaneAspect = true;
}
if (!myHasOwnArrowAspect)
{
isUpdateNeeded = true;
myArrowAspect = new Prs3d_ArrowAspect();
myHasOwnArrowAspect = true;
}
if (!myHasOwnDatumAspect)
{
isUpdateNeeded = true;
myDatumAspect = new Prs3d_DatumAspect();
myHasOwnDatumAspect = true;
}
@ -1208,13 +1223,14 @@ void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
setAspectProgram (theProgram, true, myDatumAspect->LineAspect(Prs3d_DP_ZAxis));
}
setAspectProgram (theProgram, myHasOwnArrowAspect, myArrowAspect);
return;
return isUpdateNeeded;
}
case Graphic3d_ASPECT_TEXT:
{
if (theToOverrideDefaults
&& !myHasOwnTextAspect)
{
isUpdateNeeded = true;
myTextAspect = new Prs3d_TextAspect();
myHasOwnTextAspect = true;
if (!myLink.IsNull())
@ -1224,13 +1240,14 @@ void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
}
setAspectProgram (theProgram, myHasOwnTextAspect, myTextAspect);
return;
return isUpdateNeeded;
}
case Graphic3d_ASPECT_MARKER:
{
if (theToOverrideDefaults
&& !myHasOwnPointAspect)
{
isUpdateNeeded = true;
myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
myHasOwnPointAspect = true;
if (!myLink.IsNull())
@ -1240,13 +1257,14 @@ void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
}
setAspectProgram (theProgram, myHasOwnPointAspect, myPointAspect);
return;
return isUpdateNeeded;
}
case Graphic3d_ASPECT_FILL_AREA:
{
if (theToOverrideDefaults
&& !myHasOwnShadingAspect)
{
isUpdateNeeded = true;
myShadingAspect = new Prs3d_ShadingAspect();
myHasOwnShadingAspect = true;
if (!myLink.IsNull())
@ -1255,7 +1273,8 @@ void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
}
}
setAspectProgram (theProgram, myHasOwnShadingAspect, myShadingAspect);
return;
return isUpdateNeeded;
}
}
return false;
}

View File

@ -842,7 +842,8 @@ public:
//! @param theAspect the type of primitives
//! @param theToOverrideDefaults if true then non-overridden attributes using defaults will be allocated and copied from the Link;
//! otherwise, only already customized attributes will be changed
Standard_EXPORT void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
//! @return TRUE if presentation should be recomputed after creating aspects not previously customized (if theToOverrideDefaults is also TRUE)
Standard_EXPORT bool SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
const Graphic3d_GroupAspect theAspect,
const bool theToOverrideDefaults = false);

View File

@ -49,20 +49,22 @@
THE_ATTRIBUTE vec3 occNormal;
THE_ATTRIBUTE vec4 occTexCoord;
THE_ATTRIBUTE vec4 occVertColor;
#elif (__VERSION__ >= 130)
#ifdef OCC_ENABLE_draw_buffers
out vec4 occFragColorArray[2];
#define occFragColor occFragColorArray[0]
#define occFragCoverage occFragColorArray[1]
#elif defined(FRAGMENT_SHADER)
#if (__VERSION__ >= 130)
#ifdef OCC_ENABLE_draw_buffers
out vec4 occFragColorArray[2];
#define occFragColor occFragColorArray[0]
#define occFragCoverage occFragColorArray[1]
#else
out vec4 occFragColor;
#endif
#else
out vec4 occFragColor;
#endif
#else
#ifdef OCC_ENABLE_draw_buffers
#define occFragColor gl_FragData[0]
#define occFragCoverage gl_FragData[1]
#else
#define occFragColor gl_FragColor
#ifdef OCC_ENABLE_draw_buffers
#define occFragColor gl_FragData[0]
#define occFragCoverage gl_FragData[1]
#else
#define occFragColor gl_FragColor
#endif
#endif
#endif

View File

@ -52,20 +52,22 @@ static const char Shaders_Declarations_glsl[] =
" THE_ATTRIBUTE vec3 occNormal;\n"
" THE_ATTRIBUTE vec4 occTexCoord;\n"
" THE_ATTRIBUTE vec4 occVertColor;\n"
"#elif (__VERSION__ >= 130)\n"
" #ifdef OCC_ENABLE_draw_buffers\n"
" out vec4 occFragColorArray[2];\n"
" #define occFragColor occFragColorArray[0]\n"
" #define occFragCoverage occFragColorArray[1]\n"
"#elif defined(FRAGMENT_SHADER)\n"
" #if (__VERSION__ >= 130)\n"
" #ifdef OCC_ENABLE_draw_buffers\n"
" out vec4 occFragColorArray[2];\n"
" #define occFragColor occFragColorArray[0]\n"
" #define occFragCoverage occFragColorArray[1]\n"
" #else\n"
" out vec4 occFragColor;\n"
" #endif\n"
" #else\n"
" out vec4 occFragColor;\n"
" #endif\n"
"#else\n"
" #ifdef OCC_ENABLE_draw_buffers\n"
" #define occFragColor gl_FragData[0]\n"
" #define occFragCoverage gl_FragData[1]\n"
" #else\n"
" #define occFragColor gl_FragColor\n"
" #ifdef OCC_ENABLE_draw_buffers\n"
" #define occFragColor gl_FragData[0]\n"
" #define occFragCoverage gl_FragData[1]\n"
" #else\n"
" #define occFragColor gl_FragColor\n"
" #endif\n"
" #endif\n"
"#endif\n"
"\n"

View File

@ -532,6 +532,50 @@ static int VGlInfo (Draw_Interpretor& theDI,
return 0;
}
//! Parse shader type argument.
static bool parseShaderTypeArg (Graphic3d_TypeOfShaderObject& theType,
const TCollection_AsciiString& theArg)
{
if (theArg == "-vertex"
|| theArg == "-vert")
{
theType = Graphic3d_TOS_VERTEX;
}
else if (theArg == "-tessevaluation"
|| theArg == "-tesseval"
|| theArg == "-evaluation"
|| theArg == "-eval")
{
theType = Graphic3d_TOS_TESS_EVALUATION;
}
else if (theArg == "-tesscontrol"
|| theArg == "-tessctrl"
|| theArg == "-control"
|| theArg == "-ctrl")
{
theType = Graphic3d_TOS_TESS_CONTROL;
}
else if (theArg == "-geometry"
|| theArg == "-geom")
{
theType = Graphic3d_TOS_GEOMETRY;
}
else if (theArg == "-fragment"
|| theArg == "-frag")
{
theType = Graphic3d_TOS_FRAGMENT;
}
else if (theArg == "-compute"
|| theArg == "-comp")
{
theType = Graphic3d_TOS_COMPUTE;
}
else
{
return false;
}
return true;
}
//==============================================================================
//function : VShaderProg
@ -544,150 +588,219 @@ static Standard_Integer VShaderProg (Draw_Interpretor& /*theDI*/,
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
if (aCtx.IsNull())
{
std::cerr << "Use 'vinit' command before " << theArgVec[0] << "\n";
std::cout << "Error: no active view.\n";
return 1;
}
else if (theArgNb < 2)
{
std::cerr << theArgVec[0] << " syntax error: lack of arguments\n";
std::cout << "Syntax error: lack of arguments\n";
return 1;
}
TCollection_AsciiString aLastArg (theArgVec[theArgNb - 1]);
aLastArg.LowerCase();
const Standard_Boolean toTurnOff = aLastArg == "off";
Standard_Integer anArgsNb = theArgNb - 1;
Handle(Graphic3d_ShaderProgram) aProgram;
if (!toTurnOff
&& aLastArg == "phong")
bool isExplicitShaderType = false;
Handle(Graphic3d_ShaderProgram) aProgram = new Graphic3d_ShaderProgram();
NCollection_Sequence<Handle(AIS_InteractiveObject)> aPrsList;
Graphic3d_GroupAspect aGroupAspect = Graphic3d_ASPECT_FILL_AREA;
bool isSetGroupAspect = false;
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
const TCollection_AsciiString& aShadersRoot = Graphic3d_ShaderProgram::ShadersFolder();
if (aShadersRoot.IsEmpty())
TCollection_AsciiString anArg (theArgVec[anArgIter]);
anArg.LowerCase();
Graphic3d_TypeOfShaderObject aShaderTypeArg = Graphic3d_TypeOfShaderObject(-1);
if (!aProgram.IsNull()
&& aProgram->ShaderObjects().IsEmpty()
&& (anArg == "-off"
|| anArg == "off"))
{
std::cerr << "Both environment variables CSF_ShadersDirectory and CASROOT are undefined!\n"
<< "At least one should be defined to load Phong program.\n";
return 1;
aProgram.Nullify();
}
else if (!aProgram.IsNull()
&& aProgram->ShaderObjects().IsEmpty()
&& (anArg == "-phong"
|| anArg == "phong"))
{
const TCollection_AsciiString& aShadersRoot = Graphic3d_ShaderProgram::ShadersFolder();
if (aShadersRoot.IsEmpty())
{
std::cout << "Error: both environment variables CSF_ShadersDirectory and CASROOT are undefined!\n"
"At least one should be defined to load Phong program.\n";
return 1;
}
const TCollection_AsciiString aSrcVert = aShadersRoot + "/PhongShading.vs";
const TCollection_AsciiString aSrcFrag = aShadersRoot + "/PhongShading.fs";
const TCollection_AsciiString aSrcVert = aShadersRoot + "/PhongShading.vs";
const TCollection_AsciiString aSrcFrag = aShadersRoot + "/PhongShading.fs";
if (!aSrcVert.IsEmpty()
&& !OSD_File (aSrcVert).Exists())
{
std::cout << "Error: PhongShading.vs is not found\n";
return 1;
}
if (!aSrcFrag.IsEmpty()
&& !OSD_File (aSrcFrag).Exists())
{
std::cout << "Error: PhongShading.fs is not found\n";
return 1;
}
if (!aSrcVert.IsEmpty()
&& !OSD_File (aSrcVert).Exists())
{
std::cerr << "Error: PhongShading.vs is not found\n";
return 1;
aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_VERTEX, aSrcVert));
aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_FRAGMENT, aSrcFrag));
}
if (!aSrcFrag.IsEmpty()
&& !OSD_File (aSrcFrag).Exists())
else if (aPrsList.IsEmpty()
&& anArg == "*")
{
std::cerr << "Error: PhongShading.fs is not found\n";
return 1;
//
}
else if (!isSetGroupAspect
&& anArgIter + 1 < theArgNb
&& (anArg == "-primtype"
|| anArg == "-primitivetype"
|| anArg == "-groupaspect"
|| anArg == "-aspecttype"
|| anArg == "-aspect"))
{
isSetGroupAspect = true;
TCollection_AsciiString aPrimTypeStr (theArgVec[++anArgIter]);
aPrimTypeStr.LowerCase();
if (aPrimTypeStr == "line")
{
aGroupAspect = Graphic3d_ASPECT_LINE;
}
else if (aPrimTypeStr == "tris"
|| aPrimTypeStr == "triangles"
|| aPrimTypeStr == "fill"
|| aPrimTypeStr == "fillarea"
|| aPrimTypeStr == "shading"
|| aPrimTypeStr == "shade")
{
aGroupAspect = Graphic3d_ASPECT_FILL_AREA;
}
else if (aPrimTypeStr == "text")
{
aGroupAspect = Graphic3d_ASPECT_TEXT;
}
else if (aPrimTypeStr == "marker"
|| aPrimTypeStr == "point"
|| aPrimTypeStr == "pnt")
{
aGroupAspect = Graphic3d_ASPECT_MARKER;
}
else
{
std::cerr << "Syntax error at '" << aPrimTypeStr << "'\n";
return 1;
}
}
else if (anArgIter + 1 < theArgNb
&& !aProgram.IsNull()
&& aProgram->Header().IsEmpty()
&& (anArg == "-version"
|| anArg == "-glslversion"
|| anArg == "-header"
|| anArg == "-glslheader"))
{
TCollection_AsciiString aHeader (theArgVec[++anArgIter]);
if (aHeader.IsIntegerValue())
{
aHeader = TCollection_AsciiString ("#version ") + aHeader;
}
aProgram->SetHeader (aHeader);
}
else if (!anArg.StartsWith ("-")
&& GetMapOfAIS().IsBound2 (theArgVec[anArgIter]))
{
Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (theArgVec[anArgIter]));
if (anIO.IsNull())
{
std::cerr << "Syntax error: " << theArgVec[anArgIter] << " is not an AIS object\n";
return 1;
}
aPrsList.Append (anIO);
}
else if (!aProgram.IsNull()
&& ((anArgIter + 1 < theArgNb && parseShaderTypeArg (aShaderTypeArg, anArg))
|| (!isExplicitShaderType && aProgram->ShaderObjects().Size() < 2)))
{
TCollection_AsciiString aShaderPath (theArgVec[anArgIter]);
if (aShaderTypeArg != Graphic3d_TypeOfShaderObject(-1))
{
aShaderPath = (theArgVec[++anArgIter]);
isExplicitShaderType = true;
}
aProgram = new Graphic3d_ShaderProgram();
aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_VERTEX, aSrcVert));
aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_FRAGMENT, aSrcFrag));
}
if (!toTurnOff
&& aProgram.IsNull())
{
if (theArgNb < 3)
{
std::cout << "Syntax error: lack of arguments\n";
return 1;
}
const bool isSrcFile = OSD_File (aShaderPath).Exists();
Handle(Graphic3d_ShaderObject) aShader = isSrcFile
? Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_VERTEX, aShaderPath)
: Graphic3d_ShaderObject::CreateFromSource(Graphic3d_TOS_VERTEX, aShaderPath);
const TCollection_AsciiString& aShaderSrc = aShader->Source();
const TCollection_AsciiString aSrcVert = theArgVec[theArgNb - 2];
const TCollection_AsciiString aSrcFrag = theArgVec[theArgNb - 1];
if (aSrcVert.IsEmpty() || aSrcFrag.IsEmpty())
{
std::cout << "Syntax error: lack of arguments\n";
return 1;
}
const bool hasVertPos = aShaderSrc.Search ("gl_Position") != -1;
const bool hasFragColor = aShaderSrc.Search ("occFragColor") != -1
|| aShaderSrc.Search ("gl_FragColor") != -1
|| aShaderSrc.Search ("gl_FragData") != -1;
Graphic3d_TypeOfShaderObject aShaderType = aShaderTypeArg;
if (aShaderType == Graphic3d_TypeOfShaderObject(-1))
{
if (hasVertPos
&& !hasFragColor)
{
aShaderType = Graphic3d_TOS_VERTEX;
}
if (hasFragColor
&& !hasVertPos)
{
aShaderType = Graphic3d_TOS_FRAGMENT;
}
}
if (aShaderType == Graphic3d_TypeOfShaderObject(-1))
{
std::cerr << "Error: non-existing or invalid shader source\n";
return 1;
}
const bool isVertFile = OSD_File (aSrcVert).Exists();
const bool isFragFile = OSD_File (aSrcFrag).Exists();
if (!isVertFile
&& aSrcVert.Search ("gl_Position") == -1)
aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromSource (aShaderType, aShaderSrc));
}
else
{
std::cerr << "Error: non-existing or invalid vertex shader source\n";
std::cerr << "Syntax error at '" << anArg << "'\n";
return 1;
}
if (!isFragFile
&& aSrcFrag.Search ("occFragColor") == -1)
{
std::cerr << "Error: non-existing or invalid fragment shader source\n";
return 1;
}
aProgram = new Graphic3d_ShaderProgram();
aProgram->AttachShader (isVertFile
? Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_VERTEX, aSrcVert)
: Graphic3d_ShaderObject::CreateFromSource(Graphic3d_TOS_VERTEX, aSrcVert));
aProgram->AttachShader (isFragFile
? Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_FRAGMENT, aSrcFrag)
: Graphic3d_ShaderObject::CreateFromSource(Graphic3d_TOS_FRAGMENT, aSrcFrag));
anArgsNb = theArgNb - 2;
}
Handle(AIS_InteractiveObject) anIO;
if (anArgsNb <= 1
|| *theArgVec[1] == '*')
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aGlobalPrsIter (GetMapOfAIS());
NCollection_Sequence<Handle(AIS_InteractiveObject)>::Iterator aPrsIter (aPrsList);
const bool isGlobalList = aPrsList.IsEmpty();
for (;;)
{
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
Handle(AIS_InteractiveObject) anIO;
if (isGlobalList)
{
anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
if (!aGlobalPrsIter.More())
{
break;
}
anIO = Handle(AIS_InteractiveObject)::DownCast (aGlobalPrsIter.Key1());
aGlobalPrsIter.Next();
if (anIO.IsNull())
{
continue;
}
if (!anIO->Attributes()->HasOwnShadingAspect())
}
else
{
if (!aPrsIter.More())
{
Handle(Prs3d_ShadingAspect) aNewAspect = new Prs3d_ShadingAspect();
*aNewAspect->Aspect() = *anIO->Attributes()->ShadingAspect()->Aspect();
aNewAspect->Aspect()->SetShaderProgram (aProgram);
anIO->Attributes()->SetShadingAspect (aNewAspect);
aCtx->Redisplay (anIO, Standard_False);
break;
}
else
{
anIO->Attributes()->SetShaderProgram (aProgram, Graphic3d_ASPECT_FILL_AREA);
anIO->SynchronizeAspects();
}
}
aCtx->UpdateCurrentViewer();
return 0;
}
for (Standard_Integer anArgIter = 1; anArgIter < anArgsNb; ++anArgIter)
{
const TCollection_AsciiString aName (theArgVec[anArgIter]);
if (!GetMapOfAIS().IsBound2 (aName))
{
std::cerr << "Warning: " << aName.ToCString() << " is not displayed\n";
continue;
}
anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
if (anIO.IsNull())
{
std::cerr << "Warning: " << aName.ToCString() << " is not an AIS object\n";
continue;
anIO = aPrsIter.Value();
aPrsIter.Next();
}
if (!anIO->Attributes()->HasOwnShadingAspect())
if (anIO->Attributes()->SetShaderProgram (aProgram, aGroupAspect, true))
{
Handle(Prs3d_ShadingAspect) aNewAspect = new Prs3d_ShadingAspect();
*aNewAspect->Aspect() = *anIO->Attributes()->ShadingAspect()->Aspect();
aNewAspect->Aspect()->SetShaderProgram (aProgram);
anIO->Attributes()->SetShadingAspect (aNewAspect);
aCtx->Redisplay (anIO, Standard_False);
}
else
{
anIO->Attributes()->SetShaderProgram (aProgram, Graphic3d_ASPECT_FILL_AREA);
anIO->SynchronizeAspects();
}
}
@ -720,10 +833,12 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
"\n\t\t: [GL_SHADING_LANGUAGE_VERSION] [GL_EXTENSIONS]"
"\n\t\t: print OpenGL info",
__FILE__, VGlInfo, aGroup);
theCommands.Add("vshaderprog",
" 'vshaderprog [name] pathToVertexShader pathToFragmentShader'"
"\n\t\t: or 'vshaderprog [name] off' to disable GLSL program"
"\n\t\t: or 'vshaderprog [name] phong' to enable per-pixel lighting calculations"
"\n\t\t: * might be used to specify all displayed objects",
theCommands.Add("vshader",
"vshader name -vert VertexShader -frag FragmentShader [-geom GeometryShader]"
"\n\t\t: [-off] [-phong] [-aspect {shading|line|point|text}=shading]"
"\n\t\t: [-header VersionHeader]"
"\n\t\t: [-tessControl TessControlShader -tesseval TessEvaluationShader]"
"\n\t\t: Assign custom GLSL program to presentation aspects.",
__FILE__, VShaderProg, aGroup);
theCommands.Add("vshaderprog", "Alias for vshader", __FILE__, VShaderProg, aGroup);
}

View File

@ -1,3 +0,0 @@
vclear
vclose ALL
vinit View1

55
tests/v3d/glsl/geom1 Normal file
View File

@ -0,0 +1,55 @@
puts "========"
puts "0029074: Visualization, TKOpenGl - support Geometry Shader definition"
puts "========"
pload MODELING VISUALIZATION
set aShaderVert "
out vec4 VertColor;
void main() {
VertColor = occColor;
gl_Position = occVertex;
}"
# define a Geometry shader drawing shrinked triangles
set aShaderGeom "
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
in vec4 VertColor\[3\];
out vec4 Color;
void main() {
mat4 aMat = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix;
vec3 aCenter = vec3 (0.0, 0.0, 0.0);
for (int aTriVertIter = 0; aTriVertIter < 3; ++aTriVertIter) {
aCenter += gl_in\[aTriVertIter\].gl_Position.xyz;
}
aCenter /= 3.0;
for (int aTriVertIter = 0; aTriVertIter < 3; ++aTriVertIter) {
vec3 aVec = gl_in\[aTriVertIter\].gl_Position.xyz - aCenter;
vec3 aVertRes = aCenter + normalize (aVec) * length (aVec) * 0.75;
gl_Position = aMat * vec4 (aVertRes, 1.0);
Color = VertColor\[aTriVertIter\] * 2.0;
EmitVertex();
}
EndPrimitive();
}"
set aShaderFrag "
in vec4 Color;
void main() {
occFragColor = Color;
}"
# draw a box
box b 1 2 3
vcaps -core
vclear
vinit View1
vaxo
vdisplay -dispMode 1 -mutable b
vfit
vrotate 0.2 0.0 0.0
vdump $::imagedir/${::casename}_normal.png
vshaderprog b -vert $aShaderVert -geom $aShaderGeom -frag $aShaderFrag
vdump $::imagedir/${::casename}_geom.png

View File

@ -4,6 +4,9 @@ puts "Visual comparison with the reference snapshot should be performed for this
puts "========"
# setup viewer
vclear
vclose ALL
vinit View1
vcaps -ffp 0
vrenderparams -shadingModel vert

View File

@ -3,7 +3,10 @@ puts "Per-vertex lighting using built-in GLSL program, two directional light sou
puts "Visual comparison with the reference snapshot should be performed for this test case."
puts "========"
# setup viewer
# setup viewervclear
vclear
vclose ALL
vinit View1
vcaps -ffp 0
vrenderparams -shadingModel vert
vlight delete 0

View File

@ -3,6 +3,10 @@ puts "Per-vertex lighting using built-in GLSL program, one positional light sour
puts "Visual comparison with the reference snapshot should be performed for this test case."
puts "========"
vclear
vclose ALL
vinit View1
# create objects
set anX 0.001
circle c 0 0 0 0.001

View File

@ -3,6 +3,10 @@ puts "Per-vertex lighting using built-in GLSL program, one spot light source."
puts "Visual comparison with the reference snapshot should be performed for this test case."
puts "========"
vclear
vclose ALL
vinit View1
# create objects
set anX 0.001
circle c 0 0 0 0.001

View File

@ -6,8 +6,9 @@ puts "========"
box b 1 2 3
# draw box
vinit View1
vclear
vclose ALL
vinit View1
vsetdispmode 1
vdisplay b
vfit

View File

@ -6,8 +6,9 @@ puts "========"
box b 1 2 3
# draw box
vinit View1
vclear
vclose ALL
vinit View1
vsetdispmode 1
vaxo
vdisplay b

View File

@ -8,8 +8,9 @@ tclean f
box b 2 0 0 1 0.5 0.25
# draw box
vinit View1
vclear
vclose ALL
vinit View1
vdefaults -absDefl 0.5
vsetdispmode 1
vaxo

View File

@ -4,6 +4,9 @@ puts "Visual comparison with the reference snapshot should be performed for this
puts "========"
# setup viewer
vclear
vclose ALL
vinit View1
vcaps -ffp 0
vrenderparams -shadingModel phong

View File

@ -4,6 +4,9 @@ puts "Visual comparison with the reference snapshot should be performed for this
puts "========"
# setup viewer
vclear
vclose ALL
vinit View1
vcaps -ffp 0
vrenderparams -shadingModel phong
vlight delete 0

View File

@ -7,8 +7,9 @@ restore [locate_data_file occ/fuse.brep] f
tclean f
# draw box
vinit View1
vclear
vclose ALL
vinit View1
vdefaults -absDefl 0.5
vsetdispmode 1
vaxo

View File

@ -7,8 +7,9 @@ restore [locate_data_file occ/fuse.brep] f
tclean f
# draw box
vinit View1
vclear
vclose ALL
vinit View1
vdefaults -absDefl 0.5
vsetdispmode 1
vaxo

View File

@ -6,8 +6,9 @@ puts "========"
box b 1 2 3
# draw box
vinit View1
vclear
vclose ALL
vinit View1
vsetdispmode 1
vaxo
vdisplay b

View File

@ -3,6 +3,10 @@ puts "Per-fragment lighting using built-in GLSL program, one positional light so
puts "Visual comparison with the reference snapshot should be performed for this test case."
puts "========"
vclear
vclose ALL
vinit View1
# create objects
set anX 0.001
circle c 0 0 0 0.001

View File

@ -7,8 +7,9 @@ box b 1 2 3
explode b F
# draw box
vinit View1
vclear
vclose ALL
vinit View1
vsetdispmode 1
vaxo
vdisplay b_1 b_2

View File

@ -3,6 +3,10 @@ puts "Per-fragment lighting using built-in GLSL program, one spot light source."
puts "Visual comparison with the reference snapshot should be performed for this test case."
puts "========"
vclear
vclose ALL
vinit View1
# create objects
set anX 0.001
circle c 0 0 0 0.001

View File

@ -6,8 +6,9 @@ puts "========"
box b 1 2 3
# draw box
vinit View1
vclear
vclose ALL
vinit View1
vsetdispmode 1
vaxo
vdisplay b

View File

@ -15,6 +15,7 @@ if { "$aFontFile" != "" } {
box b 1 2 3
vclear
vclose ALL
vinit View1
vdisplay b
vfit

View File

@ -3,8 +3,9 @@ puts "Stereo output modes"
puts "========"
restore [locate_data_file occ/fuse.brep] f
vinit View1
vclear
vclose ALL
vinit View1
vsetdispmode 1
vaxo
vdisplay f

View File

@ -1,6 +1,8 @@
restore [locate_data_file occ/fuse.brep] f
vcaps -ffp 1
vclear
vclose ALL
vinit View1
vclear
vsetdispmode 0

75
tests/v3d/glsl/tess1 Normal file
View File

@ -0,0 +1,75 @@
puts "========"
puts "0029074: Visualization, TKOpenGl - support of Tessellation Shaders"
puts "========"
pload MODELING VISUALIZATION
set aShaderVert "
out vec4 VertColor;
void main() {
VertColor = occColor;
gl_Position = occVertex;
}"
set aShaderTessCtrl "
layout(vertices = 3) out;
void main() {
if (gl_InvocationID == 0) {
gl_TessLevelInner\[0\] = 7.0;
gl_TessLevelOuter\[0\] = 2.0;
gl_TessLevelOuter\[1\] = 3.0;
gl_TessLevelOuter\[2\] = 7.0;
}
gl_out\[gl_InvocationID\].gl_Position = gl_in\[gl_InvocationID\].gl_Position;
}"
set aShaderTessEval "
layout(triangles, equal_spacing, ccw) in;
void main() {
vec3 aPnt0 = gl_TessCoord.x * gl_in\[0\].gl_Position.xyz;
vec3 aPnt1 = gl_TessCoord.y * gl_in\[1\].gl_Position.xyz;
vec3 aPnt2 = gl_TessCoord.z * gl_in\[2\].gl_Position.xyz;
gl_Position = vec4 (aPnt0 + aPnt1 + aPnt2, 1.0);
}"
set aShaderGeom "
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
void main() {
mat4 aMat = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix;
vec3 aCenter = vec3 (0.0, 0.0, 0.0);
for (int aTriVertIter = 0; aTriVertIter < 3; ++aTriVertIter) {
aCenter += gl_in\[aTriVertIter\].gl_Position.xyz;
}
aCenter /= 3.0;
for (int aTriVertIter = 0; aTriVertIter < 3; ++aTriVertIter) {
vec3 aVec = gl_in\[aTriVertIter\].gl_Position.xyz - aCenter;
vec3 aVertRes = aCenter + normalize (aVec) * length (aVec) * 0.75;
gl_Position = aMat * vec4 (aVertRes, 1.0);
EmitVertex();
}
EndPrimitive();
}"
set aShaderFrag "
void main() {
occFragColor = vec4(1.0, 0.0, 0.0, 1.0);
}"
# draw a box
box b 1 2 3
explode b F
vcaps -core
vclear
vinit View1
vaxo
vdisplay -dispMode 1 -mutable b_1
vfit
vrotate 0.2 0.0 0.0
# take snapshot with built-in shader
vdump $::imagedir/${::casename}_normal.png
vshaderprog b_1 -vert $aShaderVert -tessCtrl $aShaderTessCtrl -tessEval $aShaderTessEval -geom $aShaderGeom -frag $aShaderFrag
vdump $::imagedir/${::casename}_tess.png

View File

@ -26,6 +26,7 @@ void main() {
# draw a box
box b 1 2 3
vclear
vclose ALL
vinit View1
vaxo
vdisplay -dispMode 1 b
@ -36,5 +37,6 @@ vrotate 0.2 0.0 0.0
vtexture b -tex0 3 -tex1 4 -tex2 5 -tex3 6
vdump $::imagedir/${::casename}_normal.png
vshaderprog b $aShaderVert $aShaderFrag
#vshaderprog b $aShaderVert $aShaderFrag
vshaderprog b -vert $aShaderVert -frag $aShaderFrag
vdump $::imagedir/${::casename}_multi.png

View File

@ -2,6 +2,10 @@ puts "========"
puts "Texture 2D transformation (UV coordinates generation)"
puts "========"
vclear
vclose ALL
vinit View1
set aTexture [locate_data_file bug26122_texture_trsf_ref.png]
pload MODELING VISUALIZATION
box b 1 1 1

View File

@ -16,6 +16,7 @@ if { "$aFontFile" != "" } {
}
vclear
vclose ALL
vinit View1
vraytrace 0
vsetgradientbg 180 200 255 180 180 180 2