MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / main

Function main

deps/SDL2/Xcode-iOS/Demos/src/touch.c:75–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75int
76main(int argc, char *argv[])
77{
78
79 int x, y, dx, dy; /* mouse location */
80 Uint8 state; /* mouse (touch) state */
81 SDL_Event event;
82 SDL_Window *window; /* main window */
83 SDL_Renderer *renderer;
84 int done; /* does user want to quit? */
85 int w, h;
86
87 /* initialize SDL */
88 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
89 fatalError("Could not initialize SDL");
90 }
91
92 /* create main window and renderer */
93 window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI);
94 renderer = SDL_CreateRenderer(window, 0, 0);
95
96 SDL_GetWindowSize(window, &w, &h);
97 SDL_RenderSetLogicalSize(renderer, w, h);
98
99 /* load brush texture */
100 initializeTexture(renderer);
101
102 /* fill canvass initially with all black */
103 SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
104 SDL_RenderClear(renderer);
105 SDL_RenderPresent(renderer);
106
107 done = 0;
108 while (!done && SDL_WaitEvent(&event)) {
109 switch (event.type) {
110 case SDL_QUIT:
111 done = 1;
112 break;
113 case SDL_MOUSEMOTION:
114 state = SDL_GetMouseState(&x, &y); /* get its location */
115 SDL_GetRelativeMouseState(&dx, &dy); /* find how much the mouse moved */
116 if (state & SDL_BUTTON_LMASK) { /* is the mouse (touch) down? */
117 drawLine(renderer, x - dx, y - dy, dx, dy); /* draw line segment */
118 SDL_RenderPresent(renderer);
119 }
120 break;
121 }
122 }
123
124 /* cleanup */
125 SDL_DestroyTexture(brush);
126 SDL_Quit();
127
128 return 0;
129}

Callers

nothing calls this directly

Calls 15

SDL_InitFunction · 0.85
fatalErrorFunction · 0.85
SDL_CreateWindowFunction · 0.85
SDL_CreateRendererFunction · 0.85
SDL_GetWindowSizeFunction · 0.85
SDL_RenderSetLogicalSizeFunction · 0.85
SDL_SetRenderDrawColorFunction · 0.85
SDL_RenderClearFunction · 0.85
SDL_RenderPresentFunction · 0.85
SDL_WaitEventFunction · 0.85
SDL_GetMouseStateFunction · 0.85

Tested by

no test coverage detected