20 #include <emscripten/emscripten.h> 25 #define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while(0) 26 #define NUM_OBJECTS 100 77 x = rand() % viewport.
w;
78 y = rand() % viewport.
h;
91 if ((x1 == x2) && (y1 == y2))
94 SDL_Log(
"adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
135 if ((x1 == x2) || (y1 == y2))
143 SDL_Log(
"adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
210 switch (event.
type) {
229 add_line(rand() % 640, rand() % 480, rand() % 640,
236 add_rect(rand() % 640, rand() % 480, rand() % 640,
260 #ifdef __EMSCRIPTEN__ 262 emscripten_cancel_main_loop();
284 for (i = 1; i < argc;) {
318 SDL_Log(
"Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
343 #ifdef __EMSCRIPTEN__ 344 emscripten_set_main_loop(
loop, 0, 1);
357 double fps = ((double) frames * 1000) / (now - then);
358 SDL_Log(
"%2.2f frames per second\n", fps);
#define SDL_RenderDrawPoint
static SDL_BlendMode blendMode
GLdouble GLdouble GLdouble r
void DrawLines(SDL_Renderer *renderer)
GLuint GLfloat GLfloat GLfloat x1
static SDL_bool cycle_alpha
EGLSurface EGLnsecsANDROID time
int main(int argc, char *argv[])
GLint GLint GLint GLint GLint x
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
SDLTest_CommonState * SDLTest_CommonCreateState(char **argv, Uint32 flags)
Parse command line parameters and create common state.
GLfloat GLfloat GLfloat GLfloat h
#define SDL_RenderFillRect
static int cycle_direction
GLfixed GLfixed GLfixed y2
int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
Process one common argument.
#define SDL_SetRenderDrawBlendMode
static void DrawRects(SDL_Renderer *renderer)
#define SDL_IntersectRect
SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
Open test window.
void DrawPoints(SDL_Renderer *renderer)
#define SDL_RenderFillRects
void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done)
Common event handler for test windows.
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
static SDL_Renderer * renderer
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
#define SDL_RenderGetViewport
GLubyte GLubyte GLubyte GLubyte w
SDL_Rect lines[MAX_LINES]
static void DrawRectRectIntersections(SDL_Renderer *renderer)
static int add_line(int x1, int y1, int x2, int y2)
GLint GLint GLint GLint GLint GLint y
const char * SDLTest_CommonUsage(SDLTest_CommonState *state)
Returns common usage information.
SDL_Renderer ** renderers
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_LogSetPriority
static void DrawRectLineIntersections(SDL_Renderer *renderer)
SDL_MouseButtonEvent button
static SDL_bool cycle_color
#define SDL_SetRenderDrawColor
static int add_rect(int x1, int y1, int x2, int y2)
EGLSurface EGLint * rects
#define SDL_IntersectRectAndLine
static SDLTest_CommonState * state
#define SDL_RenderDrawLine
void SDLTest_CommonQuit(SDLTest_CommonState *state)
Close test window.
A rectangle, with the origin at the upper left.
#define SDL_RenderPresent