os/graphics/m3g/m3gcore11/inc/m3g_gl.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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: OpenGL utility functions and definitions
    15 *
    16 */
    17 
    18 #ifndef __M3G_GL_H__
    19 #define __M3G_GL_H__
    20 
    21 /*!
    22  * \internal
    23  * \file
    24  * \brief OpenGL utility functions and definitions
    25  */
    26 
    27 #include "M3G/m3g_core.h"
    28 #include "m3g_defs.h"
    29 
    30 #if !(defined(M3G_NGL_CONTEXT_API) || defined(M3G_NGL_TEXTURE_API))
    31 #   include <GLES/gl.h>
    32 #   include <EGL/egl.h>
    33 #else
    34 
    35 /*@notfunction@*/
    36 #   define NGL_PREFIX(func)     gl ## func
    37 /*@notfunction@*/
    38 #   define NGLI_PREFIX(func)    ngl ## func
    39 /*@notfunction@*/
    40 #   define NGLU_PREFIX(func)    nglu ## func
    41 #   include "ngl.h"
    42 
    43 #endif
    44 
    45 #if defined(__cplusplus)
    46 extern "C" {
    47 #endif
    48     
    49 /*----------------------------------------------------------------------
    50  * Handy macros
    51  *--------------------------------------------------------------------*/
    52 
    53 #if defined(M3G_DEBUG_ASSERTS)
    54     static M3G_INLINE void m3gAssertGL(const char *filename, int line)
    55     {
    56         GLint err = glGetError();
    57         if (err != GL_NO_ERROR) {
    58             M3G_LOG3(M3G_LOG_FATAL_ERRORS, "GL error 0x%X (%s: %d)\n",
    59                      err, filename, line);
    60             M3G_ASSERT(M3G_FALSE);
    61         }
    62     }
    63 #   define M3G_ASSERT_GL m3gAssertGL(__FILE__, __LINE__)
    64 #else
    65 #   define M3G_ASSERT_GL
    66 #endif
    67 
    68 #define M3G_GLTYPE(m3gType) ((m3gType) + 0x1400)
    69 #define M3G_M3GTYPE(glType) ((glType) - 0x1400)
    70 
    71 /*----------------------------------------------------------------------
    72  * Internal functions
    73  *--------------------------------------------------------------------*/
    74     
    75 static GLenum m3gGetGLFormat(M3GPixelFormat format);    /* m3g_image.inl */
    76 static void m3gGLColor(M3Guint argb, GLfixed *dst);     /* m3g_image.c */
    77 
    78 #if !defined(M3G_NGL_CONTEXT_API)
    79 static void m3gInitializeEGL(void);     /* m3g_rendercontext.inl */
    80 static void m3gTerminateEGL(void);      /* m3g_rendercontext.inl */
    81 #endif
    82 
    83 /*----------------------------------------------------------------------
    84  * Native platform abstraction layer
    85  *--------------------------------------------------------------------*/
    86     
    87 #if !defined(M3G_NGL_CONTEXT_API)
    88     
    89 M3Gbool m3gglLockNativeBitmap(M3GNativeBitmap bitmap,
    90                               M3Gubyte **ptr,
    91                               M3Gsizei *stride);
    92 void    m3gglReleaseNativeBitmap(M3GNativeBitmap bitmap);
    93     
    94 M3Gbool m3gglGetNativeBitmapParams(M3GNativeBitmap bitmap,
    95                                    M3GPixelFormat *format,
    96                                    M3Gint *width, M3Gint *height, M3Gint *pixels);
    97 M3Gbool m3gglGetNativeWindowParams(M3GNativeWindow wnd,
    98                                    M3GPixelFormat *format,
    99                                    M3Gint *width, M3Gint *height);
   100     
   101 #endif /* M3G_NGL_CONTEXT_API */
   102     
   103 #if defined(__cplusplus)
   104 } /* extern "C" */
   105 #endif
   106 
   107 #endif /*__M3G_GL_H__*/