[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Usata-commits] Changes to usata2/src/system.cpp
From: |
David Lau |
Subject: |
[Usata-commits] Changes to usata2/src/system.cpp |
Date: |
Fri, 28 Jan 2005 13:29:25 -0500 |
Index: usata2/src/system.cpp
diff -u usata2/src/system.cpp:1.18 usata2/src/system.cpp:1.19
--- usata2/src/system.cpp:1.18 Sat Jan 22 01:03:45 2005
+++ usata2/src/system.cpp Fri Jan 28 18:29:24 2005
@@ -10,7 +10,7 @@
// included in the software distribution, or visit
// http://www.fsf.org/licenses/gpl.html.
//
-// $Id: system.cpp,v 1.18 2005/01/22 01:03:45 skunix Exp $
+// $Id: system.cpp,v 1.19 2005/01/28 18:29:24 skunix Exp $
#include "build_info.hpp"
#include "system.hpp"
@@ -27,21 +27,6 @@
namespace system
{
- static bool glew_was_init = false;
- void init_glew()
- {
- if (glew_was_init)
- return; // everything is ok :)
- GLenum err = glewInit();
- if (err != GLEW_OK)
- {
- throw std::runtime_error((const
char*)(glewGetErrorString(err)));
- }
-
- log::stream << "GLEW initialized\n";
- return;
- }
-
namespace video
{
@@ -118,27 +103,11 @@
{
return capabilities;
}
- }
-
- static bool initialized = false;
- void init()
- {
- int result =
- SDL_Init(SDL_INIT_VIDEO| SDL_INIT_NOPARACHUTE);
- if (result != 0)
+ void update_capabilities()
{
- throw std::runtime_error(SDL_GetError());
+ capabilities.update();
}
- initialized = true;
}
-
- void quit()
- {
- if (initialized)
- SDL_Quit();
- initialized = false;
- }
-
// FIXME: Placed here for now. Refactor this into a property list
// which the graphics engine can lookup capabilties with and
// degrade (scale) rendering quality when necessary. - descender
@@ -217,104 +186,6 @@
log << "Point sprites\n";*/
}
- VideoMode
- scan_modes(const VideoMode& requested)
- {
- Uint32 Flags = SDL_OPENGL;
- Flags |= requested.fullscreen?SDL_FULLSCREEN:0;
- SDL_Rect **sdl_modes = SDL_ListModes(0, Flags);
-
- if (sdl_modes == (void*)-1)
- {
- return requested;
- }
-
- if (sdl_modes==0)
- {
- //FIXME: throw exception
- }
-
- std::vector<VideoMode> AvailableModes;
- for (unsigned index=0; sdl_modes[index]; ++index)
- {
- SDL_Rect *sr = sdl_modes[index];
- AvailableModes.push_back(
- VideoMode(sr->w,
sr->h,requested.fullscreen)
- );
- }
-
- std::sort(AvailableModes.begin(), AvailableModes.end());
- // this is not really important, just bothers me to have a
container
- // with as many complete duplicates as I had
-
- AvailableModes.erase(
- std::unique(AvailableModes.begin(),
- AvailableModes.end()),
- AvailableModes.end());
-
- std::vector<VideoMode>::iterator it =
- std::lower_bound(AvailableModes.begin(),
- AvailableModes.end(),
requested);
-
- if (*it == requested)
- {
- return requested;
- }
-
- if (it != AvailableModes.begin())
- {
- --it;
- }
-
- return *it;
- }
-
- bool set_mode(const VideoMode& vm)
- {
- Uint32 Flags = SDL_OPENGL | (vm.fullscreen?SDL_FULLSCREEN:0);
- const SDL_VideoInfo* vi = SDL_GetVideoInfo();
- log::BufferedStream logstream;
-
- int depth = vi->vfmt->BitsPerPixel;
-
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- bool success = (SDL_SetVideoMode(vm.width, vm.height, depth,
Flags ) != 0);
-
- if (success)
- {
- init_glew();
- print_gl_capabilities();
- video::capabilities.update();
- glViewport(0,0,(GLsizei)vm.width, (GLsizei) vm.height);
- std::string capstr(PROGRAM_TITLE " [" PROGRAM_VERSION
"]");
- SDL_WM_SetCaption(capstr.c_str(), capstr.c_str());
- }
- else
- {
- logstream << log::set_level(log::Level::ERROR) <<
SDL_GetError() << log::commit;
- return success;
- }
- return success;
- }
-
-
-void swap_buffers()
-{
- SDL_GL_SwapBuffers();
-}
-
-namespace time
-{
-
- uint32_t get_ticks()
- {
-
- return SDL_GetTicks();
- }
-
-
-}
}
}
- [Usata-commits] Changes to usata2/src/system.cpp, David Lau, 2005/01/02
- [Usata-commits] Changes to usata2/src/system.cpp, David Lau, 2005/01/03
- [Usata-commits] Changes to usata2/src/system.cpp, David Lau, 2005/01/09
- [Usata-commits] Changes to usata2/src/system.cpp, Chong Kai Xiong, 2005/01/16
- [Usata-commits] Changes to usata2/src/system.cpp, David Lau, 2005/01/20
- [Usata-commits] Changes to usata2/src/system.cpp, David Lau, 2005/01/21
- [Usata-commits] Changes to usata2/src/system.cpp,
David Lau <=