[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnash-commit
Subject:    [Gnash-commit] gnash/backend gnash.cpp render_handler_ogl.cpp
From:       Rob Savoye <rob () welcomehome ! org>
Date:       2006-03-11 20:47:25
Message-ID: E1FIAzl-0002O8-2K () savannah ! gnu ! org
[Download RAW message or body]

CVSROOT:	/sources/gnash
Module name:	gnash
Branch: 	
Changes by:	Rob Savoye <rsavoye@savannah.gnu.org>	06/03/11 20:47:25

Modified files:
	backend        : gnash.cpp render_handler_ogl.cpp 

Log message:
	* backend/gnash.cpp: Use getopt for processing command line
	arguments. Add GNU standard options. Use new logging system,
	delete the old one.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/gnash.cpp.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
 http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/render_handler_ogl.cpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text


Patches:
Index: gnash/backend/gnash.cpp
diff -u gnash/backend/gnash.cpp:1.15 gnash/backend/gnash.cpp:1.16
--- gnash/backend/gnash.cpp:1.15	Thu Mar  9 19:29:05 2006
+++ gnash/backend/gnash.cpp	Sat Mar 11 20:47:24 2006
@@ -1,19 +1,39 @@
 // 
 //   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
-//
+// 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 // the Free Software Foundation; either version 2 of the License, or
 // (at your option) any later version.
-
+// 
 // This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
-
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+// Linking Gnash statically or dynamically with other modules is making
+// a combined work based on Gnash. Thus, the terms and conditions of
+// the GNU General Public License cover the whole combination.
+// 
+// In addition, as a special exception, the copyright holders of Gnash give
+// you permission to combine Gnash with free software programs or
+// libraries that are released under the GNU LGPL and/or with Mozilla, 
+// so long as the linking with Mozilla, or any variant of Mozilla, is
+// through its standard plug-in interface. You may copy and distribute
+// such a system following the terms of the GNU GPL for Gnash and the
+// licenses of the other code concerned, provided that you include the
+// source code of that other code when and as the GNU GPL requires
+// distribution of source code. 
+// 
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is
+// their choice whether to do so.  The GNU General Public License gives
+// permission to release a modified version without this exception; this
+// exception also makes it possible to release a modified version which
+// carries forward this exception.
 //
 
 #ifdef HAVE_CONFIG_H
@@ -23,10 +43,13 @@
 #include "SDL.h"
 #include "SDL_thread.h"
 
-#include "gnash.h"
 #include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
+#include <cstdlib>
+#include <cstdio>
+#include <vector>
+
+#include "gnash.h"
+#include "log.h"
 #include "ogl.h"
 #include "utility.h"
 #include "container.h"
@@ -35,6 +58,12 @@
 #include "xmlsocket.h"
 #include "Movie.h"
 
+using namespace std;
+using namespace gnash;
+
+static void usage (const char *);
+static int runThread(void *nothing);
+
 bool gofast = false;		// FIXME: this flag gets set based on
 				// an XML message written using
 				// SendCommand(""). This way a movie
@@ -51,757 +80,641 @@
 				// the layers properly, but first I
 				// want to make sure it all works.
 
-void
-print_usage()
-{
-  printf(
-         "gnash -- a standalone Flash player.\n"
-         "\n"
-         "usage: gnash [options] movie_file.swf\n"
-         "\n"
-         "Plays a SWF (Shockwave Flash) movie using OpenGL"
-         "\n"
-         "options:\n"
-         "\n"
-         "  -h          Print this info.\n"
-         "  -s <factor> Scale the movie up/down by the specified factor\n"
-         "  -c          Produce a core file instead of letting SDL trap it\n"
-         "  -d num      Number of milli-seconds to delay in main loop\n"
-         "  -a          Turn antialiasing on/off.  (obsolete)\n"
-         "  -v          Be verbose; i.e. print log messages to stdout\n"
-         "  -va         Be verbose about movie Actions\n"
-         "  -vp         Be verbose about parsing the movie\n"
-         "  -ml <bias>  Specify the texture LOD bias (float, default is -1)\n"
-         "  -p          Run full speed (no sleep) and log frame rate\n"
-//         "  -e          Use SDL Event thread\n"
-         "  -x <ID>     X11 Window ID for display\n"
-         "  -1          Play once; exit when/if movie reaches the last frame\n"
-         "  -r <0|1|2>  0 disables renderering & sound (good for batch tests)\n"
-         "              1 enables rendering & sound (default setting)\n"
-         "              2 enables rendering & disables sound\n"
-         "  -t <sec>    Timeout and exit after the specified number of seconds\n"
-         "  -b <bits>   Bit depth of output window (16 or 32, default is 16)\n"
-         "\n"
-         "keys:\n"
-         "  CTRL-Q          Quit/Exit\n"
-         "  CTRL-W          Quit/Exit\n"
-         "  ESC             Quit/Exit\n"
-         "  CTRL-P          Toggle Pause\n"
-         "  CTRL-R          Restart the movie\n"
-         "  CTRL-[ or kp-   Step back one frame\n"
-         "  CTRL-] or kp+   Step forward one frame\n"
-         "  CTRL-A          Toggle antialiasing (doesn't work)\n"
-         "  CTRL-T          Debug.  Test the set_variable() function\n"
-         "  CTRL-G          Debug.  Test the get_variable() function\n"
-         "  CTRL-M          Debug.  Test the call_method() function\n"
-         "  CTRL-B          Toggle background color\n"
-         );
-}
-
-
 #define OVERSIZE	1.0f
 
-static int runThread(void *nothing);
 static int doneYet = 0;
 
 static float	s_scale = 1.0f;
 static bool	s_antialiased = false;
 static int	s_bit_depth = 16;
-static bool	s_verbose = false;
 static bool	s_background = true;
 static bool	s_measure_performance = false;
 static bool	s_event_thread = false;
 static bool	s_start_waiting = false;
 
-static void
-message_log(const char* message)
-// Process a log message.
-{
-  if (s_verbose) {
-    fputs(message, stdout);
-    fflush(stdout); // needed on osx for some reason
-  }
-}
-
-static void
-log_callback(bool error, const char* message)
-// Error callback for handling messages.
-{
-  if (error) {
-    // Log, and also print to stderr.
-    message_log(message);
-    fputs(message, stderr);
-  } else {
-    message_log(message);
-  }
-}
-
-
 static tu_file*
 file_opener(const char* url)
 // Callback function.  This opens files for the library.
 {
-  return new tu_file(url, "rb");
-}
+    GNASH_REPORT_FUNCTION;
 
+    if (strcmp(url, "-") == 0) {
+        FILE *newin = fdopen(dup(0),"rb");
+        return new tu_file(newin, false);
+    } else {
+        return new tu_file(url, "rb");
+    }
+}
 
 static void
 fs_callback(gnash::movie_interface* movie, const char* command, const char* args)
 // For handling notification callbacks from ActionScript.
 {
-  message_log("fs_callback: '");
-  message_log(command);
-  message_log("' '");
-  message_log(args);
-  message_log("'\n");
+    log_msg("fs_callback: '");
+    log_msg(command);
+    log_msg("' '");
+    log_msg(args);
+    log_msg("'\n");
 }
 
