def setDefinition(self, definition): from OpenGLContext import contextdefinition definition = definition or self.contextDefinition if not definition: definition = contextdefinition.ContextDefinition() elif not isinstance(definition, contextdefinition.ContextDefinition): definition = contextdefinition.ContextDefinition(**definition) self.contextDefinition = definition self.coreProfile = definition.profile == 'core' return self.contextDefinition
def __init__(self, definition=None, **named): #init pygame pygame.display.init() if definition is None: definition = contextdefinition.ContextDefinition( **named ) else: for key,value in named.items(): setattr( definition, key, value ) self.contextDefinition = definition self.screen = self.pygameDisplayMode( definition ) pygame.display.set_caption(definition.title or self.getApplicationName()) pygame.key.set_repeat(500,30) Context.__init__ (self, definition) self.ViewPort(*definition.size)
def __init__(self, parent, definition=None, id=-1, pos=wx.DefaultPosition, style=wx.WANTS_CHARS, name="GLContext", **named): """Initialize the wxContext object and window parent -- wx.Window parent of the context window id -- wxPython ID for the window, can normally be left as the default pos -- wxPython position object or a two-tuple of coordinates for the wxPython window that we are creating size -- wxPython size object, or a two-tuple of dimensions for the wxPython window that we are creating style -- wxPython style integer (a bit-mask) dictating the window style name -- string determining the wxPython window's name, which is an internal value which allows wxPython programmers to search for particular windows. This implementation simply passes the wxPython-specific arguments to the wxGLCanvas initializer, then calls the context.Context initializer. """ if definition is None: definition = contextdefinition.ContextDefinition(**named) else: for key, value in named.items(): setattr(definition, key, value) glcanvas.GLCanvas.__init__( self, parent, id=id, pos=pos, size=tuple(definition.size), style=style, name=name, attribList=self.wxFlagsFromDefinition(definition)) self.Show() context.Context.__init__(self, definition)
def __init__(self, definition=None, **named): # set up double buffering and rgb display mode if definition is None: definition = contextdefinition.ContextDefinition(**named) else: for key, value in named.items(): setattr(definition, key, value) self.contextDefinition = definition if glutInitContextVersion and definition.version[0]: glutInitContextVersion(*definition.version) if glutInitContextProfile and definition.profile == 'core': glutInitContextFlags(GLUT_FORWARD_COMPATIBLE) glutInitContextProfile(GLUT_CORE_PROFILE) glutInitDisplayMode(self.glutFlagsFromDefinition(definition)) glutInit([]) # set up window size for newly created windows glutInitWindowSize(*[int(i) for i in definition.size]) # create a new rendering window self.windowID = glutCreateWindow(definition.title or self.getApplicationName()) Context.__init__(self, definition)
glEnable(GL_MAP2_VERTEX_3) glEnable(GL_MAP2_NORMAL) glMap2f(GL_MAP2_VERTEX_3, 0., 1., 0., 1., ctrlpoints) glMap2f(GL_MAP2_NORMAL, 0., 1., 0., 1., ctrlpoints) glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0) displayList = glGenLists(1) glNewList( displayList, GL_COMPILE) glColor3f( 1.0,0,0) glEvalMesh2(GL_FILL, 0, 20, 0, 20) glEndList() return displayList def OnInit( self ): """Initialise""" print """Should see curvy surface with no texture""" self.surfaceID = self.buildDisplayList() self.light = SpotLight( direction = (-10,0,-10), cutOffAngle = 1.57, color = (0,0,1), location = (10,0,10), ) if __name__ == "__main__": from OpenGLContext import contextdefinition TestContext.ContextMainLoop( definition = contextdefinition.ContextDefinition( size = (800,500 ), ) )