def thread_main(instance): # sys.stderr.write("Starting thread_main\n") GLUT.glutInit(sys.argv) GLUT.glutInitContextVersion(3, 3) GLUT.glutInitContextFlags(GLUT.GLUT_FORWARD_COMPATIBLE) GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE) GLUT.glutSetOption(GLUT.GLUT_ACTION_ON_WINDOW_CLOSE, GLUT.GLUT_ACTION_GLUTMAINLOOP_RETURNS) GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH) # sys.stderr.write("Making default GLUT window.\n") GLUT.glutInitWindowSize(instance.width, instance.height) GLUT.glutInitWindowPosition(0, 0) instance.window = GLUT.glutCreateWindow( bytes(instance._title, encoding='UTF-8')) # Urgh.... according to the docs, I'm MUST register a display function # for any GLUT window I create. But... I don't want to do this until # later (in self.__init__). So, register a null function now, # and hope that registering a new function is an OK thing to do. GLUT.glutDisplayFunc(lambda: None) # Not sure if I want this as a timer or an idle func GLUT.glutIdleFunc(lambda: GLUTContext.class_idle()) # GLUT.glutTimerFunc(10, lambda val : GLUTContext.class_idle(), 0) sys.stderr.write("Going into GLUT.GLUT main loop.\n") GLUTContext._class_init = True GLUT.glutMainLoop()
def setUp(self): self.window_size = (400, 400) GLUT.glutInit() GLUT.glutInitContextVersion(3, 3) GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE) GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA) GLUT.glutInitWindowSize(*self.window_size) self.window = GLUT.glutCreateWindow("GLPy Test")
def main(): print("-----------------------------------------------------------") print("Alternar entre Fill e Wireframe: 'v'") print("Modo Translação: 't'") print("\t → : deslocamento positivo em X") print("\t ← : deslocamento negativo em X") print("\t ↑ : deslocamento positivo em Y") print("\t ↓ : deslocamento negativo em Y") print("\t'a' : deslocamento positivo em Z") print("\t'd' : deslocamento negativo em Z") print("Modo Rotação: 'r'") print("\t ↑ : rotação positivo em X") print("\t ↓ : rotação negativo em X") print("\t → : rotação positivo em Y") print("\t ← : rotação negativo em Y") print("\t'a' : rotação positivo em Z") print("\t'd' : rotação negativo em Z") print("Modo Escala: 'e'") print("\t → : fator positivo em X") print("\t ← : fator negativo em X") print("\t ↑ : fator positivo em Y") print("\t ↓ : fator negativo em Y") print("\t'a' : fator positivo em Z") print("\t'd' : fator negativo em Z") print("-----------------------------------------------------------") glut.glutInit() glut.glutInitContextVersion(3, 3); glut.glutInitContextProfile(glut.GLUT_CORE_PROFILE); glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH) glut.glutInitWindowSize(win_width, win_height) glut.glutCreateWindow('Trabalho 2') # Init vertex data for the triangle. initData() # Create shaders. initShaders() glut.glutReshapeFunc(reshape) glut.glutDisplayFunc(display) glut.glutKeyboardFunc(keyboard) glut.glutIdleFunc(idle); glut.glutSpecialFunc(SpecialInput) glut.glutMainLoop()
def init_glut(self, args): """Initialize the GLUT state.""" # Initialize GLUT. GLUT.glutInit(args) GLUT.glutInitContextVersion( self.context_version[0], self.context_version[1]) GLUT.glutInitContextFlags(GLUT.GLUT_FORWARD_COMPATIBLE) GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE) GLUT.glutSetOption( GLUT.GLUT_ACTION_ON_WINDOW_CLOSE, GLUT.GLUT_ACTION_GLUTMAINLOOP_RETURNS) # Initialize and create the main window. GLUT.glutInitDisplayMode( GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH) GLUT.glutInitWindowSize( self.window_size[0], self.window_size[1]) GLUT.glutInitWindowPosition( self.window_position[0], self.window_position[1]) GLUT.glutCreateWindow(self.window_title) GLUT.glutDisplayFunc(self.render) GLUT.glutIdleFunc(self.idle) GLUT.glutReshapeFunc(self.resize) GLUT.glutKeyboardFunc(self.keyboard) GLUT.glutTimerFunc(0, self.timer, 0) GLUT.glutMouseFunc(self.mouse) GLUT.glutMotionFunc(self.motion) GLUT.glutCloseFunc(self.cleanup) aspects = [('Vendor', GL.GL_VENDOR), ('Renderer', GL.GL_RENDERER), ('Version', GL.GL_VERSION),] if self.context_version[0] > 1: aspects.append(('GLSL', GL.GL_SHADING_LANGUAGE_VERSION)) for i in aspects: print('{}: {}'.format(i[0], GL.glGetString(i[1]).decode()), file=sys.stderr, flush=True)
def main(filepath, texpath): glut.glutInit() glut.glutInitContextVersion(3, 3) glut.glutInitContextProfile(glut.GLUT_CORE_PROFILE) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH) glut.glutInitWindowSize(win_width,win_height) glut.glutCreateWindow('M E S H') initData(filepath, texpath) initShaders() glut.glutReshapeFunc(reshape) glut.glutDisplayFunc(display) glut.glutKeyboardFunc(keyboard) glut.glutSpecialFunc(special_keyboard) glut.glutIdleFunc(idle) glut.glutMainLoop()
def main(): """Show the current OpenGL connection strings.""" GLUT.glutInit(sys.argv) GLUT.glutInitContextVersion(3, 3) GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE) GLUT.glutInitDisplayMode( GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH) win = GLUT.glutCreateWindow(b'NO TITLE') aspects = {'Vendor':GL.GL_VENDOR, 'Renderer':GL.GL_RENDERER, 'Version':GL.GL_VERSION,} if GL.glCreateShader: aspects['GLSL'] = GL.GL_SHADING_LANGUAGE_VERSION print('\n'.join('{}: {}'.format(key, GL.glGetString(val).decode()) for key, val in aspects.items())) GLUT.glutDestroyWindow(win)
def __init__(self, shader_programs=None, version=(3, 3)): try: GLUT.glutInit([]) except: print("freeglut missing, try " "'sudo apt-get install freeglut3' or similar") sys.exit(1) # make a window GLUT.glutInitContextVersion(version[0], version[1]) GLUT.glutInitContextFlags(GLUT.GLUT_FORWARD_COMPATIBLE) GLUT.glutInitContextProfile(GLUT.GLUT_COMPATIBILITY_PROFILE) GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE) GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH) GLUT.glutInitWindowSize(self.viewport[2], self.viewport[3]) self.window = GLUT.glutCreateWindow("pyopengl with glut") GLUT.glutDisplayFunc(self.render) GLUT.glutIdleFunc(self.render)
def main(): glut.glutInit() parse_input() glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH) glut.glutInitWindowSize(win_width,win_height) glut.glutInitContextVersion(3, 3); glut.glutInitContextProfile(glut.GLUT_CORE_PROFILE); glut.glutCreateWindow('Mesh slices') init() glut.glutReshapeFunc(reshape) glut.glutDisplayFunc(display) glut.glutKeyboardFunc(keyboard) glut.glutMouseFunc(mouse) glut.glutMotionFunc(motion) glut.glutMainLoop()
def main(): """Show the current OpenGL connection strings.""" GLUT.glutInit(sys.argv) GLUT.glutInitContextVersion(3, 3) GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE) GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH) win = GLUT.glutCreateWindow(b'NO TITLE') aspects = { 'Vendor': GL.GL_VENDOR, 'Renderer': GL.GL_RENDERER, 'Version': GL.GL_VERSION, } if GL.glCreateShader: aspects['GLSL'] = GL.GL_SHADING_LANGUAGE_VERSION print('\n'.join(f'{key}: {GL.glGetString(val).decode()}' for key, val in aspects.items())) GLUT.glutDestroyWindow(win)