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-defs.h | 219 +++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 backends/graphics/opengl/opengl-defs.h (limited to 'backends/graphics/opengl/opengl-defs.h') diff --git a/backends/graphics/opengl/opengl-defs.h b/backends/graphics/opengl/opengl-defs.h new file mode 100644 index 0000000000..4b82d7edd7 --- /dev/null +++ b/backends/graphics/opengl/opengl-defs.h @@ -0,0 +1,219 @@ +/* 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/ . + */ + +#ifndef BACKENDS_GRAPHICS_OPENGL_OPENGL_DEFS_H +#define BACKENDS_GRAPHICS_OPENGL_OPENGL_DEFS_H + +#include "common/scummsys.h" + +/* + * Datatypes + */ +typedef uint GLenum; +typedef uint8 GLboolean; +typedef uint GLbitfield; +typedef void GLvoid; +typedef int8 GLbyte; /* 1-byte signed */ +typedef int16 GLshort; /* 2-byte signed */ +typedef int32 GLint; /* 4-byte signed */ +typedef uint8 GLubyte; /* 1-byte unsigned */ +typedef uint16 GLushort; /* 2-byte unsigned */ +typedef uint32 GLuint; /* 4-byte unsigned */ +typedef int32 GLsizei; /* 4-byte signed */ +typedef float GLfloat; /* single precision float */ +typedef float GLclampf; /* single precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef double GLclampd; /* double precision float in [0,1] */ + +/* + * Constants + */ + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Scissor box */ +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 + +/* MatrixMode */ +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* EnableCap */ +#define GL_FOG 0x0B60 +#define GL_LIGHTING 0x0B50 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_ALPHA_TEST 0x0BC0 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_DEPTH_TEST 0x0B71 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_COLOR_ARRAY 0x8076 +#define GL_TEXTURE_COORD_ARRAY 0x8078 + +/* ShadingModel */ +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_FOG_HINT 0x0C54 +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* PixelFormat */ +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 + +/* PixelStoreParameter */ +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 + +/* Implementation limits */ +#define GL_MAX_TEXTURE_SIZE 0x0D33 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +#endif -- 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-defs.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'backends/graphics/opengl/opengl-defs.h') diff --git a/backends/graphics/opengl/opengl-defs.h b/backends/graphics/opengl/opengl-defs.h index 4b82d7edd7..fe79caadd4 100644 --- a/backends/graphics/opengl/opengl-defs.h +++ b/backends/graphics/opengl/opengl-defs.h @@ -75,11 +75,16 @@ typedef float GLfloat; /* single precision float */ typedef float GLclampf; /* single precision float in [0,1] */ typedef double GLdouble; /* double precision float */ typedef double GLclampd; /* double precision float in [0,1] */ +typedef char GLchar; /* * Constants */ +/* Boolean constants */ +#define GL_FALSE 0 +#define GL_TRUE 1 + /* StringName */ #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 @@ -216,4 +221,16 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_TRIANGLE_STRIP 0x0005 #define GL_TRIANGLE_FAN 0x0006 +/* Shaders */ +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 + +/* Programs */ +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_INFO_LOG_LENGTH 0x8B84 + +/* Textures */ +#define GL_TEXTURE0 0x84C0 + #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-defs.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'backends/graphics/opengl/opengl-defs.h') diff --git a/backends/graphics/opengl/opengl-defs.h b/backends/graphics/opengl/opengl-defs.h index fe79caadd4..edcf334a0b 100644 --- a/backends/graphics/opengl/opengl-defs.h +++ b/backends/graphics/opengl/opengl-defs.h @@ -76,6 +76,12 @@ typedef float GLclampf; /* single precision float in [0,1] */ typedef double GLdouble; /* double precision float */ typedef double GLclampd; /* double precision float in [0,1] */ typedef char GLchar; +typedef GLchar GLcharARB; +#if defined(__APPLE__) || defined(MACOSX) +typedef void *GLhandleARB; +#else +typedef uint GLhandleARB; +#endif /* * Constants @@ -223,13 +229,20 @@ typedef char GLchar; /* Shaders */ #define GL_FRAGMENT_SHADER 0x8B30 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 + #define GL_VERTEX_SHADER 0x8B31 +#define GL_VERTEX_SHADER_ARB 0x8B31 /* Programs */ #define GL_COMPILE_STATUS 0x8B81 #define GL_LINK_STATUS 0x8B82 #define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 + /* Textures */ #define GL_TEXTURE0 0x84C0 -- 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-defs.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'backends/graphics/opengl/opengl-defs.h') diff --git a/backends/graphics/opengl/opengl-defs.h b/backends/graphics/opengl/opengl-defs.h index edcf334a0b..5e9bcab6f1 100644 --- a/backends/graphics/opengl/opengl-defs.h +++ b/backends/graphics/opengl/opengl-defs.h @@ -77,12 +77,18 @@ typedef double GLdouble; /* double precision float */ typedef double GLclampd; /* double precision float in [0,1] */ typedef char GLchar; typedef GLchar GLcharARB; -#if defined(__APPLE__) || defined(MACOSX) +#if defined(MACOSX) typedef void *GLhandleARB; #else typedef uint GLhandleARB; #endif +// This is an addition from us to alias ARB shader object extensions to +// OpenGL (ES) 2.0 style functions. It only works when GLhandleARB and GLuint +// are type compatible. +typedef GLhandleARB GLprogram; +typedef GLhandleARB GLshader; + /* * Constants */ -- cgit v1.2.3 From 5eb0ac0c9e82b419d996784adddc5f94d1fa5be3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 27 Dec 2015 16:10:48 +0100 Subject: OPENGL: Remove (some) unused GL definitions. --- backends/graphics/opengl/opengl-defs.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'backends/graphics/opengl/opengl-defs.h') diff --git a/backends/graphics/opengl/opengl-defs.h b/backends/graphics/opengl/opengl-defs.h index 5e9bcab6f1..793955c093 100644 --- a/backends/graphics/opengl/opengl-defs.h +++ b/backends/graphics/opengl/opengl-defs.h @@ -76,7 +76,6 @@ typedef float GLclampf; /* single precision float in [0,1] */ typedef double GLdouble; /* double precision float */ typedef double GLclampd; /* double precision float in [0,1] */ typedef char GLchar; -typedef GLchar GLcharARB; #if defined(MACOSX) typedef void *GLhandleARB; #else @@ -235,20 +234,14 @@ typedef GLhandleARB GLshader; /* Shaders */ #define GL_FRAGMENT_SHADER 0x8B30 -#define GL_FRAGMENT_SHADER_ARB 0x8B30 #define GL_VERTEX_SHADER 0x8B31 -#define GL_VERTEX_SHADER_ARB 0x8B31 /* Programs */ #define GL_COMPILE_STATUS 0x8B81 #define GL_LINK_STATUS 0x8B82 #define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 - /* Textures */ #define GL_TEXTURE0 0x84C0 -- cgit v1.2.3 From db2917dde5e8aaf9514e19772b8f0f6646b18deb Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 2 Jan 2016 02:22:09 +0100 Subject: OPENGL: Fix texture format for BGR565. --- backends/graphics/opengl/opengl-defs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/graphics/opengl/opengl-defs.h') diff --git a/backends/graphics/opengl/opengl-defs.h b/backends/graphics/opengl/opengl-defs.h index 793955c093..4de73d3476 100644 --- a/backends/graphics/opengl/opengl-defs.h +++ b/backends/graphics/opengl/opengl-defs.h @@ -202,6 +202,7 @@ typedef GLhandleARB GLshader; #define GL_UNSIGNED_SHORT_5_6_5 0x8363 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 #define GL_UNSIGNED_INT_8_8_8_8 0x8035 #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -- 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-defs.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'backends/graphics/opengl/opengl-defs.h') diff --git a/backends/graphics/opengl/opengl-defs.h b/backends/graphics/opengl/opengl-defs.h index 4de73d3476..733fc2933c 100644 --- a/backends/graphics/opengl/opengl-defs.h +++ b/backends/graphics/opengl/opengl-defs.h @@ -183,6 +183,9 @@ typedef GLhandleARB GLshader; #define GL_BGR 0x80E0 #define GL_BGRA 0x80E1 +#define GL_RED 0x1903 +#define GL_R8 0x8229 + /* PixelStoreParameter */ #define GL_UNPACK_ALIGNMENT 0x0CF5 #define GL_PACK_ALIGNMENT 0x0D05 @@ -242,8 +245,18 @@ typedef GLhandleARB GLshader; #define GL_COMPILE_STATUS 0x8B81 #define GL_LINK_STATUS 0x8B82 #define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_CURRENT_PROGRAM 0x8B8D /* Textures */ #define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 + +/* GetPName */ +#define GL_VIEWPORT 0x0BA2 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 + +/* Framebuffer objects */ +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_FRAMEBUFFER 0x8D40 #endif -- cgit v1.2.3