Skip to content

Commit 204da9f

Browse files
authored
Fix SDL_GL_ExtensionSupported (#22869)
It looks like this simply didn't work before.
1 parent f7294a6 commit 204da9f

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/library_sdl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3330,7 +3330,8 @@ var LibrarySDL = {
33303330
// SDL 2
33313331

33323332
SDL_GL_ExtensionSupported__proxy: 'sync',
3333-
SDL_GL_ExtensionSupported: (extension) => Module.ctx.getExtension(extension) | 0,
3333+
SDL_GL_ExtensionSupported__deps: ['$GLctx', '$UTF8ToString'],
3334+
SDL_GL_ExtensionSupported: (extension) => GLctx?.getExtension(UTF8ToString(extension)) ? 1 : 0,
33343335

33353336
SDL_DestroyWindow: (window) => {},
33363337

test/browser/test_sdl_gl_extensions.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "SDL/SDL.h"
2+
#include "SDL/SDL_opengl.h"
3+
4+
#include <stdio.h>
5+
#include <string.h>
6+
#include <assert.h>
7+
8+
int main(int argc, char *argv[]) {
9+
SDL_Surface *screen;
10+
11+
assert(SDL_Init(SDL_INIT_VIDEO) == 0);
12+
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
13+
screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL);
14+
assert(screen);
15+
16+
char *extensions = (char*)glGetString(GL_EXTENSIONS);
17+
printf("extensions: %s\n", extensions);
18+
assert(extensions);
19+
20+
int supported = SDL_GL_ExtensionSupported("foobar");
21+
assert(!supported);
22+
23+
char* end = strchr(extensions, ' ');
24+
*end = '\0';
25+
printf("testing for extension: %s\n", extensions);
26+
supported = SDL_GL_ExtensionSupported(extensions);
27+
printf("supported: %d\n", supported);
28+
assert(supported);
29+
30+
SDL_Quit();
31+
return 0;
32+
}

test/test_browser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,10 @@ def test_sdl_canvas_size(self):
14791479
args=['-O2', '--minify=0', '--shell-file',
14801480
test_file('browser/test_sdl_canvas_size.html'), '-lSDL', '-lGL'])
14811481

1482+
@requires_graphics_hardware
1483+
def test_sdl_gl_extensions(self):
1484+
self.btest_exit('test_sdl_gl_extensions.c', args=['-lSDL', '-lGL'])
1485+
14821486
@requires_graphics_hardware
14831487
def test_sdl_gl_read(self):
14841488
# SDL, OpenGL, readPixels

0 commit comments

Comments
 (0)