testgesture.c File Reference
`#include "SDL.h"`
`#include <stdlib.h>`
Include dependency graph for testgesture.c:

Go to the source code of this file.

## Data Structures

struct | Point
struct | Knob

## Macros

#define | WIDTH 640
#define | HEIGHT 480
#define | BPP 4
#define | EVENT_BUF_SIZE 256
#define | VERBOSE 0

## Functions

void | setpix (SDL_Surface *screen, float _x, float _y, unsigned int col)
void | drawLine (SDL_Surface *screen, float x0, float y0, float x1, float y1, unsigned int col)
void | drawCircle (SDL_Surface *screen, float x, float y, float r, unsigned int c)
void | drawKnob (SDL_Surface *screen, Knob k)
void | DrawScreen (SDL_Surface *screen, SDL_Window *window)
SDL_Window * | initWindow (SDL_Window *window, int width, int height)
void | loop ()
int | main (int argc, char *argv[])

## Variables

static SDL_Event | events [EVENT_BUF_SIZE]
static int | eventWrite
static int | colors [7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF}
SDL_Surface * | screen
SDL_Window * | window
SDL_bool | quitting = SDL_FALSE
static Knob | knob

## Macro Definition Documentation

## BPP

#define BPP 4

Definition at line 27 of file testgesture.c.

Referenced by setpix().

## EVENT_BUF_SIZE

#define EVENT_BUF_SIZE 256

Definition at line 30 of file testgesture.c.

Referenced by DrawScreen(), and loop().

## HEIGHT

#define HEIGHT 480

Definition at line 26 of file testgesture.c.

Referenced by main().

## VERBOSE

#define VERBOSE 0

Definition at line 33 of file testgesture.c.

## WIDTH

#define WIDTH 640

Definition at line 25 of file testgesture.c.

Referenced by main().

## Function Documentation

## drawCircle()

void drawCircle | ( | SDL_Surface * | screen,
|  | float | x,
|  | float | y,
|  | float | r,
|  | unsigned int | c
| ) |  |

Definition at line 92 of file testgesture.c.

References SDL_fabs, SDL_sqrt, and setpix().

Referenced by drawKnob(), and DrawScreen().

{
float tx,ty;
float xr;
for(ty = (float)-SDL_fabs(r);ty <= (float)SDL_fabs((int)r);ty++) {
xr = (float)SDL_sqrt(r*r - ty*ty);
if(r > 0) { /* r > 0 ==> filled circle */
for(tx=-xr+.5f;tx<=xr-.5;tx++) {
setpix(screen,x+tx,y+ty,c);
}
}
else {
setpix(screen,x-xr+.5f,y+ty,c);
setpix(screen,x+xr-.5f,y+ty,c);
}
}
}
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
SDL_fabs
#define SDL_fabs
Definition: SDL_dynapi_overrides.h:430
f
GLfloat f
Definition: SDL_opengl_glext.h:1870
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
setpix
void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col)
Definition: testgesture.c:56
SDL_sqrt
#define SDL_sqrt
Definition: SDL_dynapi_overrides.h:437
ty
GLbyte ty
Definition: SDL_opengl_glext.h:5972

## drawKnob()

void drawKnob | ( | SDL_Surface * | screen,
|  | Knob | k
| ) |  |

Definition at line 110 of file testgesture.c.

References Knob::ang, drawCircle(), SDL_Surface::h, Knob::p, Knob::r, SDL_cosf, SDL_sinf, SDL_Surface::w, Point::x, and Point::y.

Referenced by DrawScreen().

{
drawCircle(screen,k.p.x*screen->w,k.p.y*screen->h,k.r*screen->w,0xFFFFFF);
drawCircle(screen,(k.p.x+k.r/2*SDL_cosf(k.ang))*screen->w,
(k.p.y+k.r/2*SDL_sinf(k.ang))*screen->h,k.r/4*screen->w,0);
}
SDL_sinf
#define SDL_sinf
Definition: SDL_dynapi_overrides.h:436
SDL_Surface::h
int h
Definition: SDL_surface.h:73
drawCircle
void drawCircle(SDL_Surface *screen, float x, float y, float r, unsigned int c)
Definition: testgesture.c:92
SDL_Surface::w
int w
Definition: SDL_surface.h:73
Knob::r
float r
Definition: testgesture.c:50
Point::x
float x
Definition: testgesture.c:46
Knob::p
Point p
Definition: testgesture.c:51
SDL_cosf
#define SDL_cosf
Definition: SDL_dynapi_overrides.h:429
Point::y
float y
Definition: testgesture.c:46
Knob::ang
float ang
Definition: testgesture.c:50

