Hi everyone!

I'm trying my first steps on emscripten but have bumped on a wall.
I'm trying to run a very basic hello world style empty canvas SDL2.
It compiles well but when I run it seems that the generated js is not able 
to grab the canvas element.

If I compile with 'emcc main.cpp -v --emrun -s USE_SDL=2 -o 
Build\main.html' it gives me the following error: "Rules for selecting 
event targets in HTML5 API are changing: instead of using 
document.getElementById() that only can refer to elements by their DOM ID, 
new event target selection mechanism uses the more flexible function 
document.querySelector() that can look up element names, classes, and 
complex CSS selectors. Build with -s 
DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 to change to the new lookup 
rules. See https://github.com/emscripten-core/emscripten/pull/7977 for more 
details."

And if I compile with 'emcc main.cpp -v --emrun -s USE_SDL=2 -s 
DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 -o Build\main.html' it 
gives me this other one: "exception thrown: SyntaxError: '' is not a valid 
selector,__findEventTarget@http://localhost:6931/main.js:6696:92
__findCanvasEventTarget@http://localhost:6931/main.js:6702:56
_emscripten_set_canvas_element_size@http://localhost:6931/main.js:6722:20
@http://localhost:6931/main.wasm:wasm-function[734]:0xedf0e
@http://localhost:6931/main.wasm:wasm-function[1007]:0x10d013
@http://localhost:6931/main.wasm:wasm-function[1006]:0x10c3c4
@http://localhost:6931/main.wasm:wasm-function[279]:0xe3b7
Module._main@http://localhost:6931/main.js:9629:10
callMain@http://localhost:6931/main.js:9921:15
doRun@http://localhost:6931/main.js:9979:42
run/<@http://localhost:6931/main.js:9990:7";

I'm using emscripten version 1.38.29.
Tested in Chrome 73.0.3683.75 (64 bits) and Firefox 65.0.2 (64 bits)

Here is the code for main.cpp:
#include <SDL.h>
int main(int argc, char* argv[])
{
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window *window;
    SDL_Renderer *renderer;
    SDL_CreateWindowAndRenderer(256, 256, 0, &window, &renderer);
    SDL_Surface *screen = SDL_CreateRGBSurface(0, 256, 256, 8, 0, 0, 0, 0);
    if (SDL_MUSTLOCK(screen)) SDL_LockSurface(screen);
    if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
    SDL_RenderPresent(renderer);
    SDL_Quit();
    return 0;
}

Also, my end goal is to port a small game and I appreciate if you could 
point me to some basic working examples using SDL2 and Open GL, since the 
ones I found seems outdated.

Thanks!
Fred

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to