Add compile flags to remove bits of engine; sokol_gfx_ext works on windows; remove glad/gl

This commit is contained in:
John Alanbrook 2023-09-13 04:32:14 +00:00
parent e6ef147c40
commit 009609458b
12 changed files with 60 additions and 6969 deletions

View file

@ -20,6 +20,18 @@ ifeq ($(CC), clang)
AR = llvm-ar AR = llvm-ar
endif endif
ifdef NEDITOR
CFLAGS += -DNO_EDITOR
endif
ifdef NFLAC
CFLAGS += -DNFLAC
endif
ifdef NMP3
CFLAGS += -DNMP3
endif
ifeq ($(DBG),1) ifeq ($(DBG),1)
CFLAGS += -g CFLAGS += -g
INFO += _dbg INFO += _dbg
@ -61,7 +73,7 @@ ARCH = x64
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
LDFLAGS += -mwin32 -static LDFLAGS += -mwin32 -static
CFLAGS += -mwin32 CFLAGS += -mwin32
LDLIBS += mingw32 kernel32 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m LDLIBS += mingw32 kernel32 opengl32 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m
EXT = .exe EXT = .exe
PLAT = w64 PLAT = w64
PKGCMD = cd $(BIN); zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\* PKGCMD = cd $(BIN); zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*

View file

