Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro 5 graphics API - take 6

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
Allegro 5 graphics API - take 6
Bob
Free Market Evangelist
September 2000
avatar

I had a bit more time to work on the API. Here's the current incarnation of it.

At the bottom, there are some examples of tasks you can do using the configuration system.

What it doesn't cover:
- Blending (esp 8bpp color maps)
- the GUI

Main changes:
- More consistent API
- More flexible
- Palettes are associated to bitmaps

1 
2/* Blitting
3 * 'flag' is a combination of:
4 * - AL_MASK_SOURCE - Ignore source pixels that are masked
5 * - AL_MASK_DEST - Ignore destination pixels that are masked
6 * - AL_TRANS_BLIT - Draws pixels tranlucently
7 * - AL_LIT_BLIT - Lits the source pixels with the current blend color before writting them to the destination.
8 * - AL_XOR_BLIT - xors the source with the destination
9 * - AL_HORIZONTAL_FLIP - Flips the source bitmap along the x axis
10 * - AL_VERTICAL_FLIP - Flips the source bitmap along the y axis
11 *
12 * Comments:
13 * - blit() or blit_bitmap()?
14 * - The flag parameter can be used to add more functionality (ex: asynchronous operations)
15 * - Reduction in the API from Allegro 4
16 * - However, more code will included in static builds.
17 */
18void al_blit (int flag, AL_BITMAP *source, AL_BITMAP *dest, int dest_x, int dest_y);
19void al_blit_clip(int flag, AL_BITMAP *source, AL_BITMAP* dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
20void al_blit_scale(int flag, AL_BITMAP *source, AL_BITMAP *dest, int source_x, int source_y, int source_w, int source_h, int dest_x, int dest_y, int dest_w, int dest_h);
21void al_rotate_bitmap(int flag, AL_BITMAP *source, int source_center_x, int source_center_y, int dest_x, int dest_y, float angle);
22void al_rotate_scale_bitmap(int flag, AL_BITMAP *source, int source_center_x, int source_center_y, int dest_x, int dest_y, float angle, float scale);
23 
24AL_BITMAP *al_create_display_bitmap(al_id_t card, int width, int height, al_id_t update_method);
25AL_BITMAP *al_create_video_bitmap(int flags, AL_BITMAP *display, int width, int height);
26AL_BITMAP *al_create_system_bitmap(AL_BITMAP *display, int width, int height);
27AL_BITMAP *al_create_bitmap(int width, int height, int depth);
28AL_BITMAP *al_create_rle_bitmap(AL_BITMAP *memory);
29AL_BITMAP *al_create_sub_bitmap(AL_BITMAP *parent, int x, int y, int w, int h);
30/* For video bitmaps,
31 * 'flag' can be:
32 * - AL_KEEP_MEMORY_COPY - Keeps a memory copy of the bitmap for auto-restoring of surfaces and for allowing windowed/fullscreen mode switches
33 */
34 
35 
36 
37/* Clipping */
38void al_set_bitmap_clip_region(AL_BITMAP *bitmap, int x, int y, int w, int h);
39 
40/* Updating the screen */
41void al_show_display_bitmap(AL_BITMAP *display);
42 
43/* Destroying */
44void al_destroy_bitmap(AL_BITMAP* display);
45 
46/* Bitmap locking */
47int al_acquire_bitmap(AL_BITMAP *bitmap);
48int al_release_bitmap(AL_BITMAP *bitmap);
49 
50/* Allegro primitives
51 *
52 * Flags can be:
53 * - AL_PRIMITIVE_FILLED
54 * - AL_PRIMITIVE_PATTERN
55 */
56AL_COLOR *al_get_pixel(AL_BITMAP *bmp, int x, int y, AL_COLOR *color);
57void al_put_pixel (AL_BITMAP *bitmap, int x, int y, AL_COLOR *color);
58int al_draw_line (AL_BITMAP *bitmap, int x1, int y1, int x2, int y2, AL_COLOR *color);
59void al_draw_hline(AL_BITMAP *bitmap, int x, int y, int width, AL_COLOR *color);
60void al_draw_vline(AL_BITMAP *bitmap, int x, int y, int height, AL_COLOR *color);
61void al_draw_triangle(int flag, AL_BITMAP *bitmap, int x1, int y1, int x2, int y2, int x3, int y3, AL_COLOR *color);
62void al_draw_polygon (int flag, AL_BITMAP *bitmap, int points[], int num_points, AL_COLOR *color);
63void al_draw_circle (int flag, AL_BITMAP *bitmap, int x, int y, int radius, AL_COLOR *color);
64void al_draw_rect (int flag, AL_BITMAP *bitmap, int x, int y, int width, int height, AL_COLOR *color);
65void al_draw_ellipse (int flag, AL_BITMAP *bitmap, int x, int y, int rx, int ry, AL_COLOR *color);
66void al_fill_shape (int flag, AL_BITMAP *bitmap, int x, int y, AL_COLOR *color);
67void al_clear_bitmap (AL_BITMAP *bmp, AL_COLOR *color);
68void al_set_pattern (int mode, AL_BITMAP *pattern, int anchor_x, int anchor_y);
69void al_get_pattern (int *mode, AL_BITMAP **pattern, int *anchor_x, int *anchor_y);
70 
71 
72/* Color mapping */
73AL_COLOR* al_map_rgba (AL_BITMAP *bmp, AL_COLOR *p, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
74AL_COLOR* al_map_rgba_f(AL_BITMAP *bmp, AL_COLOR *p, float r, float g, float b, float a);
75void al_unmap_rgba(AL_BITMAP *bmp, AL_COLOR *p, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a);
76 
77/* Bitmap information */
78int al_get_bitmap_color_depth(AL_BITMAP *bmp);
79AL_COLOR *al_get_bitmap_mask_color(AL_BITMAP *bmp, AL_COLOR *c);
80 
81int al_is_same_bitmap(AL_BITMAP *bmp1, AL_BITMAP *bmp2);
82int al_is_bitmap_of_type(AL_BITMAP *bmp, int type);
83 
84/* Palettes */
85void al_set_palette_color(AL_BITMAP *bmp, int index, const AL_COLOR *color);
86void al_set_palette_color_VGA(AL_BITMAP *bmp, int index, const AL_COLOR *color);
87void al_set_palette(AL_BITMAP *bmp, const AL_COLOR *palette);
88void al_set_palette_range(AL_BITMAP *bmp, const AL_COLOR *palette, int from, int to, int vsync);
89AL_COLOR *al_get_palette_color(AL_BITMAP *bmp, int index, AL_COLOR *p);
90void al_get_palette(AL_BITMAP *bmp, AL_COLOR *palette);
91void al_get_palette_range(AL_BITMAP *bmp, AL_COLOR *palette, int from, int to);
92int al_compute_palette_conversion_table(AL_BITMAP *bmp, AL_RGB_MAP *map);
93void al_set_palette_conversion_table(AL_BITMAP *bmp, AL_RGB_MAP *map);
94 
95/* Loading and saving */
96AL_BITMAP *al_load_bitmap(const char *filename);
97int al_save_bitmap(AL_BITMAP *bmp, const char *filename);
98/* Note: bitmap types can be registered via register_driver */
99 
100 
101/* Low-level bitmap access */
102int al_select_read_bitmap_region (AL_BITMAP *bitmap, int x, int y, int width, int height);
103int al_select_write_bitmap_region(AL_BITMAP *bitmap, int x, int y, int width, int height);
104int al_unselect_read_bitmap_region (AL_BITMAP *bitmap);
105int al_unselect_write_bitmap_region(AL_BITMAP *bitmap);
106void *al_map_bitmap_linear_address(AL_BITMAP *bitmap, int x, int y);
107void al_bitmap_write_8 (void *address, unsigned char value);
108void al_bitmap_write_16(void *address, unsigned short value);
109void al_bitmap_write_32(void *address, unsigned int value);
110unsigned char al_bitmap_read_8 (void *address);
111unsigned short al_bitmap_read_16(void *address);
112unsigned int al_bitmap_read_32(void *address);
113 
114 
115 
116/* Text/font operations
117 * Flag can be:
118 * - AL_TEXT_CENTER
119 * - AL_TEXT_RIGHT
120 * - AL_TEXT_JUSTIFY
121 */
122void al_draw_text(int flag, AL_BITMAP *bitmap, AL_FONT *font, int x, int y, AL_COLOR *fg_color, const char *format, ...);
123/* Note: to draw with a solid backgroud, use al_draw_rect(AL_PRIMITIVE_FILLED, ...) beforehand */
124 
125int al_get_text_width (const AL_FONT *f, const char *str);
126int al_get_text_height(const AL_FONT *f, const char *str);
127 
128 
129AL_FONT *al_create_font();
130void al_set_character_bitmap(AL_FONT *font, int character, AL_BITMAP *bmp);
131void al_destroy_font(AL_FONT *font);
132AL_FONT *al_get_default_font();
133 
134 
135typedef struct AL_COLOR {
136 unsigned long raw[4]; /* 128 bit fragments */
137} AL_COLOR;
138 
139 
140/*
141
142Configuration routines:
143
144gfx
145 |- system
146 |- num_display_devices Number of display devices on the system (multiple monitors)
147 |- num_display_drivers Number of display drivers Allegro can use (AL_GFX_*)
148 |- current
149 |- display_device Current display device for display bitmap creation and for information retreival
150 |- display_bitmap Currently selected bitmap to change parameters
151 |- color_space Current color space for newly created bitmaps
152 |- color_depth Current color depth for newly created bitmaps
153 |- window_x X Position of the window on the desktop (in pixels)
154 |- window_y Y Position of the window on the desktop (in pixels)
155 |- window_scale_x X scaling factor of the window
156 |- window_scale_y Y scaling factor of the window
157 |- resizable Allow for resize
158 |- windowed Display bitmap is a window
159 |- refresh_rate Monitor refresh rate, in Hz
160 |- overlay Request an overlayed mode
161 |- query
162 (similar to ../current, but values are read-only)
163 |- driver Selects the current driver for query
164 |- valid Indicates that the druver or display device query is valid
165 |- width Width, in pixels
166 |- height Height, in pixels
167 |- name Name of the current device or driver
168 |- refresh_rate Monitor refresh rate, in Hz
169 |- max_refresh_rate The maxium refresh rate available
170*/
171 
172 
173 
174Configuration system howto:
175 
176- Enumerate all Allegro display drivers:
177 int num = al_get_int("gfx/system/num_display_drivers");
178 for (i = 0; i < num; i++) {
179 al_set_int("gfx/query/driver", i);
180 printf("%s", al_get_string("gfx/query/name");
181 }
182
183- Create a YUV 422 overlay
184 al_set_string ("gfx/current/color_space", "YUV422");
185 al_set_int ("gfx/current/color_depth", 16);
186 al_set_boolean("gfx/current/overlay", TRUE);
187 al_set_bollean("gfz/current/windowed", TRUE);
188 AL_BITMAP *screen = al_create_display_bitmap(GFX_AUTO, width, height, GFX_UPDATE_AUTO);
189 
190- Set a full screen 32-bpp display bitmap on the second monitor
191 al_set_int("gfx/current/display_device", 1);
192 al_set_int("gfx/current/windowed", FALSE);
193 al_set_int("gfx/current/color_depth", 32);
194 AL_BITMAP *screen = al_create_display_bitmap(GFX_AUTO, width, height, GFX_UPDATE_AUTO);
195
196- Display current resolutions of all monitors on the system
197 int num = al_get_int("gfx/system/num_display_devices");
198 for (i = 0; i < num; i++) {
199 al_set_int("gfx/query/display_device", i);
200 printf("%i: %i x %i x %i (%s)\n", i
201 al_get_int("gfx/query/width"),
202 al_get_int("gfx/query/height"),
203 al_get_int("gfx/query/color_depth"),
204 al_get_string("gfx/query/color_space"));
205 }
206 
207- Moves a display bitmap window
208 al_set_int("gfx/current/display_bitmap", screen->id);
209 al_set_int("gfx/current/window_x", 55);
210 al_set_int("gfx/current/window_y", 107);

Thoughts? Comments? Flames?

--
- Bob
[ -- All my signature links are 404 -- ]

Thomas Fjellstrom
Member #476
June 2000
avatar

so.. the direct bitmap access allows 'random' access? instead of just line by line? Thomas Harte would be happy ;)

[edit] I must say, I like. everything seems to make sense ;) cough and is consistent. [/edit]

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

spellcaster
Member #1,493
September 2001
avatar

I like it.
How will the set methods work? Will they set the values directly? Will they be set once a certain function is called?

If so, I'd like to ensure that there's a naming convention which makes it clear to the user which function commits something...

--
There are no stupid questions, but there are a lot of inquisitive idiots.

ReyBrujo
Moderator
January 2001
avatar

The string parsing ("gfx/.../height") is scanned and tokenized, just stricmp'ed... ? I guess it doesn't do too much difference if they are just configuration routines, right?

I like it. It will break all code below Allegro 5, but it is fine. It is time to do that jump, and the best planned, much better the jump. DOS support will become loosy (if not disappearing at all). You think the drivers could be loaded at runtime (so there is a drivers.dat file to be delivered with each game, which can be customized deleting drivers not supported, etc)?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

lwithers
Member #630
September 2000

Here follow some totally unconnected comments.

  • Nice work.

  • Definitely blit. :-) Also very nice that the normal blit function actually draws the whole bitmap, since that is the usual case.

  • Two comments about the blit-type functions: firstly, why source, dest ordering and not dest, source? Personally I prefer the latter (easier to remember), but I'll accept any logical argument for the former. And the flag parameter: is there no other way to achieve what you want? Flags are evil because add-on flags will conflict.

  • Can we get a mailing list for v5 development? Allegro.cc is fine for short threads, but the interface is too cumbersome for long discussions and is painful for us poor modem users.

  • al_set_bitmap_clip_region is very cumbersome for a potentially oft-used function. How about al_bitmap_clip()?

  • al_draw_text() should still take a bg parameter. The reason for this is in the text renderers (currently I am writing an advanced renderer for v4, look out for it in conductors): drawing a bg with rectfill and then writing on it is potentially very slow compared to drawing fg/bg in one go. Maybe there should be a specific way of representing a transparent color? (see mail to conductors about using an array of char). Alternatively, add al_draw_text_solid().

