RE: [AD] Windowing

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


> -----Original Message-----
> From: Michael Bukin [mailto:M.A.Bukin@xxxxxxxxxx]
> Sent: Wednesday, 7 July 1999 23:31
> To: conductors@xxxxxxxxxx
> Subject: Re: [AD] Windowing
> 
> 
> "White, Ben" <ben.white@xxxxxxxxxx> writes:
> 
> I don't think I understand your suggestion.  Could you give more
> information, perhaps, with some pseudo-code of what you would like to
> be able to do.

At the end I put the header file to a small library I wrote for X (also
planning to port it to Win95 one day).  This is especially useful for when
the XServer and client are running on different machines, because for
example xl_poly gets converted to XDrawPoly (for a flat shaded 3d engine),
and I can make up sprites using masked pixmaps.  I had a bit of a poke
through the source and I don't think this is really easy to do polys in
Allegro because there's no bmp->vtable->polygon(...).  I'm not sure it would
really help me anyway because I don't think my design will map really easily
to use the allegro GUI without using threads which I don't want to do.

Anyway, I guess my idea was for something like:
bmp = create_window (w, h, callback_fn /* Or a gui parent object */ );
as an alternative to set_gfx_mode();
callback_fn would then get passed events such as resize, expose and mouse
press, or instead it somehow passes them to an attatched gui.  You could do
things like line (bmp, ...) or polygon (bmp...) or blit (bmp, ...) to it or
the gui would just draw in it.

I think I'll just keep playing around and see what I can come up with...

Thanks for your time guys, and keep up the good work!

xl.h:

#ifndef XL_H
#define XL_H

#ifdef __cplusplus
extern "C" {
#endif

typedef struct xl_event_struct {
  enum xl_event_enum {
    xl_key_press,
    xl_key_release,
    xl_mouse_press,
    xl_mouse_release,
    xl_mouse_move,
    xl_resize,
    xl_expose,
    xl_timer,
    xl_input
  } type;
  union xl_event_union {
    struct {
      int key;
    } key_press;
    struct {
      int key;
    } key_release;
    struct {
      int x, y, flags;
    } mouse_press;
    struct {
      int x, y, flags;
    } mouse_release;
    struct {
      int x, y;
    } mouse_move;
    struct {
      int w, h;
    } resize;
    struct {
      int x, y, w, h;
    } expose;
    struct {
      float time;
    } timer;
    struct {
      int fd;
    } input;
  } event;
} xl_event;

void xl_init (void);

void xl_set_depth (int d);
void *xl_create_window (int w, int h, char *title,
				void (*handler)(void *, xl_event *));
int xl_create_palette (void *win, int ncolors);
int xl_load_palette (void *win, int ncolors, unsigned char *colors);
int xl_set_timer (void *win, float time);
int xl_add_input (void *win, int fd);
int xl_remove_input (void *win, int fd);
int xl_main (void *win);
int xl_destroy (void *resource);

void *xl_create_bitmap (void *win, int w, int h);
void *xl_create_mask (int w, int h, void *data);
void *xl_load_jpeg (char *filename);
void *xl_load_png (char *filename);

int xl_width (void *bmp);
int xl_height (void *bmp);
int xl_depth (void *bmp);
int xl_ncolors (void *bmp);
int xl_palette (void *bmp, unsigned char *palette);

int xl_acquire (void *bmp, void **data, int *pitch);
int xl_release (void *bmp);

void xl_blit (void *src, void *dest, int x0, int y0, int w, int h,
		int x1, int y1);
void xl_rect (void *dest, int x, int y, int w, int h, int col);
void xl_line (void *dest, int x0, int y0, int x1, int y1, int col);
void xl_poly (void *dest, int np, int *x, int *y, int col);

#ifdef __cplusplus
}
#endif

#endif



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