コード例 #1
0
    def setup(self, context):
        if EAGL.setCurrentContext(context):
            self.sp.build()
            self.sp.bind()

            # self.texture = texture.loadTexture('test.png', 0)

            print len(self.objects), " object/s in the world"
            for rObj in self.objects:
                rObj.setup_object()

            glEnable(GL_CULL_FACE)
            glCullFace(GL_BACK)
            glEnable(GL_DEPTH_TEST)
            glDepthFunc(GL_LESS)
            glViewport(0, 0, int(glviewv.width * 2), int(glviewv.height * 2))

            glClearColor(0.1, 0.12, 0.45, 1.0)

            PhysicsWorld.js.eval_js('startUpdates();')
            glviewv.add_subview(PhysicsWorld.js)
            PhysicsWorld.js.send_to_back()
        else:
            print "Could not Setup OpenGLES"
        self.last = time.clock()
コード例 #2
0
ファイル: main.py プロジェクト: Cethric/OpenGLES-Pythonista
 def setup(self, context):
     if EAGL.setCurrentContext(context):
         self.sp.build()
         self.sp.bind()
         
         # self.texture = texture.loadTexture('test.png', 0)
         
         print len(self.objects), " object/s in the world"
         for rObj in self.objects:
             rObj.setup_object()
         
         glEnable(GL_CULL_FACE);
         glCullFace(GL_BACK)
         glEnable(GL_DEPTH_TEST);
         glDepthFunc(GL_LESS);
         glViewport(0, 0, int(glviewv.width*2), int(glviewv.height*2))
         
         glClearColor(0.1, 0.12, 0.45, 1.0)
         
         PhysicsWorld.js.eval_js('startUpdates();')
         glviewv.add_subview(PhysicsWorld.js)
         PhysicsWorld.js.send_to_back()
     else:
         print "Could not Setup OpenGLES"
     self.last = time.clock()
コード例 #3
0
 def setup_gl(self):
     glView = self.gl_kit_view
     context = self.context
     if EAGL.setCurrentContext(self.context._context):
         renderBuffer = ES2.glGenRenderbuffers(1)
         ES2.glCheckFramebufferStatus(ES2.GL_RENDERBUFFER)
         ES2.glBindRenderbuffer(ES2.GL_RENDERBUFFER, renderBuffer)
     else:
         print "Cannot setup gl"
コード例 #4
0
def main():
    from ui import Image
    i = Image.named('test:Lenna')
    with open('test.png', 'wb') as f:
        f.write(i.to_png())

    contextc = EAGL.EAGLContext(EAGL.RenderingAPI.OpenGLES2)
    GLKit.setRenderEngine(Renderer())
    glviewv.setDelegate(GLKit.GLKViewDelegate())
    glviewv.setContext(contextc)
    glviewv.present("sheet")
コード例 #5
0
    def render(self, context):
        start = time.clock()

        if EAGL.setCurrentContext(context):
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
            glViewport(0, 0, int(glviewv.width * 2), int(glviewv.height * 2))
            self.sp.bind()
            self.sp.uniform4x4("V", list(self.view.s1.m))
            self.sp.uniform4x4("P", list(self.projection.s1.m))
            for rObj in self.objects:
                rObj.render(self.sp)
            self.eye.debug_draw(self.sp)
        else:
            raise RuntimeError('Render Failed as context could not be set.')
        end = time.clock()
        # print 'render', (end - self.last)
        self.rt = end - start
        self.last = end
コード例 #6
0
ファイル: main.py プロジェクト: Cethric/OpenGLES-Pythonista
 def render(self, context):
     start = time.clock()
     
     if EAGL.setCurrentContext(context):
         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
         glViewport(0, 0, int(glviewv.width*2), int(glviewv.height*2))
         self.sp.bind()
         self.sp.uniform4x4("V", list(self.view.s1.m))
         self.sp.uniform4x4("P", list(self.projection.s1.m))
         for rObj in self.objects:
             rObj.render(self.sp)
         self.eye.debug_draw(self.sp)
     else:
         raise RuntimeError('Render Failed as context could not be set.')
     end = time.clock()
     # print 'render', (end - self.last)
     self.rt = end - start
     self.last = end
コード例 #7
0
 def draw(self):
     if EAGL.setCurrentContext(self.context._context):
         ES1.glClearColor(0.1, 0.0, 1.0, 0.0)
         ES1.glClear(ES1.GL_COLOR_BUFFER_BIT | ES1.GL_DEPTH_BUFFER_BIT)
     else:
         print "Failed to render. Could not get context"
コード例 #8
0
 def teardown(self):
     self.sp.teardown()
     EAGL.setCurrentContext(None)
     PhysicsWorld.js.eval_js('done();')
コード例 #9
0
ファイル: main.py プロジェクト: Cethric/OpenGLES-Pythonista
 def teardown(self):
     self.sp.teardown()
     EAGL.setCurrentContext(None)
     PhysicsWorld.js.eval_js('done();')