def OnInitGL(self, call_reshape=True): '''Initialize OpenGL for use in the window.''' if self.GLinitialized: return self.GLinitialized = True # create a pyglet context for this panel self.pygletcontext = gl.Context(gl.current_context) self.pygletcontext.canvas = self self.pygletcontext.set_current() # normal gl init glClearColor(0, 0, 0, 1) glColor3f(1, 0, 0) glEnable(GL_DEPTH_TEST) glClearDepth(1.0) glDepthFunc(GL_LEQUAL) glEnable(GL_CULL_FACE) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) # Uncomment this line for a wireframe view # glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) # Simple light setup. On Windows GL_LIGHT0 is enabled by default, # but this is not the case on Linux or Mac, so remember to always # include it. glEnable(GL_LIGHTING) glEnable(GL_LIGHT0) glEnable(GL_LIGHT1) glLightfv(GL_LIGHT0, GL_POSITION, vec(.5, .5, 1, 0)) glLightfv(GL_LIGHT0, GL_SPECULAR, vec(.5, .5, 1, 1)) glLightfv(GL_LIGHT0, GL_DIFFUSE, vec(1, 1, 1, 1)) glLightfv(GL_LIGHT1, GL_POSITION, vec(1, 0, .5, 0)) glLightfv(GL_LIGHT1, GL_DIFFUSE, vec(.5, .5, .5, 1)) glLightfv(GL_LIGHT1, GL_SPECULAR, vec(1, 1, 1, 1)) glShadeModel(GL_SMOOTH) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, vec(0.5, 0, 0.3, 1)) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, vec(1, 1, 1, 1)) glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50) glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, vec(0, 0.1, 0, 0.9)) if call_reshape: self.OnReshape() if hasattr(self.parent, "filenames") and self.parent.filenames: for filename in self.parent.filenames: self.parent.load_file(filename) self.parent.autoplate() if hasattr(self.parent, "loadcb"): self.parent.loadcb() self.parent.filenames = None
def OnInitGL(self): '''Initialize OpenGL for use in the window.''' # create a pyglet context for this panel #self.pygletcontext = gl.Context(gl.current_context) if pyglet.version > "1.1.4": self.pygletcontext = PygletWXContext() else: self.pygletcontext = gl.Context() self.pygletcontext.set_current() # normal gl init gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_TEXTURE_2D) gl.glClearColor(1, 1, 1, 1) # create objects to draw self.create_objects()
def OnInitGL(self, call_reshape=True): '''Initialize OpenGL for use in the window.''' if self.GLinitialized: return self.GLinitialized = True # create a pyglet context for this panel self.pygletcontext = gl.Context(gl.current_context) self.pygletcontext.canvas = self self.pygletcontext.set_current() # normal gl init glClearColor(*self.color_background) glClearDepth(1.0) # set depth value to 1 glDepthFunc(GL_LEQUAL) glEnable(GL_COLOR_MATERIAL) glEnable(GL_DEPTH_TEST) glEnable(GL_CULL_FACE) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) if call_reshape: self.OnReshape()
def OnInitGL(self): '''Initialize OpenGL for use in the window.''' #create a pyglet context for this panel self.pmat = (GLdouble * 16)() self.mvmat = (GLdouble * 16)() self.pygletcontext = gl.Context(gl.current_context) self.pygletcontext.canvas = self self.pygletcontext.set_current() self.dist = 1000 self.vpmat = None #normal gl init glClearColor(0.98, 0.98, 0.78, 1) glClearDepth(1.0) # set depth value to 1 glDepthFunc(GL_LEQUAL) glEnable(GL_COLOR_MATERIAL) glEnable(GL_DEPTH_TEST) glEnable(GL_CULL_FACE) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) self.OnReshape(*self.GetClientSize())