00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 import traceback
00020 from _ost_gfx import *
00021
00022 class PyGfxObj(GfxObj):
00023 def __init__(self,name):
00024 """
00025 requires a unique name not yet utilized in the Scene;
00026 do not place OpenGL calls in the ctor, use InitGL for
00027 that purpose
00028 """
00029 GfxObj.__init__(self,name)
00030 self._valid_flag=False
00031
00032 def _InitGL(self):
00033 try:
00034 self.InitGL()
00035 self._valid_flag=True
00036 except:
00037 traceback.print_exc()
00038
00039 def InitGL(self):
00040 """
00041 called once for each OpenGL context (usually one time),
00042 allows one-time OpenGL initialization to be implemented,
00043 such as vbo allocation
00044 """
00045 pass
00046
00047
00048 def _CustomPreRenderGL(self,rebuild):
00049 if not self._valid_flag:
00050 return
00051 try:
00052 self.CustomPreRenderGL(rebuild)
00053 except:
00054 self._valid_flag=False
00055 traceback.print_exc()
00056
00057 def CustomPreRenderGL(self,rebuild):
00058 """
00059 called just before CustomRenderGL is called; the flag
00060 indicates that a rebuild is required or was requested
00061 """
00062 pass
00063
00064
00065 def _CustomRenderGL(self,render_pass):
00066 if not self._valid_flag:
00067 return
00068 try:
00069 self.CustomRenderGL(render_pass)
00070 except:
00071 self._valid_flag=False
00072 traceback.print_exc()
00073
00074 def CustomRenderGL(self,render_pass):
00075 """
00076 called for each scene refresh
00077 """
00078 pass
00079