documentation was wrong
[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 /** OpenGL ES versions compatible with this library. */
29 typedef enum SDL_GLES_Version
30 {
31         SDL_GLES_VERSION_NONE = 0,
32         /** OpenGL ES 1.1 */
33         SDL_GLES_VERSION_1_1 = 1,
34         /** OpenGL ES 2.0 */
35         SDL_GLES_VERSION_2_0 = 2
36 } SDL_GLES_Version;
37
38 /** Context attributes. */
39 typedef enum SDL_GLES_Attr
40 {
41         SDL_GLES_BUFFER_SIZE = 0,
42         SDL_GLES_RED_SIZE,
43         SDL_GLES_GREEN_SIZE,
44         SDL_GLES_BLUE_SIZE,
45         SDL_GLES_ALPHA_SIZE,
46         SDL_GLES_LUMINANCE_SIZE,
47         SDL_GLES_DEPTH_SIZE,
48         SDL_GLES_STENCIL_SIZE
49 } SDL_GLES_Attr;
50
51 /** Represents a EGL context.
52     A context is where all textures, etc. are stored.
53   */
54 typedef struct SDL_GLES_Context
55 {
56         /* Opaque pointer to an EGLContext */
57 } SDL_GLES_Context;
58
59 /** Invoke after SDL_Init.
60     You need to call this before any other routine in this library.
61     @param version selects the OpenGL ES version to use.
62         @return 0 if SDL_gles was initialized correctly; any other value
63           if the initialization failed. You can then check for errrors using
64           SDL_GetError().
65   */
66 extern DECLSPEC int SDLCALL SDL_GLES_Init(SDL_GLES_Version version);
67
68 /** Invoke just before SDL_Quit.
69     Closes the connection with the graphics accelerator. After a call to 
70     SDL_GLES_Quit(), you must not call any other function in this library.
71   */
72 extern DECLSPEC void SDLCALL SDL_GLES_Quit();
73
74 /** Call before calling GetProcAddress. Dynamically loads a GLES library.
75   * @param path full path to the library to load, or leave as NULL to load
76   *             the default GL ES library (version as specified in SDL_GLES_Init()).
77   * @return 0 if everything went OK.
78   */
79 extern DECLSPEC int SDLCALL SDL_GLES_LoadLibrary(const char *path);
80 /** Returns the address of a symbol in the loaded GL ES library.
81   * @param proc name of the symbol to look up.
82   * @return address of the symbol or NULL.
83   */
84 extern DECLSPEC void* SDLCALL SDL_GLES_GetProcAddress(const char *proc);
85
86 /** Creates a new GL ES rendering context. This is where all your textures,
87   * etc. are stored. You need one for rendering; after creating it, make sure
88   * it is the current one calling SDL_GLES_MakeCurrent().
89   * @return the created context or NULL.
90   */
91 extern DECLSPEC SDL_GLES_Context* SDLCALL SDL_GLES_CreateContext(void);
92 /** Deletes an existing GL ES rendering context. This can delete the current
93   * context, but after that no context will be current.
94   * @param context context to delete
95   */
96 extern DECLSPEC void SDLCALL SDL_GLES_DeleteContext(SDL_GLES_Context *context);
97
98 /** Call after calling SDL_SetVideoMode() if you have an active context
99   * to refresh the surface parameters.
100   * @return 0 if everything went OK.
101   */
102 extern DECLSPEC int SDLCALL SDL_GLES_SetVideoMode(void);
103 /** Makes a context the current one. All GLES calls will use it from now on.
104   * @param context context to use
105   * @return 0 if everything went OK.
106   */
107 extern DECLSPEC int SDLCALL SDL_GLES_MakeCurrent(SDL_GLES_Context *context);
108
109 /** Equivalent to SDL_Flip(). Call when you're finished issuing GL calls
110   * and want to draw the color buffer contents to the window surface.
111   */
112 extern DECLSPEC void SDLCALL SDL_GLES_SwapBuffers(void);
113
114 /** Sets a specific context attribute (before calling SDL_CreateContext()).
115   * @param attr attribute to set
116   * @param value new value
117   * @return 0 if the attribute exists, -1 otherwise.
118   */
119 extern DECLSPEC int SDLCALL SDL_GLES_SetAttribute(SDL_GLES_Attr attr, int value);
120
121 /** Gets a context attribute from the current context, or from the wanted
122   * attribute set if no context is current.
123   * @param attr attribute to get
124   * @param value pointer where the result will be stored.
125   * @return 0 if the attribute exists, -1 otherwise.
126   */
127 extern DECLSPEC int SDLCALL SDL_GLES_GetAttribute(SDL_GLES_Attr attr, int *value);
128
129 /* Ends C function definitions when using C++ */
130 #ifdef __cplusplus
131 }
132 #endif
133
134 #endif