当前位置: 首页>>代码示例>>Python>>正文


Python graphics.RenderContext类代码示例

本文整理汇总了Python中kivy.graphics.RenderContext的典型用法代码示例。如果您正苦于以下问题:Python RenderContext类的具体用法?Python RenderContext怎么用?Python RenderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RenderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_screen

    def add_screen(self, screen):
        self.screen_in.pos = self.screen_out.pos
        self.screen_in.size = self.screen_out.size
        self.manager.real_remove_widget(self.screen_out)

        self.fbo_in = self.make_screen_fbo(self.screen_in)
        self.fbo_out = self.make_screen_fbo(self.screen_out)
        self.manager.canvas.add(self.fbo_in)
        self.manager.canvas.add(self.fbo_out)

        self.canvas = Canvas()
        self.c_front = RenderContext()
        self.c_front.shader.source = resource_find('front.glsl')
        self.c_back = RenderContext()
        self.c_back.shader.source = resource_find('back.glsl')
        self.c_backshadow = RenderContext()
        self.c_backshadow.shader.source = resource_find('backshadow.glsl')
        self.canvas.add(self.c_front)
        self.canvas.add(self.c_back)
        self.canvas.add(self.c_backshadow)

        with self.canvas.before:
            Color(1, 1, 1)
            Rectangle(
                size=self.fbo_in.size,
                texture=self.fbo_in.texture)
            Callback(self._enter_3d)
        self._build_mesh(self.fbo_in.size)
        with self.canvas.after:
            Callback(self._leave_3d)

        self.manager.canvas.add(self.canvas)
开发者ID:kivy-garden,项目名称:garden.pagecurl,代码行数:32,代码来源:pagecurltransition.py

示例2: drawing

class bench_widget_draw:
    '''Widget: empty drawing (10000 Widget + 1 root)'''

    def __init__(self):
        self.ctx = RenderContext()
        self.root = root = Widget()
        for x in range(10000):
            root.add_widget(Widget())
        self.ctx.add(self.root.canvas)

    def run(self):
        self.ctx.draw()
开发者ID:5y,项目名称:kivy,代码行数:12,代码来源:benchmark.py

示例3: __init__

    def __init__(self, **kwargs):
        super(PageCurl, self).__init__(**kwargs)
        self.c_front = RenderContext()
        self.c_front.shader.source = resource_find('front.glsl')
        self.c_back = RenderContext()
        self.c_back.shader.source = resource_find('back.glsl')
        self.c_backshadow = RenderContext()
        self.c_backshadow.shader.source = resource_find('backshadow.glsl')

        self.canvas.add(self.c_front)
        self.canvas.add(self.c_back)
        self.canvas.add(self.c_backshadow)

        self.texture = CoreImage(self.source).texture
        Clock.schedule_interval(self.update_glsl, 1 / 60.)
开发者ID:kivy-garden,项目名称:garden.pagecurl,代码行数:15,代码来源:pagecurl-second.py

示例4: SlideShaderContainer

class SlideShaderContainer(FloatLayout):
    # (internal) This class is used to animate Slide instance.

    alpha = NumericProperty(0.0)
    fbo = ObjectProperty(None)
    fbo_texture = ObjectProperty(None, allownone=True)
    vs = StringProperty(vs_default)
    fs = StringProperty(fs_default)

    def __init__(self, **kwargs):
        self.fbo = Fbo(size=self.size)
        self.fbo_texture = self.fbo
        self.canvas = RenderContext()
        self.canvas.shader.vs = self.vs
        self.canvas.shader.fs = self.fs
        self.canvas.add(self.fbo)
        Clock.schedule_interval(self.update_shader, 0)
        super(SlideShaderContainer, self).__init__(**kwargs)

    def _add_widget(self, widget):
        canvas = self.canvas
        self.canvas = self.fbo
        super(SlideShaderContainer, self).add_widget(widget)
        self.canvas = canvas

    def _remove_widget(self, widget):
        canvas = self.canvas
        self.canvas = self.fbo
        super(SlideShaderContainer, self).remove_widget(widget)
        self.canvas = canvas

    def on_size(self, instance, value):
        if value[0] < 1 or value[1] < 1:
            return
        self.fbo.size = value
        self.fbo_texture = self.fbo.texture

    def on_vs(self, instance, value):
        self.canvas.shader.vs = value

    def on_fs(self, instance, value):
        self.canvas.shader.fs = value

    def update_shader(self, dt):
        self.canvas["projection_mat"] = Window.render_context["projection_mat"]
        self.canvas["modelview_mat"] = Window.render_context["modelview_mat"]
        self.canvas["alpha"] = float(self.alpha)
        self.canvas["size"] = map(float, self.size)
开发者ID:bloureiro,项目名称:kary,代码行数:48,代码来源:main.py

