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

Fix bugs with color buffer

This commit is contained in:
mzernova 2024-08-23 17:42:56 +01:00
parent 2192e732c8
commit 3a96f39808
15 changed files with 60 additions and 31 deletions

View File

@ -48,7 +48,7 @@ namespace
theTris->AddVertex (gp_Pnt (theXLeft, theYBottom + theSizeY, 0.0), theColorTop);
theTris->AddVertex (gp_Pnt (theXLeft + theSizeX, theYBottom + theSizeY, 0.0), theColorTop);
theTris->AddEdges (aVertIndex, aVertIndex + 1, aVertIndex + 2);
theTris->AddEdges (aVertIndex + 1, aVertIndex + 2, aVertIndex + 3);
theTris->AddEdges (aVertIndex + 1, aVertIndex + 3, aVertIndex + 2);
}
//! Compute hue angle from specified value.

View File

@ -20,11 +20,12 @@ typedef Standard_Integer Graphic3d_ArrayFlags;
//! Graphic3d_ArrayFlags bitmask values.
enum
{
Graphic3d_ArrayFlags_None = 0x00, //!< no flags
Graphic3d_ArrayFlags_VertexNormal = 0x01, //!< per-vertex normal attribute
Graphic3d_ArrayFlags_VertexColor = 0x02, //!< per-vertex color attribute
Graphic3d_ArrayFlags_VertexTexel = 0x04, //!< per-vertex texel coordinates (UV) attribute
Graphic3d_ArrayFlags_BoundColor = 0x10,
Graphic3d_ArrayFlags_None = 0x00, //!< no flags
Graphic3d_ArrayFlags_VertexNormal = 0x01, //!< per-vertex normal attribute
Graphic3d_ArrayFlags_VertexColor = 0x02, //!< per-vertex color attribute
Graphic3d_ArrayFlags_VertexColorBack = 0x04, //!< per-vertex color back attribute
Graphic3d_ArrayFlags_VertexTexel = 0x08, //!< per-vertex texel coordinates (UV) attribute
Graphic3d_ArrayFlags_BoundColor = 0x10,
// advanced
Graphic3d_ArrayFlags_AttribsMutable = 0x20, //!< mutable array, which can be invalidated during lifetime without re-creation
Graphic3d_ArrayFlags_AttribsDeinterleaved = 0x40, //!< non-interleaved vertex attributes packed into single array

View File

@ -38,10 +38,12 @@ public:
//! @param theHasVNormals when TRUE, AddVertex(Point,Normal) should be used for specifying vertex normal
Graphic3d_ArrayOfPoints (Standard_Integer theMaxVertexs,
Standard_Boolean theHasVColors = Standard_False,
Standard_Boolean theHasVNormals = Standard_False)
Standard_Boolean theHasVNormals = Standard_False,
Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POINTS, theMaxVertexs, 0, 0,
(theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasVNormals ? Graphic3d_ArrayFlags_VertexNormal : Graphic3d_ArrayFlags_None)) {}
| (theHasVNormals ? Graphic3d_ArrayFlags_VertexNormal : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}
};

View File

@ -106,12 +106,14 @@ public:
const Standard_Boolean theHasVNormals = Standard_False,
const Standard_Boolean theHasVColors = Standard_False,
const Standard_Boolean theHasBColors = Standard_False,
const Standard_Boolean theHasVTexels = Standard_False)
const Standard_Boolean theHasVTexels = Standard_False,
const Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYGONS, theMaxVertexs, theMaxBounds, theMaxEdges,
(theHasVNormals ? Graphic3d_ArrayFlags_VertexNormal : Graphic3d_ArrayFlags_None)
| (theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasBColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)) {}
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}
};

View File

@ -104,10 +104,12 @@ public:
Standard_Integer theMaxBounds = 0,
Standard_Integer theMaxEdges = 0,
Standard_Boolean theHasVColors = Standard_False,
Standard_Boolean theHasBColors = Standard_False)
Standard_Boolean theHasBColors = Standard_False,
Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYLINES, theMaxVertexs, theMaxBounds, theMaxEdges,
(theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasBColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)) {}
| (theHasBColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}
};

View File

