[AD] Skater + AllegroGL

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


I'm proud to announce that the Skater demo now can work with AllegroGL, using hardware acceleration if available, without a single OpenGL command in the game code.

The only modification to the game code consist of:
- added code for AGL initialization (mandatory)
- added new gfx update driver (mandatory)
- convert all bitmaps to video bitmaps on load (not mandatory, but the whole thing losses sense without this)
- added support for AGL fonts support (quite extensive modification) [1]
- used
rectfill(buffer, 0, 0, buffer->w, fixtoi(lowy) + 1, getpixel(cloud, 0, 0));
 instead of:
 set_clip_rect(buffer, 0, 0, buffer->w, fixtoi(lowy));
 clear_to_color(buffer, getpixel(cloud, 0, 0));
 set_clip_rect(buffer, 0, 0, buffer->w, buffer->h);
 to workaround a AGL bug.  (not a big deal)
- other really minor things.

I think I didn't miss anything.


Differences to non-AGL Skater that I can notice:
- higher FPS and less CPU time used :)
- the "transition" animation looks a bit broken
- the grass (the surface where our hero is skating) contains pink pixels. That's because 3D polygons with masked textures are not supported by AGL and probably will never be. I am asking here if I can change the grass sprite the use sky-blue at those spots? It's all blue background anyways.


With this I'm trying to show you that AGL's gfx driver is becoming mature for more serious usage. I think it is ready for 4.3 branch.


To try it out:

- get AllegroGL from SVN:
svn co https://allegrogl.svn.sourceforge.net/svnroot/allegrogl/trunk allegro

Compile & install AGL.


- get Skater from SVN:
svn co https://alleg.svn.sourceforge.net/svnroot/alleg/demos/skater skater

- apply the attached patch to Skater.
cd skater/
patch -p0 <skater_agl.diff

Compile Skater using "scons" command. If you wish to build Skater with disabled AllegroGL support remove the two related defines from SConstruct file.


[1] If SKATER_USE_ALLEGRO_GL_FONT is defined (default) Skater will use AGL fonts. These are faster then regular Allegro fonts but currently cannot be drawn onto video bitmaps, thus text will not display during the "transition" animation which lasts for 0.3 seconds by the way. Regular Allegro fonts could be used instead, they which can be drawn onto video bitmaps and do not require modification of the existing code... The only drawback is that they are very slow. To try it out with regular Allegro fonts undefine ALLEGRO_USE_ALLEGRO_GL_FONT in SConstruct file.

--
Milan Mimica
http://sparklet.sf.net

Index: skater/include/oglflip.h
===================================================================
--- skater/include/oglflip.h	(revision 0)
+++ skater/include/oglflip.h	(revision 0)
@@ -0,0 +1,8 @@
+#ifndef		__DEMO_OGL_FLIPPING_H__
+#define		__DEMO_OGL_FLIPPING_H__
+
+#include "updtedvr.h"
+
+extern void select_ogl_flipping(DEMO_SCREEN_UPDATE_DRIVER *driver);
+
+#endif				/* __DEMO_OGL_FLIPPING_H__ */
Index: skater/include/global.h
===================================================================
--- skater/include/global.h	(revision 7749)
+++ skater/include/global.h	(working copy)
@@ -50,6 +50,13 @@
 /* The big title font (coloured). */
 extern FONT *demo_font_logo;
 
+/* The big title font (monocrome in AllegroGL mode, same as demo_font_logo
+   in normal mode). Needed because of limitation in AllegroGL text output.*/
+extern FONT *demo_font_logo_m;
+
+/* Font made of default allegro font (monochrome). */
+extern FONT *plain_font;
+
 /* The update driver object that is used by the framework. */
 extern DEMO_SCREEN_UPDATE_DRIVER update_driver;
 