## drawLine()

void drawLine | ( | SDL_Surface * | screen,
|  | float | x0,
|  | float | y0,
|  | float | x1,
|  | float | y1,
|  | unsigned int | col
| ) |  |

Definition at line 86 of file testgesture.c.

References SDL_fabs, SDL_max, and setpix().

{
float t;
for(t=0;t<1;t+=(float)(1.f/SDL_max(SDL_fabs(x0-x1),SDL_fabs(y0-y1))))
setpix(screen,x1+t*(x0-x1),y1+t*(y0-y1),col);
}
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
SDL_fabs
#define SDL_fabs
Definition: SDL_dynapi_overrides.h:430
f
GLfloat f
Definition: SDL_opengl_glext.h:1870
SDL_max
#define SDL_max(x, y)
Definition: SDL_stdinc.h:407
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
setpix
void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col)
Definition: testgesture.c:56
y0
GLuint GLfloat GLfloat y0
Definition: SDL_opengl_glext.h:8583
x0
GLuint GLfloat x0
Definition: SDL_opengl_glext.h:8583
t
GLdouble GLdouble t
Definition: SDL_opengl.h:2071

## DrawScreen()

void DrawScreen | ( | SDL_Surface * | screen,
|  | SDL_Window * | window
| ) |  |

Definition at line 116 of file testgesture.c.

References colors, drawCircle(), drawKnob(), EVENT_BUF_SIZE, eventWrite, SDL_Surface::h, i, NULL, Knob::p, SDL_FillRect, SDL_FINGERDOWN, SDL_FINGERMOTION, SDL_FINGERUP, SDL_UpdateWindowSurface, setpix(), SDL_Surface::w, and Point::x.

Referenced by loop().

{
int i;
#if 1
SDL_FillRect(screen, NULL, 0);
#else
int x, y;
for(y = 0;y < screen->h;y++)
for(x = 0;x < screen->w;x++)
setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
#endif
/* draw Touch History */
for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) {
const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)];
float age = (float)(i - eventWrite) / EVENT_BUF_SIZE;
float x, y;
unsigned int c, col;
if(event->type == SDL_FINGERMOTION ||
event->type == SDL_FINGERDOWN ||
event->type == SDL_FINGERUP) {
x = event->tfinger.x;
y = event->tfinger.y;
/* draw the touch: */
c = colors[event->tfinger.fingerId%7];
col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24;
if(event->type == SDL_FINGERMOTION)
drawCircle(screen,x*screen->w,y*screen->h,5,col);
else if(event->type == SDL_FINGERDOWN)
drawCircle(screen,x*screen->w,y*screen->h,-10,col);
}
}
if(knob.p.x > 0)
drawKnob(screen,knob);
SDL_UpdateWindowSurface(window);
}
SDL_Surface::h
int h
Definition: SDL_surface.h:73
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
events
static SDL_Event events[EVENT_BUF_SIZE]
Definition: testgesture.c:35
knob
static Knob knob
Definition: testgesture.c:54
drawCircle
void drawCircle(SDL_Surface *screen, float x, float y, float r, unsigned int c)
Definition: testgesture.c:92
SDL_Surface::w
int w
Definition: SDL_surface.h:73
SDL_UpdateWindowSurface
#define SDL_UpdateWindowSurface
Definition: SDL_dynapi_overrides.h:541
SDL_FINGERDOWN
Definition: SDL_events.h:125
eventWrite
static int eventWrite
Definition: testgesture.c:36
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093
EVENT_BUF_SIZE
#define EVENT_BUF_SIZE
Definition: testgesture.c:30
Point::x
float x
Definition: testgesture.c:46
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
Knob::p
Point p
Definition: testgesture.c:51
drawKnob
void drawKnob(SDL_Surface *screen, Knob k)
Definition: testgesture.c:110
SDL_FINGERMOTION
Definition: SDL_events.h:127
setpix
void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col)
Definition: testgesture.c:56
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 in i)
Definition: SDL_x11sym.h:50
NULL
#define NULL
Definition: begin_code.h:164
SDL_FINGERUP
Definition: SDL_events.h:126
SDL_FillRect
#define SDL_FillRect
Definition: SDL_dynapi_overrides.h:466
SDL_Event
General event structure.
Definition: SDL_events.h:525
colors
static int colors[7]
Definition: testgesture.c:39

