Mercurial > hg > orthanc-stone
comparison Applications/Sdl/SdlEngine.cpp @ 222:84844649a8fd am
continued: reusable applications
author | am@osimis.io |
---|---|
date | Tue, 12 Jun 2018 17:21:15 +0200 |
parents | 1c5a47dda299 |
children | 46c5296d867e |
comparison
equal
deleted
inserted
replaced
221:d7b2590744f8 | 222:84844649a8fd |
---|---|
27 | 27 |
28 #include <SDL.h> | 28 #include <SDL.h> |
29 | 29 |
30 namespace OrthancStone | 30 namespace OrthancStone |
31 { | 31 { |
32 void SdlEngine::SetSize(BasicApplicationContext::ViewportLocker& locker, | 32 void SdlEngine::SetSize(BasicSdlApplicationContext::ViewportLocker& locker, |
33 unsigned int width, | 33 unsigned int width, |
34 unsigned int height) | 34 unsigned int height) |
35 { | 35 { |
36 locker.GetViewport().SetSize(width, height); | 36 locker.GetViewport().SetSize(width, height); |
37 surface_.SetSize(width, height); | 37 surface_.SetSize(width, height); |
40 | 40 |
41 void SdlEngine::RenderFrame() | 41 void SdlEngine::RenderFrame() |
42 { | 42 { |
43 if (viewportChanged_) | 43 if (viewportChanged_) |
44 { | 44 { |
45 BasicApplicationContext::ViewportLocker locker(context_); | 45 BasicSdlApplicationContext::ViewportLocker locker(context_); |
46 surface_.Render(locker.GetViewport()); | 46 surface_.Render(locker.GetViewport()); |
47 | 47 |
48 viewportChanged_ = false; | 48 viewportChanged_ = false; |
49 } | 49 } |
50 } | 50 } |
97 return static_cast<KeyboardModifiers>(result); | 97 return static_cast<KeyboardModifiers>(result); |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 SdlEngine::SdlEngine(SdlWindow& window, | 101 SdlEngine::SdlEngine(SdlWindow& window, |
102 BasicApplicationContext& context) : | 102 BasicSdlApplicationContext& context) : |
103 window_(window), | 103 window_(window), |
104 context_(context), | 104 context_(context), |
105 surface_(window), | 105 surface_(window), |
106 viewportChanged_(true) | 106 viewportChanged_(true) |
107 { | 107 { |
117 { | 117 { |
118 int scancodeCount = 0; | 118 int scancodeCount = 0; |
119 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); | 119 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); |
120 | 120 |
121 { | 121 { |
122 BasicApplicationContext::ViewportLocker locker(context_); | 122 BasicSdlApplicationContext::ViewportLocker locker(context_); |
123 SetSize(locker, window_.GetWidth(), window_.GetHeight()); | 123 SetSize(locker, window_.GetWidth(), window_.GetHeight()); |
124 locker.GetViewport().SetDefaultView(); | 124 locker.GetViewport().SetDefaultView(); |
125 } | 125 } |
126 | 126 |
127 bool stop = false; | 127 bool stop = false; |
132 SDL_Event event; | 132 SDL_Event event; |
133 | 133 |
134 while (!stop && | 134 while (!stop && |
135 SDL_PollEvent(&event)) | 135 SDL_PollEvent(&event)) |
136 { | 136 { |
137 BasicApplicationContext::ViewportLocker locker(context_); | 137 BasicSdlApplicationContext::ViewportLocker locker(context_); |
138 | 138 |
139 if (event.type == SDL_QUIT) | 139 if (event.type == SDL_QUIT) |
140 { | 140 { |
141 stop = true; | 141 stop = true; |
142 break; | 142 break; |