1 /** @file sys_opengl.h 2 * 3 * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 4 * @authors Copyright © 2007-2013 Daniel Swanson <danij@dengine.net> 5 * @authors Copyright © 2006 Jamie Jones <jamie_jones_au@yahoo.com.au> 6 * 7 * @par License 8 * GPL: http://www.gnu.org/licenses/gpl.html 9 * 10 * <small>This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by the 12 * Free Software Foundation; either version 2 of the License, or (at your 13 * option) any later version. This program is distributed in the hope that it 14 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 * Public License for more details. You should have received a copy of the GNU 17 * General Public License along with this program; if not, see: 18 * http://www.gnu.org/licenses</small> 19 */ 20 21 /** 22 * OpenGL interface, low-level. 23 * 24 * Get OpenGL header files from: 25 * http://oss.sgi.com/projects/ogl-sample/ 26 */ 27 28 #ifndef LIBDENG_SYSTEM_OPENGL_H 29 #define LIBDENG_SYSTEM_OPENGL_H 30 31 #ifdef __SERVER__ 32 # define GL_CLAMP_TO_EDGE 0 33 #endif 34 35 #ifdef __CLIENT__ 36 37 #ifdef WIN32 38 # include <de/graphics/opengl.h> 39 # define GL_CALL __stdcall 40 #endif 41 42 #if defined(UNIX) && !defined(MACOSX) 43 # include <de/graphics/opengl.h> 44 # define GL_CALL 45 #endif 46 47 #if defined(UNIX) && defined(MACOSX) 48 # define GL_GLEXT_PROTOTYPES 49 # include <de/graphics/opengl.h> 50 # include <OpenGL/glext.h> 51 # include <OpenGL/OpenGL.h> 52 # define GL_CALL 53 #endif 54 55 #endif // __CLIENT__ 56 57 #ifndef GL_NV_texture_env_combine4 58 # define GL_NV_texture_env_combine4 1 59 # define GL_COMBINE4_NV 0x8503 60 # define GL_SOURCE3_RGB_NV 0x8583 61 # define GL_SOURCE3_ALPHA_NV 0x858B 62 # define GL_OPERAND3_RGB_NV 0x8593 63 # define GL_OPERAND3_ALPHA_NV 0x859B 64 #endif 65 66 #include <string.h> 67 68 #ifdef __CLIENT__ 69 # include "gl_deferredapi.h" 70 # include "ui/clientwindow.h" 71 #endif 72 73 /** 74 * Configure available features 75 * \todo Move out of this header. 76 */ 77 #define USE_TEXTURE_COMPRESSION_S3 1 78 79 /** 80 * High-level GL state information. 81 */ 82 typedef struct gl_state_s { 83 /// Current state: 84 float currentLineWidth; 85 float currentPointSize; 86 87 /// Feature (abstract) availability bits: 88 /// Vendor and implementation agnostic. 89 struct { 90 uint texCompression : 1; 91 uint texFilterAniso : 1; 92 } features; 93 } gl_state_t; 94 95 typedef enum arraytype_e { 96 AR_VERTEX, 97 AR_COLOR, 98 AR_TEXCOORD0, 99 AR_TEXCOORD1, 100 AR_TEXCOORD2, 101 AR_TEXCOORD3, 102 AR_TEXCOORD4, 103 AR_TEXCOORD5, 104 AR_TEXCOORD6, 105 AR_TEXCOORD7 106 } arraytype_t; 107 108 #ifdef __cplusplus 109 extern "C" { 110 #endif 111 112 #ifdef __CLIENT__ 113 114 extern gl_state_t GL_state; 115 116 #ifndef GL_ATI_texture_env_combine3 117 #define GL_MODULATE_ADD_ATI 0x8744 118 #define GL_MODULATE_SIGNED_ADD_ATI 0x8745 119 #define GL_MODULATE_SUBTRACT_ATI 0x8746 120 #endif 121 122 #ifndef GL_ATI_texture_env_combine3 123 #define GL_ATI_texture_env_combine3 1 124 #endif 125 126 dd_bool Sys_GLPreInit(void); 127 128 /** 129 * Initializes our OpenGL interface. Called once during engine statup. 130 */ 131 dd_bool Sys_GLInitialize(void); 132 133 /** 134 * Close our OpenGL interface for good. Called once during engine shutdown. 135 */ 136 void Sys_GLShutdown(void); 137 138 /** 139 * Configure the core features of OpenGL. Extensions are not configured here. 140 */ 141 void Sys_GLConfigureDefaultState(void); 142 143 /** 144 * Echo the full list of available GL extensions to the console. 145 */ 146 void Sys_GLPrintExtensions(void); 147 148 dd_bool Sys_GLCheckErrorArgs(char const *file, int line); 149 150 #endif // __CLIENT__ 151 152 #ifdef __cplusplus 153 } // extern "C" 154 155 /** 156 * Information about the OpenGL driver and its capabilities. 157 * 158 * @return Styled text. 159 */ 160 de::String Sys_GLDescription(); 161 162 #endif 163 164 #endif /* LIBDENG_SYSTEM_OPENGL_H */ 165