"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl / cogl-internal.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2007,2008,2009,2010 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  *
22  */
23
24 #ifndef __COGL_INTERNAL_H
25 #define __COGL_INTERNAL_H
26
27 #include "cogl-bitmask.h"
28
29 #ifdef COGL_HAS_XLIB_SUPPORT
30 #include <X11/Xutil.h>
31 #endif
32
33 #ifdef COGL_GL_DEBUG
34
35 const char *
36 _cogl_gl_error_to_string (GLenum error_code);
37
38 #define GE(ctx, x)                      G_STMT_START {  \
39   GLenum __err;                                         \
40   (ctx)->x;                                             \
41   while ((__err = (ctx)->glGetError ()) != GL_NO_ERROR) \
42     {                                                   \
43       g_warning ("%s: GL error (%d): %s\n",             \
44                  G_STRLOC,                              \
45                  __err,                                 \
46                  _cogl_gl_error_to_string (__err));     \
47     }                                   } G_STMT_END
48
49 #define GE_RET(ret, ctx, x)             G_STMT_START {  \
50   GLenum __err;                                         \
51   ret = (ctx)->x;                                       \
52   while ((__err = (ctx)->glGetError ()) != GL_NO_ERROR) \
53     {                                                   \
54       g_warning ("%s: GL error (%d): %s\n",             \
55                  G_STRLOC,                              \
56                  __err,                                 \
57                  _cogl_gl_error_to_string (__err));     \
58     }                                   } G_STMT_END
59
60 #else /* !COGL_GL_DEBUG */
61
62 #define GE(ctx, x) ((ctx)->x)
63 #define GE_RET(ret, ctx, x) (ret = ((ctx)->x))
64
65 #endif /* COGL_GL_DEBUG */
66
67 #define COGL_ENABLE_ALPHA_TEST        (1<<1)
68 #define COGL_ENABLE_VERTEX_ARRAY      (1<<2)
69 #define COGL_ENABLE_COLOR_ARRAY       (1<<3)
70
71 void
72 _cogl_enable (unsigned long flags);
73
74 unsigned long
75 _cogl_get_enable (void);
76
77 void
78 _cogl_transform_point (const CoglMatrix *matrix_mv,
79                        const CoglMatrix *matrix_p,
80                        const float *viewport,
81                        float *x,
82                        float *y);
83
84 #define COGL_DRIVER_ERROR (_cogl_driver_error_quark ())
85
86 typedef enum { /*< prefix=COGL_DRIVER_ERROR >*/
87   COGL_DRIVER_ERROR_UNKNOWN_VERSION,
88   COGL_DRIVER_ERROR_INVALID_VERSION,
89   COGL_DRIVER_ERROR_NO_SUITABLE_DRIVER_FOUND,
90   COGL_DRIVER_ERROR_FAILED_TO_LOAD_LIBRARY
91 } CoglDriverError;
92
93 typedef enum
94 {
95   COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE = 1L<<0,
96   COGL_PRIVATE_FEATURE_MESA_PACK_INVERT = 1L<<1,
97   COGL_PRIVATE_FEATURE_STENCIL_BUFFER = 1L<<2,
98   COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT = 1L<<3,
99   COGL_PRIVATE_FEATURE_FOUR_CLIP_PLANES = 1L<<4,
100   COGL_PRIVATE_FEATURE_PBOS = 1L<<5,
101   COGL_PRIVATE_FEATURE_VBOS = 1L<<6,
102   COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL = 1L<<7,
103   COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL = 1L<<8
104 } CoglPrivateFeatureFlags;
105
106 /* Sometimes when evaluating pipelines, either during comparisons or
107  * if calculating a hash value we need to tweak the evaluation
108  * semantics */
109 typedef enum _CoglPipelineEvalFlags
110 {
111   COGL_PIPELINE_EVAL_FLAG_NONE = 0
112 } CoglPipelineEvalFlags;
113
114 gboolean
115 _cogl_check_extension (const char *name, const char *ext);
116
117 GQuark
118 _cogl_driver_error_quark (void);
119
120 #endif /* __COGL_INTERNAL_H */