Guiliani
Version 2.5 revision 7293 (documentation build 13)
OGLES_API.h
1
/*
2
* Copyright (C) TES Electronic Solutions GmbH,
3
* All Rights Reserved.
4
* Contact: info@guiliani.de
5
*
6
* This file is part of the Guiliani HMI framework
7
* for the development of graphical user interfaces on embedded systems.
8
*/
9
10
#ifndef __OGLES_API_H__
11
#define __OGLES_API_H__
12
13
// OpenGL ES
14
#if defined(GUILIANI_USE_OGLES2)
15
#define GUILIANI_USE_GL_SHADERS 1
16
#include <GLES2/gl2.h>
17
#include <GLES2/gl2ext.h>
18
#elif defined(GUILIANI_USE_OGLES11)
19
// OpenGL ES 1.1
20
//include path for new versions of EGL (includes changed)
21
#if defined SYSTEM_NAME_DARWIN
//the header path is different on Darwin systems (iOS/MacOS)
22
#include <OpenGLES/ES1/gl.h>
23
#else
24
#include <GLES/gl.h>
25
#include <GLES/glext.h>
26
#endif
27
#endif
28
29
// Fixpoint environments (embedded targets) usually only support OpenGL ES.
30
// Float is usually supported on (non-ES) OpenGL desktop computers.
31
// Therefore, we do a simple mapping:
32
// Fixpoint -> OpenGL ES
33
// Float -> OpenGL
34
35
#if defined eC_FIXPOINT && defined GUILIANI_USE_OGLES2
36
#error Fixpoint is not supported in OGL and OGLES2 mode!
37
#endif
38
39
// maps the gl calls
40
#if defined eC_FIXPOINT
41
42
#define GL_EC_VALUE GL_FIXED
43
#define glTexEnvV glTexEnvx
44
#define glScaleV glScalex
45
#define glColor4V glColor4x
46
#define glOrthoV glOrthox
47
#define glFrustumV glFrustumx
48
#define glTranslateV glTranslatex
49
#define glClearColorV glClearColorx
50
#define glTexParameterV glTexParameterx
51
#define glTexEnvV glTexEnvx
52
#define glLoadMatrixV(m) glLoadMatrixx((GLfixed*)(m))
53
#define glMultMatrixV(m) glMultMatrixx((GLfixed*)(m))
54
#define glLineWidthV glLineWidthx
55
#define glClearDepthV glClearDepthx
56
// Use self implemented routine here. No more dependencies to glu library,
57
// when gluPerspectivex is not needed.
58
#define gluPerspectiveV GETGFX_GL.SetPerspectiveProjection
59
#define glRotateV glRotatex
60
#define glNormal3V glNormal3x
61
#define glMaterialV glMaterialx
62
#define glMaterialVv(a, b, c) glMaterialxv(a, b, (GLfixed*)(c))
63
#define glLightV glLightx
64
#define glLightVv(a, b, c) glLightxv(a, b, (GLfixed*)(c))
65
#define glLightModelVv(a, b) glLightModelxv(a, (GLfixed*)(b))
66
#define glGetV(a, b) glGetFixedv(a, (GLfixed*)(b))
67
68
#else
69
70
#if GUILIANI_USE_GL_SHADERS == 1
71
72
// when using shaders some gl-function are getting re-mapped for simplicity
73
#define glTranslateV GETGFX_GL.SetTranslation
74
#define glColor4V(r, g, b, a) glUniform4f(glGetUniformLocation(GETGFX_GL.GetShaderID(), "Color"
), eC_ToFloat(r), eC_ToFloat(g), eC_ToFloat(b), eC_ToFloat(a))
75
#define glOrthoV GETGFX_GL.SetOrthoProjection
76
#define glFrustumV GETGFX_GL.SetFrustumProjection
77
#define glRotateV(a, b, c, d) GETGFX_GL.SetRotation(a, b, c, d)
78
#define glScaleV GETGFX_GL.SetScaling
79
80
#undef GL_PROJECTION
81
#define GL_PROJECTION CGfxWrapGL::MT_PROJECTION
82
83
#undef GL_MODELVIEW
84
#define GL_MODELVIEW CGfxWrapGL::MT_MODELVIEW
85
86
// re-map GL-constants to point to locations of vertex-attributes
87
#undef GL_VERTEX_ARRAY
88
#define GL_VERTEX_ARRAY 0
89
90
#undef GL_TEXTURE_COORD_ARRAY
91
#define GL_TEXTURE_COORD_ARRAY 1
92
93
#undef GL_COLOR_ARRAY
94
#define GL_COLOR_ARRAY 2
95
96
#define glMatrixMode GETGFX_GL.SetMatrixMode
97
#define glLoadIdentity GETGFX_GL.LoadIdentity
98
#define glPushMatrix GETGFX_GL.PushMatrix
99
#define glPopMatrix GETGFX_GL.PopMatrix
100
#define glLoadMatrixV GETGFX_GL.SetMatrix
101
#define glEnableClientState glEnableVertexAttribArray
102
#define glDisableClientState glDisableVertexAttribArray
103
#define glVertexPointer(a, b, c, d) glVertexAttribPointer(GL_VERTEX_ARRAY, a, b, GL_FALSE, c, d)
104
#define glTexCoordPointer(a, b, c, d) glVertexAttribPointer(GL_TEXTURE_COORD_ARRAY, a, b, GL_FALSE, c, d)
105
106
#else
107
108
#define glTranslateV(x, y, z) glTranslatef(eC_ToFloat(x), eC_ToFloat(y), eC_ToFloat(z))
109
#define glColor4V(r, g, b, a) glColor4f(eC_ToFloat(r), eC_ToFloat(g), eC_ToFloat(b), eC_ToFloat(a))
110
#define glRotateV(a, b, c, d) glRotatef(eC_ToFloat(a), eC_ToFloat(b), eC_ToFloat(c), eC_ToFloat(d))
111
#define glTexEnvV glTexEnvf
112
#define glScaleV glScalef
113
#define glLoadMatrixV(a) glLoadMatrixf(reinterpret_cast<const GLfloat*>(a))
114
#define glMultMatrixV glMultMatrixf
115
#define glNormal3V(x, y, z) glNormal3f(eC_ToFloat(x), eC_ToFloat(y), eC_ToFloat(z))
116
#define glMaterialV(a, b, c) glMaterialf(a, b, eC_ToFloat(c))
117
#define glMaterialVv glMaterialfv
118
#define glLightV(a, b, c) glLightf(a, b, eC_ToFloat(c))
119
#define glLightVv glLightfv
120
#define glLightModelVv glLightModelfv
121
#define glOrthoV(a, b, c, d, e, f) glOrthof(eC_ToFloat(a), eC_ToFloat(b), eC_ToFloat(c), eC_ToFloat(d), eC_ToFloat(e), eC_ToFloat(f))
122
#define glFrustumV(a, b, c, d, e, f) glFrustumf(eC_ToFloat(a), eC_ToFloat(b), eC_ToFloat(c), eC_ToFloat(d), eC_ToFloat(e), eC_ToFloat(f))
123
124
#endif
125
126
#define GL_EC_VALUE GL_FLOAT
127
#define glClearColorV(r, g, b, a) glClearColor(eC_ToFloat(r), eC_ToFloat(g), eC_ToFloat(b), eC_ToFloat(a))
128
#define glTexParameterV(target, pname, param) glTexParameterf(eC_ToFloat(target), eC_ToFloat(pname), eC_ToFloat(param))
129
#define glLineWidthV glLineWidth
130
#define glClearDepthV(a) glClearDepth(eC_ToFloat(a))
131
#define gluPerspectiveV GETGFX_GL.SetPerspectiveProjection
132
#define glGetV glGetFloatv
133
134
#endif
135
136
#endif
Include
Platform
GL
OGLES_API.h
Generated by
1.9.4