fix polygon rendering bug

This commit is contained in:
John Alanbrook 2024-08-24 18:40:29 -05:00
parent ed7d65523a
commit 39cbd92bfb
6 changed files with 54 additions and 29 deletions

View file

@ -96,6 +96,30 @@ Resources.replstrs = function replstrs(path) {
return script;
};
Resources.is_sound = function(path) {
var ext = path.ext();
return Resources.sounds.any(x => x === ext);
}
Resources.is_image = function(path) {
var ext = path.ext();
return Resources.images.any(x => x === ext);
}
Resources.is_animation = function(path)
{
if (path.ext() === 'gif' && Resources.gif.frames(path) > 1) return true;
if (path.ext() === 'ase') return true;
return false;
}
Resources.is_path = function(str)
{
return !/[\\\/:*?"<>|]/.test(str);
}
globalThis.json = {};
json.encode = function (value, replacer, space = 1) {
return JSON.stringify(value, replacer, space);
@ -127,11 +151,13 @@ Resources.images = ["png", "gif", "jpg", "jpeg"];
Resources.sounds = ["wav", "flac", "mp3", "qoa"];
Resources.is_image = function (path) {
var ext = path.ext();
return Resources.images.any((x) => x === ext);
return Resources.images.some(x => x === ext);
};
function find_ext(file, ext) {
if (io.exists(file)) return file;
if (!file) return;
var file_ext = file.ext();
if (ext.some(x => x === file_ext)) return file;
for (var e of ext) {
var nf = `${file}.${e}`;
if (io.exists(nf)) return nf;

View file

@ -197,7 +197,6 @@ game.tex_hotreload = function()
}
game.texture = function (path) {
if (!io.exists(path))
path = Resources.find_image(path);
if (!io.exists(path)) {

View file

@ -673,7 +673,7 @@ function flush_poly()
render.use_shader(polyssboshader);
render.use_mat({});
render.make_particle_ssbo(poly_cache.slice(0,poly_idx), poly_ssbo);
render.draw(shape.centered_quad, poly_ssbo, poly_cache.length);
render.draw(shape.centered_quad, poly_ssbo, poly_idx);
poly_idx = 0;
}

View file

@ -24,7 +24,7 @@ audio.dsp = dspsound;
audio.cry = function(file)
{
if (!io.exists(file)) file = Resources.find_sound(file);
file = Resources.find_sound(file);
var player = audio.play(file);
if (!player) return;
@ -46,20 +46,29 @@ var killer = Register.appupdate.register(function() {
var song;
audio.music = function(file, fade = 0) {
// Play 'file' for new song, cross fade for seconds
audio.music = function(file, fade = 0.5) {
file = Resources.find_sound(file);
if (!fade) {
song = audio.play(file);
song.loop = true;
return;
}
if (!song) {
song = audio.play(file);
song.volume = 1;
// tween(song,'volume', 1, fade);
return;
}
var temp = audio.play(file);
if (!temp) return;
temp.volume = 0;
temp.volume = 1;
var temp2 = song;
tween(temp, 'volume', 1, fade);
tween(temp2, 'volume', 0, fade);
// tween(temp, 'volume', 1, fade);
// tween(temp2, 'volume', 0, fade);
song = temp;
song.loop = true;
}

View file

@ -66,24 +66,6 @@ os.openurl = function(url) {
var projectfile = "project.prosperon";
io.dumpfolder = '.prosperon';
Resources.is_sound = function(path) {
var ext = path.ext();
return Resources.sounds.any(x => x === ext);
}
Resources.is_animation = function(path)
{
if (path.ext() === 'gif' && Resources.gif.frames(path) > 1) return true;
if (path.ext() === 'ase') return true;
return false;
}
Resources.is_path = function(str)
{
return !/[\\\/:*?"<>|]/.test(str);
}
Resources.texture = {};
Resources.texture.dimensions = function(path) { texture.dimensions(path); }

View file

@ -101,9 +101,18 @@ JSC_CCALL(imgui_sokol_gfx,
}
)
JSC_SCALL(imgui_slider,
float val = js2number(argv[1]);
float low = JS_IsUndefined(argv[2]) ? 0.0 : js2number(argv[2]);
float high = JS_IsUndefined(argv[3]) ? 1.0 : js2number(argv[3]);
ImGui::SliderFloat(str, &val, low, high, "%.3f");
ret = number2js(val);
)
static const JSCFunctionListEntry js_imgui_funcs[] = {
MIST_FUNC_DEF(imgui, window, 2),
MIST_FUNC_DEF(imgui, menu, 2),
MIST_FUNC_DEF(imgui, slider, 4),
MIST_FUNC_DEF(imgui, menubar, 1),
MIST_FUNC_DEF(imgui, mainmenubar, 1),
MIST_FUNC_DEF(imgui, menuitem, 3),