gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog gui/Makefile.am gui/sdl.cpp gui...


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog gui/Makefile.am gui/sdl.cpp gui...
Date: Fri, 13 Oct 2006 16:46:23 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     06/10/13 16:46:23

Modified files:
        .              : ChangeLog 
        gui            : Makefile.am sdl.cpp sdlsup.h 
Added files:
        gui            : sdl_cairo_glue.cpp sdl_cairo_glue.h sdl_glue.h 
                         sdl_ogl_glue.cpp sdl_ogl_glue.h 

Log message:
        Add OpenGL and Cairo glues for SDL. Clean up sdl.cpp.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1200&r2=1.1201
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Makefile.am?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl.cpp?cvsroot=gnash&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdlsup.h?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl_cairo_glue.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl_cairo_glue.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl_glue.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl_ogl_glue.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl_ogl_glue.h?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1200
retrieving revision 1.1201
diff -u -b -r1.1200 -r1.1201
--- ChangeLog   13 Oct 2006 16:38:55 -0000      1.1200
+++ ChangeLog   13 Oct 2006 16:46:23 -0000      1.1201
@@ -1,3 +1,8 @@
+2006-10-13 Bastiaan Jacques <address@hidden>
+
+       * gui/{sdl_*, Makefile.am}: Add OpenGL and Cairo glues for SDL.
+       Clean up sdl.cpp.
+
 2006-10-13 Hannes Mayr <address@hidden>
        * gui/gtk.cpp, gui/gtksup.h, gui/gtk_glue.h, gui/gtk_glue_agg.cpp,
     gtk_glue_agg.h, Makefile.am: Added support for GTK with AGG renderer.

Index: gui/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/gui/Makefile.am,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- gui/Makefile.am     13 Oct 2006 16:38:55 -0000      1.32
+++ gui/Makefile.am     13 Oct 2006 16:46:23 -0000      1.33
@@ -74,6 +74,9 @@
   INCLUDES += $(GLEXT_CFLAGS) 
   GTK_OPENGL_SRCS = gtk_glue_gtkglext.cpp gtk_glue_gtkglext.h
 endif # USE_GUI_GTK
+if USE_GUI_SDL
+  SDL_OPENGL_SRCS = sdl_ogl_glue.cpp sdl_ogl_glue.h
+endif # USE_GUI_SDL
 if USE_GUI_KDE
   KDE_OPENGL_SRCS = kde_glue_opengl.cpp kde_glue_opengl.h
   AM_LDFLAGS += \
@@ -84,6 +87,7 @@
 else # ! USE_RENDERER_OPENGL
  GTK_OPENGL_SRCS =
  KDE_OPENGL_SRCS =
+ SDL_OPENGL_SRCS =
 endif # ! USE_RENDERER_OPENGL
 
 if USE_RENDERER_CAIRO
@@ -91,9 +95,11 @@
  AM_LDFLAGS += $(CAIRO_LIBS) 
  GTK_CAIRO_SRCS = gtk_glue_cairo.cpp gtk_glue_cairo.h
  KDE_CAIRO_SRCS = #kde_glue_cairo.cpp kde_glue_cairo.h
+ SDL_CAIRO_SRCS = sdl_cairo_glue.cpp sdl_cairo_glue.h
 else
  GTK_CAIRO_SRCS =
  KDE_CAIRO_SRCS =
+ SDL_CAIRO_SRCS =
 endif
 
 if USE_RENDERER_AGG
@@ -113,7 +119,7 @@
 endif
 
 if USE_GUI_SDL
- SDL_SRCS = sdl.cpp sdlsup.h # glow for SDL widgets
+ SDL_SRCS = sdl.cpp sdlsup.h sdl_glue.h $(SDL_CAIRO_SRCS) $(SDL_OPENGL_SRCS)
 else
  SDL_SRCS =
 endif

Index: gui/sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/sdl.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- gui/sdl.cpp 13 Oct 2006 15:56:34 -0000      1.37
+++ gui/sdl.cpp 13 Oct 2006 16:46:23 -0000      1.38
@@ -35,7 +35,11 @@
 // 
 //
 
-/* $Id: sdl.cpp,v 1.37 2006/10/13 15:56:34 strk Exp $ */
+/* $Id: sdl.cpp,v 1.38 2006/10/13 16:46:23 bjacques Exp $ */
+
+// XXXbjacques: Screw up the indentation in this file, and you're dead. And by
+//              screw up, I mean not adhering the indentation used throughout
+//              the file in your patch.
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -44,9 +48,9 @@
 #include <cstdio>
 
 #if defined(_WIN32) || defined(WIN32)
