Last change
on this file since 365 was
365,
checked in by epyon, 10 years ago
|
- overhaul of logging:
no longer stream operated
no longer using STL
no memory allocation
shorthand macros
fast file and console I/O
|
File size:
1.2 KB
|
Rev | Line | |
---|
[336] | 1 | // Copyright (C) 2014 ChaosForge Ltd
|
---|
| 2 | // This file is part of Nova Libraries.
|
---|
| 3 | // For conditions of distribution and use, see copyright notice in nv.hh
|
---|
| 4 |
|
---|
| 5 | #include "nv/sdl/sdl_window_manager.hh"
|
---|
| 6 |
|
---|
| 7 | #include "nv/sdl/sdl_window.hh"
|
---|
| 8 | #include "nv/core/logging.hh"
|
---|
| 9 | #include "nv/lib/sdl.hh"
|
---|
| 10 | #include "nv/lib/sdl_image.hh"
|
---|
| 11 | #include "nv/interface/image_data.hh"
|
---|
| 12 |
|
---|
| 13 | using namespace nv;
|
---|
| 14 |
|
---|
| 15 | sdl::window_manager::window_manager()
|
---|
| 16 | {
|
---|
| 17 | nv::load_sdl_library();
|
---|
| 18 |
|
---|
| 19 | if ( SDL_Init(0) < 0 )
|
---|
| 20 | {
|
---|
[365] | 21 | NV_LOG_CRITICAL( "SDL initialization failed: ", SDL_GetError( ) );
|
---|
[336] | 22 | return; // TODO: Error report
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | window* sdl::window_manager::create_window( device* dev, uint16 width, uint16 height, bool fullscreen )
|
---|
| 27 | {
|
---|
| 28 | if ( ! SDL_WasInit( SDL_INIT_VIDEO ) ) SDL_InitSubSystem( SDL_INIT_VIDEO );
|
---|
| 29 | return new sdl::window( dev, width, height, fullscreen );
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | void* sdl::window_manager::adopt_window( void* sys_w_handle )
|
---|
| 33 | {
|
---|
| 34 | if ( ! SDL_WasInit( SDL_INIT_VIDEO ) ) SDL_InitSubSystem( SDL_INIT_VIDEO );
|
---|
| 35 | return SDL_CreateWindowFrom( sys_w_handle );
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | void nv::sdl::window_manager::sleep( uint32 ms )
|
---|
| 39 | {
|
---|
| 40 | SDL_Delay( ms );
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | nv::uint32 nv::sdl::window_manager::get_ticks()
|
---|
| 44 | {
|
---|
| 45 | return SDL_GetTicks();
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | nv::sdl::window_manager::~window_manager()
|
---|
| 49 | {
|
---|
| 50 | SDL_Quit();
|
---|
| 51 | }
|
---|
| 52 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.