1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
25 Simple backend example.
32 static void redraw(GP_Backend
*self
)
34 GP_Pixmap
*pixmap
= self
->pixmap
;
35 GP_Pixel white_pixel
, black_pixel
;
37 black_pixel
= GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap
);
38 white_pixel
= GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap
);
40 GP_Fill(pixmap
, black_pixel
);
41 GP_Line(pixmap
, 0, 0, pixmap
->w
- 1, pixmap
->h
- 1, white_pixel
);
42 GP_Line(pixmap
, 0, pixmap
->h
- 1, pixmap
->w
- 1, 0, white_pixel
);
44 /* Update the backend screen */
48 int main(int argc
, char *argv
[])
51 const char *backend_opts
= "X11:100x100";
54 while ((opt
= getopt(argc
, argv
, "b:h")) != -1) {
57 backend_opts
= optarg
;
60 GP_BackendInit(NULL
, NULL
);
64 fprintf(stderr
, "Invalid paramter '%c'\n", opt
);
69 backend
= GP_BackendInit(backend_opts
, "Backend Example");
71 if (backend
== NULL
) {
72 fprintf(stderr
, "Failed to initialize backend\n");
82 GP_BackendWaitEvent(backend
, &ev
);
91 GP_BackendExit(backend
);
98 case GP_EV_SYS_RESIZE
:
99 GP_BackendResizeAck(backend
);
103 GP_BackendExit(backend
);
111 GP_BackendExit(backend
);