示例5: __init__

    def __init__(self, **kwargs):
        # Make sure opengl context exists
        EventLoop.ensure_window()

        self.canvas = RenderContext(use_parent_projection=True,
                                    use_parent_modelview=True)

        with self.canvas:
            self.fbo = Fbo(size=self.size)

        with self.fbo.before:
            PushMatrix()
            self.fbo_translation = Translate(-self.x, -self.y, 0)
        with self.fbo:
            Color(*self.background_color)
            self.fbo_rectangle = Rectangle(size=self.size)
        with self.fbo.after:
            PopMatrix()

        super(EffectWidget, self).__init__(**kwargs)

        Clock.schedule_interval(self._update_glsl, 0)

        self.bind(pos=self._update_translation,
                  size=self.refresh_fbo_setup,
                  effects=self.refresh_fbo_setup)

        self.refresh_fbo_setup()
开发者ID:deddymarzuki,项目名称:kivy,代码行数:28,代码来源:effectwidget.py

示例6: create_window

    def create_window(self):
        '''Will create the main window and configure it.

        .. warning::
            This method is called automatically at runtime. If you call it, it
            will recreate a RenderContext and Canvas. This mean you'll have a
            new graphics tree, and the old one will be unusable.

            This method exist to permit the creation of a new OpenGL context
            AFTER closing the first one. (Like using runTouchApp() and
            stopTouchApp()).

            This method have been only tested in unittest environment, and will
            be not suitable for Applications.

            Again, don't use this method unless you know exactly what you are
            doing !
        '''
        from kivy.core.gl import init_gl
        init_gl()

        # create the render context and canvas
        from kivy.graphics import RenderContext, Canvas
        self.render_context = RenderContext()
        self.canvas = Canvas()
        self.render_context.add(self.canvas)
开发者ID:alexleighton,项目名称:kivy,代码行数:26,代码来源:__init__.py

示例7: __init__

    def __init__(self, **kwargs):
        # Make sure opengl context exists
        EventLoop.ensure_window()

        self.canvas = RenderContext(use_parent_projection=True,
                                    use_parent_modelview=True)

        with self.canvas:
            self.fbo = Fbo(size=self.size)

        with self.fbo.before:
            PushMatrix()
        with self.fbo:
            ClearColor(0, 0, 0, 0)
            ClearBuffers()
            self._background_color = Color(*self.background_color)
            self.fbo_rectangle = Rectangle(size=self.size)
        with self.fbo.after:
            PopMatrix()

        super(EffectWidget, self).__init__(**kwargs)

        Clock.schedule_interval(self._update_glsl, 0)

        self.bind(size=self.refresh_fbo_setup,
                  effects=self.refresh_fbo_setup,
                  background_color=self._refresh_background_color)

        self.refresh_fbo_setup()
        self._refresh_background_color()  # In case thi was changed in kwargs
开发者ID:9miao,项目名称:kivy,代码行数:30,代码来源:effectwidget.py

示例8: __init__

 def __init__(self, **kwargs):
     self.canvas = RenderContext(use_parent_projection=True)
     self.canvas.shader.source = 'pointshader.glsl'
     glEnable(0x8642) #GL_VERTEX_PROGRAM_POINT_SIZE
     glEnable(0x8861) #GL_POINT_SPRITE
     self.mesh = None
     super(PointRenderer, self).__init__(**kwargs) 
     self.draw_mesh_points(60)
     Clock.schedule_interval(self.test_mesh_remove, 1./60.)
开发者ID:Kovak,项目名称:KivyExamples,代码行数:9,代码来源:pointrenderer.py

示例9: __init__

 def __init__(self, **kwargs):
     self.fbo = Fbo(size=self.size)
     self.fbo_texture = self.fbo
     self.canvas = RenderContext()
     self.canvas.shader.vs = self.vs
     self.canvas.shader.fs = self.fs
     self.canvas.add(self.fbo)
     Clock.schedule_interval(self.update_shader, 0)
     super(SlideShaderContainer, self).__init__(**kwargs)
开发者ID:bloureiro,项目名称:kary,代码行数:9,代码来源:main.py

示例10: create_window

    def create_window(self, *largs):
        """Will create the main window and configure it.

        .. warning::
            This method is called automatically at runtime. If you call it, it
            will recreate a RenderContext and Canvas. This means you'll have a
            new graphics tree, and the old one will be unusable.

            This method exist to permit the creation of a new OpenGL context
            AFTER closing the first one. (Like using runTouchApp() and
            stopTouchApp()).

            This method has only been tested in a unittest environment and
            is not suitable for Applications.

            Again, don't use this method unless you know exactly what you are
            doing!
        """
        # just to be sure, if the trigger is set, and if this method is
        # manually called, unset the trigger
        Clock.unschedule(self.create_window)

        # ensure the window creation will not be called twice
        if platform in ("android", "ios"):
            self._unbind_create_window()

        if not self.initialized:
            from kivy.core.gl import init_gl

            init_gl()

            # create the render context and canvas, only the first time.
            from kivy.graphics import RenderContext, Canvas

            self.render_context = RenderContext()
            self.canvas = Canvas()
            self.render_context.add(self.canvas)

        else:
            # if we get initialized more than once, then reload opengl state
            # after the second time.
            # XXX check how it's working on embed platform.
            if platform == "linux" or Window.__class__.__name__ == "WindowSDL":
                # on linux, it's safe for just sending a resize.
                self.dispatch("on_resize", *self.system_size)

            else:
                # on other platform, window are recreated, we need to reload.
                from kivy.graphics.context import get_context

                get_context().reload()
                Clock.schedule_once(lambda x: self.canvas.ask_update(), 0)
                self.dispatch("on_resize", *self.system_size)

        # ensure the gl viewport is correct
        self.update_viewport()
