font string pulling
This commit is contained in:
parent
14deabf2dd
commit
f1b2984f61
|
@ -139,6 +139,7 @@ json.doc = {
|
|||
Resources.scripts = ["jsoc", "jsc", "jso", "js"];
|
||||
Resources.images = ["qoi", "png", "gif", "jpg", "jpeg"];
|
||||
Resources.sounds = ["wav", "flac", "mp3", "qoa"];
|
||||
Resources.fonts = ["ttf"];
|
||||
Resources.is_image = function (path) {
|
||||
var ext = path.ext();
|
||||
return Resources.images.some(x => x === ext);
|
||||
|
@ -204,6 +205,10 @@ Resources.find_script = function (file, root = "") {
|
|||
return find_ext(file, Resources.scripts, root);
|
||||
}.hashify();
|
||||
|
||||
Resources.find_font = function(file, root = "") {
|
||||
return find_ext(file, Resources.fonts, root);
|
||||
}.hashify();
|
||||
|
||||
console.transcript = "";
|
||||
console.say = function (msg) {
|
||||
msg += "\n";
|
||||
|
|
|
@ -162,7 +162,6 @@ game.startengine = 0;
|
|||
|
||||
prosperon.release_mode = function () {
|
||||
prosperon.debug = false;
|
||||
mum.debug = false;
|
||||
debug.kill();
|
||||
};
|
||||
prosperon.debug = true;
|
||||
|
|
|
@ -903,12 +903,23 @@ render.window = function render_window(pos, wh, color) {
|
|||
};
|
||||
|
||||
render.text = function (str, pos, font = cur_font, size = 0, color = Color.white, wrap = -1) {
|
||||
if (typeof font === 'string')
|
||||
font = render.get_font(font);
|
||||
|
||||
if (!font) return;
|
||||
gui.text(str, pos, size, color, wrap, font); // this puts text into buffer
|
||||
cur_font = font;
|
||||
check_flush(render.flush_text);
|
||||
};
|
||||
|
||||
var tttsize = render.text_size;
|
||||
render.text_size = function(str, font)
|
||||
{
|
||||
if (typeof font === 'string')
|
||||
font = render.get_font(font);
|
||||
return tttsize(str,font);
|
||||
}
|
||||
|
||||
var lasttex = undefined;
|
||||
var img_cache = [];
|
||||
var img_idx = 0;
|
||||
|
@ -1108,7 +1119,13 @@ var fontcache = {};
|
|||
|
||||
render.get_font = function(path,size)
|
||||
{
|
||||
var fontstr = `${path}-${size}`;
|
||||
var parts = path.split('.');
|
||||
if (!isNaN(parts[1])) {
|
||||
path = parts[0];
|
||||
size = Number(parts[1]);
|
||||
}
|
||||
path = Resources.find_font(path);
|
||||
var fontstr = `${path}.${size}`;
|
||||
if (!fontcache[fontstr]) fontcache[fontstr] = os.make_font(path,size);
|
||||
return fontcache[fontstr];
|
||||
}
|
||||
|
@ -1360,7 +1377,8 @@ prosperon.render = function () {
|
|||
prosperon.postvals.diffuse = prosperon.screencolor;
|
||||
|
||||
render.use_mat(prosperon.postvals);
|
||||
render.draw((os.backend() === "directx" || os.backend() === 'metal') ? shape.flipquad : shape.quad);
|
||||
render.draw(shape.quad);
|
||||
//render.draw((os.backend() === "directx" || os.backend() === 'metal') ? shape.flipquad : shape.quad);
|
||||
|
||||
profile.endreport("post process");
|
||||
|
||||
|
@ -1372,13 +1390,8 @@ prosperon.render = function () {
|
|||
|
||||
render.set_camera(prosperon.appcam);
|
||||
render.viewport(...prosperon.appcam.view());
|
||||
|
||||
// Call gui functions
|
||||
mum.style = mum.dbg_style;
|
||||
if (render.draw_gui) prosperon.gui();
|
||||
if (mum.drawinput) mum.drawinput();
|
||||
render.flush_text();
|
||||
mum.style = mum.base;
|
||||
|
||||
check_flush();
|
||||
|
||||
|
|
|
@ -99,8 +99,6 @@ struct sFont *MakeFont(const char *fontfile, int height) {
|
|||
newfont->descent = descent*emscale;
|
||||
newfont->linegap = linegap*emscale;
|
||||
|
||||
printf("ascent %g descent %g linegap %g\n", newfont->ascent, newfont->descent, newfont->linegap);
|
||||
|
||||
newfont->texture = malloc(sizeof(texture));
|
||||
newfont->texture->id = sg_make_image(&(sg_image_desc){
|
||||
.type = SG_IMAGETYPE_2D,
|
||||
|
|
|
@ -826,6 +826,16 @@ JSC_CCALL(render_camera_screen2world,
|
|||
return vec42js(HMM_MulM4V4(view, p));
|
||||
)
|
||||
|
||||
JSC_CCALL(render_set_projection,
|
||||
globalview.p = camera2projection(argv[0]);
|
||||
globalview.vp = HMM_MulM4(globalview.p, globalview.v);
|
||||
)
|
||||
|
||||
JSC_CCALL(render_set_view,
|
||||
globalview.v = transform2view(js2transform(argv[0]));
|
||||
globalview.vp = HMM_MulM4(globalview.p, globalview.v);
|
||||
)
|
||||
|
||||
JSC_CCALL(render_set_camera,
|
||||
JSValue cam = argv[0];
|
||||
globalview.p = camera2projection(argv[0]);
|
||||
|
@ -1271,6 +1281,8 @@ static const JSCFunctionListEntry js_render_funcs[] = {
|
|||
MIST_FUNC_DEF(render, glue_pass, 0),
|
||||
MIST_FUNC_DEF(render, text_size, 5),
|
||||
MIST_FUNC_DEF(render, set_camera, 1),
|
||||
MIST_FUNC_DEF(render, set_projection, 1),
|
||||
MIST_FUNC_DEF(render, set_view, 1),
|
||||
MIST_FUNC_DEF(render, make_pipeline, 1),
|
||||
MIST_FUNC_DEF(render, setuniv3, 2),
|
||||
MIST_FUNC_DEF(render, setuniv, 2),
|
||||
|
|
Loading…
Reference in a new issue