-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.cpp
executable file
·74 lines (61 loc) · 1.94 KB
/
window.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "window.h"
InitError::InitError() :
exception(),
msg( SDL_GetError() )
{
}
InitError::InitError( const std::string & _message) :
exception(),
msg( _message )
{
}
InitError::~InitError() throw()
{
}
const char * InitError::what() const throw()
{
return msg.c_str();
}
window::window()
{
if (SDL_Init( SDL_INIT_EVERYTHING ) < 0)
throw InitError();
//m_window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN );
//if (m_window == NULL)
if ( SDL_CreateWindowAndRenderer( 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS,
&m_window, &m_renderer) != 0 )
throw InitError();
//m_screenSurface = SDL_GetWindowSurface( m_window );
}
window::~window()
{
SDL_DestroyWindow( m_window );
//SDL_DestroyRenderer( m_renderer );
SDL_Quit();
}
void window::draw()
{
// Clear the window with a black background
SDL_SetRenderDrawColor( m_renderer, 0, 0, 0, 255 );
SDL_RenderClear( m_renderer );
// Show the window
SDL_RenderPresent( m_renderer );
/*int rgb[] = { 203, 203, 203, // Gray
254, 254, 31, // Yellow
0, 255, 255, // Cyan
0, 254, 30, // Green
255, 16, 253, // Magenta
253, 3, 2, // Red
18, 14, 252, // Blue
0, 0, 0 // Black
};
SDL_Rect colorBar;
colorBar.x = 0; colorBar.y = 0; colorBar.w = 90; colorBar.h = 480;
SDL_SetRenderDrawColor( m_renderer, rgb[0], rgb[1], rgb[2], 255 );
SDL_RenderFillRect( m_renderer, &colorBar );
SDL_RenderPresent( m_renderer );*/
//Apply the current image
//SDL_BlitSurface( NULL, NULL, m_screenSurface, NULL );
//Update the surface
//SDL_UpdateWindowSurface( m_window );
}