Commits

Anonymous committed c9ff7a6

Updated SDL_mixer and SDL_image dependencies to a minimum of 1.2.11/1.2.10. Added new pygame2.sdlimage.constants module. Added new sdlimage.init() and sdlimage.quit() methods.

  • Participants
  • Parent commits 4724054
  • Branches pgreloaded

Comments (0)

Files changed (15)

 
 [Optional dependencies]
 * SDL >= 1.2.10             (http://www.libsdl.org)
-* SDL_mixer >= 1.2.8        (http://www.libsdl.org/projects/SDL_mixer/)
+* SDL_mixer >= 1.2.11       (http://www.libsdl.org/projects/SDL_mixer/)
 * SDL_ttf >= 2.0.9          (http://www.libsdl.org/projects/SDL_ttf/)
-* SDL_image >= 1.2.6        (http://www.libsdl.org/projects/SDL_image/)
+* SDL_image >= 1.2.10       (http://www.libsdl.org/projects/SDL_image/)
 * SDL_gfx >= 2.0.18         (http://www.ferzkopp.net/Software/SDL_gfx-2.0/)
 * libpng >= 1.2.24          (http://www.libpng.org)
 * libjpeg >= 6b             (http://www.ijg.org/)

File config/config_modules.py

         'sdl_image' : dep(
             ['SDL_image.h'], 'SDL_image',
             config_program='sdl-config',
-            pkgconfig_name='sdl',
+            pkgconfig_name='SDL_image',
             extra_include_dirs = [pygame_sdl_path]),
 
         'png' : dep(

File doc/BuildDarwin.txt

 packages:
 
 * SDL >= 1.2.10              (http://www.libsdl.org)
-* SDL_mixer >= 1.2.8         (http://www.libsdl.org/projects/SDL_mixer/)
+* SDL_mixer >= 1.2.11        (http://www.libsdl.org/projects/SDL_mixer/)
 * SDL_ttf >= 2.0.9           (http://www.libsdl.org/projects/SDL_ttf/)
-* SDL_image >= 1.2.6         (http://www.libsdl.org/projects/SDL_image/)
+* SDL_image >= 1.2.10         (http://www.libsdl.org/projects/SDL_image/)
 * SDL_gfx >= 2.0.18          (http://www.ferzkopp.net/Software/SDL_gfx-2.0/)
 * libpng >= 1.2.24           (http://www.libpng.org)
 * libjpeg >= 6b              (http://www.ijg.org/)

File doc/BuildMinGW.txt

 packages:
 
 * SDL >= 1.2.10              (http://www.libsdl.org)
-* SDL_mixer >= 1.2.8         (http://www.libsdl.org/projects/SDL_mixer/)
+* SDL_mixer >= 1.2.11        (http://www.libsdl.org/projects/SDL_mixer/)
 * SDL_ttf >= 2.0.9           (http://www.libsdl.org/projects/SDL_ttf/)
-* SDL_image >= 1.2.6         (http://www.libsdl.org/projects/SDL_image/)
+* SDL_image >= 1.2.10        (http://www.libsdl.org/projects/SDL_image/)
 * SDL_gfx >= 2.0.18          (http://www.ferzkopp.net/Software/SDL_gfx-2.0/)
 * libpng >= 1.2.24           (http://www.libpng.org)
 * libjpeg >= 6b              (http://www.ijg.org/)

File doc/BuildUnix.txt

 packages:
 
 * SDL >= 1.2.10              (http://www.libsdl.org)
-* SDL_mixer >= 1.2.8         (http://www.libsdl.org/projects/SDL_mixer/)
+* SDL_mixer >= 1.2.11        (http://www.libsdl.org/projects/SDL_mixer/)
 * SDL_ttf >= 2.0.9           (http://www.libsdl.org/projects/SDL_ttf/)
-* SDL_image >= 1.2.6         (http://www.libsdl.org/projects/SDL_image/)
+* SDL_image >= 1.2.10         (http://www.libsdl.org/projects/SDL_image/)
 * SDL_gfx >= 2.0.18          (http://www.ferzkopp.net/Software/SDL_gfx-2.0/)
 * libpng >= 1.2.24           (http://www.libpng.org)
 * libjpeg >= 6b              (http://www.ijg.org/)

File doc/BuildVC.txt

 packages:
 
 * SDL >= 1.2.10              (http://www.libsdl.org)
-* SDL_mixer >= 1.2.8         (http://www.libsdl.org/projects/SDL_mixer/)
+* SDL_mixer >= 1.2.11        (http://www.libsdl.org/projects/SDL_mixer/)
 * SDL_ttf >= 2.0.9           (http://www.libsdl.org/projects/SDL_ttf/)
-* SDL_image >= 1.2.6         (http://www.libsdl.org/projects/SDL_image/)
+* SDL_image >= 1.2.10        (http://www.libsdl.org/projects/SDL_image/)
 * SDL_gfx >= 2.0.18          (http://www.ferzkopp.net/Software/SDL_gfx-2.0/)
 * libpng >= 1.2.24           (http://www.libpng.org)
 * libjpeg >= 6b              (http://www.ijg.org/)

File doc/src/modules.rst

    pygame2_sdlgfx_primitives.rst
    pygame2_sdlgfx_rotozoom.rst
    pygame2_sdlimage.rst
+   pygame2_sdlimage_constants.rst
    pygame2_sdlmixer.rst
    pygame2_sdlmixer_channel.rst
    pygame2_sdlmixer_music.rst

File doc/src/sdlimage_constants.rst

+:mod:`pygame2.sdlimage.constants` -- Constants for SDL_image
+============================================================
+
+This module contains the constants used throughout the
+:mod:`pygame2.sdlimage` modules.
+
+.. module:: pygame2.sdlimage.constants
+   :synopsis: Constants used throughout the :mod:`pygame2.sdlimage` modules.
+
+Initialisation Constants
+------------------------
+
+Those constants are used by the :func:`pygame2.sdlimage.init` function.
+
+.. data:: INIT_JPG
+
+   Initialises the jpeg library bindings.
+
+.. data:: INIT_PNG
+
+   Initialises the png library bindings.
+
+.. data:: INIT_TIF
+
+   Initialises the tiff library bindings.

File doc/src/sdlimagebase.xml

     Basic SDL_image wrapper module
   </desc>
 
+  <func name="init">
+    <call>init (flags) -> int</call>
+    <desc>
+      Initializes the library bindings of the underlying SDL_image library.
+
+      Initializes the library bindings of the underlying SDL_image
+      library. This loads the dynamic libraries for PNG, JPG and TIF
+      images and avoid multiple library loading/unloading calls.
+
+      *NOTE:* The call is optional.
+    </desc>
+  </func>
   <func name="get_error">
     <call>get_error () -> :exc:`pygame2.Error`</call>
     <desc>
 
     </desc>
   </func>
+  <func name="quit">
+    <call>quit () -> None</call>
+    <desc>
+      Deinitializes the library bindings of the underlying SDL_image library.
+
+      Deinitializes the library bindings of the underlying SDL_image
+      library. This releases the loaded dynamic libraries for PNG, JPG
+      and TIF images.
+    </desc>
+  </func>
   <func name="read_xpm_from_array">
     <call>read_xpm_from_array (buffer) -> :class:`pygame2.sdl.video.Surface`</call>
     <desc>Creates a :class:`pygame2.sdl.video.Surface` from a XPM buffer.
         docfile = "sdlimagebase.xml",
         depends = ['SDL', 'SDL_image']),
 
+    Module ("sdlimage.constants",
+        sources = [ "src/sdlimage/constantsmod.c" ],
+        depends = ['SDL', 'SDL_image']),
+
     Module ("sdlgfx.base",
         sources = [
             "src/sdlgfx/fpsmanager.c",

File msys_build_deps.py

 
 """Build Pygame dependencies using MinGW and MSYS
 
-Configured for Pygame 1.9.0 and Python 2.4 and up.
+Configured for Pygame2 2.0.0 and Python 2.4 and up.
 
 The libraries are installed in /usr/local of the MSYS directory structure.
 
 
 This program has been tested against the following libraries:
 
-SDL 1.2 (.13) revision 4114 from SVN 
-SDL_image 1.2.6
-SDL_mixer 1.2 (.8) revision 3942 from SVN
+SDL 1.2.14
+SDL_image 1.2.11
+SDL_mixer 1.2.10
 SDL_ttf 2.0.9
 SDL_gfx 2.0.18
 freetype 2.3.7

File src/sdlimage/constantsmod.c

+/*
+  pygame - Python Game Library
+  Copyright (C) 2010 Marcus von Appen
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public
+  License along with this library; if not, write to the Free
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+#define PYGAME_SDLIMAGECONSTANTS_INTERNAL
+
+#include <SDL_image.h>
+#include "pgsdl.h"
+
+/* macros used to create each constant */
+#define DEC_CONST(x)  PyModule_AddIntConstant(module, #x, (int) IMG_##x)
+
+#ifdef IS_PYTHON_3
+PyMODINIT_FUNC PyInit_constants (void)
+#else
+PyMODINIT_FUNC initconstants (void)
+#endif
+{
+    PyObject *module;
+
+#ifdef IS_PYTHON_3
+    static struct PyModuleDef _module = {
+        PyModuleDef_HEAD_INIT,
+        "constants",
+        "Pygame SDL_image constants",
+        -1,
+        NULL,
+        NULL, NULL, NULL, NULL
+    };
+    module = PyModule_Create (&_module);
+#else
+    module = Py_InitModule3 ("constants", NULL, "Pygame SDL_image constants");
+#endif
+    if (!module)
+        goto fail;
+    
+    DEC_CONST(INIT_JPG);
+    DEC_CONST(INIT_PNG);
+    DEC_CONST(INIT_TIF);
+
+    MODINIT_RETURN(module);
+fail:
+    Py_XDECREF (module);
+    MODINIT_RETURN (NULL);
+}

File src/sdlimage/imagemod.c

 #include "pgsdl.h"
 #include "sdlimagebase_doc.h"
 
+static PyObject* _image_init (PyObject *self, PyObject *args);
+static PyObject* _image_quit (PyObject *self);
 static PyObject* _image_geterror (PyObject *self);
 static PyObject* _image_load (PyObject *self, PyObject *args);
 static PyObject* _image_readxpmfromarray (PyObject *self, PyObject *args);
 
 static PyMethodDef _image_methods[] = {
+    { "init", _image_init, METH_VARARGS, DOC_BASE_INIT },
+    { "quit", _image_quit, METH_VARARGS, DOC_BASE_QUIT },
     { "get_error", (PyCFunction) _image_geterror, METH_NOARGS,
       DOC_BASE_GET_ERROR },
     { "load", _image_load, METH_VARARGS, DOC_BASE_LOAD },
 };
 
 static PyObject*
+_image_init (PyObject *self, PyObject *args)
+{
+    long flags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF;
+    long retval = 0;
+
+    if (!PyArg_ParseTuple (args, "|l:init", &flags))
+        return NULL;
+    retval = IMG_Init (flags);
+    return PyInt_FromLong (flags);
+}
+
+static PyObject*
+_image_quit (PyObject *self)
+{
+    IMG_Quit ();
+    Py_RETURN_NONE;
+}
+
+static PyObject*
 _image_geterror (PyObject *self)
 {
     char *err = IMG_GetError ();
     return Text_FromUTF8 (err);
 }
 
+
 static PyObject*
 _image_load (PyObject *self, PyObject *args)
 {

File src/sdlmixer/constantsmod.c

     DEC_CONSTMIX(FADING_OUT);
     DEC_CONSTMIX(NO_FADING);
 
+    DEC_CONSTMIX(INIT_FLAC);
+    DEC_CONSTMIX(INIT_MOD);
+    DEC_CONSTMIX(INIT_MP3);
+    DEC_CONSTMIX(INIT_OGG);
+
     DEC_CONSTN(MUS_NONE);
     DEC_CONSTN(MUS_CMD);
     DEC_CONSTN(MUS_WAV);

File src/sdlmixer/mixermod.c

 #include "pgsdl.h"
 #include "sdlmixerbase_doc.h"
 
-static PyObject* _mixer_init (PyObject *self);
+static PyObject* _mixer_init (PyObject *self, PyObject *args);
 static PyObject* _mixer_wasinit (PyObject *self);
 static PyObject* _mixer_quit (PyObject *self);
 static PyObject* _mixer_getcompiledversion (PyObject *self);
 static PyObject* _mixer_queryspec (PyObject *self);
 
 static PyMethodDef _mixer_methods[] = {
-    { "init", (PyCFunction) _mixer_init, METH_NOARGS, DOC_BASE_INIT },
+    { "init", _mixer_init, METH_VARARGS, DOC_BASE_INIT },
     { "was_init", (PyCFunction) _mixer_wasinit, METH_NOARGS,
       DOC_BASE_WAS_INIT },
     { "quit", (PyCFunction) _mixer_quit, METH_NOARGS, DOC_BASE_QUIT },
 };
 
 static PyObject*
-_mixer_init (PyObject *self)
+_mixer_init (PyObject *self, PyObject *args)
 {
+    long flags = MIX_INIT_FLAC | MIX_INIT_MOD | MIX_INIT_MP3 | MIX_INIT_OGG;
+    long retval = 0;
+
     if (SDL_WasInit (SDL_INIT_AUDIO))
-        Py_RETURN_NONE;
-        
+    {
+        retval = Mix_Init (flags);
+        return PyLong_FromLong (retval);
+    }
+
     if (SDL_InitSubSystem (SDL_INIT_AUDIO) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
     }
-    Py_RETURN_NONE;
+    retval = Mix_Init (flags);
+    return PyLong_FromLong (retval);
 }
 
 static PyObject*
 {
     if (SDL_WasInit (SDL_INIT_AUDIO))
         SDL_QuitSubSystem (SDL_INIT_AUDIO);
+    Mix_Quit ();
     Py_RETURN_NONE;
 }