2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
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.
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.
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"
34 SdlOglGlue::SdlOglGlue()
35 #ifdef FIX_I810_LOD_BIAS
36 : _tex_lod_bias(-1.2f
)
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:");
54 _tex_lod_bias
= (float) strtof(optarg
, NULL
);
63 SdlOglGlue::createRenderHandler(int depth
)
65 // GNASH_REPORT_FUNCTION;
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
);
78 /// Not implemented, Fixme
80 SdlOglGlue::setInvalidatedRegions(const InvalidatedRanges
& /*ranges*/)
85 SdlOglGlue::prepDrawingArea(int width
, int height
, boost::uint32_t sdl_flags
)
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);
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.
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
);
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
);
141 // GNASH_REPORT_FUNCTION;
142 SDL_GL_SwapBuffers();