-
 static void
 key_event(SDLKey key, bool down)
 // For forwarding SDL key events.
 {
-  gnash::key::code	c(gnash::key::INVALID);
-  
-  if (key >= SDLK_a && key <= SDLK_z) {
-    c = (gnash::key::code) ((key - SDLK_a) + gnash::key::A);
-  } else if (key >= SDLK_F1 && key <= SDLK_F15)	{
-    c = (gnash::key::code) ((key - SDLK_F1) + gnash::key::F1);
-  } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
-    c = (gnash::key::code) ((key - SDLK_KP0) + gnash::key::KP_0);
-  } else {
-    // many keys don't correlate, so just use a look-up table.
-    struct {
-      SDLKey	sdlk;
-      gnash::key::code	gs;
-    } table[] = {
-      { SDLK_RETURN, gnash::key::ENTER },
-      { SDLK_ESCAPE, gnash::key::ESCAPE },
-      { SDLK_LEFT, gnash::key::LEFT },
-      { SDLK_UP, gnash::key::UP },
-      { SDLK_RIGHT, gnash::key::RIGHT },
-      { SDLK_DOWN, gnash::key::DOWN },
-      // @@ TODO fill this out some more
-      { SDLK_UNKNOWN, gnash::key::INVALID }
-    };
-    
-    for (int i = 0; table[i].sdlk != SDLK_UNKNOWN; i++) {
-      if (key == table[i].sdlk) {
-        c = table[i].gs;
-        break;
-      }
+    gnash::key::code	c(gnash::key::INVALID);
+    
+    if (key >= SDLK_a && key <= SDLK_z) {
+        c = (gnash::key::code) ((key - SDLK_a) + gnash::key::A);
+    } else if (key >= SDLK_F1 && key <= SDLK_F15)	{
+        c = (gnash::key::code) ((key - SDLK_F1) + gnash::key::F1);
+    } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
+        c = (gnash::key::code) ((key - SDLK_KP0) + gnash::key::KP_0);
+    } else {
+        // many keys don't correlate, so just use a look-up table.
+        struct {
+            SDLKey	sdlk;
+            gnash::key::code	gs;
+        } table[] = {
+            { SDLK_RETURN, gnash::key::ENTER },
+            { SDLK_ESCAPE, gnash::key::ESCAPE },
+            { SDLK_LEFT, gnash::key::LEFT },
+            { SDLK_UP, gnash::key::UP },
+            { SDLK_RIGHT, gnash::key::RIGHT },
+            { SDLK_DOWN, gnash::key::DOWN },
+            // @@ TODO fill this out some more
+            { SDLK_UNKNOWN, gnash::key::INVALID }
+        };
+        
+        for (int i = 0; table[i].sdlk != SDLK_UNKNOWN; i++) {
+            if (key == table[i].sdlk) {
+                c = table[i].gs;
+                break;
+            }
+        }
+    }
+    
+    if (c != gnash::key::INVALID) {
+        gnash::notify_key_event(c, down);
     }
-  }
-  
-  if (c != gnash::key::INVALID) {
-    gnash::notify_key_event(c, down);
-  }
 }
 
 int
 main(int argc, char *argv[])
 {
-  assert(tu_types_validate());
-  
-  const char* infile = NULL;
-  
-  float	exit_timeout = 0;
-  bool do_render = true;
-  bool do_sound = true;
-  bool do_loop = true;
-  bool sdl_abort = true;
-  int  delay = 31;
-  float	tex_lod_bias;
-  int windowid = 0;
-  
-  // -1.0 tends to look good.
-  tex_lod_bias = -1.2f;
-  
-  for (int arg = 1; arg < argc; arg++) {
-    if (argv[arg][0] == '-') {
-      // Looks like an option.
-      
-      if (argv[arg][1] == 'h') {
-        // Help.
-        print_usage();
-        exit(1);
-      }
-      if (argv[arg][1] == 'c') {
-        sdl_abort = false;
-      } else if (argv[arg][1] == 's') {
-        // Scale.
-        arg++;
-        if (arg < argc)	{
-          s_scale = fclamp((float) atof(argv[arg]), 0.01f, 100.f);
-        } else {
-          fprintf(stderr, "-s arg must be followed by a scale value\n");
-          print_usage();
-          exit(1);
-        }
-      } else if (argv[arg][1] == 'a') {
-        // Set antialiasing on or off.
-        arg++;
-        if (arg < argc)	{
-          s_antialiased = atoi(argv[arg]) ? true : false;
-        } else {
-          fprintf(stderr, "-a arg must be followed by 0 or 1 to disable/enable \
                antialiasing\n");
-          print_usage();
-          exit(1);
-        }
-      } else if (argv[arg][1] == 'b') {
-        // Set default bit depth.
-        arg++;
-        if (arg < argc) {
-          s_bit_depth = atoi(argv[arg]);
-          if (s_bit_depth != 16 && s_bit_depth != 32) {
-            fprintf(stderr, "Command-line supplied bit depth %d, but it must be 16 \
                or 32", s_bit_depth);
-            print_usage();
-            exit(1);
-          }
-        } else {
-          fprintf(stderr, "-b arg must be followed by 16 or 32 to set bit depth\n");
-          print_usage();
-          exit(1);
-        }
-      } else if (argv[arg][1] == 'd') {
-        // Set a delay
-        arg++;
-        if (arg < argc) {
-          delay = atoi(argv[arg]);
-        } else {
-          fprintf(stderr, "-d arg must be followed by number of milli-seconds to del \
                in the main loop\n");
-          print_usage();
-          exit(1);
-        }
-      } else if (argv[arg][1] == 'p') {
-        // Enable frame-rate/performance logging.
-        s_measure_performance = true;
-      } else if (argv[arg][1] == 'e') {
-        // Use an SDL thread to handle events
-        s_event_thread = true;
-      } else if (argv[arg][1] == '1') {
-        // Play once; don't loop.
-        do_loop = false;
-      } else if (argv[arg][1] == 'r') {
-        // Set rendering on/off.
-        arg++;
-        if (arg < argc) {
-          const int render_arg = atoi(argv[arg]);
-          switch (render_arg) {
-          case 0:
-            // Disable both
-            do_render = false;
-            do_sound = false;
-            break;
-          case 1:
-            // Enable both
-            do_render = true;
-            do_sound = true;
-            break;
-          case 2:
-            // Disable just sound
-            do_render = true;
-            do_sound = false;
-            break;
-          default:
-            fprintf(stderr, "-r must be followed by 0, 1 or 2 (%d is invalid)\n",
-                    render_arg);
-            print_usage();
-            exit(1);
-            break;
-          }
-        } else {
-          fprintf(stderr, "-r must be followed by 0 an argument to disable/enable \
                rendering\n");
-          print_usage();
-          exit(1);
-        }
-      } else if (argv[arg][1] == 't') {
-        // Set timeout.
-        arg++;
-        if (arg < argc) {
-          exit_timeout = (float) atof(argv[arg]);
-        } else {//     char SDL_windowhack[32];
-//     sprintf (SDL_windowhack,"SDL_WINDOWID=%d", aWindow->window);
-//     putenv (SDL_windowhack);
-
-          fprintf(stderr, "-t must be followed by an exit timeout, in seconds\n");
-          print_usage();
-          exit(1);
-        }
-      } else if (argv[arg][1] == 'x') {
-        // Set display window
-        arg++;
-        if (arg < argc) {
-          windowid = strtol(argv[arg], NULL, 0);
-        } else {
-          fprintf(stderr, "-x must be followed by the window ID\n");
-          print_usage();
-          exit(1);
-        }
-      } else if (argv[arg][1] == 'v') {
-        // Be verbose; i.e. print log messages to stdout.
-        s_verbose = true;
-        
-        if (argv[arg][2] == 'a') {
-          // Enable spew re: action.
-          gnash::set_verbose_action(true);
-        } else if (argv[arg][2] == 'p') {
-          // Enable parse spew.
-          gnash::set_verbose_parse(true);
-        }
-        // ...
-      } else if (argv[arg][1] == 'm') {
-        if (argv[arg][2] == 'l') {
-          arg++;
-          tex_lod_bias = (float) atof(argv[arg]);
-          //printf("Texture LOD Bais is no %f\n", tex_lod_bias);
-        } else {
-          fprintf(stderr, "unknown variant of -m arg\n");
-          print_usage();
-          exit(1);
+    int c;
+    int verbosity = 0;
+    int render_arg;
+    std::vector<const char*> infiles;
+
+    assert(tu_types_validate());
+    
+    float	exit_timeout = 0;
+    bool do_render = true;
+    bool do_sound = true;
+    bool do_loop = true;
+    bool sdl_abort = true;
+    int  delay = 31;
+    float	tex_lod_bias;
+    int windowid = 0;
+    
+    // -1.0 tends to look good.
+    tex_lod_bias = -1.2f;
+    
+    // scan for the two main standard GNU options
+    for (c=0; c<argc; c++) {
+        if (strcmp("--help", argv[c]) == 0) {
+            usage(argv[0]);
+            exit(0);
+        }
+        if (strcmp("--version", argv[c]) == 0) {
+            cerr << "Gnash version: " << VERSION << endl;
+            exit(0);
         }
-      }
-    } else {
-      infile = argv[arg];
     }
-  }
-  
-  if (infile == NULL) {
-    printf("no input file\n");
-    print_usage();
-    exit(1);
-  }
-  
-  gnash::register_file_opener_callback(file_opener);
-  gnash::register_fscommand_callback(fs_callback);
-  if (s_verbose == true) {
-    gnash::register_log_callback(log_callback);
-  }
-  //gnash::set_antialiased(s_antialiased);
-  
-  gnash::sound_handler  *sound = NULL;
-  gnash::render_handler *render = NULL;
-  if (do_render) {
-    if (do_sound) {
+    
+    while ((c = getopt (argc, argv, "hvaps:cfd:m:x:r:t:b:1e")) != -1) {
+	switch (c) {
+	  case 'h':
+	      usage (argv[0]);
+	      break;
+	  case 'v':
+	      verbosity++;
+	      dbglogfile.setVerbosity(verbosity);
+	      dbglogfile << "Verbose output turned on" << endl;
+	      break;
+	  case 'a':
+	      gnash::set_verbose_action(true);
+	      break;
+	  case 'p':
+	      gnash::set_verbose_parse(true);
+	      break;
+          case 'f':
+              s_measure_performance = true;
+              break;
+          case 's':
+              s_scale = fclamp((float) atof(optarg), 0.01f, 100.f);
+              break;
+          case 'c':
+              sdl_abort = false;
+              break;
+          case 'd':
+              delay = atoi(optarg);
+              break;
+          case 'e':
+              s_event_thread = true;
+              break;
+          case 'x':
+              windowid = strtol(optarg, NULL, 0);
+              break;
+          case 'm':
+              tex_lod_bias = (float) atof(optarg);
+              break;
+          case '1':
+              do_loop = false;
+              break;
+          case 'r':
+              render_arg = atoi(optarg);
+              switch (render_arg) {
+                case 0:
+                    // Disable both
+                    do_render = false;
+                    do_sound = false;
+                    break;
+                case 1:
+                    // Enable both
+                    do_render = true;
+                    do_sound = true;
+                    break;
+                case 2:
+                    // Disable just sound
+                    do_render = true;
+                    do_sound = false;
+                    break;
+                default:
+                    cerr << "-r must be followed by 0, 1 or 2 (" << 
+                        render_arg << " is invalid" << endl;
+                    
+                    break;
+              };
+              break;
+          case 't':
+              exit_timeout = (float) atof(optarg);
+              break;
+          case 'b':
+              s_bit_depth = atoi(optarg);
+              break;
+	}
+    }
+    
+    // get the file name from the command line
+    while (optind < argc) {
+        infiles.push_back(argv[optind]);
+	optind++;
+    }
+
+    // No file names were supplied
+    if (infiles.size() == 0) {
+	printf("no input files\n");
+	usage(argv[0]);
+	exit(1);
+    }
+
+    gnash::register_file_opener_callback(file_opener);
+    
+    gnash::register_fscommand_callback(fs_callback);
+//   if (s_verbose == true) {
+//       gnash::register_log_callback(log_callback);
+//   }
+    //gnash::set_antialiased(s_antialiased);
+    
+    gnash::sound_handler  *sound = NULL;
+    gnash::render_handler *render = NULL;
+    if (do_render) {
+        if (do_sound) {
 #ifdef HAVE_SDL_MIXER_H
-      sound = gnash::create_sound_handler_sdl();
-      gnash::set_sound_handler(sound);
+            sound = gnash::create_sound_handler_sdl();
+            gnash::set_sound_handler(sound);
 #endif
+        }
+        render = gnash::create_render_handler_ogl();
+        gnash::set_render_handler(render);
     }
-    render = gnash::create_render_handler_ogl();
-    gnash::set_render_handler(render);
-  }
-  
-  // Get info about the width & height of the movie.
-  int	movie_version = 0;
-  int	movie_width = 0;
-  int	movie_height = 0;
-  float	movie_fps = 30.0f;
-  gnash::get_movie_info(infile, &movie_version, &movie_width, &movie_height, \
                &movie_fps, NULL, NULL);
-  if (movie_version == 0) {
-    fprintf(stderr, "error: can't get info about %s\n", infile);
-    exit(1);
-  }
-  
-  int	width = int(movie_width * s_scale);
-  int	height = int(movie_height * s_scale);
-  
-  if (do_render) {
-      if (windowid) {
-          char SDL_windowhack[32];
-          sprintf (SDL_windowhack,"SDL_WINDOWID=%d", windowid);
-          putenv (SDL_windowhack);
-      }
-
-    // Initialize the SDL subsystems we're using. Linux
-    // and Darwin use Pthreads for SDL threads, Win32
-    // doesn't. Otherwise the SDL event loop just polls.
-    if (sdl_abort) {
-      //  Other flags are SDL_INIT_JOYSTICK | SDL_INIT_CDROM
+    
+    // Get info about the width & height of the movie.
+    int	movie_version = 0;
+    int	movie_width = 0;
+    int	movie_height = 0;
+    float	movie_fps = 30.0f;
+    gnash::get_movie_info(infiles[0], &movie_version, &movie_width, &movie_height, \
&movie_fps, NULL, NULL); +    if (movie_version == 0) {
+        fprintf(stderr, "error: can't get info about %s\n", infiles[0]);
+        exit(1);
+    }
+    
+    int	width = int(movie_width * s_scale);
+    int	height = int(movie_height * s_scale);
+    
+    if (do_render) {
+        if (windowid) {
+            char SDL_windowhack[32];
+            sprintf (SDL_windowhack,"SDL_WINDOWID=%d", windowid);
+            putenv (SDL_windowhack);
+        }
+        
+        // Initialize the SDL subsystems we're using. Linux
+        // and Darwin use Pthreads for SDL threads, Win32
+        // doesn't. Otherwise the SDL event loop just polls.
+        if (sdl_abort) {
+            //  Other flags are SDL_INIT_JOYSTICK | SDL_INIT_CDROM
 #ifdef _WIN32
-      if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO))
+            if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO))
 #else
-     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTTHREAD ))
+                if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTTHREAD \
))  #endif
-       {
-         fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
-         exit(1);
-       }
-    } else {
-      fprintf(stderr, "warning: SDL won't trap core dumps \n");
+                    {
+                        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
+                        exit(1);
+                    }
+        } else {
+            fprintf(stderr, "warning: SDL won't trap core dumps \n");
 #ifdef _WIN32
-      if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE  | \
SDL_INIT_EVENTTHREAD)) +            if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | \
SDL_INIT_NOPARACHUTE  | SDL_INIT_EVENTTHREAD))  #else
-        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE))
+                if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | \
SDL_INIT_NOPARACHUTE))  #endif
-          {
-            fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
+                    {
+                        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
+                        exit(1);
+                    }
+        }
+        
+        atexit(SDL_Quit);
+        
+        SDL_EnableKeyRepeat(250, 33);
+        
+        
+        if (s_bit_depth == 16) {
+            // 16-bit color, surface creation is likely to succeed.
+            SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
+            SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
+            SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
+            SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 15);
+            SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+            SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
+        } else {
+            assert(s_bit_depth == 32);
+            
+            // 32-bit color etc, for getting dest alpha,
+            // for MULTIPASS_ANTIALIASING (see
+            // render_handler_ogl.cpp).
+            SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
+            SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
+            SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
+            SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
+            SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
+            SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+            SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
+        }
+        
+        // Change the LOD BIAS values to tweak blurriness.
+        if (tex_lod_bias != 0.0f) {
+#ifdef FIX_I810_LOD_BIAS	
+            // If 2D textures weren't previously enabled, enable
+            // them now and force the driver to notice the update,
+            // then disable them again.
+            if (!glIsEnabled(GL_TEXTURE_2D)) {
+                // Clearing a mask of zero *should* have no
+                // side effects, but coupled with enbling
+                // GL_TEXTURE_2D it works around a segmentation
+                // fault in the driver for the Intel 810 chip.
+                glEnable(GL_TEXTURE_2D);
+                glClear(0);
+                glDisable(GL_TEXTURE_2D);
+            }
+#endif // FIX_I810_LOD_BIAS
+            glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, \
tex_lod_bias); +        }
+        
+        // Set the video mode.
+        if (SDL_SetVideoMode(width, height, s_bit_depth, SDL_OPENGL) == 0) {
+            fprintf(stderr, "SDL_SetVideoMode() failed.\n");
             exit(1);
-          }
+        }
+        
+        // Set the window title
+        char *window_title = new char[1+strlen("gnash: ")+strlen(infiles[0])];
+        strcpy(window_title, "gnash: ");
+        strcat(window_title, infiles[0]);
+        SDL_WM_SetCaption(window_title, window_title);
+        
+        //
+        ogl::open();
+        
+        // Turn on alpha blending.
+        glEnable(GL_BLEND);
+        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+        
+        // Turn on line smoothing.  Antialiased lines can be used to
+        // smooth the outsides of shapes.
+        glEnable(GL_LINE_SMOOTH);
+        glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);	// GL_NICEST, GL_FASTEST, \
GL_DONT_CARE +        
+        glMatrixMode(GL_PROJECTION);
+        glOrtho(-OVERSIZE, OVERSIZE, OVERSIZE, -OVERSIZE, -1, 1);
+        glMatrixMode(GL_MODELVIEW);
+        glLoadIdentity();
+        
+        // We don't need lighting effects
+        glDisable(GL_LIGHTING);
+        // glColorPointer(4, GL_UNSIGNED_BYTE, 0, *);
+        // glInterleavedArrays(GL_T2F_N3F_V3F, 0, *)
+        glPushAttrib (GL_ALL_ATTRIB_BITS);		
     }
     
