emscripten/tests/emscripten_api_browser.cpp

47 строки
806 B
C++
Исходник Обычный вид История

2012-04-18 07:32:14 +04:00
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
2012-04-18 07:32:14 +04:00
#include<SDL.h>
#include<emscripten.h>
#include<assert.h>
int last = 0;
extern "C" {
2012-04-19 20:50:32 +04:00
void __attribute__((used)) third() {
2012-04-18 07:32:14 +04:00
int now = SDL_GetTicks();
printf("thard! %d\n", now);
assert(fabs(now - last - 1000) < 500);
int result = 1;
REPORT_RESULT();
}
void second() {
int now = SDL_GetTicks();
printf("sacond! %d\n", now);
assert(fabs(now - last - 500) < 250);
last = now;
2012-04-19 20:50:32 +04:00
emscripten_async_run_script("_third()", 1000);
2012-04-18 07:32:14 +04:00
}
}
void never() {
int result = 0;
REPORT_RESULT();
}
2012-04-18 07:32:14 +04:00
int main() {
SDL_Init(0);
last = SDL_GetTicks();
printf("frist! %d\n", last);
atexit(never); // should never be called - it is wrong to exit the runtime orderly if we have async calls!
2012-04-18 07:32:14 +04:00
emscripten_async_call(second, 500);
return 1;
}