Handle fullscreen in csfml

This commit is contained in:
Miloslav Číž 2020-11-29 20:00:12 +01:00
parent e5805c931b
commit 3455d3281b

View File

@ -140,7 +140,6 @@ void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex)
windowPixels[y * SFG_SCREEN_RESOLUTION_X + x] = paletteRGB32[colorIndex]; windowPixels[y * SFG_SCREEN_RESOLUTION_X + x] = paletteRGB32[colorIndex];
} }
void SFG_setMusic(uint8_t value) void SFG_setMusic(uint8_t value)
{ {
switch (value) switch (value)
@ -284,7 +283,11 @@ void screenshot()
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'h' && argv[1][2] == 0) uint8_t fullScreen = 1;
for (uint8_t i = 1; i < argc; ++i)
{
if (argv[i][0] == '-' && argv[i][1] == 'h' && argv[i][2] == 0)
{ {
puts("Anarch (CSFML), version " SFG_VERSION_STRING "\n"); puts("Anarch (CSFML), version " SFG_VERSION_STRING "\n");
puts("Anarch is a unique suckless FPS game. Collect weapons and items and destroy"); puts("Anarch is a unique suckless FPS game. Collect weapons and items and destroy");
@ -303,9 +306,15 @@ int main(int argc, char *argv[])
puts("- [TAB]: map"); puts("- [TAB]: map");
puts("- [F12]: screenshot"); puts("- [F12]: screenshot");
puts("- [ESCAPE]: menu"); puts("- [ESCAPE]: menu");
return 0; return 0;
} }
else if (argv[i][0] == '-' && argv[i][1] == 'w' && argv[i][2] == 0)
fullScreen = 0;
else if (argv[i][0] == '-' && argv[i][1] == 'f' && argv[i][2] == 0)
fullScreen = 1;
else
puts("SDL: unknown argument");
}
SFG_init(); SFG_init();
@ -336,7 +345,9 @@ int main(int argc, char *argv[])
sfSprite* windowSprite = sfSprite_create(); sfSprite* windowSprite = sfSprite_create();
window = sfRenderWindow_create(mode, "Anarch", sfResize | sfClose, NULL); window = sfRenderWindow_create(mode, "Anarch",
fullScreen ? sfFullscreen : (sfResize | sfClose ), NULL);
sfSprite_setTexture(windowSprite, windowTexture, sfTrue); sfSprite_setTexture(windowSprite, windowTexture, sfTrue);
sfWindow_setMouseCursorVisible((sfWindow *) window,sfFalse); sfWindow_setMouseCursorVisible((sfWindow *) window,sfFalse);