예제 #1
0
    def test_pygame2_sdl_gl_get_attribute(self):

        # __doc__ (as of 2009-12-14) for pygame2.sdl.gl.get_attribute:

        # get_attribute (attribute) -> int
        # 
        # Gets an OpenGL attribute value.
        # 
        # Gets the current value of the specified OpenGL attribute constant.
        gllib = self._get_gllib ()
        if not gllib:
            return
        
        # No video.
        self.assertRaises (pygame2.Error, gl.get_attribute, constants.GL_DEPTH_SIZE)
        
        video.init ()
        # No GL library
        self.assertRaises (pygame2.Error, gl.get_attribute, constants.GL_DEPTH_SIZE)

        # No screen
        self.assertEquals (gl.load_library (gllib), None)
        self.assertRaises (pygame2.Error, gl.get_attribute, constants.GL_DEPTH_SIZE)
        
        # No OpenGL screen
        screen = video.set_mode (10, 10)
        self.assertEquals (gl.get_attribute (constants.GL_DEPTH_SIZE), 0)
        
        screen = video.set_mode (10, 10, bpp=32, flags=constants.OPENGL)
        self.assertEquals (gl.get_attribute (constants.GL_DEPTH_SIZE), 24)
        video.quit ()
예제 #2
0
    def todo_test_pygame2_sdl_gl_swap_buffers(self):

        # __doc__ (as of 2009-12-14) for pygame2.sdl.gl.swap_buffers:

        # swap_buffers () -> None
        # 
        # Swap the OpenGL buffers, if double-buffering is supported.
        gllib = self._get_gllib ()
        if not gllib:
            return
        self.assertEquals (gl.load_library (gllib), None)

        self.fail() 
예제 #3
0
    def test_pygame2_sdl_gl_load_library(self):

        # __doc__ (as of 2009-12-14) for pygame2.sdl.gl.load_library:

        # load_library (libraryname) -> None
        # 
        # Loads the desired OpenGL library.
        # 
        # Loads the desired OpenGL library specified by the passed full qualified
        # path. This must be called before any first call to
        # pygame2.sdl.video.set_mode to have any effect.
        self.assertRaises (pygame2.Error, gl.load_library, "invalid_opengl_lib")
        gllib = self._get_gllib ()
        if not gllib:
            return
        self.assertRaises (pygame2.Error, gl.load_library, gllib)

        video.init ()
        self.assertRaises (pygame2.Error, gl.load_library, "invalid_opengl_lib")
        self.assertEquals (gl.load_library (gllib), None)
        video.quit ()
예제 #4
0
    def test_pygame2_sdl_gl_set_attribute(self):

        # __doc__ (as of 2009-12-14) for pygame2.sdl.gl.set_attribute:

        # set_attribute (attribute, value) -> None
        # 
        # Sets an OpenGL attribute value.
        # 
        # Sets the value of the specified OpenGL attribute.
        gllib = self._get_gllib ()
        if not gllib:
            return
        
        # No video.
        self.assertRaises (pygame2.Error, gl.set_attribute, constants.GL_RED_SIZE, 1)
        
        video.init ()

        self.assertEquals (gl.load_library (gllib), None)
        
        # No OpenGL screen
        screen = video.set_mode (10, 10)
        self.assertEquals (gl.set_attribute (constants.GL_RED_SIZE, 1), None)
        self.assertEquals (gl.get_attribute (constants.GL_RED_SIZE), 0)