@@ -119,13 +126,44 @@
 
 
 /*
+   Facade for text output functions. Implements a common interface for text
+   output using Allegro's or AllegroGL's text output functions.
+   Text alignment is selected with a parameter.
+
+   Parameters:
+      BITMAP *canvas, int x, int y, int col and char *format have
+         exactly the same meaning as in the equivalent Allegro built-in
+         text output functions.
+      FONT *font can be either plain Allegro font or a font converted with
+      AllegroGL's allegro_gl_convert_allegro_font_ex().
+      int align - defines alignemnt: 0 = left, 1 = right, 2 = centre
+
+   Returns:
+      nothing
+*/
+extern void demo_textprintf_ex(BITMAP * canvas, const FONT * font, int x, int y,
+      int col, int bg, int align, const char *format, ...);
+extern void demo_textprintf(BITMAP * canvas, const FONT * font, int x, int y,
+      int col, int bg, const char *format, ...);
+extern void demo_textprintf_right(BITMAP * canvas, const FONT * font, int x, int y,
+      int col, int bg, const char *format, ...);
+extern void demo_textprintf_centre(BITMAP * canvas, const FONT * font, int x, int y,
+      int col, int bg, const char *format, ...);
+extern void demo_textout(BITMAP *bmp, const FONT *f, const char *s, int x,
+      int y, int color, int bg);
+extern void demo_textout_right(BITMAP *bmp, const FONT *f, const char *s,
+      int x, int y, int color, int bg);
+extern void demo_textout_centre(BITMAP *bmp, const FONT *f, const char *s,
+      int x, int y, int color, int bg);
+
+/*
    Custom text output function. Similar to the Allegro's built-in functions
    except that text alignment is selected with a parameter and the text is
    printed with a black shadow. Offset of the shadow is defined with the
    shadow_offset variable.
 
    Parameters:
-      BITMAP *canvas, FONT *font int x, int y, int col and char *text have
+      BITMAP *canvas, FONT *font, int x, int y, int col and char *text have
          exactly the same meaning as in the equivalent Allegro built-in
          text output functions.
       int align - defines alignemnt: 0 = left, 1 = right, 2 = centre
@@ -133,7 +171,7 @@
    Returns:
       nothing
 */
-extern void demo_textprintf(BITMAP * canvas, FONT * font, int x, int y,
+extern void shadow_textprintf(BITMAP * canvas, FONT * font, int x, int y,
       int col, int align, const char *text, ...);
 
 /*
Index: skater/include/defines.h
===================================================================
--- skater/include/defines.h	(revision 7749)
+++ skater/include/defines.h	(working copy)
@@ -18,6 +18,7 @@
 #define      DEMO_DOUBLE_BUFFER   1
 #define      DEMO_PAGE_FLIPPING   2
 #define      DEMO_TRIPLE_BUFFER   3
+#define      DEMO_OGL_FLIPPING    4
 
 /* Input controller IDs */
 #define      DEMO_CONTROLLER_KEYBOARD   0
Index: skater/src/transitn.c
===================================================================
--- skater/src/transitn.c	(revision 7749)
+++ skater/src/transitn.c	(working copy)
@@ -13,14 +13,22 @@
    t->duration = duration;
    t->progress = 0.0f;
 
+#ifdef SKATER_USE_ALLEGRO_GL
+   t->from_bmp = create_video_bitmap(SCREEN_W, SCREEN_H);
+#else
    t->from_bmp = create_bitmap(SCREEN_W, SCREEN_H);
+#endif
    if (from) {
       from->draw(t->from_bmp);
    } else {
       clear_to_color(t->from_bmp, makecol(0, 0, 0));
    }
 
+#ifdef SKATER_USE_ALLEGRO_GL
+   t->to_bmp = create_video_bitmap(SCREEN_W, SCREEN_H);
+#else
    t->to_bmp = create_bitmap(SCREEN_W, SCREEN_H);
+#endif
    if (to) {
       to->draw(t->to_bmp);
    } else {
Index: skater/src/menugfx.c
===================================================================
--- skater/src/menugfx.c	(revision 7749)
+++ skater/src/menugfx.c	(working copy)
@@ -21,6 +21,7 @@
    "1152x768",
    "1280x960", "1440x960", "1600x1200", "1800x1200", 0
 };
+
 static char *choice_update[] =
    { "double buffer", "page flipping", "triple buffer", 0 };
 
@@ -41,8 +42,13 @@
     (void **)choice_bpp, 0},
    {demo_choice_proc, "Screen Size", DEMO_MENU_SELECTABLE, 0,
     (void **)choice_res, 0},
+#ifdef SKATER_USE_ALLEGRO_GL
+   {demo_choice_proc, "Update Method", 0, 0,
+    (void **)choice_update, 0},
+#else
    {demo_choice_proc, "Update Method", DEMO_MENU_SELECTABLE, 0,
     (void **)choice_update, 0},
