-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Cannot set timing mode for main loop" & "You should use 0 for the frame rate in emscripten_set_main_loop" #7100
Comments
This does seem odd, I'm not sure why cc @Daft-Freak |
For the second message, try creating the renderer with the |
I'm having this same problem in porting a game to wasm. The code calls |
I am experiencing the same error "Cannot set timing, ..." with the following code #include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <emscripten.h>
void loop_handler(void*) {
}
int main(int argc, char** argv) {
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
SDL_Window* win = SDL_CreateWindow("WebAssembly test", 0, 0, 800, 600, 0);
SDL_Renderer* renderer = SDL_CreateRenderer(win, 0, 0);
TTF_Font* font = TTF_OpenFont("assets/DejaVuSansMono.ttf", 100);
SDL_Color white = {255, 255, 255};
SDL_Surface* sf = TTF_RenderText_Solid(font, "WebAssembly rocks!", white);
SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, sf);
emscripten_set_main_loop_arg(loop_handler, nullptr, -1, 1);
// SDL_RenderCopy(renderer, tex, nullptr, nullptr);
// SDL_RenderPresent(renderer);
// std::cout << std::endl << "Hello World" << std::endl;
// SDL_DestroyTexture(tex);
// SDL_FreeSurface(sf);
// SDL_DestroyRenderer(renderer);
// SDL_DestroyWindow(win);
// TTF_CloseFont(font);
// TTF_Quit();
// SDL_Quit();
return 0;
}
|
You can just ignore the error, it's only there when |
The warning goes away if I do this, but I wonder if this could have other consequences: #include <SDL2/SDL.h>
#include <emscripten.h>
void iterate()
{
// Here I have some code animating a sprite
}
int main(int, char**)
{
SDL_Init( SDL_INIT_VIDEO ); // I have this call, I guess it makes no difference
emscripten_set_main_loop(iterate, 0, 1); // moved before creating window and renderer
auto pwindow = SDL_CreateWindow
(
"Test",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL_WINDOW_RESIZABLE
);
auto prenderer = SDL_CreateRenderer
(
pwindow,
-1,
0
);
return 0;
} |
That shouldn't work as Where the warning comes from: |
Never mind then. I was assuming |
I have the same errors. However, in my practice, "Cannot set timing mode for main loop" error message wont break the application. It is more like a warning. |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
With the following program…:
… I get the following error in the web console:
emscripten_set_main_loop_timing: Cannot set timing mode for main loop since a main loop does not exist! Call emscripten_set_main_loop first to set one up.
Since
emscripten_set_main_loop_timing
seems to be called bySDL_CreateRenderer
, I try to fix my program like so:But now I get the following warning in the web console:
Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!
It seems like there's no way to get neither of those errors.
The text was updated successfully, but these errors were encountered: