23 #include <emscripten/emscripten.h>
34 #define EVENT_BUF_SIZE 256
41 static int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF};
55 static Knob knob = { 0.0f, 0.1f, { 0.0f, 0.0f } };
64 const int x = (
int)_x;
65 const int y = (
int)_y;
79 a = (float) ((col >> 24) & 0xFF);
84 a = (
a == 0.0f) ? 1 : (
a / 255.0f);
85 r = (
Uint8) (
r * (1 -
a) + ((col >> 16) & 0xFF) *
a);
86 g = (
Uint8) (
g * (1 -
a) + ((col >> 8) & 0xFF) *
a);
87 b = (
Uint8) (
b * (1 -
a) + ((col >> 0) & 0xFF) *
a);
109 for(tx = -xr + 0.5f; tx <= xr - 0.5f; tx++) {
149 x =
event->tfinger.x;
150 y =
event->tfinger.y;
153 c =
colors[
event->tfinger.fingerId % 7];
154 col = ((
unsigned int) (
c * (0.1f + 0.85f))) | (
unsigned int) (0xFF * age) << 24;
185 switch (
event.type) {
187 switch (
event.key.keysym.sym) {
233 SDL_Log(
"Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f",
236 SDL_Log(
"MG: numDownTouch = %i",
event.mgesture.numFingers);
239 knob.
p.
x =
event.mgesture.x;
240 knob.
p.
y =
event.mgesture.y;
241 knob.
ang +=
event.mgesture.dTheta;
242 knob.
r +=
event.mgesture.dDist;
247 event.dgesture.gestureId,
event.dgesture.error);
262 #ifdef __EMSCRIPTEN__
264 emscripten_cancel_main_loop();
269 int main(
int argc,
char* argv[])
286 #ifdef __EMSCRIPTEN__
287 emscripten_set_main_loop(
loop, 0, 1);
#define SDL_GetNumTouchDevices
#define SDL_GetNumTouchFingers
#define SDL_GetTouchDevice
#define SDL_LoadDollarTemplates
#define SDL_RecordGesture
#define SDL_UpdateWindowSurface
#define SDL_SaveAllDollarTemplates
#define SDL_GetWindowSurface
GLint GLint GLint GLint GLint GLint y
GLdouble GLdouble GLdouble r
GLint GLint GLint GLint GLint x
GLboolean GLboolean GLboolean b
GLuint GLfloat GLfloat GLfloat x1
GLboolean GLboolean GLboolean GLboolean a
GLuint GLfloat GLfloat y0
void SDLTest_CommonQuit(SDLTest_CommonState *state)
Close test window.
SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv)
Easy argument handling when test app doesn't need any custom args.
void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done)
Common event handler for test windows.
SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
Open test window.
SDLTest_CommonState * SDLTest_CommonCreateState(char **argv, Uint32 flags)
Parse command line parameters and create common state.
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)
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 int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display int int int return Display long XVisualInfo int return Display Window Atom long long Bool Atom Atom int unsigned long unsigned long k)
EGLSurface EGLNativeWindowType * window
A collection of pixels used in software blitting.
The type used to identify a window.
const char * window_title
static void drawLine(SDL_Surface *screen, float x0, float y0, float x1, float y1, unsigned int col)
int main(int argc, char *argv[])
static void drawCircle(SDL_Surface *screen, float x, float y, float r, unsigned int c)
static void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col)
static void drawKnob(SDL_Surface *screen, const Knob *k)
static SDLTest_CommonState * state
static void DrawScreen(SDL_Window *window)
static SDL_Event events[EVENT_BUF_SIZE]
typedef int(__stdcall *FARPROC)()