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-2010 Jiri "BlueBear" Dluhos *
20 * <jiri.bluebear.dluhos@gmail.com> *
22 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
24 *****************************************************************************/
33 SDL_Surface
*display
= NULL
;
36 static GP_Coord x
= 10<<8;
37 static GP_Coord y
= 10<<8;
39 SDL_UserEvent timer_event
;
41 GP_Pixel red_pixel
, green_pixel
, blue_pixel
, white_pixel
;
43 static void draw(void)
45 GP_Context
*ctx
= &context
;
47 GP_Fill(ctx
, white_pixel
);
51 for (i
= 0; i
< 24; i
++) {
52 GP_FillRect_AA(ctx
, x
, y
+ ((10*i
)<<8),
53 x
+ (60<<8), y
+ ((10*i
)<<8) + 64*i
+ 64, 0);
55 GP_FillRect_AA(ctx
, x
+ (80<<8), y
+ ((10*i
)<<8) + 64,
56 x
+ (140<<8), y
+ ((10*i
)<<8) + 64*i
+ 128, 0);
58 GP_FillRect_AA(ctx
, x
+ (160<<8), y
+ ((10*i
)<<8) + 128,
59 x
+ (220<<8), y
+ ((10*i
)<<8) + 64*i
+ 192, 0);
61 GP_FillRect_AA(ctx
, x
+ (240<<8), y
+ ((10*i
)<<8) + 192,
62 x
+ (300<<8), y
+ ((10*i
)<<8) + 64*i
+ 256, 0);
63 printf("--------------------------------------------------------\n");
73 while (SDL_WaitEvent(&event
) > 0) {
76 switch (event
.key
.keysym
.sym
) {
94 context
.x_swap
= !context
.x_swap
;
98 context
.y_swap
= !context
.y_swap
;
102 context
.axes_swap
= !context
.axes_swap
;
118 int main(int argc
, char **argv
)
123 for (i
= 1; i
< argc
; i
++) {
124 if (strcmp(argv
[i
], "-16") == 0) {
126 } else if (strcmp(argv
[i
], "-24") == 0) {
131 if (SDL_Init(SDL_INIT_VIDEO
| SDL_INIT_TIMER
) != 0) {
132 fprintf(stderr
, "Could not initialize SDL: %s\n", SDL_GetError());
136 display
= SDL_SetVideoMode(320, 240, display_bpp
, SDL_SWSURFACE
);
137 if (display
== NULL
) {
138 fprintf(stderr
, "Could not open display: %s\n", SDL_GetError());
143 printf("Display surface properties:\n");
144 printf(" width: %4d, height: %4d, pitch: %4d\n",
145 display
->w
, display
->h
, display
->pitch
);
146 printf(" bits per pixel: %2d, bytes per pixel: %2d\n",
147 display
->format
->BitsPerPixel
, display
->format
->BytesPerPixel
);
149 GP_SDL_ContextFromSurface(&context
, display
);
151 red_pixel
= GP_ColorToContextPixel(GP_COL_RED
, &context
);
152 green_pixel
= GP_ColorToContextPixel(GP_COL_GREEN
, &context
);
153 blue_pixel
= GP_ColorToContextPixel(GP_COL_BLUE
, &context
);
154 white_pixel
= GP_ColorToContextPixel(GP_COL_WHITE
, &context
);