@ -172,7 +172,9 @@ void Graphic3d_ArrayOfPrimitives::init (Graphic3d_TypeOfPrimitiveArray theType,
anAttribs[aNbAttribs].Id = Graphic3d_TOA_COLOR;
anAttribs[aNbAttribs].DataType = Graphic3d_TOD_VEC4UB;
++aNbAttribs;
}
if ((theArrayOptions & Graphic3d_ArrayFlags_VertexColorBack) != 0)
{
anAttribs[aNbAttribs].Id = Graphic3d_TOA_COLOR_BACK;
anAttribs[aNbAttribs].DataType = Graphic3d_TOD_VEC4UB;
++aNbAttribs;

View File

@ -806,7 +806,15 @@ protected: //! @name protected constructors
Standard_Integer theMaxBounds,
Standard_Integer theMaxEdges,
Graphic3d_ArrayFlags theArrayFlags)
: myNormData (NULL), myTexData (NULL), myColData (NULL), myColDataBack (NULL), myPosStride (0), myNormStride (0), myTexStride (0), myColStride (0),
: myNormData (NULL),
myTexData (NULL),
myColData (NULL),
myColDataBack (NULL),
myPosStride (0),
myNormStride (0),
myTexStride (0),
myColStride (0),
myColStrideBack (0),
myType (Graphic3d_TOPA_UNDEFINED)
{
init (theType, theMaxVertexs, theMaxBounds, theMaxEdges, theArrayFlags);

View File

@ -62,12 +62,14 @@ public:
Standard_Boolean theHasVNormals = Standard_False,
Standard_Boolean theHasVColors = Standard_False,
Standard_Boolean theHasSColors = Standard_False,
Standard_Boolean theHasVTexels = Standard_False)
Standard_Boolean theHasVTexels = Standard_False,
Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLESTRIPS, theMaxVertexs, theMaxStrips, 0,
(theHasVNormals ? Graphic3d_ArrayFlags_VertexNormal : Graphic3d_ArrayFlags_None)
| (theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)
| (theHasSColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)) {}
| (theHasSColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}

View File

@ -57,11 +57,13 @@ public:
Standard_Integer theMaxEdges = 0,
Standard_Boolean theHasVNormals = Standard_False,
Standard_Boolean theHasVColors = Standard_False,
Standard_Boolean theHasVTexels = Standard_False)
Standard_Boolean theHasVTexels = Standard_False,
Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLES, theMaxVertexs, 0, theMaxEdges,
(theHasVNormals ? Graphic3d_ArrayFlags_VertexNormal : Graphic3d_ArrayFlags_None)
| (theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)) {}
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}
};

View File

@ -56,8 +56,10 @@ public:
//! @param theHasVColors when TRUE, AddVertex(Point,Color) should be used for specifying vertex color
Graphic3d_ArrayOfSegments (Standard_Integer theMaxVertexs,
Standard_Integer theMaxEdges = 0,
Standard_Boolean theHasVColors = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_SEGMENTS, theMaxVertexs, 0, theMaxEdges, theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None) {}
Standard_Boolean theHasVColors = Standard_False,
Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_SEGMENTS, theMaxVertexs, 0, theMaxEdges, (theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}
};

View File

@ -60,12 +60,14 @@ public:
Standard_Boolean theHasVNormals = Standard_False,
Standard_Boolean theHasVColors = Standard_False,
Standard_Boolean theHasBColors = Standard_False,
Standard_Boolean theHasVTexels = Standard_False)
Standard_Boolean theHasVTexels = Standard_False,
Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLEFANS, theMaxVertexs, theMaxFans, 0,
(theHasVNormals ? Graphic3d_ArrayFlags_VertexNormal : Graphic3d_ArrayFlags_None)
| (theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)
| (theHasBColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)) {}
| (theHasBColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}
};

View File

@ -66,12 +66,14 @@ public:
Standard_Boolean theHasVNormals = Standard_False,
Standard_Boolean theHasVColors = Standard_False,
Standard_Boolean theHasBColors = Standard_False,
Standard_Boolean theHasVTexels = Standard_False)
Standard_Boolean theHasVTexels = Standard_False,
Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLESTRIPS, theMaxVertexs, theMaxStrips, 0,
(theHasVNormals ? Graphic3d_ArrayFlags_VertexNormal : Graphic3d_ArrayFlags_None)
| (theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)
| (theHasBColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)) {}
| (theHasBColors ? Graphic3d_ArrayFlags_BoundColor : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}
};

View File