-       #define basename(x) x
        #include "getopt_win32.h"
-#else
+#if 0
+// I don't understand the point of any of this.
        #include <unistd.h>
 
 #ifndef __THROW
@@ -62,6 +66,7 @@
 
        extern int getopt(int, char *const *, const char *) __THROW;
        #include <libgen.h> //For POSIX basename().
+#endif
 
 #endif // Win32
 
@@ -69,14 +74,6 @@
 #include "log.h"
 #include "sdlsup.h"
 
-#ifdef RENDERER_CAIRO
-       #include "render_handler_cairo.h"
-#endif // RENDERER_CAIRO
-
-#ifdef RENDERER_OPENGL
-       #include "tu_opengl_includes.h"
-#endif // RENDERER_OPENGL
-
 using namespace std;
 
 namespace gnash 
@@ -87,20 +84,11 @@
    _timeout(0),
    _core_trap(true)
 {
-
 }
 
 SDLGui::~SDLGui()
 {
     GNASH_REPORT_FUNCTION;
-
-#ifdef RENDERER_CAIRO
-    cairo_surface_destroy(_cairo_surface);
-    cairo_destroy (_cairo_handle);
-    SDL_FreeSurface(_sdl_surface);
-    SDL_FreeSurface(_screen);
-    free(_render_image);
-#endif
 }
 
 bool
@@ -209,15 +197,8 @@
     GNASH_REPORT_FUNCTION;
 
        int c;
-       while ((c = getopt (argc, *argv, "m:c")) != -1)
-       {
-               switch (c)
-               {
-#ifdef FIX_I810_LOD_BIAS
-                       case 'm':
-                               _tex_lod_bias = (float) atof(optarg);
-                               break;
-#endif
+    while ((c = getopt (argc, *argv, "m:c")) != -1) {
+      switch (c) {
                        case 'c':
                                disableCoreTrap();
                }
@@ -241,69 +222,25 @@
 
     SDL_EnableKeyRepeat(250, 33);
 
-#ifdef RENDERER_CAIRO
-    _renderer = renderer::cairo::create_handler();
-
-#elif defined(RENDERER_OPENGL)
+    // XXX instantiate _glue object first
 
-    _renderer = create_render_handler_ogl();
+    _glue.init(argc, argv);
 
-    if (_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(_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);
-    }
-#endif // RENDERER_OPENGL
-#if 0
-    // So this is currently unused. We may want to do so.
-    _name = basename(*argv[0]);
-#endif
+    _renderer = _glue.createRenderHandler();
 
     return false;
 }
 
-bool
-SDLGui::createWindow(const char *title, int width, int height)
-{
-   bool ret;
-
-   ret = createWindow(width, height);
-
-    // Set the window title
-    SDL_WM_SetCaption( title, title);
-    return ret;
-}
 
 bool
-SDLGui::createWindow( int width, int height)
+SDLGui::createWindow(const char *title, int width, int height)
 {
     GNASH_REPORT_FUNCTION;
     _width = width;
     _height = height;
 
-    uint32_t sdl_flags;
-#ifdef RENDERER_CAIRO
-    sdl_flags = SDL_SWSURFACE;
-#elif defined(RENDERER_OPENGL)
-    sdl_flags = SDL_OPENGL;
-#endif
+    uint32_t sdl_flags = 0;
+
     if (!_core_trap) {
       sdl_flags |= SDL_INIT_NOPARACHUTE;
     }
@@ -312,54 +249,12 @@
       sdl_flags |= SDL_NOFRAME;
     }
 
-    _screen = SDL_SetVideoMode(_width, _height, _depth, sdl_flags);
-
-    if (!_screen) {
-        fprintf(stderr, "SDL_SetVideoMode() failed.\n");
-        exit(1);
-    }
-
-#ifdef RENDERER_CAIRO
-    int stride=width * 4;
-
-    _render_image = (unsigned char *)calloc(stride*height, 1);
-
-    _cairo_surface =
-      cairo_image_surface_create_for_data (_render_image, CAIRO_FORMAT_ARGB32,
-                                           _width, _height, stride);
-
-    _cairo_handle = cairo_create(_cairo_surface);
-
-    renderer::cairo::set_handle(_cairo_handle);
-
-#elif defined (RENDERER_OPENGL)
-    // 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);
-
-#define OVERSIZE 1.0f
-    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);         
+    _glue.prepDrawingArea(_width, _height, _depth, sdl_flags);
 
-#  ifdef FIX_I810_LOD_BIAS
-    glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 
_tex_lod_bias);
-#  endif
-#endif
     set_render_handler(_renderer);
 
