0028487: Visualization, TKOpenGl - add option for rendering with lower resolution
[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>
19#include <Standard_Assert.hxx>
20#include <Image_PixMap.hxx>
21
a577aaab 22
92efcf78 23IMPLEMENT_STANDARD_RTTIEXT(OpenGl_PointSprite,OpenGl_Texture)
24
a577aaab 25// =======================================================================
26// function : OpenGl_PointSprite
27// purpose :
28// =======================================================================
29OpenGl_PointSprite::OpenGl_PointSprite()
30: OpenGl_Texture (NULL),
31 myBitmapList (0)
32{
33 //myParams->SetFilter (Graphic3d_TOTF_NEAREST);
076ca35c 34 myParams->SetModulate (Standard_False);
a577aaab 35 myParams->SetGenMode (Graphic3d_TOTM_SPRITE,
36 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f),
37 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
38}
39
40// =======================================================================
41// function : ~OpenGl_PointSprite
42// purpose :
43// =======================================================================
44OpenGl_PointSprite::~OpenGl_PointSprite()
45{
46 Release (NULL);
47}
48
49// =======================================================================
50// function : Release
51// purpose :
52// =======================================================================
10b9c7df 53void OpenGl_PointSprite::Release (OpenGl_Context* theGlCtx)
a577aaab 54{
55 if (myBitmapList != 0)
56 {
ea095e0e 57 Standard_ASSERT_RETURN (theGlCtx != NULL,
58 "OpenGl_PointSprite destroyed without GL context! Possible GPU memory leakage...",);
59
fd4a6963 60 if (theGlCtx->IsValid())
61 {
ca3c13d1 62 #if !defined(GL_ES_VERSION_2_0)
fd4a6963 63 glDeleteLists (myBitmapList, 1);
ca3c13d1 64 #endif
fd4a6963 65 }
a577aaab 66 myBitmapList = 0;
67 }
68
69 OpenGl_Texture::Release (theGlCtx);
70}
71
72// =======================================================================
73// function : SetDisplayList
74// purpose :
75// =======================================================================
76void OpenGl_PointSprite::SetDisplayList (const Handle(OpenGl_Context)& theCtx,
77 const GLuint theBitmapList)
78{
79 Release (theCtx.operator->());
80 myBitmapList = theBitmapList;
81}
82
83
84// =======================================================================
85// function : DrawBitmap
86// purpose :
87// =======================================================================
88void OpenGl_PointSprite::DrawBitmap (const Handle(OpenGl_Context)& ) const
89{
90 if (myBitmapList != 0)
91 {
ca3c13d1 92 #if !defined(GL_ES_VERSION_2_0)
a577aaab 93 glCallList (myBitmapList);
ca3c13d1 94 #endif
a577aaab 95 }
96}