def set_configuration(config): """ Set gl configuration """ s = "" s += "acca=0 " # No accum buffer s += "red>=%d " % config.red_size s += "green>=%d " % config.green_size s += "blue>=%d " % config.blue_size s += "alpha>=%d " % config.alpha_size s += "depth>=%d " % config.depth_size s += "stencil~%d " % config.stencil_size if config.double_buffer: s += "double=1 " else: s += "single=1 " s += "stereo=%d " % config.stereo s += "samples~%d " % config.samples glut.glutInitDisplayString(s)
def init(self, w=None, h=None): if w: self.width = w if h: self.height = h try: glut.glutInit() except Exception as e: print(e) sys.exit() if pl.system() == 'Darwin': #Darwin: OSX glut.glutInitDisplayString('double rgba samples=8 core depth') else: #Other: Linux try: glut.glutInitDisplayMode( glut.GLUT_DOUBLE | \ glut.GLUT_RGBA | \ glut.GLUT_MULTISAMPLE | \ glut.GLUT_DEPTH) except Exception as e: print('Issue detected') print(e) sys.exit() glut.glutInitWindowSize (self.width, self.height) glut.glutCreateWindow (self.label) self.handler.init() glut.glutDisplayFunc(self.display) glut.glutKeyboardFunc(self.on_key_press) glut.glutMouseFunc(self.on_mouse_click) glut.glutMotionFunc(self.on_mouse_motion) glut.glutPassiveMotionFunc(self.on_mouse_motion) glut.glutReshapeFunc(self.on_resize) self.last_glut_idle_time = time.time() glut.glutIdleFunc(self.on_glut_idle) if self.streamed: # sakura core defines the main program loop, # so we have to run GLUT's own loop in another # greenlet. self.spawn_greenlet_loop()
def _set_config(config): """Set gl configuration""" s = "" st = '~' if sys.platform == 'darwin' else '=' ge = '>=' if sys.platform == 'darwin' else '=' s += "red%s%d " % (ge, config['red_size']) s += "green%s%d " % (ge, config['green_size']) s += "blue%s%d " % (ge, config['blue_size']) s += "alpha%s%d " % (ge, config['alpha_size']) s += "depth%s%d " % (ge, config['depth_size']) s += "stencil%s%d " % (st, config['stencil_size']) s += "samples%s%d " % (st, config['samples']) if config['samples'] else "" s += "acca=0 " if sys.platform == 'darwin' else "" if sys.platform == 'darwin': s += "double=1 " if config['double_buffer'] else "single=1 " s += "stereo=%d " % config['stereo'] else: # freeglut s += "double " if config['double_buffer'] else "single " s += "stereo " if config['stereo'] else "" glut.glutInitDisplayString(s.encode('ASCII'))
def __init__(self, name): self._lastsize = 0 self._name = name glt.glutInit() glt.glutInitDisplayString("rgba double")
gl.glVertex3d(1.0, -1.0, 0.0) # Top Left gl.glTexCoord2f(1.0, 0.0) gl.glVertex3d(1.0, 1.0, 0.0) # Top Right gl.glTexCoord2f(0.0, 0.0) gl.glVertex3d(-1.0, 1.0, 0.0) # Bottom Right gl.glEnd() gl.glDisable(gl.GL_TEXTURE_2D) # gl.glFinish() gl.glFlush() if __name__ == '__main__': game_mode = True glut.glutInit(sys.argv) g_window_width, g_window_height = get_winodw_resolution() glut.glutInitWindowSize(g_window_width, g_window_height) glut.glutInitDisplayString(b"red=10 green=10 blue=10 alpha=2") # glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DEPTH) glut.glutInitDisplayMode(glut.GLUT_RGBA) if game_mode: mode_string = "{}x{}:32@60".format(g_window_width, g_window_height) glut.glutGameModeString(mode_string) glut.glutEnterGameMode() else: glut.glutCreateWindow(b"30bit demo") glut.glutDisplayFunc(display) glut.glutReshapeFunc(resize) glut.glutKeyboardFunc(keyboard) init() glut.glutMainLoop()