gif creation time limit; stretch or scale option
This commit is contained in:
parent
0763783284
commit
ef95b233e2
|
@ -4,6 +4,8 @@ The main editor view is made up of objects. Each object can have a
|
|||
number of components attached to it. When an object is selected, its
|
||||
name, position, and list of components are listed.
|
||||
|
||||
The editor edits either entities or components. When it is started, there is no edited level.
|
||||
|
||||
## Basic controls
|
||||
|Ctrl-Z|Undo|
|
||||
|Ctrl-Shift-Z|Redo|
|
||||
|
|
|
@ -1127,6 +1127,9 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
|
|||
str = JS_ToCString(js, argv[1]);
|
||||
gif_rec_end(str);
|
||||
break;
|
||||
case 133:
|
||||
ret = JS_NewFloat64(js, appTime);
|
||||
break;
|
||||
}
|
||||
|
||||
if (str)
|
||||
|
|
|
@ -100,8 +100,10 @@ var Debug = {
|
|||
GUI.text(x.fullpath(), world2screen(x.pos).add([0,32]), 1, [84,110,255]);
|
||||
});
|
||||
|
||||
if (Debug.Options.gif.rec)
|
||||
if (Debug.Options.gif.rec) {
|
||||
gui_text("REC", [0,40], 1);
|
||||
gui_text(Time.seconds_to_timecode(Time.time - Debug.Options.gif.start_time, Debug.Options.gif.fps), [0,30], 1);
|
||||
}
|
||||
|
||||
gui_text(Game.playing() ? "PLAYING"
|
||||
: Game.stepping() ?
|
||||
|
@ -246,22 +248,45 @@ DebugControls.inputs.f4 = function() {
|
|||
DebugControls.inputs.f4.doc = "Toggle drawing gizmos and names of objects.";
|
||||
|
||||
Debug.Options.gif = {
|
||||
w: 640,
|
||||
h: 480,
|
||||
w: 640, /* Max width */
|
||||
h: 480, /* Max height */
|
||||
stretch: false, /* True if you want to stretch */
|
||||
cpf: 2,
|
||||
depth: 8,
|
||||
file: "out.gif",
|
||||
rec: false,
|
||||
secs: 6,
|
||||
start_time: 0,
|
||||
fps: 0,
|
||||
start() {
|
||||
var w = this.w;
|
||||
var h = this.h;
|
||||
if (!this.stretch) {
|
||||
var win = Window.height / Window.width;
|
||||
var gif = h/w;
|
||||
if (gif > win)
|
||||
h = w * win;
|
||||
else
|
||||
w = h / win;
|
||||
}
|
||||
|
||||
cmd(131, w, h, this.cpf, this.depth);
|
||||
this.rec = true;
|
||||
this.fps = (1/this.cpf)*100;
|
||||
this.start_time = Time.time;
|
||||
|
||||
timer.oneshot(this.stop.bind(this), this.secs, this);
|
||||
},
|
||||
|
||||
stop() {
|
||||
if (!this.rec) return;
|
||||
cmd(132, this.file);
|
||||
this.rec = false;
|
||||
},
|
||||
};
|
||||
DebugControls.inputs.f8 = function() {
|
||||
var gif = Debug.Options.gif;
|
||||
cmd(131, gif.w, gif.h, gif.cpf, gif.depth);
|
||||
gif.rec = true;
|
||||
};
|
||||
DebugControls.inputs.f9 = function() {
|
||||
cmd(132, Debug.Options.gif.file);
|
||||
Debug.Options.gif.rec = false;
|
||||
};
|
||||
|
||||
DebugControls.inputs.f8 = Debug.Options.gif.start.bind(Debug.Options.gif);
|
||||
DebugControls.inputs.f9 = Debug.Options.gif.stop.bind(Debug.Options.gif);
|
||||
|
||||
DebugControls.inputs.f10 = function() { Time.timescale = 0.1; };
|
||||
DebugControls.inputs.f10.doc = "Toggle timescale to 1/10.";
|
||||
|
@ -284,6 +309,16 @@ var Time = {
|
|||
set physMS(x) { cmd(7, x); },
|
||||
set renderMS(x) { cmd(5, x); },
|
||||
|
||||
get time() { return cmd(133); },
|
||||
|
||||
seconds_to_timecode(secs, fps)
|
||||
{
|
||||
var s = Math.trunc(secs);
|
||||
secs -= s;
|
||||
var f = Math.trunc(fps * secs);
|
||||
return `${s}:${f}`;
|
||||
},
|
||||
|
||||
pause() {
|
||||
Time.timescale = 0;
|
||||
},
|
||||
|
|
11
source/shaders/box.glsl
Normal file
11
source/shaders/box.glsl
Normal file
|
@ -0,0 +1,11 @@
|
|||
#version 330 core
|
||||
in vec2 TexCoords;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
uniform sampler2D diffuse_texture;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = texture(diffuse_texture, TexCoords);
|
||||
}
|
Loading…
Reference in a new issue