0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / OpenGl / OpenGl_PointSprite.cxx
CommitLineData
a577aaab 1// Created by: Kirill GAVRILOV
d5f74e42 2// Copyright (c) 2013-2014 OPEN CASCADE SAS
a577aaab 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
a577aaab 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
a577aaab 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
a577aaab 14
15#include <OpenGl_PointSprite.hxx>
16
17#include <Graphic3d_TextureParams.hxx>
18#include <OpenGl_Context.hxx>
cc8cbabe 19#include <OpenGl_Sampler.hxx>
a577aaab 20#include <Standard_Assert.hxx>
a577aaab 21
92efcf78 22IMPLEMENT_STANDARD_RTTIEXT(OpenGl_PointSprite,OpenGl_Texture)
23
a577aaab 24// =======================================================================
25// function : OpenGl_PointSprite
26// purpose :
27// =======================================================================
cc8cbabe 28OpenGl_PointSprite::OpenGl_PointSprite (const TCollection_AsciiString& theResourceId)
29: OpenGl_Texture (theResourceId, Handle(Graphic3d_TextureParams)()),
a577aaab 30 myBitmapList (0)
31{
cc8cbabe 32 //mySampler->Parameters()->SetFilter (Graphic3d_TOTF_NEAREST);
33 mySampler->Parameters()->SetModulate (Standard_False);
34 mySampler->Parameters()->SetGenMode (Graphic3d_TOTM_SPRITE,
35 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f),
36 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
a577aaab 37}
38
39// =======================================================================
40// function : ~OpenGl_PointSprite
41// purpose :
42// =======================================================================
43OpenGl_PointSprite::~OpenGl_PointSprite()
44{
45 Release (NULL);
46}
47
48// =======================================================================
49// function : Release
50// purpose :
51// =======================================================================
10b9c7df 52void OpenGl_PointSprite::Release (OpenGl_Context* theGlCtx)
a577aaab 53{
54 if (myBitmapList != 0)
55 {
ea095e0e 56 Standard_ASSERT_RETURN (theGlCtx != NULL,
57 "OpenGl_PointSprite destroyed without GL context! Possible GPU memory leakage...",);
58
fd4a6963 59 if (theGlCtx->IsValid())
60 {
8f7159cb 61 theGlCtx->core11ffp->glDeleteLists (myBitmapList, 1);
fd4a6963 62 }
a577aaab 63 myBitmapList = 0;
64 }
65
66 OpenGl_Texture::Release (theGlCtx);
67}
68
69// =======================================================================
70// function : SetDisplayList
71// purpose :
72// =======================================================================
73void OpenGl_PointSprite::SetDisplayList (const Handle(OpenGl_Context)& theCtx,
74 const GLuint theBitmapList)
75{
76 Release (theCtx.operator->());
77 myBitmapList = theBitmapList;
78}
79
a577aaab 80// =======================================================================
81// function : DrawBitmap
82// purpose :
83// =======================================================================
8f7159cb 84void OpenGl_PointSprite::DrawBitmap (const Handle(OpenGl_Context)& theCtx) const
a577aaab 85{
86 if (myBitmapList != 0)
87 {
8f7159cb 88 theCtx->core11ffp->glCallList (myBitmapList);
a577aaab 89 }
90}