-    atexit(SDL_Quit);
-    
-    SDL_EnableKeyRepeat(250, 33);
-    
-    
-    if (s_bit_depth == 16) {
-      // 16-bit color, surface creation is likely to succeed.
-      SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
-      SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
-      SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
-      SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 15);
-      SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-      SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
-    } else {
-      assert(s_bit_depth == 32);
-      
-      // 32-bit color etc, for getting dest alpha,
-      // for MULTIPASS_ANTIALIASING (see
-      // render_handler_ogl.cpp).
-      SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
-      SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
-      SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
-      SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
-      SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
-      SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-      SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
+    // Load the actual movie.
+    gnash::movie_definition*	md = gnash::create_library_movie(infiles[0]);
+    if (md == NULL) {
+        fprintf(stderr, "error: can't create a movie from '%s'\n", infiles[0]);
+        exit(1);
     }
-    
-    // Change the LOD BIAS values to tweak blurriness.
-    if (tex_lod_bias != 0.0f) {
-#ifdef FIX_I810_LOD_BIAS	
-      // If 2D textures weren't previously enabled, enable
-      // them now and force the driver to notice the update,
-      // then disable them again.
-      if (!glIsEnabled(GL_TEXTURE_2D)) {
-        // Clearing a mask of zero *should* have no
-        // side effects, but coupled with enbling
-        // GL_TEXTURE_2D it works around a segmentation
-        // fault in the driver for the Intel 810 chip.
-        glEnable(GL_TEXTURE_2D);
-        glClear(0);
-        glDisable(GL_TEXTURE_2D);
-      }
-#endif // FIX_I810_LOD_BIAS
-      glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, \
tex_lod_bias); +    gnash::movie_interface*	m = create_library_movie_inst(md);
+    if (m == NULL) {
+        fprintf(stderr, "error: can't create movie instance\n");
+        exit(1);
     }
+    gnash::set_current_root(m);
     
-    // Set the video mode.
-    if (SDL_SetVideoMode(width, height, s_bit_depth, SDL_OPENGL) == 0) {
-      fprintf(stderr, "SDL_SetVideoMode() failed.\n");
-      exit(1);
-    }
-    
-    // Set the window title
-    char *window_title = new char[1+strlen("gnash: ")+strlen(infile)];
-    strcpy(window_title, "gnash: ");
-    strcat(window_title, infile);
-    SDL_WM_SetCaption(window_title, window_title);
-
-    //
-    ogl::open();
-    
-    // Turn on alpha blending.
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    
-    // Turn on line smoothing.  Antialiased lines can be used to
-    // smooth the outsides of shapes.
-    glEnable(GL_LINE_SMOOTH);
-    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);	// GL_NICEST, GL_FASTEST, GL_DONT_CARE
-    
-    glMatrixMode(GL_PROJECTION);
-    glOrtho(-OVERSIZE, OVERSIZE, OVERSIZE, -OVERSIZE, -1, 1);
-    glMatrixMode(GL_MODELVIEW);
-    glLoadIdentity();
-    
-    // We don't need lighting effects
-    glDisable(GL_LIGHTING);
-    // glColorPointer(4, GL_UNSIGNED_BYTE, 0, *);
-    // glInterleavedArrays(GL_T2F_N3F_V3F, 0, *)
-    glPushAttrib (GL_ALL_ATTRIB_BITS);		
-  }
-  
-  // Load the actual movie.
-  gnash::movie_definition*	md = gnash::create_library_movie(infile);
-  if (md == NULL) {
-    fprintf(stderr, "error: can't create a movie from '%s'\n", infile);
-    exit(1);
-  }
-  gnash::movie_interface*	m = create_library_movie_inst(md);
-  if (m == NULL) {
-    fprintf(stderr, "error: can't create movie instance\n");
-    exit(1);
-  }
-  gnash::set_current_root(m);
-  
-  // Mouse state.
-  int	mouse_x = 0;
-  int	mouse_y = 0;
-  int	mouse_buttons = 0;
-  
-  float	speed_scale = 1.0f;
-  Uint32	start_ticks = 0;
-  if (do_render) {
-    start_ticks = SDL_GetTicks();
-    
-  }
-  Uint32	last_ticks = start_ticks;
-  int	frame_counter = 0;
-  int	last_logged_fps = last_ticks;
-  
-  
-  SDL_Thread *thread = NULL;
-  if (s_event_thread) {
-    thread = SDL_CreateThread(runThread, NULL);
-    if ( thread == NULL) {
-      fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
-    }
-  }
-  
-  
-  for (;;) {
-    Uint32	ticks;
+    // Mouse state.
+    int	mouse_x = 0;
+    int	mouse_y = 0;
+    int	mouse_buttons = 0;
+    
+    float	speed_scale = 1.0f;
+    Uint32	start_ticks = 0;
     if (do_render) {
-      ticks = SDL_GetTicks();
-    } else {
-      // Simulate time.
-      ticks = last_ticks + (Uint32) (1000.0f / movie_fps);
+        start_ticks = SDL_GetTicks();
+        
     }
-    int	delta_ticks = ticks - last_ticks;
-    float	delta_t = delta_ticks / 1000.f;
-    last_ticks = ticks;
-    
-    // Check auto timeout counter.
-    if (exit_timeout > 0
-        && ticks - start_ticks > (Uint32) (exit_timeout * 1000)) {
-      // Auto exit now.
-      break;
+    Uint32	last_ticks = start_ticks;
+    int	frame_counter = 0;
+    int	last_logged_fps = last_ticks;
+    
+    
+    SDL_Thread *thread = NULL;
+    if (s_event_thread) {
+        thread = SDL_CreateThread(runThread, NULL);
+        if ( thread == NULL) {
+            fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
+        }
     }
     
-    if (do_render) {
-      SDL_Event	event;
-      // Handle input.
-      bool ret = true;
-      while (ret) {
+    
+    for (;;) {
+        Uint32	ticks;
+        if (do_render) {
+            ticks = SDL_GetTicks();
+        } else {
+            // Simulate time.
+            ticks = last_ticks + (Uint32) (1000.0f / movie_fps);
+        }
+        int	delta_ticks = ticks - last_ticks;
+        float	delta_t = delta_ticks / 1000.f;
+        last_ticks = ticks;
+        
+        // Check auto timeout counter.
+        if (exit_timeout > 0
+            && ticks - start_ticks > (Uint32) (exit_timeout * 1000)) {
+            // Auto exit now.
+            break;
+        }
+        
+        if (do_render) {
+            SDL_Event	event;
+            // Handle input.
+            bool ret = true;
+            while (ret) {
 //           printf("xml_fd is %d, gofast is %d, s_start_waiting is %d, \
s_event_thread is %d\n",  //                  xml_fd, gofast, s_start_waiting, \
s_event_thread);  #ifdef HAVE_LIBXML
-        if (s_event_thread && s_start_waiting && (xml_fd > 0) && !gofast) {
-            // 				if (s_event_thread && (xml_fd > 0)) {
+                if (s_event_thread && s_start_waiting && (xml_fd > 0) && !gofast) {
+                    // 				if (s_event_thread && (xml_fd > 0)) {
 //            printf("SDL_WaitEvent!\n");
-          ret = SDL_WaitEvent(&event);
-        } else {
+                    ret = SDL_WaitEvent(&event);
+                } else {
 //          if (gofast) {
 //               printf("SDL_PollEvent GOFAST!\n");
 //           } else {
 //               printf("SDL_PollEvent!\n");
 //           }
-          ret = SDL_PollEvent(&event) ? true : false;
-        }
+                    ret = SDL_PollEvent(&event) ? true : false;
+                }
 #else
-        // If we have no libxml, obey what the gofast variable is set to
-        if (gofast)
-            ret = SDL_PollEvent(&event) ? true : false;
-        else
-            ret = SDL_WaitEvent(&event);
+                // If we have no libxml, obey what the gofast variable is set to
+                if (gofast)
+                    ret = SDL_PollEvent(&event) ? true : false;
+                else
+                    ret = SDL_WaitEvent(&event);
 #endif
-        
+                
 //        printf("EVENT Type is %d\n", event.type);
-        switch (event.type) {
-          case SDL_NOEVENT:
-              ret = false;
-              break;
-          case SDL_USEREVENT:
+                switch (event.type) {
+                  case SDL_NOEVENT:
+                      ret = false;
+                      break;
+                  case SDL_USEREVENT:
 //              printf("SDL_USER_EVENT at %s, code %d%d\n", __FUNCTION__, __LINE__, \
                event.user.code);
-            ret = false;
-            break;
-        case SDL_KEYDOWN:
-          {
-            SDLKey	key = event.key.keysym.sym;
-            bool	ctrl = (event.key.keysym.mod & KMOD_CTRL) != 0;
-            
-            if (key == SDLK_ESCAPE
-                || (ctrl && key == SDLK_q)
-                || (ctrl && key == SDLK_w)) {
-              goto done;
-            } else if (ctrl && key == SDLK_p) {
-              // Toggle paused state.
-              if (m->get_play_state() == gnash::movie_interface::STOP) {
-                m->set_play_state(gnash::movie_interface::PLAY);
-              } else {
-                m->set_play_state(gnash::movie_interface::STOP);
-              }
-            } else if (ctrl && key == SDLK_r) {
-              // Restart the movie.
-              m->restart();
-            } else if (ctrl && (key == SDLK_LEFTBRACKET || key == SDLK_KP_MINUS)) {
-              m->goto_frame(m->get_current_frame()-1);
-            } else if (ctrl && (key == SDLK_RIGHTBRACKET || key == SDLK_KP_PLUS)) {
-              m->goto_frame(m->get_current_frame()+1);
-            } else if (ctrl && key == SDLK_a) {
-              // Toggle antialiasing.
-              s_antialiased = !s_antialiased;
-              //gnash::set_antialiased(s_antialiased);
-            } else if (ctrl && key == SDLK_t) {
-              // test text replacement / variable setting:
-              m->set_variable("test.text", "set_edit_text was here...\nanother line \
                of text for you to see in the text box\nSome UTF-8: ñö £Ã§ °Ã„ÀÔ \
                ¿");
-            } else if (ctrl && key == SDLK_g) {
-              // test get_variable.
-              message_log("testing get_variable: '");
-              message_log(m->get_variable("test.text"));
-              message_log("'\n");
-            } else if (ctrl && key == SDLK_m) {
-              // Test call_method.
-              const char* result = m->call_method(
-                                                  "test_call",
-                                                  "%d, %f, %s, %ls",
-                                                  200,
-                                                  1.0f,
-                                                  "Test string",
-                                                  L"Test long string");
-              
-              if (result) {
-                message_log("call_method: result = ");
-                message_log(result);
-                message_log("\n");
-              } else {
-                message_log("call_method: null result\n");
-              }
-            } else if (ctrl && key == SDLK_b) {
-              // toggle background color.
-              s_background = !s_background;
-            } else if (ctrl && key == SDLK_f) {
-              extern bool gnash_debug_show_paths;
-              gnash_debug_show_paths = !gnash_debug_show_paths;
-            } else if (ctrl && key == SDLK_EQUALS) {
-              float	f = gnash::get_curve_max_pixel_error();
-              f *= 1.1f;
-              gnash::set_curve_max_pixel_error(f);
-              printf("curve error tolerance = %f\n", f);
-            } else if (ctrl && key == SDLK_MINUS) {
-              float	f = gnash::get_curve_max_pixel_error();
-              f *= 0.9f;
-              gnash::set_curve_max_pixel_error(f);
-              printf("curve error tolerance = %f\n", f);
+                      ret = false;
+                      break;
+                  case SDL_KEYDOWN:
+                  {
+                      SDLKey	key = event.key.keysym.sym;
+                      bool	ctrl = (event.key.keysym.mod & KMOD_CTRL) != 0;
+                      
+                      if (key == SDLK_ESCAPE
+                          || (ctrl && key == SDLK_q)
+                          || (ctrl && key == SDLK_w)) {
+                          goto done;
+                      } else if (ctrl && key == SDLK_p) {
+                          // Toggle paused state.
+                          if (m->get_play_state() == gnash::movie_interface::STOP) {
+                              m->set_play_state(gnash::movie_interface::PLAY);
+                          } else {
+                              m->set_play_state(gnash::movie_interface::STOP);
+                          }
+                      } else if (ctrl && key == SDLK_r) {
+                          // Restart the movie.
+                          m->restart();
+                      } else if (ctrl && (key == SDLK_LEFTBRACKET || key == \
SDLK_KP_MINUS)) { +                          m->goto_frame(m->get_current_frame()-1);
+                      } else if (ctrl && (key == SDLK_RIGHTBRACKET || key == \
SDLK_KP_PLUS)) { +                          m->goto_frame(m->get_current_frame()+1);
+                      } else if (ctrl && key == SDLK_a) {
+                          // Toggle antialiasing.
+                          s_antialiased = !s_antialiased;
+                          //gnash::set_antialiased(s_antialiased);
+                      } else if (ctrl && key == SDLK_t) {
+                          // test text replacement / variable setting:
+                          m->set_variable("test.text", "set_edit_text was \
here...\nanother line of text for you to see in the text box\nSome UTF-8: ñö £Ã§ \
°Ã„ÀÔ ¿"); +                      } else if (ctrl && key == SDLK_g) {
+                          // test get_variable.
+                          log_msg("testing get_variable: '");
+                          log_msg(m->get_variable("test.text"));
+                          log_msg("'\n");
+                      } else if (ctrl && key == SDLK_m) {
+                          // Test call_method.
+                          const char* result = m->call_method(
+                              "test_call",
+                              "%d, %f, %s, %ls",
+                              200,
+                              1.0f,
+                              "Test string",
+                              L"Test long string");
+                          
+                          if (result) {
+                              log_msg("call_method: result = ");
+                              log_msg(result);
+                              log_msg("\n");
+                          } else {
+                              log_msg("call_method: null result\n");
+                          }
+                      } else if (ctrl && key == SDLK_b) {
+                          // toggle background color.
+                          s_background = !s_background;
+                      } else if (ctrl && key == SDLK_f) {
+                          extern bool gnash_debug_show_paths;
+                          gnash_debug_show_paths = !gnash_debug_show_paths;
+                      } else if (ctrl && key == SDLK_EQUALS) {
+                          float	f = gnash::get_curve_max_pixel_error();
+                          f *= 1.1f;
+                          gnash::set_curve_max_pixel_error(f);
+                          printf("curve error tolerance = %f\n", f);
+                      } else if (ctrl && key == SDLK_MINUS) {
+                          float	f = gnash::get_curve_max_pixel_error();
+                          f *= 0.9f;
+                          gnash::set_curve_max_pixel_error(f);
+                          printf("curve error tolerance = %f\n", f);
+                      }
+                      
+                      key_event(key, true);
+                      
+                      break;
+                  }
+                  
+                  case SDL_KEYUP:
+                  {
+                      SDLKey	key = event.key.keysym.sym;
+                      key_event(key, false);
+                      break;
+                  }
+                  
+                  case SDL_MOUSEMOTION:
+                      mouse_x = (int) (event.motion.x / s_scale);
+                      mouse_y = (int) (event.motion.y / s_scale);
+                      break;
+                      
+                  case SDL_MOUSEBUTTONDOWN:
+                  case SDL_MOUSEBUTTONUP:
+                  {
+                      int	mask = 1 << (event.button.button - 1);
+                      if (event.button.state == SDL_PRESSED) {
+                          mouse_buttons |= mask;
+                      } else {
+                          mouse_buttons &= ~mask;
+                      }
+                      break;
+                  }
+                  
+                  case SDL_QUIT:
+                      goto done;
+                      break;
+                      
+                  default:
+                      break;
+                }
             }
+        }
+        
+//    printf("%s(%d): Frame count is %d\n", __PRETTY_FUNCTION__, __LINE__,
+//           md->get_frame_count());
+        m = gnash::get_current_root();
+        gnash::delete_unused_root();
+        
+        m->set_display_viewport(0, 0, width, height);
+        m->set_background_alpha(s_background ? 1.0f : 0.05f);
+        
+        m->notify_mouse_state(mouse_x, mouse_y, mouse_buttons);
+        
+        m->advance(delta_t * speed_scale);
+        
+        if (do_render) {
+            glDisable(GL_DEPTH_TEST);	// Disable depth testing.
+            glDrawBuffer(GL_BACK);
+        }
+        m->display();
+        frame_counter++;
+        
+        if (do_render) {
+            SDL_GL_SwapBuffers();
+            //glPopAttrib ();
             
-            key_event(key, true);
-            
-            break;
-          }
-          
-        case SDL_KEYUP:
-          {
-            SDLKey	key = event.key.keysym.sym;
-            key_event(key, false);
-            break;
-          }
-          
-        case SDL_MOUSEMOTION:
-          mouse_x = (int) (event.motion.x / s_scale);
-          mouse_y = (int) (event.motion.y / s_scale);
-          break;
-          
-        case SDL_MOUSEBUTTONDOWN:
-        case SDL_MOUSEBUTTONUP:
-          {
-            int	mask = 1 << (event.button.button - 1);
-            if (event.button.state == SDL_PRESSED) {
-              mouse_buttons |= mask;
+            if (s_measure_performance == false) {
+                // Don't hog the CPU.
+                // 				if (!nodelay)
+                if (!gofast) {
+                    SDL_Delay(delay);
+                }
             } else {
-              mouse_buttons &= ~mask;
+                // Log the frame rate every second or so.
+                if (last_ticks - last_logged_fps > 1000) {
+                    float	delta = (last_ticks - last_logged_fps) / 1000.f;
+                    
+                    if (delta > 0) {
+                        printf("fps = %3.1f\n", frame_counter / delta);
+                    } else {
+                        printf("fps = *inf*\n");
+                    }
+                    
+                    last_logged_fps = last_ticks;
+                    frame_counter = 0;
+                }
             }
-            break;
-          }
-          
-        case SDL_QUIT:
-          goto done;
-          break;
-          
-        default:
-          break;
         }
-      }
+        
+        // See if we should exit.
+        if (do_loop == false
+            && m->get_current_frame() + 1 == md->get_frame_count())
+            {
+                // We're reached the end of the movie; exit.
+                break;
+            }
     }
-
-//    printf("%s(%d): Frame count is %d\n", __PRETTY_FUNCTION__, __LINE__,
-//           md->get_frame_count());
-    m = gnash::get_current_root();
-    gnash::delete_unused_root();
-    
-    m->set_display_viewport(0, 0, width, height);
-    m->set_background_alpha(s_background ? 1.0f : 0.05f);
     
-    m->notify_mouse_state(mouse_x, mouse_y, mouse_buttons);
+  done:
+    doneYet = 1;
+    SDL_KillThread(thread);	// kill the network read thread
+    //SDL_Quit();
     
-    m->advance(delta_t * speed_scale);
+    if (md) {
+        md->drop_ref();
+    }
     
-    if (do_render) {
-      glDisable(GL_DEPTH_TEST);	// Disable depth testing.
-      glDrawBuffer(GL_BACK);
+    if (m) {
+        m->drop_ref();
     }
-    m->display();
-    frame_counter++;
+    delete sound;
+    delete render;
     
-    if (do_render) {
-        SDL_GL_SwapBuffers();
-      //glPopAttrib ();
-      
-      if (s_measure_performance == false) {
-        // Don't hog the CPU.
-        // 				if (!nodelay)
-        if (!gofast) {
-          SDL_Delay(delay);
-        }
-      } else {
-        // Log the frame rate every second or so.
-        if (last_ticks - last_logged_fps > 1000) {
-          float	delta = (last_ticks - last_logged_fps) / 1000.f;
-          
-          if (delta > 0) {
-            printf("fps = %3.1f\n", frame_counter / delta);
-          } else {
-            printf("fps = *inf*\n");
-          }
-          
-          last_logged_fps = last_ticks;
-          frame_counter = 0;
-        }
-      }
-    }
-    
-    // See if we should exit.
-    if (do_loop == false
-        && m->get_current_frame() + 1 == md->get_frame_count())
-      {
-        // We're reached the end of the movie; exit.
-        break;
-      }
-  }
-  
- done:
-  doneYet = 1;
-  SDL_KillThread(thread);	// kill the network read thread
-  //SDL_Quit();
-  
-  if (md) md->drop_ref();
-  if (m) m->drop_ref();
-  delete sound;
-  delete render;
-  
-  // For testing purposes, throw some keypresses
-  // to make sure the key handler is properly using weak
-  // references to listeners.
-  gnash::notify_key_event(gnash::key::A, true);
-  gnash::notify_key_event(gnash::key::B, true);
-  gnash::notify_key_event(gnash::key::C, true);
-  
-  // Clean up as much as possible, so valgrind will help find actual leaks.
-  gnash::clear();
-  
-  return 0;
+    // For testing purposes, throw some keypresses
+    // to make sure the key handler is properly using weak
+    // references to listeners.
+    gnash::notify_key_event(gnash::key::A, true);
+    gnash::notify_key_event(gnash::key::B, true);
+    gnash::notify_key_event(gnash::key::C, true);
+    
+    // Clean up as much as possible, so valgrind will help find actual leaks.
+    gnash::clear();
+    
+    return 0;
 }
 
 static int
@@ -809,60 +722,107 @@
 {
 #ifdef HAVE_LIBXML
   
-  //int i = 123;
-  int val;
-  int count = 0;
-  SDL_Event *ptr;
+    //int i = 123;
+    int val;
+    int count = 0;
+    SDL_Event *ptr;
 #if 1
-  SDL_Event ev;
-  ev.type = SDL_USEREVENT;
-  ev.user.code  = 0;
-  ev.user.data1 = 0;
-  ev.user.data2 = 0;
-  ptr = &ev;
+    SDL_Event ev;
+    ev.type = SDL_USEREVENT;
+    ev.user.code  = 0;
+    ev.user.data1 = 0;
+    ev.user.data2 = 0;
+    ptr = &ev;
 #else
-  ptr = (SDL_Event *)ev_ptr;
-  ptr->type = SDL_USEREVENT;
-  ptr->user.code  = 0;
-  ptr->user.data1 = 0;
-  ptr->user.data2 = 0;
+    ptr = (SDL_Event *)ev_ptr;
+    ptr->type = SDL_USEREVENT;
+    ptr->user.code  = 0;
+    ptr->user.data1 = 0;
+    ptr->user.data2 = 0;
 #endif
-  
-  printf("Initializing event thread...\n");
-  
-  while (gnash::check_sockets(xml_fd) == -1) {
-    sleep(10); // Delay to give the socket time to
-    // connect.
-    continue;
-  }
-  
-  // give everything a chance to initialize.
-  // since all the frames need to be set up,
-  // and this is just a more runtime performance
-  // issue with CPU load.
-  sleep(20);
-  
-  printf("Enabling Event Wait Mode...\n");
-  s_start_waiting = true;
-  
-  while (!doneYet) {
-    //ptr->user.data1 = (void *)i;
-    if ((val = gnash::check_sockets(xml_fd)) == -1) {
-      return -1; // we shouldn't be seeing any errors
-    }
-    // Don't push an event if there is already one in the
-    // queue. XMLSocket::onData() will come around and get
-    // the data anyway.
-    count = SDL_PeepEvents(ptr, 1, SDL_PEEKEVENT, SDL_USEREVENT);
-    // printf("%d User Events in queue\n", count);
-    if ((count == 0) && (val >= 0)) {
-      //printf("Pushing User Event on queue\n");
-      SDL_PushEvent(ptr);
-      SDL_Delay(300);	// was 300
+    
+    printf("Initializing event thread...\n");
+    
+    while (gnash::check_sockets(xml_fd) == -1) {
+        sleep(10); // Delay to give the socket time to
+        // connect.
+        continue;
+    }
+    
+    // give everything a chance to initialize.
+    // since all the frames need to be set up,
+    // and this is just a more runtime performance
+    // issue with CPU load.
+    sleep(20);
+    
+    printf("Enabling Event Wait Mode...\n");
+    s_start_waiting = true;
+    
+    while (!doneYet) {
+        //ptr->user.data1 = (void *)i;
+        if ((val = gnash::check_sockets(xml_fd)) == -1) {
+            return -1; // we shouldn't be seeing any errors
+        }
+        // Don't push an event if there is already one in the
+        // queue. XMLSocket::onData() will come around and get
+        // the data anyway.
+        count = SDL_PeepEvents(ptr, 1, SDL_PEEKEVENT, SDL_USEREVENT);
+        // printf("%d User Events in queue\n", count);
+        if ((count == 0) && (val >= 0)) {
+            //printf("Pushing User Event on queue\n");
+            SDL_PushEvent(ptr);
+            SDL_Delay(300);	// was 300
+        }
     }
-  }
 #endif // HAVE_LIBXML
-  
-  return 0;
+    
+    return 0;
+}
+
+void
+usage(const char*name)
+{
+    printf(
+        "gnash -- a standalone Flash player.\n"
+        "\n"
+        "usage: %s [options] movie_file.swf\n"
+        "\n"
+        "Plays a SWF (Shockwave Flash) movie using OpenGL"
+        "\n"
+        "options:\n"
+        "\n"
+        "  -h          Print this info.\n"
+        "  -s <factor> Scale the movie up/down by the specified factor\n"
+        "  -c          Produce a core file instead of letting SDL trap it\n"
+        "  -d num      Number of milli-seconds to delay in main loop\n"
+//        "  -a          Turn antialiasing on/off.  (obsolete)\n"
+        "  -v          Be verbose; i.e. print log messages to stdout\n"
+        "  -va         Be verbose about movie Actions\n"
+        "  -vp         Be verbose about parsing the movie\n"
+        "  -m <bias>  Specify the texture LOD bias (float, default is -1)\n"
+        "  -f          Run full speed (no sleep) and log frame rate\n"
+//         "  -e          Use SDL Event thread\n"
+        "  -x <ID>     X11 Window ID for display\n"
+        "  -1          Play once; exit when/if movie reaches the last frame\n"
+        "  -r <0|1|2>  0 disables renderering & sound (good for batch tests)\n"
+        "              1 enables rendering & sound (default setting)\n"
+        "              2 enables rendering & disables sound\n"
+        "  -t <sec>    Timeout and exit after the specified number of seconds\n"
+        "  -b <bits>   Bit depth of output window (16 or 32, default is 16)\n"
+        "\n"
+        "keys:\n"
+        "  CTRL-Q          Quit/Exit\n"
+        "  CTRL-W          Quit/Exit\n"
+        "  ESC             Quit/Exit\n"
+        "  CTRL-P          Toggle Pause\n"
+        "  CTRL-R          Restart the movie\n"
+        "  CTRL-[ or kp-   Step back one frame\n"
+        "  CTRL-] or kp+   Step forward one frame\n"
+        "  CTRL-A          Toggle antialiasing (doesn't work)\n"
+        "  CTRL-T          Debug.  Test the set_variable() function\n"
+        "  CTRL-G          Debug.  Test the get_variable() function\n"
+        "  CTRL-M          Debug.  Test the call_method() function\n"
+        "  CTRL-B          Toggle background color\n", name
+        );
 }
 
Index: gnash/backend/render_handler_ogl.cpp
diff -u gnash/backend/render_handler_ogl.cpp:1.7 \
                gnash/backend/render_handler_ogl.cpp:1.8
--- gnash/backend/render_handler_ogl.cpp:1.7	Sun Feb 26 15:49:29 2006
+++ gnash/backend/render_handler_ogl.cpp	Sat Mar 11 20:47:24 2006
@@ -12,8 +12,12 @@
 #include "ogl.h"
 #include "utility.h"
 
+#include "log.h"
+
 #include <string.h>	// for memset()
 
+using namespace gnash;
+
 // choose the resampling method:
 // 1 = hardware (experimental, should be fast, somewhat buggy)
 // 2 = fast software bilinear (default)
@@ -33,327 +37,309 @@
 // bitmap_info_ogl declaration
 struct bitmap_info_ogl : public gnash::bitmap_info
 {
-	bitmap_info_ogl();
-	bitmap_info_ogl(int width, int height, Uint8* data);
-	bitmap_info_ogl(image::rgb* im);
-	bitmap_info_ogl(image::rgba* im);
-
-	~bitmap_info_ogl()
-	{
-		if (m_texture_id > 0)
-		{
-			glDeleteTextures(1, (GLuint*) &m_texture_id);
-		}
+    bitmap_info_ogl();
+    bitmap_info_ogl(int width, int height, Uint8* data);
+    bitmap_info_ogl(image::rgb* im);
+    bitmap_info_ogl(image::rgba* im);
+
+    ~bitmap_info_ogl() {
+	if (m_texture_id > 0) {
+	    glDeleteTextures(1, (GLuint*) &m_texture_id);
 	}
+    }
 };
 
 struct render_handler_ogl : public gnash::render_handler
 {
-	// Some renderer state.
-
-	// Enable/disable antialiasing.
-	bool	m_enable_antialias;
-	
-	// Output size.
-	float	m_display_width;
-	float	m_display_height;
+    // Some renderer state.
+    
+    // Enable/disable antialiasing.
+    bool	m_enable_antialias;
+    
+    // Output size.
+    float	m_display_width;
+    float	m_display_height;
 	
-	gnash::matrix	m_current_matrix;
-	gnash::cxform	m_current_cxform;
-	void set_antialiased(bool enable)
-	{
-		m_enable_antialias = enable;
-	}
-
-	static void make_next_miplevel(int* width, int* height, Uint8* data)
-	// Utility.  Mutates *width, *height and *data to create the
-	// next mip level.
-	{
-		assert(width);
-		assert(height);
-		assert(data);
-
-		int	new_w = *width >> 1;
-		int	new_h = *height >> 1;
-		if (new_w < 1) new_w = 1;
-		if (new_h < 1) new_h = 1;
+    gnash::matrix	m_current_matrix;
+    gnash::cxform	m_current_cxform;
+    void set_antialiased(bool enable) {
+	m_enable_antialias = enable;
+    }
+
+    // Utility.  Mutates *width, *height and *data to create the
+    // next mip level.
+    static void make_next_miplevel(int* width, int* height, Uint8* data)
+	{
+	    assert(width);
+	    assert(height);
+	    assert(data);
+
+	    int	new_w = *width >> 1;
+	    int	new_h = *height >> 1;
+	    if (new_w < 1) new_w = 1;
+	    if (new_h < 1) new_h = 1;
 		
-		if (new_w * 2 != *width	 || new_h * 2 != *height)
-		{
-			// Image can't be shrunk along (at least) one
-			// of its dimensions, so don't bother
-			// resampling.	Technically we should, but
-			// it's pretty useless at this point.  Just
-			// change the image dimensions and leave the
-			// existing pixels.
-		}
-		else
-		{
-			// Resample.  Simple average 2x2 --> 1, in-place.
-			for (int j = 0; j < new_h; j++) {
-				Uint8*	out = ((Uint8*) data) + j * new_w;
-				Uint8*	in = ((Uint8*) data) + (j << 1) * *width;
-				for (int i = 0; i < new_w; i++) {
-					int	a;
-					a = (*(in + 0) + *(in + 1) + *(in + 0 + *width) + *(in + 1 + *width));
-					*(out) = a >> 2;
-					out++;
-					in += 2;
-				}
-			}
+	    if (new_w * 2 != *width	 || new_h * 2 != *height) {
+		// Image can't be shrunk along (at least) one
+		// of its dimensions, so don't bother
+		// resampling.	Technically we should, but
+		// it's pretty useless at this point.  Just
+		// change the image dimensions and leave the
+		// existing pixels.
+	    } else {
+		// Resample.  Simple average 2x2 --> 1, in-place.
+		for (int j = 0; j < new_h; j++) {
+		    Uint8*	out = ((Uint8*) data) + j * new_w;
+		    Uint8*	in = ((Uint8*) data) + (j << 1) * *width;
+		    for (int i = 0; i < new_w; i++) {
+			int	a;
+			a = (*(in + 0) + *(in + 1) + *(in + 0 + *width) + *(in + 1 + *width));
+			*(out) = a >> 2;
+			out++;
+			in += 2;
+		    }
+		}
+	    }
+	    
+	    // Munge parameters to reflect the shrunken image.
+	    *width = new_w;
+	    *height = new_h;
+	}
+    
+    struct fill_style
+    {
+	enum mode
+	{
+	    INVALID,
+	    COLOR,
+	    BITMAP_WRAP,
+	    BITMAP_CLAMP,
+	    LINEAR_GRADIENT,
+	    RADIAL_GRADIENT,
+	};
+	mode	m_mode;
+	gnash::rgba	m_color;
+	const gnash::bitmap_info*	m_bitmap_info;
+	gnash::matrix	m_bitmap_matrix;
+	gnash::cxform	m_bitmap_color_transform;
+	bool	m_has_nonzero_bitmap_additive_color;
+		
+	fill_style()
+	    :
+	    m_mode(INVALID),
+	    m_has_nonzero_bitmap_additive_color(false)
+	    {
+	    }
+
+	// Push our style into OpenGL.
+	void apply(/*const matrix& current_matrix*/) const
+	{
+	    assert(m_mode != INVALID);
+	    
+	    if (m_mode == COLOR) {
+		apply_color(m_color);
+		glDisable(GL_TEXTURE_2D);
+	    } else if (m_mode == BITMAP_WRAP
+		       || m_mode == BITMAP_CLAMP) {
+		assert(m_bitmap_info != NULL);
+		
+		apply_color(m_color);
+		
+		if (m_bitmap_info == NULL) {
+		    glDisable(GL_TEXTURE_2D);
+		} else {
+		    // Set up the texture for rendering.
+		    {
+			// Do the modulate part of the color
+			// transform in the first pass.  The
+			// additive part, if any, needs to
+			// happen in a second pass.
+			glColor4f(m_bitmap_color_transform.m_[0][0],
+				  m_bitmap_color_transform.m_[1][0],
+				  m_bitmap_color_transform.m_[2][0],
+				  m_bitmap_color_transform.m_[3][0]
+			    );
+		    }
+		    
+		    glBindTexture(GL_TEXTURE_2D, m_bitmap_info->m_texture_id);
+		    glEnable(GL_TEXTURE_2D);
+		    glEnable(GL_TEXTURE_GEN_S);
+		    glEnable(GL_TEXTURE_GEN_T);
+		    
+		    if (m_mode == BITMAP_CLAMP)	{	
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+		    } else {
+			assert(m_mode == BITMAP_WRAP);
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+		    }
+		    
+		    // Set up the bitmap matrix for texgen.
+		    
+		    float	inv_width = 1.0f / m_bitmap_info->m_original_width;
+		    float	inv_height = 1.0f / m_bitmap_info->m_original_height;
+		    
+		    const gnash::matrix&	m = m_bitmap_matrix;
+		    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+		    float	p[4] = { 0, 0, 0, 0 };
+		    p[0] = m.m_[0][0] * inv_width;
+		    p[1] = m.m_[0][1] * inv_width;
+		    p[3] = m.m_[0][2] * inv_width;
+		    glTexGenfv(GL_S, GL_OBJECT_PLANE, p);
+		    
+		    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+		    p[0] = m.m_[1][0] * inv_height;
+		    p[1] = m.m_[1][1] * inv_height;
+		    p[3] = m.m_[1][2] * inv_height;
+		    glTexGenfv(GL_T, GL_OBJECT_PLANE, p);
 		}
-
-		// Munge parameters to reflect the shrunken image.
-		*width = new_w;
-		*height = new_h;
+	    }
 	}
 	
-	struct fill_style
-	{
-		enum mode
-		{
-			INVALID,
-			COLOR,
-			BITMAP_WRAP,
-			BITMAP_CLAMP,
-			LINEAR_GRADIENT,
-			RADIAL_GRADIENT,
-		};
-		mode	m_mode;
-		gnash::rgba	m_color;
-		const gnash::bitmap_info*	m_bitmap_info;
-		gnash::matrix	m_bitmap_matrix;
-		gnash::cxform	m_bitmap_color_transform;
-		bool	m_has_nonzero_bitmap_additive_color;
-		
-		fill_style()
-			:
-			m_mode(INVALID),
-			m_has_nonzero_bitmap_additive_color(false)
-		{
-		}
-
-		void	apply(/*const matrix& current_matrix*/) const
-		// Push our style into OpenGL.
-		{
-			assert(m_mode != INVALID);
-			
-			if (m_mode == COLOR)
-			{
-				apply_color(m_color);
-				glDisable(GL_TEXTURE_2D);
-			}
-			else if (m_mode == BITMAP_WRAP
-				 || m_mode == BITMAP_CLAMP)
-			{
-				assert(m_bitmap_info != NULL);
-
-				apply_color(m_color);
-
-				if (m_bitmap_info == NULL)
-				{
-					glDisable(GL_TEXTURE_2D);
-				}
-				else
-				{
-					// Set up the texture for rendering.
-					{
-						// Do the modulate part of the color
-						// transform in the first pass.  The
-						// additive part, if any, needs to
-						// happen in a second pass.
-						glColor4f(m_bitmap_color_transform.m_[0][0],
-							  m_bitmap_color_transform.m_[1][0],
-							  m_bitmap_color_transform.m_[2][0],
-							  m_bitmap_color_transform.m_[3][0]
-							  );
-					}
-
-					glBindTexture(GL_TEXTURE_2D, m_bitmap_info->m_texture_id);
-					glEnable(GL_TEXTURE_2D);
-					glEnable(GL_TEXTURE_GEN_S);
-					glEnable(GL_TEXTURE_GEN_T);
-				
-					if (m_mode == BITMAP_CLAMP)
-					{	
-						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-					}
-					else
-					{
-						assert(m_mode == BITMAP_WRAP);
-						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-					}
-
-					// Set up the bitmap matrix for texgen.
-
-					float	inv_width = 1.0f / m_bitmap_info->m_original_width;
-					float	inv_height = 1.0f / m_bitmap_info->m_original_height;
-
-					const gnash::matrix&	m = m_bitmap_matrix;
-					glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-					float	p[4] = { 0, 0, 0, 0 };
-					p[0] = m.m_[0][0] * inv_width;
-					p[1] = m.m_[0][1] * inv_width;
-					p[3] = m.m_[0][2] * inv_width;
-					glTexGenfv(GL_S, GL_OBJECT_PLANE, p);
-
-					glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-					p[0] = m.m_[1][0] * inv_height;
-					p[1] = m.m_[1][1] * inv_height;
-					p[3] = m.m_[1][2] * inv_height;
-					glTexGenfv(GL_T, GL_OBJECT_PLANE, p);
-				}
-			}
-		}
-
-
-		bool	needs_second_pass() const
-		// Return true if we need to do a second pass to make
-		// a valid color.  This is for cxforms with additive
-		// parts; this is the simplest way (that we know of)
-		// to implement an additive color with stock OpenGL.
-		{
-			if (m_mode == BITMAP_WRAP
-			    || m_mode == BITMAP_CLAMP)
-			{
-				return m_has_nonzero_bitmap_additive_color;
-			}
-			else
-			{
-				return false;
-			}
-		}
-
-		void	apply_second_pass() const
-		// Set OpenGL state for a necessary second pass.
-		{
-			assert(needs_second_pass());
-
-			// The additive color also seems to be modulated by the texture. So,
-			// maybe we can fake this in one pass using using the mean value of 
-			// the colors: c0*t+c1*t = ((c0+c1)/2) * t*2
-			// I don't know what the alpha component of the color is for.
-			//glDisable(GL_TEXTURE_2D);
-
-			glColor4f(
-				m_bitmap_color_transform.m_[0][1] / 255.0f,
-				m_bitmap_color_transform.m_[1][1] / 255.0f,
-				m_bitmap_color_transform.m_[2][1] / 255.0f,
-				m_bitmap_color_transform.m_[3][1] / 255.0f
-				);
-
-			glBlendFunc(GL_ONE, GL_ONE);
+	
+	// Return true if we need to do a second pass to make
+	// a valid color.  This is for cxforms with additive
+	// parts; this is the simplest way (that we know of)
+	// to implement an additive color with stock OpenGL.
+	bool	needs_second_pass() const
+	    {
+		if (m_mode == BITMAP_WRAP
+		    || m_mode == BITMAP_CLAMP) {
+		    return m_has_nonzero_bitmap_additive_color;
+		} else {
+		    return false;
 		}
+	    }
+	
+	// Set OpenGL state for a necessary second pass.
+	void	apply_second_pass() const
+	    {
+		assert(needs_second_pass());
+		
+		// The additive color also seems to be modulated by the texture. So,
+		// maybe we can fake this in one pass using using the mean value of 
+		// the colors: c0*t+c1*t = ((c0+c1)/2) * t*2
+		// I don't know what the alpha component of the color is for.
+		//glDisable(GL_TEXTURE_2D);
+		
+		glColor4f(
+		    m_bitmap_color_transform.m_[0][1] / 255.0f,
+		    m_bitmap_color_transform.m_[1][1] / 255.0f,
+		    m_bitmap_color_transform.m_[2][1] / 255.0f,
+		    m_bitmap_color_transform.m_[3][1] / 255.0f
+		    );
+		
+		glBlendFunc(GL_ONE, GL_ONE);
+	    }
 
-		void	cleanup_second_pass() const
-		{
-			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-		}
+	void	cleanup_second_pass() const
+	    {
+		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	    }
 
 
-		void	disable() { m_mode = INVALID; }
-		void	set_color(gnash::rgba color) { m_mode = COLOR; m_color = color; }
-		void	set_bitmap(const gnash::bitmap_info* bi, const gnash::matrix& m, \
                bitmap_wrap_mode wm, const gnash::cxform& color_transform)
-		{
-			m_mode = (wm == WRAP_REPEAT) ? BITMAP_WRAP : BITMAP_CLAMP;
-			m_bitmap_info = bi;
-			m_bitmap_matrix = m;
-			m_bitmap_color_transform = color_transform;
-			m_bitmap_color_transform.clamp();
+	void	disable() { m_mode = INVALID; }
+	void	set_color(gnash::rgba color) { m_mode = COLOR; m_color = color; }
+	void	set_bitmap(const gnash::bitmap_info* bi, const gnash::matrix& m, \
bitmap_wrap_mode wm, const gnash::cxform& color_transform) +	    {
+		m_mode = (wm == WRAP_REPEAT) ? BITMAP_WRAP : BITMAP_CLAMP;
+		m_bitmap_info = bi;
+		m_bitmap_matrix = m;
+		m_bitmap_color_transform = color_transform;
+		m_bitmap_color_transform.clamp();
 			
-			m_color = gnash::rgba(
-			    Uint8(m_bitmap_color_transform.m_[0][0] * 255.0f),
-			    Uint8(m_bitmap_color_transform.m_[1][0] * 255.0f),
-			    Uint8(m_bitmap_color_transform.m_[2][0] * 255.0f),
-			    Uint8(m_bitmap_color_transform.m_[3][0] * 255.0f));
+		m_color = gnash::rgba(
+		    Uint8(m_bitmap_color_transform.m_[0][0] * 255.0f),
+		    Uint8(m_bitmap_color_transform.m_[1][0] * 255.0f),
+		    Uint8(m_bitmap_color_transform.m_[2][0] * 255.0f),
+		    Uint8(m_bitmap_color_transform.m_[3][0] * 255.0f));
 			
-			if (m_bitmap_color_transform.m_[0][1] > 1.0f
-			    || m_bitmap_color_transform.m_[1][1] > 1.0f
-			    || m_bitmap_color_transform.m_[2][1] > 1.0f
-			    || m_bitmap_color_transform.m_[3][1] > 1.0f)
-			{
-				m_has_nonzero_bitmap_additive_color = true;
-			}
-			else
-			{
-				m_has_nonzero_bitmap_additive_color = false;
-			}
-		}
-		bool	is_valid() const { return m_mode != INVALID; }
-	};
-
-
-	// Style state.
-	enum style_index
-	{
-		LEFT_STYLE = 0,
-		RIGHT_STYLE,
-		LINE_STYLE,
-
-		STYLE_COUNT
-	};
-	fill_style	m_current_styles[STYLE_COUNT];
+		if (m_bitmap_color_transform.m_[0][1] > 1.0f
+		    || m_bitmap_color_transform.m_[1][1] > 1.0f
+		    || m_bitmap_color_transform.m_[2][1] > 1.0f
+		    || m_bitmap_color_transform.m_[3][1] > 1.0f)
+		    {
+			m_has_nonzero_bitmap_additive_color = true;
+		    }
+		else
+		    {
+			m_has_nonzero_bitmap_additive_color = false;
+		    }
+	    }
+	bool	is_valid() const { return m_mode != INVALID; }
+    };
+
+
+    // Style state.
+    enum style_index
+    {
+	LEFT_STYLE = 0,
+	RIGHT_STYLE,
+	LINE_STYLE,
+
+	STYLE_COUNT
+    };
+    fill_style	m_current_styles[STYLE_COUNT];
 
 
-	gnash::bitmap_info*	create_bitmap_info_rgb(image::rgb* im)
+    gnash::bitmap_info*	create_bitmap_info_rgb(image::rgb* im)
 	// Given an image, returns a pointer to a bitmap_info struct
 	// that can later be passed to fill_styleX_bitmap(), to set a
 	// bitmap fill style.
 	{
-		return new bitmap_info_ogl(im);
+	    return new bitmap_info_ogl(im);
 	}
 
 
-	gnash::bitmap_info*	create_bitmap_info_rgba(image::rgba* im)
+    gnash::bitmap_info*	create_bitmap_info_rgba(image::rgba* im)
 	// Given an image, returns a pointer to a bitmap_info struct
 	// that can later be passed to fill_style_bitmap(), to set a
 	// bitmap fill style.
 	//
 	// This version takes an image with an alpha channel.
 	{
-		return new bitmap_info_ogl(im);
+	    return new bitmap_info_ogl(im);
 	}
 
 
-	gnash::bitmap_info*	create_bitmap_info_empty()
+    gnash::bitmap_info*	create_bitmap_info_empty()
 	// Create a placeholder bitmap_info.  Used when
 	// DO_NOT_LOAD_BITMAPS is set; then later on the host program
 	// can use movie_definition::get_bitmap_info_count() and
 	// movie_definition::get_bitmap_info() to stuff precomputed
 	// textures into these bitmap infos.
 	{
-		return new bitmap_info_ogl;
+	    return new bitmap_info_ogl;
 	}
 
-	gnash::bitmap_info*	create_bitmap_info_alpha(int w, int h, Uint8* data)
+    gnash::bitmap_info*	create_bitmap_info_alpha(int w, int h, Uint8* data)
 	// Create a bitmap_info so that it contains an alpha texture
 	// with the given data (1 byte per texel).
 	//
 	// Munges *data (in order to make mipmaps)!!
 	{
-		return new bitmap_info_ogl(w, h, data);
+	    return new bitmap_info_ogl(w, h, data);
 	}
 
 
-	void	delete_bitmap_info(gnash::bitmap_info* bi)
+    void	delete_bitmap_info(gnash::bitmap_info* bi)
 	// Delete the given bitmap info struct.
 	{
-		delete bi;
+	    delete bi;
 	}
 
 
-	~render_handler_ogl()
+    ~render_handler_ogl()
 	{
 	}
 
 
-	void	begin_display(
-		gnash::rgba background_color,
-		int viewport_x0, int viewport_y0,
-		int viewport_width, int viewport_height,
-		float x0, float x1, float y0, float y1)
+    void	begin_display(
+	gnash::rgba background_color,
+	int viewport_x0, int viewport_y0,
+	int viewport_width, int viewport_height,
+	float x0, float x1, float y0, float y1)
 	// Set up to render a full frame from a movie and fills the
 	// background.	Sets up necessary transforms, to scale the
 	// movie to fit within the given dimensions.  Call
@@ -367,36 +353,37 @@
 	// coordinates of the movie that correspond to the viewport
 	// bounds.
 	{
-		m_display_width = fabsf(x1 - x0);
-		m_display_height = fabsf(y1 - y0);
+	    
+	    m_display_width = fabsf(x1 - x0);
+	    m_display_height = fabsf(y1 - y0);
 
-		glViewport(viewport_x0, viewport_y0, viewport_width, viewport_height);
+	    glViewport(viewport_x0, viewport_y0, viewport_width, viewport_height);
 
-		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-		glOrtho(x0, x1, y0, y1, -1, 1);
+	    glMatrixMode(GL_MODELVIEW);
+	    glPushMatrix();
+	    glOrtho(x0, x1, y0, y1, -1, 1);
 
-		glEnable(GL_BLEND);
-		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	    glEnable(GL_BLEND);
+	    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);	// GL_MODULATE
+	    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);	// GL_MODULATE
 
-		glDisable(GL_TEXTURE_2D);
+	    glDisable(GL_TEXTURE_2D);
 
-		// Clear the background, if background color has alpha > 0.
-		if (background_color.m_a > 0)
+	    // Clear the background, if background color has alpha > 0.
+	    if (background_color.m_a > 0)
 		{
-			// Draw a big quad.
-			apply_color(background_color);
-			glBegin(GL_QUADS);
-			glVertex2f(x0, y0);
-			glVertex2f(x1, y0);
-			glVertex2f(x1, y1);
-			glVertex2f(x0, y1);
-			glEnd();
+		    // Draw a big quad.
+		    apply_color(background_color);
+		    glBegin(GL_QUADS);
+		    glVertex2f(x0, y0);
+		    glVertex2f(x1, y0);
+		    glVertex2f(x1, y1);
+		    glVertex2f(x0, y1);
+		    glEnd();
 		}
 
-		// Old unused code.  Might get revived someday.
+	    // Old unused code.  Might get revived someday.
 // #if 0
 // 				// See if we want to, and can, use multitexture
 // 				// antialiasing.
@@ -441,198 +428,198 @@
 	}
 
 
-	void	end_display()
+    void	end_display()
 	// Clean up after rendering a frame.  Client program is still
 	// responsible for calling glSwapBuffers() or whatever.
 	{
-		glMatrixMode(GL_MODELVIEW);
-		glPopMatrix();
+	    glMatrixMode(GL_MODELVIEW);
+	    glPopMatrix();
 	}
 
 
-	void	set_matrix(const gnash::matrix& m)
+    void	set_matrix(const gnash::matrix& m)
 	// Set the current transform for mesh & line-strip rendering.
 	{
-		m_current_matrix = m;
+	    m_current_matrix = m;
 	}
 
 
-	void	set_cxform(const gnash::cxform& cx)
+    void	set_cxform(const gnash::cxform& cx)
 	// Set the current color transform for mesh & line-strip rendering.
 	{
-		m_current_cxform = cx;
+	    m_current_cxform = cx;
 	}
 	
-	static void	apply_matrix(const gnash::matrix& m)
+    static void	apply_matrix(const gnash::matrix& m)
 	// multiply current matrix with opengl matrix
 	{
-		float	mat[16];
-		memset(&mat[0], 0, sizeof(mat));
-		mat[0] = m.m_[0][0];
-		mat[1] = m.m_[1][0];
-		mat[4] = m.m_[0][1];
-		mat[5] = m.m_[1][1];
-		mat[10] = 1;
-		mat[12] = m.m_[0][2];
-		mat[13] = m.m_[1][2];
-		mat[15] = 1;
-		glMultMatrixf(mat);
+	    float	mat[16];
+	    memset(&mat[0], 0, sizeof(mat));
+	    mat[0] = m.m_[0][0];
+	    mat[1] = m.m_[1][0];
+	    mat[4] = m.m_[0][1];
+	    mat[5] = m.m_[1][1];
+	    mat[10] = 1;
+	    mat[12] = m.m_[0][2];
+	    mat[13] = m.m_[1][2];
+	    mat[15] = 1;
+	    glMultMatrixf(mat);
 	}
 
-	static void	apply_color(const gnash::rgba& c)
+    static void	apply_color(const gnash::rgba& c)
 	// Set the given color.
 	{
-		glColor4ub(c.m_r, c.m_g, c.m_b, c.m_a);
+	    glColor4ub(c.m_r, c.m_g, c.m_b, c.m_a);
 	}
 
-	void	fill_style_disable(int fill_side)
+    void	fill_style_disable(int fill_side)
 	// Don't fill on the {0 == left, 1 == right} side of a path.
 	{
-		assert(fill_side >= 0 && fill_side < 2);
+	    assert(fill_side >= 0 && fill_side < 2);
 
-		m_current_styles[fill_side].disable();
+	    m_current_styles[fill_side].disable();
 	}
 
 
-	void	line_style_disable()
+    void	line_style_disable()
 	// Don't draw a line on this path.
 	{
-		m_current_styles[LINE_STYLE].disable();
+	    m_current_styles[LINE_STYLE].disable();
 	}
 
 
-	void	fill_style_color(int fill_side, gnash::rgba color)
+    void	fill_style_color(int fill_side, gnash::rgba color)
 	// Set fill style for the left interior of the shape.  If
 	// enable is false, turn off fill for the left interior.
 	{
-		assert(fill_side >= 0 && fill_side < 2);
+	    assert(fill_side >= 0 && fill_side < 2);
 
-		m_current_styles[fill_side].set_color(m_current_cxform.transform(color));
+	    m_current_styles[fill_side].set_color(m_current_cxform.transform(color));
 	}
 
 
-	void	line_style_color(gnash::rgba color)
+    void	line_style_color(gnash::rgba color)
 	// Set the line style of the shape.  If enable is false, turn
 	// off lines for following curve segments.
 	{
-		m_current_styles[LINE_STYLE].set_color(m_current_cxform.transform(color));
+	    m_current_styles[LINE_STYLE].set_color(m_current_cxform.transform(color));
 	}
 
 
-	void	fill_style_bitmap(int fill_side, const gnash::bitmap_info* bi, const \
gnash::matrix& m, bitmap_wrap_mode wm) +    void	fill_style_bitmap(int fill_side, \
const gnash::bitmap_info* bi, const gnash::matrix& m, bitmap_wrap_mode wm)  {
-		assert(fill_side >= 0 && fill_side < 2);
-		m_current_styles[fill_side].set_bitmap(bi, m, wm, m_current_cxform);
+	    assert(fill_side >= 0 && fill_side < 2);
+	    m_current_styles[fill_side].set_bitmap(bi, m, wm, m_current_cxform);
 	}
 	
-	void	line_style_width(float width)
+    void	line_style_width(float width)
 	{
-		// TODO: OpenGL doesn't seem to handle very low-width lines well, even with \
                anti-aliasing enabled
-		// But this is a start (20 TWIPS' width = 1 pixel's)
-		glLineWidth(TWIPS_TO_PIXELS(width));
+	    // TODO: OpenGL doesn't seem to handle very low-width lines well, even with \
anti-aliasing enabled +	    // But this is a start (20 TWIPS' width = 1 pixel's)
+	    glLineWidth(TWIPS_TO_PIXELS(width));
 	}
 
 
-	void	draw_mesh_strip(const void* coords, int vertex_count)
+    void	draw_mesh_strip(const void* coords, int vertex_count)
 	{
 #define NORMAL_RENDERING
 //#define MULTIPASS_ANTIALIASING
 
 #ifdef NORMAL_RENDERING
-		// Set up current style.
-		m_current_styles[LEFT_STYLE].apply();
+	    // Set up current style.
+	    m_current_styles[LEFT_STYLE].apply();
+
+	    glMatrixMode(GL_MODELVIEW);
+	    glPushMatrix();
+	    apply_matrix(m_current_matrix);
 
-		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-		apply_matrix(m_current_matrix);
-
-		// Send the tris to OpenGL
-		glEnableClientState(GL_VERTEX_ARRAY);
-		glVertexPointer(2, GL_SHORT, sizeof(Sint16) * 2, coords);
-		glDrawArrays(GL_TRIANGLE_STRIP, 0, vertex_count);
+	    // Send the tris to OpenGL
+	    glEnableClientState(GL_VERTEX_ARRAY);
+	    glVertexPointer(2, GL_SHORT, sizeof(Sint16) * 2, coords);
+	    glDrawArrays(GL_TRIANGLE_STRIP, 0, vertex_count);
 
-		if (m_current_styles[LEFT_STYLE].needs_second_pass())
+	    if (m_current_styles[LEFT_STYLE].needs_second_pass())
 		{
-			m_current_styles[LEFT_STYLE].apply_second_pass();
-			glDrawArrays(GL_TRIANGLE_STRIP, 0, vertex_count);
-			m_current_styles[LEFT_STYLE].cleanup_second_pass();
+		    m_current_styles[LEFT_STYLE].apply_second_pass();
+		    glDrawArrays(GL_TRIANGLE_STRIP, 0, vertex_count);
+		    m_current_styles[LEFT_STYLE].cleanup_second_pass();
 		}
 
-		glDisableClientState(GL_VERTEX_ARRAY);
+	    glDisableClientState(GL_VERTEX_ARRAY);
 
-		glPopMatrix();
+	    glPopMatrix();
 #endif // NORMAL_RENDERING
 
 #ifdef MULTIPASS_ANTIALIASING
-		// So this approach basically works.  This
-		// implementation is not totally finished; two pass
-		// materials (i.e. w/ additive color) aren't correct,
-		// and there are some texture etc issues because I'm
-		// just hosing state uncarefully here.  It needs the
-		// optimization of only filling the bounding box of
-		// the shape.  You must have destination alpha.
-		//
-		// It doesn't look quite perfect on my GF4.  For one
-		// thing, you kinda want to crank down the max curve
-		// subdivision error, because suddenly you can see
-		// sub-pixel shape much better.  For another thing,
-		// the antialiasing isn't quite perfect, to my eye.
-		// It could be limited alpha precision, imperfections
-		// GL_POLYGON_SMOOTH, and/or my imagination.
-
-		glDisable(GL_TEXTURE_2D);
-
-		glEnable(GL_POLYGON_SMOOTH);
-		glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);	// GL_NICEST, GL_FASTEST, GL_DONT_CARE
+	    // So this approach basically works.  This
+	    // implementation is not totally finished; two pass
+	    // materials (i.e. w/ additive color) aren't correct,
+	    // and there are some texture etc issues because I'm
+	    // just hosing state uncarefully here.  It needs the
+	    // optimization of only filling the bounding box of
+	    // the shape.  You must have destination alpha.
+	    //
+	    // It doesn't look quite perfect on my GF4.  For one
+	    // thing, you kinda want to crank down the max curve
+	    // subdivision error, because suddenly you can see
+	    // sub-pixel shape much better.  For another thing,
+	    // the antialiasing isn't quite perfect, to my eye.
+	    // It could be limited alpha precision, imperfections
+	    // GL_POLYGON_SMOOTH, and/or my imagination.
+
+	    glDisable(GL_TEXTURE_2D);
+
+	    glEnable(GL_POLYGON_SMOOTH);
+	    glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);	// GL_NICEST, GL_FASTEST, \
GL_DONT_CARE +
+	    // Clear destination alpha.
+	    //
+	    // @@ TODO Instead of drawing this huge screen-filling
+	    // quad, we should take a bounding-box param from the
+	    // caller, and draw the box (after apply_matrix;
+	    // i.e. the box is in object space).  The point being,
+	    // to only fill the part of the screen that the shape
+	    // is in.
+	    glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+	    glColor4f(1, 1, 1, 0);
+	    glBegin(GL_QUADS);
+	    glVertex2f(0, 0);
+	    glVertex2f(100000, 0);
+	    glVertex2f(100000, 100000);
+	    glVertex2f(0, 100000);
+	    glEnd();
+
+	    // Set mode for drawing alpha mask.
+	    glBlendFunc(GL_ONE, GL_ONE);	// additive blending
+	    glColor4f(0, 0, 0, m_current_styles[LEFT_STYLE].m_color.m_a / 255.0f);
+
+	    glMatrixMode(GL_MODELVIEW);
+	    glPushMatrix();
+	    apply_matrix(m_current_matrix);
+
+	    // Send the tris to OpenGL.  This produces an
+	    // antialiased alpha mask of the mesh shape, in the
+	    // destination alpha channel.
+	    glEnableClientState(GL_VERTEX_ARRAY);
+	    glVertexPointer(2, GL_SHORT, sizeof(Sint16) * 2, coords);
+	    glDrawArrays(GL_TRIANGLE_STRIP, 0, vertex_count);
+	    glDisableClientState(GL_VERTEX_ARRAY);
 
-		// Clear destination alpha.
-		//
-		// @@ TODO Instead of drawing this huge screen-filling
-		// quad, we should take a bounding-box param from the
-		// caller, and draw the box (after apply_matrix;
-		// i.e. the box is in object space).  The point being,
-		// to only fill the part of the screen that the shape
-		// is in.
-		glBlendFunc(GL_ZERO, GL_SRC_COLOR);
-		glColor4f(1, 1, 1, 0);
-		glBegin(GL_QUADS);
-		glVertex2f(0, 0);
-		glVertex2f(100000, 0);
-		glVertex2f(100000, 100000);
-		glVertex2f(0, 100000);
-		glEnd();
-
-		// Set mode for drawing alpha mask.
-		glBlendFunc(GL_ONE, GL_ONE);	// additive blending
-		glColor4f(0, 0, 0, m_current_styles[LEFT_STYLE].m_color.m_a / 255.0f);
-
-		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-		apply_matrix(m_current_matrix);
-
-		// Send the tris to OpenGL.  This produces an
-		// antialiased alpha mask of the mesh shape, in the
-		// destination alpha channel.
-		glEnableClientState(GL_VERTEX_ARRAY);
-		glVertexPointer(2, GL_SHORT, sizeof(Sint16) * 2, coords);
-		glDrawArrays(GL_TRIANGLE_STRIP, 0, vertex_count);
-		glDisableClientState(GL_VERTEX_ARRAY);
-
-		glPopMatrix();
+	    glPopMatrix();
 		
-		// Set up desired fill style.
-		m_current_styles[LEFT_STYLE].apply();
+	    // Set up desired fill style.
+	    m_current_styles[LEFT_STYLE].apply();
 
-		// Apply fill, modulated with alpha mask.
-		//
-		// @@ TODO see note above about filling bounding box only.
-		glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
-		glBegin(GL_QUADS);
-		glVertex2f(0, 0);
-		glVertex2f(100000, 0);
-		glVertex2f(100000, 100000);
-		glVertex2f(0, 100000);
-		glEnd();
+	    // Apply fill, modulated with alpha mask.
+	    //
+	    // @@ TODO see note above about filling bounding box only.
+	    glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
+	    glBegin(GL_QUADS);
+	    glVertex2f(0, 0);
+	    glVertex2f(100000, 0);
+	    glVertex2f(100000, 100000);
+	    glVertex2f(0, 100000);
+	    glEnd();
 
 // xxxxx ??? Hm, is our mask still intact, or did we just erase it?
 // 		if (m_current_styles[LEFT_STYLE].needs_second_pass())
@@ -642,79 +629,79 @@
 // 			m_current_styles[LEFT_STYLE].cleanup_second_pass();
 // 		}
 
-		// @@ hm, there is perhaps more state that needs
-		// fixing here, or setting elsewhere.
-		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	    // @@ hm, there is perhaps more state that needs
+	    // fixing here, or setting elsewhere.
+	    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 #endif // MULTIPASS_ANTIALIASING
 	}
 
 
-	void	draw_line_strip(const void* coords, int vertex_count)
+    void	draw_line_strip(const void* coords, int vertex_count)
 	// Draw the line strip formed by the sequence of points.
 	{
-		// Set up current style.
-		m_current_styles[LINE_STYLE].apply();
+	    // Set up current style.
+	    m_current_styles[LINE_STYLE].apply();
 
-		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-		apply_matrix(m_current_matrix);
+	    glMatrixMode(GL_MODELVIEW);
+	    glPushMatrix();
+	    apply_matrix(m_current_matrix);
 
-		// Send the line-strip to OpenGL
-		glEnableClientState(GL_VERTEX_ARRAY);
-		glVertexPointer(2, GL_SHORT, sizeof(Sint16) * 2, coords);
-		glDrawArrays(GL_LINE_STRIP, 0, vertex_count);
-		glDisableClientState(GL_VERTEX_ARRAY);
+	    // Send the line-strip to OpenGL
+	    glEnableClientState(GL_VERTEX_ARRAY);
+	    glVertexPointer(2, GL_SHORT, sizeof(Sint16) * 2, coords);
+	    glDrawArrays(GL_LINE_STRIP, 0, vertex_count);
+	    glDisableClientState(GL_VERTEX_ARRAY);
 
-		glPopMatrix();
+	    glPopMatrix();
 	}
 
 
-	void	draw_bitmap(
-		const gnash::matrix& m,
-		const gnash::bitmap_info* bi,
-		const gnash::rect& coords,
-		const gnash::rect& uv_coords,
-		gnash::rgba color)
+    void	draw_bitmap(
+	const gnash::matrix& m,
+	const gnash::bitmap_info* bi,
+	const gnash::rect& coords,
+	const gnash::rect& uv_coords,
+	gnash::rgba color)
 	// Draw a rectangle textured with the given bitmap, with the
 	// given color.	 Apply given transform; ignore any currently
 	// set transforms.
 	//
 	// Intended for textured glyph rendering.
 	{
-		assert(bi);
+	    assert(bi);
 
-		apply_color(color);
+	    apply_color(color);
 
-		gnash::point a, b, c, d;
-		m.transform(&a, gnash::point(coords.m_x_min, coords.m_y_min));
-		m.transform(&b, gnash::point(coords.m_x_max, coords.m_y_min));
-		m.transform(&c, gnash::point(coords.m_x_min, coords.m_y_max));
-		d.m_x = b.m_x + c.m_x - a.m_x;
-		d.m_y = b.m_y + c.m_y - a.m_y;
+	    gnash::point a, b, c, d;
+	    m.transform(&a, gnash::point(coords.m_x_min, coords.m_y_min));
+	    m.transform(&b, gnash::point(coords.m_x_max, coords.m_y_min));
+	    m.transform(&c, gnash::point(coords.m_x_min, coords.m_y_max));
+	    d.m_x = b.m_x + c.m_x - a.m_x;
+	    d.m_y = b.m_y + c.m_y - a.m_y;
 
-		glBindTexture(GL_TEXTURE_2D, bi->m_texture_id);
-		glEnable(GL_TEXTURE_2D);
-		glDisable(GL_TEXTURE_GEN_S);
-		glDisable(GL_TEXTURE_GEN_T);
+	    glBindTexture(GL_TEXTURE_2D, bi->m_texture_id);
+	    glEnable(GL_TEXTURE_2D);
+	    glDisable(GL_TEXTURE_GEN_S);
+	    glDisable(GL_TEXTURE_GEN_T);
 
-		glBegin(GL_TRIANGLE_STRIP);
+	    glBegin(GL_TRIANGLE_STRIP);
 
-		glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_min);
-		glVertex2f(a.m_x, a.m_y);
+	    glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_min);
+	    glVertex2f(a.m_x, a.m_y);
 
-		glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_min);
-		glVertex2f(b.m_x, b.m_y);
+	    glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_min);
+	    glVertex2f(b.m_x, b.m_y);
 
-		glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_max);
-		glVertex2f(c.m_x, c.m_y);
+	    glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_max);
+	    glVertex2f(c.m_x, c.m_y);
 
-		glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_max);
-		glVertex2f(d.m_x, d.m_y);
+	    glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_max);
+	    glVertex2f(d.m_x, d.m_y);
 
