Config::Config() :
profile(1),
- fullscreen_size(800, 600),
+ fullscreen_size(0, 0),
fullscreen_refresh_rate(0),
window_size(800, 600),
aspect_size(0, 0), // auto detect
SDL_SetWindowIcon(Renderer::instance()->get_window(), icon);
SDL_FreeSurface(icon);
}
- //SDL_ShowCursor(0);
+ SDL_ShowCursor(0);
log_info << (g_config->use_fullscreen?"fullscreen ":"window ")
<< " Window: " << g_config->window_size
fullscreen_res->list.push_back(out.str());
}
}
+ fullscreen_res->list.push_back("Desktop");
std::ostringstream out;
- out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height << "@" << g_config->fullscreen_refresh_rate;
- std::string fllscrn_sz = out.str();
+ std::string fullscreen_size_str = "Desktop";
+ if (g_config->fullscreen_size != Size(0, 0))
+ {
+ out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height << "@" << g_config->fullscreen_refresh_rate;
+ fullscreen_size_str = out.str();
+ }
size_t cnt = 0;
for (std::vector<std::string>::iterator i = fullscreen_res->list.begin(); i != fullscreen_res->list.end(); ++i)
{
- if (*i == fllscrn_sz)
+ if (*i == fullscreen_size_str)
{
- fllscrn_sz.clear();
+ fullscreen_size_str.clear();
fullscreen_res->selected = cnt;
break;
}
++cnt;
}
- if (!fllscrn_sz.empty())
+ if (!fullscreen_size_str.empty())
{
fullscreen_res->selected = fullscreen_res->list.size();
- fullscreen_res->list.push_back(fllscrn_sz);
+ fullscreen_res->list.push_back(fullscreen_size_str);
}
MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"));
int width;
int height;
int refresh_rate;
- if(sscanf(item->list[item->selected].c_str(), "%dx%d@%d",
+ if (item->list[item->selected] == "Desktop")
+ {
+ g_config->fullscreen_size.width = 0;
+ g_config->fullscreen_size.height = 0;
+ g_config->fullscreen_refresh_rate = 0;
+ }
+ else if(sscanf(item->list[item->selected].c_str(), "%dx%d@%d",
&width, &height, &refresh_rate) == 3)
{
// do nothing, changes are only applied when toggling fullscreen mode
GLRenderer::GLRenderer() :
window(),
desktop_size(0, 0),
- screen_size(0, 0),
fullscreen_active(false),
last_texture(static_cast<GLuint> (-1))
{
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
- if(g_config->use_fullscreen)
- {
- apply_video_mode(g_config->fullscreen_size, true);
- }
- else
- {
- apply_video_mode(g_config->window_size, false);
- }
+ apply_video_mode();
// setup opengl state and transform
glDisable(GL_DEPTH_TEST);
// inner rectangle
Rectf irect(request.pos.x + radius,
- request.pos.y + radius,
- request.pos.x + fillrectrequest->size.x - radius,
- request.pos.y + fillrectrequest->size.y - radius);
+ request.pos.y + radius,
+ request.pos.x + fillrectrequest->size.x - radius,
+ request.pos.y + fillrectrequest->size.y - radius);
int n = 8;
int p = 0;
void
GLRenderer::apply_config()
{
- apply_video_mode(screen_size, g_config->use_fullscreen);
+ apply_video_mode();
Size target_size = g_config->use_fullscreen ?
- g_config->fullscreen_size :
+ ((g_config->fullscreen_size == Size(0, 0)) ? desktop_size : g_config->fullscreen_size) :
g_config->window_size;
float pixel_aspect_ratio = 1.0f;
Vector scale;
Size logical_size;
- calculate_viewport(min_size, max_size, screen_size,
+ calculate_viewport(min_size, max_size, target_size,
pixel_aspect_ratio,
g_config->magnification,
scale,
}
void
-GLRenderer::apply_video_mode(const Size& size, bool fullscreen)
+GLRenderer::apply_video_mode()
{
if (window)
{
- SDL_SetWindowSize(window, size.width, size.height);
-
- if (fullscreen)
+ if (!g_config->use_fullscreen)
+ {
+ SDL_SetWindowFullscreen(window, 0);
+ }
+ else
{
- SDL_DisplayMode mode;
- mode.format = SDL_PIXELFORMAT_RGB888;
- mode.w = g_config->fullscreen_size.width;
- mode.h = g_config->fullscreen_size.height;
- mode.refresh_rate = g_config->fullscreen_refresh_rate;
- mode.driverdata = 0;
-
- if (SDL_SetWindowDisplayMode(window, &mode) != 0)
+ if (g_config->fullscreen_size.width == 0 &&
+ g_config->fullscreen_size.height == 0)
{
- log_warning << "failed to set display mode: "
- << mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
- << SDL_GetError() << std::endl;
+ if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
+ {
+ log_warning << "failed to switch to desktop fullscreen mode: "
+ << SDL_GetError() << std::endl;
+ }
+ else
+ {
+ log_info << "switched to desktop fullscreen mode" << std::endl;
+ }
}
else
{
- SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
+ SDL_DisplayMode mode;
+ mode.format = SDL_PIXELFORMAT_RGB888;
+ mode.w = g_config->fullscreen_size.width;
+ mode.h = g_config->fullscreen_size.height;
+ mode.refresh_rate = g_config->fullscreen_refresh_rate;
+ mode.driverdata = 0;
+
+ if (SDL_SetWindowDisplayMode(window, &mode) != 0)
+ {
+ log_warning << "failed to set display mode: "
+ << mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
+ << SDL_GetError() << std::endl;
+ }
+ else
+ {
+ if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN) != 0)
+ {
+ log_warning << "failed to switch to fullscreen mode: "
+ << mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
+ << SDL_GetError() << std::endl;
+ }
+ else
+ {
+ log_info << "switched to fullscreen mode: "
+ << mode.w << "x" << mode.h << "@" << mode.refresh_rate << std::endl;
+ }
+ }
}
}
- else
- {
- SDL_SetWindowFullscreen(window, 0);
- }
}
else
{
int flags = SDL_WINDOW_OPENGL;
- if (fullscreen)
+ Size size;
+ if (g_config->use_fullscreen)
{
- flags |= SDL_WINDOW_FULLSCREEN;
+ if (g_config->fullscreen_size == Size(0, 0))
+ {
+ flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ size = desktop_size;
+ }
+ else
+ {
+ flags |= SDL_WINDOW_FULLSCREEN;
+ size.width = g_config->fullscreen_size.width;
+ size.height = g_config->fullscreen_size.height;
+ }
}
else
{
flags |= SDL_WINDOW_RESIZABLE;
+ size = g_config->window_size;
}
window = SDL_CreateWindow("SuperTux",
else
{
glcontext = SDL_GL_CreateContext(window);
- screen_size = size;
SCREEN_WIDTH = size.width;
SCREEN_HEIGHT = size.height;
- fullscreen_active = fullscreen;
+ fullscreen_active = g_config->use_fullscreen;
}
}
}
SDL_GLContext glcontext;
SDL_Rect viewport;
Size desktop_size;
- Size screen_size;
bool fullscreen_active;
GLuint last_texture;
void flip();
void resize(int w, int h);
void apply_config();
- void apply_video_mode(const Size& size, bool fullscreen);
+ void apply_video_mode();
Vector to_logical(int physical_x, int physical_y);
void set_gamma(float gamma);
SDL_Window* get_window() const { return window; }
int flags = SDL_WINDOW_RESIZABLE;
if(g_config->use_fullscreen)
{
- flags |= SDL_WINDOW_FULLSCREEN;
- width = g_config->fullscreen_size.width;
- height = g_config->fullscreen_size.height;
+ if (g_config->fullscreen_size == Size(0, 0))
+ {
+ flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ width = g_config->window_size.width;
+ height = g_config->window_size.height;
+ }
+ else
+ {
+ flags |= SDL_WINDOW_FULLSCREEN;
+ width = g_config->fullscreen_size.width;
+ height = g_config->fullscreen_size.height;
+ }
}
SCREEN_WIDTH = width;
}
else
{
- SDL_DisplayMode mode;
- mode.format = SDL_PIXELFORMAT_RGB888;
- mode.w = g_config->fullscreen_size.width;
- mode.h = g_config->fullscreen_size.height;
- mode.refresh_rate = g_config->fullscreen_refresh_rate;
- mode.driverdata = 0;
-
- if (SDL_SetWindowDisplayMode(window, &mode) != 0)
+ if (g_config->fullscreen_size.width == 0 &&
+ g_config->fullscreen_size.height == 0)
{
- log_warning << "failed to set display mode: "
- << mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
- << SDL_GetError() << std::endl;
+ if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
+ {
+ log_warning << "failed to switch to desktop fullscreen mode: "
+ << SDL_GetError() << std::endl;
+ }
+ else
+ {
+ log_info << "switched to desktop fullscreen mode" << std::endl;
+ }
}
else
{
- if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN) != 0)
+ SDL_DisplayMode mode;
+ mode.format = SDL_PIXELFORMAT_RGB888;
+ mode.w = g_config->fullscreen_size.width;
+ mode.h = g_config->fullscreen_size.height;
+ mode.refresh_rate = g_config->fullscreen_refresh_rate;
+ mode.driverdata = 0;
+
+ if (SDL_SetWindowDisplayMode(window, &mode) != 0)
{
- log_warning << "failed to switch to fullscreen mode: "
+ log_warning << "failed to set display mode: "
<< mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
<< SDL_GetError() << std::endl;
}
else
{
- log_info << "switched to fullscreen mode: "
- << mode.w << "x" << mode.h << "@" << mode.refresh_rate << std::endl;
+ if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN) != 0)
+ {
+ log_warning << "failed to switch to fullscreen mode: "
+ << mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
+ << SDL_GetError() << std::endl;
+ }
+ else
+ {
+ log_info << "switched to fullscreen mode: "
+ << mode.w << "x" << mode.h << "@" << mode.refresh_rate << std::endl;
+ }
}
}
}
-
}
void
SDLRenderer::apply_viewport()
{
- Size target_size = g_config->use_fullscreen ?
+ Size target_size = (g_config->use_fullscreen && g_config->fullscreen_size != Size(0, 0)) ?
g_config->fullscreen_size :
g_config->window_size;