1 /* Emacs style mode select   -*- C++ -*-
2  *-----------------------------------------------------------------------------
3  *
4  *
5  *  PrBoom: a Doom port merged with LxDoom and LSDLDoom
6  *  based on BOOM, a modified and improved DOOM engine
7  *  Copyright (C) 1999 by
8  *  id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9  *  Copyright (C) 1999-2000 by
10  *  Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11  *  Copyright 2005, 2006 by
12  *  Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13  *
14  *  This program is free software; you can redistribute it and/or
15  *  modify it under the terms of the GNU General Public License
16  *  as published by the Free Software Foundation; either version 2
17  *  of the License, or (at your option) any later version.
18  *
19  *  This program is distributed in the hope that it will be useful,
20  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *  GNU General Public License for more details.
23  *
24  *  You should have received a copy of the GNU General Public License
25  *  along with this program; if not, write to the Free Software
26  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27  *  02111-1307, USA.
28  *
29  * DESCRIPTION:
30  *   Thanks Roman "Vortex" Marchenko
31  *---------------------------------------------------------------------
32  */
33 
34 #ifndef _GL_OPENGL_H
35 #define _GL_OPENGL_H
36 
37 #ifdef HAVE_CONFIG_H
38 #include "config.h"
39 #endif
40 
41 #define USE_VERTEX_ARRAYS
42 //#define USE_VBO
43 
44 #include <SDL.h>
45 #include <SDL_opengl.h>
46 
47 #if SDL_VERSION_ATLEAST(1, 3, 0)
48 #if defined(__MACOSX__)
49 #include <OpenGL/gl.h>	/* Header File For The OpenGL Library */
50 #include <OpenGL/glu.h>	/* Header File For The GLU Library */
51 #elif defined(__MACOS__)
52 #include <gl.h>		/* Header File For The OpenGL Library */
53 #include <glu.h>	/* Header File For The GLU Library */
54 #else
55 #include <GL/gl.h>	/* Header File For The OpenGL Library */
56 #include <GL/glu.h>	/* Header File For The GLU Library */
57 #endif
58 #endif
59 
60 #include "doomtype.h"
61 
62 #if !defined(GL_DEPTH_STENCIL_EXT)
63 #define GL_DEPTH_STENCIL_EXT              0x84F9
64 #endif
65 
66 #define isExtensionSupported(ext) strstr(extensions, ext)
67 
68 //e6y: OpenGL version
69 typedef enum {
70   OPENGL_VERSION_1_0,
71   OPENGL_VERSION_1_1,
72   OPENGL_VERSION_1_2,
73   OPENGL_VERSION_1_3,
74   OPENGL_VERSION_1_4,
75   OPENGL_VERSION_1_5,
76   OPENGL_VERSION_2_0,
77   OPENGL_VERSION_2_1,
78 } glversion_t;
79 
80 extern int gl_version;
81 
82 extern int GLEXT_CLAMP_TO_EDGE;
83 extern int gl_max_texture_size;
84 
85 // obsolete?
86 extern int gl_use_paletted_texture;
87 extern int gl_use_shared_texture_palette;
88 extern int gl_paletted_texture;
89 extern int gl_shared_texture_palette;
90 
91 extern dboolean gl_ext_texture_filter_anisotropic;
92 extern dboolean gl_arb_texture_non_power_of_two;
93 extern dboolean gl_arb_multitexture;
94 extern dboolean gl_arb_texture_compression;
95 extern dboolean gl_ext_framebuffer_object;
96 extern dboolean gl_ext_packed_depth_stencil;
97 extern dboolean gl_ext_blend_color;
98 extern dboolean gl_use_stencil;
99 extern dboolean gl_ext_arb_vertex_buffer_object;
100 extern dboolean gl_arb_pixel_buffer_object;
101 
102 // obsolete?
103 extern PFNGLCOLORTABLEEXTPROC              GLEXT_glColorTableEXT;
104 
105 extern PFNGLBINDFRAMEBUFFEREXTPROC         GLEXT_glBindFramebufferEXT;
106 extern PFNGLGENFRAMEBUFFERSEXTPROC         GLEXT_glGenFramebuffersEXT;
107 extern PFNGLGENRENDERBUFFERSEXTPROC        GLEXT_glGenRenderbuffersEXT;
108 extern PFNGLBINDRENDERBUFFEREXTPROC        GLEXT_glBindRenderbufferEXT;
109 extern PFNGLRENDERBUFFERSTORAGEEXTPROC     GLEXT_glRenderbufferStorageEXT;
110 extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC GLEXT_glFramebufferRenderbufferEXT;
111 extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC    GLEXT_glFramebufferTexture2DEXT;
112 extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC  GLEXT_glCheckFramebufferStatusEXT;
113 extern PFNGLDELETEFRAMEBUFFERSEXTPROC      GLEXT_glDeleteFramebuffersEXT;
114 extern PFNGLDELETERENDERBUFFERSEXTPROC     GLEXT_glDeleteRenderbuffersEXT;
115 
116 /* ARB_multitexture command function pointers */
117 extern PFNGLACTIVETEXTUREARBPROC           GLEXT_glActiveTextureARB;
118 extern PFNGLCLIENTACTIVETEXTUREARBPROC     GLEXT_glClientActiveTextureARB;
119 extern PFNGLMULTITEXCOORD2FARBPROC         GLEXT_glMultiTexCoord2fARB;
120 extern PFNGLMULTITEXCOORD2FVARBPROC        GLEXT_glMultiTexCoord2fvARB;
121 
122 extern PFNGLBLENDCOLOREXTPROC              GLEXT_glBlendColorEXT;
123 
124 /* ARB_texture_compression */
125 extern PFNGLCOMPRESSEDTEXIMAGE2DARBPROC    GLEXT_glCompressedTexImage2DARB;
126 
127 /* VBO */
128 extern PFNGLGENBUFFERSARBPROC              GLEXT_glGenBuffersARB;
129 extern PFNGLDELETEBUFFERSARBPROC           GLEXT_glDeleteBuffersARB;
130 extern PFNGLBINDBUFFERARBPROC              GLEXT_glBindBufferARB;
131 extern PFNGLBUFFERDATAARBPROC              GLEXT_glBufferDataARB;
132 
133 /* PBO */
134 extern PFNGLBUFFERSUBDATAARBPROC           GLEXT_glBufferSubDataARB;
135 extern PFNGLGETBUFFERPARAMETERIVARBPROC    GLEXT_glGetBufferParameterivARB;
136 extern PFNGLMAPBUFFERARBPROC               GLEXT_glMapBufferARB;
137 extern PFNGLUNMAPBUFFERARBPROC             GLEXT_glUnmapBufferARB;
138 
139 void gld_InitOpenGL(dboolean compatibility_mode);
140 
141 //states
142 void gld_EnableTexture2D(GLenum texture, int enable);
143 void gld_EnableClientCoordArray(GLenum texture, int enable);
144 void gld_EnableMultisample(int enable);
145 
146 typedef enum
147 {
148   TMF_MASKBIT = 1,
149   TMF_OPAQUEBIT = 2,
150   TMF_INVERTBIT = 4,
151 
152   TM_MODULATE = 0,
153   TM_MASK = TMF_MASKBIT,
154   TM_OPAQUE = TMF_OPAQUEBIT,
155   TM_INVERT = TMF_INVERTBIT,
156   //TM_INVERTMASK = TMF_MASKBIT | TMF_INVERTBIT
157   TM_INVERTOPAQUE = TMF_INVERTBIT | TMF_OPAQUEBIT,
158 } tex_mode_e;
159 void SetTextureMode(tex_mode_e type);
160 
161 #endif // _GL_OPENGL_H
162