2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 Free Software Foundation, Inc
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 "opengl/Renderer_ogl.h"
20 #include "tu_opengl_includes.h"
22 #include "sdl_ogl_glue.h"
33 SdlOglGlue::SdlOglGlue()
35 // GNASH_REPORT_FUNCTION;
38 SdlOglGlue::~SdlOglGlue()
40 // GNASH_REPORT_FUNCTION;
44 bool SdlOglGlue::init(int /*argc*/, char ** /*argv*/ [])
46 // GNASH_REPORT_FUNCTION;
52 SdlOglGlue::createRenderHandler(int depth
)
54 // GNASH_REPORT_FUNCTION;
58 Renderer
* renderer
= renderer::opengl::create_handler();
63 /// Not implemented, Fixme
65 SdlOglGlue::setInvalidatedRegions(const InvalidatedRanges
& /*ranges*/)
70 SdlOglGlue::prepDrawingArea(int width
, int height
, std::uint32_t sdl_flags
)
73 // 16-bit color, surface creation is likely to succeed.
74 SDL_GL_SetAttribute(SDL_GL_RED_SIZE
, 5);
75 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE
, 5);
76 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE
, 5);
77 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE
, 15);
78 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER
, 1);
79 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE
, 1);
83 // 32-bit color etc, for getting dest alpha,
84 // for MULTIPASS_ANTIALIASING (see
86 SDL_GL_SetAttribute(SDL_GL_RED_SIZE
, 8);
87 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE
, 8);
88 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE
, 8);
89 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE
, 8);
90 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE
, 24);
91 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER
, 1);
92 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE
, 1);
95 SDL_SetVideoMode(width
, height
, _bpp
, sdl_flags
| SDL_OPENGL
);
97 // Turn on alpha blending.
99 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
101 // Turn on line smoothing. Antialiased lines can be used to
102 // smooth the outsides of shapes.
103 glEnable(GL_LINE_SMOOTH
);
104 glHint(GL_LINE_SMOOTH_HINT
, GL_NICEST
); // GL_NICEST, GL_FASTEST, GL_DONT_CARE
105 glMatrixMode(GL_PROJECTION
);
108 glOrtho(-OVERSIZE
, OVERSIZE
, OVERSIZE
, -OVERSIZE
, -1, 1);
109 glMatrixMode(GL_MODELVIEW
);
112 // We don't need lighting effects
113 glDisable(GL_LIGHTING
);
114 glPushAttrib (GL_ALL_ATTRIB_BITS
);
122 // GNASH_REPORT_FUNCTION;
123 SDL_GL_SwapBuffers();