69 lines
2.6 KiB
C++
69 lines
2.6 KiB
C++
/* +------------------------------------------------------+
|
|
____/ \____ /| - Open source game framework licensed to freely use, |
|
|
\ / / | copy, modify and sell without restriction |
|
|
+--\ ^__^ /--+ | |
|
|
| ~/ \~ | | - created for <https://foam.shampoo.ooo> |
|
|
| ~~~~~~~~~~~~ | +------------------------------------------------------+
|
|
| SPACE ~~~~~ | /
|
|
| ~~~~~~~ BOX |/
|
|
+-------------*/
|
|
|
|
#pragma once
|
|
|
|
#include <sstream>
|
|
#include "glm/vec2.hpp"
|
|
#include "SDL.h"
|
|
#include "SDL_image.h"
|
|
#include "sdl2-gfx/SDL2_gfxPrimitives.h"
|
|
#include "sdl2-gfx/SDL2_rotozoom.h"
|
|
#include "Node.hpp"
|
|
#include "Box.hpp"
|
|
#include "Log.hpp"
|
|
|
|
namespace sb
|
|
{
|
|
class Display : public Node
|
|
{
|
|
|
|
public:
|
|
|
|
const static int bpp = 32;
|
|
inline const static Box ndc {-1.0f, -1.0f, 2.0f, 2.0f, true};
|
|
|
|
Display(Node*);
|
|
glm::ivec2 window_size() const;
|
|
Uint32 pixel_format(int = 0) const;
|
|
Box window_box(bool = false) const;
|
|
Box ndc_subsection(const Box&) const;
|
|
Box ndc_to_pixel(const Box&) const;
|
|
void screen_pixels(unsigned char*, int, int, int = 0, int = 0) const;
|
|
SDL_Surface* screen_surface() const;
|
|
SDL_Surface* screen_surface_from_pixels(unsigned char*, bool) const;
|
|
|
|
/*!
|
|
* Respond to full screen requests and window resize events. If fluid resize is enabled in the configuration, respond to
|
|
* resize events as the screen is being resized, otherwise respond once when the resize is finished.
|
|
*
|
|
* The dispay object subscribes to SDL events in its constructor, so this function will be called automatically by
|
|
* sb::Delegate::dispatch when an event happens.
|
|
*
|
|
* @param event an SDL event
|
|
*/
|
|
void respond(SDL_Event& event);
|
|
|
|
/*!
|
|
* Query SDL window flags to determine if fullscreen is on or off and use SDL's fullscreen function to toggle the fullscreen
|
|
* state to the opposite state.
|
|
*
|
|
* Before calling SDL's fullscreen function, this function queries the display index to find out which display (for example,
|
|
* which monitor in a dual-screen system) is displaying the window. It then sets the window's fullscreen display mode to the
|
|
* current desktop display mode of that display. This ensures that the fullscreen will succeed smoothly, without a resolution
|
|
* change, but it also requires that the game is adaptable to dynamic window sizing.
|
|
*/
|
|
void toggle_fullscreen() const;
|
|
|
|
};
|
|
}
|
|
|
|
#include "Game.hpp"
|