ScummVM API documentation
gfx.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef AGS_LIB_ALLEGRO_GRAPHICS_H
23#define AGS_LIB_ALLEGRO_GRAPHICS_H
24
25#include "graphics/managed_surface.h"
26#include "ags/lib/allegro/base.h"
27#include "ags/lib/allegro/fixed.h"
28#include "ags/lib/allegro/surface.h"
29#include "common/array.h"
30
31namespace AGS3 {
32
33#define GFX_TEXT -1
34#define GFX_AUTODETECT 0
35#define GFX_AUTODETECT_FULLSCREEN 1
36#define GFX_AUTODETECT_WINDOWED 2
37#define GFX_SAFE AL_ID('S','A','F','E')
38#define GFX_NONE AL_ID('N','O','N','E')
39
40/* Bitfield for relaying graphics driver type information */
41#define GFX_TYPE_UNKNOWN 0
42#define GFX_TYPE_WINDOWED 1
43#define GFX_TYPE_FULLSCREEN 2
44#define GFX_TYPE_DEFINITE 4
45#define GFX_TYPE_MAGIC 8
46
47/* drawing modes for draw_sprite_ex() */
48#define DRAW_SPRITE_NORMAL 0
49#define DRAW_SPRITE_LIT 1
50#define DRAW_SPRITE_TRANS 2
51
52/* flipping modes for draw_sprite_ex() */
53#define DRAW_SPRITE_NO_FLIP 0x0
54#define DRAW_SPRITE_H_FLIP 0x1
55#define DRAW_SPRITE_V_FLIP 0x2
56#define DRAW_SPRITE_VH_FLIP 0x3
57
58/* Blender mode defines, for the gfx_driver->set_blender_mode() function */
59#define blender_mode_none 0
60#define blender_mode_trans 1
61#define blender_mode_add 2
62#define blender_mode_burn 3
63#define blender_mode_color 4
64#define blender_mode_difference 5
65#define blender_mode_dissolve 6
66#define blender_mode_dodge 7
67#define blender_mode_hue 8
68#define blender_mode_invert 9
69#define blender_mode_luminance 10
70#define blender_mode_multiply 11
71#define blender_mode_saturation 12
72#define blender_mode_screen 13
73#define blender_mode_alpha 14
74
75
76#define SCREEN_W (gfx_driver ? gfx_driver->w : 0)
77#define SCREEN_H (gfx_driver ? gfx_driver->h : 0)
78
79#define VIRTUAL_W (screen ? screen->w : 0)
80#define VIRTUAL_H (screen ? screen->h : 0)
81
82#define COLORCONV_NONE 0
83
84#define COLORCONV_8_TO_15 1
85#define COLORCONV_8_TO_16 2
86#define COLORCONV_8_TO_24 4
87#define COLORCONV_8_TO_32 8
88
89#define COLORCONV_15_TO_8 0x10
90#define COLORCONV_15_TO_16 0x20
91#define COLORCONV_15_TO_24 0x40
92#define COLORCONV_15_TO_32 0x80
93
94#define COLORCONV_16_TO_8 0x100
95#define COLORCONV_16_TO_15 0x200
96#define COLORCONV_16_TO_24 0x400
97#define COLORCONV_16_TO_32 0x800
98
99#define COLORCONV_24_TO_8 0x1000
100#define COLORCONV_24_TO_15 0x2000
101#define COLORCONV_24_TO_16 0x4000
102#define COLORCONV_24_TO_32 0x8000
103
104#define COLORCONV_32_TO_8 0x10000
105#define COLORCONV_32_TO_15 0x20000
106#define COLORCONV_32_TO_16 0x40000
107#define COLORCONV_32_TO_24 0x80000
108
109#define COLORCONV_32A_TO_8 0x100000
110#define COLORCONV_32A_TO_15 0x200000
111#define COLORCONV_32A_TO_16 0x400000
112#define COLORCONV_32A_TO_24 0x800000
113
114#define COLORCONV_DITHER_PAL 0x1000000
115#define COLORCONV_DITHER_HI 0x2000000
116#define COLORCONV_KEEP_TRANS 0x4000000
117
118#define COLORCONV_DITHER (COLORCONV_DITHER_PAL | \
119 COLORCONV_DITHER_HI)
120
121#define COLORCONV_EXPAND_256 (COLORCONV_8_TO_15 | \
122 COLORCONV_8_TO_16 | \
123 COLORCONV_8_TO_24 | \
124 COLORCONV_8_TO_32)
125
126#define COLORCONV_REDUCE_TO_256 (COLORCONV_15_TO_8 | \
127 COLORCONV_16_TO_8 | \
128 COLORCONV_24_TO_8 | \
129 COLORCONV_32_TO_8 | \
130 COLORCONV_32A_TO_8)
131
132#define COLORCONV_EXPAND_15_TO_16 COLORCONV_15_TO_16
133
134#define COLORCONV_REDUCE_16_TO_15 COLORCONV_16_TO_15
135
136#define COLORCONV_EXPAND_HI_TO_TRUE (COLORCONV_15_TO_24 | \
137 COLORCONV_15_TO_32 | \
138 COLORCONV_16_TO_24 | \
139 COLORCONV_16_TO_32)
140
141#define COLORCONV_REDUCE_TRUE_TO_HI (COLORCONV_24_TO_15 | \
142 COLORCONV_24_TO_16 | \
143 COLORCONV_32_TO_15 | \
144 COLORCONV_32_TO_16)
145
146#define COLORCONV_24_EQUALS_32 (COLORCONV_24_TO_32 | \
147 COLORCONV_32_TO_24)
148
149#define COLORCONV_TOTAL (COLORCONV_EXPAND_256 | \
150 COLORCONV_REDUCE_TO_256 | \
151 COLORCONV_EXPAND_15_TO_16 | \
152 COLORCONV_REDUCE_16_TO_15 | \
153 COLORCONV_EXPAND_HI_TO_TRUE | \
154 COLORCONV_REDUCE_TRUE_TO_HI | \
155 COLORCONV_24_EQUALS_32 | \
156 COLORCONV_32A_TO_15 | \
157 COLORCONV_32A_TO_16 | \
158 COLORCONV_32A_TO_24)
159
160#define COLORCONV_PARTIAL (COLORCONV_EXPAND_15_TO_16 | \
161 COLORCONV_REDUCE_16_TO_15 | \
162 COLORCONV_24_EQUALS_32)
163
164#define COLORCONV_MOST (COLORCONV_EXPAND_15_TO_16 | \
165 COLORCONV_REDUCE_16_TO_15 | \
166 COLORCONV_EXPAND_HI_TO_TRUE | \
167 COLORCONV_REDUCE_TRUE_TO_HI | \
168 COLORCONV_24_EQUALS_32)
169
170#define COLORCONV_KEEP_ALPHA (COLORCONV_TOTAL \
171 & ~(COLORCONV_32A_TO_8 | \
172 COLORCONV_32A_TO_15 | \
173 COLORCONV_32A_TO_16 | \
174 COLORCONV_32A_TO_24))
175
176AL_FUNC(void, set_color_conversion, (int mode));
177AL_FUNC(int, get_color_conversion, ());
178AL_FUNC(int, set_gfx_mode, (int card, int w, int h, int depth));
179
180AL_FUNC(void, set_clip_rect, (BITMAP *bitmap, int x1, int y1, int x2, int y2));
181AL_FUNC(void, get_clip_rect, (BITMAP *bitmap, int *x1, int *y1, int *x2, int *y2));
182AL_FUNC(void, clear_bitmap, (BITMAP *bitmap));
183
184AL_FUNC(void, acquire_bitmap, (BITMAP *bitmap));
185AL_FUNC(void, release_bitmap, (BITMAP *bitmap));
186AL_FUNC(void, draw_sprite, (BITMAP *bmp, const BITMAP *sprite, int x, int y));
187AL_FUNC(void, stretch_sprite, (BITMAP *bmp, const BITMAP *sprite, int x, int y, int w, int h));
188
189extern void clear_to_color(BITMAP *bitmap, int color);
190extern int bitmap_color_depth(BITMAP *bmp);
191extern int bitmap_mask_color(BITMAP *bmp);
192extern void add_palette_if_needed(Graphics::ManagedSurface &surf);
193extern void blit(const BITMAP *src, BITMAP *dest, int src_x, int src_y, int dst_x, int dst_y, int width, int height);
194extern void masked_blit(const BITMAP *src, BITMAP *dest, int src_x, int src_y, int dst_x, int dst_y, int width, int height);
195extern void stretch_blit(const BITMAP *src, BITMAP *dest, int source_x, int source_y, int source_width, int source_height,
196 int dest_x, int dest_y, int dest_width, int dest_height);
197extern void masked_stretch_blit(const BITMAP *src, BITMAP *dest, int source_x, int source_y, int source_width, int source_height,
198 int dest_x, int dest_y, int dest_width, int dest_height);
199extern void draw_trans_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y);
200extern void draw_lit_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y, int color);
201extern void draw_sprite_h_flip(BITMAP *bmp, const BITMAP *sprite, int x, int y);
202extern void draw_sprite_v_flip(BITMAP *bmp, const BITMAP *sprite, int x, int y);
203extern void draw_sprite_vh_flip(BITMAP *bmp, const BITMAP *sprite, int x, int y);
204extern void rotate_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y, fixed angle);
205extern void pivot_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y, int cx, int cy, fixed angle);
206
207extern bool is_screen_bitmap(BITMAP *bmp);
208extern bool is_video_bitmap(BITMAP *bmp);
209extern bool is_linear_bitmap(BITMAP *bmp);
210extern bool is_same_bitmap(BITMAP *bmp1, BITMAP *bmp2);
211extern bool is_planar_bitmap(BITMAP *bmp);
212extern void bmp_select(BITMAP *bmp);
213extern byte *bmp_write_line(BITMAP *bmp, int line);
214extern void bmp_write8(byte *addr, int color);
215extern void bmp_write15(byte *addr, int color);
216extern void bmp_write16(byte *addr, int color);
217extern void bmp_write24(byte *addr, int color);
218extern void bmp_write32(byte *addr, int color);
219extern void memory_putpixel(BITMAP *bmp, int x, int y, int color);
220extern void putpixel(BITMAP *bmp, int x, int y, int color);
221extern void _putpixel(BITMAP *bmp, int x, int y, int color);
222extern void _putpixel15(BITMAP *bmp, int x, int y, int color);
223extern void _putpixel16(BITMAP *bmp, int x, int y, int color);
224extern void _putpixel24(BITMAP *bmp, int x, int y, int color);
225extern void _putpixel32(BITMAP *bmp, int x, int y, int color);
226extern int getpixel(const BITMAP *bmp, int x, int y);
227extern int _getpixel(const BITMAP *bmp, int x, int y);
228extern int _getpixel15(const BITMAP *bmp, int x, int y);
229extern int _getpixel16(const BITMAP *bmp, int x, int y);
230extern int _getpixel24(const BITMAP *bmp, int x, int y);
231extern int _getpixel32(const BITMAP *bmp, int x, int y);
232extern void line(BITMAP *bmp, int x1, int y_1, int x2, int y2, int color);
233extern void rect(BITMAP *bmp, int x1, int y_1, int x2, int y2, int color);
234extern void rectfill(BITMAP *bmp, int x1, int y_1, int x2, int y2, int color);
235extern void triangle(BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color);
236extern void circlefill(BITMAP *bmp, int x, int y, int radius, int color);
237
238} // namespace AGS3
239
240#endif
Definition: managed_surface.h:51