-		glEnd();
+	    glEnd();
 	}
 	
-	void begin_submit_mask()
+    void begin_submit_mask()
 	{
 	    glEnable(GL_STENCIL_TEST); 
 	    glClearStencil(0);
@@ -727,14 +714,14 @@
 							// replace if test passes 
 	}
 	
-	void end_submit_mask()
+    void end_submit_mask()
 	{	     
 	    glColorMask(1,1,1,1);	// enable framebuffer writes
 	    glStencilFunc(GL_EQUAL, 1, 1);	// we draw only where the stencil is 1 (where \
                the mask was drawn)
 	    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);	// don't change the stencil buffer    
 	}
 	
-	void disable_mask()
+    void disable_mask()
 	{	       
 	    glDisable(GL_STENCIL_TEST); 
 	}
@@ -752,47 +739,47 @@
 // Sets the current texture to a resampled/expanded version of the
 // given image data.
 {
-	assert(bytes_per_pixel == 3 || bytes_per_pixel == 4);
+    assert(bytes_per_pixel == 3 || bytes_per_pixel == 4);
 
-	unsigned int	in_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
-	unsigned int	out_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
+    unsigned int	in_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
+    unsigned int	out_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
 
-	// alex: use the hardware to resample the image
-	// issue: does not work when image > allocated window size!
-	glMatrixMode(GL_PROJECTION);
-	glPushMatrix();
-	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
-	glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT);
-	{
-		char* temp = new char[dst_width * dst_height * bytes_per_pixel];
-		//memset(temp,255,w*h*3);
-		glTexImage2D(GL_TEXTURE_2D, 0, in_format, dst_width, dst_height, 0, out_format, \
                GL_UNSIGNED_BYTE, temp);
-		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, src_width, src_height, out_format, \
                GL_UNSIGNED_BYTE, src_data);