## initWindow()

SDL_Window* initWindow | ( | SDL_Window * | window,
|  | int | width,
|  | int | height
| ) |  |

Definition at line 159 of file testgesture.c.

References SDL_CreateWindow, SDL_WINDOW_RESIZABLE, SDL_WINDOWPOS_CENTERED, and window.

Referenced by loop(), and main().

{
if (!window) {
window = SDL_CreateWindow("Gesture Test",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
width, height, SDL_WINDOW_RESIZABLE);
}
return window;
}
SDL_WINDOWPOS_CENTERED
#define SDL_WINDOWPOS_CENTERED
Definition: SDL_video.h:139
SDL_CreateWindow
#define SDL_CreateWindow
Definition: SDL_dynapi_overrides.h:514
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
window
SDL_Window * window
Definition: testgesture.c:42
SDL_WINDOW_RESIZABLE
Definition: SDL_video.h:105
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572

## loop()

void loop | ( |  | ) |

Definition at line 169 of file testgesture.c.

References Knob::ang, SDL_WindowEvent::data1, SDL_WindowEvent::data2, SDL_MultiGestureEvent::dDist, SDL_Event::dgesture, DrawScreen(), SDL_MultiGestureEvent::dTheta, SDL_DollarGestureEvent::error, SDL_WindowEvent::event, EVENT_BUF_SIZE, eventWrite, SDL_TouchFingerEvent::fingerId, SDL_DollarGestureEvent::gestureId, i, initWindow(), SDL_Event::key, SDL_KeyboardEvent::keysym, SDL_Event::mgesture, SDL_MultiGestureEvent::numFingers, Knob::p, quitting, Knob::r, SDL_DOLLARGESTURE, SDL_DOLLARRECORD, SDL_FINGERDOWN, SDL_FINGERMOTION, SDL_FINGERUP, SDL_GetNumTouchDevices, SDL_GetNumTouchFingers, SDL_GetTouchDevice, SDL_GetWindowSurface, SDL_KEYDOWN, SDL_LoadDollarTemplates, SDL_Log, SDL_MULTIGESTURE, SDL_PollEvent, SDL_PRIs64, SDL_Quit, SDL_QUIT, SDL_RecordGesture, SDL_RWclose, SDL_RWFromFile, SDL_SaveAllDollarTemplates, SDL_TRUE, SDL_WINDOWEVENT, SDL_WINDOWEVENT_RESIZED, SDLK_ESCAPE, SDLK_i, SDLK_l, SDLK_s, SDLK_SPACE, SDL_Keysym::sym, SDL_Event::tfinger, SDL_Event::type, SDL_Event::window, Point::x, SDL_TouchFingerEvent::x, SDL_MultiGestureEvent::x, Point::y, SDL_TouchFingerEvent::y, and SDL_MultiGestureEvent::y.

Referenced by main().

