Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
def test_buffer_data_and_reserve(self):
with self.assertRaises(moderngl.Error):
self.ctx.buffer(b'Hello World!', reserve=1024)
def test_renderbuffer_invalid_samples(self):
with self.assertRaisesRegex(moderngl.Error, 'sample'):
self.ctx.renderbuffer((64, 64), samples=3)
def test_empty_framebuffer(self):
with self.assertRaisesRegex(moderngl.Error, 'empty'):
self.ctx.framebuffer([])
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)
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