-
-		glLoadIdentity();
-		glViewport(0, 0, dst_width, dst_height);
-		glOrtho(0, dst_width, 0, dst_height, 0.9, 1.1);
-		glColor3f(1, 1, 1);
-		glNormal3f(0, 0, 1);
-		glBegin(GL_QUADS);
-		{
-			glTexCoord2f(0, (float) src_height / dst_height);
-			glVertex3f(0, 0, -1);
-			glTexCoord2f( (float) src_width / dst_width, (float) src_height / dst_height);
-			glVertex3f((float) dst_width, 0, -1);
-			glTexCoord2f( (float) src_width / dst_width, 0);
-			glVertex3f((float) dst_width, (float) dst_height, -1);
-			glTexCoord2f(0, 0);
-			glVertex3f(0, (float) dst_height, -1);
-		}
-		glEnd();
-		glCopyTexImage2D(GL_TEXTURE_2D, 0, out_format, 0,0, dst_width, dst_height, 0);
-		delete temp;
-	}
-	glPopAttrib();
-	glPopMatrix();
-	glPopMatrix();
+    // alex: use the hardware to resample the image
+    // issue: does not work when image > allocated window size!
+    glMatrixMode(GL_PROJECTION);
+    glPushMatrix();
+    glMatrixMode(GL_MODELVIEW);
+    glPushMatrix();
+    glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT);
+    {
+	char* temp = new char[dst_width * dst_height * bytes_per_pixel];
+	//memset(temp,255,w*h*3);
+	glTexImage2D(GL_TEXTURE_2D, 0, in_format, dst_width, dst_height, 0, out_format, \
GL_UNSIGNED_BYTE, temp); +	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, src_width, \
src_height, out_format, GL_UNSIGNED_BYTE, src_data); +
+	glLoadIdentity();
+	glViewport(0, 0, dst_width, dst_height);
+	glOrtho(0, dst_width, 0, dst_height, 0.9, 1.1);
+	glColor3f(1, 1, 1);
+	glNormal3f(0, 0, 1);
+	glBegin(GL_QUADS);
+	{
+	    glTexCoord2f(0, (float) src_height / dst_height);
+	    glVertex3f(0, 0, -1);
+	    glTexCoord2f( (float) src_width / dst_width, (float) src_height / dst_height);
+	    glVertex3f((float) dst_width, 0, -1);
+	    glTexCoord2f( (float) src_width / dst_width, 0);
+	    glVertex3f((float) dst_width, (float) dst_height, -1);
+	    glTexCoord2f(0, 0);
+	    glVertex3f(0, (float) dst_height, -1);
+	}
+	glEnd();
+	glCopyTexImage2D(GL_TEXTURE_2D, 0, out_format, 0,0, dst_width, dst_height, 0);
+	delete temp;
+    }
+    glPopAttrib();
+    glPopMatrix();
+    glPopMatrix();
 }
 
 
