main
Dominik Madarász 2024-02-16 18:41:02 +01:00
parent 77af66bb2b
commit 9337fdfa6e
10 changed files with 70 additions and 45 deletions

View File

@ -681,9 +681,9 @@ typedef struct font_metrics_t {
void font_goto(float x, float y); void font_goto(float x, float y);
vec2 font_print(const char *text); vec2 font_print(const char *text);
vec2 font_clip(const char *text, vec4 rect); vec2 font_clip(const char *text, vec4 rect);
const char* font_wrap(const char *text, float max_width);
vec2 font_rect(const char *text); vec2 font_rect(const char *text);
font_metrics_t font_metrics(const char *text); font_metrics_t font_metrics(const char *text);
const char* font_wrap(const char *text, float max_width);
void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords);
vec2 font_highlight(const char *text, const void *colors); vec2 font_highlight(const char *text, const void *colors);
void ui_font(); void ui_font();
@ -2028,7 +2028,6 @@ enum WINDOW_FLAGS {
vec2 window_canvas(); vec2 window_canvas();
void* window_handle(); void* window_handle();
char* window_stats(); char* window_stats();
void window_debug(bool visible);
uint64_t window_frame(); uint64_t window_frame();
int window_width(); int window_width();
int window_height(); int window_height();
@ -2050,6 +2049,8 @@ enum WINDOW_FLAGS {
int window_has_transparent(); int window_has_transparent();
void window_icon(const char *file_icon); void window_icon(const char *file_icon);
int window_has_icon(); int window_has_icon();
void window_debug(int visible);
int window_has_debug();
double window_aspect(); double window_aspect();
void window_aspect_lock(unsigned numer, unsigned denom); void window_aspect_lock(unsigned numer, unsigned denom);
void window_aspect_unlock(); void window_aspect_unlock();

View File

@ -60,7 +60,7 @@ int main() {
ddraw_grid(0); ddraw_grid(0);
// pan the viewport // pan the viewport
if (input(MOUSE_L)) { if (input(MOUSE_L) && !ui_active()) {
cursor.x += input_diff(MOUSE_X); cursor.x += input_diff(MOUSE_X);
cursor.y += input_diff(MOUSE_Y); cursor.y += input_diff(MOUSE_Y);
} }

View File

@ -14064,8 +14064,8 @@ extern "C" {
#define ENABLE_RETAIL 0 // ifdef(retail, 1, 0) ///+ #define ENABLE_RETAIL 0 // ifdef(retail, 1, 0) ///+
#endif #endif
#ifndef COOK_DISABLED #ifndef ENABLE_COOK
#define COOK_DISABLED 0 // ifdef(nocook, 1, 0) ///+ #define ENABLE_COOK ifdef(retail, 0, 1) ///+
#endif #endif
#ifndef ENABLE_RPMALLOC #ifndef ENABLE_RPMALLOC
@ -14158,10 +14158,12 @@ extern "C" {
#define ifdef_retail ifdef_false #define ifdef_retail ifdef_false
#endif #endif
#if COOK_DISABLED #if ENABLE_COOK
#define ifdef_nocook ifdef_true #define ifdef_cook ifdef_true
#else
#define ifdef_nocook ifdef_false #define ifdef_nocook ifdef_false
#else
#define ifdef_cook ifdef_false
#define ifdef_nocook ifdef_true
#endif #endif
#if defined NDEBUG && NDEBUG >= 3 // we use NDEBUG=[0,1,2,3] to signal the compiler optimization flags O0,O1,O2,O3 #if defined NDEBUG && NDEBUG >= 3 // we use NDEBUG=[0,1,2,3] to signal the compiler optimization flags O0,O1,O2,O3
@ -16147,12 +16149,10 @@ API vec2 font_xy();
API void font_goto(float x, float y); API void font_goto(float x, float y);
API vec2 font_print(const char *text); API vec2 font_print(const char *text);
API vec2 font_clip(const char *text, vec4 rect); API vec2 font_clip(const char *text, vec4 rect);
API const char* font_wrap(const char *text, float max_width);
API vec2 font_rect(const char *text); API vec2 font_rect(const char *text);
API font_metrics_t font_metrics(const char *text); API font_metrics_t font_metrics(const char *text);
// utilities
API const char* font_wrap(const char *text, float max_width);
// syntax highlighting // syntax highlighting
API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result. API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result.
API vec2 font_highlight(const char *text, const void *colors); API vec2 font_highlight(const char *text, const void *colors);
@ -18681,7 +18681,6 @@ API void window_color(unsigned color);
API vec2 window_canvas(); API vec2 window_canvas();
API void* window_handle(); API void* window_handle();
API char* window_stats(); API char* window_stats();
API void window_debug(bool visible);
API uint64_t window_frame(); API uint64_t window_frame();
API int window_width(); API int window_width();
@ -18708,6 +18707,8 @@ API void window_transparent(int enabled);
API int window_has_transparent(); API int window_has_transparent();
API void window_icon(const char *file_icon); API void window_icon(const char *file_icon);
API int window_has_icon(); API int window_has_icon();
API void window_debug(int visible);
API int window_has_debug();
API double window_aspect(); API double window_aspect();
API void window_aspect_lock(unsigned numer, unsigned denom); API void window_aspect_lock(unsigned numer, unsigned denom);
@ -359016,10 +359017,14 @@ void collide_demo() { // debug draw collisions // @fixme: fix leaks: poly_free()
// @fixme: leaks (worth?) // @fixme: leaks (worth?)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef COOK_INI_PATHFILE
#define COOK_INI_PATHFILE "tools/cook.ini"
#endif
const char *ART = "art/"; const char *ART = "art/";
const char *TOOLS = "tools/bin/"; const char *TOOLS = "tools/bin/";
const char *EDITOR = "tools/"; const char *EDITOR = "tools/";
const char *COOK_INI = "tools/cook.ini"; const char *COOK_INI = COOK_INI_PATHFILE;
static unsigned ART_SKIP_ROOT; // number of chars to skip the base root in ART folder static unsigned ART_SKIP_ROOT; // number of chars to skip the base root in ART folder
static unsigned ART_LEN; // dupe static unsigned ART_LEN; // dupe
@ -359462,7 +359467,7 @@ static cook_worker jobs[JOBS_MAX] = {0};
static volatile bool cook_cancelable = false, cook_cancelling = false, cook_debug = false; static volatile bool cook_cancelable = false, cook_cancelling = false, cook_debug = false;
#ifndef COOK_ON_DEMAND #ifndef COOK_ON_DEMAND
#define COOK_ON_DEMAND flag("--cook-on-demand") #define COOK_ON_DEMAND ifdef(cook, optioni("--cook-on-demand", 1), false)
#endif #endif
static static
@ -379052,7 +379057,7 @@ int fps__timing_thread(void *arg) {
#if is(win32) #if is(win32)
timeBeginPeriod(1); timeBeginPeriod(1);
#endif #endif
sleep_ns( (float)tt ); sleep_ns( tt > 0 ? (float)tt : 0.f );
took += time_ns(); took += time_ns();
ns_excess = took - tt; ns_excess = took - tt;
if( ns_excess < 0 ) ns_excess = 0; if( ns_excess < 0 ) ns_excess = 0;
@ -379782,9 +379787,12 @@ double window_delta() {
return dt; return dt;
} }
void window_debug(bool visible) { void window_debug(int visible) {
win_debug_visible = visible; win_debug_visible = visible;
} }
int window_has_debug() {
return win_debug_visible;
}
double window_fps() { double window_fps() {
return fps; return fps;
@ -380119,7 +380127,7 @@ void window_setclipboard(const char *text) {
static static
double window_scale() { // ok? @testme double window_scale() { // ok? @testme
float xscale=1.0f, yscale=1.0f; float xscale = 1, yscale = 1;
#if !is(ems) && !is(osx) // @todo: remove silicon mac M1 hack #if !is(ems) && !is(osx) // @todo: remove silicon mac M1 hack
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); GLFWmonitor *monitor = glfwGetPrimaryMonitor();
glfwGetMonitorContentScale(monitor, &xscale, &yscale); glfwGetMonitorContentScale(monitor, &xscale, &yscale);

View File

@ -33,8 +33,8 @@
#define ENABLE_RETAIL 0 // ifdef(retail, 1, 0) ///+ #define ENABLE_RETAIL 0 // ifdef(retail, 1, 0) ///+
#endif #endif
#ifndef COOK_DISABLED #ifndef ENABLE_COOK
#define COOK_DISABLED 0 // ifdef(nocook, 1, 0) ///+ #define ENABLE_COOK ifdef(retail, 0, 1) ///+
#endif #endif
#ifndef ENABLE_RPMALLOC #ifndef ENABLE_RPMALLOC
@ -127,10 +127,12 @@
#define ifdef_retail ifdef_false #define ifdef_retail ifdef_false
#endif #endif
#if COOK_DISABLED #if ENABLE_COOK
#define ifdef_nocook ifdef_true #define ifdef_cook ifdef_true
#else
#define ifdef_nocook ifdef_false #define ifdef_nocook ifdef_false
#else
#define ifdef_cook ifdef_false
#define ifdef_nocook ifdef_true
#endif #endif
#if defined NDEBUG && NDEBUG >= 3 // we use NDEBUG=[0,1,2,3] to signal the compiler optimization flags O0,O1,O2,O3 #if defined NDEBUG && NDEBUG >= 3 // we use NDEBUG=[0,1,2,3] to signal the compiler optimization flags O0,O1,O2,O3

View File

@ -9,10 +9,14 @@
// @fixme: leaks (worth?) // @fixme: leaks (worth?)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef COOK_INI_PATHFILE
#define COOK_INI_PATHFILE "tools/cook.ini"
#endif
const char *ART = "art/"; const char *ART = "art/";
const char *TOOLS = "tools/bin/"; const char *TOOLS = "tools/bin/";
const char *EDITOR = "tools/"; const char *EDITOR = "tools/";
const char *COOK_INI = "tools/cook.ini"; const char *COOK_INI = COOK_INI_PATHFILE;
static unsigned ART_SKIP_ROOT; // number of chars to skip the base root in ART folder static unsigned ART_SKIP_ROOT; // number of chars to skip the base root in ART folder
static unsigned ART_LEN; // dupe static unsigned ART_LEN; // dupe
@ -455,7 +459,7 @@ static cook_worker jobs[JOBS_MAX] = {0};
static volatile bool cook_cancelable = false, cook_cancelling = false, cook_debug = false; static volatile bool cook_cancelable = false, cook_cancelling = false, cook_debug = false;
#ifndef COOK_ON_DEMAND #ifndef COOK_ON_DEMAND
#define COOK_ON_DEMAND flag("--cook-on-demand") #define COOK_ON_DEMAND ifdef(cook, optioni("--cook-on-demand", 1), false)
#endif #endif
static static

View File

@ -90,12 +90,10 @@ API vec2 font_xy();
API void font_goto(float x, float y); API void font_goto(float x, float y);
API vec2 font_print(const char *text); API vec2 font_print(const char *text);
API vec2 font_clip(const char *text, vec4 rect); API vec2 font_clip(const char *text, vec4 rect);
API const char* font_wrap(const char *text, float max_width);
API vec2 font_rect(const char *text); API vec2 font_rect(const char *text);
API font_metrics_t font_metrics(const char *text); API font_metrics_t font_metrics(const char *text);
// utilities
API const char* font_wrap(const char *text, float max_width);
// syntax highlighting // syntax highlighting
API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result. API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result.
API vec2 font_highlight(const char *text, const void *colors); API vec2 font_highlight(const char *text, const void *colors);

View File

@ -17,7 +17,7 @@ int fps__timing_thread(void *arg) {
#if is(win32) #if is(win32)
timeBeginPeriod(1); timeBeginPeriod(1);
#endif #endif
sleep_ns( (float)tt ); sleep_ns( tt > 0 ? (float)tt : 0.f );
took += time_ns(); took += time_ns();
ns_excess = took - tt; ns_excess = took - tt;
if( ns_excess < 0 ) ns_excess = 0; if( ns_excess < 0 ) ns_excess = 0;
@ -747,9 +747,12 @@ double window_delta() {
return dt; return dt;
} }
void window_debug(bool visible) { void window_debug(int visible) {
win_debug_visible = visible; win_debug_visible = visible;
} }
int window_has_debug() {
return win_debug_visible;
}
double window_fps() { double window_fps() {
return fps; return fps;
@ -1084,7 +1087,7 @@ void window_setclipboard(const char *text) {
static static
double window_scale() { // ok? @testme double window_scale() { // ok? @testme
float xscale=1.0f, yscale=1.0f; float xscale = 1, yscale = 1;
#if !is(ems) && !is(osx) // @todo: remove silicon mac M1 hack #if !is(ems) && !is(osx) // @todo: remove silicon mac M1 hack
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); GLFWmonitor *monitor = glfwGetPrimaryMonitor();
glfwGetMonitorContentScale(monitor, &xscale, &yscale); glfwGetMonitorContentScale(monitor, &xscale, &yscale);

View File

@ -41,7 +41,6 @@ API void window_color(unsigned color);
API vec2 window_canvas(); API vec2 window_canvas();
API void* window_handle(); API void* window_handle();
API char* window_stats(); API char* window_stats();
API void window_debug(bool visible);
API uint64_t window_frame(); API uint64_t window_frame();
API int window_width(); API int window_width();
@ -68,6 +67,8 @@ API void window_transparent(int enabled);
API int window_has_transparent(); API int window_has_transparent();
API void window_icon(const char *file_icon); API void window_icon(const char *file_icon);
API int window_has_icon(); API int window_has_icon();
API void window_debug(int visible);
API int window_has_debug();
API double window_aspect(); API double window_aspect();
API void window_aspect_lock(unsigned numer, unsigned denom); API void window_aspect_lock(unsigned numer, unsigned denom);

View File

@ -6156,10 +6156,14 @@ void collide_demo() { // debug draw collisions // @fixme: fix leaks: poly_free()
// @fixme: leaks (worth?) // @fixme: leaks (worth?)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef COOK_INI_PATHFILE
#define COOK_INI_PATHFILE "tools/cook.ini"
#endif
const char *ART = "art/"; const char *ART = "art/";
const char *TOOLS = "tools/bin/"; const char *TOOLS = "tools/bin/";
const char *EDITOR = "tools/"; const char *EDITOR = "tools/";
const char *COOK_INI = "tools/cook.ini"; const char *COOK_INI = COOK_INI_PATHFILE;
static unsigned ART_SKIP_ROOT; // number of chars to skip the base root in ART folder static unsigned ART_SKIP_ROOT; // number of chars to skip the base root in ART folder
static unsigned ART_LEN; // dupe static unsigned ART_LEN; // dupe
@ -6602,7 +6606,7 @@ static cook_worker jobs[JOBS_MAX] = {0};
static volatile bool cook_cancelable = false, cook_cancelling = false, cook_debug = false; static volatile bool cook_cancelable = false, cook_cancelling = false, cook_debug = false;
#ifndef COOK_ON_DEMAND #ifndef COOK_ON_DEMAND
#define COOK_ON_DEMAND flag("--cook-on-demand") #define COOK_ON_DEMAND ifdef(cook, optioni("--cook-on-demand", 1), false)
#endif #endif
static static
@ -26192,7 +26196,7 @@ int fps__timing_thread(void *arg) {
#if is(win32) #if is(win32)
timeBeginPeriod(1); timeBeginPeriod(1);
#endif #endif
sleep_ns( (float)tt ); sleep_ns( tt > 0 ? (float)tt : 0.f );
took += time_ns(); took += time_ns();
ns_excess = took - tt; ns_excess = took - tt;
if( ns_excess < 0 ) ns_excess = 0; if( ns_excess < 0 ) ns_excess = 0;
@ -26922,9 +26926,12 @@ double window_delta() {
return dt; return dt;
} }
void window_debug(bool visible) { void window_debug(int visible) {
win_debug_visible = visible; win_debug_visible = visible;
} }
int window_has_debug() {
return win_debug_visible;
}
double window_fps() { double window_fps() {
return fps; return fps;
@ -27259,7 +27266,7 @@ void window_setclipboard(const char *text) {
static static
double window_scale() { // ok? @testme double window_scale() { // ok? @testme
float xscale=1.0f, yscale=1.0f; float xscale = 1, yscale = 1;
#if !is(ems) && !is(osx) // @todo: remove silicon mac M1 hack #if !is(ems) && !is(osx) // @todo: remove silicon mac M1 hack
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); GLFWmonitor *monitor = glfwGetPrimaryMonitor();
glfwGetMonitorContentScale(monitor, &xscale, &yscale); glfwGetMonitorContentScale(monitor, &xscale, &yscale);

View File

@ -131,8 +131,8 @@ extern "C" {
#define ENABLE_RETAIL 0 // ifdef(retail, 1, 0) ///+ #define ENABLE_RETAIL 0 // ifdef(retail, 1, 0) ///+
#endif #endif
#ifndef COOK_DISABLED #ifndef ENABLE_COOK
#define COOK_DISABLED 0 // ifdef(nocook, 1, 0) ///+ #define ENABLE_COOK ifdef(retail, 0, 1) ///+
#endif #endif
#ifndef ENABLE_RPMALLOC #ifndef ENABLE_RPMALLOC
@ -225,10 +225,12 @@ extern "C" {
#define ifdef_retail ifdef_false #define ifdef_retail ifdef_false
#endif #endif
#if COOK_DISABLED #if ENABLE_COOK
#define ifdef_nocook ifdef_true #define ifdef_cook ifdef_true
#else
#define ifdef_nocook ifdef_false #define ifdef_nocook ifdef_false
#else
#define ifdef_cook ifdef_false
#define ifdef_nocook ifdef_true
#endif #endif
#if defined NDEBUG && NDEBUG >= 3 // we use NDEBUG=[0,1,2,3] to signal the compiler optimization flags O0,O1,O2,O3 #if defined NDEBUG && NDEBUG >= 3 // we use NDEBUG=[0,1,2,3] to signal the compiler optimization flags O0,O1,O2,O3
@ -2214,12 +2216,10 @@ API vec2 font_xy();
API void font_goto(float x, float y); API void font_goto(float x, float y);
API vec2 font_print(const char *text); API vec2 font_print(const char *text);
API vec2 font_clip(const char *text, vec4 rect); API vec2 font_clip(const char *text, vec4 rect);
API const char* font_wrap(const char *text, float max_width);
API vec2 font_rect(const char *text); API vec2 font_rect(const char *text);
API font_metrics_t font_metrics(const char *text); API font_metrics_t font_metrics(const char *text);
// utilities
API const char* font_wrap(const char *text, float max_width);
// syntax highlighting // syntax highlighting
API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result. API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result.
API vec2 font_highlight(const char *text, const void *colors); API vec2 font_highlight(const char *text, const void *colors);
@ -4748,7 +4748,6 @@ API void window_color(unsigned color);
API vec2 window_canvas(); API vec2 window_canvas();
API void* window_handle(); API void* window_handle();
API char* window_stats(); API char* window_stats();
API void window_debug(bool visible);
API uint64_t window_frame(); API uint64_t window_frame();
API int window_width(); API int window_width();
@ -4775,6 +4774,8 @@ API void window_transparent(int enabled);
API int window_has_transparent(); API int window_has_transparent();
API void window_icon(const char *file_icon); API void window_icon(const char *file_icon);
API int window_has_icon(); API int window_has_icon();
API void window_debug(int visible);
API int window_has_debug();
API double window_aspect(); API double window_aspect();
API void window_aspect_lock(unsigned numer, unsigned denom); API void window_aspect_lock(unsigned numer, unsigned denom);