/
sys_opengl.h
180 lines (155 loc) · 4.53 KB
/
sys_opengl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**\file sys_opengl.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2007-2011 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006 Jamie Jones <jamie_jones_au@yahoo.com.au>
*
* 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 St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/**
* OpenGL interface, low-level.
*
* Get OpenGL header files from:
* http://oss.sgi.com/projects/ogl-sample/
*/
#ifndef LIBDENG_SYSTEM_OPENGL_H
#define LIBDENG_SYSTEM_OPENGL_H
#ifdef WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <GL/gl.h>
# include <GL/wglext.h>
# include <GL/glext.h>
#endif
#ifdef UNIX
# define GL_GLEXT_PROTOTYPES
# ifdef MACOSX
# include <SDL.h>
# include <SDL_opengl.h>
# else
# include <SDL.h>
# include <SDL_opengl.h>
# endif
#endif
#include <string.h>
#include "sys_window.h"
/**
* Configure available features
* \todo Move out of this header.
*/
#define USE_TEXTURE_COMPRESSION_S3 1
/**
* High-level GL state information.
*/
typedef struct gl_state_s {
/// Global config:
boolean forceFinishBeforeSwap;
int maxTexFilterAniso;
int maxTexSize; // Logical pixels.
int maxTexUnits;
int multisampleFormat;
/// Current state:
boolean currentUseFog;
boolean currentUseTexCompression;
float currentGrayMipmapFactor;
float currentLineWidth;
float currentPointSize;
/// Feature (abstract) availability bits:
/// Vendor and implementation agnostic.
struct {
uint blendSubtract : 1;
uint elementArrays : 1;
uint genMipmap : 1;
uint multisample : 1;
uint texCompression : 1;
uint texFilterAniso : 1;
uint texNonPowTwo : 1;
uint vsync : 1;
} features;
/// Extension availability bits:
struct {
uint blendSub : 1;
uint genMipmapSGIS : 1;
uint lockArray : 1;
#ifdef USE_TEXTURE_COMPRESSION_S3
uint texCompressionS3 : 1;
#endif
uint texEnvComb : 1;
uint texEnvCombNV : 1;
uint texEnvCombATI : 1;
uint texFilterAniso : 1;
uint texNonPowTwo : 1;
#if WIN32
uint wglMultisampleARB : 1;
uint wglSwapIntervalEXT : 1;
#endif
} extensions;
} gl_state_t;
typedef enum arraytype_e {
AR_VERTEX,
AR_COLOR,
AR_TEXCOORD0,
AR_TEXCOORD1,
AR_TEXCOORD2,
AR_TEXCOORD3,
AR_TEXCOORD4,
AR_TEXCOORD5,
AR_TEXCOORD6,
AR_TEXCOORD7
} arraytype_t;
extern gl_state_t GL_state;
#ifdef WIN32
extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
extern PFNGLBLENDEQUATIONEXTPROC glBlendEquationEXT;
extern PFNGLLOCKARRAYSEXTPROC glLockArraysEXT;
extern PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT;
extern PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTexture;
extern PFNGLACTIVETEXTUREARBPROC glActiveTexture;
extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2f;
extern PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fv;
#endif
#ifndef GL_ATI_texture_env_combine3
#define GL_MODULATE_ADD_ATI 0x8744
#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
#define GL_MODULATE_SUBTRACT_ATI 0x8746
#endif
#ifndef GL_ATI_texture_env_combine3
#define GL_ATI_texture_env_combine3 1
#endif
boolean Sys_GLPreInit(void);
/**
* Initializes our OpenGL interface. Called once during engine statup.
*/
boolean Sys_GLInitialize(void);
/**
* Close our OpenGL interface for good. Called once during engine shutdown.
*/
void Sys_GLShutdown(void);
void Sys_GLConfigureDefaultState(void);
/**
* Echo the full list of available GL extensions to the console.
*/
void Sys_GLPrintExtensions(void);
/**
* @return Non-zero iff the extension is found.
*/
boolean Sys_GLQueryExtension(const char* name, const GLubyte* extensions);
boolean Sys_GLCheckError(void);
#endif /* LIBDENG_SYSTEM_OPENGL_H */