Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_properties(self):
self.assertEqual(type(self.window.ctx), moderngl.Context)
# We don't have a default framebuffer in headless mode
self.assertIsNone(self.ctx.screen)
self.assertIsNotNone(self.window.fbo)
texture.use()
# FIXME: size for texture array bug in ModernGL
if not isinstance(texture, TextureArray):
assert texture.size == (256, 256)
assert texture.width == 256
assert texture.height == 256
assert texture.components > 0
texture.filter = moderngl.LINEAR, moderngl.LINEAR
assert isinstance(texture.dtype, str)
if not texture.depth:
assert texture.swizzle == 'RGBA'
assert isinstance(texture.ctx, moderngl.Context)
assert isinstance(texture.glo, int)
texture.repeat_x = False
texture.repeat_y = True
assert texture.repeat_x is False
assert texture.repeat_y is True
def test_properties(self):
"""Ensure all callback funcs are callable"""
# Configured Values
self.assertIsInstance(self.window.config, WindowConfig)
self.assertEqual(self.window.size, self.config.window_size)
self.assertEqual(self.window.width, self.config.window_size[0])
self.assertEqual(self.window.height, self.config.window_size[1])
self.assertEqual(self.window.title, self.config.title)
self.assertEqual(self.window.gl_version, self.config.gl_version)
self.assertEqual(self.config.aspect_ratio, self.window.aspect_ratio)
self.assertIsInstance(self.window.ctx, moderngl.Context)
self.assertIsInstance(self.window.fbo, moderngl.Framebuffer)
self.assertEqual(self.window.vsync, False)
# Defaults
self.assertEqual(self.config.resizable, True) # Disabled in headless
self.assertEqual(self.config.cursor, True) # Disabled in headless
self.assertEqual(self.config.samples, self.window.samples)
self.assertIsInstance(self.config.resource_dir, Path)
# Ensure callback funcs are actual callable
self.assertTrue(callable(self.window.resize_func))
self.assertTrue(callable(self.window.key_event_func))
self.assertTrue(callable(self.window.mouse_position_event_func))
self.assertTrue(callable(self.window.mouse_press_event_func))
self.assertTrue(callable(self.window.mouse_release_event_func))
self.assertTrue(callable(self.window.mouse_drag_event_func))
def test_ctx(self):
assert isinstance(self.window.ctx, moderngl.Context)
def test_single_reloadable(self):
"""Load a single file glsl program as reloadable"""
program = resources.programs.load(ProgramDescription(path='programs/white.glsl', reloadable=True))
self.assertIsInstance(program, ReloadableProgram)
# Ensure attribute is present
program['in_position']
self.assertIsInstance(program.extra.get('meta'), ProgramDescription)
self.assertEqual(program.name, 'programs/white.glsl')
self.assertIsInstance(program.ctx, moderngl.Context)
self.assertIsNotNone(program.get('in_position', None))
self.assertIsNotNone(program.mglo)
self.assertGreater(program.glo, 0)
program.subroutines
program.geometry_input
program.geometry_output
program.geometry_vertices
program._members
repr(program)
def test_properties(self):
self.assertEqual(self.window.keys, Keys)
self.assertEqual(self.window.title, 'ModernGL Window')
self.assertIsInstance(self.window.ctx, moderngl.Context)
self.assertIsInstance(self.window.fbo, moderngl.Framebuffer)
self.assertEqual(self.window.gl_version, (4, 1))
self.assertEqual(self.window.width, self.window_size[0])
self.assertEqual(self.window.height, self.window_size[1])
self.assertEqual(self.window.size, self.window_size)
self.assertEqual(self.window.buffer_size, self.window_size)
self.assertEqual(self.window.viewport, (0, 0, self.window_size[0], self.window_size[1]))
self.assertIsInstance(self.window.frames, int)
self.assertEqual(self.window.resizable, False)
self.assertEqual(self.window.fullscreen, False)
self.assertEqual(self.window.config, None)
self.assertEqual(self.window.vsync, False)
self.assertEqual(self.window.aspect_ratio, 1.0)
self.assertEqual(self.window.samples, 0)
self.assertEqual(self.window.cursor, False)
self.assertIsNotNone(self.window.modifiers)
def __init__(self, ctx: moderngl.Context = None, wnd: BaseWindow = None, timer: BaseTimer = None, **kwargs):
"""Initialize the window config
Keyword Args:
ctx (moderngl.Context): The moderngl context
wnd: The window instance
timer: The timer instance
"""
self.ctx = ctx
self.wnd = wnd
self.timer = timer
if self.resource_dir:
resources.register_dir(Path(self.resource_dir).resolve())
if not self.ctx or not isinstance(self.ctx, moderngl.Context):
raise ValueError("WindowConfig requires a moderngl context. ctx={}".format(self.ctx))
if not self.wnd or not isinstance(self.wnd, BaseWindow):
raise ValueError("WindowConfig requires a window. wnd={}".format(self.wnd))