2015-12-08 07:31:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-07-19 17:35:25 +00:00
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2021-01-02 21:05:29 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-08 07:31:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-01-02 21:05:29 +00:00
|
|
|
* @file clayer_triangles.cpp
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "layer_triangles.h"
|
2021-01-05 22:19:00 +00:00
|
|
|
#include "../3d_render_raytracing/ray.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <wx/debug.h> // For the wxASSERT
|
2018-09-21 04:23:15 +00:00
|
|
|
#include <mutex>
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_LIST::TRIANGLE_LIST( unsigned int aNrReservedTriangles, bool aReserveNormals )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNrReservedTriangles > 0 );
|
|
|
|
|
|
|
|
m_vertexs.clear();
|
|
|
|
m_normals.clear();
|
|
|
|
|
|
|
|
m_vertexs.reserve( aNrReservedTriangles * 3 );
|
|
|
|
|
|
|
|
if( aReserveNormals )
|
|
|
|
m_normals.reserve( aNrReservedTriangles * 3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void TRIANGLE_LIST::Reserve_More( unsigned int aNrReservedTriangles, bool aReserveNormals )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
m_vertexs.reserve( m_vertexs.size() + aNrReservedTriangles * 3 );
|
|
|
|
|
|
|
|
if( aReserveNormals )
|
|
|
|
m_normals.reserve( m_normals.size() + aNrReservedTriangles * 3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void TRIANGLE_LIST::AddQuad( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3,
|
|
|
|
const SFVEC3F& aV4 )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
m_vertexs.push_back( aV1 );
|
|
|
|
m_vertexs.push_back( aV2 );
|
|
|
|
m_vertexs.push_back( aV3 );
|
|
|
|
|
|
|
|
m_vertexs.push_back( aV3 );
|
|
|
|
m_vertexs.push_back( aV4 );
|
|
|
|
m_vertexs.push_back( aV1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void TRIANGLE_LIST::AddTriangle( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3 )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
m_vertexs.push_back( aV1 );
|
|
|
|
m_vertexs.push_back( aV2 );
|
|
|
|
m_vertexs.push_back( aV3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void TRIANGLE_LIST::AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3 )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
m_normals.push_back( aN1 );
|
|
|
|
m_normals.push_back( aN2 );
|
|
|
|
m_normals.push_back( aN3 );
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void TRIANGLE_LIST::AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3,
|
|
|
|
const SFVEC3F& aN4 )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
m_normals.push_back( aN1 );
|
|
|
|
m_normals.push_back( aN2 );
|
|
|
|
m_normals.push_back( aN3 );
|
|
|
|
|
|
|
|
m_normals.push_back( aN3 );
|
|
|
|
m_normals.push_back( aN4 );
|
|
|
|
m_normals.push_back( aN1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_DISPLAY_LIST::TRIANGLE_DISPLAY_LIST( unsigned int aNrReservedTriangles )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNrReservedTriangles > 0 );
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
m_layer_top_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false );
|
|
|
|
m_layer_top_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false );
|
|
|
|
m_layer_middle_contourns_quads = new TRIANGLE_LIST( aNrReservedTriangles, true );
|
|
|
|
m_layer_bot_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false );
|
|
|
|
m_layer_bot_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_DISPLAY_LIST::~TRIANGLE_DISPLAY_LIST()
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
delete m_layer_top_segment_ends;
|
|
|
|
m_layer_top_segment_ends = 0;
|
|
|
|
|
|
|
|
delete m_layer_top_triangles;
|
|
|
|
m_layer_top_triangles = 0;
|
|
|
|
|
|
|
|
delete m_layer_middle_contourns_quads;
|
|
|
|
m_layer_middle_contourns_quads = 0;
|
|
|
|
|
|
|
|
delete m_layer_bot_triangles;
|
|
|
|
m_layer_bot_triangles = 0;
|
|
|
|
|
|
|
|
delete m_layer_bot_segment_ends;
|
|
|
|
m_layer_bot_segment_ends = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >& aContournPoints,
|
|
|
|
float zBot, float zTop, bool aInvertFaceDirection,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2019-02-02 16:59:53 +00:00
|
|
|
if( aContournPoints.size() >= 4 )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// Calculate normals of each segment of the contourn
|
|
|
|
std::vector< SFVEC2F > contournNormals;
|
|
|
|
|
|
|
|
contournNormals.clear();
|
|
|
|
contournNormals.resize( aContournPoints.size() - 1 );
|
|
|
|
|
|
|
|
if( aInvertFaceDirection )
|
|
|
|
{
|
|
|
|
for( unsigned int i = 0; i < ( aContournPoints.size() - 1 ); ++i )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& v0 = aContournPoints[i + 0];
|
|
|
|
const SFVEC2F& v1 = aContournPoints[i + 1];
|
2016-07-19 17:35:25 +00:00
|
|
|
const SFVEC2F n = glm::normalize( v1 - v0 );
|
|
|
|
|
|
|
|
contournNormals[i] = SFVEC2F( n.y,-n.x );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( unsigned int i = 0; i < ( aContournPoints.size() - 1 ); ++i )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& v0 = aContournPoints[i + 0];
|
|
|
|
const SFVEC2F& v1 = aContournPoints[i + 1];
|
2016-07-19 17:35:25 +00:00
|
|
|
const SFVEC2F n = glm::normalize( v1 - v0 );
|
|
|
|
|
|
|
|
contournNormals[i] = SFVEC2F( -n.y, n.x );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( aInvertFaceDirection )
|
|
|
|
std::swap( zBot, zTop );
|
|
|
|
|
|
|
|
const unsigned int nContournsToProcess = ( aContournPoints.size() - 1 );
|
|
|
|
|
|
|
|
for( unsigned int i = 0; i < nContournsToProcess; ++i )
|
|
|
|
{
|
|
|
|
SFVEC2F lastNormal;
|
|
|
|
|
|
|
|
if( i > 0 )
|
|
|
|
lastNormal = contournNormals[i - 1];
|
|
|
|
else
|
|
|
|
lastNormal = contournNormals[nContournsToProcess - 1];
|
|
|
|
|
|
|
|
SFVEC2F n0 = contournNormals[i];
|
|
|
|
|
|
|
|
// Only interpolate the normal if the angle is closer
|
|
|
|
if( glm::dot( n0, lastNormal ) > 0.5f )
|
|
|
|
n0 = glm::normalize( n0 + lastNormal );
|
|
|
|
|
|
|
|
SFVEC2F nextNormal;
|
|
|
|
|
|
|
|
if( i < (nContournsToProcess - 1) )
|
|
|
|
nextNormal = contournNormals[i + 1];
|
|
|
|
else
|
|
|
|
nextNormal = contournNormals[0];
|
|
|
|
|
|
|
|
SFVEC2F n1 = contournNormals[i];
|
|
|
|
|
|
|
|
if( glm::dot( n1, nextNormal ) > 0.5f )
|
|
|
|
n1 = glm::normalize( n1 + nextNormal );
|
|
|
|
|
|
|
|
const SFVEC3F n3d0 = SFVEC3F( n0.x, n0.y, 0.0f );
|
|
|
|
const SFVEC3F n3d1 = SFVEC3F( n1.x, n1.y, 0.0f );
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& v0 = aContournPoints[i + 0];
|
|
|
|
const SFVEC2F& v1 = aContournPoints[i + 1];
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-11-04 09:36:41 +00:00
|
|
|
if( aThroughHoles && aThroughHoles->IntersectAny( RAYSEG2D( v0, v1 ) ) )
|
2021-01-02 21:05:29 +00:00
|
|
|
{
|
2020-11-04 09:36:41 +00:00
|
|
|
continue;
|
2021-01-02 21:05:29 +00:00
|
|
|
}
|
2020-11-04 09:36:41 +00:00
|
|
|
else
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-09-21 04:23:15 +00:00
|
|
|
std::lock_guard<std::mutex> lock( m_middle_layer_lock );
|
2016-07-19 17:35:25 +00:00
|
|
|
m_layer_middle_contourns_quads->AddQuad( SFVEC3F( v0.x, v0.y, zTop ),
|
|
|
|
SFVEC3F( v1.x, v1.y, zTop ),
|
|
|
|
SFVEC3F( v1.x, v1.y, zBot ),
|
|
|
|
SFVEC3F( v0.x, v0.y, zBot ) );
|
|
|
|
|
|
|
|
m_layer_middle_contourns_quads->AddNormal( n3d0, n3d1, n3d1, n3d0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_LINE_CHAIN& outlinePath, float zBot,
|
|
|
|
float zTop, double aBiuTo3Du,
|
|
|
|
bool aInvertFaceDirection,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
std::vector< SFVEC2F >contournPoints;
|
|
|
|
|
|
|
|
contournPoints.clear();
|
|
|
|
contournPoints.reserve( outlinePath.PointCount() + 2 );
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const VECTOR2I& firstV = outlinePath.CPoint( 0 );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC2F lastV = SFVEC2F( firstV.x * aBiuTo3Du, -firstV.y * aBiuTo3Du );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
contournPoints.push_back( lastV );
|
|
|
|
|
|
|
|
for( unsigned int i = 1; i < (unsigned int)outlinePath.PointCount(); ++i )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const VECTOR2I& v = outlinePath.CPoint( i );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F vf = SFVEC2F( v.x * aBiuTo3Du, -v.y * aBiuTo3Du );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( vf != lastV ) // Do not add repeated points
|
|
|
|
{
|
|
|
|
lastV = vf;
|
|
|
|
contournPoints.push_back( vf );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add first position fo the list to close the path
|
|
|
|
if( lastV != contournPoints[0] )
|
|
|
|
contournPoints.push_back( contournPoints[0] );
|
|
|
|
|
2020-11-04 09:36:41 +00:00
|
|
|
AddToMiddleContourns( contournPoints, zBot, zTop, aInvertFaceDirection, aThroughHoles );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_POLY_SET& aPolySet, float zBot,
|
|
|
|
float zTop, double aBiuTo3Du,
|
|
|
|
bool aInvertFaceDirection,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
if( aPolySet.OutlineCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Calculate an estimation of points to reserve
|
|
|
|
unsigned int nrContournPointsToReserve = 0;
|
|
|
|
|
|
|
|
for( int i = 0; i < aPolySet.OutlineCount(); ++i )
|
|
|
|
{
|
|
|
|
const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i );
|
|
|
|
|
|
|
|
nrContournPointsToReserve += pathOutline.PointCount();
|
|
|
|
|
|
|
|
for( int h = 0; h < aPolySet.HoleCount( i ); ++h )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SHAPE_LINE_CHAIN& hole = aPolySet.CHole( i, h );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
nrContournPointsToReserve += hole.PointCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Request to reserve more space
|
2021-01-02 21:05:29 +00:00
|
|
|
m_layer_middle_contourns_quads->Reserve_More( nrContournPointsToReserve * 2, true );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-12-11 03:49:21 +00:00
|
|
|
for( int i = 0; i < aPolySet.OutlineCount(); i++ )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-12-11 03:49:21 +00:00
|
|
|
// Add outline
|
|
|
|
const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i );
|
2018-09-21 04:23:15 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
AddToMiddleContourns( pathOutline, zBot, zTop, aBiuTo3Du, aInvertFaceDirection,
|
|
|
|
aThroughHoles );
|
2018-09-21 04:23:15 +00:00
|
|
|
|
2018-12-11 03:49:21 +00:00
|
|
|
// Add holes for this outline
|
|
|
|
for( int h = 0; h < aPolySet.HoleCount( i ); ++h )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SHAPE_LINE_CHAIN& hole = aPolySet.CHole( i, h );
|
|
|
|
AddToMiddleContourns( hole, zBot, zTop, aBiuTo3Du, aInvertFaceDirection,
|
|
|
|
aThroughHoles );
|
2018-12-11 03:49:21 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
OPENGL_RENDER_LIST::OPENGL_RENDER_LIST( const TRIANGLE_DISPLAY_LIST& aLayerTriangles,
|
2021-01-05 22:19:00 +00:00
|
|
|
GLuint aTextureIndexForSegEnds,
|
|
|
|
float aZBot, float aZTop )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
m_zBot = aZBot;
|
|
|
|
m_zTop = aZTop;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
m_layer_top_segment_ends = 0;
|
|
|
|
m_layer_top_triangles = 0;
|
|
|
|
m_layer_middle_contourns_quads = 0;
|
|
|
|
m_layer_bot_triangles = 0;
|
|
|
|
m_layer_bot_segment_ends = 0;
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( aTextureIndexForSegEnds )
|
|
|
|
{
|
|
|
|
wxASSERT( glIsTexture( aTextureIndexForSegEnds ) );
|
|
|
|
|
|
|
|
if( glIsTexture( aTextureIndexForSegEnds ) )
|
|
|
|
{
|
|
|
|
m_layer_top_segment_ends =
|
|
|
|
generate_top_or_bot_seg_ends( aLayerTriangles.m_layer_top_segment_ends,
|
2021-01-02 21:05:29 +00:00
|
|
|
true, aTextureIndexForSegEnds );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
m_layer_bot_segment_ends =
|
|
|
|
generate_top_or_bot_seg_ends( aLayerTriangles.m_layer_bot_segment_ends,
|
2021-01-02 21:05:29 +00:00
|
|
|
false, aTextureIndexForSegEnds );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_layer_top_triangles = generate_top_or_bot_triangles( aLayerTriangles.m_layer_top_triangles,
|
|
|
|
true );
|
|
|
|
|
|
|
|
m_layer_bot_triangles = generate_top_or_bot_triangles( aLayerTriangles.m_layer_bot_triangles,
|
|
|
|
false );
|
|
|
|
|
|
|
|
|
|
|
|
if( aLayerTriangles.m_layer_middle_contourns_quads->GetVertexSize() > 0 )
|
|
|
|
{
|
|
|
|
m_layer_middle_contourns_quads =
|
|
|
|
generate_middle_triangles( aLayerTriangles.m_layer_middle_contourns_quads );
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
m_draw_it_transparent = false;
|
|
|
|
m_haveTransformation = false;
|
|
|
|
m_zPositionTransformation = 0.0f;
|
|
|
|
m_zScaleTransformation = 0.0f;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
OPENGL_RENDER_LIST::~OPENGL_RENDER_LIST()
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
if( glIsList( m_layer_top_segment_ends ) )
|
|
|
|
glDeleteLists( m_layer_top_segment_ends, 1 );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_top_triangles ) )
|
|
|
|
glDeleteLists( m_layer_top_triangles, 1 );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_middle_contourns_quads ) )
|
|
|
|
glDeleteLists( m_layer_middle_contourns_quads, 1 );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_bot_triangles ) )
|
|
|
|
glDeleteLists( m_layer_bot_triangles, 1 );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_bot_segment_ends ) )
|
|
|
|
glDeleteLists( m_layer_bot_segment_ends, 1 );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
m_layer_top_segment_ends = 0;
|
|
|
|
m_layer_top_triangles = 0;
|
|
|
|
m_layer_middle_contourns_quads = 0;
|
|
|
|
m_layer_bot_triangles = 0;
|
|
|
|
m_layer_bot_segment_ends = 0;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::DrawTopAndMiddle() const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
beginTransformation();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
if( glIsList( m_layer_middle_contourns_quads ) )
|
|
|
|
glCallList( m_layer_middle_contourns_quads );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( glIsList( m_layer_top_triangles ) )
|
|
|
|
glCallList( m_layer_top_triangles );
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
if( glIsList( m_layer_top_segment_ends ) )
|
|
|
|
glCallList( m_layer_top_segment_ends );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
endTransformation();
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::DrawBotAndMiddle() const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
beginTransformation();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
if( glIsList( m_layer_middle_contourns_quads ) )
|
|
|
|
glCallList( m_layer_middle_contourns_quads );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( glIsList( m_layer_bot_triangles ) )
|
|
|
|
glCallList( m_layer_bot_triangles );
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
if( glIsList( m_layer_bot_segment_ends ) )
|
|
|
|
glCallList( m_layer_bot_segment_ends );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
endTransformation();
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::DrawTop() const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
beginTransformation();
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
if( glIsList( m_layer_top_triangles ) )
|
|
|
|
glCallList( m_layer_top_triangles );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_top_segment_ends ) )
|
|
|
|
glCallList( m_layer_top_segment_ends );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
endTransformation();
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::DrawBot() const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
beginTransformation();
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
if( glIsList( m_layer_bot_triangles ) )
|
|
|
|
glCallList( m_layer_bot_triangles );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_bot_segment_ends ) )
|
|
|
|
glCallList( m_layer_bot_segment_ends );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
endTransformation();
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::DrawMiddle() const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
beginTransformation();
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
if( glIsList( m_layer_middle_contourns_quads ) )
|
|
|
|
glCallList( m_layer_middle_contourns_quads );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
endTransformation();
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::DrawAll( bool aDrawMiddle ) const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
beginTransformation();
|
|
|
|
|
|
|
|
if( aDrawMiddle )
|
|
|
|
if( glIsList( m_layer_middle_contourns_quads ) )
|
|
|
|
glCallList( m_layer_middle_contourns_quads );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
if( glIsList( m_layer_top_triangles ) )
|
|
|
|
glCallList( m_layer_top_triangles );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_bot_triangles ) )
|
|
|
|
glCallList( m_layer_bot_triangles );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_top_segment_ends ) )
|
|
|
|
glCallList( m_layer_top_segment_ends );
|
|
|
|
|
|
|
|
if( glIsList( m_layer_bot_segment_ends ) )
|
|
|
|
glCallList( m_layer_bot_segment_ends );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
endTransformation();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::DrawAllCameraCulled( float zCameraPos, bool aDrawMiddle ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
zCameraPos = m_haveTransformation
|
|
|
|
? ( ( zCameraPos - m_zPositionTransformation ) / m_zScaleTransformation )
|
|
|
|
: zCameraPos;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( aDrawMiddle )
|
|
|
|
DrawMiddle();
|
|
|
|
|
|
|
|
if( zCameraPos > m_zTop )
|
|
|
|
{
|
|
|
|
DrawTop();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( zCameraPos < m_zBot )
|
|
|
|
{
|
|
|
|
DrawBot();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
// If camera is in the middle dont draw it.
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::DrawAllCameraCulledSubtractLayer( bool aDrawMiddle,
|
|
|
|
const OPENGL_RENDER_LIST* aLayerToSubtractA,
|
|
|
|
const OPENGL_RENDER_LIST* aLayerToSubtractB,
|
|
|
|
const OPENGL_RENDER_LIST* aLayerToSubtractC,
|
|
|
|
const OPENGL_RENDER_LIST* aLayerToSubtractD ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
glClearStencil( 0x00 );
|
|
|
|
glClear( GL_STENCIL_BUFFER_BIT );
|
|
|
|
|
|
|
|
glEnable( GL_CULL_FACE );
|
|
|
|
glCullFace( GL_BACK );
|
|
|
|
|
|
|
|
glDisable( GL_DEPTH_TEST );
|
|
|
|
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
|
|
|
|
glDepthMask( GL_FALSE );
|
|
|
|
glEnable( GL_STENCIL_TEST );
|
|
|
|
glStencilFunc( GL_ALWAYS, 1, 0 );
|
|
|
|
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
|
|
|
|
|
|
|
|
if( aLayerToSubtractA )
|
|
|
|
aLayerToSubtractA->DrawBot();
|
|
|
|
|
|
|
|
if( aLayerToSubtractB )
|
|
|
|
aLayerToSubtractB->DrawBot();
|
|
|
|
|
2020-10-01 15:49:36 +00:00
|
|
|
if( aLayerToSubtractC )
|
|
|
|
aLayerToSubtractC->DrawBot();
|
|
|
|
|
2020-11-03 09:38:07 +00:00
|
|
|
if( aLayerToSubtractD )
|
|
|
|
aLayerToSubtractD->DrawBot();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthMask(GL_TRUE);
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
|
|
|
|
glStencilFunc( GL_EQUAL, 0, 1 );
|
|
|
|
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
|
|
|
|
DrawBot();
|
|
|
|
|
|
|
|
glDisable( GL_DEPTH_TEST );
|
|
|
|
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
|
|
|
|
glDepthMask( GL_FALSE );
|
|
|
|
glEnable( GL_STENCIL_TEST );
|
|
|
|
glStencilFunc( GL_ALWAYS, 2, 0 );
|
|
|
|
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
|
|
|
|
|
|
|
|
if( aLayerToSubtractA )
|
|
|
|
aLayerToSubtractA->DrawTop();
|
|
|
|
|
|
|
|
if( aLayerToSubtractB )
|
|
|
|
aLayerToSubtractB->DrawTop();
|
|
|
|
|
2020-10-01 15:49:36 +00:00
|
|
|
if( aLayerToSubtractC )
|
|
|
|
aLayerToSubtractC->DrawTop();
|
|
|
|
|
2020-11-03 09:38:07 +00:00
|
|
|
if( aLayerToSubtractD )
|
|
|
|
aLayerToSubtractD->DrawTop();
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthMask(GL_TRUE);
|
2016-07-19 17:35:25 +00:00
|
|
|
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
|
|
|
|
glStencilFunc( GL_NOTEQUAL, 2, 0x03 );
|
|
|
|
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
|
|
|
|
DrawTop();
|
|
|
|
|
2020-01-29 16:00:05 +00:00
|
|
|
if( aDrawMiddle )
|
|
|
|
DrawMiddle();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
|
|
|
|
|
|
|
|
glCullFace( GL_FRONT );
|
|
|
|
glStencilFunc( GL_GEQUAL, 3, 0x03 );
|
|
|
|
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
|
|
|
|
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
|
|
|
|
|
|
|
|
if( aDrawMiddle )
|
|
|
|
{
|
|
|
|
if( aLayerToSubtractA )
|
|
|
|
aLayerToSubtractA->DrawMiddle();
|
|
|
|
}
|
|
|
|
|
|
|
|
glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
|
|
|
|
|
|
|
|
glCullFace( GL_BACK );
|
|
|
|
glDisable( GL_STENCIL_TEST );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::ApplyScalePosition( float aZposition, float aZscale )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aZscale > FLT_EPSILON );
|
|
|
|
|
|
|
|
m_zPositionTransformation = aZposition;
|
|
|
|
m_zScaleTransformation = aZscale;
|
|
|
|
m_haveTransformation = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::SetItIsTransparent( bool aSetTransparent )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
m_draw_it_transparent = aSetTransparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
|
|
|
|
const TRIANGLE_LIST* aTriangleContainer, bool aIsNormalUp, GLuint aTextureId ) const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( aTriangleContainer != nullptr );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Top and Bot dont have normals array stored in container
|
2015-12-08 07:31:57 +00:00
|
|
|
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( ( aTriangleContainer->GetVertexSize() > 0 )
|
|
|
|
&& ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ) )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
GLuint listIdx = glGenLists( 1 );
|
|
|
|
|
|
|
|
if( glIsList( listIdx ) )
|
|
|
|
{
|
|
|
|
// Prepare an array of UV text coordinates
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC2F* uvArray = new SFVEC2F[aTriangleContainer->GetVertexSize()];
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
for( unsigned int i = 0; i < aTriangleContainer->GetVertexSize(); i += 3 )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
uvArray[i + 0] = SFVEC2F( 1.0f, 0.0f );
|
|
|
|
uvArray[i + 1] = SFVEC2F( 0.0f, 1.0f );
|
|
|
|
uvArray[i + 2] = SFVEC2F( 0.0f, 0.0f );
|
|
|
|
}
|
|
|
|
|
|
|
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
glDisableClientState( GL_COLOR_ARRAY );
|
|
|
|
glDisableClientState( GL_NORMAL_ARRAY );
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
|
|
|
|
glTexCoordPointer( 2, GL_FLOAT, 0, uvArray );
|
|
|
|
|
|
|
|
glNewList( listIdx, GL_COMPILE );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
glDisable( GL_COLOR_MATERIAL );
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
glEnable( GL_TEXTURE_2D );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, aTextureId );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
setBlendfunction();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
glAlphaFunc( GL_GREATER, 0.2f );
|
|
|
|
glEnable( GL_ALPHA_TEST );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
glNormal3f( 0.0f, 0.0f, aIsNormalUp?1.0f:-1.0f );
|
|
|
|
|
|
|
|
glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
|
|
|
|
|
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
glDisable( GL_ALPHA_TEST );
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
|
|
|
|
glEndList();
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
2016-04-05 10:32:22 +00:00
|
|
|
delete [] uvArray;
|
2015-12-08 07:31:57 +00:00
|
|
|
return listIdx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer,
|
|
|
|
bool aIsNormalUp ) const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( aTriangleContainer != nullptr );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Top and Bot dont have normals array stored in container
|
2015-12-08 07:31:57 +00:00
|
|
|
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( ( aTriangleContainer->GetVertexSize() > 0 )
|
|
|
|
&& ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ) )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
const GLuint listIdx = glGenLists( 1 );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
if( glIsList( listIdx ) )
|
|
|
|
{
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
glDisableClientState( GL_COLOR_ARRAY );
|
|
|
|
glDisableClientState( GL_NORMAL_ARRAY );
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
|
|
|
|
|
|
|
|
glNewList( listIdx, GL_COMPILE );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
setBlendfunction();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
glNormal3f( 0.0f, 0.0f, aIsNormalUp?1.0f:-1.0f );
|
|
|
|
|
|
|
|
glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
2015-12-08 07:31:57 +00:00
|
|
|
glEndList();
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
|
|
|
return listIdx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
GLuint OPENGL_RENDER_LIST::generate_middle_triangles(
|
|
|
|
const TRIANGLE_LIST* aTriangleContainer ) const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( aTriangleContainer != nullptr );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
// We expect that it is a multiple of 3 vertex
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
// We expect that it is a multiple of 6 vertex (because we expect to add quads)
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( (aTriangleContainer->GetVertexSize() % 6 ) == 0 );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
// We expect that there are normals with same size as vertex
|
|
|
|
wxASSERT( aTriangleContainer->GetNormalsSize() == aTriangleContainer->GetVertexSize() );
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( ( aTriangleContainer->GetVertexSize() > 0 )
|
|
|
|
&& ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 )
|
|
|
|
&& ( ( aTriangleContainer->GetVertexSize() % 6 ) == 0 )
|
|
|
|
&& ( aTriangleContainer->GetNormalsSize() == aTriangleContainer->GetVertexSize() ) )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
const GLuint listIdx = glGenLists( 1 );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
if( glIsList( listIdx ) )
|
|
|
|
{
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
glDisableClientState( GL_COLOR_ARRAY );
|
|
|
|
glEnableClientState( GL_NORMAL_ARRAY );
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
|
|
|
|
glNormalPointer( GL_FLOAT, 0, aTriangleContainer->GetNormalsPointer() );
|
|
|
|
|
|
|
|
glNewList( listIdx, GL_COMPILE );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
setBlendfunction();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
2015-12-08 07:31:57 +00:00
|
|
|
glEndList();
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_NORMAL_ARRAY );
|
|
|
|
|
|
|
|
return listIdx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::endTransformation() const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
if( m_haveTransformation )
|
|
|
|
{
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::setBlendfunction() const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void OPENGL_RENDER_LIST::beginTransformation() const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
if( m_haveTransformation )
|
|
|
|
{
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef( 0.0f, 0.0f, m_zPositionTransformation );
|
|
|
|
glScalef( 1.0f, 1.0f, m_zScaleTransformation );
|
|
|
|
}
|
|
|
|
}
|