Commits

Anonymous committed 96dd4ba

Added boolean and double type recognition to pygame2.openal property methods.

  • Participants
  • Parent commits c2a6107
  • Branches pgreloaded

Comments (0)

Files changed (5)

 features as possible and thus will enable them.
 
 Currently the following environment variables are controlling, which
-components of pgreloaded should be build: ::
+components of pygame2 should be build: ::
 
   WITH_SDL=[yes|no|1|True]                Example: make -DWITH_SDL=yes
 
 Build and install the :mod:`pygame2.openal` module. This wraps the OpenAL
 library and gives access to the :mod:`pygame2.openal` module. ::
 
-  WITH_OPENMP=[yes|no|1|True]         Example: make -DWITH_OPENAL=1
+  WITH_OPENMP=[yes|no|1|True]             Example: make -DWITH_OPENAL=1
     
 Add support for the Open Multi-Processing library. This will utilize the
 OpenMP API to speed up certain routines, such as e.g blit and fill

doc/create_rstref.py

         data += "%s\n" % self.create_desc_rst (func.description, 2)
         return data
 
-    def create_example_rst (self, example, showex=False):
+    def create_example_rst (self, example, showex=True):
         data = ""
         if showex:
             data = "  **Example:** ::\n"
             fp.write (".. currentmodule:: %s\n\n" % (name))
 
         if len (self.example) > 0:
-            fp.write (self.create_example_rst (self.example, True))
+            fp.write (self.create_example_rst (self.example))
 
         if len (self.data) > 0:
             fp.write ("Data Fields\n")
                             fp.write ("            %s.%s\n" % (cls.name, call))
                         fp.write (self.create_desc_rst (method.description, 2))
                         if len (method.example) > 0:
-                            fp.write ("Example:\n")
                             fp.write (self.create_example_rst (method.example))
 
         fp.write ("\n")
   </desc>
 
   <data name="__version__">
-    The version of the Pygame2 package as string.
+    The version of the pygame2 package as string.
   </data>
 
   <data name="version_info">
-    The version of the Pygame2 package as value tuple. The tuple is of
+    The version of the pygame2 package as value tuple. The tuple is of
     the form ``('major', 'minor', 'micro', 'releaselevel')``, where all
     values except the *releaselevel* are integers.
   </data>
       <desc>
         Applies a certain gamma value to the Color.
 
-        Applies a certain gamma value to the Color and returns a new
-        Color with the adjusted RGBA values.
+        Applies a certain *gamma* value to the Color and returns a new
+        Color with the adjusted RGBA values. The *gamma* value will be
+        used as exponent for a power of calculation to adjust the actual
+        gamma tone.
+
+        The passed *gamma* value will influence he overall luminance of
+        the color, where the following rules apply.
+        
+        * Pure white and black colors (R = G = B = 255 or 0) won't be effected by adjusting the gamma value.
+        * the smaller the gamma factor, the higher the luminance and thus the brighter the color channels will be.
       </desc>
+      <example>
+        from pygame2 import Color
+
+        color = Color (127, 127, 127)
+        # 1.0 has no effect - corrected will be (127, 127, 127)
+        corrected = color.correct_gamma (1.0)
+        # 0.5 brightens the color by two - brightened will be (180, 180, 180)
+        brightened = color.correct_gamma (0.5)
+        # 2.0 darkens the color by two - darkened will be (63, 63, 63)
+        darkened = color.correct_gamma (2.0)
+      </example>
     </method>
     <attr name="g">
       <desc>Gets or sets the green value of the Color.</desc>
         Returns the normalized RGBA values of the Color as floating
         point values.
       </desc>
+      <example>
+        from pygame2 import Color
+
+        color = Color (255, 255, 255)
+        # normalized will be (1.0, 1.0, 1.0, 1.0)
+        normalized = color.normalize ()
+      </example>
     </method>
     <attr name="r">
       <desc>Gets or sets the red value of the Color.</desc>

doc/src/openalbase.xml

   <short>basic OpenAL wrapper module</short>
   <desc>
     Basic Pygame2 OpenAL wrapper module.
