14 #ifdef ALLEGRO_WINDOWS    21 #include <allegro/internal/aintern.h>    23 #include <OpenGL/glu.h>    34 static GFX_VTABLE allegro_gl_video_vtable;
    37 static int video_bitmap_count = 2;
    39 static int __allegro_gl_video_bitmap_bpp = -1;
    41 extern BITMAP *__agl_drawing_pattern_bmp;
    42 BITMAP *old_pattern = NULL;
    48 static int allegro_gl_make_video_bitmap_helper1(
int w, 
int h, 
int x, 
int y,
    49                                    GLint target, AGL_VIDEO_BITMAP **pvid) {
    54     if (__allegro_gl_video_bitmap_bpp == -1) {
    55         bpp = bitmap_color_depth(screen);
    58         bpp = __allegro_gl_video_bitmap_bpp;
    61     (*pvid) = malloc(
sizeof(AGL_VIDEO_BITMAP));
    66     memset(*pvid, 0, 
sizeof(AGL_VIDEO_BITMAP));
    69     (*pvid)->memory_copy = create_bitmap_ex(bpp, w, h);
    70     if (!(*pvid)->memory_copy)
    74     (*pvid)->type = __allegro_gl_get_bitmap_type((*pvid)->memory_copy, 0);
    77     (*pvid)->target = target;
    87     glGenTextures(1, &((*pvid)->tex));
    91     glEnable((*pvid)->target);
    92     glBindTexture((*pvid)->target, ((*pvid)->tex));
    94     glTexImage2D((*pvid)->target, 0, internal_format, w, h,
    95                  0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    98     glTexParameteri((*pvid)->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    99     glTexParameteri((*pvid)->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   109         GLenum clamp = GL_CLAMP_TO_EDGE;
   113         glTexParameteri((*pvid)->target, GL_TEXTURE_WRAP_S, clamp);
   114         glTexParameteri((*pvid)->target, GL_TEXTURE_WRAP_T, clamp);
   118     glDisable((*pvid)->target);
   121         glGenFramebuffersEXT(1, &((*pvid)->fbo));
   123             glDeleteTextures(1, &((*pvid)->tex));
   127         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, (*pvid)->fbo);
   128         glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, (*pvid)->target, (*pvid)->tex, 0);
   129         if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
   131             glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
   132             glDeleteFramebuffersEXT(1, &((*pvid)->fbo));
   137         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
   148 static int allegro_gl_make_video_bitmap_helper0(
int w, 
int h, 
int x, 
int y,
   149                                                 AGL_VIDEO_BITMAP **pvid) {
   151     int is_power_of_2 = (!(w & (w - 1)) && !(h & (h - 1)));
   153 #ifdef ALLEGRO_MACOSX   157     GLint max_rect_texture_size = 0;
   159     if (texture_rect_available) {
   160         glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &max_rect_texture_size);
   163     if (w <= allegro_gl_info.max_texture_size &&
   164         h <= allegro_gl_info.max_texture_size) {
   167             if (allegro_gl_make_video_bitmap_helper1(w, h, x, y,
   168                                             GL_TEXTURE_2D, pvid)) {
   172         else if (texture_rect_available &&
   173                  w <= max_rect_texture_size &&
   174                  h <= max_rect_texture_size) {
   175             if (allegro_gl_make_video_bitmap_helper1(w, h, x, y,
   176                                             GL_TEXTURE_RECTANGLE_ARB, pvid)) {
   183             const unsigned int BITS = 
sizeof(int) * CHAR_BIT;
   191             for (i = 0; i < BITS; i++) {
   199                 for (j = 0; j < BITS; j++) {
   206                     if (allegro_gl_make_video_bitmap_helper0(w1, h1, x + x1,
   211                         pvid = &((*pvid)->next);
   237         if (allegro_gl_make_video_bitmap_helper0(w1, h1, x, y, pvid)) {
   241             pvid = &((*pvid)->next);
   246             if (allegro_gl_make_video_bitmap_helper0(w2, h1, x + w1, y, pvid)) {
   250                 pvid = &((*pvid)->next);
   255             if (allegro_gl_make_video_bitmap_helper0(w1, h2, x, y + h1, pvid)) {
   259                 pvid = &((*pvid)->next);
   264             if (allegro_gl_make_video_bitmap_helper0(w2, h2, x + w1, y + h1, pvid)) {
   268                 pvid = &((*pvid)->next);
   283 static BITMAP *allegro_gl_make_video_bitmap(BITMAP *bmp) {
   286     void *ptr = &bmp->extra;
   287     AGL_VIDEO_BITMAP **pvid = (AGL_VIDEO_BITMAP**)ptr;
   290     if (allegro_gl_make_video_bitmap_helper0(bmp->w, bmp->h, 0, 0, pvid)) {
   310     AGL_VIDEO_BITMAP *vid = bmp ? bmp->extra : NULL, *next;
   316         if (vid->memory_copy)
   317             destroy_bitmap(vid->memory_copy);
   320             glDeleteTextures(1, &vid->tex);
   323             glDeleteFramebuffersEXT(1, &vid->fbo);
   348     bitmap = malloc(
sizeof(BITMAP) + 
sizeof(
char *));
   354     bitmap->w = bitmap->cr = w;
   355     bitmap->h = bitmap->cb = h;
   357     bitmap->cl = bitmap->ct = 0;
   358     bitmap->write_bank = bitmap->read_bank = NULL;
   360     bitmap->id = BMP_ID_VIDEO | video_bitmap_count;
   361     bitmap->extra = NULL;
   364     bitmap->seg = _default_ds();
   365     bitmap->line[0] = NULL;
   366     bitmap->vtable = NULL;
   368     if (!allegro_gl_make_video_bitmap(bitmap)) {
   371     video_bitmap_count++;
   376     vtable = malloc(
sizeof(
struct GFX_VTABLE));
   377     *vtable = allegro_gl_video_vtable;
   378     if (__allegro_gl_video_bitmap_bpp == -1) {
   379         vtable->color_depth = bitmap_color_depth(screen);
   382         vtable->color_depth = __allegro_gl_video_bitmap_bpp;
   384     switch (vtable->color_depth) {
   386             vtable->mask_color = MASK_COLOR_8;
   389             vtable->mask_color = MASK_COLOR_15;
   392             vtable->mask_color = MASK_COLOR_16;
   395             vtable->mask_color = MASK_COLOR_24;
   398             vtable->mask_color = MASK_COLOR_32;
   401     bitmap->vtable = vtable;
   424     GLint old_val = __allegro_gl_video_bitmap_bpp;
   425     __allegro_gl_video_bitmap_bpp = bpp;
   452 static void set_drawing_pattern(
void)
   454     if (_drawing_pattern && !is_memory_bitmap(_drawing_pattern)) {
   455         old_pattern = _drawing_pattern;
   456         drawing_mode(_drawing_mode, __agl_drawing_pattern_bmp,
   457                      _drawing_x_anchor, _drawing_y_anchor);
   463 static void unset_drawing_pattern(
void)
   466         drawing_mode(_drawing_mode, old_pattern,
   467                      _drawing_x_anchor, _drawing_y_anchor);
   474 static int allegro_gl_video_getpixel(
struct BITMAP *bmp, 
int x, 
int y)
   477     AGL_VIDEO_BITMAP *vid;
   478     AGL_LOG(2, 
"glvtable.c:allegro_gl_screen_getpixel\n");  
   480     if (is_sub_bitmap(bmp)) {
   484     if (x < bmp->cl || x >= bmp->cr || y < bmp->ct || y >= bmp->cb) {
   491         if (vid->x_ofs <= x && vid->y_ofs <= y
   492          && vid->x_ofs + vid->memory_copy->w > x
   493          && vid->y_ofs + vid->memory_copy->h > y) {
   495             pix = getpixel(vid->memory_copy, x - vid->x_ofs, y - vid->y_ofs);
   510 static void update_texture_memory(AGL_VIDEO_BITMAP *vid, 
int x1, 
int y1,
   512     GLint saved_row_length;
   513     GLint saved_alignment;
   518     BITMAP *vbmp = vid->memory_copy;;
   520     glGetIntegerv(GL_UNPACK_ROW_LENGTH, &saved_row_length);
   521     glGetIntegerv(GL_UNPACK_ALIGNMENT, &saved_alignment);
   523     bpp = BYTES_PER_PIXEL(bitmap_color_depth(vid->memory_copy));
   524     format = vid->format;
   527     glColor4ub(255, 255, 255, 255);
   533                                           && bitmap_color_depth(vbmp) < 24) {
   534         temp = create_bitmap_ex(24, vbmp->w, vbmp->h);
   538         blit(vbmp, temp, 0, 0, 0, 0, temp->w, temp->h);
   540         bpp = BYTES_PER_PIXEL(bitmap_color_depth(vbmp));
   541         format = __allegro_gl_get_bitmap_color_format(vbmp, 0);
   542         type = __allegro_gl_get_bitmap_type(vbmp, 0);
   545     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   546     glPixelStorei(GL_UNPACK_ROW_LENGTH,
   548                  ? (vbmp->line[1] - vbmp->line[0]) / bpp
   551     glEnable(vid->target);
   552     glBindTexture(vid->target, vid->tex);
   553     glTexSubImage2D(vid->target, 0,
   554         x1, y1, x2 - x1 + 1, y2 - y1 + 1, format,
   555         type, vbmp->line[y1] + x1 * bpp);
   556     glBindTexture(vid->target, 0);
   557     glDisable(vid->target);
   560         destroy_bitmap(temp);
   562     glPixelStorei(GL_UNPACK_ROW_LENGTH, saved_row_length);
   563     glPixelStorei(GL_UNPACK_ALIGNMENT, saved_alignment);
   568 static void allegro_gl_video_putpixel(
struct BITMAP *bmp, 
int x, 
int y,
   570     AGL_VIDEO_BITMAP *vid;
   572     if (is_sub_bitmap(bmp)) {
   576     if (x < bmp->cl || x >= bmp->cr || y < bmp->ct || y >= bmp->cb) {
   583         if (vid->x_ofs <= x && vid->y_ofs <= y
   584          && vid->x_ofs + vid->memory_copy->w > x
   585          && vid->y_ofs + vid->memory_copy->h > y) {
   587             set_drawing_pattern();
   588             putpixel(vid->memory_copy, x - vid->x_ofs, y - vid->y_ofs, color);
   589             unset_drawing_pattern();
   590             update_texture_memory(vid, x - vid->x_ofs, y - vid->y_ofs, x - vid->x_ofs, y - vid->y_ofs);
   601 static void allegro_gl_video_vline(BITMAP *bmp, 
int x, 
int y1, 
int y2,
   604     AGL_VIDEO_BITMAP *vid;
   606     AGL_LOG(2, 
"glvtable.c:allegro_gl_video_vline\n");
   609     if (is_sub_bitmap(bmp)) {
   614     if (x < bmp->cl || x >= bmp->cr) {
   632         BITMAP *vbmp = vid->memory_copy;
   635         if (vid->x_ofs > x || vid->y_ofs > y2
   636          || vid->x_ofs + vbmp->w <= x
   637          || vid->y_ofs + vbmp->h <= y1) {
   643         _y1 = MAX(y1, vid->y_ofs) - vid->y_ofs;
   644         _y2 = MIN(y2, vid->y_ofs + vbmp->h - 1) - vid->y_ofs;
   647         set_drawing_pattern();
   648         vline(vbmp, _x, _y1, _y2, color);
   649         unset_drawing_pattern();
   650         update_texture_memory(vid, _x, _y1, _x, _y2);
   660 static void allegro_gl_video_hline(BITMAP *bmp, 
int x1, 
int y, 
int x2,
   663     AGL_VIDEO_BITMAP *vid;
   665     AGL_LOG(2, 
"glvtable.c:allegro_gl_video_hline\n");
   668     if (is_sub_bitmap(bmp)) {
   674     if (y < bmp->ct || y >= bmp->cb) {
   692         BITMAP *vbmp = vid->memory_copy;
   695         if (vid->y_ofs > y || vid->x_ofs > x2
   696          || vid->x_ofs + vbmp->w <= x1
   697          || vid->y_ofs + vbmp->h <= y) {
   703         _x1 = MAX(x1, vid->x_ofs) - vid->x_ofs;
   704         _x2 = MIN(x2, vid->x_ofs + vbmp->w - 1) - vid->x_ofs;
   707         set_drawing_pattern();
   708         hline(vbmp, _x1, _y, _x2, color);   
   709         unset_drawing_pattern();
   710         update_texture_memory(vid, _x1, _y, _x2, _y);
   720 static void allegro_gl_video_line(
struct BITMAP *bmp, 
int x1, 
int y1, 
int x2,
   724     do_line(bmp, x1, y1, x2, y2, color, allegro_gl_video_putpixel);
   731 static void allegro_gl_video_rectfill(
struct BITMAP *bmp, 
int x1, 
int y1,
   732                                       int x2, 
int y2, 
int color) {
   734     AGL_VIDEO_BITMAP *vid;
   736     AGL_LOG(2, 
"glvtable.c:allegro_gl_video_rectfill\n");
   739     if (is_sub_bitmap(bmp)) {
   772         BITMAP *vbmp = vid->memory_copy;
   774         int _y1, _y2, _x1, _x2;
   775         if (vid->x_ofs > x2 || vid->y_ofs > y2
   776          || vid->x_ofs + vbmp->w <= x1
   777          || vid->y_ofs + vbmp->h <= y1) {
   783         _y1 = MAX(y1, vid->y_ofs) - vid->y_ofs;
   784         _y2 = MIN(y2, vid->y_ofs + vbmp->h - 1) - vid->y_ofs;
   785         _x1 = MAX(x1, vid->x_ofs) - vid->x_ofs;
   786         _x2 = MIN(x2, vid->x_ofs + vbmp->w - 1) - vid->x_ofs;
   788         set_drawing_pattern();
   789         rectfill(vbmp, _x1, _y1, _x2, _y2, color);
   790         unset_drawing_pattern();
   792         update_texture_memory(vid, _x1, _y1, _x2, _y2);
   801 static void allegro_gl_video_triangle(
struct BITMAP *bmp, 
int x1, 
int y1,
   802                                       int x2, 
int y2, 
int x3, 
int y3, 
int color)
   804     AGL_VIDEO_BITMAP *vid;
   805     int min_y, max_y, min_x, max_x;
   807     AGL_LOG(2, 
"glvtable.c:allegro_gl_video_triangle\n");
   810     if (is_sub_bitmap(bmp)) {
   819     min_y = MIN(y1, MIN(y2, y3));
   820     min_x = MIN(x1, MIN(x2, x3));
   821     max_y = MAX(y1, MAX(y2, y3));
   822     max_x = MAX(x1, MAX(x2, x3));
   825         BITMAP *vbmp = vid->memory_copy;
   827         int _y1, _y2, _x1, _x2, _x3, _y3;
   828         if (vid->x_ofs > max_x || vid->y_ofs > max_y
   829          || vid->x_ofs + vbmp->w <= min_x
   830          || vid->y_ofs + vbmp->h <= min_y) {
   836         _y1 = y1 - vid->y_ofs;
   837         _y2 = y2 - vid->y_ofs;
   838         _y3 = y3 - vid->y_ofs;
   839         _x1 = x1 - vid->x_ofs;
   840         _x2 = x2 - vid->x_ofs;
   841         _x3 = x3 - vid->x_ofs;
   843         set_clip_rect(vbmp, bmp->cl - vid->x_ofs, bmp->ct - vid->y_ofs,
   844                             bmp->cr - vid->x_ofs - 1, bmp->cb - vid->y_ofs - 1);
   846         set_drawing_pattern();
   848         triangle(vbmp, _x1, _y1, _x2, _y2, _x3, _y3, color);
   850         unset_drawing_pattern();
   852         set_clip_rect(vbmp, 0, 0, vbmp->w - 1, vbmp->h - 1);
   856         _y1 = MAX(0, min_y - vid->y_ofs);
   857         _y2 = MIN(vbmp->h - 1, max_y - vid->y_ofs);
   858         _x1 = MAX(0, min_x - vid->x_ofs);
   859         _x2 = MIN(vbmp->w - 1, max_x - vid->x_ofs);
   861         update_texture_memory(vid, _x1, _y1, _x2, _y2);
   869 static void allegro_gl_video_blit_from_memory_ex(BITMAP *source, BITMAP *dest,
   870                     int source_x, 
int source_y, 
int dest_x, 
int dest_y,
   871                     int width, 
int height, 
int draw_type) {
   873     AGL_VIDEO_BITMAP *vid;
   874     BITMAP *dest_parent = dest;
   876     if (is_sub_bitmap (dest)) {
   877        dest_x += dest->x_ofs;
   878        dest_y += dest->y_ofs;
   879        while (dest_parent->id & BMP_ID_SUB)
   880           dest_parent = (BITMAP *)dest_parent->extra;
   883     if (dest_x < dest->cl) {
   886     if (dest_y < dest->ct) {
   889     if (dest_x + width >= dest->cr) {
   890         width = dest->cr - dest_x;
   892     if (dest_y + height >= dest->cb) {
   893         height = dest->cb - dest_y;
   895     if (width < 1 || height < 1) {
   899     vid = dest_parent->extra;
   902         BITMAP *vbmp = vid->memory_copy;
   904         int _x, _y, _w, _h, _sx, _sy;
   905         if (vid->x_ofs >= dest_x + width || vid->y_ofs >= dest_y + height
   906          || vid->x_ofs + vbmp->w <= dest_x
   907          || vid->y_ofs + vbmp->h <= dest_y) {
   913         _x = MAX (vid->x_ofs, dest_x) - vid->x_ofs;
   914         _w = MIN (vid->x_ofs + vbmp->w, dest_x + width)
   916         _y = MAX (vid->y_ofs, dest_y) - vid->y_ofs;
   917         _h = MIN (vid->y_ofs + vbmp->h, dest_y + height)
   920         _sx = source_x + vid->x_ofs + _x - dest_x;
   921         _sy = source_y + vid->y_ofs + _y - dest_y;
   923         if (draw_type == BLIT) {
   924             blit(source, vbmp, _sx, _sy, _x, _y, _w, _h);
   926         else if (draw_type == MASKED_BLIT) {
   927             masked_blit(source, vbmp, _sx, _sy, _x, _y, _w, _h);
   929         else if (draw_type == TRANS) {
   930             BITMAP *clip = create_sub_bitmap(source, _sx, _sy, _w, _h);
   933             draw_trans_sprite(vbmp, clip, _x, _y);
   934             destroy_bitmap(clip);
   937         update_texture_memory(vid, _x, _y, _x + _w - 1, _y + _h - 1);
   946 void allegro_gl_video_blit_from_memory(BITMAP *source, BITMAP *dest,
   947                     int source_x, 
int source_y, 
int dest_x, 
int dest_y,
   948                     int width, 
int height) {
   950     allegro_gl_video_blit_from_memory_ex(source, dest, source_x, source_y,
   951                                          dest_x, dest_y, width, height, BLIT);
   957 void allegro_gl_video_blit_to_memory(
struct BITMAP *source, 
struct BITMAP *dest,
   958                          int source_x, 
int source_y, 
int dest_x, 
int dest_y,
   959                          int width, 
int height) {
   961     AGL_VIDEO_BITMAP *vid;
   962     BITMAP *source_parent = source;
   964     AGL_LOG(2, 
"glvtable.c:allegro_gl_video_blit_to_memory\n");
   966     if (is_sub_bitmap(source)) {
   967        source_x += source->x_ofs;
   968        source_y += source->y_ofs;
   969        while (source_parent->id & BMP_ID_SUB)
   970           source_parent = (BITMAP *)source_parent->extra;
   973     vid = source_parent->extra;
   976         BITMAP *vbmp = vid->memory_copy;
   977         int x, y, dx, dy, w, h;
   979         x = MAX(source_x, vid->x_ofs) - vid->x_ofs;
   980         y = MAX(source_y, vid->y_ofs) - vid->y_ofs;
   981         w = MIN(vid->x_ofs + vbmp->w, source_x + width) - vid->x_ofs;
   982         h = MIN(vid->y_ofs + vbmp->h, source_y + height) - vid->y_ofs;
   983         dx = MAX(0, vid->x_ofs - source_x) + dest_x;
   984         dy = MAX(0, vid->y_ofs - source_y) + dest_y;
   986         blit(vbmp, dest, x, y, dx, dy, w, h);
   999 static void __video_update_memory_copy(BITMAP *source, BITMAP *dest,
  1000                             int source_x, 
int source_y, 
int dest_x, 
int dest_y,
  1001                             int width, 
int height, 
int draw_type) {
  1002     AGL_VIDEO_BITMAP *vid;
  1003     BITMAP *dest_parent = dest;
  1005     if (is_sub_bitmap (dest)) {
  1006        dest_x += dest->x_ofs;
  1007        dest_y += dest->y_ofs;
  1008        while (dest_parent->id & BMP_ID_SUB)
  1009           dest_parent = (BITMAP *)dest_parent->extra;
  1012     if (dest_x < dest->cl) {
  1015     if (dest_y < dest->ct) {
  1018     if (dest_x + width >= dest->cr) {
  1019         width = dest->cr - dest_x;
  1021     if (dest_y + height >= dest->cb) {
  1022         height = dest->cb - dest_y;
  1024     if (width < 1 || height < 1) {
  1028     vid = dest_parent->extra;
  1032         BITMAP *vbmp = vid->memory_copy;
  1035         if (vid->x_ofs >= dest_x + width || vid->y_ofs >= dest_y + height
  1036          || vid->x_ofs + vbmp->w <= dest_x
  1037          || vid->y_ofs + vbmp->h <= dest_y) {
  1043         dx = MAX (vid->x_ofs, dest_x) - vid->x_ofs;
  1044         w = MIN (vid->x_ofs + vbmp->w, dest_x + width)
  1046         dy = MAX (vid->y_ofs, dest_y) - vid->y_ofs;
  1047         h = MIN (vid->y_ofs + vbmp->h, dest_y + height)
  1050         sx = source_x + vid->x_ofs + dx - dest_x;
  1051         sy = source_y + vid->y_ofs + dy - dest_y;
  1053         if (draw_type == MASKED_BLIT) {
  1054             masked_blit(source, vbmp, sx, sy, dx, dy, w, h);
  1056         else if (draw_type == BLIT) {
  1057             blit(source, vbmp, sx, sy, dx, dy, w, h);
  1059         else if (draw_type == TRANS) {
  1060             BITMAP *clip = create_sub_bitmap(source, sx, sy, w, h);
  1063             draw_trans_sprite(vbmp, clip, dx, dy);
  1064             destroy_bitmap(clip);
  1074 #define FOR_EACH_TEXTURE_FRAGMENT(  \  1075     screen_blit_from_vid,             1077     screen_blit_from_mem,             1079     mem_copy_blit_from_vid,           1081     mem_copy_blit_from_mem,           1083     vid_and_mem_copy_blit_from_vid,   1086     vid_and_mem_copy_blit_from_mem)   1090     int used_fbo = FALSE;                                  \  1091     AGL_VIDEO_BITMAP *vid;                                 \  1093     vid = dest->extra;                                     \  1099         static GLint v[4];                                 \  1100         static double allegro_gl_projection_matrix[16];    \  1101         static double allegro_gl_modelview_matrix[16];     \  1103         glGetIntegerv(GL_VIEWPORT, &v[0]);                 \  1104         glMatrixMode(GL_MODELVIEW);                        \  1105         glGetDoublev(GL_MODELVIEW_MATRIX, allegro_gl_modelview_matrix);   \  1106         glMatrixMode(GL_PROJECTION);                                      \  1107         glGetDoublev(GL_PROJECTION_MATRIX, allegro_gl_projection_matrix); \  1110             if (dest_x >= vid->x_ofs + vid->memory_copy->w ||             \  1111                 dest_y >= vid->y_ofs + vid->memory_copy->h ||             \  1112                 vid->x_ofs >= dest_x + width ||          \  1113                 vid->y_ofs >= dest_y + height) {         \  1118             dx = MAX(vid->x_ofs, dest_x) - vid->x_ofs;                  \  1119             w = MIN(vid->x_ofs + vid->memory_copy->w, dest_x + width)   \  1120               - vid->x_ofs - dx;                                        \  1121             dy = MAX(vid->y_ofs, dest_y) - vid->y_ofs;                  \  1122             h = MIN(vid->y_ofs + vid->memory_copy->h, dest_y + height)  \  1123               - vid->y_ofs - dy;                                        \  1125             sx = source_x + vid->x_ofs + dx - dest_x;                   \  1126             sy = source_y + vid->y_ofs + dy - dest_y;                   \  1128             glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, vid->fbo);         \  1130             glViewport(0, 0, vid->memory_copy->w, vid->memory_copy->h); \  1131             glMatrixMode(GL_PROJECTION);                                \  1133             gluOrtho2D(0, vid->memory_copy->w, 0, vid->memory_copy->h); \  1134             glMatrixMode(GL_MODELVIEW);                                 \  1136             if (is_memory_bitmap(source)) {  \  1137                 screen_blit_from_mem;        \  1140                 screen_blit_from_vid;        \  1146         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); \  1148         glViewport(v[0], v[1], v[2], v[3]);          \  1149         glMatrixMode(GL_PROJECTION);                 \  1150         glLoadMatrixd(allegro_gl_projection_matrix); \  1151         glMatrixMode(GL_MODELVIEW);                  \  1152         glLoadMatrixd(allegro_gl_modelview_matrix);  \  1157     if (is_video_bitmap(source)) {        \  1162         vid = source->extra;   \  1165             if (source_x >= vid->x_ofs + vid->memory_copy->w ||  \  1166                 source_y >= vid->y_ofs + vid->memory_copy->h ||  \  1167                 vid->x_ofs >= source_x + width ||                \  1168                 vid->y_ofs >= source_y + height) {               \  1173             sx = MAX(vid->x_ofs, source_x) - vid->x_ofs;         \  1174             w = MIN(vid->x_ofs + vid->memory_copy->w, source_x + width)  \  1175               - vid->x_ofs - sx;                                         \  1176             sy = MAX(vid->y_ofs, source_y) - vid->y_ofs;                 \  1177             h = MIN(vid->y_ofs + vid->memory_copy->h, source_y + height) \  1178               - vid->y_ofs - sy;                                         \  1180             dx = dest_x + vid->x_ofs + sx - source_x;  \  1181             dy = dest_y + vid->y_ofs + sy - source_y;  \  1184                 mem_copy_blit_from_vid;                \  1187                 vid_and_mem_copy_blit_from_vid;        \  1193     else if (is_memory_bitmap(source)) {       \  1195             mem_copy_blit_from_mem;            \  1198             vid_and_mem_copy_blit_from_mem;    \  1207 void allegro_gl_video_blit_to_self(
struct BITMAP *source, 
struct BITMAP *dest,
  1208     int source_x, 
int source_y, 
int dest_x, 
int dest_y, 
int width, 
int height) {
  1210     FOR_EACH_TEXTURE_FRAGMENT (
  1211         allegro_gl_screen_blit_to_self(source, screen, sx, sy, dx, dy, w, h),
  1212         allegro_gl_screen_blit_to_self(source, screen, sx, sy, dx, dy, w, h),
  1213         __video_update_memory_copy(vid->memory_copy, dest, sx, sy, dx, dy, w, h, BLIT),
  1214         __video_update_memory_copy(source, dest, source_x, source_y, dest_x, dest_y, width, height, BLIT),
  1215         allegro_gl_video_blit_from_memory(vid->memory_copy, dest, sx, sy, dx, dy, w, h),
  1216         allegro_gl_video_blit_from_memory(source, dest, source_x, source_y, dest_x, dest_y, width, height)
  1221 static void do_masked_blit_video(
struct BITMAP *source, 
struct BITMAP *dest,
  1222             int source_x, 
int source_y, 
int dest_x, 
int dest_y,
  1223             int width, 
int height, 
int flip_dir, 
int blit_type) {
  1225     FOR_EACH_TEXTURE_FRAGMENT (
  1226         do_masked_blit_screen(source, screen, sx, sy, dx, dy, w, h, flip_dir, blit_type),
  1227         do_masked_blit_screen(source, screen, sx, sy, dx, dy, w, h, flip_dir, blit_type),
  1228         __video_update_memory_copy(vid->memory_copy, dest, sx, sy, dx, dy, w, h, MASKED_BLIT),
  1229         __video_update_memory_copy(source, dest, source_x, source_y, dest_x, dest_y, width, height, MASKED_BLIT),
  1230         allegro_gl_video_blit_from_memory_ex(vid->memory_copy, dest, sx, sy, dx, dy, w, h, MASKED_BLIT),
  1231         allegro_gl_video_blit_from_memory_ex(source, dest, source_x, source_y, dest_x, dest_y, width, height, MASKED_BLIT)
  1239 static void allegro_gl_video_masked_blit(
struct BITMAP *source,
  1240                 struct BITMAP *dest, 
int source_x, 
int source_y,
  1241                 int dest_x, 
int dest_y, 
int width, 
int height) {
  1242     do_masked_blit_video(source, dest, source_x, source_y, dest_x, dest_y,
  1243                          width, height, FALSE, AGL_REGULAR_BMP | AGL_NO_ROTATION);
  1252 static void allegro_gl_video_draw_sprite(
struct BITMAP *bmp,
  1253                         struct BITMAP *sprite, 
int x, 
int y) {
  1255     do_masked_blit_video(sprite, bmp, 0, 0, x, y, sprite->w, sprite->h,
  1256                          FALSE, AGL_NO_ROTATION);
  1267 static void allegro_gl_video_draw_sprite_v_flip(
struct BITMAP *bmp,
  1268                         struct BITMAP *sprite, 
int x, 
int y) {
  1270     do_masked_blit_video(sprite, bmp, 0, 0, x, y, sprite->w, sprite->h,
  1271                          AGL_V_FLIP, AGL_NO_ROTATION);
  1282 static void allegro_gl_video_draw_sprite_h_flip(
struct BITMAP *bmp,
  1283                         struct BITMAP *sprite, 
int x, 
int y) {
  1285     do_masked_blit_video(sprite, bmp, 0, 0, x, y, sprite->w, sprite->h,
  1286                          AGL_H_FLIP, AGL_NO_ROTATION);
  1297 static void allegro_gl_video_draw_sprite_vh_flip(
struct BITMAP *bmp,
  1298                         struct BITMAP *sprite, 
int x, 
int y) {
  1300     do_masked_blit_video(sprite, bmp, 0, 0, x, y, sprite->w, sprite->h,
  1301                          AGL_V_FLIP | AGL_H_FLIP, AGL_NO_ROTATION);
  1312 static void allegro_gl_video_pivot_scaled_sprite_flip(
struct BITMAP *bmp,
  1313             struct BITMAP *sprite, fixed x, fixed y, fixed cx, fixed cy,
  1314             fixed angle, fixed scale, 
int v_flip) {
  1315     double dscale = fixtof(scale);
  1318 #define BIN_2_DEG(x) (-(x) * 180.0 / 128)  1320     glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
  1321     glMatrixMode(GL_MODELVIEW);
  1323     glTranslated(fixtof(x), fixtof(y), 0.);
  1324     glRotated(BIN_2_DEG(fixtof(angle)), 0., 0., -1.);
  1325     glScaled(dscale, dscale, dscale);
  1326     glTranslated(-fixtof(x+cx), -fixtof(y+cy), 0.);
  1328     do_masked_blit_video(sprite, bmp, 0, 0, fixtoi(x), fixtoi(y),
  1329                           sprite->w, sprite->h, v_flip ? AGL_V_FLIP : FALSE, FALSE);
  1331     glMatrixMode(matrix_mode);
  1344 static void allegro_gl_video_do_stretch_blit(BITMAP *source, BITMAP *dest,
  1345                int source_x, 
int source_y, 
int source_width, 
int source_height,
  1346                int dest_x, 
int dest_y, 
int dest_width, 
int dest_height,
  1350     double scalew = ((double)dest_width) / source_width;
  1351     double scaleh = ((double)dest_height) / source_height;
  1357         if ((dest_x >= dest->cr) || (dest_y >= dest->cb)
  1358          || (dest_x + dest_width < dest->cl) || (dest_y + dest_height < dest->ct)) {
  1361         if (dest_x < dest->cl) {
  1362             source_x -= (dest_x - dest->cl) / scalew;
  1365         if (dest_y < dest->ct) {
  1366             source_y -= (dest_y - dest->ct) / scaleh;
  1369         if (dest_x + dest_width > dest->cr) {
  1370             source_width -= (dest_x + dest_width - dest->cr) / scalew;
  1371             dest_width = dest->cr - dest_x;
  1373         if (dest_y + dest_height > dest->cb) {
  1374             source_height -= (dest_y + dest_height - dest->cb) / scaleh;
  1375             dest_height = dest->cb - dest_y;
  1379     glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
  1380     glMatrixMode(GL_MODELVIEW);
  1382     glTranslated(dest_x, dest_y, 0.);
  1383     glScaled(scalew, scaleh, 1.);
  1384     glTranslated(-dest_x, -dest_y, 0.);
  1387         if (is_screen_bitmap(dest)) {
  1388             do_masked_blit_screen(source, dest, source_x, source_y,
  1389                                   dest_x, dest_y, source_width, source_height,
  1390                                   FALSE, AGL_REGULAR_BMP);
  1393             do_masked_blit_video(source, dest, source_x, source_y,
  1394                                  dest_x, dest_y, source_width, source_height,
  1395                                  FALSE, AGL_REGULAR_BMP);
  1399         allegro_gl_screen_blit_to_self(source, dest, source_x, source_y,
  1400                            dest_x, dest_y, source_width, source_height);
  1404     glMatrixMode(matrix_mode);
  1414 static void allegro_gl_video_draw_trans_rgba_sprite(BITMAP *bmp,
  1415                                 BITMAP *sprite, 
int x, 
int y) {
  1417     BITMAP *source = sprite;
  1423     int width = sprite->w;
  1424     int height = sprite->h;
  1426     GLint type = __allegro_gl_get_bitmap_type(sprite, 0);
  1428     if (__allegro_gl_blit_operation == AGL_OP_LOGIC_OP)
  1429         glEnable(GL_COLOR_LOGIC_OP);
  1433     FOR_EACH_TEXTURE_FRAGMENT (
  1434         allegro_gl_screen_blit_to_self(source, screen, sx, sy, dx, dy, w, h),
  1435         allegro_gl_upload_and_display_texture(sprite, sx, sy, dx, dy, w, h, 0, format, type),
  1436         __video_update_memory_copy(vid->memory_copy, dest, sx, sy, dx, dy, w, h, TRANS),
  1437         __video_update_memory_copy(source, dest, 0, 0, x, y, sprite->w, sprite->h, TRANS),
  1438         allegro_gl_video_blit_from_memory_ex(vid->memory_copy, dest, sx, sy, dx, dy, w, h, TRANS),
  1439         allegro_gl_video_blit_from_memory_ex(source, dest, 0, 0, x, y, sprite->w, sprite->h, TRANS)
  1442     if (__allegro_gl_blit_operation == AGL_OP_LOGIC_OP)
  1443         glDisable(GL_COLOR_LOGIC_OP);
  1445         glDisable(GL_BLEND);
  1459 static void allegro_gl_video_draw_sprite_ex(BITMAP *bmp, BITMAP *sprite,
  1460                                             int x, 
int y, 
int mode, 
int flip) {
  1466         case DRAW_SPRITE_NO_FLIP:
  1469         case DRAW_SPRITE_V_FLIP:
  1472         case DRAW_SPRITE_H_FLIP:
  1475         case DRAW_SPRITE_VH_FLIP:
  1476             lflip = AGL_V_FLIP | AGL_H_FLIP;
  1481         case DRAW_SPRITE_NORMAL:
  1482             do_masked_blit_video(sprite, bmp, 0, 0, x, y,
  1483                                  sprite->w, sprite->h, lflip, FALSE);
  1485         case DRAW_SPRITE_TRANS:
  1487                 glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
  1488                 glMatrixMode(GL_MODELVIEW);
  1491                 glTranslatef(x, y, 0.f);
  1492                 glScalef((lflip&AGL_H_FLIP) ? -1 : 1, (lflip&AGL_V_FLIP)? -1 : 1, 1);
  1493                 glTranslatef(-x, -y, 0);
  1494                 glTranslatef((lflip&AGL_H_FLIP) ? -sprite->w : 0,
  1495                              (lflip&AGL_V_FLIP) ? -sprite->h : 0, 0);
  1498             allegro_gl_video_draw_trans_rgba_sprite(bmp, sprite, x, y);
  1502                 glMatrixMode(matrix_mode);
  1505         case DRAW_SPRITE_LIT:
  1513 static void allegro_gl_video_clear_to_color(BITMAP *bmp, 
int color) {
  1514     AGL_VIDEO_BITMAP *vid = bmp->extra;
  1518         static double allegro_gl_projection_matrix[16];
  1519         static double allegro_gl_modelview_matrix[16];
  1521         glGetIntegerv(GL_VIEWPORT, &v[0]);
  1522         glMatrixMode(GL_MODELVIEW);
  1523         glGetDoublev(GL_MODELVIEW_MATRIX, allegro_gl_modelview_matrix);
  1524         glMatrixMode(GL_PROJECTION);
  1525         glGetDoublev(GL_PROJECTION_MATRIX, allegro_gl_projection_matrix);
  1528             glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, vid->fbo);
  1530             glViewport(0, 0, vid->memory_copy->w, vid->memory_copy->h);
  1531             glMatrixMode(GL_PROJECTION);
  1533             gluOrtho2D(0, vid->memory_copy->w, 0, vid->memory_copy->h);
  1534             glMatrixMode(GL_MODELVIEW);
  1536             allegro_gl_screen_clear_to_color(bmp, color);
  1537             clear_to_color(vid->memory_copy, color);
  1541         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
  1543         glViewport(v[0], v[1], v[2], v[3]);
  1544         glMatrixMode(GL_PROJECTION);
  1545         glLoadMatrixd(allegro_gl_projection_matrix);
  1546         glMatrixMode(GL_MODELVIEW);
  1547         glLoadMatrixd(allegro_gl_modelview_matrix);
  1550         allegro_gl_video_rectfill(bmp, 0, 0, bmp->w, bmp->h, color);
  1559 static void allegro_gl_video_draw_color_glyph(
struct BITMAP *bmp,
  1560     struct BITMAP *sprite, 
int x, 
int y, 
int color, 
int bg)
  1562     AGL_VIDEO_BITMAP *vid = bmp->extra;
  1565     static double allegro_gl_projection_matrix[16];
  1566     static double allegro_gl_modelview_matrix[16];
  1571     glGetIntegerv(GL_VIEWPORT, &v[0]);
  1572     glMatrixMode(GL_MODELVIEW);
  1573     glGetDoublev(GL_MODELVIEW_MATRIX, allegro_gl_modelview_matrix);
  1574     glMatrixMode(GL_PROJECTION);
  1575     glGetDoublev(GL_PROJECTION_MATRIX, allegro_gl_projection_matrix);
  1577     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, vid->fbo);
  1579     glViewport(0, 0, vid->memory_copy->w, vid->memory_copy->h);
  1580     glMatrixMode(GL_PROJECTION);
  1582     gluOrtho2D(0, vid->memory_copy->w, 0, vid->memory_copy->h);
  1583     glMatrixMode(GL_MODELVIEW);
  1585     allegro_gl_screen_draw_color_glyph_ex(bmp, sprite, x, y, color, bg, 0);
  1587     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
  1589     glViewport(v[0], v[1], v[2], v[3]);
  1590     glMatrixMode(GL_PROJECTION);
  1591     glLoadMatrixd(allegro_gl_projection_matrix);
  1592     glMatrixMode(GL_MODELVIEW);
  1593     glLoadMatrixd(allegro_gl_modelview_matrix);
  1595     vid->memory_copy->vtable->draw_character(vid->memory_copy, sprite, x, y, color, bg);
  1600 static void allegro_gl_video_draw_256_sprite(BITMAP *bmp, BITMAP *sprite,
  1602     allegro_gl_video_draw_color_glyph(bmp, sprite, x, y, -1, _textmode);
  1607 static void allegro_gl_video_draw_character(BITMAP *bmp, BITMAP *sprite,
  1608                                             int x, 
int y, 
int color, 
int bg) {
  1609     allegro_gl_video_draw_color_glyph(bmp, sprite, x, y, color, bg);
  1617 static void allegro_gl_video_draw_glyph(
struct BITMAP *bmp,
  1618                                AL_CONST 
struct FONT_GLYPH *glyph, 
int x, 
int y,
  1619                                int color, 
int bg) {
  1620     AGL_VIDEO_BITMAP *vid = bmp->extra;
  1623     static double allegro_gl_projection_matrix[16];
  1624     static double allegro_gl_modelview_matrix[16];
  1629     glGetIntegerv(GL_VIEWPORT, &v[0]);
  1630     glMatrixMode(GL_MODELVIEW);
  1631     glGetDoublev(GL_MODELVIEW_MATRIX, allegro_gl_modelview_matrix);
  1632     glMatrixMode(GL_PROJECTION);
  1633     glGetDoublev(GL_PROJECTION_MATRIX, allegro_gl_projection_matrix);
  1635     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, vid->fbo);
  1637     glViewport(0, 0, vid->memory_copy->w, vid->memory_copy->h);
  1638     glMatrixMode(GL_PROJECTION);
  1640     gluOrtho2D(0, vid->memory_copy->w, 0, vid->memory_copy->h);
  1641     glMatrixMode(GL_MODELVIEW);
  1643     allegro_gl_screen_draw_glyph_ex(bmp, glyph, x, y, color, bg, 1);
  1645     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
  1647     glViewport(v[0], v[1], v[2], v[3]);
  1648     glMatrixMode(GL_PROJECTION);
  1649     glLoadMatrixd(allegro_gl_projection_matrix);
  1650     glMatrixMode(GL_MODELVIEW);
  1651     glLoadMatrixd(allegro_gl_modelview_matrix);
  1653     vid->memory_copy->vtable->draw_glyph(vid->memory_copy, glyph, x, y, color, bg);
  1658 static void allegro_gl_video_polygon3d_f(BITMAP *bmp, 
int type, BITMAP *texture,
  1659                                   int vc, V3D_f *vtx[])
  1661     AGL_VIDEO_BITMAP *vid = bmp->extra;
  1665     int use_fbo = (type == POLYTYPE_FLAT) ||
  1666                   (type == POLYTYPE_GRGB) ||
  1667                   (type == POLYTYPE_GCOL) ||
  1668                   (type == POLYTYPE_ATEX) ||
  1669                   (type == POLYTYPE_PTEX) ||
  1670                   (type == POLYTYPE_ATEX_TRANS) ||
  1671                   (type == POLYTYPE_PTEX_TRANS);
  1673     if (vid->fbo && use_fbo) {
  1675         static double allegro_gl_projection_matrix[16];
  1676         static double allegro_gl_modelview_matrix[16];
  1678         glGetIntegerv(GL_VIEWPORT, &v[0]);
  1679         glMatrixMode(GL_MODELVIEW);
  1680         glGetDoublev(GL_MODELVIEW_MATRIX, allegro_gl_modelview_matrix);
  1681         glMatrixMode(GL_PROJECTION);
  1682         glGetDoublev(GL_PROJECTION_MATRIX, allegro_gl_projection_matrix);
  1685             BITMAP *mem_texture;
  1687             glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, vid->fbo);
  1689             glViewport(0, 0, vid->memory_copy->w, vid->memory_copy->h);
  1690             glMatrixMode(GL_PROJECTION);
  1692             gluOrtho2D(0, vid->memory_copy->w, 0, vid->memory_copy->h);
  1693             glMatrixMode(GL_MODELVIEW);
  1695             allegro_gl_screen_polygon3d_f(bmp, type, texture, vc, vtx);
  1697             if (is_video_bitmap(texture)) {
  1698                 AGL_VIDEO_BITMAP *vbmp = texture->extra;
  1699                 mem_texture = vbmp->memory_copy;
  1702                 mem_texture = texture;
  1704             polygon3d_f(vid->memory_copy, type, mem_texture, vc, vtx);
  1709         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
  1711         glViewport(v[0], v[1], v[2], v[3]);
  1712         glMatrixMode(GL_PROJECTION);
  1713         glLoadMatrixd(allegro_gl_projection_matrix);
  1714         glMatrixMode(GL_MODELVIEW);
  1715         glLoadMatrixd(allegro_gl_modelview_matrix);
  1719         AGL_VIDEO_BITMAP *vid;
  1723         if (is_sub_bitmap(bmp)) {
  1724             for (i = 0; i < vc; ++i) {
  1725                 vtx[i]->x += bmp->x_ofs;
  1726                 vtx[i]->y += bmp->y_ofs;
  1731             BITMAP *mem_texture;
  1732             int _y1, _y2, _x1, _x2;
  1733             BITMAP *vbmp = vid->memory_copy;
  1736             for (i = 0; i < vc; ++i)
  1737                 if (vtx[i]->x < _x1) _x1 = vtx[i]->x;
  1740             for (i = 0; i < vc; ++i)
  1741                 if (vtx[i]->x > _x2) _x2 = vtx[i]->x;
  1744             for (i = 0; i < vc; ++i)
  1745                 if (vtx[i]->y < _y1) _y1 = vtx[i]->y;
  1748             for (i = 0; i < vc; ++i)
  1749                 if (vtx[i]->y > _y2) _y2 = vtx[i]->y;
  1751             if (vid->x_ofs > _x2 || vid->y_ofs > _y2
  1752              || vid->x_ofs + vbmp->w <= _x1
  1753              || vid->y_ofs + vbmp->h <= _y1) {
  1759             _x1 = MAX(0, _x1 - vid->x_ofs);
  1760             _x2 = (_x2 - (vid->x_ofs + vbmp->w) > 0) ? vbmp->w - 1: _x2 - vid->x_ofs;
  1761             _y1 = MAX(0, _y1 - vid->y_ofs);
  1762             _y2 = (_x2 - (vid->y_ofs + vbmp->h) > 0) ? vbmp->h - 1: _y2 - vid->y_ofs;
  1764             if (is_video_bitmap(texture)) {
  1765                 AGL_VIDEO_BITMAP *tex = texture->extra;
  1766                 mem_texture = tex->memory_copy;
  1769                 mem_texture = texture;
  1771             polygon3d_f(vid->memory_copy, type, mem_texture, vc, vtx);
  1773             update_texture_memory(vid, _x1, _y1, _x2, _y2);
  1784 static void allegro_gl_video_polygon3d(BITMAP *bmp, 
int type, BITMAP *texture,
  1788     V3D_f **vtx_f = malloc(vc * 
sizeof(
struct V3D_f*));
  1792     for (i = 0; i < vc; i++) {
  1793         vtx_f[i] = malloc(
sizeof(
struct V3D_f));
  1796             for (k = 0; k < i; k++)
  1801         vtx_f[i]->c = vtx[i]->c;
  1802         vtx_f[i]->u = fixtof(vtx[i]->u);
  1803         vtx_f[i]->v = fixtof(vtx[i]->v);
  1804         vtx_f[i]->x = fixtof(vtx[i]->x);
  1805         vtx_f[i]->y = fixtof(vtx[i]->y);
  1806         vtx_f[i]->z = fixtof(vtx[i]->z);
  1809     allegro_gl_video_polygon3d_f(bmp, type, texture, vc, vtx_f);
  1811     for (i = 0; i < vc; i++)
  1818 static void allegro_gl_video_triangle3d(BITMAP *bmp, 
int type, BITMAP *texture,
  1819                                         V3D *v1, V3D *v2, V3D *v3)
  1826     allegro_gl_video_polygon3d(bmp, type, texture, 3, vtx);
  1831 static void allegro_gl_video_triangle3d_f(BITMAP *bmp, 
int type, BITMAP *texture,
  1832                                           V3D_f *v1, V3D_f *v2, V3D_f *v3)
  1839     allegro_gl_video_polygon3d_f(bmp, type, texture, 3, vtx_f);
  1844 static void allegro_gl_video_quad3d(BITMAP *bmp, 
int type, BITMAP *texture,
  1845                                     V3D *v1, V3D *v2, V3D *v3, V3D *v4)
  1853     allegro_gl_video_polygon3d(bmp, type, texture, 4, vtx);
  1858 static void allegro_gl_video_quad3d_f(BITMAP *bmp, 
int type, BITMAP *texture,
  1859                                V3D_f *v1, V3D_f *v2, V3D_f *v3, V3D_f *v4)
  1867     allegro_gl_video_polygon3d_f(bmp, type, texture, 4, vtx_f);
  1872 static void dummy_unwrite_bank(
void)
  1878 static GFX_VTABLE allegro_gl_video_vtable = {
  1886     allegro_gl_created_sub_bitmap,
  1887     allegro_gl_video_getpixel,
  1888     allegro_gl_video_putpixel,
  1889     allegro_gl_video_vline,
  1890     allegro_gl_video_hline,
  1891     allegro_gl_video_hline,
  1892     allegro_gl_video_line,
  1893     allegro_gl_video_line,
  1894     allegro_gl_video_rectfill,
  1895     allegro_gl_video_triangle,
  1896     allegro_gl_video_draw_sprite,
  1897     allegro_gl_video_draw_256_sprite,
  1898     allegro_gl_video_draw_sprite_v_flip,
  1899     allegro_gl_video_draw_sprite_h_flip,
  1900     allegro_gl_video_draw_sprite_vh_flip,
  1901     allegro_gl_video_draw_trans_rgba_sprite,
  1902     allegro_gl_video_draw_trans_rgba_sprite,
  1908     allegro_gl_video_draw_character,
  1909     allegro_gl_video_draw_glyph,
  1910     allegro_gl_video_blit_from_memory,
  1911     allegro_gl_video_blit_to_memory,
  1914     allegro_gl_screen_blit_to_self, 
  1915     allegro_gl_screen_blit_to_self, 
  1916     allegro_gl_screen_blit_to_self, 
  1917     allegro_gl_memory_blit_between_formats,
  1918     allegro_gl_video_masked_blit,
  1919     allegro_gl_video_clear_to_color,
  1920     allegro_gl_video_pivot_scaled_sprite_flip,
  1921     allegro_gl_video_do_stretch_blit,
  1934     allegro_gl_video_polygon3d,
  1935     allegro_gl_video_polygon3d_f,
  1936     allegro_gl_video_triangle3d,
  1937     allegro_gl_video_triangle3d_f,
  1938     allegro_gl_video_quad3d,
  1939     allegro_gl_video_quad3d_f,
  1940     allegro_gl_video_draw_sprite_ex
 struct AGL_EXTENSION_LIST_GL allegro_gl_extensions_GL
List of OpenGL extensions supported by AllegroGL. 
 
static void allegro_gl_video_acquire(struct BITMAP *bmp)
acquire_bitmap(bmp) overload. 
 
void allegro_gl_destroy_video_bitmap(BITMAP *bmp)
destroy_video_bitmap() overload. 
 
Main header file for AllegroGL. 
 
static void allegro_gl_video_release(struct BITMAP *bmp)
release_bitmap(bmp) overload. 
 
#define AGL_TEXTURE_HAS_ALPHA
Tell AllegroGL that the bitmap had an alpha channel, so it should be preserved when generating the te...
 
BITMAP * allegro_gl_create_video_bitmap(int w, int h)
create_video_bitmap() overload. 
 
GLint allegro_gl_set_video_bitmap_color_depth(int bpp)
Sets the color depth you'd like AllegroGL to use for video bitmaps.