0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / OpenGl / OpenGl_AspectLine.cxx
CommitLineData
b311480e 1// Created on: 2011-07-13
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
30f0ad28 16#include <Graphic3d_ShaderProgram.hxx>
17
2166f0fa 18#include <OpenGl_AspectLine.hxx>
30f0ad28 19#include <OpenGl_Context.hxx>
20#include <OpenGl_ShaderManager.hxx>
21#include <OpenGl_ShaderProgram.hxx>
bf75be98 22#include <OpenGl_Workspace.hxx>
2166f0fa 23
30f0ad28 24namespace
25{
30f0ad28 26 static const TCollection_AsciiString THE_EMPTY_KEY;
a3f6f591 27}
2166f0fa 28
30f0ad28 29// =======================================================================
30// function : OpenGl_AspectLine
31// purpose :
32// =======================================================================
b6472664 33OpenGl_AspectLine::OpenGl_AspectLine()
34: myAspect (new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0))
35{
36 //
37}
2166f0fa 38
30f0ad28 39// =======================================================================
40// function : OpenGl_AspectLine
41// purpose :
42// =======================================================================
b6472664 43OpenGl_AspectLine::OpenGl_AspectLine (const Handle(Graphic3d_AspectLine3d)& theAspect)
44{
45 SetAspect (theAspect);
46}
2166f0fa 47
30f0ad28 48// =======================================================================
49// function : SetAspect
50// purpose :
51// =======================================================================
b6472664 52void OpenGl_AspectLine::SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
2166f0fa 53{
b6472664 54 myAspect = theAspect;
55 const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId();
30f0ad28 56 if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
57 {
f85399e5 58 myResources.ResetShaderReadiness();
30f0ad28 59 }
60}
2166f0fa 61
30f0ad28 62// =======================================================================
63// function : Render
64// purpose :
65// =======================================================================
5e27df78 66void OpenGl_AspectLine::Render (const Handle(OpenGl_Workspace) &theWorkspace) const
2166f0fa 67{
5e27df78 68 theWorkspace->SetAspectLine (this);
2166f0fa
SK
69}
70
30f0ad28 71// =======================================================================
72// function : Release
73// purpose :
74// =======================================================================
10b9c7df 75void OpenGl_AspectLine::Release (OpenGl_Context* theContext)
30f0ad28 76{
392ac980 77 if (!myResources.ShaderProgram.IsNull()
10b9c7df 78 && theContext)
30f0ad28 79 {
392ac980 80 theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
81 myResources.ShaderProgram);
30f0ad28 82 }
83 myResources.ShaderProgramId.Clear();
f85399e5 84 myResources.ResetShaderReadiness();
30f0ad28 85}
86
87// =======================================================================
88// function : BuildShader
89// purpose :
90// =======================================================================
8625ef7e 91void OpenGl_AspectLine::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
30f0ad28 92 const Handle(Graphic3d_ShaderProgram)& theShader)
5e27df78 93{
4e1523ef 94 if (theCtx->core20fwd == NULL)
392ac980 95 {
30f0ad28 96 return;
392ac980 97 }
30f0ad28 98
99 // release old shader program resources
100 if (!ShaderProgram.IsNull())
101 {
8625ef7e 102 theCtx->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
f85399e5 103 ShaderProgramId.Clear();
104 ShaderProgram.Nullify();
30f0ad28 105 }
392ac980 106 if (theShader.IsNull())
30f0ad28 107 {
392ac980 108 return;
30f0ad28 109 }
392ac980 110
8625ef7e 111 theCtx->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
5e27df78 112}