mirror of https://github.com/bjornbytes/lovr.git
Add resize event; lovr.resize callback;
This commit is contained in:
parent
b035f8e4dc
commit
c0d73ab541
|
@ -11,6 +11,7 @@ StringEntry EventTypes[] = {
|
||||||
[EVENT_QUIT] = ENTRY("quit"),
|
[EVENT_QUIT] = ENTRY("quit"),
|
||||||
[EVENT_RESTART] = ENTRY("restart"),
|
[EVENT_RESTART] = ENTRY("restart"),
|
||||||
[EVENT_FOCUS] = ENTRY("focus"),
|
[EVENT_FOCUS] = ENTRY("focus"),
|
||||||
|
[EVENT_RESIZE] = ENTRY("resize"),
|
||||||
#ifdef LOVR_ENABLE_THREAD
|
#ifdef LOVR_ENABLE_THREAD
|
||||||
[EVENT_THREAD_ERROR] = ENTRY("threaderror"),
|
[EVENT_THREAD_ERROR] = ENTRY("threaderror"),
|
||||||
#endif
|
#endif
|
||||||
|
@ -106,6 +107,11 @@ static int nextEvent(lua_State* L) {
|
||||||
lua_pushboolean(L, event.data.boolean.value);
|
lua_pushboolean(L, event.data.boolean.value);
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
|
case EVENT_RESIZE:
|
||||||
|
lua_pushinteger(L, event.data.resize.width);
|
||||||
|
lua_pushinteger(L, event.data.resize.height);
|
||||||
|
return 3;
|
||||||
|
|
||||||
#ifdef LOVR_ENABLE_THREAD
|
#ifdef LOVR_ENABLE_THREAD
|
||||||
case EVENT_THREAD_ERROR:
|
case EVENT_THREAD_ERROR:
|
||||||
luax_pushtype(L, Thread, event.data.thread.thread);
|
luax_pushtype(L, Thread, event.data.thread.thread);
|
||||||
|
|
|
@ -11,6 +11,7 @@ typedef enum {
|
||||||
EVENT_QUIT,
|
EVENT_QUIT,
|
||||||
EVENT_RESTART,
|
EVENT_RESTART,
|
||||||
EVENT_FOCUS,
|
EVENT_FOCUS,
|
||||||
|
EVENT_RESIZE,
|
||||||
EVENT_CUSTOM,
|
EVENT_CUSTOM,
|
||||||
#ifdef LOVR_ENABLE_THREAD
|
#ifdef LOVR_ENABLE_THREAD
|
||||||
EVENT_THREAD_ERROR,
|
EVENT_THREAD_ERROR,
|
||||||
|
@ -49,6 +50,11 @@ typedef struct {
|
||||||
bool value;
|
bool value;
|
||||||
} BoolEvent;
|
} BoolEvent;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
} ResizeEvent;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct Thread* thread;
|
struct Thread* thread;
|
||||||
char* error;
|
char* error;
|
||||||
|
@ -63,6 +69,7 @@ typedef struct {
|
||||||
typedef union {
|
typedef union {
|
||||||
QuitEvent quit;
|
QuitEvent quit;
|
||||||
BoolEvent boolean;
|
BoolEvent boolean;
|
||||||
|
ResizeEvent resize;
|
||||||
ThreadEvent thread;
|
ThreadEvent thread;
|
||||||
CustomEvent custom;
|
CustomEvent custom;
|
||||||
} EventData;
|
} EventData;
|
||||||
|
|
|
@ -170,6 +170,7 @@ static void onResizeWindow(int width, int height) {
|
||||||
state.height = height;
|
state.height = height;
|
||||||
lovrCanvasSetWidth(state.defaultCanvas, width);
|
lovrCanvasSetWidth(state.defaultCanvas, width);
|
||||||
lovrCanvasSetHeight(state.defaultCanvas, height);
|
lovrCanvasSetHeight(state.defaultCanvas, height);
|
||||||
|
lovrEventPush((Event) { .type = EVENT_RESIZE, .data.resize = { width, height } });
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* lovrGraphicsMapBuffer(StreamType type, uint32_t count) {
|
static void* lovrGraphicsMapBuffer(StreamType type, uint32_t count) {
|
||||||
|
|
Loading…
Reference in New Issue