Re: [AD] Implementation of draw_memory_bitmap_region

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


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




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