+#endif
    {demo_choice_proc, "Vsync", DEMO_MENU_SELECTABLE, 0,
     (void **)choice_on_off, on_vsync},
    {demo_button_proc, "Apply", DEMO_MENU_SELECTABLE, DEMO_STATE_GFX,
Index: skater/src/quadtree.c
===================================================================
--- skater/src/quadtree.c	(revision 7749)
+++ skater/src/quadtree.c	(working copy)
@@ -42,7 +42,9 @@
 */
 
 #include "level.h"
-
+#ifdef SKATER_USE_ALLEGRO_GL
+#include <alleggl.h>
+#endif
 /*
 
 	CentreX and CentreY are macros that evaluate to the centre point of the
@@ -427,8 +429,13 @@
          PolyEdges[0].v = PolyEdges[1].v = 0;
          PolyEdges[2].v = PolyEdges[3].v = itofix(tri->Material->Edge->h);
 
+#ifdef SKATER_USE_ALLEGRO_GL
+         quad3d(target, POLYTYPE_ATEX, tri->Material->Edge,
+                &PolyEdges[0], &PolyEdges[1], &PolyEdges[2], &PolyEdges[3]);
+#else
          quad3d(target, POLYTYPE_ATEX_MASK, tri->Material->Edge,
                 &PolyEdges[0], &PolyEdges[1], &PolyEdges[2], &PolyEdges[3]);
+#endif
       }
    }
 }
@@ -460,6 +467,7 @@
             tri->Edges[1]->Pos[1] - ScrBounder->TL.Pos[1],
             tri->Edges[2]->Pos[0] - ScrBounder->TL.Pos[0],
             tri->Edges[2]->Pos[1] - ScrBounder->TL.Pos[1], 0);
+	solid_mode();
 }
 
 /*
Index: skater/src/fps.c
===================================================================
--- skater/src/fps.c	(revision 7749)
+++ skater/src/fps.c	(working copy)
@@ -4,6 +4,7 @@
 
 #include <allegro.h>
 #include "fps.h"
+#include "global.h"
 
 
 FPS *create_fps(int fps)
@@ -60,5 +61,6 @@
 void draw_fps(FPS * fps, BITMAP *bmp, FONT *font, int x, int y, int fg,
               char *format)
 {
-   textprintf_ex(bmp, font, x, y, fg, -1, format, get_fps(fps));
+   demo_textprintf(bmp, plain_font, x, y, fg, makecol(0, 0, 0), format,
+                   get_fps(fps));
 }
Index: skater/src/global.c
===================================================================
--- skater/src/global.c	(revision 7749)
+++ skater/src/global.c	(working copy)
@@ -1,4 +1,8 @@
 #include <allegro.h>
+#ifdef SKATER_USE_ALLEGRO_GL
+    #include <alleggl.h>
+    #include "oglflip.h"
+#endif
 #include "backscrl.h"
 #include "dblbuf.h"
 #include "demodata.h"
@@ -32,6 +36,8 @@
 char data_path[DEMO_PATH_LENGTH];
 FONT *demo_font;
 FONT *demo_font_logo;
+FONT *demo_font_logo_m;
+FONT *plain_font;
 DATAFILE *demo_data = 0;
 
 DEMO_SCREEN_UPDATE_DRIVER update_driver = { 0, 0, 0, 0 };
@@ -149,14 +155,32 @@
 
    /* Select appropriate (fullscreen or windowed) autodetect gfx
       mode driver. */
+#ifdef SKATER_USE_ALLEGRO_GL
    if (fullscreen == 1) {
+      gfx_mode = GFX_OPENGL_FULLSCREEN;
+   } else {
+      gfx_mode = GFX_OPENGL_WINDOWED;
+   }
+#else
+   if (fullscreen == 1) {
       gfx_mode = GFX_AUTODETECT_FULLSCREEN;
    } else {
       gfx_mode = GFX_AUTODETECT_WINDOWED;
    }
+#endif
 
+
+#ifdef SKATER_USE_ALLEGRO_GL
+   install_allegro_gl();
+   allegro_gl_set(AGL_COLOR_DEPTH, bit_depth);
+   allegro_gl_set(AGL_DOUBLEBUFFER, 1);
+   allegro_gl_set(AGL_RENDERMETHOD, 1);
+   allegro_gl_set(AGL_SUGGEST, AGL_COLOR_DEPTH | AGL_DOUBLEBUFFER | AGL_RENDERMETHOD);
+#else
+   set_color_depth(bit_depth);
+#endif
+
    /* Attempt to set the selected colour depth and gfx mode. */
-   set_color_depth(bit_depth);
    if (set_gfx_mode(gfx_mode, screen_width, screen_height, 0, 0) != 0) {
       /* If setting gfx mode failed, try an alternative colour depth. 8bpp
          doesn't have an alternative, but 15 and 16 can be exchanged as well
@@ -196,12 +220,22 @@
       }
    }
 
+#ifdef SKATER_USE_ALLEGRO_GL
+   /* Needed for Allegro drawnig functions to behave. Also sets the Allegro
+      coordinate system. */
+   allegro_gl_set_allegro_mode();
+#endif
+
    /* blank display now, before doing any more complicated stuff */
    clear_to_color(screen, makecol(0, 0, 0));
    if (fullscreen) {
       show_os_cursor(MOUSE_CURSOR_NONE);
    }
 
+#ifdef SKATER_USE_ALLEGRO_GL
+   /* OpenGL doesn't let us choose the update mode. */
+   select_update_driver(DEMO_OGL_FLIPPING);
+#else
    /* select update driver */
    switch (update_driver_id) {
       case DEMO_TRIPLE_BUFFER:
@@ -223,6 +257,7 @@
       default:
          ret = DEMO_ERROR_GFX;
    };
+#endif
 
    /* Attempt to load game data. */
    ret = load_data();
@@ -248,8 +283,35 @@
       return DEMO_ERROR_DATA;
    }
 
+#ifdef SKATER_USE_ALLEGRO_GL_FONT
+   /* Convert Allegro FONT to AllegroGL FONT. */
+   /* Note that we could use Allegro's FONT and text output routines in
+      AllegroGL mode but it is proven to be very slow. */
+
+   demo_font = allegro_gl_convert_allegro_font_ex(demo_data[DEMO_FONT].dat,
+               AGL_FONT_TYPE_TEXTURED, -1.0, GL_ALPHA8);
+
+   set_palette(demo_data[DEMO_MENU_PALETTE].dat);
+   demo_font_logo = allegro_gl_convert_allegro_font_ex(
+                    demo_data[DEMO_FONT_LOGO].dat, AGL_FONT_TYPE_TEXTURED,
+                    -1.0, GL_RGBA8);
+
+   /* Due to lack of the flexibility in AllegroGL text output routines we need
+      an additional FONT that is equivalent to demo_font_logo - but monocrome.
+      This allows tinting it to any color, which cannot be done with true color
+      fonts (paletred fonts are not supported by AllegroGL). */
+   demo_font_logo_m = allegro_gl_convert_allegro_font_ex(
+                    demo_data[DEMO_FONT_LOGO].dat, AGL_FONT_TYPE_TEXTURED,
+                    -1.0, GL_ALPHA8);
+
+   plain_font = allegro_gl_convert_allegro_font_ex(font,
+                AGL_FONT_TYPE_TEXTURED, -1.0, GL_ALPHA8);
+#else
    demo_font = demo_data[DEMO_FONT].dat;
    demo_font_logo = demo_data[DEMO_FONT_LOGO].dat;
+   demo_font_logo_m = demo_font_logo;
+   plain_font = font;
+#endif
 
    /* Load other game resources. */
    if ((GameError = load_game_resources()))
@@ -266,12 +328,40 @@
       unload_game_resources();
       demo_data = 0;
    }
