os/graphics/graphics_plat/m3g_core_api/inc/M3G/m3g_core.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: M3G core API public interface
    15 *
    16 */
    17 
    18 #ifndef __M3G_CORE_H__
    19 #define __M3G_CORE_H__
    20 
    21 #if defined(__cplusplus)
    22 extern "C" {
    23 #endif
    24 
    25 /*!
    26  * \file
    27  * \brief Public interface to the M3G core library
    28  *
    29  * This can be overlaid by an additional layer providing the actual
    30  * API for different languages; for the JSR184 API, this is the Java
    31  * binding layer.
    32  */
    33 
    34 #if (__ARMCC_VERSION >= 220000)
    35 #   if defined(M3G_BUILD_DLL)
    36 #       define M3G_API __declspec(dllexport)
    37 #   else
    38 #       define M3G_API __declspec(dllimport)
    39 #   endif
    40 #else
    41 #   if defined(M3G_BUILD_DLL)
    42 #       define M3G_API __declspec(dllexport)
    43 #   else
    44 #       define M3G_API
    45 #   endif
    46 #endif
    47     
    48 /*----------------------------------------------------------------------
    49  * Enumerated constants
    50  *--------------------------------------------------------------------*/
    51 
    52 /*javax.microedition.m3g.AnimationTrack*/
    53 #define M3G_ANIM_ALPHA          256
    54 #define M3G_ANIM_AMBIENT_COLOR  257
    55 #define M3G_ANIM_COLOR          258
    56 #define M3G_ANIM_CROP           259
    57 #define M3G_ANIM_DENSITY        260
    58 #define M3G_ANIM_DIFFUSE_COLOR  261
    59 #define M3G_ANIM_EMISSIVE_COLOR 262
    60 #define M3G_ANIM_FAR_DISTANCE   263
    61 #define M3G_ANIM_FIELD_OF_VIEW  264
    62 #define M3G_ANIM_INTENSITY      265
    63 #define M3G_ANIM_MORPH_WEIGHTS  266
    64 #define M3G_ANIM_NEAR_DISTANCE  267
    65 #define M3G_ANIM_ORIENTATION    268
    66 #define M3G_ANIM_PICKABILITY    269
    67 #define M3G_ANIM_SCALE          270
    68 #define M3G_ANIM_SHININESS      271
    69 #define M3G_ANIM_SPECULAR_COLOR 272
    70 #define M3G_ANIM_SPOT_ANGLE     273
    71 #define M3G_ANIM_SPOT_EXPONENT  274
    72 #define M3G_ANIM_TRANSLATION    275
    73 #define M3G_ANIM_VISIBILITY     276
    74 
    75 /*javax.microedition.m3g.Background*/
    76 #define M3G_BORDER              32
    77 #define M3G_REPEAT              33
    78 
    79 /*javax.microedition.m3g.Camera*/
    80 #define M3G_GENERIC             48
    81 #define M3G_PARALLEL            49
    82 #define M3G_PERSPECTIVE         50
    83 
    84 /*javax.microedition.m3g.CompositingMode*/
    85 #define M3G_ALPHA_BLEND         64
    86 #define M3G_ALPHA_ADD           65
    87 #define M3G_MODULATE            66
    88 #define M3G_MODULATE_X2         67
    89 #define M3G_REPLACE             68
    90 
    91 /*javax.microedition.m3g.Fog*/
    92 #define M3G_EXPONENTIAL_FOG     80
    93 #define M3G_LINEAR_FOG          81
    94 
    95 /*javax.microedition.m3g.Graphics3D*/
    96 #define M3G_ANTIALIAS_BIT       2
    97 #define M3G_DITHER_BIT          4
    98 #define M3G_TRUECOLOR_BIT       8
    99 #define M3G_OVERWRITE_BIT       16
   100 
   101 /*javax.microedition.m3g.Image2D*/
   102 typedef enum 
   103 {
   104     M3G_ALPHA           = 96,
   105     M3G_LUMINANCE       = 97,
   106     M3G_LUMINANCE_ALPHA = 98,
   107     M3G_RGB             = 99,
   108     M3G_RGBA            = 100
   109 } M3GImageFormat;
   110 
   111 /*javax.microedition.m3g.KeyframeSequence*/
   112 #define M3G_LINEAR              176
   113 #define M3G_SLERP               177
   114 #define M3G_SPLINE              178
   115 #define M3G_SQUAD               179
   116 #define M3G_STEP                180
   117 #define M3G_CONSTANT            192
   118 #define M3G_LOOP                193
   119 
   120 /*javax.microedition.m3g.Light*/
   121 #define M3G_AMBIENT             128
   122 #define M3G_DIRECTIONAL         129
   123 #define M3G_OMNI                130
   124 #define M3G_SPOT                131
   125 
   126 /*javax.microedition.m3g.Material*/
   127 #define M3G_AMBIENT_BIT         1024
   128 #define M3G_DIFFUSE_BIT         2048
   129 #define M3G_EMISSIVE_BIT        4096
   130 #define M3G_SPECULAR_BIT        8192
   131 
   132 /*javax.microedition.m3g.Node*/
   133 #define M3G_NONE                144
   134 #define M3G_ORIGIN              145
   135 #define M3G_X_AXIS              146
   136 #define M3G_Y_AXIS              147
   137 #define M3G_Z_AXIS              148
   138 
   139 /*javax.microedition.m3g.Object3D*/
   140 typedef enum {    
   141     M3G_CLASS_ANIMATION_CONTROLLER = 1,
   142     M3G_CLASS_ANIMATION_TRACK      = 2,
   143     M3G_CLASS_APPEARANCE           = 3,
   144     M3G_CLASS_BACKGROUND           = 4,
   145     M3G_CLASS_CAMERA               = 5,
   146     M3G_CLASS_COMPOSITING_MODE     = 6,
   147     M3G_CLASS_FOG                  = 7,
   148     M3G_CLASS_GROUP                = 8,
   149     M3G_CLASS_IMAGE                = 9,
   150     M3G_CLASS_INDEX_BUFFER         = 10,
   151     M3G_CLASS_KEYFRAME_SEQUENCE    = 11,
   152     M3G_CLASS_LIGHT                = 12,
   153     M3G_CLASS_LOADER               = 13,
   154     M3G_CLASS_MATERIAL             = 14,
   155     M3G_CLASS_MESH                 = 15,
   156     M3G_CLASS_MORPHING_MESH        = 16,
   157     M3G_CLASS_POLYGON_MODE         = 17,
   158     M3G_CLASS_RENDER_CONTEXT       = 18,
   159     M3G_CLASS_SKINNED_MESH         = 19,
   160     M3G_CLASS_SPRITE               = 20,
   161     M3G_CLASS_TEXTURE              = 21,
   162     M3G_CLASS_VERTEX_ARRAY         = 22,
   163     M3G_CLASS_VERTEX_BUFFER        = 23,
   164     M3G_CLASS_WORLD                = 24,
   165     /* extra enumeration used for abstract classes */
   166     M3G_ABSTRACT_CLASS             = 0
   167 } M3GClass;
   168     
   169 /*javax.microedition.m3g.PolygonMode*/
   170 #define M3G_CULL_BACK           160
   171 #define M3G_CULL_FRONT          161
   172 #define M3G_CULL_NONE           162
   173 #define M3G_SHADE_FLAT          164
   174 #define M3G_SHADE_SMOOTH        165
   175 #define M3G_WINDING_CCW         168
   176 #define M3G_WINDING_CW          169
   177 
   178 /*javax.microedition.m3g.Texture2D*/
   179 #define M3G_FILTER_BASE_LEVEL   208
   180 #define M3G_FILTER_LINEAR       209
   181 #define M3G_FILTER_NEAREST      210
   182 #define M3G_FUNC_ADD            224
   183 #define M3G_FUNC_BLEND          225
   184 #define M3G_FUNC_DECAL          226
   185 #define M3G_FUNC_MODULATE       227
   186 #define M3G_FUNC_REPLACE        228
   187 #define M3G_WRAP_CLAMP          240
   188 #define M3G_WRAP_REPEAT         241
   189 
   190 /*javax.microedition.m3g.Defs*/
   191 #define M3G_GET_POSITIONS       0
   192 #define M3G_GET_NORMALS         1
   193 #define M3G_GET_COLORS          2
   194 #define M3G_GET_TEXCOORDS0      3
   195 #define M3G_GET_CROPX           0
   196 #define M3G_GET_CROPY           1
   197 #define M3G_GET_CROPWIDTH       2
   198 #define M3G_GET_CROPHEIGHT      3
   199 #define M3G_GET_MODEX           0
   200 #define M3G_GET_MODEY           1
   201 #define M3G_SETGET_COLORCLEAR   0
   202 #define M3G_SETGET_DEPTHCLEAR   1
   203 #define M3G_GET_NEAR            0
   204 #define M3G_GET_FAR             1
   205 #define M3G_SETGET_RENDERING    0
   206 #define M3G_SETGET_PICKING      1
   207 #define M3G_GET_CONSTANT        0
   208 #define M3G_GET_LINEAR          1
   209 #define M3G_GET_QUADRATIC       2
   210 
   211 /*--------------------------------------------------------------------*/
   212 /* Object usage flag bits
   213  *
   214  * Currently only used for Image
   215  */
   216 
   217 /*! \brief Specifies that an object can be written to at any time */
   218 #define M3G_DYNAMIC             0x0001
   219 /*! \brief Specifies that an object can only be written to prior to
   220  *  its first use (default) */
   221 #define M3G_STATIC              0x0002
   222 /*! \brief Specifies that an Image can be rendered to (implies
   223  *  M3G_DYNAMIC) */
   224 #define M3G_RENDERING_TARGET    0x0004
   225 /*!
   226  * \brief Specifies that an Image is paletted
   227  */
   228 #define M3G_PALETTED            0x0008
   229 
   230 
   231 /*--------------------------------------------------------------------*/
   232 /* Buffer bit constants */
   233 #define M3G_COLOR_BUFFER_BIT        0x0001
   234 #define M3G_DEPTH_BUFFER_BIT        0x0002
   235 #define M3G_STENCIL_BUFFER_BIT      0x0004
   236 #define M3G_MULTISAMPLE_BUFFER_BIT  0x0008
   237 
   238 /*--------------------------------------------------------------------*/
   239 /* Pixel (output/texture) formats
   240  */
   241 typedef enum {
   242     M3G_L8,
   243     M3G_A8,
   244     M3G_LA8,
   245     M3G_LA4,
   246     M3G_RGB8,
   247     M3G_RGB8_32,
   248     M3G_BGR8_32,
   249     M3G_RGB4,
   250     M3G_RGB565,
   251     M3G_RGBA8,
   252     M3G_BGRA8,
   253     M3G_ARGB8,
   254     M3G_RGBA4,
   255     M3G_RGB5A1,
   256     M3G_PALETTE8_RGB8,
   257     M3G_PALETTE8_RGB8_32,
   258     M3G_PALETTE8_RGBA8,
   259     M3G_NO_FORMAT
   260 } M3GPixelFormat;
   261 
   262 /* Errors */
   263 typedef enum {
   264     M3G_NO_ERROR = 0x00,
   265     M3G_INVALID_VALUE,
   266     M3G_INVALID_ENUM,
   267     M3G_INVALID_OPERATION,
   268     M3G_INVALID_OBJECT,
   269     M3G_INVALID_INDEX,
   270     M3G_OUT_OF_MEMORY,
   271     M3G_NULL_POINTER,
   272     M3G_ARITHMETIC_ERROR,
   273     M3G_IO_ERROR
   274 } M3GError;
   275 
   276 /* Supported types of rendering primitives
   277  *
   278  * These match GL enums directly.
   279  */
   280 typedef enum {
   281     M3G_TRIANGLE_STRIPS = 0x05
   282     /*M3G_TRIANGLES,
   283       M3G_TRIANGLE_FANS*/
   284 } M3Gprimitive;
   285 
   286 /*--------------------------------------------------------------------*/
   287 /*! \brief Supported input data types
   288  *
   289  * These can be converted to/from OpengGL type enums by adding 0x1400.
   290  */
   291 typedef enum {
   292     M3G_BYTE    = 0x00,
   293     M3G_UBYTE,
   294     M3G_SHORT,
   295     M3G_USHORT,
   296     M3G_INT,
   297     M3G_UINT,
   298     M3G_FLOAT
   299 } M3Gdatatype;
   300 
   301 /*--------------------------------------------------------------------*/
   302 /*! \brief Profiling statistics */
   303 typedef enum {
   304     M3G_STAT_CULLING_TESTS,
   305     M3G_STAT_FLOPS,
   306     M3G_STAT_MEMORY_ALLOCS,
   307     M3G_STAT_MEMORY_LOCKS,
   308     M3G_STAT_RENDER_NODES,
   309     M3G_STAT_RENDER_NODES_CULLED,
   310     M3G_STAT_RENDER_NODES_DRAWN,
   311     M3G_STAT_TCACHE_COMPOSITE_COLLISIONS,
   312     M3G_STAT_TCACHE_COMPOSITE_HITS,
   313     M3G_STAT_TCACHE_COMPOSITE_INSERTS,
   314     M3G_STAT_TCACHE_COMPOSITE_MISSES,
   315     M3G_STAT_TCACHE_PATH_COLLISIONS,
   316     M3G_STAT_TCACHE_PATH_FLUSHES,
   317     M3G_STAT_TCACHE_PATH_HITS,
   318     M3G_STAT_TCACHE_PATH_INSERTS,
   319     M3G_STAT_TCACHE_PATH_MISSES,
   320     M3G_PROFILE_ALIGN,
   321     M3G_PROFILE_ANIM,
   322     M3G_PROFILE_BINDTORELEASE,
   323     M3G_PROFILE_COMMIT,
   324     M3G_PROFILE_LOADER_DECODE,
   325     M3G_PROFILE_MORPH,
   326     M3G_PROFILE_NGL_DRAW,
   327     M3G_PROFILE_PICK,
   328     M3G_PROFILE_RELEASETOBIND,
   329     M3G_PROFILE_SETUP,
   330     M3G_PROFILE_SETUP_SORT,
   331     M3G_PROFILE_SETUP_TRANSFORMS,
   332     M3G_PROFILE_SKIN,
   333     M3G_PROFILE_TCACHE,
   334     M3G_PROFILE_TRANSFORM_INVERT,
   335     M3G_PROFILE_TRANSFORM_TO,
   336     M3G_PROFILE_VALIDATE,
   337     M3G_PROFILE_VFC_TEST,
   338     M3G_PROFILE_VFC_UPDATE,
   339     /*----------------*/
   340     M3G_STAT_CUMULATIVE, /* the rest are not cleared automatically */
   341     /*----------------*/
   342     M3G_STAT_BOUNDING_BOXES,
   343     M3G_STAT_MEMORY_ALLOCATED,
   344     M3G_STAT_MEMORY_MALLOC_BYTES,
   345     M3G_STAT_MEMORY_MALLOC_PEAK,
   346     M3G_STAT_MEMORY_OBJECT_BYTES,
   347     M3G_STAT_MEMORY_OBJECT_PEAK,
   348     M3G_STAT_MEMORY_PEAK,
   349     M3G_STAT_OBJECTS,
   350     M3G_STAT_RENDERABLES,
   351     M3G_STAT_RENDERQUEUE_SIZE,
   352     M3G_STAT_TCACHE_COMPOSITE_LOAD,
   353     M3G_STAT_TCACHE_PATH_LOAD,
   354     /*----------------*/
   355     M3G_STAT_MAX
   356 } M3Gstatistic;
   357 
   358 #define MIN_PROFILE_STAT    M3G_PROFILE_ALIGN
   359 
   360 /*----------------------------------------------------------------------
   361  * Portable numeric types
   362  *--------------------------------------------------------------------*/
   363 
   364 typedef int             M3Gint;     /*!< \brief 32-bit signed integer   */
   365 typedef short           M3Gshort;   /*!< \brief 16-bit signed integer   */
   366 typedef signed char     M3Gbyte;    /*!< \brief  8-bit signed integer   */
   367 typedef unsigned        M3Guint;    /*!< \brief 32-bit unsigned integer */
   368 typedef unsigned short  M3Gushort;  /*!< \brief 16-bit unsigned integer */
   369 typedef unsigned char   M3Gubyte;   /*!< \brief  8-bit unsigned integer */
   370 typedef float           M3Gfloat;   /*!< \brief 32-bit IEEE float */
   371 
   372 typedef M3Gint   M3Genum;
   373 typedef M3Guint  M3Gbitmask;
   374 typedef M3Guint  M3Gbool;
   375 
   376 typedef M3Gint  M3Gsizei;
   377 
   378 /* Boolean values */
   379 #define M3G_TRUE        ((M3Gbool)1)
   380 #define M3G_FALSE       ((M3Gbool)0)
   381 
   382 /*----------------------------------------------------------------------
   383  * Object handle types
   384  *--------------------------------------------------------------------*/
   385 
   386 typedef struct M3GInterfaceImpl *M3GInterface;
   387 typedef struct M3GLoaderImpl *M3GLoader;
   388 typedef struct M3GObjectImpl *M3GObject;
   389     typedef struct M3GAnimationControllerImpl *M3GAnimationController;
   390     typedef struct M3GAnimationTrackImpl *M3GAnimationTrack;
   391     typedef struct M3GAppearanceImpl *M3GAppearance;
   392     typedef struct M3GBackgroundImpl *M3GBackground;
   393     typedef struct M3GCompositingModeImpl *M3GCompositingMode;
   394     typedef struct M3GFogImpl *M3GFog;
   395     typedef struct M3GImageImpl *M3GImage;
   396     typedef struct M3GIndexBufferImpl *M3GIndexBuffer;
   397     typedef struct M3GKeyframeSequenceImpl *M3GKeyframeSequence;
   398     typedef struct M3GMaterialImpl *M3GMaterial;
   399     typedef struct M3GTransformableImpl *M3GTransformable;
   400         typedef struct M3GNodeImpl *M3GNode;
   401             typedef struct M3GCameraImpl *M3GCamera;
   402             typedef struct M3GGroupImpl *M3GGroup;
   403                 typedef struct M3GWorldImpl *M3GWorld;
   404             typedef struct M3GLightImpl *M3GLight;
   405             typedef struct M3GMeshImpl *M3GMesh;
   406                 typedef struct M3GMorphingMeshImpl *M3GMorphingMesh;
   407                 typedef struct M3GSkinnedMeshImpl *M3GSkinnedMesh;
   408             typedef struct M3GSpriteImpl *M3GSprite;
   409         typedef struct M3GTextureImpl *M3GTexture;
   410     typedef struct M3GPolygonModeImpl *M3GPolygonMode;
   411     typedef struct M3GRenderContextImpl *M3GRenderContext;
   412     typedef struct M3GVertexArrayImpl *M3GVertexArray;
   413     typedef struct M3GVertexBufferImpl *M3GVertexBuffer;
   414 
   415 typedef /*@abstract@*/ M3Gint M3GMemObject;
   416 
   417 /*----------------------------------------------------------------------
   418  * Abstracted OpenGL rendering target types
   419  *--------------------------------------------------------------------*/
   420 
   421 typedef /*@abstract@*/ M3Guint M3GNativeBitmap;
   422 typedef /*@abstract@*/ M3Guint M3GNativeWindow;
   423 typedef /*@abstract@*/ M3Guint M3GEGLSurface;
   424 
   425 /*----------------------------------------------------------------------
   426  * Math API
   427  *--------------------------------------------------------------------*/
   428 
   429 /* -------- Data types -------- */
   430 
   431 /*!
   432  * \brief An optimized 4x4 matrix class.
   433  *
   434  * \note This is an abstract type, and only declared here so that it
   435  * can be instantiated on the stack.  The internal format may change
   436  * in the future.
   437  */
   438 typedef struct
   439 {
   440     /* If you change this struct be sure to check the
   441      * structure size against the array size in Transform.java!! */
   442     M3Gfloat elem[16];
   443     M3Guint mask;
   444     M3Guint classified  : 1;
   445     M3Guint complete    : 1;
   446 } M3GMatrix;
   447 
   448 /*!
   449  * \brief A 3-vector class
   450  */
   451 typedef struct {
   452     M3Gfloat x, y, z;
   453 } M3GVec3;
   454 
   455 /*!
   456  * \brief A 4-vector class
   457  */
   458 typedef struct {
   459     M3Gfloat x, y, z, w;
   460 } M3GVec4;
   461 
   462 /*!
   463  * \brief A quaternion class
   464  */
   465 typedef struct {
   466     M3Gfloat x, y, z, w;
   467 } M3GQuat;
   468 
   469 /*!
   470  * \brief A rectangle
   471  */
   472 typedef struct {
   473 	M3Gint x;
   474 	M3Gint y;
   475 	M3Gint width;
   476 	M3Gint height;
   477 } M3GRectangle;
   478 
   479 /* -------- Interpolation -------- */
   480 
   481 M3G_API void m3gLerp    (M3Gint size,
   482                          M3Gfloat *vec,
   483                          M3Gfloat s,
   484                          const M3Gfloat *start, const M3Gfloat *end);
   485 M3G_API void m3gHermite (M3Gint size,
   486                          M3Gfloat *vec,
   487                          M3Gfloat s,
   488                          const M3Gfloat *start, const M3Gfloat *end,
   489                          const M3Gfloat *tStart, const M3Gfloat *tEnd);
   490 M3G_API void m3gSlerpQuat(M3GQuat *quat,
   491                           M3Gfloat s,
   492                           const M3GQuat *q0, const M3GQuat *q1);
   493 M3G_API void m3gSquadQuat(M3GQuat *quat,
   494                           M3Gfloat s,
   495                           const M3GQuat *q0, const M3GQuat *a,
   496                           const M3GQuat *b, const M3GQuat *q1);
   497 
   498 /* -------- Matrix, vector & quaternion operations -------- */
   499 
   500 /* Matrix */
   501 
   502 /* shorthand names for the OpenGL style functions */
   503 #define m3gRotateMatrix         m3gPostRotateMatrix
   504 #define m3gRotateMatrixQuat     m3gPostRotateMatrixQuat
   505 #define m3gTranslateMatrix      m3gPostTranslateMatrix
   506 #define m3gScaleMatrix          m3gPostScaleMatrix
   507 #define m3gMulMatrix            m3gPostMultiplyMatrix
   508 
   509 /* ...and second names for the matrix-matrix multipliers */
   510 #define m3gLeftMulMatrix        m3gPreMultiplyMatrix
   511 #define m3gRightMulMatrix       m3gPostMultiplyMatrix
   512 
   513 M3G_API void    m3gCopyMatrix           (M3GMatrix *dst, const M3GMatrix *src);
   514 M3G_API void    m3gGetMatrixColumn      (const M3GMatrix *mtx, M3Gint col, M3GVec4 *dst);
   515 M3G_API void    m3gGetMatrixColumns     (const M3GMatrix *mtx, M3Gfloat *dst);
   516 M3G_API void    m3gGetMatrixRow         (const M3GMatrix *mtx, M3Gint row, M3GVec4 *dst);
   517 M3G_API void    m3gGetMatrixRows        (const M3GMatrix *mtx, M3Gfloat *dst);
   518 M3G_API void    m3gIdentityMatrix       (M3GMatrix *mtx);
   519 M3G_API M3Gbool m3gInvertMatrix         (M3GMatrix *mtx);
   520 M3G_API M3Gbool m3gMatrixInverse        (M3GMatrix *mtx, const M3GMatrix *other);
   521 M3G_API void    m3gMatrixTranspose      (M3GMatrix *mtx, const M3GMatrix *other);
   522 M3G_API M3Gbool m3gInverseTranspose     (M3GMatrix *mtx, const M3GMatrix *other);
   523 M3G_API void    m3gMatrixProduct        (M3GMatrix *dst, const M3GMatrix *left, const M3GMatrix *right);
   524 M3G_API void    m3gPostMultiplyMatrix   (M3GMatrix *mtx, const M3GMatrix *other);
   525 M3G_API void    m3gPostRotateMatrix     (M3GMatrix *mtx, M3Gfloat angle, M3Gfloat ax, M3Gfloat ay, M3Gfloat az);
   526 M3G_API void    m3gPostRotateMatrixQuat (M3GMatrix *mtx, const M3GQuat *quat);
   527 M3G_API void    m3gPostScaleMatrix      (M3GMatrix *mtx, M3Gfloat sx, M3Gfloat sy, M3Gfloat sz);
   528 M3G_API void    m3gPostTranslateMatrix  (M3GMatrix *mtx, M3Gfloat tx, M3Gfloat ty, M3Gfloat tz);
   529 M3G_API void    m3gPreMultiplyMatrix    (M3GMatrix *mtx, const M3GMatrix *other);
   530 M3G_API void    m3gPreRotateMatrix      (M3GMatrix *mtx, M3Gfloat angle, M3Gfloat ax, M3Gfloat ay, M3Gfloat az);
   531 M3G_API void    m3gPreRotateMatrixQuat  (M3GMatrix *mtx, const M3GQuat *quat);
   532 M3G_API void    m3gPreScaleMatrix       (M3GMatrix *mtx, M3Gfloat sx, M3Gfloat sy, M3Gfloat sz);
   533 M3G_API void    m3gPreTranslateMatrix   (M3GMatrix *mtx, M3Gfloat tx, M3Gfloat ty, M3Gfloat tz);
   534 M3G_API void    m3gScalingMatrix        (M3GMatrix *mtx, const M3Gfloat sx, const M3Gfloat sy, const M3Gfloat sz);
   535 M3G_API void    m3gSetMatrixColumns     (M3GMatrix *mtx, const M3Gfloat *src);
   536 M3G_API void    m3gSetMatrixRows        (M3GMatrix *mtx, const M3Gfloat *src);
   537 M3G_API void    m3gTranslationMatrix    (M3GMatrix *mtx, const M3Gfloat tx, const M3Gfloat ty, const M3Gfloat tz);
   538 
   539 /* Vec3/4 */
   540 
   541 M3G_API void    m3gAddVec3         (M3GVec3 *vec, const M3GVec3 *other);
   542 M3G_API void    m3gAddVec4         (M3GVec4 *vec, const M3GVec4 *other);
   543 M3G_API void    m3gCross           (M3GVec3 *dst, const M3GVec3 *a, const M3GVec3 *b);
   544 M3G_API M3Gfloat m3gDot3           (const M3GVec3 *a, const M3GVec3 *b);
   545 M3G_API M3Gfloat m3gDot4           (const M3GVec4 *a, const M3GVec4 *b);
   546 M3G_API M3Gfloat m3gLengthVec3     (const M3GVec3 *vec);
   547 M3G_API void    m3gNormalizeVec3   (M3GVec3 *vec);
   548 M3G_API void    m3gNormalizeVec4   (M3GVec4 *vec);
   549 M3G_API void    m3gScaleVec3       (M3GVec3 *vec, const M3Gfloat s);
   550 M3G_API void    m3gScaleVec4       (M3GVec4 *vec, const M3Gfloat s);
   551 M3G_API void    m3gSetVec3         (M3GVec3 *v, M3Gfloat x, M3Gfloat y, M3Gfloat z);
   552 M3G_API void    m3gSetVec4         (M3GVec4 *v, M3Gfloat x, M3Gfloat y, M3Gfloat z, M3Gfloat w);
   553 M3G_API void    m3gSubVec3         (M3GVec3 *vec, const M3GVec3 *other);
   554 M3G_API void    m3gSubVec4         (M3GVec4 *vec, const M3GVec4 *other);
   555 M3G_API void    m3gTransformVec4   (const M3GMatrix *mtx, M3GVec4 *vec);
   556 
   557 /* Quat */
   558 
   559 M3G_API void    m3gGetAngleAxis    (const M3GQuat *quat,
   560                                     M3Gfloat *angle, M3GVec3 *axis);
   561 M3G_API void    m3gIdentityQuat    (M3GQuat *quat);
   562 M3G_API void	m3gMulQuat		   (M3GQuat *quat, const M3GQuat *other);
   563 M3G_API void    m3gNormalizeQuat   (M3GQuat *quat);
   564 M3G_API void    m3gQuatMatrix      (M3GMatrix *mtx, const M3GQuat *quat);
   565 M3G_API void    m3gSetAngleAxis    (M3GQuat *quat,
   566                                     M3Gfloat angle,
   567                                     M3Gfloat ax, M3Gfloat ay, M3Gfloat az);
   568 M3G_API void    m3gSetAngleAxisRad (M3GQuat *quat,
   569                                     M3Gfloat angleRad,
   570                                     M3Gfloat ax, M3Gfloat ay, M3Gfloat az);
   571 M3G_API void    m3gSetQuat         (M3GQuat *quat, const M3Gfloat *vec);
   572 M3G_API void	m3gSetQuatRotation (M3GQuat *quat, const M3GVec3 *from, const M3GVec3 *to);
   573 
   574 /*----------------------------------------------------------------------
   575  * Interface callback types
   576  *--------------------------------------------------------------------*/
   577 
   578 typedef /*@only@*//*@null@*/ void* (m3gMallocFunc) (M3Guint bytes);
   579 
   580 typedef void    (m3gFreeFunc)   (/*@only@*//*@null@*//*@out@*/ void *ptr);
   581 
   582 typedef M3GMemObject (m3gObjectAllocator)    (M3Guint bytes);
   583 typedef /*@dependent@*/ void*   (m3gObjectResolver)     (M3GMemObject handle);
   584 typedef void    (m3gObjectDeallocator)(M3GMemObject handle);
   585     
   586 typedef void    (m3gErrorHandler)(M3Genum errorCode, M3GInterface hInterface);
   587 
   588 typedef void*   (m3gBeginRenderFunc)(M3Guint userTarget);
   589 typedef void    (m3gEndRenderFunc)(M3Guint userTarget);
   590 typedef void    (m3gReleaseTargetFunc)(M3Guint userTarget);
   591 
   592 /*!
   593  * \brief M3G interface initialization structure
   594  *
   595  *
   596  */
   597 typedef struct {
   598     /*@shared@*/ m3gMallocFunc          *mallocFunc;
   599     /*@shared@*/ m3gFreeFunc            *freeFunc;
   600     /*@shared@*/ m3gObjectAllocator     *objAllocFunc;
   601     /*@shared@*/ m3gObjectResolver      *objResolveFunc;
   602     /*@shared@*/ m3gObjectDeallocator   *objFreeFunc;
   603     /*@shared@*/ m3gErrorHandler        *errorFunc;
   604     /*@shared@*/ m3gBeginRenderFunc     *beginRenderFunc;
   605     /*@shared@*/ m3gEndRenderFunc       *endRenderFunc;
   606     /*@shared@*/ m3gReleaseTargetFunc   *releaseTargetFunc;
   607     /*@shared@*/ void                   *userContext;
   608 } M3Gparams;
   609 
   610 /*----------------------------------------------------------------------
   611  * API functions
   612  *--------------------------------------------------------------------*/
   613 
   614 /* -------- AnimationTrack -------- */
   615     
   616 M3G_API M3GAnimationTrack       m3gCreateAnimationTrack (M3GInterface hInterface, M3GKeyframeSequence hSequence, M3Gint property);
   617 M3G_API void                    m3gSetController        (M3GAnimationTrack hTrack, M3GAnimationController hController);
   618 M3G_API M3GAnimationController  m3gGetController        (M3GAnimationTrack hTrack);
   619 M3G_API M3GKeyframeSequence     m3gGetSequence          (M3GAnimationTrack hTrack);
   620 M3G_API M3Gint                  m3gGetTargetProperty    (M3GAnimationTrack hTrack);
   621 
   622 
   623 /* -------- AnimationController -------- */
   624 
   625 M3G_API M3GAnimationController m3gCreateAnimationController(M3GInterface hInterface);
   626 M3G_API void            m3gSetActiveInterval        (M3GAnimationController hController, M3Gint worldTimeMin, M3Gint worldTimeMax);
   627 M3G_API M3Gint          m3gGetActiveIntervalStart   (M3GAnimationController hController);
   628 M3G_API M3Gint          m3gGetActiveIntervalEnd     (M3GAnimationController hController);
   629 M3G_API void            m3gSetSpeed                 (M3GAnimationController hController, M3Gfloat factor, M3Gint worldTime);
   630 M3G_API M3Gfloat        m3gGetSpeed                 (M3GAnimationController hController);
   631 M3G_API void            m3gSetPosition              (M3GAnimationController hController, M3Gfloat sequenceTime, M3Gint worldTime);
   632 M3G_API M3Gfloat        m3gGetPosition              (M3GAnimationController hController, M3Gint worldTime);
   633 M3G_API void            m3gSetWeight                (M3GAnimationController hController, M3Gfloat weight);
   634 M3G_API M3Gfloat        m3gGetWeight                (M3GAnimationController hController);
   635 M3G_API M3Gint          m3gGetRefWorldTime          (M3GAnimationController hController);
   636     
   637 /* -------- Appearance -------- */
   638     
   639 M3G_API M3GAppearance   m3gCreateAppearance     (M3GInterface hInterface);
   640 M3G_API M3GCompositingMode m3gGetCompositingMode(M3GAppearance hApp);
   641 M3G_API M3GFog          m3gGetFog               (M3GAppearance hApp);
   642 M3G_API M3Gint          m3gGetLayer             (M3GAppearance hApp);
   643 M3G_API M3GMaterial     m3gGetMaterial          (M3GAppearance hApp);
   644 M3G_API M3GPolygonMode  m3gGetPolygonMode       (M3GAppearance hApp);
   645 M3G_API M3GTexture      m3gGetTexture           (M3GAppearance hApp, M3Gint unit);
   646 M3G_API void            m3gSetCompositingMode   (M3GAppearance hApp, M3GCompositingMode hMode);
   647 M3G_API void            m3gSetFog               (M3GAppearance hApp, M3GFog hFog);
   648 M3G_API void            m3gSetLayer             (M3GAppearance hApp, M3Gint layer);
   649 M3G_API void            m3gSetPolygonMode       (M3GAppearance hApp, M3GPolygonMode hMode);
   650 M3G_API void            m3gSetMaterial          (M3GAppearance hApp, M3GMaterial hMaterial);
   651 M3G_API void            m3gSetTexture           (M3GAppearance hAppearance, M3Gint unit, M3GTexture hTexture);
   652 
   653     
   654 /* -------- Background -------- */
   655     
   656 M3G_API M3GBackground   m3gCreateBackground     (M3GInterface hInterface);
   657 M3G_API void            m3gSetBgColor           (M3GBackground handle, M3Guint ARGB);
   658 M3G_API void            m3gSetBgMode            (M3GBackground handle, M3Gint modeX, M3Gint modeY);
   659 M3G_API void            m3gSetBgCrop            (M3GBackground handle, M3Gint cropX, M3Gint cropY, M3Gint width, M3Gint height);
   660 M3G_API void            m3gSetBgImage           (M3GBackground handle, M3GImage hImage);
   661 M3G_API M3GImage        m3gGetBgImage           (M3GBackground handle);
   662 M3G_API M3Guint         m3gGetBgColor           (M3GBackground handle);
   663 M3G_API M3Gint          m3gGetBgMode            (M3GBackground handle, M3Gint which);
   664 M3G_API M3Gint          m3gGetBgCrop            (M3GBackground handle, M3Gint which);
   665 M3G_API void            m3gSetBgEnable          (M3GBackground handle, M3Gint which, M3Gbool enable);
   666 M3G_API M3Gbool         m3gIsBgEnabled          (M3GBackground handle, M3Gint which);
   667 
   668     
   669 /* -------- Camera -------- */
   670     
   671 M3G_API M3GCamera       m3gCreateCamera         (M3GInterface hInterface);
   672 M3G_API void            m3gSetParallel          (M3GCamera handle, M3Gfloat height, M3Gfloat aspectRatio, M3Gfloat clipNear, M3Gfloat clipFar);
   673 M3G_API void            m3gSetPerspective       (M3GCamera handle, M3Gfloat fovy, M3Gfloat aspectRatio, M3Gfloat clipNear, M3Gfloat clipFar);
   674 M3G_API void            m3gSetProjectionMatrix  (M3GCamera handle, const M3GMatrix *transform);
   675 M3G_API M3Gint          m3gGetProjectionAsMatrix(M3GCamera handle, M3GMatrix *transform);
   676 M3G_API M3Gint          m3gGetProjectionAsParams(M3GCamera handle, M3Gfloat *params);
   677 
   678     
   679 /* -------- CompositingMode -------- */
   680     
   681 M3G_API M3GCompositingMode m3gCreateCompositingMode(M3GInterface m3g);
   682     
   683 M3G_API void            m3gSetBlending          (M3GCompositingMode compositingMode, M3Genum mode);
   684 M3G_API M3Genum         m3gGetBlending          (M3GCompositingMode compositingMode);
   685 M3G_API void            m3gSetAlphaThreshold    (M3GCompositingMode compositingMode, M3Gfloat threshold);
   686 M3G_API M3Gfloat        m3gGetAlphaThreshold    (M3GCompositingMode compositingMode);
   687 M3G_API void            m3gEnableDepthTest      (M3GCompositingMode compositingMode, M3Gbool enable);
   688 M3G_API void            m3gEnableDepthWrite     (M3GCompositingMode compositingMode, M3Gbool enable);
   689 M3G_API void            m3gEnableColorWrite     (M3GCompositingMode compositingMode, M3Gbool enable);
   690 M3G_API void            m3gSetDepthOffset       (M3GCompositingMode compositingMode, M3Gfloat factor, M3Gfloat units);
   691 M3G_API M3Gfloat        m3gGetDepthOffsetFactor (M3GCompositingMode compositingMode);
   692 M3G_API M3Gfloat        m3gGetDepthOffsetUnits  (M3GCompositingMode compositingMode);
   693 M3G_API M3Gbool         m3gIsAlphaWriteEnabled  (M3GCompositingMode handle);
   694 M3G_API M3Gbool         m3gIsColorWriteEnabled  (M3GCompositingMode handle);
   695 M3G_API M3Gbool         m3gIsDepthTestEnabled   (M3GCompositingMode handle);
   696 M3G_API M3Gbool         m3gIsDepthWriteEnabled  (M3GCompositingMode handle);
   697 M3G_API void            m3gSetAlphaWriteEnable  (M3GCompositingMode handle, M3Gbool enable);
   698 
   699     
   700 /* -------- Fog -------- */
   701 
   702 M3G_API M3GFog          m3gCreateFog    (M3GInterface hInterface);
   703 M3G_API void            m3gSetFogMode   (M3GFog handle, M3Gint mode);
   704 M3G_API M3Gint          m3gGetFogMode   (M3GFog handle);
   705 M3G_API void            m3gSetFogLinear (M3GFog handle, M3Gfloat fogNear, M3Gfloat fogFar);
   706 M3G_API M3Gfloat        m3gGetFogDistance(M3GFog handle, M3Genum which);
   707 M3G_API void            m3gSetFogDensity(M3GFog handle, M3Gfloat density);
   708 M3G_API M3Gfloat        m3gGetFogDensity(M3GFog handle);
   709 M3G_API void            m3gSetFogColor  (M3GFog handle, M3Guint rgb);
   710 M3G_API M3Guint         m3gGetFogColor  (M3GFog handle);
   711     
   712     
   713 /* -------- Group -------- */
   714 
   715 M3G_API M3GGroup        m3gCreateGroup  (M3GInterface m3g);
   716 M3G_API void            m3gAddChild     (M3GGroup handle, M3GNode hNode);
   717 M3G_API void            m3gRemoveChild  (M3GGroup handle, M3GNode hNode);
   718 M3G_API M3GNode         m3gPick3D       (M3GGroup handle, M3Gint mask, M3Gfloat *ray, M3Gfloat *result);
   719 M3G_API M3GNode         m3gPick2D       (M3GGroup handle, M3Gint mask, M3Gfloat x, M3Gfloat y, M3GCamera hCamera, M3Gfloat *result);
   720 M3G_API M3GNode         m3gGetChild     (M3GGroup handle, M3Gint idx);
   721 M3G_API M3Gint          m3gGetChildCount(M3GGroup handle);
   722 
   723     
   724 /* -------- Image -------- */
   725     
   726 M3G_API M3GImage        m3gCreateImage      (M3GInterface m3g, M3GImageFormat format, M3Gint width, M3Gint height, M3Gbitmask flags);
   727 M3G_API void            m3gSetImage         (M3GImage hImage, const void *pixels);
   728 M3G_API void            m3gSetImagePalette  (M3GImage hImage, M3Gint paletteLength, const void *palette);
   729 M3G_API void            m3gSetImageScanline (M3GImage hImage, M3Gint line, M3Gbool trueAlpha, const M3Guint *pixels);
   730 M3G_API void            m3gSetSubImage      (M3GImage hImage, M3Gint x, M3Gint y, M3Gint width, M3Gint height, M3Gint length, const void *pixels);
   731 M3G_API M3Gbool         m3gIsMutable        (M3GImage hImage);
   732 M3G_API M3GImageFormat  m3gGetFormat        (M3GImage hImage);
   733 M3G_API M3Gint          m3gGetWidth         (M3GImage hImage);
   734 M3G_API M3Gint          m3gGetHeight        (M3GImage hImage);
   735 M3G_API void            m3gGetImageARGB     (M3GImage hImage, M3Guint *pixels);
   736 M3G_API void            m3gCommitImage      (M3GImage hImage);
   737     
   738 /* -------- IndexBuffer -------- */
   739     
   740 M3G_API M3GIndexBuffer  m3gCreateStripBuffer            (M3GInterface m3g, M3Gprimitive primitive, M3Gsizei stripCount, const M3Gsizei *stripLengths, M3Gdatatype type, M3Gsizei indicesCount, const void *stripIndices);
   741 M3G_API M3GIndexBuffer  m3gCreateImplicitStripBuffer    (M3GInterface hInterface, M3Gsizei stripCount, const M3Gsizei *stripLengths, M3Gint firstIndex);
   742 M3G_API M3Gint          m3gGetBatchCount(M3GIndexBuffer buffer);
   743 M3G_API M3Gbool         m3gGetBatchIndices(M3GIndexBuffer buffer, M3Gint batchIndex, M3Gint *indices);
   744 M3G_API M3Gint          m3gGetBatchSize(M3GIndexBuffer buffer, M3Gint batchIndex);
   745 M3G_API M3Gprimitive    m3gGetPrimitive(M3GIndexBuffer buffer);
   746     
   747 /* -------- Interface -------- */
   748 
   749 M3G_API M3GInterface    m3gCreateInterface  (const M3Gparams *params);
   750 M3G_API void            m3gDeleteInterface  (M3GInterface m3g);
   751 M3G_API void            m3gGarbageCollect   (M3GInterface hInterface);    
   752 M3G_API M3Genum         m3gGetError         (M3GInterface m3g);
   753 M3G_API M3Gint          m3gGetStatistic     (M3GInterface hInterface,
   754                                              M3Gstatistic stat);
   755 M3G_API void *          m3gGetUserContext   (M3GInterface m3g);
   756 M3G_API M3Gbool         m3gIsAntialiasingSupported(M3GInterface interface);
   757 
   758 /* -------- KeyframeSequence -------- */
   759 
   760 M3G_API M3GKeyframeSequence m3gCreateKeyframeSequence(M3GInterface hInterface, M3Gint numKeyframes, M3Gint numComponents, M3Gint interpolation);
   761 M3G_API void            m3gSetValidRange(M3GKeyframeSequence handle, M3Gint first, M3Gint last);
   762 M3G_API void            m3gSetKeyframe  (M3GKeyframeSequence handle, M3Gint ind, M3Gint time, M3Gint valueSize, const M3Gfloat *value);
   763 M3G_API void            m3gSetDuration  (M3GKeyframeSequence handle, M3Gint duration);
   764 M3G_API M3Gint          m3gGetDuration  (M3GKeyframeSequence handle);
   765 M3G_API void            m3gSetRepeatMode(M3GKeyframeSequence handle, M3Genum mode);
   766 M3G_API M3Genum         m3gGetRepeatMode(M3GKeyframeSequence handle);
   767 M3G_API M3Gint          m3gGetComponentCount(M3GKeyframeSequence handle);
   768 M3G_API M3Gint          m3gGetInterpolationType(M3GKeyframeSequence handle);
   769 M3G_API M3Gint          m3gGetKeyframe  (M3GKeyframeSequence handle, M3Gint frameIndex, M3Gfloat *value);
   770 M3G_API M3Gint          m3gGetKeyframeCount(M3GKeyframeSequence handle);
   771 M3G_API void            m3gGetValidRange(M3GKeyframeSequence handle, M3Gint *first, M3Gint *last);
   772     
   773 /* -------- Light -------- */
   774     
   775 M3G_API M3GLight        m3gCreateLight      (M3GInterface hInterface);
   776 M3G_API void            m3gSetIntensity     (M3GLight handle, M3Gfloat intensity);
   777 M3G_API void            m3gSetLightColor    (M3GLight handle, M3Guint rgb);
   778 M3G_API void            m3gSetLightMode     (M3GLight handle, M3Genum mode);
   779 M3G_API void            m3gSetSpotAngle     (M3GLight handle, M3Gfloat angle);
   780 M3G_API void            m3gSetSpotExponent  (M3GLight handle, M3Gfloat exponent);
   781 M3G_API void            m3gSetAttenuation   (M3GLight handle, M3Gfloat constant, M3Gfloat linear, M3Gfloat quadratic);
   782 M3G_API M3Gfloat        m3gGetIntensity     (M3GLight handle);
   783 M3G_API M3Guint         m3gGetLightColor    (M3GLight handle);
   784 M3G_API M3Gint          m3gGetLightMode     (M3GLight handle);
   785 M3G_API M3Gfloat        m3gGetSpotAngle     (M3GLight handle);
   786 M3G_API M3Gfloat        m3gGetSpotExponent  (M3GLight handle);
   787 M3G_API M3Gfloat        m3gGetAttenuation   (M3GLight handle, M3Genum type);
   788 M3G_API M3Gint          m3gGetScopeMask     (M3GLight handle);
   789 
   790     
   791 /* -------- Loader -------- */
   792 
   793 M3G_API M3GLoader       m3gCreateLoader(M3GInterface m3g);
   794 M3G_API M3Gsizei        m3gDecodeData(M3GLoader loader, M3Gsizei bytes, const M3Gubyte *data);
   795 M3G_API M3Gint          m3gGetLoadedObjects(M3GLoader loader, M3GObject *buffer);
   796 M3G_API void            m3gImportObjects(M3GLoader loader, M3Gint n, M3GObject *refs);
   797 M3G_API M3Gint          m3gGetObjectsWithUserParameters(M3GLoader loader, M3GObject *objects);
   798 M3G_API M3Gint          m3gGetNumUserParameters(M3GLoader loader, M3Gint object);
   799 M3G_API M3Gint          m3gGetUserParameter(M3GLoader loader, M3Gint object, M3Gint index, M3Gbyte *buffer);
   800 M3G_API void            m3gSetConstraints(M3GLoader loader, M3Gint triConstraint);
   801 
   802 /* -------- Material -------- */
   803     
   804 M3G_API M3GMaterial     m3gCreateMaterial               (M3GInterface m3g);
   805 M3G_API void            m3gSetColor                     (M3GMaterial material, M3Genum target, M3Guint ARGB);
   806 M3G_API M3Guint         m3gGetColor                     (M3GMaterial material, M3Genum target);
   807 M3G_API void            m3gSetShininess                 (M3GMaterial material, M3Gfloat shininess);
   808 M3G_API M3Gfloat        m3gGetShininess                 (M3GMaterial material);
   809 M3G_API void            m3gSetVertexColorTrackingEnable (M3GMaterial material, M3Gbool enable);
   810 M3G_API M3Gbool         m3gIsVertexColorTrackingEnabled (M3GMaterial material);
   811 
   812     
   813 /* -------- Mesh -------- */
   814 
   815 M3G_API M3GMesh         m3gCreateMesh       (M3GInterface hInterface, M3GVertexBuffer hVertices, M3GIndexBuffer *hTriangles, M3GAppearance *hAppearances, M3Gint trianglePatchCount);
   816 M3G_API void            m3gSetAppearance    (M3GMesh handle, M3Gint appearanceIndex, M3GAppearance hAppearance);
   817 M3G_API M3GAppearance   m3gGetAppearance    (M3GMesh handle, M3Gint idx);
   818 M3G_API M3GIndexBuffer  m3gGetIndexBuffer   (M3GMesh handle, M3Gint idx);
   819 M3G_API M3GVertexBuffer m3gGetVertexBuffer  (M3GMesh handle);
   820 M3G_API M3Gint          m3gGetSubmeshCount  (M3GMesh handle);
   821     
   822     
   823 /* -------- MorphingMesh -------- */
   824 
   825 M3G_API M3GMorphingMesh m3gCreateMorphingMesh  (M3GInterface hInterface, M3GVertexBuffer hVertices, M3GVertexBuffer *hTargets, M3GIndexBuffer *hTriangles, M3GAppearance *hAppearances, M3Gint trianglePatchCount, M3Gint targetCount);
   826 M3G_API void            m3gSetWeights          (M3GMorphingMesh handle, M3Gfloat *weights, M3Gint numWeights);
   827 M3G_API void            m3gGetWeights          (M3GMorphingMesh handle, M3Gfloat *weights, M3Gint numWeights);
   828 M3G_API M3GVertexBuffer m3gGetMorphTarget      (M3GMorphingMesh handle, M3Gint idx);
   829 M3G_API M3Gint          m3gGetMorphTargetCount  (M3GMorphingMesh handle);
   830 
   831     
   832 /* -------- Node -------- */
   833 
   834 M3G_API void            m3gAlignNode        (M3GNode hNode, M3GNode hReference);
   835 M3G_API M3Gbool         m3gGetTransformTo   (M3GNode handle, M3GNode hTarget, M3GMatrix *transform);
   836 M3G_API void            m3gSetAlignment     (M3GNode handle, M3GNode hZReference, M3Gint zTarget, M3GNode hYReference, M3Gint yTarget);
   837 M3G_API void            m3gSetAlphaFactor   (M3GNode handle, M3Gfloat alphaFactor);
   838 M3G_API M3Gfloat        m3gGetAlphaFactor   (M3GNode handle);
   839 M3G_API void            m3gEnable           (M3GNode handle, M3Gint which, M3Gbool enable);
   840 M3G_API M3Gint          m3gIsEnabled        (M3GNode handle, M3Gint which);
   841 M3G_API void            m3gSetScope         (M3GNode handle, M3Gint id);
   842 M3G_API M3Gint          m3gGetScope         (M3GNode handle);
   843 M3G_API M3GNode         m3gGetParent        (M3GNode handle);
   844 M3G_API M3GNode         m3gGetZRef          (M3GNode handle);
   845 M3G_API M3GNode         m3gGetYRef          (M3GNode handle);
   846 M3G_API M3Gint          m3gGetSubtreeSize   (M3GNode handle);
   847 M3G_API M3Gint          m3gGetAlignmentTarget(M3GNode handle, M3Gint axis);
   848     
   849 /* -------- Object -------- */
   850     
   851 M3G_API void            m3gAddRef               (M3GObject hObject);
   852 M3G_API void            m3gDeleteObject         (M3GObject hObject);
   853 M3G_API void            m3gDeleteRef            (M3GObject hObject);
   854 M3G_API M3GClass        m3gGetClass             (M3GObject hObject);
   855 M3G_API M3Gint          m3gAddAnimationTrack    (M3GObject hObject, M3GAnimationTrack hAnimationTrack);
   856 M3G_API void            m3gRemoveAnimationTrack (M3GObject hObject, M3GAnimationTrack hAnimationTrack);
   857 M3G_API M3Gint          m3gGetAnimationTrackCount(M3GObject hObject);
   858 M3G_API M3Gint          m3gAnimate              (M3GObject hObject, M3Gint time);
   859 M3G_API void            m3gSetUserID            (M3GObject hObject, M3Gint userID);
   860 M3G_API M3Gint          m3gGetUserID            (M3GObject hObject);
   861 M3G_API M3GAnimationTrack m3gGetAnimationTrack  (M3GObject hObject, M3Gint idx);
   862 M3G_API M3GObject       m3gDuplicate            (M3GObject hObject, M3GObject *hReferences);
   863 M3G_API M3GInterface    m3gGetObjectInterface   (M3GObject hObject);
   864 M3G_API M3Gint          m3gGetReferences        (M3GObject hObject, M3GObject *references, M3Gint length);
   865 M3G_API M3GObject       m3gFind                 (M3GObject hObject, M3Gint userID);
   866 
   867 #define m3gGetInterface(obj) m3gGetObjectInterface((M3GObject)(obj))
   868     
   869 /* -------- PolygonMode -------- */
   870     
   871 M3G_API M3GPolygonMode  m3gCreatePolygonMode    (M3GInterface m3g);
   872 M3G_API void            m3gSetCulling           (M3GPolygonMode handle, M3Gint mode);
   873 M3G_API M3Gint          m3gGetCulling           (M3GPolygonMode handle);
   874 M3G_API void            m3gSetWinding           (M3GPolygonMode handle, M3Gint mode);
   875 M3G_API M3Gint          m3gGetWinding           (M3GPolygonMode handle);
   876 M3G_API void            m3gSetShading           (M3GPolygonMode handle, M3Gint mode);
   877 M3G_API M3Gint          m3gGetShading           (M3GPolygonMode handle);
   878 M3G_API void            m3gSetTwoSidedLightingEnable(M3GPolygonMode handle, M3Gbool enable);
   879 M3G_API M3Gbool         m3gIsTwoSidedLightingEnabled(M3GPolygonMode handle);
   880 M3G_API void            m3gSetLocalCameraLightingEnable(M3GPolygonMode polygonMode, M3Gbool enable);
   881 M3G_API void            m3gSetPerspectiveCorrectionEnable(M3GPolygonMode polygonMode, M3Gbool enable);
   882 M3G_API M3Gbool         m3gIsLocalCameraLightingEnabled(M3GPolygonMode handle);
   883 M3G_API M3Gbool         m3gIsPerspectiveCorrectionEnabled(M3GPolygonMode handle);
   884     
   885 /* -------- RenderContext -------- */
   886 
   887 M3G_API M3GRenderContext m3gCreateContext(M3GInterface m3g);
   888     
   889 M3G_API M3Gint  m3gAddLight             (M3GRenderContext ctx, M3GLight light, const M3GMatrix *transform);
   890 M3G_API void    m3gBindBitmapTarget     (M3GRenderContext ctx, M3GNativeBitmap hBitmap);
   891 M3G_API void    m3gBindImageTarget      (M3GRenderContext ctx, M3GImage hImage);
   892 M3G_API void    m3gBindEGLSurfaceTarget (M3GRenderContext context, M3GEGLSurface surface);
   893 M3G_API void    m3gBindMemoryTarget     (M3GRenderContext context, void *pixels, M3Guint width, M3Guint height, M3GPixelFormat format, M3Guint stride, M3Guint userContext);
   894 M3G_API void    m3gBindWindowTarget     (M3GRenderContext ctx, M3GNativeWindow hWindow);
   895 M3G_API void    m3gClear                (M3GRenderContext context, M3GBackground hBackground);
   896 M3G_API void    m3gClearLights          (M3GRenderContext context);
   897 M3G_API M3Guint m3gGetUserHandle        (M3GRenderContext hCtx);
   898 M3G_API void    m3gInvalidateBitmapTarget(M3GRenderContext ctx, M3GNativeBitmap hBitmap);
   899 M3G_API void    m3gInvalidateWindowTarget(M3GRenderContext ctx, M3GNativeWindow hWindow);
   900 M3G_API void    m3gInvalidateMemoryTarget(M3GRenderContext ctx, void *pixels);
   901 M3G_API void    m3gReleaseTarget        (M3GRenderContext ctx);
   902 M3G_API void    m3gRender               (M3GRenderContext ctx, M3GVertexBuffer hVertices, M3GIndexBuffer hIndices, M3GAppearance hAppearance, const M3GMatrix *transform, M3Gfloat alphaFactor, M3Gint scope);
   903 M3G_API void    m3gRenderWorld          (M3GRenderContext context, M3GWorld hWorld);
   904 M3G_API void    m3gRenderNode           (M3GRenderContext context, M3GNode hNode, const M3GMatrix *transform);
   905 M3G_API M3Gbool m3gSetRenderBuffers     (M3GRenderContext hCtx, M3Gbitmask bufferBits);
   906 M3G_API M3Gbool m3gSetRenderHints       (M3GRenderContext hCtx, M3Gbitmask hintBits);
   907 M3G_API void    m3gSetCamera            (M3GRenderContext context, M3GCamera hCamera, M3GMatrix *transform);
   908 M3G_API void    m3gSetDepthRange        (M3GRenderContext hCtx, M3Gfloat depthNear, M3Gfloat depthFar);
   909 M3G_API void    m3gSetLight             (M3GRenderContext context, M3Gint lightIndex, M3GLight hLight, const M3GMatrix *transform);
   910 M3G_API void    m3gSetClipRect          (M3GRenderContext ctx, M3Gint x, M3Gint y, M3Gint width, M3Gint height);
   911 M3G_API void    m3gSetDisplayArea(M3GRenderContext hCtx, M3Gint width, M3Gint height);
   912 M3G_API void    m3gSetViewport          (M3GRenderContext ctx, M3Gint x, M3Gint y, M3Gint width, M3Gint height);
   913 M3G_API void    m3gGetViewport          (M3GRenderContext hCtx, M3Gint *x, M3Gint *y, M3Gint *width, M3Gint *height);
   914 M3G_API void    m3gGetDepthRange        (M3GRenderContext hCtx, M3Gfloat *depthNear, M3Gfloat *depthFar);
   915 M3G_API void    m3gGetViewTransform     (M3GRenderContext hCtx, M3GMatrix *transform);
   916 M3G_API M3GLight m3gGetLightTransform   (M3GRenderContext hCtx, M3Gint lightIndex, M3GMatrix *transform);
   917 M3G_API M3Gsizei m3gGetLightCount       (M3GRenderContext hCtx);
   918 M3G_API M3GCamera m3gGetCamera          (M3GRenderContext hCtx);
   919 M3G_API void	m3gSetAlphaWrite		(M3GRenderContext ctx, M3Gbool enable);
   920 M3G_API M3Gbool	m3gGetAlphaWrite		(M3GRenderContext ctx);
   921 M3G_API void    m3gFreeGLESResources    (M3GRenderContext ctx);
   922 
   923 /* -------- SkinnedMesh -------- */
   924 
   925 M3G_API M3GSkinnedMesh  m3gCreateSkinnedMesh    (M3GInterface hInterface, M3GVertexBuffer hVertices, M3GIndexBuffer *hTriangles, M3GAppearance *hAppearances, M3Gint trianglePatchCount, M3GGroup hSkeleton);
   926 M3G_API void            m3gAddTransform         (M3GSkinnedMesh handle, M3GNode hBone, M3Gint weight, M3Gint firstVertex, M3Gint numVertices);
   927 M3G_API M3GGroup        m3gGetSkeleton          (M3GSkinnedMesh handle);
   928 M3G_API void            m3gGetBoneTransform     (M3GSkinnedMesh handle, M3GNode hBone, M3GMatrix *transform);
   929 M3G_API M3Gint          m3gGetBoneVertices      (M3GSkinnedMesh handle, M3GNode hBone, M3Gint *indices, M3Gfloat *weights);
   930     
   931     
   932 /* -------- Sprite -------- */
   933 
   934 M3G_API M3GSprite       m3gCreateSprite         (M3GInterface hInterface, M3Gbool scaled, M3GImage hImage, M3GAppearance hAppearance);
   935 M3G_API M3Gbool         m3gIsScaledSprite       (M3GSprite handle);
   936 M3G_API void            m3gSetSpriteAppearance  (M3GSprite handle, M3GAppearance hAppearance);
   937 M3G_API M3Gbool         m3gSetSpriteImage       (M3GSprite handle, M3GImage hImage);
   938 M3G_API void            m3gSetCrop              (M3GSprite handle, M3Gint cropX, M3Gint cropY, M3Gint width, M3Gint height);
   939 M3G_API M3Gint          m3gGetCrop              (M3GSprite handle, M3Gint which);
   940 M3G_API M3GAppearance   m3gGetSpriteAppearance  (M3GSprite handle);
   941 M3G_API M3GImage        m3gGetSpriteImage       (M3GSprite handle);
   942 
   943     
   944 /* -------- Texture -------- */
   945     
   946 M3G_API M3GTexture      m3gCreateTexture        (M3GInterface m3g, M3GImage hImage);
   947 M3G_API M3GImage        m3gGetTextureImage      (M3GTexture hTexture);
   948 M3G_API void            m3gSetTextureImage      (M3GTexture hTexture, M3GImage hImage);
   949 M3G_API void            m3gSetTextureTransform  (M3GTexture hTexture, M3GMatrix *mtx);
   950 M3G_API void            m3gSetFiltering         (M3GTexture hTexture, M3Genum levelFilter, M3Genum imageFilter);
   951 M3G_API void            m3gSetWrapping          (M3GTexture hTexture, M3Genum wrapS, M3Genum wrapT);
   952 M3G_API int             m3gGetWrappingS         (M3GTexture hTexture);
   953 M3G_API int             m3gGetWrappingT         (M3GTexture hTexture);
   954 M3G_API void            m3gTextureSetBlending   (M3GTexture hTexture, M3Genum func);
   955 M3G_API int             m3gTextureGetBlending   (M3GTexture hTexture);
   956 M3G_API void            m3gSetBlendColor        (M3GTexture hTexture, M3Guint RGB);
   957 M3G_API M3Guint         m3gGetBlendColor        (M3GTexture hTexture);
   958 M3G_API void            m3gTransformSetTransform(M3GTexture hTexture, const M3GMatrix *transform);
   959 M3G_API void            m3gTransformGetTransform(M3GTexture hTexture, M3GMatrix *transform);
   960 M3G_API void            m3gGetFiltering         (M3GTexture hTexture, M3Gint *levelFilter, M3Gint *imageFilter);
   961 
   962 /* -------- Transformable -------- */
   963 
   964 M3G_API void    m3gSetOrientation       (M3GTransformable handle, M3Gfloat angle, M3Gfloat ax, M3Gfloat ay, M3Gfloat az);
   965 M3G_API void    m3gPostRotate           (M3GTransformable handle, M3Gfloat angle, M3Gfloat ax, M3Gfloat ay, M3Gfloat az);
   966 M3G_API void    m3gPreRotate            (M3GTransformable handle, M3Gfloat angle, M3Gfloat ax, M3Gfloat ay, M3Gfloat az);
   967 M3G_API void    m3gGetOrientation       (M3GTransformable handle, M3Gfloat *angleAxis);
   968 M3G_API void    m3gSetScale             (M3GTransformable handle, M3Gfloat sx, M3Gfloat sy, M3Gfloat sz);
   969 M3G_API void    m3gScale                (M3GTransformable handle, M3Gfloat sx, M3Gfloat sy, M3Gfloat sz);
   970 M3G_API void    m3gGetScale             (M3GTransformable handle, M3Gfloat *scale);
   971 M3G_API void    m3gSetTranslation       (M3GTransformable handle, M3Gfloat tx, M3Gfloat ty, M3Gfloat tz);
   972 M3G_API void    m3gTranslate            (M3GTransformable handle, M3Gfloat tx, M3Gfloat ty, M3Gfloat tz);
   973 M3G_API void    m3gGetTranslation       (M3GTransformable handle, M3Gfloat *translation);
   974 M3G_API void    m3gSetTransform         (M3GTransformable handle, const M3GMatrix *transform);
   975 M3G_API void    m3gGetTransform         (M3GTransformable handle, M3GMatrix *transform);
   976 M3G_API void    m3gGetCompositeTransform(M3GTransformable handle, M3GMatrix *transform);
   977     
   978 /* -------- VertexArray -------- */
   979     
   980 M3G_API M3GVertexArray  m3gCreateVertexArray    (M3GInterface m3g, M3Gsizei count, M3Gint size, M3Gdatatype type);
   981 M3G_API void            m3gGetVertexArrayParams (M3GVertexArray handle, M3Gsizei *count, M3Gint *size, M3Gdatatype *type, M3Gsizei *stride);
   982 M3G_API void *          m3gMapVertexArray       (M3GVertexArray handle);
   983 M3G_API const void *    m3gMapVertexArrayReadOnly(M3GVertexArray handle);
   984 M3G_API void            m3gSetVertexArrayElements(M3GVertexArray handle, M3Gint first, M3Gsizei count, M3Gsizei srcLength, M3Gdatatype type, const void *src);
   985 M3G_API void            m3gTransformArray       (M3GVertexArray handle, M3GMatrix *transform, M3Gfloat *out, M3Gint outLength, M3Gbool w);
   986 M3G_API void            m3gUnmapVertexArray     (M3GVertexArray handle);
   987 M3G_API void            m3gGetVertexArrayElements(M3GVertexArray handle, M3Gint first, M3Gsizei count, M3Gsizei dstLength, M3Gdatatype type, void *dst);
   988     
   989 /* -------- VertexBuffer -------- */
   990     
   991 M3G_API M3GVertexBuffer m3gCreateVertexBuffer   (M3GInterface m3g);
   992 M3G_API M3Gint          m3gGetVertexCount       (M3GVertexBuffer hBuffer);
   993 M3G_API M3GVertexArray  m3gGetVertexArray       (M3GVertexBuffer handle, M3Gint which, M3Gfloat *scaleBias, M3Gint sbLength);
   994 M3G_API void            m3gSetColorArray        (M3GVertexBuffer hBuffer, M3GVertexArray hArray);
   995 M3G_API void            m3gSetNormalArray       (M3GVertexBuffer hBuffer, M3GVertexArray hArray);
   996 M3G_API void            m3gSetTexCoordArray     (M3GVertexBuffer hBuffer, M3Gint unit, M3GVertexArray hArray, M3Gfloat scale, M3Gfloat *bias, M3Gint biasLength);
   997 M3G_API void            m3gSetVertexDefaultColor(M3GVertexBuffer hBuffer, M3Guint ARGB);
   998 M3G_API M3Guint         m3gGetVertexDefaultColor(M3GVertexBuffer hBuffer);
   999 M3G_API void            m3gSetVertexArray       (M3GVertexBuffer hBuffer, M3GVertexArray hArray, M3Gfloat scale, M3Gfloat *bias, M3Gint biasLength);
  1000     
  1001 /* -------- World -------- */
  1002     
  1003 M3G_API M3GWorld        m3gCreateWorld          (M3GInterface hInterface);
  1004 M3G_API void            m3gSetActiveCamera      (M3GWorld handle, M3GCamera hCamera);
  1005 M3G_API void            m3gSetBackground        (M3GWorld handle, M3GBackground hBackground);
  1006 M3G_API M3GBackground   m3gGetBackground        (M3GWorld handle);
  1007 M3G_API M3GCamera       m3gGetActiveCamera      (M3GWorld handle);
  1008 
  1009 #if defined(__cplusplus)
  1010 } /* extern "C" */
  1011 #endif
  1012 
  1013 #endif /*__M3G_CORE_H__*/