1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +03:00

0032289: Visualization - add NCollection_Mat3 for 3x3 matrix similar to NCollection_Mat4

Introduced NCollection_Mat3 class similar to NCollection_Mat4.
Added NCollection_Mat4::operator() alias to NCollection_Mat4::Value().
Added NCollection_Mat4::Negated(), ::Subtracted(), ::Added(), ::Divided() operations.
Added a note to NCollection_Mat4::GetData() that matrix values are stored in column-major order.
Removed duplicated operator== operators from NCollection_Mat4/NCollection_Vec4/NCollection_Vec3/NCollection_Vec2 classes.

Removed obsolete and no more used matrix state fields from OpenGl_Workspace.
Removed obsoiete structure OpenGl_Matrix (replaced by OpenGl_Mat4).
OpenGl_ShaderProgram - duplicated methods have been replaced by templates.
This commit is contained in:
kgv
2021-04-09 12:16:55 +03:00
committed by bugmaster
parent c6aa2a8317
commit a2af24d1a9
21 changed files with 878 additions and 486 deletions

View File

@@ -41,7 +41,6 @@ OpenGl_GraduatedTrihedron.hxx
OpenGl_GraduatedTrihedron.cxx
OpenGl_Material.hxx
OpenGl_MaterialState.hxx
OpenGl_Matrix.hxx
OpenGl_MatrixState.hxx
OpenGl_LineAttributes.hxx
OpenGl_LineAttributes.cxx

View File

@@ -69,7 +69,7 @@ namespace
// set identity model matrix
aContext->ModelWorldState.Push();
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
aContext->ModelWorldState.SetCurrent (thePlane->Orientation());
aContext->ApplyModelViewMatrix();
thePlane->Primitives().Render (theWorkspace);

View File

@@ -46,26 +46,15 @@ namespace
1.0f, 0.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f,-1.0f, 0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f
};
static const OpenGl_Matrix OpenGl_IdentityMatrix =
{
// mat[4][4]
{ { 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f } }
};
}
// =======================================================================
// function : OpenGl_CappingPlaneResource
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
: myPrimitives (NULL),
myOrientation (OpenGl_IdentityMatrix),
myOrientation (OpenGl_Mat4::Identity()),
myAspect (NULL),
myPlaneRoot (thePlane),
myEquationMod ((unsigned int )-1),
@@ -210,24 +199,8 @@ void OpenGl_CappingPlaneResource::updateTransform (const Handle(OpenGl_Context)&
}
const Graphic3d_Vec3 F = Graphic3d_Vec3::Cross (-aLeft, aNorm);
myOrientation.mat[0][0] = aLeft[0];
myOrientation.mat[0][1] = aLeft[1];
myOrientation.mat[0][2] = aLeft[2];
myOrientation.mat[0][3] = 0.0f;
myOrientation.mat[1][0] = aNorm[0];
myOrientation.mat[1][1] = aNorm[1];
myOrientation.mat[1][2] = aNorm[2];
myOrientation.mat[1][3] = 0.0f;
myOrientation.mat[2][0] = F[0];
myOrientation.mat[2][1] = F[1];
myOrientation.mat[2][2] = F[2];
myOrientation.mat[2][3] = 0.0f;
myOrientation.mat[3][0] = T[0];
myOrientation.mat[3][1] = T[1];
myOrientation.mat[3][2] = T[2];
myOrientation.mat[3][3] = 1.0f;
myOrientation.SetColumn (0, aLeft);
myOrientation.SetColumn (1, aNorm);
myOrientation.SetColumn (2, F);
myOrientation.SetColumn (3, T);
}

View File

@@ -19,7 +19,7 @@
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Resource.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_Matrix.hxx>
#include <OpenGl_Vec.hxx>
#include <Graphic3d_ClipPlane.hxx>
class OpenGl_CappingPlaneResource;
@@ -64,7 +64,7 @@ public:
inline const OpenGl_Aspects* AspectFace() const { return myAspect; }
//! @return evaluated orientation matrix to transform infinite plane.
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
inline const OpenGl_Mat4& Orientation() const { return myOrientation; }
//! @return primitive array of vertices to render infinite plane.
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
@@ -80,7 +80,7 @@ private:
private:
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
OpenGl_Mat4 myOrientation; //!< plane transformation matrix.
OpenGl_Aspects* myAspect; //!< capping face aspect.
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
Handle(Graphic3d_Aspects) myFillAreaAspect;//!< own capping aspect

View File

