Resources::big_font->get_text_width(items[i]->input) + 16;
if(items[i]->kind == MN_TOGGLE)
w += 32;
+ if (items[i]->kind == MN_STRINGSELECT)
+ w += font->get_text_width(items[i]->list[items[i]->selected]) + 32;
+
if(w > menu_width)
menu_width = w;
fullscreen_size(800, 600),
window_size(800, 600),
aspect_size(0, 0), // auto detect
- magnification(1.0f),
+ magnification(0.0f),
use_fullscreen(false),
video(VideoSystem::AUTO_VIDEO),
try_vsync(true),
config_video_lisp->get("aspect_width", aspect_size.width);
config_video_lisp->get("aspect_height", aspect_size.height);
+
+ config_video_lisp->get("magnification", magnification);
}
const lisp::Lisp* config_audio_lisp = config_lisp->get_lisp("audio");
writer.write("aspect_width", aspect_size.width);
writer.write("aspect_height", aspect_size.height);
+
+ writer.write("magnification", magnification);
writer.end_list("video");
magnification->list.push_back("160%");
magnification->list.push_back("200%");
magnification->list.push_back("250%");
+ if (g_config->magnification != 0.0f) //auto
+ {
+ std::ostringstream out;
+ out << (g_config->magnification*100) << "%";
+ std::string magn = out.str();
+ size_t count = 0;
+ for (std::vector<std::string>::iterator i = magnification->list.begin(); i != magnification->list.end(); ++i)
+ {
+ if (*i == magn)
+ {
+ magnification->selected = count;
+ magn.clear();
+ break;
+ }
+
+ ++count;
+ }
+ if (!magn.empty()) //magnification not in our list but accept anyway
+ {
+ magnification->selected = magnification->list.size();
+ magnification->list.push_back(magn);
+ }
+ }
+
SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
// lowest, so reverse them
std::sort(fullscreen_res->list.begin(), fullscreen_res->list.end(), StringUtil::numeric_less);
}
+
+ std::ostringstream out;
+ out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height;
+ std::string fllscrn_sz = 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)
+ {
+ fllscrn_sz.clear();
+ fullscreen_res->selected = cnt;
+ break;
+ }
+ ++cnt;
+ }
+ if (!fllscrn_sz.empty())
+ {
+ fullscreen_res->selected = fullscreen_res->list.size();
+ fullscreen_res->list.push_back(fllscrn_sz);
+ }
MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"));
aspect->set_help(_("Adjust the aspect ratio"));
std::ostringstream out;
out << g_config->aspect_size.width << ":" << g_config->aspect_size.height;
std::string aspect_ratio = out.str();
+ size_t cnt = 0;
for(std::vector<std::string>::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i)
{
if(*i == aspect_ratio)
{
aspect_ratio.clear();
+ aspect->selected = cnt;
break;
}
+ ++cnt;
}
if (!aspect_ratio.empty())
{
screen = SDL_GetVideoSurface();
- lightmap_width = screen->w / LIGHTMAP_DIV;
- lightmap_height = screen->h / LIGHTMAP_DIV;
+ lightmap_width = SCREEN_WIDTH / LIGHTMAP_DIV;
+ lightmap_height = SCREEN_HEIGHT / LIGHTMAP_DIV;
unsigned int width = next_po2(lightmap_width);
unsigned int height = next_po2(lightmap_height);
void
GLLightmap::start_draw(const Color &ambient_color)
{
- glViewport(0, screen->h - lightmap_height, lightmap_width, lightmap_height);
+
+ glGetFloatv(GL_VIEWPORT, old_viewport); //save viewport
+ glViewport(old_viewport[0], SCREEN_HEIGHT - lightmap_height + old_viewport[1], lightmap_width, lightmap_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
#ifdef GL_VERSION_ES_CM_1_0
{
glDisable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, lightmap->get_handle());
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, screen->h - lightmap_height, lightmap_width, lightmap_height);
-
- glViewport(0, 0, screen->w, screen->h);
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, old_viewport[0], SCREEN_HEIGHT - lightmap_height + old_viewport[1], lightmap_width, lightmap_height);
+
+ glViewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
#ifdef GL_VERSION_ES_CM_1_0
for( int i = 0; i<3; i++)
pixels[i] = 0.0f; //set to black
- float posX = request.pos.x * lightmap_width / SCREEN_WIDTH;
- float posY = screen->h - request.pos.y * lightmap_height / SCREEN_HEIGHT;
+ float posX = request.pos.x * lightmap_width / SCREEN_WIDTH + old_viewport[0];
+ float posY = SCREEN_HEIGHT + old_viewport[1] - request.pos.y * lightmap_height / SCREEN_HEIGHT;
glReadPixels((GLint) posX, (GLint) posY , 1, 1, GL_RGB, GL_FLOAT, pixels);
*(getlightrequest->color_ptr) = Color( pixels[0], pixels[1], pixels[2]);
}
int lightmap_height;
float lightmap_uv_right;
float lightmap_uv_bottom;
+ GLfloat old_viewport[4]; //holds vieport before redefining in start_draw - returned from glGet
private:
GLLightmap(const GLLightmap&);
}
Size max_size(1280, 800);
+ Size min_size(640, 480);
if (g_config->magnification == 0.0f) // Magic value that means 'minfill'
{
// This scales SCREEN_WIDTH/SCREEN_HEIGHT so that they never excede
- // max_size.width/max_size.height
+ // max_size.width/max_size.height resp. min_size.width/min_size.height
if (SCREEN_WIDTH > max_size.width || SCREEN_HEIGHT > max_size.height)
{
float scale1 = float(max_size.width)/SCREEN_WIDTH;
float scale = (scale1 < scale2) ? scale1 : scale2;
SCREEN_WIDTH = static_cast<int>(SCREEN_WIDTH * scale);
SCREEN_HEIGHT = static_cast<int>(SCREEN_HEIGHT * scale);
+ }
+ else if (SCREEN_WIDTH < min_size.width || SCREEN_HEIGHT < min_size.height)
+ {
+ float scale1 = float(min_size.width)/SCREEN_WIDTH;
+ float scale2 = float(min_size.height)/SCREEN_HEIGHT;
+ float scale = (scale1 < scale2) ? scale1 : scale2;
+ SCREEN_WIDTH = static_cast<int>(SCREEN_WIDTH * scale);
+ SCREEN_HEIGHT = static_cast<int>(SCREEN_HEIGHT * scale);
}
+
glViewport(0, 0, screen_size.width, screen_size.height);
}