diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-07 17:38:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-07 17:38:00 +0300 |
commit | b60aef9dc9977b54a1b27431890e06558a2b6784 (patch) | |
tree | 9dcb836f2717b1d8f1e3c717e859d9c5003c2de4 /src/render | |
parent | aa43e9466326f63017fb92ee0cf5a61976fe3535 (diff) | |
download | plus-b60aef9dc9977b54a1b27431890e06558a2b6784.tar.gz plus-b60aef9dc9977b54a1b27431890e06558a2b6784.tar.bz2 plus-b60aef9dc9977b54a1b27431890e06558a2b6784.tar.xz plus-b60aef9dc9977b54a1b27431890e06558a2b6784.zip |
Split mgl into separate files.
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/mgl.h | 167 | ||||
-rw-r--r-- | src/render/mgldefines.h | 86 | ||||
-rw-r--r-- | src/render/mgltypes.h | 139 |
3 files changed, 228 insertions, 164 deletions
diff --git a/src/render/mgl.h b/src/render/mgl.h index d4dd33bcc..2213458bb 100644 --- a/src/render/mgl.h +++ b/src/render/mgl.h @@ -24,168 +24,11 @@ #include "main.h" #ifdef USE_OPENGL -#ifdef ANDROID -#include <GLES/gl.h> -#include <GLES/glext.h> -#define APIENTRY GL_APIENTRY -#else -#ifndef USE_SDL2 -#define GL_GLEXT_PROTOTYPES 1 -#endif -#include <SDL_opengl.h> -#include <GL/glext.h> -#endif - -#define GL_NUM_EXTENSIONS 0x821D -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 - -#ifndef GL_COMPRESSED_RGBA_ARB -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif -#ifndef GL_MAX_ELEMENTS_VERTICES -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#endif - -#ifndef GL_DEBUG_OUTPUT -#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#define GL_DEBUG_OUTPUT 0x92E0 -#define GL_DEBUG_SOURCE_API 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#define GL_DEBUG_SOURCE_OTHER 0x824B -#define GL_DEBUG_TYPE_ERROR 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#define GL_DEBUG_TYPE_PORTABILITY 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#define GL_DEBUG_TYPE_OTHER 0x8251 -#define GL_DEBUG_TYPE_MARKER 0x8268 -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#define GL_DEBUG_SEVERITY_HIGH 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#define GL_DEBUG_SEVERITY_LOW 0x9148 -#endif - -#ifndef GL_EXT_debug_label -#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F -#define GL_PROGRAM_OBJECT_EXT 0x8B40 -#define GL_SHADER_OBJECT_EXT 0x8B48 -#define GL_BUFFER_OBJECT_EXT 0x9151 -#define GL_QUERY_OBJECT_EXT 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 -#endif - -#ifndef GL_ARRAY_BUFFER -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#endif - -#ifndef GL_STREAM_DRAW -#define GL_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 -#endif +#include "render/mgldefines.h" +#include "render/mgltypes.h" #define defNameE(name) extern name##_t m##name -typedef void (APIENTRY *glGenRenderbuffers_t)(GLsizei, GLuint *); -typedef void (APIENTRY *glBindRenderbuffer_t)(GLenum target, - GLuint renderbuffer); -typedef void (APIENTRY *glRenderbufferStorage_t)(GLenum target, - GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRY *glGenFramebuffers_t)(GLsizei n, GLuint *framebuffers); -typedef void (APIENTRY *glBindFramebuffer_t)(GLenum target, - GLuint framebuffer); -typedef void (APIENTRY *glFramebufferTexture2D_t)(GLenum target, - GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRY *glFramebufferRenderbuffer_t)(GLenum target, - GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRY *glDeleteFramebuffers_t) (GLsizei, const GLuint *); -typedef void (APIENTRY *glDeleteRenderbuffers_t) (GLsizei, const GLuint *); -typedef const GLubyte *(APIENTRY *glGetStringi_t) (GLenum, GLuint); -typedef void (APIENTRY *glGenSamplers_t) (GLsizei count, GLuint *samplers); -typedef void (APIENTRY *glDeleteSamplers_t) - (GLsizei count, const GLuint * samplers); -typedef void (APIENTRY *glBindSampler_t) (GLuint unit, GLuint sampler); -typedef void (APIENTRY *glSamplerParameteri_t) - (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRY *glDebugMessageControl_t) (GLenum source, GLenum type, - GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); -typedef void (APIENTRY *glFrameTerminator_t) (void); -typedef void (APIENTRY *glLabelObject_t) (GLenum type, GLuint object, - GLsizei length, const GLchar *label); -typedef void (APIENTRY *glGetObjectLabel_t) (GLenum type, GLuint object, - GLsizei bufSize, GLsizei *length, GLchar *label); -typedef void (APIENTRY *glInsertEventMarker_t) - (GLsizei length, const char *marker); -typedef void (APIENTRY *glPushGroupMarker_t) - (GLsizei length, const char *marker); -typedef void (APIENTRY *glPopGroupMarker_t) (void); -typedef void (APIENTRY *glGenVertexArrays_t) (GLsizei n, GLuint *arrays); -typedef void (APIENTRY *glBindVertexArray_t) (GLuint array); -typedef void (APIENTRY *glDeleteVertexArrays_t) (GLsizei n, GLuint *arrays); -typedef void (APIENTRY *glVertexAttribPointer_t) (GLuint index, GLint size, - GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRY *glEnableVertexAttribArray_t) (GLuint index); -typedef void (APIENTRY *glDisableVertexAttribArray_t) (GLuint index); -typedef void (APIENTRY *glGenBuffers_t) (GLsizei n, GLuint *buffers); -typedef void (APIENTRY *glDeleteBuffers_t) (GLsizei n, GLuint *buffers); -typedef void (APIENTRY *glBindBuffer_t) (GLenum target, GLuint buffer); -typedef void (APIENTRY *glBufferData_t) (GLenum target, GLsizeiptr size, - const GLvoid *data, GLenum usage); -typedef void (APIENTRY *glCreateShader_t) (GLenum shaderType); -typedef void (APIENTRY *glDeleteShader_t) (GLenum shader); -typedef void (APIENTRY *glGetShaderiv_t) (GLuint shader, - GLenum pname, GLint *params); -typedef void (APIENTRY *glGetShaderInfoLog_t) (GLuint shader, - GLsizei maxLength, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRY *glGetShaderSource_t) (GLuint shader, - GLsizei bufSize, GLsizei *length, GLchar *source); -typedef void (APIENTRY *glShaderSource_t) (GLuint shader, - GLsizei count, const GLchar **string, const GLint *length); -typedef void (APIENTRY *glCompileShader_t) (GLuint shader); -typedef void (APIENTRY *glLinkProgram_t) (GLuint program); -typedef void (APIENTRY *glDeleteProgram_t) (GLuint program); -typedef GLuint (APIENTRY *glCreateProgram_t) (void); -typedef void (APIENTRY *glAttachShader_t) (GLuint program, GLuint shader); -typedef void (APIENTRY *glDetachShader_t) (GLuint program, GLuint shader); -typedef void (APIENTRY *glGetAttachedShaders_t) (GLuint program, - GLsizei maxCount, GLsizei *count, GLuint *shaders); -typedef void (APIENTRY *glGetUniformLocation_t) (GLuint program, - const GLchar *name); -typedef void (APIENTRY *glGetActiveUniform_t) (GLuint program, GLuint index, - GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRY *glGetProgramiv_t) (GLuint program, - GLenum pname, GLint *params); -typedef GLint (APIENTRY *glBindFragDataLocation_t) (GLuint program, - GLuint colorNumber, const char *name); -typedef void (APIENTRY *glUseProgram_t) (GLuint program); -typedef void (APIENTRY *glValidateProgram_t) (GLuint program); -typedef GLint (APIENTRY *glGetAttribLocation_t) (GLuint program, - const GLchar *name); -typedef void (APIENTRY *glUniform1f_t) (GLint location, GLfloat v0); -typedef void (APIENTRY *glUniform2f_t) (GLint location, - GLfloat v0, GLfloat v1); -typedef void (APIENTRY *glUniform3f_t) (GLint location, - GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRY *glUniform4f_t) (GLint location, - GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); - -// callback -typedef void (APIENTRY *GLDEBUGPROC_t) (GLenum source, GLenum type, GLuint id, - GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam); - -typedef void (APIENTRY *glDebugMessageCallback_t) (GLDEBUGPROC_t callback, - const void *userParam); - defNameE(glGenRenderbuffers); defNameE(glBindRenderbuffer); defNameE(glRenderbufferStorage); @@ -244,12 +87,8 @@ defNameE(glUniform3f); defNameE(glUniform4f); #ifdef WIN32 -typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc); - defNameE(wglGetExtensionsString); -#else -#define CALLBACK #endif -#endif +#endif // USE_OPENGL #endif // RENDER_MGL_H diff --git a/src/render/mgldefines.h b/src/render/mgldefines.h new file mode 100644 index 000000000..7a65932eb --- /dev/null +++ b/src/render/mgldefines.h @@ -0,0 +1,86 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef RENDER_MGLDEFINES_H +#define RENDER_MGLDEFINES_H + +#ifdef USE_OPENGL + +#define GL_NUM_EXTENSIONS 0x821D +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 + +#ifndef GL_COMPRESSED_RGBA_ARB +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif +#ifndef GL_MAX_ELEMENTS_VERTICES +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#endif + +#ifndef GL_DEBUG_OUTPUT +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#endif + +#ifndef GL_EXT_debug_label +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +#endif + +#ifndef GL_ARRAY_BUFFER +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#endif + +#ifndef GL_STREAM_DRAW +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#endif + +#endif // USE_OPENGL + +#endif // RENDER_MGLDEFINES_H diff --git a/src/render/mgltypes.h b/src/render/mgltypes.h new file mode 100644 index 000000000..8e5cbe40d --- /dev/null +++ b/src/render/mgltypes.h @@ -0,0 +1,139 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef RENDER_MGLTYPES_H +#define RENDER_MGLTYPES_H + +#include "main.h" +#ifdef USE_OPENGL + +#include "render/mgldefines.h" + +#ifdef ANDROID +#include <GLES/gl.h> +#include <GLES/glext.h> +#define APIENTRY GL_APIENTRY +#else +#ifndef USE_SDL2 +#define GL_GLEXT_PROTOTYPES 1 +#endif +#include <SDL_opengl.h> +#include <GL/glext.h> +#endif + +typedef void (APIENTRY *glGenRenderbuffers_t)(GLsizei, GLuint *); +typedef void (APIENTRY *glBindRenderbuffer_t)(GLenum target, + GLuint renderbuffer); +typedef void (APIENTRY *glRenderbufferStorage_t)(GLenum target, + GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRY *glGenFramebuffers_t)(GLsizei n, GLuint *framebuffers); +typedef void (APIENTRY *glBindFramebuffer_t)(GLenum target, + GLuint framebuffer); +typedef void (APIENTRY *glFramebufferTexture2D_t)(GLenum target, + GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRY *glFramebufferRenderbuffer_t)(GLenum target, + GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRY *glDeleteFramebuffers_t) (GLsizei, const GLuint *); +typedef void (APIENTRY *glDeleteRenderbuffers_t) (GLsizei, const GLuint *); +typedef const GLubyte *(APIENTRY *glGetStringi_t) (GLenum, GLuint); +typedef void (APIENTRY *glGenSamplers_t) (GLsizei count, GLuint *samplers); +typedef void (APIENTRY *glDeleteSamplers_t) + (GLsizei count, const GLuint * samplers); +typedef void (APIENTRY *glBindSampler_t) (GLuint unit, GLuint sampler); +typedef void (APIENTRY *glSamplerParameteri_t) + (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRY *glDebugMessageControl_t) (GLenum source, GLenum type, + GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); +typedef void (APIENTRY *glFrameTerminator_t) (void); +typedef void (APIENTRY *glLabelObject_t) (GLenum type, GLuint object, + GLsizei length, const GLchar *label); +typedef void (APIENTRY *glGetObjectLabel_t) (GLenum type, GLuint object, + GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRY *glInsertEventMarker_t) + (GLsizei length, const char *marker); +typedef void (APIENTRY *glPushGroupMarker_t) + (GLsizei length, const char *marker); +typedef void (APIENTRY *glPopGroupMarker_t) (void); +typedef void (APIENTRY *glGenVertexArrays_t) (GLsizei n, GLuint *arrays); +typedef void (APIENTRY *glBindVertexArray_t) (GLuint array); +typedef void (APIENTRY *glDeleteVertexArrays_t) (GLsizei n, GLuint *arrays); +typedef void (APIENTRY *glVertexAttribPointer_t) (GLuint index, GLint size, + GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRY *glEnableVertexAttribArray_t) (GLuint index); +typedef void (APIENTRY *glDisableVertexAttribArray_t) (GLuint index); +typedef void (APIENTRY *glGenBuffers_t) (GLsizei n, GLuint *buffers); +typedef void (APIENTRY *glDeleteBuffers_t) (GLsizei n, GLuint *buffers); +typedef void (APIENTRY *glBindBuffer_t) (GLenum target, GLuint buffer); +typedef void (APIENTRY *glBufferData_t) (GLenum target, GLsizeiptr size, + const GLvoid *data, GLenum usage); +typedef void (APIENTRY *glCreateShader_t) (GLenum shaderType); +typedef void (APIENTRY *glDeleteShader_t) (GLenum shader); +typedef void (APIENTRY *glGetShaderiv_t) (GLuint shader, + GLenum pname, GLint *params); +typedef void (APIENTRY *glGetShaderInfoLog_t) (GLuint shader, + GLsizei maxLength, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRY *glGetShaderSource_t) (GLuint shader, + GLsizei bufSize, GLsizei *length, GLchar *source); +typedef void (APIENTRY *glShaderSource_t) (GLuint shader, + GLsizei count, const GLchar **string, const GLint *length); +typedef void (APIENTRY *glCompileShader_t) (GLuint shader); +typedef void (APIENTRY *glLinkProgram_t) (GLuint program); +typedef void (APIENTRY *glDeleteProgram_t) (GLuint program); +typedef GLuint (APIENTRY *glCreateProgram_t) (void); +typedef void (APIENTRY *glAttachShader_t) (GLuint program, GLuint shader); +typedef void (APIENTRY *glDetachShader_t) (GLuint program, GLuint shader); +typedef void (APIENTRY *glGetAttachedShaders_t) (GLuint program, + GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef void (APIENTRY *glGetUniformLocation_t) (GLuint program, + const GLchar *name); +typedef void (APIENTRY *glGetActiveUniform_t) (GLuint program, GLuint index, + GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRY *glGetProgramiv_t) (GLuint program, + GLenum pname, GLint *params); +typedef GLint (APIENTRY *glBindFragDataLocation_t) (GLuint program, + GLuint colorNumber, const char *name); +typedef void (APIENTRY *glUseProgram_t) (GLuint program); +typedef void (APIENTRY *glValidateProgram_t) (GLuint program); +typedef GLint (APIENTRY *glGetAttribLocation_t) (GLuint program, + const GLchar *name); +typedef void (APIENTRY *glUniform1f_t) (GLint location, GLfloat v0); +typedef void (APIENTRY *glUniform2f_t) (GLint location, + GLfloat v0, GLfloat v1); +typedef void (APIENTRY *glUniform3f_t) (GLint location, + GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRY *glUniform4f_t) (GLint location, + GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + +// callback +typedef void (APIENTRY *GLDEBUGPROC_t) (GLenum source, GLenum type, GLuint id, + GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam); + +typedef void (APIENTRY *glDebugMessageCallback_t) (GLDEBUGPROC_t callback, + const void *userParam); + + +#ifdef WIN32 +typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc); +#else +#define CALLBACK +#endif + +#endif // USE_OPENGL +#endif // RENDER_MGLTYPES_H |