@@ -2657,7 +2657,7 @@ void OpenGl_Context::SetTextureMatrix (const Handle(Graphic3d_TextureParams)& th
Graphic3d_TransformUtils::Translate (aTextureMat, -aTrans.x(), -aTrans.y(), 0.0f);
}
Graphic3d_TransformUtils::Rotate (aTextureMat, -theParams->Rotation(), 0.0f, 0.0f, 1.0f);
core11ffp->glLoadMatrixf (aTextureMat);
core11ffp->glLoadMatrixf (aTextureMat.GetData());
core11ffp->glMatrixMode (aMatrixMode);
}
#endif

View File

@@ -1,27 +0,0 @@
// Created on: 2011-09-20
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OpenGl_Matrix_Header
#define OpenGl_Matrix_Header
#include <Standard_Type.hxx>
struct OpenGl_Matrix
{
float mat[4][4];
DEFINE_STANDARD_ALLOC
};
#endif //OpenGl_Matrix_Header

View File

@@ -597,7 +597,7 @@ void OpenGl_ShaderManager::pushProjectionState (const Handle(OpenGl_ShaderProgra
if (myContext->core11ffp != NULL)
{
myContext->core11ffp->glMatrixMode (GL_PROJECTION);
myContext->core11ffp->glLoadMatrixf (myProjectionState.ProjectionMatrix());
myContext->core11ffp->glLoadMatrixf (myProjectionState.ProjectionMatrix().GetData());
}
#endif
return;

View File

@@ -821,17 +821,6 @@ GLint OpenGl_ShaderProgram::GetAttributeLocation (const Handle(OpenGl_Context)&
: INVALID_LOCATION;
}
// =======================================================================
// function : GetUniform
// purpose : Returns the value of the integer uniform variable
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::GetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
OpenGl_Vec4i& theValue) const
{
return GetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : GetUniform
// purpose : Returns the value of the integer uniform variable
@@ -849,17 +838,6 @@ Standard_Boolean OpenGl_ShaderProgram::GetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : GetUniform
// purpose : Returns the value of the floating-point uniform variable
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::GetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
OpenGl_Vec4& theValue) const
{
return GetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : GetUniform
// purpose : Returns the value of the floating-point uniform variable
@@ -877,17 +855,6 @@ Standard_Boolean OpenGl_ShaderProgram::GetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : GetAttribute
// purpose : Returns the integer vertex attribute
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::GetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
OpenGl_Vec4i& theValue) const
{
return GetAttribute (theCtx, GetAttributeLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : GetAttribute
// purpose : Returns the integer vertex attribute
@@ -905,17 +872,6 @@ Standard_Boolean OpenGl_ShaderProgram::GetAttribute (const Handle(OpenGl_Context
return Standard_True;
}
// =======================================================================
// function : GetAttribute
// purpose : Returns the floating-point vertex attribute
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::GetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
OpenGl_Vec4& theValue) const
{
return GetAttribute (theCtx, GetAttributeLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : GetAttribute
// purpose : Returns the floating-point vertex attribute
@@ -945,17 +901,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetAttributeName (const Handle(OpenGl_Con
return Standard_True;
}
// =======================================================================
// function : SetAttribute
// purpose :
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
GLfloat theValue)
{
return SetAttribute (theCtx, GetAttributeLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetAttribute
// purpose :
@@ -973,17 +918,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetAttribute (const Handle(OpenGl_Context
return Standard_True;
}
// =======================================================================
// function : SetAttribute
// purpose :
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec2& theValue)
{
return SetAttribute (theCtx, GetAttributeLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetAttribute
// purpose :
@@ -1001,17 +935,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetAttribute (const Handle(OpenGl_Context
return Standard_True;
}
// =======================================================================
// function : SetAttribute
// purpose :
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec3& theValue)
{
return SetAttribute (theCtx, GetAttributeLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetAttribute
// purpose :
@@ -1029,17 +952,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetAttribute (const Handle(OpenGl_Context
return Standard_True;
}
// =======================================================================
// function : SetAttribute
// purpose :
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec4& theValue)
{
return SetAttribute (theCtx, GetAttributeLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetAttribute
// purpose :
@@ -1057,17 +969,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetAttribute (const Handle(OpenGl_Context
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the integer uniform variable
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
GLint theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the integer uniform variable
@@ -1085,17 +986,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose :
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec2u& theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose :
@@ -1167,17 +1057,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return false;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform variable
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
GLfloat theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform variable
@@ -1195,17 +1074,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the integer uniform 2D vector
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec2i& theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the integer uniform 2D vector
@@ -1223,17 +1091,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the integer uniform 3D vector
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec3i& theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the integer uniform 3D vector
@@ -1251,17 +1108,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the integer uniform 4D vector
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec4i& theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the integer uniform 4D vector
@@ -1279,17 +1125,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 2D vector
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec2& theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 2D vector
@@ -1307,17 +1142,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 3D vector
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec3& theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 3D vector
@@ -1335,17 +1159,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 4D vector
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec4& theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 4D vector
@@ -1365,14 +1178,20 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 4x4 matrix
// purpose :
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Mat4& theValue,
GLboolean theTranspose)
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const NCollection_Mat3<float>* theData)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue, theTranspose);
if (myProgramID == NO_PROGRAM || theLocation == INVALID_LOCATION)
{
return Standard_False;
}
theCtx->core20fwd->glUniformMatrix3fv (theLocation, theCount, GL_FALSE, theData->GetData());
return Standard_True;
}
// =======================================================================
@@ -1389,34 +1208,10 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_False;
}
theCtx->core20fwd->glUniformMatrix4fv (theLocation, 1, GL_FALSE, theTranspose ? theValue.Transposed() : theValue);
theCtx->core20fwd->glUniformMatrix4fv (theLocation, 1, GL_FALSE, theTranspose ? theValue.Transposed().GetData() : theValue.GetData());
return Standard_True;
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 4x4 matrix
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Matrix& theValue,
GLboolean theTranspose)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue, theTranspose);
}
// =======================================================================
// function : SetUniform
// purpose : Specifies the value of the floating-point uniform 4x4 matrix
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Matrix& theValue,
GLboolean theTranspose)
{
return SetUniform (theCtx, theLocation, OpenGl_Mat4::Map (*theValue.mat), theTranspose);
}
// =======================================================================
// function : SetUniform
// purpose :
@@ -1579,17 +1374,6 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return Standard_True;
}
// =======================================================================
// function : SetSampler
// purpose : Specifies the value of the sampler uniform variable
// =======================================================================
Standard_Boolean OpenGl_ShaderProgram::SetSampler (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const Graphic3d_TextureUnit theTextureUnit)
{
return SetSampler (theCtx, GetUniformLocation (theCtx, theName), theTextureUnit);
}
// =======================================================================
// function : SetSampler
// purpose : Specifies the value of the sampler uniform variable

View File

@@ -25,7 +25,6 @@
#include <Graphic3d_TextureSetBits.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_Matrix.hxx>
#include <OpenGl_NamedResource.hxx>
#include <OpenGl_ShaderObject.hxx>
@@ -340,43 +339,46 @@ public:
public:
//! Returns the value of the integer uniform variable.
Standard_EXPORT Standard_Boolean GetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
OpenGl_Vec4i& theValue) const;
//! Returns the value of the uniform variable from given name.
template<typename ValueType>
bool GetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
ValueType& theValue) const
{
return GetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
//! Returns the value of the integer uniform variable.
//! Wrapper for glGetUniformiv()
Standard_EXPORT Standard_Boolean GetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
OpenGl_Vec4i& theValue) const;
//! Returns the value of the float uniform variable.
Standard_EXPORT Standard_Boolean GetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
OpenGl_Vec4& theValue) const;
//! Returns the value of the float uniform variable.
//! Wrapper for glGetUniformfv()
Standard_EXPORT Standard_Boolean GetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
OpenGl_Vec4& theValue) const;
public:
//! Returns the integer vertex attribute.
Standard_EXPORT Standard_Boolean GetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
OpenGl_Vec4i& theValue) const;
//! Returns the vertex attribute from given name.
template<typename ValueType>
bool GetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
ValueType& theValue) const
{
return GetAttribute (theCtx, GetAttributeLocation (theCtx, theName), theValue);
}
//! Returns the integer vertex attribute.
//! Wrapper for glGetVertexAttribiv()
Standard_EXPORT Standard_Boolean GetAttribute (const Handle(OpenGl_Context)& theCtx,
GLint theIndex,
OpenGl_Vec4i& theValue) const;
//! Returns the float vertex attribute.
Standard_EXPORT Standard_Boolean GetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
OpenGl_Vec4& theValue) const;
//! Returns the float vertex attribute.
//! Wrapper for glGetVertexAttribfv()
Standard_EXPORT Standard_Boolean GetAttribute (const Handle(OpenGl_Context)& theCtx,
GLint theIndex,
OpenGl_Vec4& theValue) const;
@@ -388,41 +390,30 @@ public:
GLint theIndex,
const GLchar* theName);
//! Wrapper for glVertexAttrib1f()
Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
GLfloat theValue);
//! Wrapper for glVertexAttrib*() for attribute with the given name.
template<typename ValueType>
bool SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const ValueType& theValue)
{
return SetAttribute (theCtx, GetAttributeLocation (theCtx, theName), theValue);
}
//! Wrapper for glVertexAttrib1f()
Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
GLint theIndex,
GLfloat theValue);
//! Wrapper for glVertexAttrib2fv()
Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec2& theValue);
//! Wrapper for glVertexAttrib2fv()
Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
GLint theIndex,
const OpenGl_Vec2& theValue);
//! Wrapper for glVertexAttrib3fv()
Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec3& theValue);
//! Wrapper for glVertexAttrib3fv()
Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
GLint theIndex,
const OpenGl_Vec3& theValue);
//! Wrapper for glVertexAttrib4fv()
Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec4& theValue);
//! Wrapper for glVertexAttrib4fv()
Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
GLint theIndex,
@@ -430,42 +421,35 @@ public:
public:
//! Specifies the value of the integer uniform variable.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
GLint theValue);
//! Specifies the value of the uniform variable with given name.
template<typename ValueType>
bool SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const ValueType& theValue)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
}
//! Specifies the value of the integer uniform variable.
//! Wrapper for glUniform1i()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLint theValue);
//! Specifies the value of the integer uniform 2D vector.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec2i& theValue);
//! Specifies the value of the integer uniform 2D vector.
//! Wrapper for glUniform2iv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Vec2i& theValue);
//! Specifies the value of the integer uniform 3D vector.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec3i& theValue);
//! Specifies the value of the integer uniform 3D vector.
//! Wrapper for glUniform3iv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Vec3i& theValue);
//! Specifies the value of the integer uniform 4D vector.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec4i& theValue);
//! Specifies the value of the integer uniform 4D vector.
//! Wrapper for glUniform4iv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Vec4i& theValue);
@@ -473,22 +457,20 @@ public:
public:
//! Specifies the value of the unsigned integer uniform 2D vector (uvec2).
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec2u& theValue);
//! Specifies the value of the unsigned integer uniform 2D vector (uvec2).
//! Wrapper for glUniform2uiv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Vec2u& theValue);
//! Specifies the value of the uvec2 uniform array
//! Wrapper for glUniform2uiv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const GLsizei theCount,
const OpenGl_Vec2u* theValue);
//! Specifies the value of the uvec2 uniform array
//! Wrapper for glUniform2uiv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const GLsizei theCount,
@@ -497,54 +479,50 @@ public:
public:
//! Specifies the value of the float uniform variable.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
GLfloat theValue);
//! Specifies the value of the float uniform variable.
//! Wrapper for glUniform1f()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLfloat theValue);
//! Specifies the value of the float uniform 2D vector.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec2& theValue);
//! Specifies the value of the float uniform 2D vector.
//! Wrapper for glUniform2fv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Vec2& theValue);
//! Specifies the value of the float uniform 3D vector.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec3& theValue);
//! Specifies the value of the float uniform 3D vector.
//! Wrapper for glUniform3fv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Vec3& theValue);
//! Specifies the value of the float uniform 4D vector.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Vec4& theValue);
//! Specifies the value of the float uniform 4D vector.
//! Wrapper for glUniform4fv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Vec4& theValue);
public:
//! Specifies the value of the float uniform 4x4 matrix.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Mat4& theValue,
GLboolean theTranspose = GL_FALSE);
//! Specifies the value of the array of float uniform 3x3 matrices.
//! Wrapper over glUniformMatrix3fv().
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const NCollection_Mat3<float>* theData);
//! Specifies the value of the float uniform 4x4 matrix.
//! Wrapper for glUniformMatrix4fv()
bool SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Mat4& theValue,
GLboolean theTranspose = GL_FALSE)
{
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue, theTranspose);
}
//! Specifies the value of the float uniform 4x4 matrix.
//! Wrapper for glUniformMatrix4fv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Mat4& theValue,
@@ -557,61 +535,57 @@ public:
GLuint theCount,
const OpenGl_Mat4* theData);
//! Specifies the value of the float uniform 4x4 matrix.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const OpenGl_Matrix& theValue,
GLboolean theTranspose = GL_FALSE);
//! Specifies the value of the float uniform 4x4 matrix.
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
const OpenGl_Matrix& theValue,
GLboolean theTranspose = GL_FALSE);
//! Specifies the value of the float uniform array
//! Wrapper over glUniform1fv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const Standard_ShortReal* theData);
//! Specifies the value of the float2 uniform array
//! Wrapper over glUniform2fv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const OpenGl_Vec2* theData);
//! Specifies the value of the float3 uniform array
//! Wrapper over glUniform3fv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const OpenGl_Vec3* theData);
//! Specifies the value of the float4 uniform array
//! Wrapper over glUniform4fv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const OpenGl_Vec4* theData);
//! Specifies the value of the integer uniform array
//! Wrapper over glUniform1iv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const Standard_Integer* theData);
//! Specifies the value of the int2 uniform array
//! Wrapper over glUniform2iv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const OpenGl_Vec2i* theData);
//! Specifies the value of the int3 uniform array
//! Wrapper over glUniform3iv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
const OpenGl_Vec3i* theData);
//! Specifies the value of the int4 uniform array
//! Wrapper over glUniform4iv()
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
GLint theLocation,
GLuint theCount,
@@ -620,9 +594,12 @@ public:
public:
//! Specifies the value of the sampler uniform variable.
Standard_EXPORT Standard_Boolean SetSampler (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const Graphic3d_TextureUnit theTextureUnit);
bool SetSampler (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName,
const Graphic3d_TextureUnit theTextureUnit)
{
return SetSampler (theCtx, GetUniformLocation (theCtx, theName), theTextureUnit);
}
//! Specifies the value of the sampler uniform variable.
Standard_EXPORT Standard_Boolean SetSampler (const Handle(OpenGl_Context)& theCtx,

View File

@@ -23,7 +23,6 @@
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_Group.hxx>
#include <OpenGl_Matrix.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_Workspace.hxx>

View File

@@ -53,8 +53,6 @@
#include <map>
#include <set>
struct OpenGl_Matrix;
class Graphic3d_StructureManager;
class OpenGl_DepthPeeling;
class OpenGl_GraphicDriver;

View File

@@ -34,21 +34,6 @@
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
namespace
{
static const OpenGl_Vec4 THE_WHITE_COLOR (1.0f, 1.0f, 1.0f, 1.0f);
static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f);
static const OpenGl_Matrix myDefaultMatrix =
{
{{ 1.0F, 0.0F, 0.0F, 0.0F },
{ 0.0F, 1.0F, 0.0F, 0.0F },
{ 0.0F, 0.0F, 1.0F, 0.0F },
{ 0.0F, 0.0F, 0.0F, 1.0F }}
};
}
// =======================================================================
// function : Init
// purpose :
@@ -133,10 +118,7 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
//
myAspectsSet (&myDefaultAspects),
//
ViewMatrix_applied (&myDefaultMatrix),
StructureMatrix_applied (&myDefaultMatrix),
myToAllowFaceCulling (false),
myModelViewMatrix (myDefaultMatrix)
myToAllowFaceCulling (false)
{
if (!myGlContext.IsNull() && myGlContext->MakeCurrent())
{
@@ -186,9 +168,6 @@ Standard_Boolean OpenGl_Workspace::Activate()
return Standard_False;
}
ViewMatrix_applied = &myDefaultMatrix;
StructureMatrix_applied = &myDefaultMatrix;
if (myGlContext->core11ffp == NULL)
{
if (myGlContext->caps->ffpEnable)

View File

@@ -22,7 +22,6 @@
#include <OpenGl_CappingAlgo.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_Material.hxx>
#include <OpenGl_Matrix.hxx>
#include <OpenGl_ShaderObject.hxx>
#include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_TextureBufferArb.hxx>
@@ -188,12 +187,6 @@ public:
//! @sa OpenGl_LayerList::Render()
void ResetSkippedCounter() { myNbSkippedTranspElems = 0; }
//! @return applied view matrix.
inline const OpenGl_Matrix* ViewMatrix() const { return ViewMatrix_applied; }
//! @return applied model structure matrix.
inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
//! Returns face aspect for none culling mode.
const OpenGl_Aspects& NoneCulling() const { return myNoneCulling; }
@@ -230,14 +223,9 @@ protected: //! @name fields related to status
Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
const OpenGl_Matrix* ViewMatrix_applied;
const OpenGl_Matrix* StructureMatrix_applied;
bool myToAllowFaceCulling; //!< allow back face culling
Handle(Graphic3d_PresentationAttributes) myHighlightStyle; //!< active highlight style
OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
OpenGl_Aspects myAspectFaceHl; //!< Hiddenline aspect
Handle(OpenGl_TextureSet) myEnvironmentTexture;