{
SDL_Event event;
SDL_RWops *stream;
while(SDL_PollEvent(&event))
{
/* Record _all_ events */
events[eventWrite & (EVENT_BUF_SIZE-1)] = event;
eventWrite++;
switch (event.type)
{
case SDL_QUIT:
quitting = SDL_TRUE;
break;
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_i:
{
int i;
for (i = 0; i < SDL_GetNumTouchDevices(); ++i) {
SDL_TouchID id = SDL_GetTouchDevice(i);
SDL_Log("Fingers Down on device %"SDL_PRIs64": %d", id, SDL_GetNumTouchFingers(id));
}
break;
}
case SDLK_SPACE:
SDL_RecordGesture(-1);
break;
case SDLK_s:
stream = SDL_RWFromFile("gestureSave", "w");
SDL_Log("Wrote %i templates", SDL_SaveAllDollarTemplates(stream));
SDL_RWclose(stream);
break;
case SDLK_l:
stream = SDL_RWFromFile("gestureSave", "r");
SDL_Log("Loaded: %i", SDL_LoadDollarTemplates(-1, stream));
SDL_RWclose(stream);
break;
case SDLK_ESCAPE:
quitting = SDL_TRUE;
break;
}
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
if (!(window = initWindow(window, event.window.data1, event.window.data2)) ||
!(screen = SDL_GetWindowSurface(window)))
{
SDL_Quit();
exit(1);
}
}
break;
case SDL_FINGERMOTION:
#if VERBOSE
SDL_Log("Finger: %"SDL_PRIs64",x: %f, y: %f",event.tfinger.fingerId,
event.tfinger.x,event.tfinger.y);
#endif
break;
case SDL_FINGERDOWN:
#if VERBOSE
SDL_Log("Finger: %"SDL_PRIs64" down - x: %f, y: %f",
event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
#endif
break;
case SDL_FINGERUP:
#if VERBOSE
SDL_Log("Finger: %"SDL_PRIs64" up - x: %f, y: %f",
event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
#endif
break;
case SDL_MULTIGESTURE:
#if VERBOSE
SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f",
event.mgesture.x,
event.mgesture.y,
event.mgesture.dTheta,
event.mgesture.dDist);
SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers);
#endif
knob.p.x = event.mgesture.x;
knob.p.y = event.mgesture.y;
knob.ang += event.mgesture.dTheta;
knob.r += event.mgesture.dDist;
break;
case SDL_DOLLARGESTURE:
SDL_Log("Gesture %"SDL_PRIs64" performed, error: %f",
event.dgesture.gestureId,
event.dgesture.error);
break;
case SDL_DOLLARRECORD:
SDL_Log("Recorded gesture: %"SDL_PRIs64"",event.dgesture.gestureId);
break;
}
}
DrawScreen(screen, window);
#ifdef __EMSCRIPTEN__
if (quitting) {
emscripten_cancel_main_loop();
}
#endif
}
initWindow
SDL_Window * initWindow(SDL_Window *window, int width, int height)
Definition: testgesture.c:159
SDL_PollEvent
#define SDL_PollEvent
Definition: SDL_dynapi_overrides.h:122
SDL_KEYDOWN
Definition: SDL_events.h:93
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_Event::dgesture
SDL_DollarGestureEvent dgesture
Definition: SDL_events.h:550
SDL_RecordGesture
#define SDL_RecordGesture
Definition: SDL_dynapi_overrides.h:155
screen
SDL_Surface * screen
Definition: testgesture.c:41
SDL_RWops
Definition: SDL_rwops.h:52
events
static SDL_Event events[EVENT_BUF_SIZE]
Definition: testgesture.c:35
SDL_QUIT
Definition: SDL_events.h:60
quitting
SDL_bool quitting
Definition: testgesture.c:43
knob
static Knob knob
Definition: testgesture.c:54
SDL_MultiGestureEvent::dDist
float dDist
Definition: SDL_events.h:436
SDL_MultiGestureEvent::y
float y
Definition: SDL_events.h:438
SDL_GetNumTouchDevices
#define SDL_GetNumTouchDevices
Definition: SDL_dynapi_overrides.h:489
SDL_DollarGestureEvent::gestureId
SDL_GestureID gestureId
Definition: SDL_events.h:452
SDL_DollarGestureEvent::error
float error
Definition: SDL_events.h:454
SDLK_i
Definition: SDL_keycode.h:108
Knob::r
float r
Definition: testgesture.c:50
SDLK_s
Definition: SDL_keycode.h:118
SDL_DOLLARGESTURE
Definition: SDL_events.h:130
SDL_Event::window
SDL_WindowEvent window
Definition: SDL_events.h:529
SDL_GetTouchDevice
#define SDL_GetTouchDevice
Definition: SDL_dynapi_overrides.h:490
SDL_Log
#define SDL_Log
Definition: SDL_dynapi_overrides.h:31
SDL_RWFromFile
#define SDL_RWFromFile
Definition: SDL_dynapi_overrides.h:351
SDL_FINGERDOWN
Definition: SDL_events.h:125
SDL_PRIs64
#define SDL_PRIs64
Definition: SDL_stdinc.h:205
eventWrite
static int eventWrite
Definition: testgesture.c:36
stream
GLuint GLuint stream
Definition: SDL_opengl_glext.h:1776
SDL_TouchFingerEvent::x
float x
Definition: SDL_events.h:419
SDL_MultiGestureEvent::numFingers
Uint16 numFingers
Definition: SDL_events.h:439
SDL_Event::mgesture
SDL_MultiGestureEvent mgesture
Definition: SDL_events.h:549
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_Quit
#define SDL_Quit
Definition: SDL_dynapi_overrides.h:58
SDL_SaveAllDollarTemplates
#define SDL_SaveAllDollarTemplates
Definition: SDL_dynapi_overrides.h:156
SDL_WindowEvent::data2
Sint32 data2
Definition: SDL_events.h:184
SDL_WINDOWEVENT
Definition: SDL_events.h:89
SDL_GetWindowSurface
#define SDL_GetWindowSurface
Definition: SDL_dynapi_overrides.h:540
EVENT_BUF_SIZE
#define EVENT_BUF_SIZE
Definition: testgesture.c:30
SDL_TouchID
Sint64 SDL_TouchID
Definition: SDL_touch.h:41
Point::x
float x
Definition: testgesture.c:46
SDL_GetNumTouchFingers
#define SDL_GetNumTouchFingers
Definition: SDL_dynapi_overrides.h:491
Knob::p
Point p
Definition: testgesture.c:51
SDL_WindowEvent::event
Uint8 event
Definition: SDL_events.h:179
SDL_KeyboardEvent::keysym
SDL_Keysym keysym
Definition: SDL_events.h:199
SDL_FINGERMOTION
Definition: SDL_events.h:127
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 in i)
Definition: SDL_x11sym.h:50
SDL_MultiGestureEvent::dTheta
float dTheta
Definition: SDL_events.h:435
SDL_RWclose
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189
SDL_FINGERUP
Definition: SDL_events.h:126
SDL_LoadDollarTemplates
#define SDL_LoadDollarTemplates
Definition: SDL_dynapi_overrides.h:158
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_Event::key
SDL_KeyboardEvent key
Definition: SDL_events.h:530
SDL_MultiGestureEvent::x
float x
Definition: SDL_events.h:437
SDL_TouchFingerEvent::y
float y
Definition: SDL_events.h:420
Point::y
float y
Definition: testgesture.c:46
SDL_TouchFingerEvent::fingerId
SDL_FingerID fingerId
Definition: SDL_events.h:418
SDL_Keysym::sym
SDL_Keycode sym
Definition: SDL_keyboard.h:50
SDL_Event
General event structure.
Definition: SDL_events.h:525
SDL_WINDOWEVENT_RESIZED
Definition: SDL_video.h:155
Knob::ang
float ang
Definition: testgesture.c:50
SDLK_ESCAPE
Definition: SDL_keycode.h:55
SDL_WindowEvent::data1
Sint32 data1
Definition: SDL_events.h:183
DrawScreen
void DrawScreen(SDL_Surface *screen, SDL_Window *window)
Definition: testgesture.c:116
SDLK_l
Definition: SDL_keycode.h:111
SDLK_SPACE
Definition: SDL_keycode.h:58
SDL_DOLLARRECORD
Definition: SDL_events.h:131
SDL_Event::type
Uint32 type
Definition: SDL_events.h:527
SDL_MULTIGESTURE
Definition: SDL_events.h:132
SDL_Event::tfinger
SDL_TouchFingerEvent tfinger
Definition: SDL_events.h:548