+    SDL_WM_SetCaption( title, title);
+
     return false;
 }
 
@@ -374,24 +269,7 @@
 {
     GNASH_REPORT_FUNCTION;
 
-#ifdef RENDERER_CAIRO
-    uint32_t rmask, gmask, bmask, amask;
-
-    rmask = 0x00ff0000;
-    gmask = 0x0000ff00;
-    bmask = 0x000000ff;
-    amask = 0xff000000;
-
-    int stride = _width * 4;
-
-    _sdl_surface = SDL_CreateRGBSurfaceFrom((void *) _render_image, _width, 
_height,
-                                           _depth, stride, rmask, gmask, 
bmask, amask);
-    assert(_sdl_surface);
-    SDL_BlitSurface(_sdl_surface, NULL, _screen, NULL);
-    SDL_UpdateRect (_screen, 0, 0, 0, 0);
-#elif defined(RENDERER_OPENGL)
-    SDL_GL_SwapBuffers();
-#endif
+    _glue.render();
 }
 
 void
@@ -481,4 +359,3 @@
 
 } // namespace gnash
 
-

Index: gui/sdlsup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/sdlsup.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- gui/sdlsup.h        13 Oct 2006 15:56:34 -0000      1.16
+++ gui/sdlsup.h        13 Oct 2006 16:46:23 -0000      1.17
@@ -48,6 +48,12 @@
 #include "SDL.h"
 #include "SDL_thread.h"
 
+#ifdef RENDERER_CAIRO
+#include "sdl_cairo_glue.h"
+#elif defined(RENDERER_OPENGL)
+#include "sdl_ogl_glue.h"
+#endif
+
 
 #ifdef RENDERER_CAIRO
 # include <cairo.h>
@@ -62,7 +68,6 @@
     SDLGui(unsigned long xid, float scale, bool loop, unsigned int depth);
     virtual ~SDLGui();
     virtual bool init(int argc, char **argv[]);
-    virtual bool createWindow( int width, int height);
     virtual bool createWindow(const char *title, int width, int height);
     virtual bool run();
     virtual bool createMenu();
@@ -76,7 +81,7 @@
 
 private:
     unsigned int    _timeout;
-    SDL_Surface     *_screen;
+    bool               _core_trap;
 
     /// Handle VIDEORESIZE event
     void resize_event();
@@ -85,16 +90,14 @@
     void expose_event();
 
 #ifdef RENDERER_CAIRO
-    cairo_surface_t *_cairo_surface;
-    cairo_t         *_cairo_handle;
-    SDL_Surface     *_sdl_surface;
-    unsigned char   *_render_image;
-
-#endif
-    bool _core_trap;
-#ifdef FIX_I810_LOD_BIAS
+    SdlCairoGlue       _glue;
+#elif defined(RENDERER_OPENGL)
+    SdlOglGlue         _glue;
+# ifdef FIX_I810_LOD_BIAS
     float _tex_lod_bias;
+# endif
 #endif
+
 };
  
 // void xt_event_handler(Widget xtwidget, gpointer instance,