@@ -800,150 +787,150 @@
 // DESTRUCTIVELY generate mipmaps of the given image.  The image data
 // and width/height of im are munged in this process.
 {
-	int	level = 1;
-	while (im->m_width > 1 || im->m_height > 1)
+    int	level = 1;
+    while (im->m_width > 1 || im->m_height > 1)
 	{
-		if (bytes_per_pixel == 3)
+	    if (bytes_per_pixel == 3)
 		{
-			image::make_next_miplevel((image::rgb*) im);
+		    image::make_next_miplevel((image::rgb*) im);
 		}
-		else
+	    else
 		{
-			image::make_next_miplevel((image::rgba*) im);
+		    image::make_next_miplevel((image::rgba*) im);
 		}
 
-		glTexImage2D(GL_TEXTURE_2D, level, internal_format, im->m_width, im->m_height, 0,
-			     input_format, GL_UNSIGNED_BYTE, im->m_data);
-		level++;
+	    glTexImage2D(GL_TEXTURE_2D, level, internal_format, im->m_width, im->m_height, \
0, +			 input_format, GL_UNSIGNED_BYTE, im->m_data);
+	    level++;
 	}
 }
 
 
 void	software_resample(
-	int bytes_per_pixel,
-	int src_width,
-	int src_height,
-	int src_pitch,
-	uint8* src_data,
-	int dst_width,
-	int dst_height)
+    int bytes_per_pixel,
+    int src_width,
+    int src_height,
+    int src_pitch,
+    uint8* src_data,
+    int dst_width,
+    int dst_height)
 // Code from Alex Streit
 //
 // Creates an OpenGL texture of the specified dst dimensions, from a
 // resampled version of the given src image.  Does a bilinear
 // resampling to create the dst image.
 {
-	assert(bytes_per_pixel == 3 || bytes_per_pixel == 4);
+    assert(bytes_per_pixel == 3 || bytes_per_pixel == 4);
 
-	assert(dst_width >= src_width);
-	assert(dst_height >= src_height);
+    assert(dst_width >= src_width);
+    assert(dst_height >= src_height);
 
-	unsigned int	internal_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
-	unsigned int	input_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
+    unsigned int	internal_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
+    unsigned int	input_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
 
-	// FAST bi-linear filtering
-	// the code here is designed to be fast, not readable
-	Uint8* rescaled = new Uint8[dst_width * dst_height * bytes_per_pixel];
-	float Uf, Vf;		// fractional parts
-	float Ui, Vi;		// integral parts
-	float w1, w2, w3, w4;	// weighting
-	Uint8* psrc;
-	Uint8* pdst = rescaled;
-	// i1,i2,i3,i4 are the offsets of the surrounding 4 pixels
-	const int i1 = 0;
-	const int i2 = bytes_per_pixel;
-	int i3 = src_pitch;
-	int i4 = src_pitch + bytes_per_pixel;
-	// change in source u and v
-	float dv = (float)(src_height-2) / dst_height;
-	float du = (float)(src_width-2) / dst_width;
-	// source u and source v
-	float U;
-	float V=0;
+    // FAST bi-linear filtering
+    // the code here is designed to be fast, not readable
+    Uint8* rescaled = new Uint8[dst_width * dst_height * bytes_per_pixel];
+    float Uf, Vf;		// fractional parts
+    float Ui, Vi;		// integral parts
+    float w1, w2, w3, w4;	// weighting
+    Uint8* psrc;
+    Uint8* pdst = rescaled;
+    // i1,i2,i3,i4 are the offsets of the surrounding 4 pixels
+    const int i1 = 0;
+    const int i2 = bytes_per_pixel;
+    int i3 = src_pitch;
+    int i4 = src_pitch + bytes_per_pixel;
+    // change in source u and v
+    float dv = (float)(src_height-2) / dst_height;
+    float du = (float)(src_width-2) / dst_width;
+    // source u and source v
+    float U;
+    float V=0;
 
 #define BYTE_SAMPLE(offset)	\
 	(Uint8) (w1 * psrc[i1 + (offset)] + w2 * psrc[i2 + (offset)] + w3 * psrc[i3 + \
(offset)] + w4 * psrc[i4 + (offset)])  
-	if (bytes_per_pixel == 3)
+    if (bytes_per_pixel == 3)
 	{
-		for (int v = 0; v < dst_height; ++v)
+	    for (int v = 0; v < dst_height; ++v)
 		{
-			Vf = modff(V, &Vi);
-			V+=dv;
-			U=0;
+		    Vf = modff(V, &Vi);
+		    V+=dv;
+		    U=0;
 
-			for (int u = 0; u < dst_width; ++u)
+		    for (int u = 0; u < dst_width; ++u)
 			{
-				Uf = modff(U, &Ui);
-				U+=du;
+			    Uf = modff(U, &Ui);
+			    U+=du;
 
-				w1 = (1 - Uf) * (1 - Vf);
-				w2 = Uf * (1 - Vf);
-				w3 = (1 - Uf) * Vf;
-				w4 = Uf * Vf;
-				psrc = &src_data[(int) (Vi * src_pitch) + (int) (Ui * bytes_per_pixel)];
-
-				*pdst++ = BYTE_SAMPLE(0);	// red
-				*pdst++ = BYTE_SAMPLE(1);	// green
-				*pdst++ = BYTE_SAMPLE(2);	// blue
+			    w1 = (1 - Uf) * (1 - Vf);
+			    w2 = Uf * (1 - Vf);
+			    w3 = (1 - Uf) * Vf;
+			    w4 = Uf * Vf;
+			    psrc = &src_data[(int) (Vi * src_pitch) + (int) (Ui * bytes_per_pixel)];
+
+			    *pdst++ = BYTE_SAMPLE(0);	// red
+			    *pdst++ = BYTE_SAMPLE(1);	// green
+			    *pdst++ = BYTE_SAMPLE(2);	// blue
 
-				psrc += 3;
+			    psrc += 3;
 			}
 		}
 
 #ifdef DEBUG_WRITE_TEXTURES_TO_PPM
-		static int s_image_sequence = 0;
-		char temp[256];
-		sprintf(temp, "image%d.ppm", s_image_sequence++);
-		FILE* f = fopen(temp, "wb");
-		if (f)
-		{
-			fprintf(f, "P6\n# test code\n%d %d\n255\n", dst_width, dst_height);
-			fwrite(rescaled, dst_width * dst_height * 3, 1, f);
-			fclose(f);
+	    static int s_image_sequence = 0;
+	    char temp[256];
+	    sprintf(temp, "image%d.ppm", s_image_sequence++);
+	    FILE* f = fopen(temp, "wb");
+	    if (f)
+		{
+		    fprintf(f, "P6\n# test code\n%d %d\n255\n", dst_width, dst_height);
+		    fwrite(rescaled, dst_width * dst_height * 3, 1, f);
+		    fclose(f);
 		}
 #endif
 	}
-	else
+    else
 	{
-		assert(bytes_per_pixel == 4);
+	    assert(bytes_per_pixel == 4);
 
-		for (int v = 0; v < dst_height; ++v)
+	    for (int v = 0; v < dst_height; ++v)
 		{
-			Vf = modff(V, &Vi);
-			V+=dv;
-			U=0;
+		    Vf = modff(V, &Vi);
+		    V+=dv;
+		    U=0;
 
-			for (int u = 0; u < dst_width; ++u)
+		    for (int u = 0; u < dst_width; ++u)
 			{
-				Uf = modff(U, &Ui);
-				U+=du;
+			    Uf = modff(U, &Ui);
+			    U+=du;
 
-				w1 = (1 - Uf) * (1 - Vf);
-				w2 = Uf * (1 - Vf);
-				w3 = (1 - Uf) * Vf;
-				w4 = Uf * Vf;
-				psrc = &src_data[(int) (Vi * src_pitch) + (int) (Ui * bytes_per_pixel)];
-
-				*pdst++ = BYTE_SAMPLE(0);	// red
-				*pdst++ = BYTE_SAMPLE(1);	// green
-				*pdst++ = BYTE_SAMPLE(2);	// blue
-				*pdst++ = BYTE_SAMPLE(3);	// alpha
+			    w1 = (1 - Uf) * (1 - Vf);
+			    w2 = Uf * (1 - Vf);
+			    w3 = (1 - Uf) * Vf;
+			    w4 = Uf * Vf;
+			    psrc = &src_data[(int) (Vi * src_pitch) + (int) (Ui * bytes_per_pixel)];
+
+			    *pdst++ = BYTE_SAMPLE(0);	// red
+			    *pdst++ = BYTE_SAMPLE(1);	// green
+			    *pdst++ = BYTE_SAMPLE(2);	// blue
+			    *pdst++ = BYTE_SAMPLE(3);	// alpha
 
-				psrc += 4;
+			    psrc += 4;
 			}
 		}
 	}
 
-	glTexImage2D(GL_TEXTURE_2D, 0, internal_format, dst_width, dst_height, 0, \
input_format, GL_UNSIGNED_BYTE, rescaled); +    glTexImage2D(GL_TEXTURE_2D, 0, \
internal_format, dst_width, dst_height, 0, input_format, GL_UNSIGNED_BYTE, rescaled); \
  #if GENERATE_MIPMAPS
-	// Build mipmaps.
-	image::image_base	im(rescaled, dst_width, dst_height, dst_width * bytes_per_pixel);
-	generate_mipmaps(internal_format, input_format, bytes_per_pixel, &im);
+    // Build mipmaps.
+    image::image_base	im(rescaled, dst_width, dst_height, dst_width * \
bytes_per_pixel); +    generate_mipmaps(internal_format, input_format, \
bytes_per_pixel, &im);  #endif // GENERATE_MIPMAPS
 
-	delete [] rescaled;
+    delete [] rescaled;
 }
 
 
@@ -951,9 +938,9 @@
 // Make a placeholder bitmap_info.  Must be filled in later before
 // using.
 {
-	m_texture_id = 0;
-	m_original_width = 0;
-	m_original_height = 0;
+    m_texture_id = 0;
+    m_original_width = 0;
+    m_original_height = 0;
 }
 
 
@@ -963,43 +950,43 @@
 //
 // !! Munges *data in order to create mipmaps !!
 {
-	assert(width > 0);
-	assert(height > 0);
-	assert(data);
+    assert(width > 0);
+    assert(height > 0);
+    assert(data);
 
-	m_texture_id = 0;
+    m_texture_id = 0;
 	
-	// Create the texture.
+    // Create the texture.
 
-	glEnable(GL_TEXTURE_2D);
-	glGenTextures(1, (GLuint*)&m_texture_id);
-	glBindTexture(GL_TEXTURE_2D, m_texture_id);
-
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);	// GL_NEAREST ?
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
-
-	m_original_width = width;
-	m_original_height = height;
-
-	#ifndef NDEBUG
-	// You must use power-of-two dimensions!!
-	int	w = 1; while (w < width) { w <<= 1; }
-	int	h = 1; while (h < height) { h <<= 1; }
-	assert(w == width);
-	assert(h == height);
-	#endif // not NDEBUG
-
-	glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, \
                GL_UNSIGNED_BYTE, data);
