source: trunk/src/sdl/sdl_window_manager.cc @ 475

Last change on this file since 475 was 395, checked in by epyon, 10 years ago
  • bulk update copyright update include guards cleanup core/common.hh -> common.hh minor cleanups
File size: 1.3 KB
Line 
1// Copyright (C) 2014-2015 ChaosForge Ltd
2// http://chaosforge.org/
3//
4// This file is part of Nova libraries.
5// For conditions of distribution and use, see copying.txt file in root folder.
6
7#include "nv/sdl/sdl_window_manager.hh"
8
9#include "nv/sdl/sdl_window.hh"
10#include "nv/core/logging.hh"
11#include "nv/lib/sdl.hh"
12#include "nv/lib/sdl_image.hh"
13#include "nv/interface/image_data.hh"
14
15using namespace nv;
16
17sdl::window_manager::window_manager()
18{
19        nv::load_sdl_library();
20
21        if ( SDL_Init(0) < 0 )
22        {
23                NV_LOG_CRITICAL( "SDL initialization failed: ", SDL_GetError( ) );
24                return; // TODO: Error report
25        }
26}
27
28window* sdl::window_manager::create_window( device* dev, uint16 width, uint16 height, bool fullscreen )
29{
30        if ( ! SDL_WasInit( SDL_INIT_VIDEO ) ) SDL_InitSubSystem( SDL_INIT_VIDEO );
31        return new sdl::window( dev, width, height, fullscreen );
32}
33
34void* sdl::window_manager::adopt_window( void* sys_w_handle )
35{
36        if ( ! SDL_WasInit( SDL_INIT_VIDEO ) ) SDL_InitSubSystem( SDL_INIT_VIDEO );
37        return SDL_CreateWindowFrom( sys_w_handle );
38}
39
40void nv::sdl::window_manager::sleep( uint32 ms )
41{
42        SDL_Delay( ms );
43}
44
45nv::uint32 nv::sdl::window_manager::get_ticks()
46{
47        return SDL_GetTicks();
48}
49
50nv::sdl::window_manager::~window_manager()
51{
52        SDL_Quit();
53}
54
Note: See TracBrowser for help on using the repository browser.