From 4a781737c1da77015df4547f64f2f88966816343 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 12 Dec 2015 01:18:46 +0100 Subject: OPENGL: Resolve OpenGL functions on run-time. Formerly we relied on static linkage. However, in the presense of modern OpenGL (ES) implementations it is not easily identifable which library to link against. For example, on Linux amd64 with nVidia drivers and SDL2 setup to create a GLES 1.1 context one would need to link against libGL.so. However, traditionally GLES 1.1 required to link against libGLESv1_CM.so. To prevent a huge mess we simply resolve the OpenGL functions on run-time now and stop linking against a static library (in most cases). GLES support needs to be enabled manually on configure time for now. Tizen changes have NOT been tested. --- backends/graphics/opengl/opengl-func.h | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 backends/graphics/opengl/opengl-func.h (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h new file mode 100644 index 0000000000..75bc0b4e81 --- /dev/null +++ b/backends/graphics/opengl/opengl-func.h @@ -0,0 +1,97 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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 (at your option) 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* This file is based on Mesa 3-D's gl.h and GLES/gl.h from Khronos Registry. + * + * Mesa 3-D's gl.h file is distributed under the following license: + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * + * GLES/gl.h from Khronos Registry is distributed under the following license: + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* + * This file is a template file to be used inside specific locations in the + * OpenGL graphics code. It is not to be included otherwise. It intentionally + * does not contain include guards because it can be required to include it + * multiple times in a source file. + * + * Functions are defined by two different user supplied macros: + * GL_FUNC_DEF: Define a (builtin) OpenGL (ES) function. + * GL_EXT_FUNC_DEF: Define an OpenGL (ES) extension function. + */ + +GL_FUNC_DEF(void, glEnable, (GLenum cap)); +GL_FUNC_DEF(void, glDisable, (GLenum cap)); +GL_FUNC_DEF(void, glClear, (GLbitfield mask)); +GL_FUNC_DEF(void, glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)); +GL_FUNC_DEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)); +GL_FUNC_DEF(void, glMatrixMode, (GLenum mode)); +GL_FUNC_DEF(void, glLoadIdentity, ()); +#ifdef USE_GLES +GL_FUNC_DEF(void, glOrthof, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)); +#else +GL_FUNC_DEF(void, glOrtho, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)); +#endif +GL_FUNC_DEF(void, glShadeModel, (GLenum mode)); +GL_FUNC_DEF(void, glHint, (GLenum target, GLenum mode)); +GL_FUNC_DEF(void, glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)); +GL_FUNC_DEF(void, glBlendFunc, (GLenum sfactor, GLenum dfactor)); +GL_FUNC_DEF(void, glEnableClientState, (GLenum array)); +GL_FUNC_DEF(void, glPixelStorei, (GLenum pname, GLint param)); +GL_FUNC_DEF(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height)); +GL_FUNC_DEF(void, glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)); +GL_FUNC_DEF(void, glGetIntegerv, (GLenum pname, GLint *params)); +GL_FUNC_DEF(void, glDeleteTextures, (GLsizei n, const GLuint *textures)); +GL_FUNC_DEF(void, glGenTextures, (GLsizei n, GLuint *textures)); +GL_FUNC_DEF(void, glBindTexture, (GLenum target, GLuint texture)); +GL_FUNC_DEF(void, glTexParameteri, (GLenum target, GLenum pname, GLint param)); +GL_FUNC_DEF(void, glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)); +GL_FUNC_DEF(void, glTexCoordPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)); +GL_FUNC_DEF(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)); +GL_FUNC_DEF(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)); +GL_FUNC_DEF(void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)); +GL_FUNC_DEF(const GLubyte *, glGetString, (GLenum name)); +GL_FUNC_DEF(GLenum, glGetError, ()); -- cgit v1.2.3 From d6d3e17d53754acedce0b1706e73f929d29b5eb8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 12 Dec 2015 22:08:33 +0100 Subject: OPENGL: Allow runtime specification of OpenGL mode. Formerly, we required that the OpenGL mode was fixed at compile time. Now we allow the code to work with whatever it is given at runtime. It is still possible to force a context type on compile time. --- backends/graphics/opengl/opengl-func.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index 75bc0b4e81..0ff39c845a 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -70,9 +70,10 @@ GL_FUNC_DEF(void, glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat GL_FUNC_DEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)); GL_FUNC_DEF(void, glMatrixMode, (GLenum mode)); GL_FUNC_DEF(void, glLoadIdentity, ()); -#ifdef USE_GLES +#if !USE_FORCED_GL GL_FUNC_DEF(void, glOrthof, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)); -#else +#endif +#if !USE_FORCED_GLES GL_FUNC_DEF(void, glOrtho, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)); #endif GL_FUNC_DEF(void, glShadeModel, (GLenum mode)); -- cgit v1.2.3 From c5ce812711c68ea546926f243b9f6f0ece8ca736 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 19 Dec 2015 18:06:10 +0100 Subject: OPENGL: Simplify orthogonal projection setup. --- backends/graphics/opengl/opengl-func.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index 0ff39c845a..d13dece1ea 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -70,12 +70,7 @@ GL_FUNC_DEF(void, glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat GL_FUNC_DEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)); GL_FUNC_DEF(void, glMatrixMode, (GLenum mode)); GL_FUNC_DEF(void, glLoadIdentity, ()); -#if !USE_FORCED_GL -GL_FUNC_DEF(void, glOrthof, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)); -#endif -#if !USE_FORCED_GLES -GL_FUNC_DEF(void, glOrtho, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)); -#endif +GL_FUNC_DEF(void, glLoadMatrixf, (const GLfloat *m)); GL_FUNC_DEF(void, glShadeModel, (GLenum mode)); GL_FUNC_DEF(void, glHint, (GLenum target, GLenum mode)); GL_FUNC_DEF(void, glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)); -- cgit v1.2.3 From fe88375ff376cbb0d940c96ac6ec1667be4acab0 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Dec 2015 05:42:54 +0100 Subject: OPENGL: Support GLES2 contexts. --- backends/graphics/opengl/opengl-func.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index d13dece1ea..633385a4d0 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -91,3 +91,28 @@ GL_FUNC_DEF(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)); GL_FUNC_DEF(void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)); GL_FUNC_DEF(const GLubyte *, glGetString, (GLenum name)); GL_FUNC_DEF(GLenum, glGetError, ()); + +#if !USE_FORCED_GL && !USE_FORCED_GLES +GL_FUNC_DEF(void, glVertexAttrib4f, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); +GL_FUNC_DEF(void, glVertexAttribPointer, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)); +GL_FUNC_DEF(void, glUniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)); +GL_FUNC_DEF(void, glUniform1i, (GLint location, GLint v0)); +GL_FUNC_DEF(void, glDeleteProgram, (GLuint program)); +GL_FUNC_DEF(void, glDeleteShader, (GLuint shader)); +GL_FUNC_DEF(GLuint, glCreateProgram, ()); +GL_FUNC_DEF(void, glAttachShader, (GLuint program, GLuint shader)); +GL_FUNC_DEF(void, glBindAttribLocation, (GLuint program, GLuint index, const GLchar *name)); +GL_FUNC_DEF(void, glLinkProgram, (GLuint program)); +GL_FUNC_DEF(void, glDetachShader, (GLuint program, GLuint shader)); +GL_FUNC_DEF(void, glGetProgramiv, (GLuint program, GLenum pname, GLint *params)); +GL_FUNC_DEF(void, glGetProgramInfoLog, (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); +GL_FUNC_DEF(GLint, glGetUniformLocation, (GLuint program, const GLchar *name)); +GL_FUNC_DEF(void, glUseProgram, (GLuint program)); +GL_FUNC_DEF(GLuint, glCreateShader, (GLenum type)); +GL_FUNC_DEF(void, glShaderSource, (GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length)); +GL_FUNC_DEF(void, glCompileShader, (GLuint shader)); +GL_FUNC_DEF(void, glGetShaderiv, (GLuint shader, GLenum pname, GLint *params)); +GL_FUNC_DEF(void, glGetShaderInfoLog, (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); +GL_FUNC_DEF(void, glEnableVertexAttribArray, (GLuint index)); +GL_FUNC_DEF(void, glActiveTexture, (GLenum texture)); +#endif -- cgit v1.2.3 From fee1aa550203c3f46ff19afbe19a7baa4771a5cd Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Dec 2015 09:30:11 +0100 Subject: OPENGL: Add support for shaders with GL contexts. --- backends/graphics/opengl/opengl-func.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index 633385a4d0..d022d00b30 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -116,3 +116,24 @@ GL_FUNC_DEF(void, glGetShaderInfoLog, (GLuint shader, GLsizei bufSize, GLsizei * GL_FUNC_DEF(void, glEnableVertexAttribArray, (GLuint index)); GL_FUNC_DEF(void, glActiveTexture, (GLenum texture)); #endif + +#if !USE_FORCED_GLES && !USE_FORCED_GLES2 +GL_EXT_FUNC_DEF(void, glDeleteObjectARB, (GLhandleARB obj)); +GL_EXT_FUNC_DEF(GLhandleARB, glCreateProgramObjectARB, ()); +GL_EXT_FUNC_DEF(void, glAttachObjectARB, (GLhandleARB containerObj, GLhandleARB obj)); +GL_EXT_FUNC_DEF(void, glBindAttribLocationARB, (GLhandleARB programObj, GLuint index, const GLcharARB *name)); +GL_EXT_FUNC_DEF(void, glLinkProgramARB, (GLhandleARB programObj)); +GL_EXT_FUNC_DEF(void, glDetachObjectARB, (GLhandleARB containerObj, GLhandleARB attachedObj)); +GL_EXT_FUNC_DEF(void, glGetObjectParameterivARB, (GLhandleARB obj, GLenum pname, GLint *params)); +GL_EXT_FUNC_DEF(GLint, glGetUniformLocationARB, (GLhandleARB programObj, const GLcharARB *name)); +GL_EXT_FUNC_DEF(void, glGetInfoLogARB, (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog)); +GL_EXT_FUNC_DEF(void, glUseProgramObjectARB, (GLhandleARB programObj)); +GL_EXT_FUNC_DEF(void, glUniformMatrix4fvARB, (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)); +GL_EXT_FUNC_DEF(void, glUniform1iARB, (GLint location, GLint v0)); +GL_EXT_FUNC_DEF(GLhandleARB, glCreateShaderObjectARB, (GLenum shaderType)); +GL_EXT_FUNC_DEF(void, glShaderSourceARB, (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length)); +GL_EXT_FUNC_DEF(void, glCompileShaderARB, (GLhandleARB shaderObj)); +GL_EXT_FUNC_DEF(void, glVertexAttribPointerARB, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)); +GL_EXT_FUNC_DEF(void, glVertexAttrib4fARB, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); +GL_EXT_FUNC_DEF(void, glEnableVertexAttribArrayARB, (GLuint index)); +#endif -- cgit v1.2.3 From 1802c939a1a46d89df05cae5e30e2014646e30fa Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Dec 2015 04:45:52 +0100 Subject: OPENGL: Slight simplifcation for opengl-func.h usage. --- backends/graphics/opengl/opengl-func.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index d022d00b30..f870214754 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -63,6 +63,11 @@ * GL_EXT_FUNC_DEF: Define an OpenGL (ES) extension function. */ +#if !defined(GL_EXT_FUNC_DEF) +#define GL_EXT_FUNC_DEF(ret, name, param) GL_FUNC_DEF(ret, name, param) +#define DEFINED_GL_EXT_FUNC_DEF +#endif + GL_FUNC_DEF(void, glEnable, (GLenum cap)); GL_FUNC_DEF(void, glDisable, (GLenum cap)); GL_FUNC_DEF(void, glClear, (GLbitfield mask)); @@ -137,3 +142,8 @@ GL_EXT_FUNC_DEF(void, glVertexAttribPointerARB, (GLuint index, GLint size, GLenu GL_EXT_FUNC_DEF(void, glVertexAttrib4fARB, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); GL_EXT_FUNC_DEF(void, glEnableVertexAttribArrayARB, (GLuint index)); #endif + +#ifdef DEFINED_GL_EXT_FUNC_DEF +#undef DEFINED_GL_EXT_FUNC_DEF +#undef GL_EXT_FUNC_DEF +#endif -- cgit v1.2.3 From fc52f730506422ac99e44cd74f229e6a0c5c2121 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Dec 2015 05:47:29 +0100 Subject: OPENGL: Slightly cleanup programmable pipeline handling. --- backends/graphics/opengl/opengl-func.h | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index f870214754..c85d936497 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -58,11 +58,18 @@ * does not contain include guards because it can be required to include it * multiple times in a source file. * - * Functions are defined by two different user supplied macros: - * GL_FUNC_DEF: Define a (builtin) OpenGL (ES) function. + * Functions are defined by three different user supplied macros: + * GL_FUNC_DEF: Define a (builtin) OpenGL (ES) function. + * GL_FUNC_2_DEF: Define a OpenGL (ES) 2.0 function which can be provided by + * extensions in OpenGL 1.x contexts. * GL_EXT_FUNC_DEF: Define an OpenGL (ES) extension function. */ +#if !defined(GL_FUNC_2_DEF) +#define GL_FUNC_2_DEF(ret, name, extName, param) GL_FUNC_DEF(ret, name, param) +#define DEFINED_GL_FUNC_2_DEF +#endif + #if !defined(GL_EXT_FUNC_DEF) #define GL_EXT_FUNC_DEF(ret, name, param) GL_FUNC_DEF(ret, name, param) #define DEFINED_GL_EXT_FUNC_DEF @@ -97,11 +104,15 @@ GL_FUNC_DEF(void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, G GL_FUNC_DEF(const GLubyte *, glGetString, (GLenum name)); GL_FUNC_DEF(GLenum, glGetError, ()); +#if !USE_FORCED_GLES +GL_FUNC_2_DEF(void, glEnableVertexAttribArray, glEnableVertexAttribArrayARB, (GLuint index)); +GL_FUNC_2_DEF(void, glUniform1i, glUniform1iARB, (GLint location, GLint v0)); +GL_FUNC_2_DEF(void, glUniformMatrix4fv, glUniformMatrix4fvARB, (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)); +GL_FUNC_2_DEF(void, glVertexAttrib4f, glVertexAttrib4fARB, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); +GL_FUNC_2_DEF(void, glVertexAttribPointer, glVertexAttribPointerARB, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)); +#endif + #if !USE_FORCED_GL && !USE_FORCED_GLES -GL_FUNC_DEF(void, glVertexAttrib4f, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); -GL_FUNC_DEF(void, glVertexAttribPointer, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)); -GL_FUNC_DEF(void, glUniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)); -GL_FUNC_DEF(void, glUniform1i, (GLint location, GLint v0)); GL_FUNC_DEF(void, glDeleteProgram, (GLuint program)); GL_FUNC_DEF(void, glDeleteShader, (GLuint shader)); GL_FUNC_DEF(GLuint, glCreateProgram, ()); @@ -118,7 +129,6 @@ GL_FUNC_DEF(void, glShaderSource, (GLuint shader, GLsizei count, const GLchar *c GL_FUNC_DEF(void, glCompileShader, (GLuint shader)); GL_FUNC_DEF(void, glGetShaderiv, (GLuint shader, GLenum pname, GLint *params)); GL_FUNC_DEF(void, glGetShaderInfoLog, (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); -GL_FUNC_DEF(void, glEnableVertexAttribArray, (GLuint index)); GL_FUNC_DEF(void, glActiveTexture, (GLenum texture)); #endif @@ -133,17 +143,17 @@ GL_EXT_FUNC_DEF(void, glGetObjectParameterivARB, (GLhandleARB obj, GLenum pname, GL_EXT_FUNC_DEF(GLint, glGetUniformLocationARB, (GLhandleARB programObj, const GLcharARB *name)); GL_EXT_FUNC_DEF(void, glGetInfoLogARB, (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog)); GL_EXT_FUNC_DEF(void, glUseProgramObjectARB, (GLhandleARB programObj)); -GL_EXT_FUNC_DEF(void, glUniformMatrix4fvARB, (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)); -GL_EXT_FUNC_DEF(void, glUniform1iARB, (GLint location, GLint v0)); GL_EXT_FUNC_DEF(GLhandleARB, glCreateShaderObjectARB, (GLenum shaderType)); GL_EXT_FUNC_DEF(void, glShaderSourceARB, (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length)); GL_EXT_FUNC_DEF(void, glCompileShaderARB, (GLhandleARB shaderObj)); -GL_EXT_FUNC_DEF(void, glVertexAttribPointerARB, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)); -GL_EXT_FUNC_DEF(void, glVertexAttrib4fARB, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); -GL_EXT_FUNC_DEF(void, glEnableVertexAttribArrayARB, (GLuint index)); #endif #ifdef DEFINED_GL_EXT_FUNC_DEF #undef DEFINED_GL_EXT_FUNC_DEF #undef GL_EXT_FUNC_DEF #endif + +#ifdef DEFINED_GL_FUNC_2_DEF +#undef DEFINED_GL_FUNC_2_DEF +#undef GL_FUNC_2_DEF +#endif -- cgit v1.2.3 From 8a3eecb73a9eb5d885e3585835db6bee738c1de5 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Dec 2015 06:35:13 +0100 Subject: OPENGL: Unify shader implementation for GL and GLES2. --- backends/graphics/opengl/opengl-func.h | 50 ++++++++++++---------------------- 1 file changed, 18 insertions(+), 32 deletions(-) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index c85d936497..fb0877913e 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -110,44 +110,30 @@ GL_FUNC_2_DEF(void, glUniform1i, glUniform1iARB, (GLint location, GLint v0)); GL_FUNC_2_DEF(void, glUniformMatrix4fv, glUniformMatrix4fvARB, (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)); GL_FUNC_2_DEF(void, glVertexAttrib4f, glVertexAttrib4fARB, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); GL_FUNC_2_DEF(void, glVertexAttribPointer, glVertexAttribPointerARB, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)); + +GL_FUNC_2_DEF(GLprogram, glCreateProgram, glCreateProgramObjectARB, ()); +GL_FUNC_2_DEF(void, glDeleteProgram, glDeleteObjectARB, (GLprogram program)); +GL_FUNC_2_DEF(void, glAttachShader, glAttachObjectARB, (GLprogram program, GLshader shader)); +GL_FUNC_2_DEF(void, glDetachShader, glDetachObjectARB, (GLprogram program, GLshader shader)); +GL_FUNC_2_DEF(void, glLinkProgram, glLinkProgramARB, (GLprogram program)); +GL_FUNC_2_DEF(void, glUseProgram, glUseProgramObjectARB, (GLprogram program)); +GL_FUNC_2_DEF(void, glGetProgramiv, glGetObjectParameterivARB, (GLprogram program, GLenum pname, GLint *params)); +GL_FUNC_2_DEF(void, glGetProgramInfoLog, glGetInfoLogARB, (GLprogram program, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); +GL_FUNC_2_DEF(void, glBindAttribLocation, glBindAttribLocationARB, (GLprogram program, GLuint index, const GLchar *name)); +GL_FUNC_2_DEF(GLint, glGetUniformLocation, glGetUniformLocationARB, (GLprogram program, const GLchar *name)); + +GL_FUNC_2_DEF(GLshader, glCreateShader, glCreateShaderObjectARB, (GLenum type)); +GL_FUNC_2_DEF(void, glDeleteShader, glDeleteObjectARB, (GLshader shader)); +GL_FUNC_2_DEF(void, glGetShaderiv, glGetObjectParameterivARB, (GLshader shader, GLenum pname, GLint *params)); +GL_FUNC_2_DEF(void, glGetShaderInfoLog, glGetInfoLogARB, (GLshader shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); +GL_FUNC_2_DEF(void, glShaderSource, glShaderSourceARB, (GLshader shader, GLsizei count, const GLchar *const *string, const GLint *length)); +GL_FUNC_2_DEF(void, glCompileShader, glCompileShaderARB, (GLshader shader)); #endif #if !USE_FORCED_GL && !USE_FORCED_GLES -GL_FUNC_DEF(void, glDeleteProgram, (GLuint program)); -GL_FUNC_DEF(void, glDeleteShader, (GLuint shader)); -GL_FUNC_DEF(GLuint, glCreateProgram, ()); -GL_FUNC_DEF(void, glAttachShader, (GLuint program, GLuint shader)); -GL_FUNC_DEF(void, glBindAttribLocation, (GLuint program, GLuint index, const GLchar *name)); -GL_FUNC_DEF(void, glLinkProgram, (GLuint program)); -GL_FUNC_DEF(void, glDetachShader, (GLuint program, GLuint shader)); -GL_FUNC_DEF(void, glGetProgramiv, (GLuint program, GLenum pname, GLint *params)); -GL_FUNC_DEF(void, glGetProgramInfoLog, (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); -GL_FUNC_DEF(GLint, glGetUniformLocation, (GLuint program, const GLchar *name)); -GL_FUNC_DEF(void, glUseProgram, (GLuint program)); -GL_FUNC_DEF(GLuint, glCreateShader, (GLenum type)); -GL_FUNC_DEF(void, glShaderSource, (GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length)); -GL_FUNC_DEF(void, glCompileShader, (GLuint shader)); -GL_FUNC_DEF(void, glGetShaderiv, (GLuint shader, GLenum pname, GLint *params)); -GL_FUNC_DEF(void, glGetShaderInfoLog, (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); GL_FUNC_DEF(void, glActiveTexture, (GLenum texture)); #endif -#if !USE_FORCED_GLES && !USE_FORCED_GLES2 -GL_EXT_FUNC_DEF(void, glDeleteObjectARB, (GLhandleARB obj)); -GL_EXT_FUNC_DEF(GLhandleARB, glCreateProgramObjectARB, ()); -GL_EXT_FUNC_DEF(void, glAttachObjectARB, (GLhandleARB containerObj, GLhandleARB obj)); -GL_EXT_FUNC_DEF(void, glBindAttribLocationARB, (GLhandleARB programObj, GLuint index, const GLcharARB *name)); -GL_EXT_FUNC_DEF(void, glLinkProgramARB, (GLhandleARB programObj)); -GL_EXT_FUNC_DEF(void, glDetachObjectARB, (GLhandleARB containerObj, GLhandleARB attachedObj)); -GL_EXT_FUNC_DEF(void, glGetObjectParameterivARB, (GLhandleARB obj, GLenum pname, GLint *params)); -GL_EXT_FUNC_DEF(GLint, glGetUniformLocationARB, (GLhandleARB programObj, const GLcharARB *name)); -GL_EXT_FUNC_DEF(void, glGetInfoLogARB, (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog)); -GL_EXT_FUNC_DEF(void, glUseProgramObjectARB, (GLhandleARB programObj)); -GL_EXT_FUNC_DEF(GLhandleARB, glCreateShaderObjectARB, (GLenum shaderType)); -GL_EXT_FUNC_DEF(void, glShaderSourceARB, (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length)); -GL_EXT_FUNC_DEF(void, glCompileShaderARB, (GLhandleARB shaderObj)); -#endif - #ifdef DEFINED_GL_EXT_FUNC_DEF #undef DEFINED_GL_EXT_FUNC_DEF #undef GL_EXT_FUNC_DEF -- cgit v1.2.3 From e66e9e44d358b0cc90d128c31e695a8ace4177fa Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 2 Jan 2016 14:09:41 +0100 Subject: OPENGL: Accelerate palette lookups with shaders. This currently is limited to GL contexts. --- backends/graphics/opengl/opengl-func.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index fb0877913e..763d5e9143 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -77,6 +77,7 @@ GL_FUNC_DEF(void, glEnable, (GLenum cap)); GL_FUNC_DEF(void, glDisable, (GLenum cap)); +GL_FUNC_DEF(GLboolean, glIsEnabled, (GLenum cap)); GL_FUNC_DEF(void, glClear, (GLbitfield mask)); GL_FUNC_DEF(void, glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)); GL_FUNC_DEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)); @@ -128,10 +129,16 @@ GL_FUNC_2_DEF(void, glGetShaderiv, glGetObjectParameterivARB, (GLshader shader, GL_FUNC_2_DEF(void, glGetShaderInfoLog, glGetInfoLogARB, (GLshader shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); GL_FUNC_2_DEF(void, glShaderSource, glShaderSourceARB, (GLshader shader, GLsizei count, const GLchar *const *string, const GLint *length)); GL_FUNC_2_DEF(void, glCompileShader, glCompileShaderARB, (GLshader shader)); + +#if !USE_FORCED_GLES2 +GL_FUNC_2_DEF(void, glBindFramebuffer, glBindFramebufferEXT, (GLenum target, GLuint renderbuffer)); +GL_FUNC_2_DEF(void, glDeleteFramebuffers, glDeleteFramebuffersEXT, (GLsizei n, const GLuint *framebuffers)); +GL_FUNC_2_DEF(void, glGenFramebuffers, glGenFramebuffersEXT, (GLsizei n, GLuint *renderbuffers)); +GL_FUNC_2_DEF(void, glFramebufferTexture2D, glFramebufferTexture2DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)); +GL_FUNC_2_DEF(GLenum, glCheckFramebufferStatus, glCheckFramebufferStatusEXT, (GLenum target)); #endif -#if !USE_FORCED_GL && !USE_FORCED_GLES -GL_FUNC_DEF(void, glActiveTexture, (GLenum texture)); +GL_FUNC_2_DEF(void, glActiveTexture, glActiveTextureARB, (GLenum texture)); #endif #ifdef DEFINED_GL_EXT_FUNC_DEF -- cgit v1.2.3 From 08553a09cfa2110d56b200bf6c69d01d5adbc6bb Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 3 Jan 2016 14:06:02 +0100 Subject: OPENGL: Support GLSL based CLUT8 look up for GLES2+. --- backends/graphics/opengl/opengl-func.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index 763d5e9143..554ac3c6ff 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -130,13 +130,11 @@ GL_FUNC_2_DEF(void, glGetShaderInfoLog, glGetInfoLogARB, (GLshader shader, GLsiz GL_FUNC_2_DEF(void, glShaderSource, glShaderSourceARB, (GLshader shader, GLsizei count, const GLchar *const *string, const GLint *length)); GL_FUNC_2_DEF(void, glCompileShader, glCompileShaderARB, (GLshader shader)); -#if !USE_FORCED_GLES2 GL_FUNC_2_DEF(void, glBindFramebuffer, glBindFramebufferEXT, (GLenum target, GLuint renderbuffer)); GL_FUNC_2_DEF(void, glDeleteFramebuffers, glDeleteFramebuffersEXT, (GLsizei n, const GLuint *framebuffers)); GL_FUNC_2_DEF(void, glGenFramebuffers, glGenFramebuffersEXT, (GLsizei n, GLuint *renderbuffers)); GL_FUNC_2_DEF(void, glFramebufferTexture2D, glFramebufferTexture2DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)); GL_FUNC_2_DEF(GLenum, glCheckFramebufferStatus, glCheckFramebufferStatusEXT, (GLenum target)); -#endif GL_FUNC_2_DEF(void, glActiveTexture, glActiveTextureARB, (GLenum texture)); #endif -- cgit v1.2.3 From baca885cfce10acaa7a9892133aaa5b82c7183f7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 2 Mar 2016 15:16:05 +0100 Subject: OPENGL: Let Shader store the uniform state. --- backends/graphics/opengl/opengl-func.h | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index 554ac3c6ff..ad7c572ca9 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -108,6 +108,7 @@ GL_FUNC_DEF(GLenum, glGetError, ()); #if !USE_FORCED_GLES GL_FUNC_2_DEF(void, glEnableVertexAttribArray, glEnableVertexAttribArrayARB, (GLuint index)); GL_FUNC_2_DEF(void, glUniform1i, glUniform1iARB, (GLint location, GLint v0)); +GL_FUNC_2_DEF(void, glUniform1f, glUniform1fARB, (GLint location, GLfloat v0)); GL_FUNC_2_DEF(void, glUniformMatrix4fv, glUniformMatrix4fvARB, (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)); GL_FUNC_2_DEF(void, glVertexAttrib4f, glVertexAttrib4fARB, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); GL_FUNC_2_DEF(void, glVertexAttribPointer, glVertexAttribPointerARB, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)); -- cgit v1.2.3 From 39100b613272523c2e36be213cc827857a08f824 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 4 Mar 2016 00:14:22 +0100 Subject: OPENGL: Do not hardcode any uniform/attribute handling in Shader. --- backends/graphics/opengl/opengl-func.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends/graphics/opengl/opengl-func.h') diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h index ad7c572ca9..4e44c13d0f 100644 --- a/backends/graphics/opengl/opengl-func.h +++ b/backends/graphics/opengl/opengl-func.h @@ -107,6 +107,7 @@ GL_FUNC_DEF(GLenum, glGetError, ()); #if !USE_FORCED_GLES GL_FUNC_2_DEF(void, glEnableVertexAttribArray, glEnableVertexAttribArrayARB, (GLuint index)); +GL_FUNC_2_DEF(void, glDisableVertexAttribArray, glDisableVertexAttribArrayARB, (GLuint index)); GL_FUNC_2_DEF(void, glUniform1i, glUniform1iARB, (GLint location, GLint v0)); GL_FUNC_2_DEF(void, glUniform1f, glUniform1fARB, (GLint location, GLfloat v0)); GL_FUNC_2_DEF(void, glUniformMatrix4fv, glUniformMatrix4fvARB, (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)); @@ -122,6 +123,7 @@ GL_FUNC_2_DEF(void, glUseProgram, glUseProgramObjectARB, (GLprogram program)); GL_FUNC_2_DEF(void, glGetProgramiv, glGetObjectParameterivARB, (GLprogram program, GLenum pname, GLint *params)); GL_FUNC_2_DEF(void, glGetProgramInfoLog, glGetInfoLogARB, (GLprogram program, GLsizei bufSize, GLsizei *length, GLchar *infoLog)); GL_FUNC_2_DEF(void, glBindAttribLocation, glBindAttribLocationARB, (GLprogram program, GLuint index, const GLchar *name)); +GL_FUNC_2_DEF(GLint, glGetAttribLocation, glGetAttribLocationARB, (GLprogram program, const GLchar *name)); GL_FUNC_2_DEF(GLint, glGetUniformLocation, glGetUniformLocationARB, (GLprogram program, const GLchar *name)); GL_FUNC_2_DEF(GLshader, glCreateShader, glCreateShaderObjectARB, (GLenum type)); -- cgit v1.2.3