window

v0.1.6
createWindow(w, h, [mode]);

Create a GLFW window.

Arguments

wWindow width
hWindow height
[mode]Rendering mode, either GL2D or GL3D, by default GL2D is set.

It is also possible to create a window in the global scope without defining a setup function.

function setup()
  -- Create the window here
  createWindow(600, 600);
end

function draw()
  -- draw things
end
See createWindow in window.h
frameRate(fps);

Set the frame rate

Arguments

fpsThe frame rate to set

If frame rate is called without an argument, it will return frame per seconds

x = 0;

function setup()
  createWindow(400, 400);
  frameRate(24);
end

function draw()
  background(51);
  text('fps: ' .. frameRate(), 20, 10);

  circle(x, 200, 32);
  x = x + 1;
end
See frameRate in window.h
deltaTimeGlobal

Elapsed time since the last draw call in seconds

x = 0;
vx = 128;

function setup()
  createWindow(400, 400);
  frameRate(24); -- try with 60
end

function draw()
  background(51);

  circle(x, height/2, 32);

  -- Get the same velocity with different framerates
  x = x + vx * deltaTime;
end
See deltaTime in window.h
widthGlobal

The window's width in pixels. If no window was created, this value is nil

createWindow(800, 600);

print(width);
-- 800
See width in window.h
heightGlobal

The window's height in pixels. If no window was created, this value is nil

createWindow(800, 600);

print(height);
-- 600
See height in window.h
windowResized();Event

Called when the window is resized

function setup()
    createWindow(500, 500);
end

function draw()
    background(51)
end

function windowResized()
    print('Resized!')
end
See windowResized in window.h