OpenStructure
Loading...
Searching...
No Matches
py_gfx_obj.py
Go to the documentation of this file.
1#------------------------------------------------------------------------------
2# This file is part of the OpenStructure project <www.openstructure.org>
3#
4# Copyright (C) 2008-2020 by the OpenStructure authors
5#
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 as published by the Free
8# Software Foundation; either version 3.0 of the License, or (at your option)
9# any later version.
10# This library is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13# details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this library; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18#------------------------------------------------------------------------------
19import traceback
20from ._ost_gfx import *
21
23 def __init__(self,name):
24 """
25 requires a unique name not yet utilized in the Scene;
26 do not place OpenGL calls in the ctor, use InitGL for
27 that purpose
28 """
29 GfxObj.__init__(self,name)
30 self._valid_flag=False
31
32 def _InitGL(self):
33 try:
34 self.InitGLInitGL()
35 self._valid_flag=True
36 except:
37 traceback.print_exc()
38
39 def InitGL(self):
40 """
41 called once for each OpenGL context (usually one time),
42 allows one-time OpenGL initialization to be implemented,
43 such as vbo allocation
44 """
45 pass
46
47
48 def _CustomPreRenderGL(self,rebuild):
49 if not self._valid_flag:
50 return
51 try:
52 self.CustomPreRenderGL(rebuild)
53 except:
54 self._valid_flag=False
55 traceback.print_exc()
56
57 def CustomPreRenderGL(self,rebuild):
58 """
59 called just before CustomRenderGL is called; the flag
60 indicates that a rebuild is required or was requested
61 """
62 pass
63
64
65 def _CustomRenderGL(self,render_pass):
66 if not self._valid_flag:
67 return
68 try:
69 self.CustomRenderGL(render_pass)
70 except:
71 self._valid_flag=False
72 traceback.print_exc()
73
74 def CustomRenderGL(self,render_pass):
75 """
76 called for each scene refresh
77 """
78 pass
79
main class for all graphic objects
Definition gfx_object.hh:52
virtual void InitGL()
_CustomRenderGL(self, render_pass)
Definition py_gfx_obj.py:65
CustomRenderGL(self, render_pass)
Definition py_gfx_obj.py:74
_CustomPreRenderGL(self, rebuild)
Definition py_gfx_obj.py:48
CustomPreRenderGL(self, rebuild)
Definition py_gfx_obj.py:57