@ -59,11 +59,13 @@ public:
Standard_Integer theMaxEdges = 0,
Standard_Boolean theHasVNormals = Standard_False,
Standard_Boolean theHasVColors = Standard_False,
Standard_Boolean theHasVTexels = Standard_False)
Standard_Boolean theHasVTexels = Standard_False,
Standard_Boolean theHasVColorsBack = Standard_False)
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLES, theMaxVertexs, 0, theMaxEdges,
(theHasVNormals ? Graphic3d_ArrayFlags_VertexNormal : Graphic3d_ArrayFlags_None)
| (theHasVColors ? Graphic3d_ArrayFlags_VertexColor : Graphic3d_ArrayFlags_None)
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)) {}
| (theHasVTexels ? Graphic3d_ArrayFlags_VertexTexel : Graphic3d_ArrayFlags_None)
| (theHasVColorsBack ? Graphic3d_ArrayFlags_VertexColorBack : Graphic3d_ArrayFlags_None)) {}
};

View File

@ -427,7 +427,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
myChartVertices->Bind (aCtx);
myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_POS, 3, GL_FLOAT, myChartVertices->GetComponentsNb(), NULL);
myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_COLOR, 4, GL_UNSIGNED_BYTE, myChartVertices->GetComponentsNb(), (void* )sizeof(Graphic3d_Vec3));
myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_COLOR_BACK, 5, GL_UNSIGNED_BYTE, myChartVertices->GetComponentsNb(), (void*)sizeof(Graphic3d_Vec3));
myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_COLOR_BACK, 4, GL_UNSIGNED_BYTE, myChartVertices->GetComponentsNb(), (void*)sizeof(Graphic3d_Vec3));
myChartIndices->Bind (aCtx);
aCtx->core15fwd->glDrawElements (GL_TRIANGLES, myChartIndices->GetElemsNb(), myChartIndices->GetDataType(), NULL);
@ -441,7 +441,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
myChartLines->Bind (aCtx);
myChartLines->bindAttribute (aCtx, Graphic3d_TOA_POS, 3, GL_FLOAT, myChartLines->GetComponentsNb(), NULL);
myChartLines->bindAttribute (aCtx, Graphic3d_TOA_COLOR, 4, GL_UNSIGNED_BYTE, myChartLines->GetComponentsNb(), (void* )sizeof(Graphic3d_Vec3));
myChartLines->bindAttribute (aCtx, Graphic3d_TOA_COLOR_BACK, 5, GL_UNSIGNED_BYTE, myChartLines->GetComponentsNb(), (void*)sizeof(Graphic3d_Vec3));
myChartLines->bindAttribute (aCtx, Graphic3d_TOA_COLOR_BACK, 4, GL_UNSIGNED_BYTE, myChartLines->GetComponentsNb(), (void*)sizeof(Graphic3d_Vec3));
aCtx->core15fwd->glDrawArrays (GL_LINES, 0, myChartLines->GetElemsNb());
myChartLines->Unbind (aCtx);
myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_COLOR_BACK);

View File

@ -205,7 +205,7 @@ void OpenGl_VertexBuffer::bindFixed (const Handle(OpenGl_Context)& theCtx,
{
theCtx->core11ffp->glEnableClientState (GL_COLOR_ARRAY);
theCtx->core11ffp->glColorPointer (theNbComp, theDataType, theStride, theOffset);
theCtx->core11ffp->glColorMaterial (GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
theCtx->core11ffp->glColorMaterial (GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
theCtx->core11fwd->glEnable (GL_COLOR_MATERIAL);
return;
}
@ -236,8 +236,8 @@ void OpenGl_VertexBuffer::unbindFixed (const Handle(OpenGl_Context)& theCtx,
case Graphic3d_TOA_POS: theCtx->core11ffp->glDisableClientState (GL_VERTEX_ARRAY); return;
case Graphic3d_TOA_NORM: theCtx->core11ffp->glDisableClientState (GL_NORMAL_ARRAY); return;
case Graphic3d_TOA_UV: theCtx->core11ffp->glDisableClientState (GL_TEXTURE_COORD_ARRAY); return;
case Graphic3d_TOA_COLOR: unbindFixedColor (theCtx); return;
case Graphic3d_TOA_COLOR_BACK:
case Graphic3d_TOA_COLOR: unbindFixedColor (theCtx); return;
case Graphic3d_TOA_COLOR_BACK: unbindFixedColor (theCtx); return;
case Graphic3d_TOA_CUSTOM:
{
return;