From f12403b590cf0722077ec97a7c777ee97d2670b0 Mon Sep 17 00:00:00 2001 From: "Mike C. Fletcher" Date: Thu, 2 Jan 2020 13:26:43 -0500 Subject: [PATCH] WGL FIX Set the resstyle for getCurrentDC in the wrapper --- OpenGL/WGL/VERSION/WGL_1_0.py | 4 ++- tests/test_wgl.py | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/test_wgl.py diff --git a/OpenGL/WGL/VERSION/WGL_1_0.py b/OpenGL/WGL/VERSION/WGL_1_0.py index 00b9c19d..e15b4445 100644 --- a/OpenGL/WGL/VERSION/WGL_1_0.py +++ b/OpenGL/WGL/VERSION/WGL_1_0.py @@ -20,4 +20,6 @@ def glInitWgl10VERSION(): return extensions.hasGLExtension( _EXTENSION_NAME ) -### END AUTOGENERATED SECTION \ No newline at end of file +### END AUTOGENERATED SECTION + +wglGetCurrentDC.restyle = ctypes.HDC diff --git a/tests/test_wgl.py b/tests/test_wgl.py new file mode 100644 index 00000000..4e4e6c6a --- /dev/null +++ b/tests/test_wgl.py @@ -0,0 +1,50 @@ +from __future__ import print_function +import pytest, os, sys, unittest +import logging +log = logging.getLogger(__name__) +HERE = os.path.dirname( __file__ ) +if sys.platform != 'win32': + raise pytest.skip(reason='Non-windows platform') +try: + from numpy import * +except ImportError as err: + array = None +import pygame, pygame.display +pygame.display.init() +from OpenGL.GL import * +from OpenGL.WGL import * + + +class TestWGL(unittest.TestCase): + width,height = 300,300 + def setUp(self): + self.screen = pygame.display.set_mode( + (self.width,self.height), + pygame.OPENGL | pygame.DOUBLEBUF, + ) + + pygame.display.set_caption('Testing system') + pygame.key.set_repeat(500,30) + def tearDown(self): + pygame.display.flip() + + def test_wgl_imported(self): + assert bool(wglCreateContext) + def test_create_context(self): + window = pygame.display.get_wm_info()['window'] + wglCreateContext(window) + + def test_get_extensions_low_level(self): + from OpenGL.WGL.ARB.extensions_string import wglGetExtensionsStringARB + window = pygame.display.get_wm_info()['window'] + extensions = wglGetExtensionsStringARB(wglGetCurrentDC()) + assert extensions + assert b'WGL_ARB_extensions_string' in extensions, extensions + + def test_swap_control_interval(self): + from OpenGL.WGL.EXT import swap_control + if not swap_control.wglGetSwapIntervalEXT: + raise pytest.skip(reason='No wglGetSwapIntervalEXT available') + interval = swap_control.wglGetSwapIntervalEXT() + + swap_control.wglSwapIntervalEXT(1)