-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathframe-family.c
58 lines (48 loc) · 1.43 KB
/
frame-family.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "SDL.h"
#include "KW_gui.h"
#include "KW_frame.h"
#include "KW_label.h"
#include "KW_renderdriver_sdl2.h"
int main(int argc, char ** argv) {
/* initialize window and renderer */
KW_RenderDriver * driver;
SDL_Window * window;
SDL_Renderer * renderer;
KW_Surface * set;
KW_GUI * gui;
KW_Font * font;
KW_Rect framegeom, labelgeom;
KW_Widget * frame;
SDL_Init(SDL_INIT_EVERYTHING);
SDL_CreateWindowAndRenderer(320, 240, 0, &window, &renderer);
SDL_SetRenderDrawColor(renderer, 200, 100, 100, 1);
driver = KW_CreateSDL2RenderDriver(renderer, window);
/* load tileset */
set = KW_LoadSurface(driver, "tileset.png");
/* initialize gui */
gui = KW_Init(driver, set);
font = KW_LoadFont(driver, "Fontin-Regular.ttf", 12);
KW_SetFont(gui, font);
framegeom.x = 10, framegeom.y = 10, framegeom.w = 160, framegeom.h = 120;
labelgeom = framegeom; labelgeom.x = labelgeom.y = 0;
/* create 10 frames and 10 labels */
frame = NULL;
for (int i = 0; i < 10; i++) {
frame = KW_CreateFrame(gui, frame, &framegeom);
KW_CreateLabel(gui, frame, "Yay", &labelgeom);
}
while (!SDL_QuitRequested()) {
SDL_RenderClear(renderer);
KW_ProcessEvents(gui);
KW_Paint(gui);
SDL_RenderPresent(renderer);
SDL_Delay(1);
}
/* free stuff */
KW_Quit(gui);
KW_ReleaseFont(driver, font);
KW_ReleaseSurface(driver, set);
KW_ReleaseRenderDriver(driver);
SDL_Quit();
return 0;
}