## main()

int main | ( | int | argc,
|  | char * | argv[]
| ) |  |

Definition at line 276 of file testgesture.c.

References Knob::ang, HEIGHT, initWindow(), loop(), NULL, quitting, Knob::r, SDL_FALSE, SDL_GetWindowSurface, SDL_Init, SDL_INIT_VIDEO, SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, SDL_LogSetPriority, SDL_Quit, and WIDTH.

{
window = NULL;
screen = NULL;
quitting = SDL_FALSE;
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* gesture variables */
knob.r = .1f;
knob.ang = 0;
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
if (!(window = initWindow(window, WIDTH, HEIGHT)) ||
!(screen = SDL_GetWindowSurface(window)))
{
SDL_Quit();
return 1;
}
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
while(!quitting) {
loop();
}
#endif
SDL_Quit();
return 0;
}
initWindow
SDL_Window * initWindow(SDL_Window *window, int width, int height)
Definition: testgesture.c:159
screen
SDL_Surface * screen
Definition: testgesture.c:41
SDL_FALSE
Definition: SDL_stdinc.h:141
quitting
SDL_bool quitting
Definition: testgesture.c:43
knob
static Knob knob
Definition: testgesture.c:54
Knob::r
float r
Definition: testgesture.c:50
loop
void loop()
Definition: testgesture.c:169
SDL_Quit
#define SDL_Quit
Definition: SDL_dynapi_overrides.h:58
SDL_GetWindowSurface
#define SDL_GetWindowSurface
Definition: SDL_dynapi_overrides.h:540
WIDTH
#define WIDTH
Definition: testgesture.c:25
SDL_LOG_PRIORITY_INFO
Definition: SDL_log.h:106
SDL_LogSetPriority
#define SDL_LogSetPriority
Definition: SDL_dynapi_overrides.h:236
NULL
#define NULL
Definition: begin_code.h:164
HEIGHT
#define HEIGHT
Definition: testgesture.c:26
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_Init
#define SDL_Init
Definition: SDL_dynapi_overrides.h:54
Knob::ang
float ang
Definition: testgesture.c:50
SDL_LOG_CATEGORY_APPLICATION
Definition: SDL_log.h:66
SDL_INIT_VIDEO
#define SDL_INIT_VIDEO
Definition: SDL.h:78