Index: gui/sdl_cairo_glue.cpp
===================================================================
RCS file: gui/sdl_cairo_glue.cpp
diff -N gui/sdl_cairo_glue.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gui/sdl_cairo_glue.cpp      13 Oct 2006 16:46:23 -0000      1.1
@@ -0,0 +1,137 @@
+//
+//   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.
+//
+// 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 with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// 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.
+//
+//
+
+#include "sdl_cairo_glue.h"
+#include "log.h"
+#include "render_handler_cairo.h"
+
+using namespace std;
+
+
+namespace gnash
+{
+
+SdlCairoGlue::SdlCairoGlue()
+#ifdef FIX_I810_LOD_BIAS
+  : _tex_lod_bias(-1.2f)
+#endif
+{
+//    GNASH_REPORT_FUNCTION;
+}
+
+SdlCairoGlue::~SdlCairoGlue()
+{
+//    GNASH_REPORT_FUNCTION;
+    cairo_surface_destroy(_cairo_surface);
+    cairo_destroy (_cairo_handle);
+    SDL_FreeSurface(_sdl_surface);
+    SDL_FreeSurface(_screen);
+    delete [] _render_image;
+}
+
+bool
+SdlCairoGlue::init(int argc, char** argv[])
+{
+//    GNASH_REPORT_FUNCTION;
+#ifdef FIX_I810_LOD_BIAS
+    int c = getopt (argc, *argv, "m:");
+    if (c == 'm') {
+      _tex_lod_bias = (float) atof(optarg);
+    }
+#endif
+
+    return true;
+}
+
+
+render_handler*
+SdlCairoGlue::createRenderHandler()
+{
+//    GNASH_REPORT_FUNCTION;
+
+    return renderer::cairo::create_handler();
+
+}
+
+
+bool
+SdlCairoGlue::prepDrawingArea(int width, int height, int depth, uint32_t 
sdl_flags)
+{
+    _screen = SDL_SetVideoMode(width, height, depth, sdl_flags | 
SDL_SWSURFACE);
+
+    if (!_screen) {
+        fprintf(stderr, "SDL_SetVideoMode() failed.\n");
+        exit(1);
+    }
+    
+    int stride=width * 4;
+
+    _render_image = new unsigned char[stride * height];
+    // XXX is there a need for zeroing out _render_image?
+
+    _cairo_surface =
+      cairo_image_surface_create_for_data (_render_image, CAIRO_FORMAT_ARGB32,
+                                           width, height, stride);
+
+    _cairo_handle = cairo_create(_cairo_surface);
+
+    renderer::cairo::set_handle(_cairo_handle);
+
+    uint32_t rmask, gmask, bmask, amask;
+
+    rmask = 0x00ff0000;
+    gmask = 0x0000ff00;
+    bmask = 0x000000ff;
+    amask = 0xff000000;
+
+    _sdl_surface = SDL_CreateRGBSurfaceFrom((void *) _render_image, width, 
height,
+                                           depth, stride, rmask, gmask, bmask, 
amask);
+    assert(_sdl_surface);
+
+    return true;
+}
+
+void
+SdlCairoGlue::render()
+{
+//    GNASH_REPORT_FUNCTION;
+    SDL_BlitSurface(_sdl_surface, NULL, _screen, NULL);
+    SDL_UpdateRect (_screen, 0, 0, 0, 0);
+}
+
+
+} // namespace gnash

Index: gui/sdl_cairo_glue.h
===================================================================
RCS file: gui/sdl_cairo_glue.h
diff -N gui/sdl_cairo_glue.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gui/sdl_cairo_glue.h        13 Oct 2006 16:46:23 -0000      1.1
@@ -0,0 +1,69 @@
+//
+//   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.
+//
+// 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 with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// 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.
+//
+//
+
+#include "sdl_glue.h"
+#include <cairo.h>
+#include <SDL.h>
+
+
+
+using namespace std;
+
+
+namespace gnash
+{
+
+class SdlCairoGlue : public SdlGlue
+{
+  public:
+    SdlCairoGlue();
+    virtual ~SdlCairoGlue();
+
+    bool init(int argc, char **argv[]);
+    render_handler* createRenderHandler();
+    bool prepDrawingArea(int width, int height, int depth, uint32_t sdl_flags);
+    uint32_t maskFlags(uint32_t sdl_flags);
+    void render();
+  private:
+    cairo_surface_t *_cairo_surface;
+    cairo_t         *_cairo_handle;
+    SDL_Surface     *_sdl_surface;
+    unsigned char   *_render_image;
+    SDL_Surface     *_screen;
+};
+
+}

Index: gui/sdl_glue.h
===================================================================
RCS file: gui/sdl_glue.h
diff -N gui/sdl_glue.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gui/sdl_glue.h      13 Oct 2006 16:46:23 -0000      1.1
@@ -0,0 +1,54 @@
+//
+//   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.
+//
+// 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 with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// 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.
+//
+//
+
+#include "gnash.h"
+
+namespace gnash
+{
+
+class SdlGlue
+{
+  public:
+    virtual ~SdlGlue() { }
+    virtual bool init(int argc, char **argv[]) = 0;
+
+    virtual bool prepDrawingArea(int width, int height, int depth, uint32_t 
sdl_flags) = 0;
+    virtual render_handler* createRenderHandler() = 0;
+    virtual void render() = 0;
+};
+
+} // namespace gnash

