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