mirror of
https://github.com/Relintai/sfw.git
synced 2024-12-20 21:06:49 +01:00
Cleaned up Window.
This commit is contained in:
parent
d9485f9c3e
commit
eda9c2a063
@ -37,7 +37,8 @@
|
|||||||
# g++ -Wall -D_REENTRANT -g -Isfw -c sfw/pool_vector.cpp -o sfw/pool_vector.o
|
# g++ -Wall -D_REENTRANT -g -Isfw -c sfw/pool_vector.cpp -o sfw/pool_vector.o
|
||||||
# g++ -Wall -D_REENTRANT -g -Isfw -c sfw/pool_allocator.cpp -o sfw/pool_allocator.o
|
# g++ -Wall -D_REENTRANT -g -Isfw -c sfw/pool_allocator.cpp -o sfw/pool_allocator.o
|
||||||
# g++ -Wall -D_REENTRANT -g -Isfw -c sfw/mutex.cpp -o sfw/mutex.o
|
# g++ -Wall -D_REENTRANT -g -Isfw -c sfw/mutex.cpp -o sfw/mutex.o
|
||||||
g++ -Wall -D_REENTRANT -g -Isfw -c sfw/stime.cpp -o sfw/stime.o
|
#g++ -Wall -D_REENTRANT -g -Isfw -c sfw/stime.cpp -o sfw/stime.o
|
||||||
|
|
||||||
#g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c sfw/application/application.cpp -o sfw/application/application.o
|
#g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c sfw/application/application.cpp -o sfw/application/application.o
|
||||||
#g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c sfw/application/scene.cpp -o sfw/application/scene.o
|
#g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c sfw/application/scene.cpp -o sfw/application/scene.o
|
||||||
|
g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c sfw/application/window.cpp -o sfw/application/window.o
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef WINDOW_H
|
||||||
|
#define WINDOW_H
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// window framework
|
// window framework
|
||||||
// - rlyeh, public domain
|
// - rlyeh, public domain
|
||||||
@ -6,9 +9,14 @@
|
|||||||
// @todo: if WINDOW_PORTRAIT && exist portrait monitor, use that instead of primary one
|
// @todo: if WINDOW_PORTRAIT && exist portrait monitor, use that instead of primary one
|
||||||
// @todo: WINDOW_TRAY
|
// @todo: WINDOW_TRAY
|
||||||
|
|
||||||
|
#include "color.h"
|
||||||
#include "int_types.h"
|
#include "int_types.h"
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
|
|
||||||
|
struct GLFWwindow;
|
||||||
|
struct GLFWcursor;
|
||||||
|
struct GLFWmonitor;
|
||||||
|
|
||||||
class Window {
|
class Window {
|
||||||
public:
|
public:
|
||||||
enum WINDOW_FLAGS {
|
enum WINDOW_FLAGS {
|
||||||
@ -31,7 +39,6 @@ public:
|
|||||||
|
|
||||||
bool create(float scale, unsigned flags);
|
bool create(float scale, unsigned flags);
|
||||||
bool create_from_handle(void *handle, float scale, unsigned flags);
|
bool create_from_handle(void *handle, float scale, unsigned flags);
|
||||||
void reload();
|
|
||||||
|
|
||||||
int frame_begin();
|
int frame_begin();
|
||||||
void frame_end();
|
void frame_end();
|
||||||
@ -41,50 +48,47 @@ public:
|
|||||||
void loop(void (*function)(void *loopArg), void *loopArg); // run main loop function continuously (emscripten only)
|
void loop(void (*function)(void *loopArg), void *loopArg); // run main loop function continuously (emscripten only)
|
||||||
void loop_exit(); // exit from main loop function (emscripten only)
|
void loop_exit(); // exit from main loop function (emscripten only)
|
||||||
|
|
||||||
void title(const char *title);
|
void set_title(const char *title);
|
||||||
void color(unsigned color);
|
void set_color(unsigned color);
|
||||||
Vector2 canvas();
|
Vector2 get_canvas();
|
||||||
void *handle();
|
void *get_handle();
|
||||||
char *stats();
|
char *get_stats();
|
||||||
|
|
||||||
uint64_t frame();
|
uint64_t frame();
|
||||||
int width();
|
int get_width();
|
||||||
int height();
|
int get_height();
|
||||||
double time();
|
double get_time();
|
||||||
double delta();
|
double get_delta();
|
||||||
|
|
||||||
// bool hook(void (*func)(), void* userdata); // deprecated
|
// bool hook(void (*func)(), void* userdata); // deprecated
|
||||||
// void unhook(void (*func)()); // deprecated
|
// void unhook(void (*func)()); // deprecated
|
||||||
|
|
||||||
void focus(); // window attribute using haz catz language for now
|
void set_focus(); // window attribute using haz catz language for now
|
||||||
int has_focus();
|
int has_focus();
|
||||||
void fullscreen(int enabled);
|
void set_fullscreen(int enabled);
|
||||||
int has_fullscreen();
|
int has_fullscreen();
|
||||||
void cursor(int visible);
|
void set_cursor(int visible);
|
||||||
int has_cursor();
|
int has_cursor();
|
||||||
void pause(int paused);
|
void set_pause(int paused);
|
||||||
int has_pause();
|
int has_pause();
|
||||||
void visible(int visible);
|
void set_visible(int visible);
|
||||||
int has_visible();
|
int has_visible();
|
||||||
void maximize(int enabled);
|
void set_maximize(int enabled);
|
||||||
int has_maximize();
|
int has_maximize();
|
||||||
void transparent(int enabled);
|
void set_transparent(int enabled);
|
||||||
int has_transparent();
|
int has_transparent();
|
||||||
void icon(const char *file_icon);
|
void set_icon(const char *file_icon);
|
||||||
int has_icon();
|
int has_icon();
|
||||||
|
|
||||||
double aspect();
|
double get_aspect();
|
||||||
void aspect_lock(unsigned numer, unsigned denom);
|
void aspect_lock(unsigned numer, unsigned denom);
|
||||||
void aspect_unlock();
|
void aspect_unlock();
|
||||||
|
|
||||||
double fps();
|
double get_fps();
|
||||||
double fps_target();
|
double get_fps_target();
|
||||||
void fps_lock(float fps);
|
void fps_lock(float fps);
|
||||||
void fps_unlock();
|
void fps_unlock();
|
||||||
|
|
||||||
void screenshot(const char *outfile_png); // , bool record_cursor
|
|
||||||
int record(const char *outfile_mp4); // , bool record_cursor
|
|
||||||
|
|
||||||
Vector2 dpi();
|
Vector2 dpi();
|
||||||
|
|
||||||
enum CURSOR_SHAPES {
|
enum CURSOR_SHAPES {
|
||||||
@ -98,10 +102,10 @@ public:
|
|||||||
CURSOR_SW_AUTO, // software cursor, ui driven. note: this is the only icon that may be recorded or snapshotted
|
CURSOR_SW_AUTO, // software cursor, ui driven. note: this is the only icon that may be recorded or snapshotted
|
||||||
};
|
};
|
||||||
|
|
||||||
void cursor_shape(unsigned shape);
|
void set_cursor_shape(unsigned shape);
|
||||||
|
|
||||||
const char *clipboard();
|
const char *get_clipboard();
|
||||||
void setclipboard(const char *text);
|
void set_clipboard(const char *text);
|
||||||
|
|
||||||
static Window *get_singleton();
|
static Window *get_singleton();
|
||||||
|
|
||||||
@ -109,11 +113,23 @@ public:
|
|||||||
~Window();
|
~Window();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static void glfw_quit();
|
||||||
|
static void glfw_init();
|
||||||
|
static void glfw_error_callback(int error, const char *description);
|
||||||
|
static void drop_callback(GLFWwindow *window, int count, const char **paths);
|
||||||
|
static void window_hints(unsigned flags);
|
||||||
|
GLFWmonitor *find_monitor(int wx, int wy);
|
||||||
|
void shutdown();
|
||||||
|
void resize();
|
||||||
|
static void loop_wrapper(void *loopArg);
|
||||||
|
void glNewFrame();
|
||||||
|
Vector2 canvas();
|
||||||
|
double get_scale();
|
||||||
|
void create_default_cursors();
|
||||||
|
|
||||||
static Window *_singleton;
|
static Window *_singleton;
|
||||||
|
|
||||||
struct GLFWwindow;
|
GLFWwindow *_window;
|
||||||
|
|
||||||
GLFWwindow *window;
|
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
int xpos;
|
int xpos;
|
||||||
@ -131,5 +147,27 @@ protected:
|
|||||||
double hz;
|
double hz;
|
||||||
char title[128];
|
char title[128];
|
||||||
int locked_aspect_ratio;
|
int locked_aspect_ratio;
|
||||||
Vector4 winbgcolor;
|
Color winbgcolor;
|
||||||
|
int _has_icon;
|
||||||
|
|
||||||
|
int _cursorshape = 1;
|
||||||
|
|
||||||
|
void (*render_callback)(void *loopArg);
|
||||||
|
Vector2 last_canvas_size;
|
||||||
|
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
bool keep_running;
|
||||||
|
unsigned int _window_flags;
|
||||||
|
|
||||||
|
bool _fullscreen;
|
||||||
|
bool _transparent;
|
||||||
|
bool _vsync;
|
||||||
|
bool _vsync_adaptive;
|
||||||
|
|
||||||
|
bool _cursors_initialized;
|
||||||
|
GLFWcursor *cursors[7];
|
||||||
|
unsigned int cursor_enums[7];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -112,7 +112,7 @@ _FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3, E
|
|||||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#define ERR_FAIL_V(val) \
|
#define ERR_FAIL_V(val) \
|
||||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, ""); \
|
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, ""); \
|
||||||
return val;
|
return val;
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ _FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3, E
|
|||||||
} else \
|
} else \
|
||||||
((void)0)
|
((void)0)
|
||||||
|
|
||||||
#define CRASH_BAD_INDEX(index, size) \
|
#define CRASH_BAD_INDEX(index, size) \
|
||||||
if ((index < 0) || (index >= size)) { \
|
if ((index < 0) || (index >= size)) { \
|
||||||
RLogger::log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, "CRASH!"); \
|
RLogger::log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, "CRASH!"); \
|
||||||
GENERATE_TRAP \
|
GENERATE_TRAP \
|
||||||
@ -234,6 +234,10 @@ _FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3, E
|
|||||||
} else \
|
} else \
|
||||||
((void)0)
|
((void)0)
|
||||||
|
|
||||||
|
#define CRASH_MSG(msg) \
|
||||||
|
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||||
|
GENERATE_TRAP
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should be a 'free' assert for program flow and should not be needed in any releases,
|
* This should be a 'free' assert for program flow and should not be needed in any releases,
|
||||||
* only used in dev builds.
|
* only used in dev builds.
|
||||||
|
Loading…
Reference in New Issue
Block a user