예제 #1
0
    def __init__(self, config):
        
        self.title = 'FoFiX' # Move to version.py
        
        self.config = config
        window.init_video()
        resolution = config['display', 'resolution']

        width, height = resolution.split('x')
        width = int(width)
        height = int(height)

        multisamples = config['display', 'multisamples']
        
        self.window = window.Window(width, height)

        # Forward Compatible Opengl 3.1 Core Profile Rendering Context
        # This was chosen as OpenGL 3.1 is the highest supported version on the
        # Sandy Bridge iGPU when on linux and windows.
        self.context = context.Context(3, 1, profile=context.PROFILE_CORE,
                                       flags=context.CONTEXT_FORWARD_COMPATIBLE,
                                       msaa=multisamples)

        self.window.make_current(self.context)


        self.task = TaskManager(self)
        self.events = EventManager()
        self.layer = LayerManager()
        self.scene = SceneManager()
        
        self.task.add(self.events)
        self.task.add(self.layer)
        self.task.add(self.scene)
        
        self.scene.create("GameScene")
        
        self.running = False
        
        self.run()
예제 #2
0
class Engine(object):
    ''' Necessary game structure, everything ties together here '''
    def __init__(self, config):
        
        self.title = 'FoFiX' # Move to version.py
        
        self.config = config
        window.init_video()
        resolution = config['display', 'resolution']

        width, height = resolution.split('x')
        width = int(width)
        height = int(height)

        multisamples = config['display', 'multisamples']
        
        self.window = window.Window(width, height)

        # Forward Compatible Opengl 3.1 Core Profile Rendering Context
        # This was chosen as OpenGL 3.1 is the highest supported version on the
        # Sandy Bridge iGPU when on linux and windows.
        self.context = context.Context(3, 1, profile=context.PROFILE_CORE,
                                       flags=context.CONTEXT_FORWARD_COMPATIBLE,
                                       msaa=multisamples)

        self.window.make_current(self.context)


        self.task = TaskManager(self)
        self.events = EventManager()
        self.layer = LayerManager()
        self.scene = SceneManager()
        
        self.task.add(self.events)
        self.task.add(self.layer)
        self.task.add(self.scene)
        
        self.scene.create("GameScene")
        
        self.running = False
        
        self.run()
    
    def run(self):
        self.running = True
        
        while self.running:
        
            self.update()
            self.render()
            
            # Put the frame on screen
            self.window.flip()
    
    def update(self):
        self.task.run()
    
    def render(self):
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        self.layer.render()
    
    def stop(self):
        self.running = False