Backslash ${prefix} for kde3 too...
[gnash.git] / gui / sdl / sdl_ogl_glue.cpp
blob2045ae6fcb426e85acb45a8c6e527877a1625918
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
3 // Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "sdl_ogl_glue.h"
20 #include "Renderer_ogl.h"
21 #include "tu_opengl_includes.h"
22 #include "SDL.h"
24 #include "log.h"
26 #define OVERSIZE 1.0f
28 using namespace std;
31 namespace gnash
34 SdlOglGlue::SdlOglGlue()
35 #ifdef FIX_I810_LOD_BIAS
36 : _tex_lod_bias(-1.2f)
37 #endif
39 // GNASH_REPORT_FUNCTION;
42 SdlOglGlue::~SdlOglGlue()
44 // GNASH_REPORT_FUNCTION;
48 bool SdlOglGlue::init(int /*argc*/, char ** /*argv*/ [])
50 // GNASH_REPORT_FUNCTION;
51 #ifdef FIX_I810_LOD_BIAS
52 int c = getopt (argc, *argv, "m:");
53 if (c == 'm') {
54 _tex_lod_bias = (float) strtof(optarg, NULL);
56 #endif
58 return true;
62 Renderer*
63 SdlOglGlue::createRenderHandler(int depth)
65 // GNASH_REPORT_FUNCTION;
67 _bpp = depth;
69 Renderer* renderer = create_Renderer_ogl();
71 #ifdef FIX_I810_LOD_BIAS
72 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, _tex_lod_bias);
73 #endif
75 return renderer;
78 /// Not implemented, Fixme
79 void
80 SdlOglGlue::setInvalidatedRegions(const InvalidatedRanges& /*ranges*/)
84 bool
85 SdlOglGlue::prepDrawingArea(int width, int height, boost::uint32_t sdl_flags)
87 if (_bpp == 16) {
88 // 16-bit color, surface creation is likely to succeed.
89 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
90 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
91 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
92 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 15);
93 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
94 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
95 } else {
96 assert(_bpp == 32);
98 // 32-bit color etc, for getting dest alpha,
99 // for MULTIPASS_ANTIALIASING (see
100 // Renderer_ogl.cpp).
101 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
102 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
103 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
104 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
105 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
106 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
107 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
110 SDL_SetVideoMode(width, height, _bpp, sdl_flags | SDL_OPENGL);
112 // Turn on alpha blending.
113 glEnable(GL_BLEND);
114 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
116 // Turn on line smoothing. Antialiased lines can be used to
117 // smooth the outsides of shapes.
118 glEnable(GL_LINE_SMOOTH);
119 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // GL_NICEST, GL_FASTEST, GL_DONT_CARE
120 glMatrixMode(GL_PROJECTION);
123 glOrtho(-OVERSIZE, OVERSIZE, OVERSIZE, -OVERSIZE, -1, 1);
124 glMatrixMode(GL_MODELVIEW);
125 glLoadIdentity();
127 // We don't need lighting effects
128 glDisable(GL_LIGHTING);
129 glPushAttrib (GL_ALL_ATTRIB_BITS);
131 # ifdef FIX_I810_LOD_BIAS
132 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, _tex_lod_bias);
133 # endif
135 return true;
138 void
139 SdlOglGlue::render()
141 // GNASH_REPORT_FUNCTION;
142 SDL_GL_SwapBuffers();
147 } // namespace gnash