X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvideo%2Fgl%2Fgl_renderer.cpp;h=12086fc701190ce0181480eb8f015c3fe0ad0394;hb=3bdfcbe06bc5b2725f3b662924251f5ca91e3261;hp=e05f75588dcff710a333ea09df9b70c06c08c89d;hpb=73259e6cd83bae601cb8ce49b6e7a0df1d4de087;p=supertux.git diff --git a/src/video/gl/gl_renderer.cpp b/src/video/gl/gl_renderer.cpp index e05f75588..12086fc70 100644 --- a/src/video/gl/gl_renderer.cpp +++ b/src/video/gl/gl_renderer.cpp @@ -22,7 +22,7 @@ #include #include "supertux/gameconfig.hpp" -#include "supertux/main.hpp" +#include "supertux/globals.hpp" #include "video/drawing_request.hpp" #include "video/gl/gl_surface_data.hpp" #include "video/gl/gl_texture.hpp" @@ -111,9 +111,9 @@ inline void intern_draw(float left, float top, float right, float bottom, } // namespace -GLRenderer::GLRenderer() - : desktop_width(-1), - desktop_height(-1) +GLRenderer::GLRenderer() : + desktop_width(-1), + desktop_height(-1) { Renderer::instance_ = this; @@ -153,14 +153,14 @@ GLRenderer::GLRenderer() if(g_config->use_fullscreen) { flags |= SDL_FULLSCREEN; - width = g_config->fullscreen_width; - height = g_config->fullscreen_height; + width = g_config->fullscreen_size.width; + height = g_config->fullscreen_size.height; } else { // flags |= SDL_RESIZABLE; - width = g_config->window_width; - height = g_config->window_height; + width = g_config->window_size.width; + height = g_config->window_size.height; } int bpp = 0; @@ -189,6 +189,17 @@ GLRenderer::GLRenderer() texture_manager = new TextureManager(); else texture_manager->reload_textures(); + +#ifndef GL_VERSION_ES_CM_1_0 + GLenum err = glewInit(); + if (GLEW_OK != err) + { + std::ostringstream out; + out << "GLRenderer: " << glewGetErrorString(err); + throw std::runtime_error(out.str()); + } + log_info << "Using GLEW " << glewGetString(GLEW_VERSION) << std::endl; +#endif } GLRenderer::~GLRenderer() @@ -470,6 +481,7 @@ GLRenderer::do_take_screenshot() SDL_FreeSurface(shot_surf); return; } + glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels); // copy array line-by-line @@ -528,8 +540,7 @@ GLRenderer::resize(int w, int h) // unavoidable with SDL at the moment SDL_SetVideoMode(w, h, 0, SDL_OPENGL /*| SDL_RESIZABLE*/); - g_config->window_width = w; - g_config->window_height = h; + g_config->window_size = Size(w, h); apply_config(); } @@ -541,17 +552,19 @@ GLRenderer::apply_config() { std::cout << "Applying Config:" << "\n Desktop: " << desktop_width << "x" << desktop_height - << "\n Window: " << g_config->window_width << "x" << g_config->window_height - << "\n FullRes: " << g_config->fullscreen_width << "x" << g_config->fullscreen_height - << "\n Aspect: " << g_config->aspect_width << ":" << g_config->aspect_height + << "\n Window: " << g_config->window_size + << "\n FullRes: " << g_config->fullscreen_size + << "\n Aspect: " << g_config->aspect_size << "\n Magnif: " << g_config->magnification << std::endl; } float target_aspect = static_cast(desktop_width) / static_cast(desktop_height); - if (g_config->aspect_width != 0 && g_config->aspect_height != 0) - target_aspect = float(g_config->aspect_width) / float(g_config->aspect_height); + if (g_config->aspect_size != Size(0, 0)) + { + target_aspect = float(g_config->aspect_size.width) / float(g_config->aspect_size.height); + } float desktop_aspect = 4.0f / 3.0f; // random default fallback guess @@ -565,14 +578,14 @@ GLRenderer::apply_config() // Get the screen width if (g_config->use_fullscreen) { - w = g_config->fullscreen_width; - h = g_config->fullscreen_height; + w = g_config->fullscreen_size.width; + h = g_config->fullscreen_size.height; desktop_aspect = float(w) / float(h); } else { - w = g_config->window_width; - h = g_config->window_height; + w = g_config->window_size.width; + h = g_config->window_size.height; } if (target_aspect > 1.0f)