Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-12 14:55:10 +0000
committerStijn Buys <ingar@osirion.org>2008-10-12 14:55:10 +0000
commitb417df720584c101f3799874a0c836a543a8d0a8 (patch)
treefb7105ed662f13753a6ab8d3efb047bad04f2316 /src/client/video.cc
parent18383a5fc596bf9546f14d7393ee66c57720b116 (diff)
user interface updates, work-in-progress
Diffstat (limited to 'src/client/video.cc')
-rw-r--r--src/client/video.cc148
1 files changed, 21 insertions, 127 deletions
diff --git a/src/client/video.cc b/src/client/video.cc
index 123bd88..7338d70 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -4,10 +4,6 @@
the terms and conditions of the GNU General Public License version 2
*/
-#include <fstream>
-#include <sstream>
-
-#include "auxiliary/functions.h"
#include "client/video.h"
#include "client/input.h"
#include "client/view.h"
@@ -38,49 +34,15 @@ int height = 0;
int width_prev = 0;
int height_prev = 0;
-int screenshot_number = 0;
-
const int width_default = 1024;
const int height_default = 768;
-//--- cvars -------------------------------------------------------
+/* -- engine variables --------------------------------------------- */
core::Cvar *r_width;
core::Cvar *r_height;
core::Cvar *r_fullscreen;
-core::Cvar *screenshotformat;
-core::Cvar *screenshotquality;
-
-void restart()
-{
- shutdown();
-
- if (!init()) {
- client()->quit(1);
- }
-
- input::reset();
-}
-
-void reset()
-{
- // setup our viewport.
- gl::viewport(0, 0, width, height );
-
- // recalculate the video aspect
- render::Camera::set_aspect(width, height);
-
- // resize user interface
- if (ui::root()) {
- ui::root()->set_size((float) width, (float) height);
- ui::root()->event_resize();
- }
-
- // reset the view
- view::reset();
-}
-
bool init()
{
con_print << "^BInitializing video..." << std::endl;
@@ -95,12 +57,6 @@ bool init()
r_fullscreen = core::Cvar::get("r_fullscreen", "0", core::Cvar::Archive);
r_fullscreen->set_info("[bool] enable or disable fullscreen video");
- screenshotformat = core::Cvar::get("screenshotformat", "jpg", core::Cvar::Archive);
- screenshotformat->set_info("[string] screenshot format: jpg png tga");
-
- screenshotquality = core::Cvar::get("screenshotquality", "85", core::Cvar::Archive);
- screenshotquality->set_info("[int] screenshot jpg quality");
-
int bpp = 0;
int flags = 0;
@@ -162,7 +118,7 @@ bool init()
} else
return false;
}
- con_print << " video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl;
+ con_print << " video mode " << width << "x" << height << "x" << bpp << "bpp " << (fullscreen ? "fullscreen " : "window") << std::endl;
#ifdef HAVE_DEBUG_MESSAGES
@@ -178,24 +134,40 @@ bool init()
#endif // HAVE_DEBUG_MESSAGES
- render::Camera::set_aspect(width, height);
+ // save r_width and r_height variables
(*r_width) = width;
(*r_height) = height;
+ // set window caption
std::string version(core::name());
version += ' ';
version.append(core::version());
SDL_WM_SetCaption(version.c_str(), 0);
- render::init();
+ // resize user interface
+ ui::root()->set_size((float) width, (float) height);
+ ui::root()->event_resize();
- video::reset();
+ // initialize renderer
+ render::Camera::resize(width, height);
+ render::init();
+ render::Camera::resize(width, height); // yes twice, bug
view::init();
return true;
}
+void restart()
+{
+ shutdown();
+ if (!init()) {
+ client()->quit(1);
+ }
+
+ input::reset();
+}
+
void frame(float seconds)
{
// detect fullscreen/windowed mode switch
@@ -222,84 +194,6 @@ void shutdown()
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
-void screenshot()
-{
- bool available = false;
- std::string shortname;
- std::string filename;
- const int TYPETGA = 0;
- const int TYPEPNG = 1;
- const int TYPEJPG = 2;
- int filetype = TYPETGA;
-
- // make sure the screenshots folder exists
- filename.assign(filesystem::writedir());
- filename.append("screenshots/");
- sys::mkdir(filename);
-
- aux::lowercase(screenshotformat->str());
-
- if ((screenshotformat->str().compare("jpg") == 0) || (screenshotformat->str().compare("jpeg") == 0)) {
- filetype = TYPEJPG;
- if (screenshotquality->value() < 10) {
- (*screenshotquality) = 10;
- } else if (screenshotquality->value() > 100) {
- (*screenshotquality) = 100;
- }
-
- } else if (screenshotformat->str().compare("png") == 0) {
- filetype = TYPEPNG;
-
- } else if (screenshotformat->str().compare("tga") == 0) {
- filetype = TYPETGA;
-
- } else {
- filetype = TYPETGA;
- (*screenshotformat) = "tga";
- }
-
- // find the first available screenshotxxxx
- do {
- std::stringstream nstr;
- nstr << screenshot_number;
- shortname.assign(nstr.str());
-
- while(shortname.size() < 4)
- shortname.insert(0, 1, '0');
-
- shortname.insert(0, "screenshots/osirion");
- shortname.append(".");
- shortname.append(screenshotformat->str());
-
- filename.assign(filesystem::writedir());
- filename.append(shortname);
-
- FILE *handle = fopen(filename.c_str(), "r");
- if (handle) {
- fclose(handle);
- } else {
- available = true;
- }
- screenshot_number++;
- } while (!available);
-
- render::Image image((unsigned int)video::width, (unsigned int)video::height, 3);
-
- glReadPixels(0, 0, (GLsizei) video::width, (GLsizei) video::height,
- GL_RGB, GL_UNSIGNED_BYTE, (void *) image.data());
-
- image.flip();
-
- if (filetype == TYPEPNG) {
- render::PNG::save(filename.c_str(), image);
- } else if (filetype == TYPEJPG) {
- render::JPG::save(filename.c_str(), image, (int) screenshotquality->value());
- } else if (filetype == TYPETGA) {
- render::TGA::save(filename.c_str(), image);
- }
-}
-
-
} // namespace video
} // namespace client