Skip to content

Commit b4fd0ea

Browse files
committed
Fix SDL_GL_ExtensionSupported
It looks like this simply didn't work before.
1 parent b5ffb21 commit b4fd0ea

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-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

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

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)