@ -12,7 +12,7 @@
#include "log.h" #include "log.h"
#include "mix.h" #include "mix.h"
#include "music.h" #include "music.h"
#include "nuke.h"
#include "sound.h" #include "sound.h"
#include "sprite.h" #include "sprite.h"
#include "stb_ds.h" #include "stb_ds.h"
@ -24,8 +24,6 @@
#include "resources.h" #include "resources.h"
#include <sokol/sokol_time.h> #include <sokol/sokol_time.h>
#include <glob.h>
#include "render.h" #include "render.h"
#include "model.h" #include "model.h"
@ -90,15 +88,6 @@ JSValue strarr2js(const char **c, int len)
return arr; return arr;
} }
JSValue glob2js(char *pat)
{
glob_t mglob;
glob(pat, GLOB_NOSORT, NULL, &mglob);
JSValue arr = strarr2js(mglob.gl_pathv, mglob.gl_pathc);
globfree(&mglob);
return arr;
}
double js2number(JSValue v) { double js2number(JSValue v) {
double g; double g;
JS_ToFloat64(js, &g, v); JS_ToFloat64(js, &g, v);
@ -326,6 +315,10 @@ JSValue bb2js(struct boundingbox bb)
return obj; return obj;
} }
#ifndef NO_EDITOR
#include "nuke.h"
JSValue duk_nuke(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { JSValue duk_nuke(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
int cmd = js2int(argv[0]); int cmd = js2int(argv[0]);
float editnum; float editnum;
@ -426,6 +419,8 @@ JSValue duk_nuke(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
return ret; return ret;
} }
#endif
JSValue duk_win_make(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { JSValue duk_win_make(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
/* /*
const char *title = JS_ToCString(js, argv[0]); const char *title = JS_ToCString(js, argv[0]);
@ -1079,9 +1074,6 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
return num2js(get_timescale()); return num2js(get_timescale());
break; break;
case 122: case 122:
str = JS_ToCString(js, argv[1]);
ret = glob2js(str);
break; break;
case 123: case 123:
@ -1685,7 +1677,11 @@ void ffi_load() {
globalThis = JS_GetGlobalObject(js); globalThis = JS_GetGlobalObject(js);
DUK_FUNC(yughlog, 4) DUK_FUNC(yughlog, 4)
#ifndef NO_EDITOR
DUK_FUNC(nuke, 6) DUK_FUNC(nuke, 6)
#endif
DUK_FUNC(make_gameobject, 7) DUK_FUNC(make_gameobject, 7)
DUK_FUNC(set_body, 3) DUK_FUNC(set_body, 3)
DUK_FUNC(q_body, 2) DUK_FUNC(q_body, 2)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,7 @@
#include "nuke.h" #include "nuke.h"
#ifndef NO_EDITOR
#define NK_INCLUDE_STANDARD_IO #define NK_INCLUDE_STANDARD_IO
#define NK_IMPLEMENTATION #define NK_IMPLEMENTATION
#define NK_KEYSTATE_BASED_INPUT #define NK_KEYSTATE_BASED_INPUT
@ -172,3 +175,5 @@ void nuke_labelf(const char *fmt, ...) {
nuke_label(buf); nuke_label(buf);
va_end(args); va_end(args);
} }
#endif

View file

@ -31,7 +31,6 @@ void nuke_img(char *path);
void nuke_scrolltext(char *str); void nuke_scrolltext(char *str);
int nuke_push_tree_id(const char *name, int id); int nuke_push_tree_id(const char *name, int id);
void nuke_tree_pop(); void nuke_tree_pop();

View file

@ -13,7 +13,6 @@
#include "window.h" #include "window.h"
#include "model.h" #include "model.h"
#include "stb_ds.h" #include "stb_ds.h"
#include "stb_image_resize.h";
#include "resources.h" #include "resources.h"
#include "yugine.h" #include "yugine.h"
@ -220,8 +219,11 @@ void render_init() {
font_init(); font_init();
debugdraw_init(); debugdraw_init();
sprite_initialize(); sprite_initialize();
nuke_init(&mainwin);
#ifndef NO_EDITOR
nuke_init(&mainwin);
#endif
model_init(); model_init();
sg_color c; sg_color c;
rgba2floats(&c, editorClearColor); rgba2floats(&c, editorClearColor);
@ -427,14 +429,18 @@ void full_2d_pass(struct window *window)
////// TEXT && GUI ////// TEXT && GUI
debug_nextpass(); debug_nextpass();
nuke_start(); #ifndef NO_EDITOR
nuke_start();
#endif
call_gui(); call_gui();
debug_flush(&hudproj); debug_flush(&hudproj);
text_flush(&hudproj); text_flush(&hudproj);
#ifndef NO_EDITOR
call_nk_gui(); call_nk_gui();
nuke_end(); nuke_end();
#endif
} }
void full_3d_pass(struct window *window) void full_3d_pass(struct window *window)

View file

@ -13,8 +13,6 @@
#include <unistd.h> #include <unistd.h>
#include "font.h" #include "font.h"
#include <glob.h>
#include <fcntl.h> #include <fcntl.h>
#include "cdb.h" #include "cdb.h"
@ -200,11 +198,6 @@ int slurp_write(const char *txt, const char *filename) {
return 0; return 0;
} }
static int glob_err(const char *epath, int errno)
{
return 0;
}
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
static struct cdb_make cdbm; static struct cdb_make cdbm;

View file

@ -27,11 +27,16 @@
#define DR_WAV_IMPLEMENTATION #define DR_WAV_IMPLEMENTATION
#include "dr_wav.h" #include "dr_wav.h"
#ifndef NFLAC
#define DR_FLAC_IMPLEMENTATION #define DR_FLAC_IMPLEMENTATION
#include "dr_flac.h" #include "dr_flac.h"
#endif
#ifndef NMP3
#define DR_MP3_IMPLEMENTATION #define DR_MP3_IMPLEMENTATION
#include "dr_mp3.h" #include "dr_mp3.h"
#endif
#define QOA_IMPLEMENTATION #define QOA_IMPLEMENTATION
#include "qoa.h" #include "qoa.h"
@ -141,14 +146,21 @@ struct wav *make_sound(const char *wav) {
if (!strcmp(ext, "wav")) { if (!strcmp(ext, "wav")) {
mwav.data = drwav_open_file_and_read_pcm_frames_f32(wav, &mwav.ch, &mwav.samplerate, &mwav.frames, NULL); mwav.data = drwav_open_file_and_read_pcm_frames_f32(wav, &mwav.ch, &mwav.samplerate, &mwav.frames, NULL);
} else if (!strcmp(ext, "flac")) { }
#ifndef NFLAC
else if (!strcmp(ext, "flac")) {
mwav.data = drflac_open_file_and_read_pcm_frames_f32(wav, &mwav.ch, &mwav.samplerate, &mwav.frames, NULL); mwav.data = drflac_open_file_and_read_pcm_frames_f32(wav, &mwav.ch, &mwav.samplerate, &mwav.frames, NULL);
} else if (!strcmp(ext, "mp3")) { }
#endif
#ifndef NMP3
else if (!strcmp(ext, "mp3")) {
drmp3_config cnf; drmp3_config cnf;
mwav.data = drmp3_open_file_and_read_pcm_frames_f32(wav, &cnf, &mwav.frames, NULL); mwav.data = drmp3_open_file_and_read_pcm_frames_f32(wav, &cnf, &mwav.frames, NULL);
mwav.ch = cnf.channels; mwav.ch = cnf.channels;
mwav.samplerate = cnf.sampleRate; mwav.samplerate = cnf.sampleRate;
} else if (!strcmp(ext, "qoa")) { }
#endif
else if (!strcmp(ext, "qoa")) {
unsigned char header[QOA_MIN_FILESIZE]; unsigned char header[QOA_MIN_FILESIZE];
FILE *f = fopen(wav, "rb"); FILE *f = fopen(wav, "rb");
fread(header, QOA_MIN_FILESIZE, 1, f); fread(header, QOA_MIN_FILESIZE, 1, f);

View file

@ -9,6 +9,7 @@
#define STB_IMAGE_RESIZE_IMPLEMENTATION #define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "stb_image_resize.h" #include "stb_image_resize.h"
#include <stdio.h> #include <stdio.h>
#define QOI_IMPLEMENTATION #define QOI_IMPLEMENTATION

View file

@ -3513,6 +3513,7 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_UNPACK_ALIGNMENT 0x0CF5 #define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_FRAMEBUFFER_SRGB 0x8DB9 #define GL_FRAMEBUFFER_SRGB 0x8DB9
#define GL_VIEWPORT 0x0BA2
#endif #endif
#ifndef GL_UNSIGNED_INT_2_10_10_10_REV #ifndef GL_UNSIGNED_INT_2_10_10_10_REV

View file

@ -33,13 +33,8 @@
#include "string.h" #include "string.h"
#include "nuklear.h"
#include "sokol/sokol_nuklear.h"
#define SOKOL_TRACE_HOOKS #define SOKOL_TRACE_HOOKS
#define SOKOL_IMPL #define SOKOL_IMPL
#include "sokol/sokol_app.h" #include "sokol/sokol_app.h"
#include "sokol/sokol_audio.h" #include "sokol/sokol_audio.h"
#include "sokol/sokol_time.h" #include "sokol/sokol_time.h"
@ -206,7 +201,11 @@ void c_clean() {
void c_event(const sapp_event *e) void c_event(const sapp_event *e)
{ {
render_dirty = 1; render_dirty = 1;
#ifndef NO_EDITOR
snk_handle_event(e); snk_handle_event(e);
#endif
switch (e->type) { switch (e->type) {
case SAPP_EVENTTYPE_MOUSE_MOVE: case SAPP_EVENTTYPE_MOUSE_MOVE:
input_mouse_move(e->mouse_x, e->mouse_y, e->mouse_dx, e->mouse_dy); input_mouse_move(e->mouse_x, e->mouse_y, e->mouse_dx, e->mouse_dy);