os/graphics/m3g/m3gcore11/inc/m3g_gl.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.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: OpenGL utility functions and definitions
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
#ifndef __M3G_GL_H__
sl@0
    19
#define __M3G_GL_H__
sl@0
    20
sl@0
    21
/*!
sl@0
    22
 * \internal
sl@0
    23
 * \file
sl@0
    24
 * \brief OpenGL utility functions and definitions
sl@0
    25
 */
sl@0
    26
sl@0
    27
#include "M3G/m3g_core.h"
sl@0
    28
#include "m3g_defs.h"
sl@0
    29
sl@0
    30
#if !(defined(M3G_NGL_CONTEXT_API) || defined(M3G_NGL_TEXTURE_API))
sl@0
    31
#   include <GLES/gl.h>
sl@0
    32
#   include <EGL/egl.h>
sl@0
    33
#else
sl@0
    34
sl@0
    35
/*@notfunction@*/
sl@0
    36
#   define NGL_PREFIX(func)     gl ## func
sl@0
    37
/*@notfunction@*/
sl@0
    38
#   define NGLI_PREFIX(func)    ngl ## func
sl@0
    39
/*@notfunction@*/
sl@0
    40
#   define NGLU_PREFIX(func)    nglu ## func
sl@0
    41
#   include "ngl.h"
sl@0
    42
sl@0
    43
#endif
sl@0
    44
sl@0
    45
#if defined(__cplusplus)
sl@0
    46
extern "C" {
sl@0
    47
#endif
sl@0
    48
    
sl@0
    49
/*----------------------------------------------------------------------
sl@0
    50
 * Handy macros
sl@0
    51
 *--------------------------------------------------------------------*/
sl@0
    52
sl@0
    53
#if defined(M3G_DEBUG_ASSERTS)
sl@0
    54
    static M3G_INLINE void m3gAssertGL(const char *filename, int line)
sl@0
    55
    {
sl@0
    56
        GLint err = glGetError();
sl@0
    57
        if (err != GL_NO_ERROR) {
sl@0
    58
            M3G_LOG3(M3G_LOG_FATAL_ERRORS, "GL error 0x%X (%s: %d)\n",
sl@0
    59
                     err, filename, line);
sl@0
    60
            M3G_ASSERT(M3G_FALSE);
sl@0
    61
        }
sl@0
    62
    }
sl@0
    63
#   define M3G_ASSERT_GL m3gAssertGL(__FILE__, __LINE__)
sl@0
    64
#else
sl@0
    65
#   define M3G_ASSERT_GL
sl@0
    66
#endif
sl@0
    67
sl@0
    68
#define M3G_GLTYPE(m3gType) ((m3gType) + 0x1400)
sl@0
    69
#define M3G_M3GTYPE(glType) ((glType) - 0x1400)
sl@0
    70
sl@0
    71
/*----------------------------------------------------------------------
sl@0
    72
 * Internal functions
sl@0
    73
 *--------------------------------------------------------------------*/
sl@0
    74
    
sl@0
    75
static GLenum m3gGetGLFormat(M3GPixelFormat format);    /* m3g_image.inl */
sl@0
    76
static void m3gGLColor(M3Guint argb, GLfixed *dst);     /* m3g_image.c */
sl@0
    77
sl@0
    78
#if !defined(M3G_NGL_CONTEXT_API)
sl@0
    79
static void m3gInitializeEGL(void);     /* m3g_rendercontext.inl */
sl@0
    80
static void m3gTerminateEGL(void);      /* m3g_rendercontext.inl */
sl@0
    81
#endif
sl@0
    82
sl@0
    83
/*----------------------------------------------------------------------
sl@0
    84
 * Native platform abstraction layer
sl@0
    85
 *--------------------------------------------------------------------*/
sl@0
    86
    
sl@0
    87
#if !defined(M3G_NGL_CONTEXT_API)
sl@0
    88
    
sl@0
    89
M3Gbool m3gglLockNativeBitmap(M3GNativeBitmap bitmap,
sl@0
    90
                              M3Gubyte **ptr,
sl@0
    91
                              M3Gsizei *stride);
sl@0
    92
void    m3gglReleaseNativeBitmap(M3GNativeBitmap bitmap);
sl@0
    93
    
sl@0
    94
M3Gbool m3gglGetNativeBitmapParams(M3GNativeBitmap bitmap,
sl@0
    95
                                   M3GPixelFormat *format,
sl@0
    96
                                   M3Gint *width, M3Gint *height, M3Gint *pixels);
sl@0
    97
M3Gbool m3gglGetNativeWindowParams(M3GNativeWindow wnd,
sl@0
    98
                                   M3GPixelFormat *format,
sl@0
    99
                                   M3Gint *width, M3Gint *height);
sl@0
   100
    
sl@0
   101
#endif /* M3G_NGL_CONTEXT_API */
sl@0
   102
    
sl@0
   103
#if defined(__cplusplus)
sl@0
   104
} /* extern "C" */
sl@0
   105
#endif
sl@0
   106
sl@0
   107
#endif /*__M3G_GL_H__*/