namespace Msp {
namespace Graphics {
-Display::Display(const string &):
- primary_monitor(0),
- focus_window(0)
+Display::Display(const string &)
{
Android::MainThread *thread = reinterpret_cast<Android::MainThread *>(Application::get_data());
if(!thread->is_starting_up())
throw logic_error("Display must be created during startup");
priv = new Private;
- priv->input_queue = 0;
- priv->native_window = 0;
thread->signal_native_window_created.connect(sigc::mem_fun(priv, &PlatformDisplayPrivate::native_window_created));
thread->signal_native_window_resized.connect(sigc::mem_fun(priv, &PlatformDisplayPrivate::native_window_resized));
struct PlatformDisplayPrivate: public sigc::trackable
{
- AInputQueue *input_queue;
+ AInputQueue *input_queue = 0;
std::list<Window::Event> events;
Mutex event_mutex;
- WindowHandle native_window;
+ WindowHandle native_window = 0;
Mutex window_mutex;
void push_event(AndroidEventType);
void Window::platform_init()
{
- priv->window = 0;
}
void Window::platform_cleanup()
struct PlatformEvent
{
AndroidEventType type;
- AInputEvent *aevent;
+ AInputEvent *aevent = 0;
};
} // namespace Graphics
BmpLoader::BmpLoader(IO::Base &i, unsigned sb):
io(i),
- sig_bytes(sb),
- invert_row_order(false)
+ sig_bytes(sb)
{
// Image data location is stored at offset 10 and can't be skipped
if(sig_bytes>10)
{
private:
IO::Base &io;
- unsigned sig_bytes;
- bool invert_row_order;
+ unsigned sig_bytes = 0;
+ bool invert_row_order = false;
public:
BmpLoader(IO::Base &, unsigned = 0);
struct GLContext::Private
{
- ContextHandle context;
+ ContextHandle context = 0;
};
void GLContext::platform_init(const GLOptions &opts)
namespace Graphics {
Display::Display(const string &):
- primary_monitor(0),
- priv(new Private),
- focus_window(0)
+ priv(new Private)
{
static ErrorDialog err_dlg(0);
{
private:
IO::Base &io;
- unsigned id;
+ unsigned id = 0;
public:
DevilLoader(IO::Seekable &);
private:
std::list<Monitor> monitors;
- Monitor *primary_monitor;
+ Monitor *primary_monitor = 0;
std::list<VideoMode> modes;
- Private *priv;
- ErrorDialog *err_dialog;
- Window *focus_window;
+ Private *priv = 0;
+ ErrorDialog *err_dialog = 0;
+ Window *focus_window = 0;
public:
Display(const std::string &disp_name = std::string());
struct Display::Private: PlatformDisplayPrivate
{
- DisplayHandle display;
+ DisplayHandle display = 0;
std::map<WindowHandle, Window *> windows;
};
struct GLContext::Private
{
- EGLDisplay display;
- EGLConfig config;
- EGLSurface surface;
- EGLContext context;
+ EGLDisplay display = EGL_NO_DISPLAY;
+ EGLConfig config = EGL_NO_CONFIG;
+ EGLSurface surface = EGL_NO_SURFACE;
+ EGLContext context = EGL_NO_CONTEXT;
void attach(WindowHandle);
void detach();
class ErrorDialog: public Debug::ErrorReporter
{
private:
- Display *display;
+ Display *display = 0;
public:
ErrorDialog(Display *d): display(d) { }
namespace Msp {
namespace Graphics {
-GLOptions::GLOptions():
- alpha(false),
- stencil(false),
- doublebuffer(true),
- multisample(0),
- forward_compatible(false),
- core_profile(false),
- gl_version_major(DEFAULT_VERSION),
- gl_version_minor(DEFAULT_VERSION)
-{ }
-
-
unsupported_gl_mode::unsupported_gl_mode(const GLOptions &opts):
runtime_error(format("{ .alpha=%s, .stencil=%s, .doublebuffer=%s, .multisample=%d, .forward_compatible=%s, .core_profile=%s, .gl_version=%s }",
opts.alpha, opts.stencil, opts.doublebuffer, opts.multisample, opts.forward_compatible, opts.core_profile, format_version(opts)))
LATEST_VERSION = 0xFFFFFFFF
};
- bool alpha;
- bool stencil;
- bool doublebuffer;
- unsigned multisample;
- bool forward_compatible;
- bool core_profile;
- unsigned gl_version_major;
- unsigned gl_version_minor;
-
- GLOptions();
+ bool alpha = false;
+ bool stencil = false;
+ bool doublebuffer = true;
+ unsigned multisample = 0;
+ bool forward_compatible = false;
+ bool core_profile = false;
+ unsigned gl_version_major = DEFAULT_VERSION;
+ unsigned gl_version_minor = DEFAULT_VERSION;
};
Display &display;
Window &window;
- Private *priv;
+ Private *priv = 0;
public:
GLContext(Window &wnd, const GLOptions &opts = GLOptions());
struct GLContext::Private
{
- ContextHandle context;
+ ContextHandle context = 0;
// We need to create a window with the chosen visual
- WindowHandle subwnd;
- GLXWindow glxwnd;
+ WindowHandle subwnd = None;
+ GLXWindow glxwnd = None;
};
namespace Msp {
namespace Graphics {
-Image::Data::Data():
- fmt(RGB),
- width(0),
- height(0),
- owned_pixels(0),
- pixels(0)
-{ }
-
Image::Data::Data(const Data &other):
fmt(other.fmt),
width(other.width),
public:
struct Data
{
- PixelFormat fmt;
- unsigned width;
- unsigned height;
- unsigned stride;
- char *owned_pixels;
- char *pixels;
-
- Data();
+ PixelFormat fmt = RGB;
+ unsigned width = 0;
+ unsigned height = 0;
+ unsigned stride = 0;
+ char *owned_pixels = 0;
+ char *pixels = 0;
+
+ Data() = default;
Data(const Data &);
Data &operator=(const Data &);
~Data();
namespace Msp {
namespace Graphics {
-ImageLoader::ImageLoader():
- source(0),
- state(INITIAL)
-{ }
-
ImageLoader::~ImageLoader()
{
delete source;
}
-ImageLoader::Registry::Registry():
- changed(false)
-{ }
-
ImageLoader::Registry::~Registry()
{
for(auto l: loaders)
struct Registry
{
std::list<RegisterBase *> loaders;
- bool changed;
+ bool changed = false;
- Registry();
~Registry();
};
private:
- IO::Base *source;
- State state;
+ IO::Base *source = 0;
+ State state = INITIAL;
protected:
- ImageLoader();
+ ImageLoader() = default;
public:
virtual ~ImageLoader();
private:
struct Private;
- Private *priv;
+ Private *priv = 0;
public:
JpegLoader(IO::Seekable &);
+++ /dev/null
-#include "monitor.h"
-
-using namespace std;
-
-namespace Msp {
-namespace Graphics {
-
-Monitor::Monitor():
- index(0),
- next_left(0),
- next_right(0)
-{ }
-
-
-Monitor::Settings::Settings():
- mode(0),
- rotation(ROTATE_NORMAL),
- x(0),
- y(0)
-{ }
-
-} // namespace Graphics
-} // namespace Msp
{
struct Settings
{
- const VideoMode *mode;
- VideoRotation rotation;
- int x, y;
-
- Settings();
+ const VideoMode *mode = 0;
+ VideoRotation rotation = ROTATE_NORMAL;
+ int x = 0;
+ int y = 0;
};
- unsigned index;
+ unsigned index = 0;
std::string name;
std::list<const VideoMode *> video_modes;
Settings desktop_settings;
Settings current_settings;
- const Monitor *next_left;
- const Monitor *next_right;
-
- Monitor();
+ const Monitor *next_left = 0;
+ const Monitor *next_right = 0;
};
} // namespace Graphics
struct PngLoader::Private
{
- std::string message;
- png_struct *png;
- png_info *info;
- int interlace;
+ string message;
+ png_struct *png = 0;
+ png_info *info = 0;
+ int interlace = PNG_INTERLACE_NONE;
};
private:
struct Private;
- Private *priv;
+ Private *priv = 0;
public:
PngLoader(IO::Base &, unsigned = 0);
private:
struct Private;
- Private *priv;
+ Private *priv = 0;
public:
QuartzLoader(IO::Seekable &);
{ }
-VideoMode::VideoMode():
- index(0),
- monitor(0),
- width(0),
- height(0),
- rate(0),
- rotation(ROTATE_ANY)
-{ }
-
VideoMode::VideoMode(unsigned w, unsigned h):
- index(0),
- monitor(0),
width(w),
- height(h),
- rate(0),
- rotation(ROTATE_ANY)
+ height(h)
{ }
} // namespace Graphics
struct VideoMode
{
- unsigned index;
- const Monitor *monitor;
- unsigned width;
- unsigned height;
- float rate;
- VideoRotation rotation;
-
- VideoMode();
+ unsigned index = 0;
+ const Monitor *monitor = 0;
+ unsigned width = 0;
+ unsigned height = 0;
+ float rate = 0.0f;
+ VideoRotation rotation = ROTATE_ANY;
+
+ VideoMode() = default;
VideoMode(unsigned, unsigned);
};
}
}
-VulkanOptions::VulkanOptions():
- enable_validation(false),
- enable_debug_report(false),
- enable_geometry_shader(false),
- enable_tessellation_shader(false)
-{ }
-
void VulkanContext::platform_init(const VulkanOptions &opts)
{
if(result!=VK_SUCCESS)
throw vulkan_error(result, "vkCreateDebugReportCallback");
}
- else
- priv->debug_report_callback = 0;
VkXlibSurfaceCreateInfoKHR surface_create_info = { };
surface_create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
if(result!=VK_SUCCESS)
throw vulkan_error(result, "vkEnumeratePhysicalDevices");
- priv->physical_device = 0;
unsigned gfx_queue_index = 0;
for(unsigned i=0; i<n_phys_devices; ++i)
{
}
-VulkanContext::Private::Private():
- instance(0),
- physical_device(0),
- device(0),
- graphics_queue(0),
- debug_report_callback(0)
-{ }
-
VkBool32 VulkanContext::Private::debug_report_func(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *message, void *)
{
IO::print(IO::cerr, "%s\n", message);
struct VulkanFunctions
{
- PFN_vkCreateInstance vkCreateInstance;
- PFN_vkDestroyInstance vkDestroyInstance;
- PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
- PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
- PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupport;
- PFN_vkCreateDevice vkCreateDevice;
- PFN_vkDestroyDevice vkDestroyDevice;
- PFN_vkGetDeviceQueue vkGetDeviceQueue;
- PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurface;
- PFN_vkDestroySurfaceKHR vkDestroySurface;
- PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallback;
- PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback;
+ PFN_vkCreateInstance vkCreateInstance = 0;
+ PFN_vkDestroyInstance vkDestroyInstance = 0;
+ PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices = 0;
+ PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties = 0;
+ PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupport = 0;
+ PFN_vkCreateDevice vkCreateDevice = 0;
+ PFN_vkDestroyDevice vkDestroyDevice = 0;
+ PFN_vkGetDeviceQueue vkGetDeviceQueue = 0;
+ PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurface = 0;
+ PFN_vkDestroySurfaceKHR vkDestroySurface = 0;
+ PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallback = 0;
+ PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = 0;
};
struct VulkanContext::Private
{
VulkanFunctions functions;
- VkInstance instance;
- VkPhysicalDevice physical_device;
- VkDevice device;
- unsigned graphics_queue_family;
- VkQueue graphics_queue;
- VkSurfaceKHR surface;
- VkDebugReportCallbackEXT debug_report_callback;
-
- Private();
+ VkInstance instance = 0;
+ VkPhysicalDevice physical_device = 0;
+ VkDevice device = 0;
+ unsigned graphics_queue_family = 0;
+ VkQueue graphics_queue = 0;
+ VkSurfaceKHR surface = 0;
+ VkDebugReportCallbackEXT debug_report_callback = 0;
static VkBool32 debug_report_func(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *, void *);
};
struct VulkanOptions
{
- bool enable_validation;
- bool enable_debug_report;
- bool enable_geometry_shader;
- bool enable_tessellation_shader;
-
- VulkanOptions();
+ bool enable_validation = false;
+ bool enable_debug_report = false;
+ bool enable_geometry_shader = false;
+ bool enable_tessellation_shader = false;
};
class VulkanContext
Display &display;
Window &window;
- Private *priv;
+ Private *priv = 0;
public:
VulkanContext(Window &, const VulkanOptions & = VulkanOptions());
struct GLContext::Private
{
- ContextHandle context;
+ ContextHandle context = 0;
};
namespace Msp {
namespace Graphics {
-WindowOptions::WindowOptions():
- x(0),
- y(0),
- user_position(false),
- width(640),
- height(480),
- fullscreen(false),
- fullscreen_monitor(0),
- fullscreen_exclusive(true),
- resizable(false)
-{ }
-
-
Window::Window(Display &dpy, unsigned w, unsigned h, bool fs):
display(dpy)
{
void Window::init()
{
- visible = false;
- kbd_autorepeat = true;
- touch_input = false;
- resizing = false;
- moving = false;
priv = new Private;
if(options.fullscreen && !options.fullscreen_monitor)
struct WindowOptions
{
- int x;
- int y;
- bool user_position;
- unsigned width;
- unsigned height;
- bool fullscreen;
- const Monitor *fullscreen_monitor;
- bool fullscreen_exclusive;
- bool resizable;
-
- WindowOptions();
+ int x = 0;
+ int y = 0;
+ bool user_position = false;
+ unsigned width = 640;
+ unsigned height = 480;
+ bool fullscreen = false;
+ const Monitor *fullscreen_monitor = 0;
+ bool fullscreen_exclusive = true;
+ bool resizable = false;
};
class Window
protected:
Display &display;
WindowOptions options;
- bool visible;
- bool kbd_autorepeat;
- bool touch_input;
- bool resizing;
- bool moving;
- Private *priv;
+ bool visible = false;
+ bool kbd_autorepeat = true;
+ bool touch_input = false;
+ bool resizing = false;
+ bool moving = false;
+ Private *priv = 0;
public:
Window(Display &, unsigned w, unsigned h, bool fs = false);
struct Window::Private: PlatformWindowPrivate
{
- WindowHandle window;
+ WindowHandle window = 0;
};
struct Window::Event: PlatformEvent
namespace Graphics {
Display::Display(const string &):
- primary_monitor(0),
- priv(new Private),
- focus_window(0)
+ priv(new Private)
{
static ErrorDialog err_dlg(0);
this);
if(!priv->window)
throw system_error("CreateWindowEx");
-
- priv->cursor_in_client_area = false;
- priv->cursor_visible = true;
}
void Window::platform_cleanup()
struct PlatformWindowPrivate
{
- bool cursor_in_client_area;
- bool cursor_visible;
+ bool cursor_in_client_area = false;
+ bool cursor_visible = true;
};
struct PlatformEvent
namespace Graphics {
Display::Display(const string &disp_name):
- primary_monitor(0),
- priv(new Private),
- focus_window(0)
+ priv(new Private)
{
if(disp_name.empty())
priv->display = XOpenDisplay(0);
DisplayHandle dpy = display.get_private().display;
priv->wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", true);
- priv->invisible_cursor = 0;
- priv->reparented = false;
- priv->rel_x = 0;
- priv->rel_y = 0;
XSetWindowAttributes attr;
attr.override_redirect = options.fullscreen;
struct PlatformWindowPrivate
{
- Atom wm_delete_window;
- Cursor invisible_cursor;
- bool reparented;
- int rel_x;
- int rel_y;
+ Atom wm_delete_window = None;
+ Cursor invisible_cursor = None;
+ bool reparented = false;
+ int rel_x = 0;
+ int rel_y = 0;
};
struct PlatformEvent
namespace Msp {
namespace Input {
-BinaryControl::BinaryControl():
- state(false),
- threshold(0.5)
-{ }
-
BinaryControl::BinaryControl(const ControlSource &s):
- Control(s),
- state(false),
- threshold(0.5)
+ Control(s)
{ }
BinaryControl::BinaryControl(Device &d, ControlSrcType t, unsigned i):
- Control(d, t, i),
- state(false),
- threshold(0.5)
+ Control(d, t, i)
{ }
BinaryControl::~BinaryControl()
sigc::signal<void> signal_release;
private:
- bool state;
- float threshold;
+ bool state = false;
+ float threshold = 0.5f;
public:
- BinaryControl();
+ BinaryControl() = default;
BinaryControl(const ControlSource &);
BinaryControl(Device &, ControlSrcType, unsigned);
~BinaryControl();
};
std::string control;
- unsigned device;
- ControlSrcType type;
- unsigned index;
+ unsigned device = 0;
+ ControlSrcType type = NONE;
+ unsigned index = 0;
};
private:
namespace Msp {
namespace Input {
-ControlSource::ControlSource():
- dev(0),
- type(NONE),
- index(0)
-{ }
-
ControlSource::ControlSource(Device &d, ControlSrcType t, unsigned i):
dev(&d),
type(t),
}
-Control::Control():
- capture_dev(0),
- activator(0),
- origin(0),
- rising_edge(false),
- falling_edge(false)
-{ }
-
Control::Control(const ControlSource &s):
- src(s),
- capture_dev(0),
- activator(0),
- origin(0),
- rising_edge(false),
- falling_edge(false)
+ src(s)
{ }
Control::Control(Device &d, ControlSrcType t, unsigned i):
- src(d, t, i),
- capture_dev(0),
- activator(0),
- origin(0),
- rising_edge(false),
- falling_edge(false)
+ src(d, t, i)
{
connect_signals();
}
*/
struct ControlSource
{
- Device *dev;
- ControlSrcType type;
- unsigned index;
+ Device *dev = 0;
+ ControlSrcType type = NONE;
+ unsigned index = 0;
- ControlSource();
+ ControlSource() = default;
ControlSource(Device &, ControlSrcType, unsigned);
std::string str() const;
};
protected:
ControlSource src;
- Device *capture_dev;
- BinaryControl *activator;
- float origin;
- bool rising_edge;
- bool falling_edge;
+ Device *capture_dev = 0;
+ BinaryControl *activator = 0;
+ float origin = 0.0f;
+ bool rising_edge = false;
+ bool falling_edge = false;
- Control();
+ Control() = default;
Control(const ControlSource &);
Control(Device &, ControlSrcType, unsigned);
public:
sigc::signal<bool, unsigned, float, float>::accumulated<EventAccumulator> signal_axis_motion;
protected:
- DeviceType type;
+ DeviceType type = UNSPECIFIED;
std::string name;
std::vector<char> buttons;
std::vector<float> axes;
private:
struct Private;
- Private *priv;
- IO::EventDispatcher *event_disp;
+ Private *priv = 0;
+ IO::EventDispatcher *event_disp = 0;
static bool detect_done;
static unsigned n_detected_controllers;
GestureDetector::GestureDetector(Touchscreen &ts):
Device(UNSPECIFIED),
- touchscreen(ts),
- current_gesture(GESTURE_NONE),
- pending_tap(GESTURE_NONE),
- invalid_gesture(false)
+ touchscreen(ts)
{
name = "Gesture";
Touchscreen &touchscreen;
TouchPoint points[MAX_POINTS];
- Gesture current_gesture;
- Gesture pending_tap;
- bool invalid_gesture;
- float threshold_x_sq;
- float threshold_y_sq;
+ Gesture current_gesture = GESTURE_NONE;
+ Gesture pending_tap = GESTURE_NONE;
+ bool invalid_gesture = false;
+ float threshold_x_sq = 1.0f;
+ float threshold_y_sq = 1.0f;
public:
GestureDetector(Touchscreen &);
vector<string> GameController::Private::detected_controllers;
GameController::GameController(unsigned index):
- Device(GAME_CONTROLLER),
- event_disp(0)
+ Device(GAME_CONTROLLER)
{
if(!detect_done)
detect();
struct GameController::Private
{
- JsDevice *dev;
+ JsDevice *dev = 0;
static std::vector<std::string> detected_controllers;
};
namespace Msp {
namespace Input {
-SmoothControl::SmoothControl():
- value(0),
- paired_ctrl(0),
- dead_zone(0.1),
- threshold(0.9)
-{ }
-
SmoothControl::SmoothControl(const ControlSource &s):
- Control(s),
- value(0),
- paired_ctrl(0),
- dead_zone(0.1),
- threshold(0.9)
+ Control(s)
{ }
SmoothControl::SmoothControl(Device &d, ControlSrcType t, unsigned i):
- Control(d, t, i),
- value(0),
- paired_ctrl(0),
- dead_zone(0.1),
- threshold(0.9)
+ Control(d, t, i)
{ }
SmoothControl::~SmoothControl()
sigc::signal<void, float> signal_motion;
private:
- float value;
- SmoothControl *paired_ctrl;
- float dead_zone;
- float threshold;
+ float value = 0.0f;
+ SmoothControl *paired_ctrl = 0;
+ float dead_zone = 0.1f;
+ float threshold = 0.9f;
public:
- SmoothControl();
+ SmoothControl() = default;
SmoothControl(const ControlSource &);
SmoothControl(Device &, ControlSrcType, unsigned);
~SmoothControl();
}
-GameController::Private::Private():
- index(0),
- last_packet_number(0),
- event_pipe(0),
- timer_slot(0)
-{ }
-
bool GameController::Private::generate_event()
{
event_pipe->put(1);
GameControllerTimerThread *GameControllerTimerThread::thread = 0;
GameControllerTimerThread::GameControllerTimerThread():
- Thread("GameController"),
- n_users(0)
+ Thread("GameController")
{
launch();
}
{
private:
Time::Timer timer;
- unsigned n_users;
+ unsigned n_users = 0;
static GameControllerTimerThread *thread;
struct GameController::Private
{
- unsigned index;
- unsigned last_packet_number;
- IO::Pipe *event_pipe;
- Time::Timer::Slot *timer_slot;
+ unsigned index = 0;
+ unsigned last_packet_number = 0;
+ IO::Pipe *event_pipe = 0;
+ Time::Timer::Slot *timer_slot = 0;
static std::vector<unsigned> detected_controllers;
- Private();
-
bool generate_event();
void update_state(GameController &, const XINPUT_STATE &, bool);