SDLGLES initial import
[sdlhildon] / sdlgles / src / SDL_gles.h
1 /* This file is part of SDL_gles - SDL addon for OpenGL|ES
2  * Copyright (C) 2010 Javier S. Pedro
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 3 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA or see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __SDL_GLES_H
21 #define __SDL_GLES_H
22
23 /* Set up for C function definitions, even when using C++ */
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 typedef enum SDL_GLES_Version
29 {
30         SDL_GLES_VERSION_NONE = 0,
31         SDL_GLES_VERSION_1_1 = 1,
32         SDL_GLES_VERSION_2_0 = 2
33 } SDL_GLES_Version;
34
35 typedef struct SDL_GLES_Context
36 {
37         /* Opaque pointer to an EGLContext */
38 } SDL_GLES_Context;
39
40 /** Invoke after SDL_Init.
41         @return 0 if SDL_gles was initialized correctly.
42   */
43 extern DECLSPEC int SDLCALL SDL_GLES_Init(SDL_GLES_Version version);
44
45 /** Invoke just before SDL_Quit.
46   */
47 extern DECLSPEC void SDLCALL SDL_GLES_Quit();
48
49 /* Equivalent to SDL/GL ones. Untested. */
50 /** Call before calling GetProcAddress. Dynamically loads a GLES library.
51   * @param path full path to the library to load, or leave as NULL to load
52   *             the default GL ES library to the version specified in SDL_GLES_Init().
53   * @return 0 if everything went OK.
54   */
55 extern DECLSPEC int SDLCALL SDL_GLES_LoadLibrary(const char *path);
56 /** Returns the address of a symbol in the loaded GL ES library.
57   * @param name of the symbol to look up.
58   * @return address of the symbol or NULL.
59   */
60 extern DECLSPEC void* SDLCALL SDL_GLES_GetProcAddress(const char *proc);
61
62 /** Creates a new GL ES rendering context. This is where all your textures,
63   * etc. are stored. You need one for rendering; after creating it, make sure
64   * it is the current one calling SDL_GLES_MakeCurrent().
65   * @return the created context or NULL.
66   */
67 extern DECLSPEC SDL_GLES_Context* SDLCALL SDL_GLES_CreateContext(void);
68 /** Deletes an existing GL ES rendering context. This can delete the current
69   * context, but after that no context will be current.
70   * @param context context to delete
71   */
72 extern DECLSPEC void SDLCALL SDL_GLES_DeleteContext(SDL_GLES_Context *context);
73
74 /** Call after calling SDL_SetVideoMode() if you have an active context
75   * to refresh the surface parameters.
76   * @return 0 if everything went OK.
77   */
78 extern DECLSPEC int SDLCALL SDL_GLES_SetVideoMode(void);
79 /** Makes a context the current one. All GLES calls will use it from now on.
80   * @param context context to use
81   * @return 0 if everything went OK.
82   */
83 extern DECLSPEC int SDLCALL SDL_GLES_MakeCurrent(SDL_GLES_Context *context);
84
85 /** Equivalent to SDL_Flip(). Call when you're finished issuing GL calls
86   * and want to draw the color buffer contents to the window surface.
87   */
88 extern DECLSPEC void SDLCALL SDL_GLES_SwapBuffers(void);
89
90 /* Ends C function definitions when using C++ */
91 #ifdef __cplusplus
92 }
93 #endif
94
95 #endif