Skip to content

Commit 26ffbfd

Browse files
committed
gl_common,glx_common: IWYU
1 parent e8cd71b commit 26ffbfd

File tree

4 files changed

+41
-27
lines changed

4 files changed

+41
-27
lines changed

src/gl_context.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,21 @@
3535
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
*/
3737

38-
#ifdef HAVE_CONFIG_H
39-
#include "config.h"
40-
#include "config_unix.h"
41-
#include "config_win32.h"
42-
#endif
38+
#include "gl_context.h"
4339

44-
#include <stdio.h>
40+
#include <stdio.h> // for NULL, fprintf, stderr
41+
#include <stdlib.h> // for free, atoi
42+
#include <string.h> // for strtok_r
4543

4644
#ifdef __APPLE__
4745
#include "mac_gl_common.h"
4846
#elif defined __linux__
49-
#include "x11_common.h"
5047
#include "glx_common.h"
5148
#else // _WIN32
5249
#include "win32_gl_common.h"
5350
#endif
5451

5552
#include "debug.h"
56-
#include "gl_context.h"
5753
#include "utils/macros.h"
5854

5955
/**
@@ -72,14 +68,14 @@ bool init_gl_context(struct gl_context *context, int which) {
7268
if(which == GL_CONTEXT_ANY) {
7369
debug_msg("Trying OpenGL 3.1 first.\n");
7470
context->context = glx_init(MK_OPENGL_VERSION(3,1));
75-
context->legacy = FALSE;
71+
context->legacy = false;
7672
}
7773
if(!context->context) {
7874
if(which != GL_CONTEXT_LEGACY) {
7975
debug_msg("OpenGL 3.1 profile failed to initialize, falling back to legacy profile.\n");
8076
}
8177
context->context = glx_init(OPENGL_VERSION_UNSPECIFIED);
82-
context->legacy = TRUE;
78+
context->legacy = true;
8379
}
8480
if(context->context) {
8581
glx_validate(context->context);
@@ -92,14 +88,14 @@ bool init_gl_context(struct gl_context *context, int which) {
9288
if(!context->context) {
9389
debug_msg("OpenGL 3.2 Core profile failed to initialize, falling back to legacy profile.\n");
9490
} else {
95-
context->legacy = FALSE;
91+
context->legacy = false;
9692
}
9793
}
9894
}
9995

10096
if(!context->context) {
10197
context->context = mac_gl_init(MAC_GL_PROFILE_LEGACY);
102-
context->legacy = TRUE;
98+
context->legacy = true;
10399
}
104100
#else // _WIN32
105101
if(which == GL_CONTEXT_ANY) {
@@ -108,7 +104,7 @@ bool init_gl_context(struct gl_context *context, int which) {
108104
context->context = win32_context_init(OPENGL_VERSION_LEGACY);
109105
}
110106

111-
context->legacy = TRUE;
107+
context->legacy = true;
112108
#endif
113109

114110
{

src/gl_context.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@
4848
#include <Availability.h>
4949
#endif
5050

51+
#ifdef __cplusplus
52+
#include <cstdio> // for fprintf, stderr
53+
#include <cstdlib> // for abort
54+
#else
55+
#include <stdbool.h>
56+
#include <stdio.h> // for fprintf, stderr
57+
#include <stdlib.h> // for abort
58+
#endif
59+
5160
#ifdef __cplusplus
5261
extern "C" {
5362
#endif // __cplusplus

src/glx_common.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,21 @@
3535
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
*/
3737

38-
#ifdef HAVE_CONFIG_H
39-
#include "config.h"
40-
#include "config_unix.h"
41-
#endif
42-
#include "debug.h"
38+
#include "glx_common.h"
4339

4440
#include <GL/glew.h>
41+
#include <GL/glx.h>
42+
#include <X11/X.h> // for None, AllocNone, CWBorderPixel, CWColormap
4543
#include <X11/Xlib.h>
4644
#include <X11/Xutil.h>
47-
#include <GL/glx.h>
45+
#include <assert.h>
46+
#include <stdbool.h> // for false, true
47+
#include <stdio.h> // for fprintf, stderr
48+
#include <stdlib.h>
49+
#include <string.h>
50+
51+
#include "debug.h"
4852
#include "x11_common.h"
49-
#include "glx_common.h"
5053

5154
#ifdef HAVE_GPUPERFAPI
5255
#include "GPUPerfAPI.h"
@@ -134,7 +137,7 @@ static int isExtensionSupported(const char *extList, const char *extension)
134137
/* Extension names should not have spaces. */
135138
where = strchr(extension, ' ');
136139
if ( where || *extension == '\0' )
137-
return FALSE;
140+
return false;
138141

139142
/* It takes a bit of care to be fool-proof about parsing the
140143
OpenGL extensions string. Don't be fooled by sub-strings,
@@ -149,20 +152,20 @@ static int isExtensionSupported(const char *extList, const char *extension)
149152

150153
if ( where == start || *(where - 1) == ' ' )
151154
if ( *terminator == ' ' || *terminator == '\0' )
152-
return TRUE;
155+
return true;
153156

154157
start = terminator;
155158
}
156159

157-
return FALSE;
160+
return false;
158161
}
159162

160-
static int ctxErrorOccurred = FALSE;
163+
static int ctxErrorOccurred = false;
161164
static int ctxErrorHandler( Display *dpy, XErrorEvent *ev )
162165
{
163166
UNUSED(dpy);
164167
UNUSED(ev);
165-
ctxErrorOccurred = TRUE;
168+
ctxErrorOccurred = true;
166169
return 0;
167170
}
168171

@@ -322,7 +325,7 @@ void *glx_init(glx_opengl_version_t version)
322325
// Note this error handler is global. All display connections in all threads
323326
// of a process use the same error handler, so be sure to guard against other
324327
// threads issuing X commands while this code is running.
325-
ctxErrorOccurred = FALSE;
328+
ctxErrorOccurred = false;
326329
oldHandler = XSetErrorHandler(&ctxErrorHandler);
327330

328331
// Check for the GLX_ARB_create_context extension string and the function.
@@ -374,7 +377,7 @@ void *glx_init(glx_opengl_version_t version)
374377
// GLX_CONTEXT_MINOR_VERSION_ARB = 0
375378
context_attribs[3] = 0;
376379

377-
ctxErrorOccurred = FALSE;
380+
ctxErrorOccurred = false;
378381

379382
debug_msg( "Failed to create GL 3.0 context"
380383
" ... using old-style GLX context\n" );

src/glx_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
*/
3737

38+
#ifdef __cplusplus
39+
#include <csdint>
40+
#else
41+
#include <stdint.h>
42+
#endif
43+
3844
typedef uint32_t glx_opengl_version_t;
3945
#define OPENGL_VERSION_UNSPECIFIED 0u
4046
#define MK_OPENGL_VERSION(major,minor) (major << 8u | minor)

0 commit comments

Comments
 (0)