+
+#ifdef SKATER_USE_ALLEGRO_GL_FONT
+   allegro_gl_destroy_font(demo_font);
+   allegro_gl_destroy_font(demo_font_logo);
+   allegro_gl_destroy_font(demo_font_logo_m);
+   allegro_gl_destroy_font(plain_font);
+#endif
 }
 
 
-void demo_textprintf(BITMAP *canvas, FONT *font, int x, int y,
-                     int col, int align, const char *format, ...)
+void demo_textout(BITMAP *bmp, const FONT *f, const char *s, int x, int y,
+                  int color, int bg)
 {
+   demo_textprintf(bmp, f, x, y, color, bg, "%s", s);
+}
+
+
+void demo_textout_right(BITMAP *bmp, const FONT *f, const char *s, int x, int y,
+                  int color, int bg)
+{
+   demo_textprintf_right(bmp, f, x, y, color, bg, "%s", s);
+}
+
+
+void demo_textout_centre(BITMAP *bmp, const FONT *f, const char *s, int x, int y,
+                  int color, int bg)
+{
+   demo_textprintf_centre(bmp, f, x, y, color, bg, "%s", s);
+}
+
+
+void demo_textprintf_centre(BITMAP *canvas, const FONT *font, int x, int y,
+                     int col, int bg, const char *format, ...)
+{
    char buf[512];
 
    va_list ap;
@@ -280,28 +370,108 @@
    uvszprintf(buf, sizeof(buf), format, ap);
    va_end(ap);
 
+   demo_textprintf_ex(canvas, font, x, y, col, bg, 2, "%s", buf);
+}
+
+
+void demo_textprintf_right(BITMAP *canvas, const FONT *font, int x, int y,
+                     int col, int bg, const char *format, ...)
+{
+   char buf[512];
+
+   va_list ap;
+
+   va_start(ap, format);
+   uvszprintf(buf, sizeof(buf), format, ap);
+   va_end(ap);
+
+   demo_textprintf_ex(canvas, font, x, y, col, bg, 1, "%s", buf);
+}
+
+
+void demo_textprintf(BITMAP *canvas, const FONT *font, int x, int y,
+                     int col, int bg, const char *format, ...)
+{
+   char buf[512];
+
+   va_list ap;
+
+   va_start(ap, format);
+   uvszprintf(buf, sizeof(buf), format, ap);
+   va_end(ap);
+
+   demo_textprintf_ex(canvas, font, x, y, col, bg, 0, "%s", buf);
+}
+
+void demo_textprintf_ex(BITMAP *canvas, const FONT *font, int x, int y,
+                     int col, int bg, int align, const char *format, ...)
+{
+   char buf[512];
+
+   va_list ap;
+
+   va_start(ap, format);
+   uvszprintf(buf, sizeof(buf), format, ap);
+   va_end(ap);
+
+#ifdef SKATER_USE_ALLEGRO_GL_FONT
+   if (bg != -1) {
+      rectfill(canvas, x, y,
+               x + text_length(font, buf), y + text_height(font), bg);
+   }
+
    switch (align) {
+      case 1:
+         x = x - text_length(font, buf);
+         break;
+      case 2:
+         x = x - text_length(font, buf) / 2;
+         break;
+   };
+
+   glEnable(GL_TEXTURE_2D);
+   glEnable(GL_BLEND);
+   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+   allegro_gl_printf(font, x, y, 0, col, "%s", buf);
+
+   glDisable(GL_BLEND);
+   glDisable(GL_TEXTURE_2D);
+
+#else
+
+   switch (align) {
       case 0:
-         textout_ex(canvas, font, buf, x + shadow_offset, y + shadow_offset,
-                    0, -1);
-         textout_ex(canvas, font, buf, x, y, col, -1);
+         textprintf_ex(canvas, font, x, y, col, bg, "%s", buf);
          break;
-
       case 1:
-         textout_right_ex(canvas, font, buf, x + shadow_offset,
-                          y + shadow_offset, 0, -1);
-         textout_right_ex(canvas, font, buf, x, y, col, -1);
+         textprintf_right_ex(canvas, font, x, y, col, bg, "%s", buf);
          break;
-
       case 2:
-         textout_centre_ex(canvas, font, buf, x + shadow_offset,
-                           y + shadow_offset, 0, -1);
-         textout_centre_ex(canvas, font, buf, x, y, col, -1);
+         textprintf_centre_ex(canvas, font, x, y, col, bg, "%s", buf);
          break;
    };
+#endif
 }
 
 