-
-	// Build mips.
-	int	level = 1;
-	while (width > 1 || height > 1)
-	{
-		render_handler_ogl::make_next_miplevel(&width, &height, data);
-		glTexImage2D(GL_TEXTURE_2D, level, GL_ALPHA, width, height, 0, GL_ALPHA, \
                GL_UNSIGNED_BYTE, data);
-		level++;
+    glEnable(GL_TEXTURE_2D);
+    glGenTextures(1, (GLuint*)&m_texture_id);
+    glBindTexture(GL_TEXTURE_2D, m_texture_id);
+
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);	// GL_NEAREST \
? +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, \
GL_LINEAR_MIPMAP_LINEAR); +
+    m_original_width = width;
+    m_original_height = height;
+
+#ifndef NDEBUG
+    // You must use power-of-two dimensions!!
+    int	w = 1; while (w < width) { w <<= 1; }
+    int	h = 1; while (h < height) { h <<= 1; }
+    assert(w == width);
+    assert(h == height);
+#endif // not NDEBUG
+
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, \
GL_UNSIGNED_BYTE, data); +
+    // Build mips.
+    int	level = 1;
+    while (width > 1 || height > 1)
+	{
+	    render_handler_ogl::make_next_miplevel(&width, &height, data);
+	    glTexImage2D(GL_TEXTURE_2D, level, GL_ALPHA, width, height, 0, GL_ALPHA, \
GL_UNSIGNED_BYTE, data); +	    level++;
 	}
 }
 
