#include <physfs.h>
#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"
} // namespace
-GLRenderer::GLRenderer()
- : desktop_width(-1),
- desktop_height(-1)
+GLRenderer::GLRenderer() :
+ desktop_width(-1),
+ desktop_height(-1)
{
Renderer::instance_ = this;
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;
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;
+ log_info << "GL_ARB_texture_non_power_of_two: " << GL_ARB_texture_non_power_of_two << std::endl;
+#endif
}
GLRenderer::~GLRenderer()
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
// 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();
}
{
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<float>(desktop_width) / static_cast<float>(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
// 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)