| 1 |
/** |
| 2 |
* Access to GL functions without linking to system-specific library |
| 3 |
|
| 4 |
* Copyright (C) 2015 Sylvain Beucler |
| 5 |
|
| 6 |
* This file is part of GNU FreeDink |
| 7 |
|
| 8 |
* GNU FreeDink is free software: you can redistribute it and/or |
| 9 |
* modify it under the terms of the GNU Affero General Public License |
| 10 |
* as published by the Free Software Foundation, either version 3 of |
| 11 |
* the License, or (at your option) any later version. |
| 12 |
|
| 13 |
* GNU FreeDink is distributed in the hope that it will be useful, but |
| 14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
* Affero General Public License for more details. |
| 17 |
|
| 18 |
* You should have received a copy of the GNU Affero General Public |
| 19 |
* License along with GNU FreeDink. If not, see |
| 20 |
* <http://www.gnu.org/licenses/>. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef IOGRAPHICSGLFUNCS_H |
| 24 |
#define IOGRAPHICSGLFUNCS_H |
| 25 |
|
| 26 |
#ifndef APIENTRY |
| 27 |
# if defined(_WIN32) |
| 28 |
# define APIENTRY __stdcall |
| 29 |
# else |
| 30 |
# define APIENTRY |
| 31 |
# endif |
| 32 |
#endif |
| 33 |
|
| 34 |
//#include <GLES2/gl2.h> |
| 35 |
//#if 0 |
| 36 |
#include <stddef.h> /* ptrdiff_t */ |
| 37 |
typedef void GLvoid; |
| 38 |
typedef char GLchar; |
| 39 |
typedef unsigned int GLuint; |
| 40 |
typedef int GLint; |
| 41 |
typedef int GLsizei; |
| 42 |
typedef float GLfloat; |
| 43 |
typedef float GLclampf; |
| 44 |
typedef unsigned int GLenum; |
| 45 |
typedef unsigned int GLbitfield; |
| 46 |
typedef ptrdiff_t GLsizeiptr; |
| 47 |
|
| 48 |
typedef unsigned char GLboolean; |
| 49 |
#define GL_FALSE 0 |
| 50 |
#define GL_TRUE 1 |
| 51 |
|
| 52 |
#define GL_NO_ERROR 0 |
| 53 |
#define GL_INVALID_ENUM 0x0500 |
| 54 |
#define GL_INVALID_VALUE 0x0501 |
| 55 |
#define GL_INVALID_OPERATION 0x0502 |
| 56 |
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 |
| 57 |
#define GL_OUT_OF_MEMORY 0x0505 |
| 58 |
|
| 59 |
#define GL_BLEND 0x0BE2 |
| 60 |
#define GL_SRC_ALPHA 0x0302 |
| 61 |
#define GL_ONE_MINUS_SRC_ALPHA 0x0303 |
| 62 |
|
| 63 |
#define GL_DEPTH_BUFFER_BIT 0x0100 |
| 64 |
#define GL_STENCIL_BUFFER_BIT 0x0400 |
| 65 |
#define GL_COLOR_BUFFER_BIT 0x4000 |
| 66 |
|
| 67 |
#define GL_RGB 0x1907 |
| 68 |
#define GL_RGBA 0x1908 |
| 69 |
#define GL_LUMINANCE 0x1909 |
| 70 |
|
| 71 |
#define GL_UNSIGNED_BYTE 0x1401 |
| 72 |
#define GL_FLOAT 0x1406 |
| 73 |
#define GL_TEXTURE_2D 0x0DE1 |
| 74 |
#define GL_TEXTURE_MIN_FILTER 0x2801 |
| 75 |
#define GL_TEXTURE_MAG_FILTER 0x2800 |
| 76 |
#define GL_NEAREST 0x2600 |
| 77 |
#define GL_LINEAR 0x2601 |
| 78 |
#define GL_TEXTURE_WRAP_S 0x2802 |
| 79 |
#define GL_TEXTURE_WRAP_T 0x2803 |
| 80 |
#define GL_CLAMP_TO_EDGE 0x812F |
| 81 |
#define GL_CLAMP 0x2900 |
| 82 |
|
| 83 |
#define GL_ARRAY_BUFFER 0x8892 |
| 84 |
#define GL_TRIANGLE_STRIP 0x0005 |
| 85 |
#define GL_STATIC_DRAW 0x88E4 |
| 86 |
|
| 87 |
#define GL_VERTEX_SHADER 0x8B31 |
| 88 |
#define GL_FRAGMENT_SHADER 0x8B30 |
| 89 |
#define GL_COMPILE_STATUS 0x8B81 |
| 90 |
#define GL_LINK_STATUS 0x8B82 |
| 91 |
#define GL_INFO_LOG_LENGTH 0x8B84 |
| 92 |
|
| 93 |
#define GL_TEXTURE0 0x84C0 |
| 94 |
#define GL_TEXTURE1 0x84C1 |
| 95 |
|
| 96 |
#define GL_FRAMEBUFFER 0x8D40 |
| 97 |
#define GL_RENDERBUFFER 0x8D41 |
| 98 |
#define GL_COLOR_ATTACHMENT0 0x8CE0 |
| 99 |
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 |
| 100 |
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 |
| 101 |
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 |
| 102 |
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 |
| 103 |
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD |
| 104 |
|
| 105 |
#define GL_READ_BUFFER 0x0C02 |
| 106 |
#define GL_FRONT 0x0404 |
| 107 |
#define GL_BACK 0x0405 |
| 108 |
|
| 109 |
//#endif |
| 110 |
|
| 111 |
class IOGfxGLFuncs { |
| 112 |
public: |
| 113 |
IOGfxGLFuncs(); |
| 114 |
|
| 115 |
GLenum (APIENTRY *GetError)(void); |
| 116 |
void (APIENTRY *Enable)(GLenum cap); |
| 117 |
void (APIENTRY *GetIntegerv)(GLenum pname, GLint* params); |
| 118 |
void (APIENTRY *BlendFunc)(GLenum sfactor, GLenum dfactor); |
| 119 |
|
| 120 |
void (APIENTRY *Clear)(GLbitfield); |
| 121 |
void (APIENTRY *ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); |
| 122 |
void (APIENTRY *Viewport)(GLint x, GLint y, GLsizei width, GLsizei height); |
| 123 |
|
| 124 |
void (APIENTRY *ReadBuffer)(GLenum mode); |
| 125 |
void (APIENTRY *ReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); |
| 126 |
|
| 127 |
void (APIENTRY *GenTextures)(GLsizei n, GLuint *textures); |
| 128 |
void (APIENTRY *BindTexture)(GLenum target, GLuint texture); |
| 129 |
void (APIENTRY *DeleteTextures)(GLsizei n, const GLuint *textures); |
| 130 |
void (APIENTRY *TexParameteri)(GLenum target, GLenum pname, GLint param); |
| 131 |
void (APIENTRY *TexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); |
| 132 |
|
| 133 |
void (APIENTRY *GenBuffers)(GLsizei n, GLuint* buffers); |
| 134 |
void (APIENTRY *BindBuffer)(GLenum target, GLuint buffer); |
| 135 |
void (APIENTRY *BufferData)(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); |
| 136 |
void (APIENTRY *DeleteBuffers)(GLsizei n, const GLuint* buffers); |
| 137 |
|
| 138 |
GLboolean (APIENTRY *IsShader)(GLuint shader); |
| 139 |
GLuint (APIENTRY *CreateShader)(GLenum type); |
| 140 |
void (APIENTRY *ShaderSource)(GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); |
| 141 |
void (APIENTRY *CompileShader)(GLuint shader); |
| 142 |
void (APIENTRY *GetShaderiv)(GLuint shader, GLenum pname, GLint* param); |
| 143 |
void (APIENTRY *GetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); |
| 144 |
void (APIENTRY *AttachShader)(GLuint program, GLuint shader); |
| 145 |
void (APIENTRY *DeleteShader)(GLuint shader); |
| 146 |
|
| 147 |
GLboolean (APIENTRY *IsProgram)(GLuint program); |
| 148 |
GLuint (APIENTRY *CreateProgram)(void); |
| 149 |
void (APIENTRY *GetProgramiv)(GLuint program, GLenum pname, GLint* param); |
| 150 |
void (APIENTRY *LinkProgram)(GLuint program); |
| 151 |
void (APIENTRY *GetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); |
| 152 |
void (APIENTRY *DeleteProgram)(GLuint program); |
| 153 |
|
| 154 |
GLint (APIENTRY *GetAttribLocation)(GLuint program, const GLchar* name); |
| 155 |
GLint (APIENTRY *GetUniformLocation)(GLuint program, const GLchar* name); |
| 156 |
|
| 157 |
void (APIENTRY *UseProgram)(GLuint program); |
| 158 |
void (APIENTRY *ActiveTexture)(GLenum texture); |
| 159 |
void (APIENTRY *Uniform1i)(GLint location, GLint v0); |
| 160 |
void (APIENTRY *Uniform1f)(GLint location, GLfloat v0); |
| 161 |
void (APIENTRY *Uniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); |
| 162 |
void (APIENTRY *Uniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); |
| 163 |
void (APIENTRY *UniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); |
| 164 |
void (APIENTRY *UniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); |
| 165 |
|
| 166 |
void (APIENTRY *EnableVertexAttribArray)(GLuint); |
| 167 |
void (APIENTRY *VertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); |
| 168 |
void (APIENTRY *DisableVertexAttribArray)(GLuint); |
| 169 |
|
| 170 |
void (APIENTRY *GenFramebuffers)(GLsizei n, GLuint* framebuffers); |
| 171 |
void (APIENTRY *BindFramebuffer)(GLenum target, GLuint framebuffer); |
| 172 |
void (APIENTRY *FramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); |
| 173 |
GLenum (APIENTRY *CheckFramebufferStatus)(GLenum target); |
| 174 |
void (APIENTRY *DeleteFramebuffers)(GLsizei n, const GLuint* framebuffers); |
| 175 |
|
| 176 |
void (APIENTRY *DrawArrays)(GLenum mode, GLint first, GLsizei count); |
| 177 |
|
| 178 |
void logGetError(); |
| 179 |
}; |
| 180 |
|
| 181 |
#endif |