Add steam quickjs
This commit is contained in:
parent
459ef00330
commit
fa5398474b
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -25,6 +25,8 @@ jsc
|
|||
.vscode
|
||||
primum*
|
||||
Prosperon*
|
||||
prosperon*
|
||||
*.icns
|
||||
game.cdb
|
||||
icon.ico
|
||||
icon.ico
|
||||
steam/
|
15
Makefile
15
Makefile
|
@ -138,8 +138,8 @@ else
|
|||
endif
|
||||
|
||||
# All other sources
|
||||
OBJS != find source/engine -type f -name '*.c' | grep -vE 'test|tool|example|fuzz|main' | grep -vE 'quickjs'
|
||||
CPPOBJS != find source/engine -type f -name '*.cpp' | grep -vE 'test|tool|example|fuzz|main'
|
||||
OBJS != find source -type f -name '*.c' | grep -vE 'test|tool|example|fuzz|main' | grep -vE 'quickjs'
|
||||
CPPOBJS != find source -type f -name '*.cpp' | grep -vE 'test|tool|example|fuzz|main'
|
||||
OBJS += $(CPPOBJS)
|
||||
OBJS += $(shell find source/engine -type f -name '*.m')
|
||||
OBJS := $(patsubst %.cpp, %$(INFO).o, $(OBJS))
|
||||
|
@ -149,6 +149,8 @@ OBJS := $(patsubst %.m, %$(INFO).o, $(OBJS))
|
|||
engineincs != find source/engine -maxdepth 1 -type d
|
||||
includeflag != find source -type d -name include
|
||||
includeflag += $(engineincs) source/engine/thirdparty/tinycdb source/shaders source/engine/thirdparty/sokol source/engine/thirdparty/stb source/engine/thirdparty/cgltf source/engine/thirdparty/TinySoundFont source/engine/thirdparty/dr_libs
|
||||
includeflag += steam/public
|
||||
includeflag += source
|
||||
includeflag := $(addprefix -I, $(includeflag))
|
||||
|
||||
WARNING_FLAGS = -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types
|
||||
|
@ -158,7 +160,9 @@ NAME = $(APP)$(INFO)$(EXT)
|
|||
SEM != git describe --tags --abbrev=0
|
||||
COM != git rev-parse --short HEAD
|
||||
|
||||
LDLIBS += steam_api64
|
||||
LDLIBS := $(addprefix -l, $(LDLIBS))
|
||||
LDPATHS := steam/redistributable_bin/win64
|
||||
LDPATHS := $(addprefix -L, $(LDPATHS))
|
||||
|
||||
DEPENDS = $(OBJS:.o=.d)
|
||||
|
@ -181,7 +185,7 @@ $(NAME): libengine$(INFO).a libquickjs$(INFO).a $(DEPS)
|
|||
$(LD) $^ $(CPPFLAGS) $(LDFLAGS) -L. $(LDPATHS) $(LDLIBS) -o $@
|
||||
@echo Finished build
|
||||
|
||||
libengine$(INFO).a: $(OBJS)
|
||||
libengine$(INFO).a: source/engine/core.cdb.h $(OBJS)
|
||||
@echo Archiving $@
|
||||
$(AR) rcs $@ $(OBJS)
|
||||
|
||||
|
@ -195,7 +199,7 @@ libquickjs$(INFO).a: $(QUICKJS)/libregexp$(INFO).o $(QUICKJS)/quickjs$(INFO).o $
|
|||
|
||||
%$(INFO).o: %.cpp
|
||||
@echo Making C++ object $@
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -fpermissive -c $< -o $@
|
||||
|
||||
%$(INFO).o: %.m
|
||||
@echo Making Objective-C object $@
|
||||
|
@ -292,7 +296,8 @@ playweb:
|
|||
|
||||
clean:
|
||||
@echo Cleaning project
|
||||
rm -f source/shaders/*.h core.cdb jso cdb packer TAGS source/engine/core.cdb.h tools/libcdb.a **.a **.o **.d $(APP)* *.icns *.ico
|
||||
rm -f source/shaders/*.h core.cdb jso cdb packer TAGS source/engine/core.cdb.h tools/libcdb.a $(APP)* *.icns *.ico
|
||||
find . -type f -name "*.[oad]" -delete
|
||||
rm -rf Prosperon.app
|
||||
|
||||
docs: doc/prosperon.org
|
||||
|
|
|
@ -540,6 +540,10 @@ var gameobject = {
|
|||
return n;
|
||||
},
|
||||
|
||||
dead() {
|
||||
return this.__kill;
|
||||
},
|
||||
|
||||
kill() {
|
||||
if (this.__kill) return;
|
||||
this.__kill = true;
|
||||
|
|
|
@ -136,11 +136,10 @@ render.text = function(str, pos, size, color, wrap, anchor, cursor) {
|
|||
};
|
||||
|
||||
render.image = function(tex, pos, rotation, color) {
|
||||
color ??= Color.black;
|
||||
color ??= Color.white;
|
||||
rotation ??= 0;
|
||||
// var wh = texture.dimensions(64,path);
|
||||
gui.img(tex,pos, [1.0,1.0], 0.0, false, [0.0,0.0], Color.white);
|
||||
// return bbox.fromcwh([0,0], wh);
|
||||
gui.img(tex,pos, [1.0,1.0], 0.0, false, [0.0,0.0], color);
|
||||
return bbox.fromcwh([0,0], [tex.width,tex.height]);
|
||||
}
|
||||
|
||||
render.doc = "Draw shapes in screen space.";
|
||||
|
|
|
@ -1563,10 +1563,11 @@ static const JSCFunctionListEntry js_nota_funcs[] = {
|
|||
MIST_FUNC_DEF(nota, decode, 1)
|
||||
};
|
||||
|
||||
#define DUK_FUNC(NAME, ARGS) JS_SetPropertyStr(js, globalThis, #NAME, JS_NewCFunction(js, duk_##NAME, #NAME, ARGS));
|
||||
#include "steam.h"
|
||||
|
||||
void ffi_load() {
|
||||
globalThis = JS_GetGlobalObject(js);
|
||||
js_steam_init(js);
|
||||
|
||||
QJSCLASSPREP(ptr);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "quickjs/quickjs.h"
|
||||
#include "HandmadeMath.h"
|
||||
#include "dsp.h"
|
||||
|
||||
void ffi_load();
|
||||
void ffi_stop();
|
||||
|
|
22
source/engine/steam.cpp
Normal file
22
source/engine/steam.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "steam.h"
|
||||
#include <steam/steam_api.h>
|
||||
|
||||
#define countof(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
static JSValue js_steam_start(JSContext *js, JSValue this_v, int argc, JSValue *argv)
|
||||
{
|
||||
SteamAPI_Init();
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_steam_funcs[] = {
|
||||
JS_CFUNC_DEF("init", 0, js_steam_start ),
|
||||
};
|
||||
|
||||
int js_steam_init(JSContext *js)
|
||||
{
|
||||
JSValue proto = JS_NewObject(js);
|
||||
JS_SetPropertyFunctionList(js, proto, js_steam_funcs, countof(js_steam_funcs));
|
||||
JS_SetPropertyStr(js, JS_GetGlobalObject(js), "steam", proto);
|
||||
return 0;
|
||||
}
|
12
source/engine/steam.h
Normal file
12
source/engine/steam.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef QJS_STEAM_H
|
||||
#define QJS_STEAM_H
|
||||
|
||||
#include "jsffi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" int js_steam_init(JSContext *js);
|
||||
#else
|
||||
int js_steam_init(JSContext *js);
|
||||
#endif
|
||||
|
||||
#endif
|
0
source/modules/nota.c
Normal file
0
source/modules/nota.c
Normal file
0
source/modules/nota.h
Normal file
0
source/modules/nota.h
Normal file
Loading…
Reference in a new issue