@@ -1007,76 +994,76 @@
 bitmap_info_ogl::bitmap_info_ogl(image::rgb* im)
 // NOTE: This function destroys im's data in the process of making mipmaps.
 {
-	assert(im);
+    assert(im);
 
-	// Create the texture.
+    // Create the texture.
 
-	glEnable(GL_TEXTURE_2D);
-	glGenTextures(1, (GLuint*)&m_texture_id);
-	glBindTexture(GL_TEXTURE_2D, m_texture_id);
+    glEnable(GL_TEXTURE_2D);
+    glGenTextures(1, (GLuint*)&m_texture_id);
+    glBindTexture(GL_TEXTURE_2D, m_texture_id);
 
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 #if GENERATE_MIPMAPS
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
 #else
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 #endif
 
-	m_original_width = im->m_width;
-	m_original_height = im->m_height;
+    m_original_width = im->m_width;
+    m_original_height = im->m_height;
 
-	int	w = 1; while (w < im->m_width) { w <<= 1; }
-	int	h = 1; while (h < im->m_height) { h <<= 1; }
+    int	w = 1; while (w < im->m_width) { w <<= 1; }
+    int	h = 1; while (h < im->m_height) { h <<= 1; }
 
-	if (w != im->m_width
-	    || h != im->m_height)
+    if (w != im->m_width
+	|| h != im->m_height)
 	{
 #if (RESAMPLE_METHOD == 1)
-		int	viewport_dim[2] = { 0, 0 };
-		glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &viewport_dim[0]);
-		if (w > viewport_dim[0]
-		    || h > viewport_dim[1]
-		    || im->m_width * 3 != im->m_pitch)
-		{
-			// Can't use hardware resample.  Either frame
-			// buffer isn't big enough to fit the source
-			// texture, or the source data isn't padded
-			// quite right.
-			software_resample(3, im->m_width, im->m_height, im->m_pitch, im->m_data, w, h);
+	    int	viewport_dim[2] = { 0, 0 };
+	    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &viewport_dim[0]);
+	    if (w > viewport_dim[0]
+		|| h > viewport_dim[1]
+		|| im->m_width * 3 != im->m_pitch)
+		{
+		    // Can't use hardware resample.  Either frame
+		    // buffer isn't big enough to fit the source
+		    // texture, or the source data isn't padded
+		    // quite right.
+		    software_resample(3, im->m_width, im->m_height, im->m_pitch, im->m_data, w, \
h);  }
-		else
+	    else
 		{
-			hardware_resample(3, im->m_width, im->m_height, im->m_data, w, h);
+		    hardware_resample(3, im->m_width, im->m_height, im->m_data, w, h);
 		}
 #elif (RESAMPLE_METHOD == 2)
-		{
-			// Faster/simpler software bilinear rescale.
-			software_resample(3, im->m_width, im->m_height, im->m_pitch, im->m_data, w, h);
-		}
+	    {
+		// Faster/simpler software bilinear rescale.
+		software_resample(3, im->m_width, im->m_height, im->m_pitch, im->m_data, w, h);
+	    }
 #else
-		{
-			// Fancy but slow software resampling.
-			image::rgb*	rescaled = image::create_rgb(w, h);
-			image::resample(rescaled, 0, 0, w - 1, h - 1,
-					im, 0, 0, (float) im->m_width, (float) im->m_height);
+	    {
+		// Fancy but slow software resampling.
+		image::rgb*	rescaled = image::create_rgb(w, h);
+		image::resample(rescaled, 0, 0, w - 1, h - 1,
+				im, 0, 0, (float) im->m_width, (float) im->m_height);
 
-			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, \
rescaled->m_data); +		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, \
GL_UNSIGNED_BYTE, rescaled->m_data);  #if GENERATE_MIPMAPS
-			generate_mipmaps(GL_RGB, GL_RGB, 3, rescaled);
+		generate_mipmaps(GL_RGB, GL_RGB, 3, rescaled);
 #endif // GENERATE_MIPMAPS
 
-			delete rescaled;
-		}
+		delete rescaled;
+	    }
 #endif
 	}
-	else
+    else
 	{
-		// Use original image directly.
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, \
im->m_data); +	    // Use original image directly.
+	    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, \
im->m_data);  #if GENERATE_MIPMAPS
-		generate_mipmaps(GL_RGB, GL_RGB, 3, im);
+	    generate_mipmaps(GL_RGB, GL_RGB, 3, im);
 #endif // GENERATE_MIPMAPS
 	}
 }
@@ -1086,76 +1073,76 @@
 // Version of the constructor that takes an image with alpha.
 // NOTE: This function destroys im's data in the process of making mipmaps.
 {
-	assert(im);
+    assert(im);
 
-	// Create the texture.
+    // Create the texture.
 
-	glEnable(GL_TEXTURE_2D);
-	glGenTextures(1, (GLuint*)&m_texture_id);
-	glBindTexture(GL_TEXTURE_2D, m_texture_id);
+    glEnable(GL_TEXTURE_2D);
+    glGenTextures(1, (GLuint*)&m_texture_id);
+    glBindTexture(GL_TEXTURE_2D, m_texture_id);
 
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);	// GL_NEAREST ?
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);	// GL_NEAREST \
?  #if GENERATE_MIPMAPS
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
 #else
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 #endif
 
-	m_original_width = im->m_width;
-	m_original_height = im->m_height;
+    m_original_width = im->m_width;
+    m_original_height = im->m_height;
 
-	int	w = 1; while (w < im->m_width) { w <<= 1; }
-	int	h = 1; while (h < im->m_height) { h <<= 1; }
+    int	w = 1; while (w < im->m_width) { w <<= 1; }
+    int	h = 1; while (h < im->m_height) { h <<= 1; }
 
-	if (w != im->m_width
-	    || h != im->m_height)
+    if (w != im->m_width
+	|| h != im->m_height)
 	{
 #if (RESAMPLE_METHOD == 1)
-		int	viewport_dim[2] = { 0, 0 };
-		glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &viewport_dim[0]);
-		if (w > viewport_dim[0]
-		    || h > viewport_dim[1]
-		    || im->m_width * 4 != im->m_pitch)
-		{
-			// Can't use hardware resample.  Either frame
-			// buffer isn't big enough to fit the source
-			// texture, or the source data isn't padded
-			// quite right.
-			software_resample(4, im->m_width, im->m_height, im->m_pitch, im->m_data, w, h);
+	    int	viewport_dim[2] = { 0, 0 };
+	    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &viewport_dim[0]);
+	    if (w > viewport_dim[0]
+		|| h > viewport_dim[1]
+		|| im->m_width * 4 != im->m_pitch)
+		{
+		    // Can't use hardware resample.  Either frame
+		    // buffer isn't big enough to fit the source
+		    // texture, or the source data isn't padded
+		    // quite right.
+		    software_resample(4, im->m_width, im->m_height, im->m_pitch, im->m_data, w, \
h);  }
-		else
+	    else
 		{
-			hardware_resample(4, im->m_width, im->m_height, im->m_data, w, h);
+		    hardware_resample(4, im->m_width, im->m_height, im->m_data, w, h);
 		}
 #elif (RESAMPLE_METHOD == 2)
-		{
-			// Faster/simpler software bilinear rescale.
-			software_resample(4, im->m_width, im->m_height, im->m_pitch, im->m_data, w, h);
-		}
+	    {
+		// Faster/simpler software bilinear rescale.
+		software_resample(4, im->m_width, im->m_height, im->m_pitch, im->m_data, w, h);
+	    }
 #else
-		{
-			// Fancy but slow software resampling.
-			image::rgba*	rescaled = image::create_rgba(w, h);
-			image::resample(rescaled, 0, 0, w - 1, h - 1,
-					im, 0, 0, (float) im->m_width, (float) im->m_height);
+	    {
+		// Fancy but slow software resampling.
+		image::rgba*	rescaled = image::create_rgba(w, h);
+		image::resample(rescaled, 0, 0, w - 1, h - 1,
+				im, 0, 0, (float) im->m_width, (float) im->m_height);
 
-			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, \
rescaled->m_data); +		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, \
GL_UNSIGNED_BYTE, rescaled->m_data);  #if GENERATE_MIPMAPS
-			generate_mipmaps(GL_RGBA, GL_RGBA, 4, rescaled);
+		generate_mipmaps(GL_RGBA, GL_RGBA, 4, rescaled);
 #endif // GENERATE_MIPMAPS
 
-			delete rescaled;
-		}
+		delete rescaled;
+	    }
 #endif
 	}
-	else
+    else
 	{
-		// Use original image directly.
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, \
im->m_data); +	    // Use original image directly.
+	    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, \
im->m_data);  #if GENERATE_MIPMAPS
-		generate_mipmaps(GL_RGBA, GL_RGBA, 4, im);
+	    generate_mipmaps(GL_RGBA, GL_RGBA, 4, im);
 #endif // GENERATE_MIPMAPS
 	}
 }
@@ -1164,7 +1151,7 @@
 gnash::render_handler*	gnash::create_render_handler_ogl()
 // Factory.
 {
-	return new render_handler_ogl;
+    return new render_handler_ogl;
 }
 
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic