src/ext/amaretto/gles/inc/glesmodule.h
changeset 0 ca70ae20a155
equal deleted inserted replaced
-1:000000000000 0:ca70ae20a155
       
     1 /**
       
     2  * ====================================================================
       
     3  * glesmodule.h
       
     4  *
       
     5  * Copyright (c) 2006 Nokia Corporation
       
     6  *
       
     7  * Licensed under the Apache License, Version 2.0 (the "License");
       
     8  * you may not use this file except in compliance with the License.
       
     9  * You may obtain a copy of the License at
       
    10  *
       
    11  *     http://www.apache.org/licenses/LICENSE-2.0
       
    12  *
       
    13  * Unless required by applicable law or agreed to in writing, software
       
    14  * distributed under the License is distributed on an "AS IS" BASIS,
       
    15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    16  * See the License for the specific language governing permissions and
       
    17  * limitations under the License.
       
    18  */
       
    19 #ifndef __GLES_H
       
    20 #define __GLES_H
       
    21 
       
    22 #include "Python.h"
       
    23 
       
    24 // For RDebug messages
       
    25 #include <eikenv.h>
       
    26 
       
    27 // For SPy(Add|Get)GlobalString
       
    28 #include "symbian_python_ext_util.h"
       
    29 
       
    30 #include <GLES/gl.h>
       
    31 #include <GLES/egl.h>
       
    32 
       
    33 // comment this out to disable RDebug messages
       
    34 #define DEBUG_GLES
       
    35 
       
    36 // Older SDK versions may include a 1.1 header file while the actual implementation is 1.0
       
    37 #if SERIES60_VERSION<30
       
    38   #undef GL_OES_VERSION_1_1
       
    39 #endif
       
    40 
       
    41 #define RETURN_PYNONE do { Py_INCREF(Py_None); return Py_None; } while(0)
       
    42 #define RETURN_PYTRUE do { Py_INCREF(Py_True); return Py_True; } while(0)
       
    43 #define RETURN_PYFALSE do { Py_INCREF(Py_False); return Py_False; } while(0)
       
    44 
       
    45 #define RETURN_IF_GLERROR do { if(gles_check_error() != 0) { return NULL; } } while(0)
       
    46 
       
    47 #define GLES_ARRAY_TYPE ((PyTypeObject*)SPyGetGlobalString("GLESArrayType"))
       
    48 #define IMAGE_TYPE ((PyTypeObject*)SPyGetGlobalString("ImageType"))
       
    49 
       
    50 #define DEBUGMSG(msg) do { RDebug::Print(_L(msg)); } while(0)
       
    51 #define DEBUGMSG1(msg,arg1) do { RDebug::Print(_L(msg),arg1); } while(0)
       
    52 #define DEBUGMSG2(msg,arg1,arg2) do { RDebug::Print(_L(msg),arg1,arg2); } while(0)
       
    53 #define DEBUGMSG3(msg,arg1,arg2,arg3) do { RDebug::Print(_L(msg),arg1,arg2,arg3); } while(0)
       
    54 #define DEBUGMSG4(msg,arg1,arg2,arg3,arg4) do { RDebug::Print(_L(msg),arg1,arg2,arg3,arg4); } while(0)
       
    55 
       
    56 // Structure for an array pointer
       
    57 struct gles_array_t {
       
    58   void* ptr; // A pointer to the vertex/etc. data
       
    59   PyObject *obj; // Associated Python object (can be NULL).
       
    60 };
       
    61 
       
    62 // Structure for array storage in TLS
       
    63 struct GLES_Arrays {
       
    64   gles_array_t color;     // Pointer for color array
       
    65   gles_array_t normal;    // Pointer for normal array
       
    66   gles_array_t texcoord;  // Pointer for texture coordinate array
       
    67   gles_array_t vertex;    // Pointer for vertex array
       
    68   gles_array_t matrix;    // Pointer for matrix index array
       
    69   gles_array_t pointsize; // Pointer for point size array
       
    70   gles_array_t weight;    // Pointer for weight array
       
    71 };
       
    72 
       
    73 // Definition for gles.array object
       
    74 struct array_object {
       
    75   PyObject_VAR_HEAD
       
    76   // Array object specific fields below.
       
    77   void *arrdata; // A pointer to the raw data.
       
    78   signed int len; // How many elements in the array.
       
    79   GLenum arrtype; // Type of array.
       
    80   // Length of a single element (needed for glVertexPointer etc.)
       
    81   signed int dimension;
       
    82   // Lenght of an item in bytes
       
    83   signed int item_size;
       
    84   // Lenght of the data in bytes
       
    85   signed int real_len;
       
    86 };
       
    87 
       
    88 extern "C" PyObject *new_array_object(PyObject */*self*/, PyObject *args);
       
    89 /*extern "C" static void array_dealloc(array_object *op);
       
    90 extern "C" static PyObject *array_getattr(array_object *op, char *name);
       
    91 extern "C" static int array_setattr(array_object *op, char *name, PyObject *v);*/
       
    92 
       
    93 // Prototypes for functions in gles_util.cpp
       
    94 void *gles_convert_fbsbitmap(CFbsBitmap *bitmap, GLenum format, GLenum type, unsigned int *datalen);
       
    95 CFbsBitmap *Bitmap_AsFbsBitmap(PyObject *obj);
       
    96 PyObject *PyCAPI_GetCAPI(PyObject *object, const char *apiname);
       
    97 
       
    98 int gles_PySequence_Dimension(PyObject *seq);
       
    99 PyObject *gles_PySequence_Collapse(GLenum type, PyObject *source, PyObject *target);
       
   100 void *gles_assign_array(GLenum targetarr, void *ptr, array_object *object);
       
   101 
       
   102 GLbyte   *gles_PySequence_AsGLbyteArray(PyObject *seq);
       
   103 GLubyte  *gles_PySequence_AsGLubyteArray(PyObject *seq);
       
   104 GLfloat  *gles_PySequence_AsGLfloatArray(PyObject *seq);
       
   105 GLshort  *gles_PySequence_AsGLshortArray(PyObject *seq);
       
   106 GLushort *gles_PySequence_AsGLushortArray(PyObject *seq);
       
   107 GLint    *gles_PySequence_AsGLintArray(PyObject *seq);
       
   108 GLuint   *gles_PySequence_AsGLuintArray(PyObject *seq);
       
   109 GLfixed  *gles_PySequence_AsGLfixedArray(PyObject *seq);
       
   110 
       
   111 void *gles_alloc(size_t size);
       
   112 void gles_free(void *ptr);
       
   113 
       
   114 void gles_free_array(GLenum arrtype);
       
   115 void gles_init_arrays();
       
   116 void gles_uninit_arrays();
       
   117 unsigned int gles_check_error();
       
   118   
       
   119 #endif // __GLES_H