How to use the moderngl.Error function in moderngl

To help you get started, we’ve selected a few moderngl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moderngl / moderngl / tests / test_vertex_array_index.py View on Github external
out_vert = in_vert;
                }
            ''',
            varyings=['out_vert']
        )

        vertices = [
            4.0, 2.0, 7.5, 1.8,
            3.0, 2.8, 6.0, 10.0
        ]
        indices = [0, 1, 0, 1, 0, 1, 0, 1, 0]

        vbo1 = self.ctx.buffer(np.array(vertices, dtype='f4').tobytes())
        index_u4 = self.ctx.buffer(np.array(indices, dtype='u4').tobytes())

        with self.assertRaises(moderngl.Error):
            self.ctx.simple_vertex_array(prog, vbo1, 'in_vert', index_buffer=index_u4, index_element_size=0)
github moderngl / moderngl / tests / test_simple_texture.py View on Github external
def test_texture_invalid_samples(self):
        if self.max_samples < 2:
            self.skipTest('multisampling is not supported')

        with self.assertRaisesRegex(moderngl.Error, 'sample'):
            self.ctx.texture((16, 16), 3, samples=3)
github moderngl / moderngl / tests / test_simple_buffer.py View on Github external
def test_buffer_data_and_reserve(self):
        with self.assertRaises(moderngl.Error):
            self.ctx.buffer(b'Hello World!', reserve=1024)
github moderngl / moderngl / tests / test_simple_renderbuffer.py View on Github external
def test_renderbuffer_invalid_samples(self):
        with self.assertRaisesRegex(moderngl.Error, 'sample'):
            self.ctx.renderbuffer((64, 64), samples=3)
github moderngl / moderngl / tests / test_simple_framebuffer.py View on Github external
def test_empty_framebuffer(self):
        with self.assertRaisesRegex(moderngl.Error, 'empty'):
            self.ctx.framebuffer([])
github moderngl / moderngl / tests / test_texture_new.py View on Github external
def test_texture_invalid_samples(self):
        # if self.ctx.max_samples < 2:
        #     self.skipTest('multisampling is not supported')

        with self.assertRaisesRegex(moderngl.Error, 'sample'):
            self.ctx.texture((16, 16), 3, samples=3)
github moderngl / moderngl / examples / context_manager.py View on Github external
def get_default_context(allow_fallback_standalone_context=True) -> moderngl.Context:
        '''
            Default context
        '''

        if ContextManager.ctx is None:
            try:
                ContextManager.ctx = moderngl.create_context()
            except moderngl.Error:
                if allow_fallback_standalone_context:
                    ContextManager.ctx = moderngl.create_standalone_context()
                else:
                    raise

        return ContextManager.ctx