开发者ID:FantasyNJ,项目名称:Tickeys-linux,代码行数:56,代码来源:__init__.py

示例11: __init__

    def __init__(self, client, **kwargs):
        self.canvas = RenderContext(use_parent_projection=True)
        self.client = client

        super(Section, self).__init__(**kwargs)
        
        self.canvas.shader.fs = open(resource_find('shaders/section_fragment.glsl')).read()
        self.canvas.shader.vs = open(resource_find('shaders/section_vertex.glsl')).read()
        
        self.recalc()
开发者ID:cedarsuite,项目名称:displayminion,代码行数:10,代码来源:Section.py

示例12: create_canvas

    def create_canvas(self):
        self.canvas = Canvas()
        self.c_front = RenderContext()
        self.c_front.shader.source = join(curdir, 'front.glsl')
        self.c_back = RenderContext()
        self.c_back.shader.source = join(curdir, 'back.glsl')
        self.c_backshadow = RenderContext()
        self.c_backshadow.shader.source = join(curdir, 'backshadow.glsl')
        self.canvas.add(self.c_front)
        self.canvas.add(self.c_back)
        self.canvas.add(self.c_backshadow)

        with self.canvas.before:
            Color(1, 1, 1)
            Rectangle(
                size=self.fbo_in.size,
                texture=self.fbo_in.texture)
            Callback(self._enter_3d)
        self._build_mesh(self.fbo_in.size)
        with self.canvas.after:
            Callback(self._leave_3d)
开发者ID:kivy-garden,项目名称:garden.pagecurl,代码行数:21,代码来源:__init__.py

示例13: add_screen

    def add_screen(self, screen):
        self.screen_in.pos = self.screen_out.pos
        self.screen_in.size = self.screen_out.size
        self.manager.real_remove_widget(self.screen_out)

        print '-----------'
        print 'add_screen', screen, screen.canvas
        print 'screen_in', self.screen_in, self.screen_in.parent
        print 'screen_out', self.screen_out, self.screen_out.parent
        print '-----------'
        self.fbo_in = self.make_screen_fbo(self.screen_in, mode='in')
        self.fbo_out = self.make_screen_fbo(self.screen_out, mode='out')
        self.manager.canvas.add(self.fbo_in)
        self.manager.canvas.add(self.fbo_out)

        self.canvas = Canvas()
        self.c_front = RenderContext()
        self.c_front.shader.source = join(curdir, 'front.glsl')
        self.c_back = RenderContext()
        self.c_back.shader.source = join(curdir, 'back.glsl')
        self.c_backshadow = RenderContext()
        self.c_backshadow.shader.source = join(curdir, 'backshadow.glsl')
        self.canvas.add(self.c_front)
        self.canvas.add(self.c_back)
        self.canvas.add(self.c_backshadow)

        with self.canvas.before:
            Color(1, 1, 1)
            Rectangle(
                size=self.fbo_in.size,
                texture=self.fbo_in.texture)
            Callback(self._enter_3d)
        self._build_mesh(self.fbo_in.size)
        with self.canvas.after:
            Callback(self._leave_3d)

        self.manager.canvas.add(self.canvas)
        self.on_progress(0)
开发者ID:kivy-garden,项目名称:garden.pagecurl,代码行数:38,代码来源:__init__.py

示例14: __init__

    def __init__(self, **kwargs):

        self.register_event_type('on_load')

        self.canvas = RenderContext(fs=self.FS_CONVERT_YUV)
        self.canvas['tex_y'] = 1
        self.canvas['tex_u'] = 2
        self.canvas['tex_v'] = 3

        super(YuvVideo, self).__init__(**kwargs)

        if self.colorfmt == OUT_COLOR_FORMAT[0]:
            self.fs = self.FS_CONVERT_RGB
        elif self.format != YUV_CHROMA_FORMAT[0]:
            self.fs = self.FS_CONVERT_YUV
        else:
            self.fs = self.FS_CONVERT_MONO
开发者ID:dev-life,项目名称:yuvist,代码行数:17,代码来源:yuvvideo.py

示例15: __init__

    def __init__(self, **kwargs):
        self.canvas = RenderContext()

        super(AndroidCameraPreview, self).__init__(**kwargs)
        self.bind(resolution=self._resolution_changed)
        self.bind(camera_id=self._camera_id_changed)
        self.bind(play=self._play_changed)


        # This is needed for the default vertex shader.
        self.canvas['projection_mat'] = Window.render_context['projection_mat']


        with self.canvas:   
            Callback(self._draw_callback)
            BindTexture(texture=self._secondary_texture, index=1)
        self.canvas['secondary_texture'] = 1
        self._init_texture(self.resolution)
开发者ID:sergey1kabanov,项目名称:tourist,代码行数:18,代码来源:camera.py


注:本文中的kivy.graphics.RenderContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。