Re: [AD] Implementation of draw_memory_bitmap_region

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


There's a check in al_draw_bitmap - if the target is a memory bitmap
then it calls _al_draw_bitmap_memory instead. This seems to be a
pattern in the code; the al_XXX function checks for a memory target
before invoking any of the display's vtable functions. Can anyone
confirm if that is always the case?

Pete


On Sat, Mar 1, 2008 at 9:13 PM, Trent Gamblin <trent@xxxxxxxxxx> wrote:
>
> On Sat, March 1, 2008 1:56 pm, Peter Hull said:
>  > I've implemented this function for OS X using OpenGL. Does it look
>  > OK?
>  > Maybe it could be moved to ogl_display.c if it is correct.
>  > The function decode_allegro_format gets the appropriate OpenGL
>  > format/size for an Allegro mode. I don't know if there's an official
>  > way to do that.
>  >
>  > Pete
>  >
>  > static void draw_memory_bitmap_region(ALLEGRO_DISPLAY *display,
>  > ALLEGRO_BITMAP *bmp,
>  >                               float sx, float sy, float sw, float sh, float dx, float
>  > dy,
>  > int flags) {
>  >    int fmt, size;
>  >    ALLEGRO_LOCKED_REGION region;
>  >    int l = MAX((int) sx, bmp->cl);
>  >    int r = MIN((int) (sx+sw) - 1, bmp->cr);
>  >    int t = MAX((int) sy, bmp->ct);
>  >    int b = MIN((int) (sy+sh) - 1, bmp->cb);
>  >    if (l>=r || t>=b) {
>  >       /* Clipped out */
>  >       return;
>  >    }
>  >    al_lock_bitmap_region(bmp, l, t, r - l + 1, b - t + 1, &region,
>  > ALLEGRO_LOCK_READONLY);
>  >    decode_allegro_format(region.format,&fmt,&size,NULL);
>  >    glPixelStorei(GL_UNPACK_ROW_LENGTH, region.pitch /
>  > al_get_pixel_size(region.format));
>  >    glRasterPos2f(dx - sx + l, dy - sy + t);
>  >       glDrawPixels(bmp->lock_w, bmp->lock_h, fmt, size, region.data);
>  >    al_unlock_bitmap(bmp);
>  > }
>
>  What about when the target bitmap is not the framebuffer?
>
>
>  Trent
>
>  -------------------------------------------------------------------------
>  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
>




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