@@ -19,9 +19,11 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
19
19
#include " DataFile.h"
20
20
#include " DataNode.h"
21
21
#include " Dialog.h"
22
+ #include " Files.h"
22
23
#include " Font.h"
23
24
#include " FrameTimer.h"
24
25
#include " GameData.h"
26
+ #include " ImageBuffer.h"
25
27
#include " MenuPanel.h"
26
28
#include " Panel.h"
27
29
#include " PlayerInfo.h"
@@ -47,6 +49,7 @@ using namespace std;
47
49
48
50
void PrintHelp ();
49
51
void PrintVersion ();
52
+ void SetIcon (SDL_Window *window);
50
53
void AdjustViewport (SDL_Window *window);
51
54
int DoError (string message, SDL_Window *window = nullptr , SDL_GLContext context = nullptr );
52
55
void Cleanup (SDL_Window *window, SDL_GLContext context);
@@ -183,6 +186,7 @@ int main(int argc, char *argv[])
183
186
GameData::LoadShaders ();
184
187
// Make sure the screen size and viewport are set correctly.
185
188
AdjustViewport (window);
189
+ SetIcon (window);
186
190
if (!isFullscreen)
187
191
SDL_GetWindowSize (window, &windowWidth, &windowHeight);
188
192
@@ -344,6 +348,32 @@ void PrintVersion()
344
348
345
349
346
350
351
+ void SetIcon (SDL_Window *window)
352
+ {
353
+ // Load the icon file.
354
+ ImageBuffer *buffer = ImageBuffer::Read (Files::Resources () + " icon.png" );
355
+ if (!buffer)
356
+ return ;
357
+ if (!buffer->Pixels () || !buffer->Width () || !buffer->Height ())
358
+ {
359
+ delete buffer;
360
+ return ;
361
+ }
362
+
363
+ // Convert the icon to an SDL surface.
364
+ SDL_Surface *surface = SDL_CreateRGBSurfaceFrom (buffer->Pixels (), buffer->Width (), buffer->Height (),
365
+ 32 , 4 * buffer->Width (), 0x00FF0000 , 0x0000FF00 , 0x000000FF , 0xFF000000 );
366
+ if (surface)
367
+ {
368
+ SDL_SetWindowIcon (window, surface);
369
+ SDL_FreeSurface (surface);
370
+ }
371
+ // Free the image buffer.
372
+ delete buffer;
373
+ }
374
+
375
+
376
+
347
377
void AdjustViewport (SDL_Window *window)
348
378
{
349
379
// Get the window's size in screen coordinates.
0 commit comments