Finally, my personal view about the config system. I agree with the API, but the usage is my concern. We should come up with rules for when things should be done through the config system and when they should be done through functions.

I think that global information which doesn't regularly change (this includes which graphics adapters you have, the CPU information, OS information, current color depth/screen resolution, etc) should be read from the config system.

Fast changing information, and anything which returns a pointer, should be implemented with a function (getting a pointer to the current screen, the equivalent to reading the key[] array in v4, etc.).

Changing things which won't have an immediate effect (eg. setting preferred drivers, telling packfiles to use bz2 compression, etc.) should go through the config system.

Changing things that will have an immediate effect, or anything using pointers (eg. setting the window size) should happen in a function. In your last example, imagine that it takes 0.5s to resize the window; you now have an unsightly delay in resizing along each axis.

Also, the config system encourages moving towards a state-based system, but we all know that this is generally a bad thing: it makes multithreading a problem. In fact, it makes multi-anything a problem :-( (By this I mean that performing an operation twice, but without the two instances interfering with each other, becomes a pain).

Having said this, I do like your example "Create a YUV 422 overlay": this shows where the config system would be most useful. The graphics driver doesn't have to know a thing about YUV 422, so it can just fail the request because it doesn't see enough information. But think about this in a multithreading context: two threads each trying to set up a display will totally break each other.

I think maybe you should do this instead:

- Create a YUV 422 overlay
    al_set_string ("gfx/my_new_display/color_space", "YUV422");
    al_set_int    ("gfx/my_new_display/color_depth", 16);
    al_set_boolean("gfx/my_new_display/overlay", TRUE);
    al_set_boolean("gfx/my_new_display/windowed", TRUE);

/* Also set all the other parms via the config system, because we may introduce new things in
   new versions of Allegro and using the config system waives the requirement that old drivers
   be updated to know about new code. */

    AL_BITMAP *screen = al_create_display_bitmap("my_new_display");

/* This call reads from the directory gfx/my_new_display/ to get its parms. */

This way, a thread simply needs a unique string ID rather than having to implement mutexes for each operation a thread might want to carry out using the config system.

Anyway, enough rambling for now. Please think about the mailing list.

Bob
Free Market Evangelist
September 2000
avatar

Quote:

so.. the direct bitmap access allows 'random' access? instead of just line by line?

Yes. Of course, not all bitmaps can work this way. If a bitmap does not support locking a particular region, an error code is returned. Then, you can revert to the line-by-line access, just like Allegro 4.

Quote:

How will the set methods work? Will they set the values directly? Will they be set once a certain function is called?

The set methods are part of the configuration module, and not the gfx module, so lillo is probably the best person to answer your question. IIRC, set looks something like:

- parse_string
- Find key in tree via a hash value
- Set the value
- Call a registered callback (optional)

Values are committed as they are set. Who reads them is up to the library / user.

Quote:

The string parsing ("gfx/.../height") is scanned and tokenized, just stricmp'ed... ?

Not quite. The string is parsed into tokens, then hashed. The hash value is then used to loop up the section of the tree and finally the variable itself.

--
- Bob
[ -- All my signature links are 404 -- ]

Thomas Harte
Member #33
April 2000
avatar

Straight off the top of my head, I have a few changes I would like to see. Obviously shoot me down if these are stupid suggestions. What do people think about these :

/* Clipping */
int al_get_bitmap_num_clip_regions(AL_BITMAP *bitmap);
void al_set_bitmap_clip_region(AL_BITMAP *bitmap, int x, int y, int w, int h, int id);
void al_set_bitmap_clip_mode(AL_BITMAP *bitmap, int id, AL_BOOL mode);

It is assumed that num_clip_regions returns how many clip regions may be attached to a bitmap. This number is always positive, or it is 0 if there is no limit. People may then adjust the dimensions of any of the potential clip regions (id is either arbitrary with the user using whatever values they like, or else 0 <= id < number of clip regions) and enable them or disable them. When they are disabled, it is assumed that Allegro forgets their shape.

All elements of geometry that fall within any clip region are displayed. So the total clip region is the boolean OR of all regions.

Also, in addition to :

/* Updating the screen */
void al_show_display_bitmap(AL_BITMAP *display);
void al_flush(AL_BITMAP *display);

Just for future target proofing. That is, assuming the former is only for page flipping?

On the same topic, for similar future proofing, are you sure we can do without :

int al_unselect_read_bitmap_region(AL_BITMAP *bitmap);

Finally, are the Allegro team absolutely opposed to combining some of the al_create_*bitmap functions, except for sub? Imagine the benefits of this :

AL_BITMAP *al_create_display_bitmap(al_id_t card, int width, int height, al_id_t update_method);
AL_BITMAP *al_create_bitmap(int flags, AL_BITMAP *display, int width, int height);
AL_BITMAP *al_create_rle_bitmap(AL_BITMAP *memory);
AL_BITMAP *al_create_sub_bitmap(AL_BITMAP *parent, int x, int y, int w, int h);

Arguments to create_bitmap may be one of the obvious :

AL_VIDEO
AL_SYSTEM
AL_MEMORY

Or, to simplify things even further for users, could be one of these :

AL_MAXIMUM_VRAM_BLIT_SPEED
AL_MAXIMUM_READ_SPEED
AL_MAXIMUM_MEMORY_BLIT_SPEED
etc

With Allegro being a little intelligent about the matter. For example, the VRAM example might try to allocate a video bitmap if they are supported on this hardware and any memory is available, if that doesn't work out, it could head for AGP memory, then system memory (possibly in RLE form, first . . .). I think users would like this feature.

EDIT : in response to some more posts that have appeared just now.

Quote:

Two comments about the blit-type functions: firstly, why source, dest ordering and not dest, source? Personally I prefer the latter (easier to remember), but I'll accept any logical argument for the former. And the flag parameter: is there no other way to achieve what you want? Flags are evil because add-on flags will conflict.

I agree with dest, source, to be the same as memcpy, strcpy, etc.

ReyBrujo
Moderator
January 2001
avatar

(Edited: I think I will let this thread advance a bit before asking what I was going to)

Remember to set some macros, since it seems you will need to call several functions to get results you used to get automagically done with Allegro 4.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Thomas Harte
Member #33
April 2000
avatar

Oh, one more thing, if those who wanted an events based input system have definitely been silenced, can there at least be the following additions to the traditional key array?

keychanged[] contains non-zero for any key that changed since either the last al_flush if that proposal is taken on board, or the last page flip or blit to the front buffer?

KEY_QUIT is a virtual key, which is considered pressed if the user uses some inherent quit request function available through their OS, such as clicking the [X] in Windows.

lwithers
Member #630
September 2000

Storing drivers on disk, etc: no, not really. Why would drivers be distributed with a game anyway? Windows uses DLLs, proper operating systems use autoconf to build a customised but binary compatible shared library, and DOS uses static linking. (I didn't say anyone was or was not going to write a DOS version of Allegro 5, btw).

Technically, the idea is a little difficult to implement. For the most part it's pretty trivial on Unix, I don't know about Windows (though I guess it's neither particularly easy nor particularly robust), and it's very difficult on DOS.

ReyBrujo
Moderator
January 2001
avatar

Hmm... DOS support has been discussed a lot. On the other hand, Mac support is quite preliminary. I guess the first near-stable Allegro 5 version will come in one year and a half, two years maybe. How many users are supporting MAC lately? I am afraid it doesn't get too much attention.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

23yrold3yrold
Member #1,134
March 2001
avatar

We actually get a draw translucent sprite function now (via the flags)? :o
cries with joy
I like how those blit flags work, especially the flips. I could really use them right now, actually :P I'm also warming to the idea of using strings like that; I'm doing the same thing in my engine and it's very easy and powerful. Lovin' it Bob, lovin' it ....

So ... when you guys gonna do this thing?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Matthew Leverton
Supreme Loser
January 1999
avatar

Let's please not degenerate into an OS support war ... whatever OS's are supported will be because someone took the time to develop for it. If you want support for an OS, help code it.

--

I like the looks of the new API. Anything that is consistent will plese me. :)

Typo here, though:

int al_get_text_wdith (const AL_FONT *f, const char *str);

23yrold3yrold
Member #1,134
March 2001
avatar

Just read TH's post; I vote dest, source too!

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Harte
Member #33
April 2000
avatar

Quote:

Let's please not degenerate into an OS support war ... whatever OS's are supported will be because someone took the time to develop for it. If you want support for an OS, help code it.

Conversely, if people porting is to be encouraged, how about a document on how to write a new driver being a development priority? There used to be one, many years ago, but obviously it is irrelevant now.

ReyBrujo
Moderator
January 2001
avatar

Oh, no, no OS war! I was just saying that it "might" be too early to start planning Allegro 5 while there is still one port that is not as tested as the others.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Rash
Member #2,374
May 2002
avatar

Please remove as much macros as possible. Integer constants can be represented by anonymous enums if necessary.

kazzmir
Member #1,786
December 2001
avatar

will the new API break the code written for previous versions of allegro therfore making every single project currently hosted on allegro.cc unrecompiable unless they were rewritten?

lwithers
Member #630
September 2000

RB: it doesn't really matter since v5 is such a drastic change from v4.

Rash: yes, macros are evil. If anybody disagrees, read the C++ FAQ (or failing that, the Allegro source code! damn 100-line macros...). Enums are generally much better because the compiler can use their information in a sensible manner (such as warning you when you forget to switch(){} on them).

Rash
Member #2,374
May 2002
avatar

kazzmir: It has been indicated that Allegro 4 will continue to exist separately.

Goodbytes
Member #448
June 2000
avatar

I also vote for (dest, source). Looks pretty sweet so far.

The only thing I don't like is the fact that some functions(i.e. al_map_rgba() and co.) both return a colour and set a parameter for it... why would we need both? I can't think of a situation where you would need a parameter where you couldn't use a return value... and it seems to be cumbersome, at least to me.


--
~Goodbytes

Thomas Harte
Member #33
April 2000
avatar

Quote:

The only thing I don't like is the fact that some functions(i.e. al_map_rgba() and co.) both return a colour and set a parameter for it... why would we need both?

I wondered this also. But since it happens in time.h also, I assumed there was some dark reason I just don't understand (?)

Thomas Fjellstrom
Member #476
June 2000
avatar

maybe its also why fputc returns what you passed it?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Bob
Free Market Evangelist
September 2000
avatar

The reason why al_map_rgba returns the color parameter is so that you can do:

al_put_pixel(bmp, x, y, al_map_rgba(bmp, &color, r, g, b, a));

Just like in Allegro 4 with makecol(). The reason why you need to also pass a pointer to a color structure is so that no memory allocation needs to take place (this improves speed), no memory management needs to take place (simplifies the code), and we don't need to return structures (unportable, even across DLLs).

As for the (source, dest) ordering, that is to remain consistent with Allegro 4's blit() parameters. I'm open for changes. Matthew, a new poll perhaps?

Quote:

Conversely, if people porting is to be encouraged, how about a document on how to write a new driver being a development priority?

Sure, but not now. Allegro 5 is going to have a completely different driver structure.
(yes, this will also mean that add-ons won't work without changes).

Quote:

All elements of geometry that fall within any clip region are displayed. So the total clip region is the boolean OR of all regions.

There is no speed benefit of doing this inside of Allegro. This can sit perfectly well as an addon which does:

- Change clip region
- Do operation on bitmap
- Repeat for all clip regions

It's not because it's in DirectX that it must be useful :)
It would also complicate the clipping code by an order of magnitude.

As for al_flush() - that's not really needed, is it? How would this be useful at all?
al_show_display_bitmap(), as well as all read operations would imply a flush() anyway.

Yes, I missed the al_unselect_read_bitmap_region. Thank you for pointing it out.

As for unifying the al_create_bitmap() variants, I can see it as being useful. It can loosen the burden of having to implement all 3 or 4 forms of al_create_bitmap when porting Allegro.

However, this would mean that the system bitmap, memory bitmap and video bitmap code would get linked in your executable all the time (for DOS people).

Edit:

Quote:

Flags are evil because add-on flags will conflict.

In that case, we can provide a function that will create flags. Something like al_make_guid(). Then, if an addon adds (let's say) an AND drawing mode, the addon can do:

#define ADDON_AND_BLIT some_variable

int install_addon() {
  some_variable = al_make_guid();
}

Quote:

Can we get a mailing list for v5 development? Allegro.cc is fine for short threads, but the interface is too cumbersome for long discussions and is painful for us poor modem users.

Yes, Id like that. On sourceforge maybe?

Quote:

al_set_bitmap_clip_region is very cumbersome for a potentially oft-used function. How about al_bitmap_clip()?

Or al_set_bitmap_clip(). I'm sticking with verb/noun for consistency (appart for blit).

About a background color for the text routines, I can see it being useful. I'll just add a bg parameter to the call. You can always use NULL if you don't want a background color - or is this bad somehow?

--
- Bob
[ -- All my signature links are 404 -- ]

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

As for the (source, dest) ordering, that is to remain consistent with Allegro 4's blit() parameters.

Yeah, blit and blit alone. All the other bitmap drawing functions use (dest, source), and I still think it's more intuitive. Besides, who cares about consistency with Allegro 4 anyway ;)?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

 1   2   3   4 


Go to: