Fix cache detection for shaders
This commit is contained in:
parent
b2a466ce8b
commit
9d90cd6f56
4
Makefile
4
Makefile
|
@ -75,7 +75,9 @@ else
|
|||
CPPFLAGS += -O2
|
||||
endif
|
||||
|
||||
CPPFLAGS += -DHAVE_CEIL -DCP_USE_CGTYPES=0 -DCP_USE_DOUBLES=0 -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) $(WARNING_FLAGS) -I. -DVER=\"$(SEM)\" -DCOM=\"$(COM)\" -DINFO=\"$(INFO)\" #-DENABLE_SINC_MEDIUM_CONVERTER -DENABLE_SINC_FAST_CONVERTER -DCP_COLLISION_TYPE_TYPE=uintptr_t -DCP_BITMASK_TYPE=uintptr_t
|
||||
UNIX_TIME != stat -f "%m" core.cdb
|
||||
|
||||
CPPFLAGS += -DHAVE_CEIL -DCP_USE_CGTYPES=0 -DCP_USE_DOUBLES=0 -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) $(WARNING_FLAGS) -I. -DVER=\"$(SEM)\" -DCOM=\"$(COM)\" -DINFO=\"$(INFO)\" -Wno-narrowing -DUNIX_TIME=$(UNIX_TIME) #-DENABLE_SINC_MEDIUM_CONVERTER -DENABLE_SINC_FAST_CONVERTER -DCP_COLLISION_TYPE_TYPE=uintptr_t -DCP_BITMASK_TYPE=uintptr_t
|
||||
CPPFLAGS += -DCONFIG_VERSION=\"2024-02-14\" -DCONFIG_BIGNUM #for quickjs
|
||||
|
||||
# ENABLE_SINC_[BEST|FAST|MEDIUM]_CONVERTER
|
||||
|
|
|
@ -295,8 +295,6 @@ game.engine_start = function(s) {
|
|||
Object.readonly(window.__proto__, 'sample_count');
|
||||
s();
|
||||
|
||||
render.polyshader = render.make_shader("poly.sglsl");
|
||||
|
||||
shape.quad = {
|
||||
pos:os.make_buffer([
|
||||
0,0,0,
|
||||
|
@ -321,6 +319,8 @@ game.engine_start = function(s) {
|
|||
count: 3,
|
||||
index: os.make_buffer([0,2,1],1),
|
||||
};
|
||||
|
||||
render.init();
|
||||
}, process, window.size.x, window.size.y);
|
||||
}
|
||||
|
||||
|
|
|
@ -146,9 +146,10 @@ render.make_shader = function(shader)
|
|||
for (var inc of incs) {
|
||||
var filez = inc.match(/#include <(.*)>/)[1];
|
||||
var macro = io.slurp(filez);
|
||||
if (!macro)
|
||||
macro = io.slurp(`shaders/${filez}`);
|
||||
|
||||
if (!macro) {
|
||||
filez = `shaders/${filez}`;
|
||||
macro = io.slurp(filez);
|
||||
}
|
||||
shader = shader.replace(inc, macro);
|
||||
files.push(filez);
|
||||
}
|
||||
|
@ -356,6 +357,57 @@ render.device = {
|
|||
|
||||
render.device.doc = `Device resolutions given as [x,y,inches diagonal].`;
|
||||
|
||||
var textshader;
|
||||
var circleshader;
|
||||
var polyshader;
|
||||
|
||||
render.init = function() {
|
||||
textshader = render.make_shader("shaders/text_base.cg");
|
||||
render.spriteshader = render.make_shader("shaders/sprite.cg");
|
||||
render.postshader = render.make_shader("shaders/simplepost.cg");
|
||||
circleshader = render.make_shader("shaders/circle.cg");
|
||||
polyshader = render.make_shader("shaders/poly.cg");
|
||||
|
||||
render.textshader = textshader;
|
||||
}
|
||||
|
||||
render.circle = function(pos, radius, color) {
|
||||
var mat = {
|
||||
radius: radius,
|
||||
coord: pos,
|
||||
shade: color
|
||||
};
|
||||
render.setpipeline(circleshader.pipe);
|
||||
render.shader_apply_material(circleshader, mat);
|
||||
var bind = render.sg_bind(circleshader, shape.quad, mat);
|
||||
bind.inst = 1;
|
||||
render.spdraw(bind);
|
||||
}
|
||||
|
||||
render.poly = function(points, color, transform) {
|
||||
var buffer = render.poly_prim(points);
|
||||
var mat = { shade: color};
|
||||
render.setpipeline(polyshader.pipe);
|
||||
render.setunim4(0,polyshader.vs.unimap.model.slot, transform);
|
||||
render.shader_apply_material(polyshader, mat);
|
||||
var bind = render.sg_bind(polyshader, buffer, mat);
|
||||
bind.inst = 1;
|
||||
render.spdraw(bind);
|
||||
}
|
||||
|
||||
render.line = function(points, color = Color.white, thickness = 1, transform) {
|
||||
var buffer = os.make_line_prim(points, thickness, 0, false);
|
||||
render.setpipeline(polyshader.pipe);
|
||||
var mat = {
|
||||
shade: color
|
||||
};
|
||||
render.shader_apply_material(polyshader, mat);
|
||||
render.setunim4(0,polyshader.vs.unimap.model.slot, transform);
|
||||
var bind = render.sg_bind(polyshader, buffer, mat);
|
||||
bind.inst = 1;
|
||||
render.spdraw(bind);
|
||||
}
|
||||
|
||||
/* All draw in screen space */
|
||||
render.point = function(pos,size,color = Color.blue) {
|
||||
render.circle(pos,size,size,color);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "gui.h"
|
||||
|
||||
#include "render.h"
|
||||
#include "sokol/sokol_app.h"
|
||||
#include "imgui.h"
|
||||
|
@ -72,11 +73,12 @@ void gui_input(sapp_event *e)
|
|||
|
||||
void gui_newframe(int x, int y, float dt)
|
||||
{
|
||||
simgui_new_frame(&(simgui_frame_desc_t){
|
||||
simgui_frame_desc_t frame = {
|
||||
.width = x,
|
||||
.height = y,
|
||||
.delta_time = dt
|
||||
});
|
||||
};
|
||||
simgui_new_frame(&frame);
|
||||
}
|
||||
|
||||
void gfx_gui()
|
||||
|
|
|
@ -167,7 +167,14 @@ static int ls_ftw(const char *path, const struct stat *sb, int typeflag)
|
|||
|
||||
time_t file_mod_secs(const char *file) {
|
||||
struct stat attr;
|
||||
stat(file, &attr);
|
||||
|
||||
if (mz_zip_reader_locate_file(&game_cdb, file, NULL, 0) != -1)
|
||||
stat("game.zip", &attr);
|
||||
else if (mz_zip_reader_locate_file(&corecdb, file, NULL, 0) != -1)
|
||||
return UNIX_TIME;
|
||||
else
|
||||
stat(file, &attr);
|
||||
|
||||
return attr.st_mtime;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue