Re: [AD] Additional graphics primitives API

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Feb 6, 2008 10:55 PM, Paul Suntsov <siegelords_abode@xxxxxxxxxx> wrote:
Hello everyone,

Here's a little set of functions I propose to add to
allegro5, all are meant to be harware accelerated and
all have implementations mostly done (in OpenGL only
though, no DirectX and no software(yet)).

Here are the equivalents for old allegro functions.
The flags in all of these are the ALLEGRO_OUTLINED and
ALLEGRO_FILLED. Filled arcs look like pizza slices.
Parameters for these should be self-explanatory.

void al_draw_polygon(float* vertices, int
number_vertices, ALLEGRO_COLOR color, int flags);
void al_draw_ellipse(float x, float y, float r1, float
r2, ALLEGRO_COLOR color, int flags);
void al_draw_arc(float x, float y, float r, float
theta1, float theta2, ALLEGRO_COLOR color, int flags);
void al_draw_line(float fx, float fy, float tx, float
ty, ALLEGRO_COLOR color);
void al_draw_rectangle(float l, float r, float t,
float b, ALLEGRO_COLOR color, int flags);
void al_draw_triangle(float x1, float y1, float x2,
float y2, float x3, float y3, ALLEGRO_COLOR color, int
flags);
void al_calc_spline(float points[8], float* vertices,
int num_vertices);
void al_draw_spline(float points[8], ALLEGRO_COLOR
color);
void al_put_pixel(float x, float y, ALLEGRO_COLOR
color);

Some notes on the above. al_draw_polygon only accepts
convex polygons now. al_draw_arc when called with the
filled flag has no obvious implementation for memory
bitmaps. The al_calc_spline are almost identical to
the versions in the old allegro, but with different
parameters. I draw elipses and arcs using a polygonal
approximation... which sometimes has pixel differences
from the allegro's version. There is no al_draw_circle
since the code is exactly the same as the
al_draw_ellipse... so that should be called instead.
There is no al_get_pixel since I am unsure how such
things are handled... Also there are no do_*
functions, since they do not need to be accelerated.
There are these functions however:

void al_calc_ellipse(float x, float y, float r1, float
r2, float* vertices, int num_vertices);
void al_calc_line(float fx, float fy, float tx, float
ty, float* vertices, int num_vertices);
void al_calc_arc(float x, float y, float r, float
theta1, float theta2, float* vertices, int
num_vertices);
void al_calc_ellipse(float x, float y, float r1, float
r2, float* vertices, int num_vertices);

They are identical in operation to al_calc_spline. I
figured that they might be useful.

There are also a bunch of other functions I made...
but I guess they could be put in a completely separate
addon:

void al_draw_polyline(float* vertices, int
number_vertices, ALLEGRO_COLOR color);
void al_set_polygon_stipple(const uint8_t * mask, int
enable);
void al_set_line_stipple(int factor, unsigned short
pattern, int enable);
void al_set_line_width(float width);
void al_set_point_width(float width);

Aside from draw_polyline (this just draws a line
strip) there are no obvious memory bitmap
implementations of the other 4 functions.

My guess that assuming that these are fine, the next
step would be for me to add the implementations into
the actual source code and test them there? Or would
it be better if I just sent the implementations to
someone with greater knowledge of allegro5's
internals?

-SiegeLord


     ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
--
https://lists.sourceforge.net/lists/listinfo/alleg-developers

I've just read this email quickly before i head out the door this morning. It appears to be quite a complete set of drawing routines.

A few quick questions:
al_draw_circle could be done as a simple wrapper for al_draw_ellipse. It would simplify things for users.

Memory based drawing routines?
I can help out but there is a lot going on here and it could take a while. Some things may not be portable too easily. No doubt there will be differences in details. I do know on linux that MESA is a software based opengl library. I am sure we could beat its performance by ignoring the 3rd dimension + associated details. On mac opengl is basically guaranteed for os x so there is no worry there. Is it also safe to assume d3d will be supported on all windows boxen? The acceleration landscape is quite different from when the old allegro came out.

This is probably best done as an addon in the addon directory.

FYI: ALLEGRO_COLOR al_get_pixel(bmp,x,y); there is an al_set_pixel too.

-- Ryan Dickie


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/