Index: gui/sdl_ogl_glue.cpp
===================================================================
RCS file: gui/sdl_ogl_glue.cpp
diff -N gui/sdl_ogl_glue.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gui/sdl_ogl_glue.cpp        13 Oct 2006 16:46:23 -0000      1.1
@@ -0,0 +1,187 @@
+//
+//   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.
+//
+// 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 with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// 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.
+//
+//
+
+#include "sdl_ogl_glue.h"
+#include "tu_opengl_includes.h"
+#include "SDL.h"
+
+#include "log.h"
+
+
+#if defined(_WIN32) || defined(WIN32)
+#      define basename(x) x
+#      include "getopt_win32.h"
+#      ifndef _INC_WINDOWS
+
+#              define WINAPI   __stdcall
+#              define APIENTRY WINAPI
+#              define CALLBACK __stdcall
+#              define DECLSPEC_IMPORT __declspec(dllimport)
+
+#              if !defined(_GDI32_)
+#                      define WINGDIAPI DECLSPEC_IMPORT
+#              else
+#                      define WINGDIAPI
+#              endif
+
+#      else
+#              define WIN32_LEAN_AND_MEAN
+#              include <windows.h>
+#      endif
+#endif
+
+#if defined(__sgi) || defined(SGI) || defined(__sgi__)
+       #define basename(x) x
+#endif
+
+#define OVERSIZE 1.0f
+
+using namespace std;
+
+
+namespace gnash
+{
+
+SdlOglGlue::SdlOglGlue()
+#ifdef FIX_I810_LOD_BIAS
+  : _tex_lod_bias(-1.2f)
+#endif
+{
+//    GNASH_REPORT_FUNCTION;
+}
+
+SdlOglGlue::~SdlOglGlue()
+{
+//    GNASH_REPORT_FUNCTION;
+
+}
+
+bool
+SdlOglGlue::init(int argc, char** argv[])
+{
+//    GNASH_REPORT_FUNCTION;
+#ifdef FIX_I810_LOD_BIAS
+    int c = getopt (argc, *argv, "m:");
+    if (c == 'm') {
+      _tex_lod_bias = (float) atof(optarg);
+    }
+#endif
+
+    return true;
+}
+
+
+render_handler*
+SdlOglGlue::createRenderHandler()
+{
+//    GNASH_REPORT_FUNCTION;
+
+// ogl initialisation?
+
+    render_handler* renderer = create_render_handler_ogl();
+
+#ifdef FIX_I810_LOD_BIAS
+    glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 
_tex_lod_bias);
+#endif
+
+    return renderer;
+}
+
+bool
+SdlOglGlue::prepDrawingArea(int width, int height, int depth, uint32_t 
sdl_flags)
+{
+    if (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(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);
+    }
+
+    SDL_SetVideoMode(width, height, depth, sdl_flags | SDL_OPENGL);
+
+     // 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);
+    glPushAttrib (GL_ALL_ATTRIB_BITS);         
+
+#  ifdef FIX_I810_LOD_BIAS
+    glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 
_tex_lod_bias);
+#  endif
+
+    return true;
+}
+
+void
+SdlOglGlue::render()
+{
+//    GNASH_REPORT_FUNCTION;
+    SDL_GL_SwapBuffers();
+}
+
+
+
+} // namespace gnash

Index: gui/sdl_ogl_glue.h
===================================================================
RCS file: gui/sdl_ogl_glue.h
diff -N gui/sdl_ogl_glue.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gui/sdl_ogl_glue.h  13 Oct 2006 16:46:23 -0000      1.1
@@ -0,0 +1,65 @@
+//
+//   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.
+//
+// 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 with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// 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.
+//
+//
+
+#include "sdl_glue.h"
+
+
+
+
+using namespace std;
+
+
+namespace gnash
+{
+
+class SdlOglGlue : public SdlGlue
+{
+  public:
+    SdlOglGlue();
+    virtual ~SdlOglGlue();
+
+    bool init(int argc, char **argv[]);
+    render_handler* createRenderHandler();
+    bool prepDrawingArea(int width, int height, int depth, uint32_t sdl_flags);
+    void render();
+  private:
+#ifdef FIX_I810_LOD_BIAS
+    float _tex_lod_bias;
+#endif
+};
+
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]