Add scripting for rendering colors
This commit is contained in:
parent
f535a88453
commit
0fc2498f90
|
@ -8,6 +8,7 @@ game.loadurs();
|
|||
console.info(`window size: ${window.size}, render size: ${window.rendersize}`);
|
||||
|
||||
player[0].control(debug);
|
||||
render.clear_color([35,60,92,255].map(x => x/255));
|
||||
|
||||
var show_frame = true;
|
||||
|
||||
|
@ -486,7 +487,7 @@ var editor = {
|
|||
render.text("lock", obj,screenpos());
|
||||
});
|
||||
|
||||
render.grid(1, editor.grid_size, Color.Editor.grid.alpha(0.3));
|
||||
render.grid(1, editor.grid_size, editor.grid_color);
|
||||
var startgrid = game.camera.view2world([-20,0]).map(function(x) { return Math.snap(x, editor.grid_size); });
|
||||
var endgrid = game.camera.view2world([window.width, window.height]);
|
||||
|
||||
|
|
|
@ -144,7 +144,6 @@ console.transcript = "";
|
|||
console.say = function(msg) {
|
||||
msg += "\n";
|
||||
console.print(msg);
|
||||
return;
|
||||
console.transcript += msg;
|
||||
};
|
||||
console.log = console.say;
|
||||
|
|
|
@ -610,6 +610,11 @@ JSC_CCALL(render_end_pass,
|
|||
JSC_SCALL(render_text_size, ret = bb2js(text_bb(str, js2number(argv[1]), js2number(argv[2]), 1)))
|
||||
JSC_CCALL(render_set_camera, useproj = projection)
|
||||
JSC_CCALL(render_set_window, useproj = hudproj)
|
||||
JSC_CCALL(render_clear_color,
|
||||
sg_color c;
|
||||
rgba2floats(&c, js2color(argv[0]));
|
||||
pass_action.colors[0].clear_value = c;
|
||||
)
|
||||
|
||||
static const JSCFunctionListEntry js_render_funcs[] = {
|
||||
MIST_FUNC_DEF(render, grid, 3),
|
||||
|
@ -625,6 +630,7 @@ static const JSCFunctionListEntry js_render_funcs[] = {
|
|||
MIST_FUNC_DEF(render, text_size, 3),
|
||||
MIST_FUNC_DEF(render, set_camera, 0),
|
||||
MIST_FUNC_DEF(render, set_window, 0),
|
||||
MIST_FUNC_DEF(render, clear_color, 1),
|
||||
};
|
||||
|
||||
JSC_CCALL(gui_flush, text_flush(&useproj));
|
||||
|
@ -897,8 +903,19 @@ static const JSCFunctionListEntry js_io_funcs[] = {
|
|||
|
||||
JSC_CCALL(debug_draw_gameobject, gameobject_draw_debug(js2gameobject(argv[0]));)
|
||||
|
||||
JSC_GETSET_GLOBAL(disabled_color, color)
|
||||
JSC_GETSET_GLOBAL(sleep_color, color)
|
||||
JSC_GETSET_GLOBAL(dynamic_color, color)
|
||||
JSC_GETSET_GLOBAL(kinematic_color, color)
|
||||
JSC_GETSET_GLOBAL(static_color, color)
|
||||
|
||||
static const JSCFunctionListEntry js_debug_funcs[] = {
|
||||
MIST_FUNC_DEF(debug, draw_gameobject, 1)
|
||||
MIST_FUNC_DEF(debug, draw_gameobject, 1),
|
||||
CGETSET_ADD(global, disabled_color),
|
||||
CGETSET_ADD(global, sleep_color),
|
||||
CGETSET_ADD(global, dynamic_color),
|
||||
CGETSET_ADD(global, kinematic_color),
|
||||
CGETSET_ADD(global, static_color),
|
||||
};
|
||||
|
||||
JSC_CCALL(physics_sgscale,
|
||||
|
|
|
@ -121,9 +121,6 @@ void capture_screen(int x, int y, int w, int h, const char *path)
|
|||
|
||||
#include "HandmadeMath.h"
|
||||
|
||||
//struct rgba editorClearColor = {35,60,92,255};
|
||||
struct rgba editorClearColor = {0,0,0,255};
|
||||
|
||||
sg_pass_action pass_action = {0};
|
||||
|
||||
static struct {
|
||||
|
@ -236,9 +233,8 @@ void render_init() {
|
|||
sprite_initialize();
|
||||
|
||||
model_init();
|
||||
sg_color c;
|
||||
rgba2floats((float*)&c, editorClearColor);
|
||||
|
||||
sg_color c = (sg_color){0,0,0,1};
|
||||
pass_action = (sg_pass_action){
|
||||
.colors[0] = {.load_action = SG_LOADACTION_CLEAR, .clear_value = c},
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@ extern HMM_Vec3 dirl_pos;
|
|||
extern HMM_Mat4 projection;
|
||||
extern HMM_Mat4 hudproj;
|
||||
extern HMM_Mat4 useproj;
|
||||
extern sg_pass_action pass_action;
|
||||
|
||||
struct draw_p {
|
||||
float x;
|
||||
|
|
Loading…
Reference in a new issue