+void shadow_textprintf(BITMAP *canvas, FONT *font, int x, int y,
+                     int col, int align, const char *format, ...)
+{
+   char buf[512];
+
+   va_list ap;
+
+   va_start(ap, format);
+   uvszprintf(buf, sizeof(buf), format, ap);
+   va_end(ap);
+
+   demo_textprintf_ex(canvas, font, x + shadow_offset, y + shadow_offset, 0, -1,
+                   align, "%s", buf);
+   demo_textprintf_ex(canvas, font, x, y, col, -1, align, "%s", buf);
+}
+
+
 int select_update_driver(int id)
 {
    int error;
@@ -326,6 +496,11 @@
       case DEMO_TRIPLE_BUFFER:
          select_triple_buffer(&new_driver);
          break;
+#ifdef SKATER_USE_ALLEGRO_GL
+      case DEMO_OGL_FLIPPING:
+         select_ogl_flipping(&new_driver);
+         break;
+#endif
    };
 
    if (!new_driver.create) {
Index: skater/src/menu.c
===================================================================
--- skater/src/menu.c	(revision 7749)
+++ skater/src/menu.c	(working copy)
@@ -163,9 +163,9 @@
 
    x = SCREEN_W / 2;
    y = 1 * SCREEN_H / 6 - text_height(demo_font_logo) / 2;
-   textprintf_centre_ex(canvas, demo_font_logo, x + 6, y + 5,
+   demo_textprintf_centre(canvas, demo_font_logo_m, x + 6, y + 5,
                         makecol(128, 128, 128), -1, logo_text);
-   textprintf_centre_ex(canvas, demo_font_logo, x, y, -1, -1, logo_text);
+   demo_textprintf_centre(canvas, demo_font_logo, x, y, -1, -1, logo_text);
 
    /* calculate height of the whole menu and the starting y coordinate */
    h = 0;
@@ -210,7 +210,7 @@
 int demo_text_proc(DEMO_MENU * item, int msg, int extra)
 {
    if (msg == DEMO_MENU_MSG_DRAW) {
-      demo_textprintf(demo_menu_canvas, demo_font, SCREEN_W / 2,
+      shadow_textprintf(demo_menu_canvas, demo_font, SCREEN_W / 2,
                       extra, makecol(210, 230, 255), 2, item->name);
    } else if (msg == DEMO_MENU_MSG_WIDTH) {
       return text_length(demo_font, item->name);
@@ -241,7 +241,7 @@
                (SCREEN_W + w) / 2 + 2, extra + h + 2, 0);
       rect(demo_menu_canvas, (SCREEN_W - w) / 2 - 2, extra - 2,
            (SCREEN_W + w) / 2 + 2, extra + h + 2, col);
-      demo_textprintf(demo_menu_canvas, demo_font, SCREEN_W / 2,
+      shadow_textprintf(demo_menu_canvas, demo_font, SCREEN_W / 2,
                       extra, col, 2, item->name);
       if (item->flags & DEMO_MENU_SELECTED) {
          x = (SCREEN_W + text_length(demo_font, item->name)) / 2 + 2;
@@ -299,7 +299,7 @@
          col = makecol(255, 255, 255);
       }
 
-      demo_textprintf(demo_menu_canvas, demo_font, SCREEN_W / 2,
+      shadow_textprintf(demo_menu_canvas, demo_font, SCREEN_W / 2,
                       extra, col, 2, item->name);
    } else if (msg == DEMO_MENU_MSG_KEY) {
       switch (extra >> 8) {
@@ -342,7 +342,7 @@
       x = (SCREEN_W - slider_width) / 2;
 
       /* print name of the item */
-      demo_textprintf(demo_menu_canvas, demo_font, x - 8, extra, col, 1,
+      shadow_textprintf(demo_menu_canvas, demo_font, x - 8, extra, col, 1,
                       item->name);
 
       /* draw slider thingy */
@@ -376,7 +376,7 @@
       x += slider_width;
 
       /* print selected choice */
-      demo_textprintf(demo_menu_canvas, demo_font, x + 8, extra, col,
+      shadow_textprintf(demo_menu_canvas, demo_font, x + 8, extra, col,
                       0, (char *)(item->data)[item->extra]);
    } else if (msg == DEMO_MENU_MSG_KEY) {
       switch (extra >> 8) {
@@ -433,14 +433,14 @@
          col = makecol(255, 255, 255);
       }
 
-      demo_textprintf(demo_menu_canvas, demo_font, SCREEN_W / 2 - 16,
+      shadow_textprintf(demo_menu_canvas, demo_font, SCREEN_W / 2 - 16,
                       extra, col, 1, item->name);
 
       if (item->flags & DEMO_MENU_EXTRA) {
-         demo_textprintf(demo_menu_canvas, demo_font,
+         shadow_textprintf(demo_menu_canvas, demo_font,
                          SCREEN_W / 2 + 16, extra, col, 0, "...");
       } else {
-         demo_textprintf(demo_menu_canvas, demo_font,
+         shadow_textprintf(demo_menu_canvas, demo_font,
                          SCREEN_W / 2 + 16, extra, col, 0,
                          controller[controller_id]->
                          get_button_description(controller
@@ -512,7 +512,7 @@
       x = SCREEN_W / 2 - (slider_width + 4) * 3 / 2;
       h = text_height(demo_font);
 
-      demo_textprintf(demo_menu_canvas, demo_font, x - 8, extra, col1,
+      shadow_textprintf(demo_menu_canvas, demo_font, x - 8, extra, col1,
                       1, item->name);
 
       c = *(int *)(item->data);
@@ -539,7 +539,7 @@
       }
 
       uszprintf(buf, sizeof(buf), "%d,%d,%d", rgb[0], rgb[1], rgb[2]);
-      demo_textprintf(demo_menu_canvas, demo_font, x + 8, extra, c, 0, buf);
+      shadow_textprintf(demo_menu_canvas, demo_font, x + 8, extra, c, 0, buf);
    } else if (msg == DEMO_MENU_MSG_KEY) {
       c = *(int *)(item->data);
 
Index: skater/src/level.c
===================================================================
--- skater/src/level.c	(revision 7749)
+++ skater/src/level.c	(working copy)
@@ -69,12 +69,23 @@
 
 BITMAP *ObtainBitmap(const char *name)
 {
+#ifdef SKATER_USE_ALLEGRO_GL
+   BITMAP *ret, *bmp;
+#endif
    char LocName[DEMO_PATH_LENGTH], TString[DEMO_PATH_LENGTH];
 
    uszprintf(TString, sizeof(TString), "demo.dat#%s", name);
    get_executable_name(LocName, DEMO_PATH_LENGTH);
    replace_filename(LocName, LocName, TString, DEMO_PATH_LENGTH);
+#ifdef SKATER_USE_ALLEGRO_GL
+   bmp = load_bmp(LocName, NULL);
+   ret = create_video_bitmap(bmp->w, bmp->h);
+   blit(bmp, ret, 0, 0, 0, 0, bmp->w, bmp->h);
+   destroy_bitmap(bmp);
+   return ret;
+#else
    return load_bmp(LocName, NULL);
+#endif
 }
 
 SAMPLE *ObtainSample(const char *name)
Index: skater/src/game.c
===================================================================
--- skater/src/game.c	(revision 7749)
+++ skater/src/game.c	(working copy)
@@ -278,10 +278,8 @@
          c--;
       }
 
-      set_clip_rect(buffer, 0, 0, buffer->w, fixtoi(lowy));
-      clear_to_color(buffer, getpixel(cloud, 0, 0));
+      rectfill(buffer, 0, 0, buffer->w, fixtoi(lowy) + 1, getpixel(cloud, 0, 0));
       DrawClouds(buffer);
-      set_clip_rect(buffer, 0, 0, buffer->w, buffer->h);
    }
 
    /* draw interactable parts of level */
@@ -354,12 +352,12 @@
    DrawLevelForeground(buffer, Lvl);
 
    /* add status */
-   textprintf_ex(buffer, demo_font,
+   demo_textprintf(buffer, demo_font,
                  SCREEN_W - text_length(demo_font,
                                         "Items Required: 1000"), 8,
                  makecol(255, 255, 255), -1, "Items Required: %d",
                  RequiredObjectsLeft);
-   textprintf_ex(buffer, demo_font,
+   demo_textprintf(buffer, demo_font,
                  SCREEN_W - text_length(demo_font,
                                         "Items Remaining: 1000"),
                  8 + text_height(demo_font), makecol(255, 255, 255),
Index: skater/src/intro.c
===================================================================
--- skater/src/intro.c	(revision 7749)
+++ skater/src/intro.c	(working copy)
@@ -78,9 +78,9 @@
                   (1.0f - 2.0f * (progress - 0.5f)));
       }
 
-      textprintf_centre_ex(canvas, demo_font_logo, x + 6 - offx,
+      demo_textprintf_centre(canvas, demo_font_logo_m, x + 6 - offx,
                            y + 5, makecol(128, 128, 128), -1, logo_text1);
-      textprintf_centre_ex(canvas, demo_font_logo, x - offx, y, -1, -1,
+      demo_textprintf_centre(canvas, demo_font_logo, x - offx, y, -1, -1,
                            logo_text1);
 
       if (progress >= 1.5f) {
@@ -89,10 +89,11 @@
          if (progress < 2.0f) {
             offy = (int)((SCREEN_H - y) * (1.0f - 2.0f * (progress - 1.5f)));
          }
-         textprintf_centre_ex(canvas, demo_font_logo, x + 6,
+
+         demo_textprintf_centre(canvas, demo_font_logo_m, x + 6,
                               y + 5 + offy, makecol(128, 128, 128), -1,
                               logo_text2);
-         textprintf_centre_ex(canvas, demo_font_logo, x, y + offy, -1, -1,
+         demo_textprintf_centre(canvas, demo_font_logo, x, y + offy, -1, -1,
                               logo_text2);
       }
    }
Index: skater/src/framewk.c
===================================================================
--- skater/src/framewk.c	(revision 7749)
+++ skater/src/framewk.c	(working copy)
@@ -202,9 +202,8 @@
 
    /* Draw the current framerate if required. */
    if (display_framerate) {
-      textprintf_ex(update_driver.get_canvas(), font, 0, 0,
-                    makecol(255, 255, 255), makecol(0, 0, 0),
-                    "%d FPS", get_fps(fps));
+      draw_fps(fps, update_driver.get_canvas(), font, 0, 0,
+               makecol(255, 255, 255), "%d FPS");
    }
 
    /* Release the previously acquired canvas bitmap (backbuffer). */
Index: skater/src/oglflip.c
===================================================================
--- skater/src/oglflip.c	(revision 0)
+++ skater/src/oglflip.c	(revision 0)
@@ -0,0 +1,43 @@
+#ifdef SKATER_USE_ALLEGRO_GL
+
+#include <allegro.h>
+#include <alleggl.h>
+#include "defines.h"
+#include "oglflip.h"
+
+/*****************************************************************************
+ * OpenGL screen update module                                               *
+ *****************************************************************************/
+
+static void destroy(void)
+{
+}
+
+
+static int create(void)
+{
+   return DEMO_OK;
+}
+
+
+static void draw(void)
+{
+   allegro_gl_flip();
+}
+
+
+static BITMAP *get_canvas(void)
+{
+   return screen;
+}
+
+
+void select_ogl_flipping(DEMO_SCREEN_UPDATE_DRIVER * driver)
+{
+   driver->create = create;
+   driver->destroy = destroy;
+   driver->draw = draw;
+   driver->get_canvas = get_canvas;
+}
+
+#endif //SKATER_USE_ALLEGRO_GL
Index: skater/src/credits.c
===================================================================
--- skater/src/credits.c	(revision 7749)
+++ skater/src/credits.c	(working copy)
@@ -402,7 +402,7 @@
 
          if (cred->text) {
             credit_scroll =
-               text_length(font, cred->text) + SCREEN_W - credit_width;
+               text_length(plain_font, cred->text) + SCREEN_W - credit_width;
          } else {
             credit_scroll = 256;
          }
@@ -443,7 +443,7 @@
       c = text_length(demo_font, buf);
 
       if (text_pix + c > 0) {
-         textout_ex(canvas, demo_font, buf, text_pix, y2, col_font, -1);
+         demo_textout(canvas, demo_font, buf, text_pix, y2, col_font, -1);
       }
 
       text_pix += c;
@@ -487,7 +487,7 @@
             if ((c2 > 128) && (c2 <= 255)) {
                c2 = 255 - c2 + 64;
                cbuf[0] = *p;
-               textout_ex(canvas, font, cbuf, c, y2, makecol(c2, c2, c2), -1);
+               demo_textout(canvas, plain_font, cbuf, c, y2, makecol(c2, c2, c2), -1);
             }
 
             p++;
@@ -507,9 +507,9 @@
    }
 
    if (cred)
-      textprintf_ex(canvas, demo_font, c, 0, col_font, -1, "%s:", cred->name);
+      demo_textprintf(canvas, demo_font, c, 0, col_font, -1, "%s:", cred->name);
    else
-      textprintf_ex(canvas, demo_font, 0, 0, col_font, -1,
+      demo_textprintf(canvas, demo_font, 0, 0, col_font, -1,
                     "thanks._tx not found!");
 }
 
Index: skater/SConstruct
===================================================================
--- skater/SConstruct	(revision 7749)
+++ skater/SConstruct	(working copy)
@@ -2,6 +2,7 @@
 
 env = Environment(ENV = os.environ)
 
+env.Append(LIBS = ["agld", "GL", "GLU"])
 if sys.platform == "linux2":
     env.ParseConfig("allegro-config --libs")
 elif sys.platform == "windows":
@@ -11,7 +12,7 @@
 
 env.Append(CPPPATH = ["include"])
 
-env.Append(CCFLAGS = ["-W", "-Wall", "-Wno-unused-parameter"])
+env.Append(CCFLAGS = ["-DSKATER_USE_ALLEGRO_GL", "-DSKATER_USE_ALLEGRO_GL_FONT", "-O2", "-g0", "-W", "-Wall", "-Wno-unused-parameter"])
 
 files = glob.glob("src/*.c")
 files = [os.path.join("build", x[4:]) for x in files]
Index: skater/makefile.lst
===================================================================
--- skater/makefile.lst	(revision 7749)
+++ skater/makefile.lst	(working copy)
@@ -32,4 +32,5 @@
 	token.c \
 	transitn.c \
 	tribuf.c \
-	virtctl.c
+	virtctl.c \
+	oglflip.c


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