## setpix()

void setpix | ( | SDL_Surface * | screen,
|  | float | _x,
|  | float | _y,
|  | unsigned int | col
| ) |  |

Definition at line 56 of file testgesture.c.

References BPP, SDL_PixelFormat::BytesPerPixel, SDL_Surface::format, SDL_Surface::h, SDL_Surface::pitch, SDL_Surface::pixels, SDL_GetRGB, SDL_MapRGB, SDL_memcpy, and SDL_Surface::w.

Referenced by drawCircle(), drawLine(), and DrawScreen().

{
Uint32 *pixmem32;
Uint32 colour;
Uint8 r,g,b;
int x = (int)_x;
int y = (int)_y;
float a;
if(x < 0 || x >= screen->w) return;
if(y < 0 || y >= screen->h) return;
pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x;
SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel);
SDL_GetRGB(colour,screen->format,&r,&g,&b);
/* r = 0;g = 0; b = 0; */
a = (float)((col>>24)&0xFF);
if(a == 0) a = 0xFF; /* Hack, to make things easier. */
a /= 0xFF;
r = (Uint8)(r*(1-a) + ((col>>16)&0xFF)*(a));
g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a));
b = (Uint8)(b*(1-a) + ((col>> 0)&0xFF)*(a));
colour = SDL_MapRGB( screen->format,r, g, b);
*pixmem32 = colour;
}
SDL_GetRGB
#define SDL_GetRGB
Definition: SDL_dynapi_overrides.h:288
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_Surface::h
int h
Definition: SDL_surface.h:73
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
SDL_PixelFormat::BytesPerPixel
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
SDL_Surface::w
int w
Definition: SDL_surface.h:73
BPP
#define BPP
Definition: testgesture.c:27
SDL_memcpy
#define SDL_memcpy
Definition: SDL_dynapi_overrides.h:387
SDL_Surface::pixels
void * pixels
Definition: SDL_surface.h:75
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:157
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_MapRGB
#define SDL_MapRGB
Definition: SDL_dynapi_overrides.h:286
SDL_Surface::pitch
int pitch
Definition: SDL_surface.h:74
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

## Variable Documentation

## colors

int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF}

static

Definition at line 39 of file testgesture.c.

Referenced by DrawScreen(), MapNto1(), SDL_LoadBMP_RW(), and SDL_SaveBMP_RW().

## events

SDL_Event events[EVENT_BUF_SIZE]

static

Definition at line 35 of file testgesture.c.

Referenced by IsSDLWindowEventPending(), and UpdateEventsForDeviceRemoval().

## eventWrite

int eventWrite

static

Definition at line 36 of file testgesture.c.

Referenced by DrawScreen(), and loop().

## knob

Knob knob

static

Definition at line 54 of file testgesture.c.

## quitting

SDL_bool quitting = SDL_FALSE

Definition at line 43 of file testgesture.c.

Referenced by loop(), and main().

## screen

SDL_Surface* screen

Definition at line 41 of file testgesture.c.

## window

SDL_Window* window

Definition at line 42 of file testgesture.c.

Referenced by initWindow().