emscripten-core / emscripten-core/emscripten
"Cannot set timing mode for main loop" & "You should use 0 for the frame rate in emscripten_set_main_loop"
- Lingua principale
- C++
- Stelle
- 27.6k
- Fork
- 3.6k
- Merge medio
- 1g 14h
- PR unite (30g)
- 125
Descrizione
With the following program…:
```c++
#include
#include
void iterate()
{
}
int main(int, char**)
{
auto pwindow = SDL_CreateWindow
(
"Test",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL_WINDOW_RESIZABLE
);
auto prenderer = SDL_CreateRenderer
(
pwindow,
-1,
0
);
emscripten_set_main_loop(iterate, 0, 1);
return 0;
}
```
… 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 by `SDL_CreateRenderer`, I try to fix my program like so:
```c++
#include
#include
void iterate()
{
SDL_Window* pwindow;
SDL_Renderer* prenderer;
static auto first_call = true;
if(first_call)
{
pwindow = SDL_CreateWindow
(
"Test",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL_WINDOW_RESIZABLE
);
prenderer = SDL_CreateRenderer
(
pwindow,
-1,
0
);
first_call = false;
}
}
int main(int, char**)
{
emscripten_set_main_loop(iterate, 0, 1);
return 0;
}
```
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Riproduci i due snippet e inizia con emscripten_set_main_loop, emscripten_set_main_loop_timing, SDL_CreateWindow e SDL_CreateRenderer, che il report identifica come i punti di ingresso rilevanti. Traccia il modo in cui la creazione del renderer e la frequenza dei fotogrammi richiesta interagiscono con la configurazione del main loop. Il lavoro è completato quando l’ordine di inizializzazione valido non produce più nessuna delle due diagnosi contraddittorie nella console.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, wasm
- Ambito
- compilers, web-dev
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100