+
+
+
+
+    Identifiers for the property get and set methods:
+    
+    +------+------------------------------------------------------------+
+    | 'b'  | Get or set a single boolean value (e.g. AL_TRUE)           |
+    +------+------------------------------------------------------------+
+    | 'ba' | Get or set an array of boolean values. The array can be    |
+    |      | any type of sequence containing matching values.           |
+    +------+------------------------------------------------------------+
+    | 'i'  | Get or set a single integer value.                         |
+    +------+------------------------------------------------------------+
+    | 'i3' | Get or set an triplet of integer values. The array can be  |
+    |      | any type of sequence containing matching values.           |
+    +------+------------------------------------------------------------+
+    | 'ia' | Get or set an array of integer values. The array can be    |
+    |      | any type of sequence containing matching values.           |
+    +------+------------------------------------------------------------+
+    | 'f'  | Get or set a single floating point value.                  |
+    +------+------------------------------------------------------------+
+    | 'f3' | Get or set an triplet of floating point values. The array  |
+    |      | can be any type of sequence containing matching values.    |
+    +------+------------------------------------------------------------+
+    | 'fa' | Get or set an array of floating point values. The array    |
+    |      | can be any type of sequence containing matching values.    |
+    +------+------------------------------------------------------------+
+    | 'd'  | Get or set a single double precision floating point value. |
+    +------+------------------------------------------------------------+
+    | 'da' | Get or set an array of double precision floating point     |
+    |      | values. The array can be any type of sequence containing   |
+    |      | matching values.                                           |
+    +------+------------------------------------------------------------+
   </desc>
 
   <class name="Buffers">
       <example></example>
     </method>
     <attr name="buffers">
-      <desc>None</desc>
+      <desc>The buffer identifiers used inb the Buffers instance.</desc>
       <example></example>
     </attr>
     <attr name="count">
-      <desc>None</desc>
+      <desc>The number of buffers.</desc>
       <example></example>
     </attr>
     <method name="get_prop">
-      <call></call>
-      <desc></desc>
+      <call>get_prop (bufnum, prop, type) -> value or (value, ...) </call>
+      <desc>
+        Retrieves the value(s) of an OpenAL property for the Buffers.
+      
+        
+      </desc>
       <example></example>
     </method>
     <method name="set_prop">

src/openal/openalmod.c

         return INVALID;
 
     len = strlen (name);
+    if (len > 2)
+        return INVALID;
 
-    if (len == 1)
+    switch (name[0])
     {
-        if (name[0] == 'i')
-            return INT;
-        else if (name[0] == 'f')
-            return FLOAT;
+    case 'b':
+    {
+        if (len == 2)
+        {
+            if (name[1] == 'a')
+                return BOOLARRAY;
+            return INVALID;
+        }
+        return BOOL;
+    }
+    case 'd':
+    {
+        if (len == 2)
+        {
+            if (name[1] == 'a')
+                return DOUBLEARRAY;
+            return INVALID;
+        }
+        return DOUBLE;
+    }
+    case 'f':
+    {
+        if (len == 2)
+        {
+            if (name[1] == '3')
+                return FLOAT3;
+            if (name[1] == 'a')
+                return FLOATARRAY;
+            return INVALID;
+        }
+        return FLOAT;
+    }
+    case 'i':
+    {
+        if (len == 2)
+        {
+            if (name[1] == '3')
+                return INT3;
+            if (name[1] == 'a')
+                return INTARRAY;
+            return INVALID;
+        }
+        return INT;
+    }
+    default:
         return INVALID;
     }
 
-    if (len == 2)
-    {
-        if (name[0] == 'i')
-        {
-            if (name[1] == 'a')
-                return INTARRAY;
-            if (name[1] == '3')
-                return INT3;
-        }
-        else if (name[0] == 'f')
-        {
-            if (name[1] == 'a')
-                return FLOATARRAY;
-            if (name[1] == '3')
-                return FLOAT3;
-        }
-    }
     return INVALID;
 }