naev 0.11.5
opengl.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
31#include "physfsrwops.h"
32#include "SDL.h"
33#include "SDL_error.h"
34#include "SDL_image.h"
35
36#include "naev.h"
39#include "opengl.h"
40
41#include "conf.h"
42#include "debug.h"
43#include "log.h"
44#include "render.h"
45
46/*
47 * Requirements
48 */
49#define OPENGL_REQ_MULTITEX 2
52static int gl_activated = 0;
54static unsigned int colourblind_pp = 0;
56/*
57 * Viewport offsets
58 */
59static int gl_view_x = 0; /* X viewport offset. */
60static int gl_view_y = 0; /* Y viewport offset. */
61static int gl_view_w = 0; /* Viewport width. */
62static int gl_view_h = 0; /* Viewport height. */
63mat4 gl_view_matrix = {{{{0}}}};
64
65/*
66 * prototypes
67 */
68/* gl */
69static int gl_setupAttributes( int fallback );
70static int gl_createWindow( unsigned int flags );
71static int gl_getFullscreenMode (void);
72static int gl_getGLInfo (void);
73static int gl_defState (void);
74static int gl_setupScaling (void);
75
76/*
77 *
78 * M I S C
79 *
80 */
86void gl_screenshot( const char *filename )
87{
88 GLubyte *screenbuf;
89 SDL_RWops *rw;
90 SDL_Surface *surface;
91 int w, h;
92
93 /* Allocate data. */
94 w = gl_screen.rw;
95 h = gl_screen.rh;
96 screenbuf = malloc( sizeof(GLubyte) * 3 * w*h );
97 surface = SDL_CreateRGBSurface( 0, w, h, 24, RGBAMASK );
98
99 /* Read pixels from buffer -- SLOW. */
100 glPixelStorei(GL_PACK_ALIGNMENT, 1); /* Force them to pack the bytes. */
101 glReadPixels( 0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenbuf );
102
103 /* Convert data. */
104 for (int i=0; i<h; i++)
105 memcpy( (GLubyte*)surface->pixels + i * surface->pitch, &screenbuf[ (h - i - 1) * (3*w) ], 3*w );
106 free( screenbuf );
107
108 /* Save PNG. */
109 if (!(rw = PHYSFSRWOPS_openWrite( filename )))
110 WARN( _("Aborting screenshot") );
111 else
112 IMG_SavePNG_RW( surface, rw, 1 );
113
114 /* Check to see if an error occurred. */
115 gl_checkErr();
116
117 /* Free memory. */
118 SDL_FreeSurface( surface );
119}
120
121/*
122 *
123 * G L O B A L
124 *
125 */
133GLboolean gl_hasVersion( int major, int minor )
134{
135 if (GLVersion.major >= major && GLVersion.minor >= minor)
136 return GL_TRUE;
137 return GL_FALSE;
138}
139
140#ifdef DEBUGGING
144void gl_checkHandleError( const char *func, int line )
145{
146 (void) func;
147 (void) line;
148#if !DEBUG_GL
149 const char* errstr;
150 GLenum err = glGetError();
151
152 /* No error. */
153 if (err == GL_NO_ERROR)
154 return;
155
156 switch (err) {
157 case GL_INVALID_ENUM:
158 errstr = _("GL invalid enum");
159 break;
160 case GL_INVALID_VALUE:
161 errstr = _("GL invalid value");
162 break;
163 case GL_INVALID_OPERATION:
164 errstr = _("GL invalid operation");
165 break;
166 case GL_INVALID_FRAMEBUFFER_OPERATION:
167 errstr = _("GL invalid framebuffer operation");
168 break;
169 case GL_OUT_OF_MEMORY:
170 errstr = _("GL out of memory");
171 break;
172
173 default:
174 errstr = _("GL unknown error");
175 break;
176 }
177 WARN(_("OpenGL error [%s:%d]: %s"), func, line, errstr);
178#endif /* !DEBUG_GL */
179}
180
181#if DEBUG_GL
185static void GLAPIENTRY gl_debugCallback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* p )
186{
187 static int errors_seen = 0;
188 (void) source;
189 (void) id;
190 (void) length;
191 (void) p;
192 const char *typestr;
193
194 if (++errors_seen == 10)
195 WARN( _("Too many OpenGL diagnostics reported! Suppressing further reports.") );
196 if (errors_seen >= 10)
197 return;
198
199 switch (type) {
200 case GL_DEBUG_TYPE_ERROR:
201 typestr = " GL_DEBUG_TYPE_ERROR";
202 break;
203 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
204 typestr = " GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR";
205 break;
206 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
207 typestr = " GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR";
208 break;
209 case GL_DEBUG_TYPE_PORTABILITY:
210 typestr = " GL_DEBUG_TYPE_PORTABILITY";
211 break;
212 case GL_DEBUG_TYPE_PERFORMANCE:
213 typestr = " GL_DEBUG_TYPE_PERFORMANCE";
214 break;
215 case GL_DEBUG_TYPE_OTHER:
216 typestr = " GL_DEBUG_TYPE_OTHER";
217 break;
218 case GL_DEBUG_TYPE_MARKER: /* fallthrough */
219 case GL_DEBUG_TYPE_PUSH_GROUP: /* fallthrough */
220 case GL_DEBUG_TYPE_POP_GROUP: /* fallthrough */
221 return;
222 default:
223 typestr = "";
224 }
225 WARN( _("[type = 0x%x%s], severity = 0x%x, message = %s backtrace:"), type, typestr, severity, message );
226 debug_logBacktrace();
227}
228#endif /* DEBUG_GL */
229#endif /* DEBUGGING */
230
236static int gl_setupAttributes( int fallback )
237{
238 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, fallback ? 3 : 4);
239 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, fallback ? 2 : 0);
240 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
241 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); /* Ideally want double buffering. */
242 if (conf.fsaa > 1) {
243 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
244 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, conf.fsaa);
245 }
246 SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
247#if DEBUG_GL
248 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
249#endif /* DEBUG_GL */
250
251 return 0;
252}
253
261{
262 int ok;
263 int display_index = SDL_GetWindowDisplayIndex( gl_screen.window );
264 if (conf.fullscreen && conf.modesetting) {
265 SDL_DisplayMode target, closest;
266 /* Try to use desktop resolution if nothing is specifically set. */
267 if (conf.explicit_dim) {
268 SDL_GetWindowDisplayMode( gl_screen.window, &target );
269 target.w = conf.width;
270 target.h = conf.height;
271 }
272 else
273 SDL_GetDesktopDisplayMode( display_index, &target );
274
275 if (SDL_GetClosestDisplayMode( display_index, &target, &closest ) == NULL)
276 SDL_GetDisplayMode( display_index, 0, &closest ); /* fall back to the best one */
277
278 SDL_SetWindowDisplayMode( gl_screen.window, &closest );
279 }
280 ok = SDL_SetWindowFullscreen( gl_screen.window, gl_getFullscreenMode() );
281 /* HACK: Force pending resize events to be processed, particularly on Wayland. */
282 SDL_PumpEvents();
283 SDL_GL_SwapWindow(gl_screen.window);
284 SDL_GL_SwapWindow(gl_screen.window);
285 return ok;
286}
287
293static int gl_getFullscreenMode (void)
294{
295 if (conf.fullscreen)
296 return conf.modesetting ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_FULLSCREEN_DESKTOP;
297 return 0;
298}
299
305static int gl_createWindow( unsigned int flags )
306{
307 flags |= SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI;
308 if (!conf.notresizable)
309 flags |= SDL_WINDOW_RESIZABLE;
310 if (conf.borderless)
311 flags |= SDL_WINDOW_BORDERLESS;
312
313 /* Create the window. */
314 gl_screen.window = SDL_CreateWindow( APPNAME,
315 SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
316 conf.width, conf.height, flags );
317 if (gl_screen.window == NULL)
318 ERR(_("Unable to create window! %s"), SDL_GetError());
319
320 /* Set focus loss behaviour. */
321 SDL_SetHint( SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
322 conf.minimize ? "1" : "0" );
323
324 /* Create the OpenGL context, note we don't need an actual renderer. */
325 for (int fallback=0; fallback <= 1; fallback++) {
326 gl_setupAttributes( fallback );
327 gl_screen.context = SDL_GL_CreateContext( gl_screen.window );
328 if (gl_screen.context != NULL)
329 break;
330 }
331 if (!gl_screen.context)
332 ERR(_("Unable to create OpenGL context! %s"), SDL_GetError());
333
334 /* Set Vsync. */
335 if (conf.vsync) {
336 int ret = SDL_GL_SetSwapInterval( 1 );
337 if (ret == 0)
338 gl_screen.flags |= OPENGL_VSYNC;
339 } else {
340 SDL_GL_SetSwapInterval( 0 );
341 }
342
343 /* Finish getting attributes. */
344 gl_screen.current_fbo = 0; /* No FBO set. */
345 for (int i=0; i<OPENGL_NUM_FBOS; i++) {
346 gl_screen.fbo[i] = GL_INVALID_VALUE;
347 gl_screen.fbo_tex[i] = GL_INVALID_VALUE;
348 }
349 SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &gl_screen.depth );
350 gl_activated = 1; /* Opengl is now activated. */
351
352 return 0;
353}
354
360static int gl_getGLInfo (void)
361{
362 int doublebuf;
363 SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &gl_screen.r );
364 SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &gl_screen.g );
365 SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &gl_screen.b );
366 SDL_GL_GetAttribute( SDL_GL_ALPHA_SIZE, &gl_screen.a );
367 SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &doublebuf );
368 SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &gl_screen.fsaa );
369 if (doublebuf)
370 gl_screen.flags |= OPENGL_DOUBLEBUF;
371 if (GLAD_GL_ARB_shader_subroutine && glGetSubroutineIndex && glGetSubroutineUniformLocation && glUniformSubroutinesuiv)
372 gl_screen.flags |= OPENGL_SUBROUTINES;
373 /* Calculate real depth. */
375
376 /* Texture information */
377 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_screen.tex_max);
378 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gl_screen.multitex_max);
379
380 /* Debug happiness */
381 DEBUG(_("OpenGL Drawable Created: %dx%d@%dbpp"), gl_screen.rw, gl_screen.rh, gl_screen.depth);
382 DEBUG(_("r: %d, g: %d, b: %d, a: %d, db: %s, fsaa: %d, tex: %d"),
384 gl_has(OPENGL_DOUBLEBUF) ? _("yes") : _("no"),
386 DEBUG(_("vsync: %s"), gl_has(OPENGL_VSYNC) ? _("yes") : _("no"));
387 DEBUG(_("Renderer: %s"), glGetString(GL_RENDERER));
388 DEBUG(_("Version: %s"), glGetString(GL_VERSION));
389
390 /* Now check for things that can be bad. */
392 WARN(_("Missing texture units (%d required, %d found)"),
394 if ((conf.fsaa > 1) && (gl_screen.fsaa != conf.fsaa))
395 WARN(_("Unable to get requested FSAA level (%d requested, got %d)"),
396 conf.fsaa, gl_screen.fsaa );
397
398 return 0;
399}
400
406static int gl_defState (void)
407{
408 glDisable( GL_DEPTH_TEST ); /* set for doing 2d */
409 glEnable( GL_BLEND ); /* alpha blending ftw */
410 glEnable( GL_LINE_SMOOTH ); /* We use SDF shaders for most shapes, but star trails & map routes are thin & anti-aliased. */
411#if DEBUG_GL
412 glEnable( GL_DEBUG_OUTPUT ); /* Log errors immediately.. */
413 glDebugMessageCallback( gl_debugCallback, 0 );
414 glDebugMessageControl( GL_DONT_CARE, GL_DEBUG_TYPE_PERFORMANCE, GL_DONT_CARE, 0, NULL, GL_FALSE );
415 glDebugMessageControl( GL_DONT_CARE, GL_DEBUG_TYPE_OTHER, GL_DONT_CARE, 0, NULL, GL_FALSE );
416#endif /* DEBUG_GL */
417
418 /* Set the blending/shading model to use. */
419 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); /* good blend model */
420
421 return 0;
422}
423
429static int gl_setupScaling (void)
430{
431 /* Get the basic dimensions from SDL2. */
432 SDL_GetWindowSize(gl_screen.window, &gl_screen.w, &gl_screen.h);
433 SDL_GL_GetDrawableSize(gl_screen.window, &gl_screen.rw, &gl_screen.rh);
434 /* Calculate scale factor, if OS has native HiDPI scaling. */
435 gl_screen.dwscale = (double)gl_screen.w / (double)gl_screen.rw;
436 gl_screen.dhscale = (double)gl_screen.h / (double)gl_screen.rh;
437
438 /* Combine scale factor from OS with the one in Naev's config */
440 glLineWidth(1. / gl_screen.scale);
441 glPointSize(1. / gl_screen.scale + 2.0);
442
443 /* New window is real window scaled. */
446 /* Small windows get handled here. */
447 if ((gl_screen.nw < RESOLUTION_W_MIN)
448 || (gl_screen.nh < RESOLUTION_H_MIN)) {
449 double scalew, scaleh;
450 if (gl_screen.scale != 1.)
451 DEBUG(_("Screen size too small, upscaling..."));
452 scalew = RESOLUTION_W_MIN / (double)gl_screen.nw;
453 scaleh = RESOLUTION_H_MIN / (double)gl_screen.nh;
454 gl_screen.scale *= MAX( scalew, scaleh );
455 /* Rescale. */
458 }
459 /* Viewport matches new window size. */
462 /* Set scale factors. */
463 gl_screen.wscale = (double)gl_screen.nw / (double)gl_screen.w;
464 gl_screen.hscale = (double)gl_screen.nh / (double)gl_screen.h;
465 gl_screen.mxscale = (double)gl_screen.w / (double)gl_screen.rw;
466 gl_screen.myscale = (double)gl_screen.h / (double)gl_screen.rh;
467
468 return 0;
469}
470
475int gl_init (void)
476{
477 unsigned int flags;
478 GLuint VaoId;
479
480 /* Defaults. */
481 memset( &gl_screen, 0, sizeof(gl_screen) );
482 SDL_SetHint( "SDL_WINDOWS_DPI_SCALING", "1" );
483 flags = SDL_WINDOW_OPENGL | gl_getFullscreenMode();
484
485 /* Initializes Video */
486 if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
487 WARN(_("Unable to initialize SDL Video: %s"), SDL_GetError());
488 return -1;
489 }
490
491 /* Create the window. */
492 gl_createWindow( flags );
493
494 /* Apply the configured fullscreen display mode, if any. */
496
497 /* Load extensions. */
498 if (!gladLoadGLLoader(SDL_GL_GetProcAddress))
499 ERR("Unable to load OpenGL using GLAD");
500
501 /* We are interested in 3.1 because it drops all the deprecated stuff. */
502 if ( !GLAD_GL_VERSION_3_1 )
503 WARN( "Naev requires OpenGL 3.1, but got OpenGL %d.%d!", GLVersion.major, GLVersion.minor );
504
505 /* Some OpenGL options. */
506 glClearColor( 0., 0., 0., 1. );
507
508 /* Set default opengl state. */
509 gl_defState();
510
511 /* Handles resetting the viewport and scaling, rw/rh are set in createWindow. */
512 gl_resize();
513
514 /* Finishing touches. */
515 glClear( GL_COLOR_BUFFER_BIT ); /* must clear the buffer first */
516 gl_checkErr();
517
518 /* Initialize subsystems.*/
520 gl_initVBO();
522
523 /* Get info about the OpenGL window */
524 gl_getGLInfo();
525
526 /* Modern OpenGL requires at least one VAO */
527 glGenVertexArrays(1, &VaoId);
528 glBindVertexArray(VaoId);
529
530 shaders_load();
531
532 /* Set colourblind shader if necessary. */
534
535 /* Set colourspace. */
536 glEnable( GL_FRAMEBUFFER_SRGB );
537
538 /* Cosmetic new line. */
539 DEBUG_BLANK();
540
541 return 0;
542}
543
547void gl_resize (void)
548{
550 glViewport( 0, 0, gl_screen.rw, gl_screen.rh );
553
554 /* Set up framebuffer. */
555 for (int i=0; i<OPENGL_NUM_FBOS; i++) {
556 if (gl_screen.fbo[i] != GL_INVALID_VALUE) {
557 glDeleteFramebuffers( 1, &gl_screen.fbo[i] );
558 glDeleteTextures( 1, &gl_screen.fbo_tex[i] );
559 }
561 }
562
563 gl_checkErr();
564}
565
569void gl_viewport( int x, int y, int w, int h )
570{
571 mat4 proj = mat4_ortho( 0., /* Left edge. */
572 gl_screen.nw, /* Right edge. */
573 0., /* Bottom edge. */
574 gl_screen.nh, /* Top edge. */
575 -1., /* near */
576 1. ); /* far */
577
578 /* Take into account possible translation. */
579 gl_screen.x = x;
580 gl_screen.y = y;
581 mat4_translate( &proj, x, y, 0. );
582
583 /* Set screen size. */
584 gl_screen.w = w;
585 gl_screen.h = h;
586
587 /* Take into account possible scaling. */
588 if (gl_screen.scale != 1.)
590
591 gl_view_matrix = proj;
592}
593
597void gl_setDefViewport( int x, int y, int w, int h )
598{
599 gl_view_x = x;
600 gl_view_y = y;
601 gl_view_w = w;
602 gl_view_h = h;
603}
604
608void gl_defViewport (void)
609{
610 gl_viewport( gl_view_x, gl_view_y, gl_view_w, gl_view_h );
611}
612
616void gl_windowToScreenPos( int *sx, int *sy, int wx, int wy )
617{
618 wx /= gl_screen.dwscale;
619 wy /= gl_screen.dhscale;
620
621 *sx = gl_screen.mxscale * (double)wx - (double)gl_screen.x;
622 *sy = gl_screen.myscale * (double)(gl_screen.rh - wy) - (double)gl_screen.y;
623}
624
628void gl_screenToWindowPos( int *wx, int *wy, int sx, int sy )
629{
630 *wx = (sx + (double)gl_screen.x) / gl_screen.mxscale;
631 *wy = (double)gl_screen.rh - (sy + (double)gl_screen.y) / gl_screen.myscale;
632
633 *wx *= gl_screen.dwscale;
634 *wy *= gl_screen.dhscale;
635}
636
643GLint gl_stringToFilter( const char *s )
644{
645 if (strcmp(s,"linear")==0)
646 return GL_LINEAR;
647 else if (strcmp(s,"nearest")==0)
648 return GL_NEAREST;
649 return 0;
650}
651
658GLint gl_stringToClamp( const char *s )
659{
660 if (strcmp(s,"clamp")==0)
661 return GL_CLAMP_TO_EDGE;
662 else if (strcmp(s,"repeat")==0)
663 return GL_REPEAT;
664 else if (strcmp(s,"mirroredrepeat")==0)
665 return GL_MIRRORED_REPEAT;
666 return 0;
667}
668
674void gl_colourblind( int enable )
675{
676 if (enable) {
677 LuaShader_t shader;
678 if (colourblind_pp != 0)
679 return;
680 memset( &shader, 0, sizeof(LuaShader_t) );
681 shader.program = shaders.colourblind.program;
682 shader.VertexPosition = shaders.colourblind.VertexPosition;
683 shader.ClipSpaceFromLocal = shaders.colourblind.ClipSpaceFromLocal;
684 shader.MainTex = shaders.colourblind.MainTex;
685 colourblind_pp = render_postprocessAdd( &shader, PP_LAYER_CORE, 99, PP_SHADER_PERMANENT );
686 } else {
687 if (colourblind_pp != 0)
688 render_postprocessRm( colourblind_pp );
689 colourblind_pp = 0;
690 }
691}
692
696void gl_exit (void)
697{
698 for (int i=0; i<OPENGL_NUM_FBOS; i++) {
699 if (gl_screen.fbo[i] != GL_INVALID_VALUE) {
700 glDeleteFramebuffers( 1, &gl_screen.fbo[i] );
701 glDeleteTextures( 1, &gl_screen.fbo_tex[i] );
702 gl_screen.fbo[i] = GL_INVALID_VALUE;
703 gl_screen.fbo_tex[i] = GL_INVALID_VALUE;
704 }
705 }
706
707 /* Exit the OpenGL subsystems. */
709 gl_exitVBO();
711
712 shaders_unload();
713
714 /* Shut down the subsystem */
715 SDL_QuitSubSystem(SDL_INIT_VIDEO);
716}
void mat4_translate(mat4 *m, double x, double y, double z)
Translates a homogenous transformation matrix.
Definition mat4.c:99
void mat4_scale(mat4 *m, double x, double y, double z)
Scales a homogeneous transformation matrix.
Definition mat4.c:82
mat4 mat4_ortho(double left, double right, double bottom, double top, double nearVal, double farVal)
Creates an orthographic projection matrix.
Definition mat4.c:209
Header file with generic functions and naev-specifics.
#define APPNAME
Definition naev.h:34
#define MAX(x, y)
Definition naev.h:39
void gl_setDefViewport(int x, int y, int w, int h)
Sets the default viewport.
Definition opengl.c:597
void gl_screenshot(const char *filename)
Takes a screenshot.
Definition opengl.c:86
static int gl_defState(void)
Sets the opengl state to it's default parameters.
Definition opengl.c:406
static int gl_getGLInfo(void)
Gets some information about the OpenGL window.
Definition opengl.c:360
void gl_defViewport(void)
Resets viewport to default.
Definition opengl.c:608
void gl_colourblind(int enable)
Enables or disables the colourblind shader.
Definition opengl.c:674
void gl_resize(void)
Handles a window resize and resets gl_screen parameters.
Definition opengl.c:547
void gl_screenToWindowPos(int *wx, int *wy, int sx, int sy)
Translates the screen position to windos position.
Definition opengl.c:628
GLint gl_stringToFilter(const char *s)
Gets the associated min/mag filter from a string.
Definition opengl.c:643
void gl_exit(void)
Cleans up OpenGL, the works.
Definition opengl.c:696
void gl_viewport(int x, int y, int w, int h)
Sets the opengl viewport.
Definition opengl.c:569
static int gl_activated
Definition opengl.c:52
void gl_windowToScreenPos(int *sx, int *sy, int wx, int wy)
Translates the window position to screen position.
Definition opengl.c:616
static int gl_getFullscreenMode(void)
Returns the fullscreen configuration as SDL2 flags.
Definition opengl.c:293
static unsigned int colourblind_pp
Definition opengl.c:54
static int gl_setupAttributes(int fallback)
Tries to set up the OpenGL attributes for the OpenGL context.
Definition opengl.c:236
static int gl_setupScaling(void)
Sets up dimensions in gl_screen, including scaling as needed.
Definition opengl.c:429
int gl_init(void)
Initializes SDL/OpenGL and the works.
Definition opengl.c:475
static int gl_createWindow(unsigned int flags)
Creates the OpenGL window.
Definition opengl.c:305
GLboolean gl_hasVersion(int major, int minor)
Checks to see if opengl version is at least major.minor.
Definition opengl.c:133
glInfo gl_screen
Definition opengl.c:51
#define OPENGL_REQ_MULTITEX
Definition opengl.c:49
GLint gl_stringToClamp(const char *s)
Gets the associated min/mag filter from a string.
Definition opengl.c:658
int gl_setupFullscreen(void)
Tries to apply the configured display mode to the window.
Definition opengl.c:260
void gl_exitRender(void)
Cleans up the OpenGL rendering routines.
int gl_initRender(void)
Initializes the OpenGL rendering routines.
void gl_exitTextures(void)
Cleans up the opengl texture subsystem.
int gl_fboCreate(GLuint *fbo, GLuint *tex, GLsizei width, GLsizei height)
Creates a framebuffer and its associated texture.
Definition opengl_tex.c:252
int gl_initTextures(void)
Initializes the opengl texture subsystem.
int gl_initVBO(void)
Initializes the OpenGL VBO subsystem.
Definition opengl_vbo.c:48
void gl_exitVBO(void)
Exits the OpenGL VBO subsystem.
Definition opengl_vbo.c:56
double scalefactor
Definition conf.h:89
int colourblind
Definition conf.h:96
int fullscreen
Definition conf.h:91
int vsync
Definition conf.h:83
int modesetting
Definition conf.h:92
int width
Definition conf.h:86
int minimize
Definition conf.h:95
int height
Definition conf.h:87
int notresizable
Definition conf.h:93
int explicit_dim
Definition conf.h:88
int fsaa
Definition conf.h:82
int borderless
Definition conf.h:94
Stores data about the current opengl environment.
Definition opengl.h:40
double dwscale
Definition opengl.h:55
int depth
Definition opengl.h:59
double scale
Definition opengl.h:52
int y
Definition opengl.h:42
int b
Definition opengl.h:62
int g
Definition opengl.h:61
double wscale
Definition opengl.h:53
int x
Definition opengl.h:41
double myscale
Definition opengl.h:58
int w
Definition opengl.h:44
double dhscale
Definition opengl.h:56
int rh
Definition opengl.h:51
int fsaa
Definition opengl.h:67
int r
Definition opengl.h:60
GLuint fbo_tex[OPENGL_NUM_FBOS]
Definition opengl.h:72
double mxscale
Definition opengl.h:57
SDL_Window * window
Definition opengl.h:68
int a
Definition opengl.h:63
double hscale
Definition opengl.h:54
GLuint fbo[OPENGL_NUM_FBOS]
Definition opengl.h:71
int tex_max
Definition opengl.h:65
SDL_GLContext context
Definition opengl.h:69
int rw
Definition opengl.h:50
int h
Definition opengl.h:45
unsigned int flags
Definition opengl.h:64
int nw
Definition opengl.h:47
int multitex_max
Definition opengl.h:66
int nh
Definition opengl.h:48
GLuint current_fbo
Definition opengl.h:70
Definition mat4.h:10