mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
gfx.startFrame -> gfx.start and gfx.endFrame -> gfx.stop
This commit is contained in:
parent
07d5316d72
commit
73b5c55133
7 changed files with 30 additions and 30 deletions
|
|
@ -86,20 +86,20 @@ while ctr.run() do
|
||||||
if not file then
|
if not file then
|
||||||
local t = os.time()
|
local t = os.time()
|
||||||
repeat
|
repeat
|
||||||
gfx.startFrame(gfx.GFX_TOP)
|
gfx.start(gfx.GFX_TOP)
|
||||||
gfx.text(3, 3, "Can't open file in write mode")
|
gfx.text(3, 3, "Can't open file in write mode")
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
gfx.render()
|
gfx.render()
|
||||||
until t + 5 < os.time()
|
until t + 5 < os.time()
|
||||||
else
|
else
|
||||||
for i = 1, #lines, 1 do
|
for i = 1, #lines, 1 do
|
||||||
file:write(lines[i]..lineEnding)
|
file:write(lines[i]..lineEnding)
|
||||||
gfx.startFrame(gfx.GFX_TOP)
|
gfx.start(gfx.GFX_TOP)
|
||||||
gfx.rectangle(0, 0, math.ceil(i/#lines*gfx.TOP_WIDTH), gfx.TOP_HEIGHT, 0, 0xFFFFFFFF)
|
gfx.rectangle(0, 0, math.ceil(i/#lines*gfx.TOP_WIDTH), gfx.TOP_HEIGHT, 0, 0xFFFFFFFF)
|
||||||
gfx.color.setDefault(color.background)
|
gfx.color.setDefault(color.background)
|
||||||
gfx.text(gfx.TOP_WIDTH/2, gfx.TOP_HEIGHT/2, math.ceil(i/#lines*100).."%")
|
gfx.text(gfx.TOP_WIDTH/2, gfx.TOP_HEIGHT/2, math.ceil(i/#lines*100).."%")
|
||||||
gfx.color.setDefault(color.default)
|
gfx.color.setDefault(color.default)
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
gfx.render()
|
gfx.render()
|
||||||
end
|
end
|
||||||
file:flush()
|
file:flush()
|
||||||
|
|
@ -138,7 +138,7 @@ while ctr.run() do
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Draw
|
-- Draw
|
||||||
gfx.startFrame(gfx.GFX_TOP)
|
gfx.start(gfx.GFX_TOP)
|
||||||
|
|
||||||
-- Lines
|
-- Lines
|
||||||
local sI = math.floor(scrollY / lineHeight)
|
local sI = math.floor(scrollY / lineHeight)
|
||||||
|
|
@ -167,15 +167,15 @@ while ctr.run() do
|
||||||
gfx.rectangle(-scrollX+ font:width(displayedText(curline:sub(1, (utf8.offset(curline, cursorX) or 0)-1))),
|
gfx.rectangle(-scrollX+ font:width(displayedText(curline:sub(1, (utf8.offset(curline, cursorX) or 0)-1))),
|
||||||
-scrollY+ (cursorY-1)*lineHeight, 1, lineHeight, 0, color.cursor)
|
-scrollY+ (cursorY-1)*lineHeight, 1, lineHeight, 0, color.cursor)
|
||||||
|
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
gfx.startFrame(gfx.GFX_BOTTOM)
|
gfx.start(gfx.GFX_BOTTOM)
|
||||||
|
|
||||||
gfx.text(3, 3, "FPS: "..math.ceil(gfx.getFPS()))
|
gfx.text(3, 3, "FPS: "..math.ceil(gfx.getFPS()))
|
||||||
|
|
||||||
keyboard.draw(5, 115)
|
keyboard.draw(5, 115)
|
||||||
|
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
gfx.render()
|
gfx.render()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -47,19 +47,19 @@ while ctr.run() do
|
||||||
|
|
||||||
dMul = hid.pos3d()
|
dMul = hid.pos3d()
|
||||||
|
|
||||||
gfx.startFrame(gfx.GFX_TOP, gfx.GFX_LEFT)
|
gfx.start(gfx.GFX_TOP, gfx.GFX_LEFT)
|
||||||
|
|
||||||
drawStuffIn3D(-1)
|
drawStuffIn3D(-1)
|
||||||
|
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
gfx.startFrame(gfx.GFX_TOP, gfx.GFX_RIGHT)
|
gfx.start(gfx.GFX_TOP, gfx.GFX_RIGHT)
|
||||||
|
|
||||||
drawStuffIn3D(1)
|
drawStuffIn3D(1)
|
||||||
|
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
gfx.startFrame(gfx.GFX_BOTTOM)
|
gfx.start(gfx.GFX_BOTTOM)
|
||||||
|
|
||||||
gfx.color.setDefault(gfx.color.RGBA8(0, 0, 0))
|
gfx.color.setDefault(gfx.color.RGBA8(0, 0, 0))
|
||||||
gfx.text(5, 5, "FPS: "..math.ceil(gfx.getFPS()))
|
gfx.text(5, 5, "FPS: "..math.ceil(gfx.getFPS()))
|
||||||
|
|
@ -72,7 +72,7 @@ while ctr.run() do
|
||||||
gfx.rectangle(40, 90, 60, 60, 0, 0xDDDDDDFF)
|
gfx.rectangle(40, 90, 60, 60, 0, 0xDDDDDDFF)
|
||||||
gfx.circle(70 + math.ceil(cx/156 * 30), 120 - math.ceil(cy/156 * 30), 10, 0xFF000000)
|
gfx.circle(70 + math.ceil(cx/156 * 30), 120 - math.ceil(cy/156 * 30), 10, 0xFF000000)
|
||||||
|
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
angle = angle + 0.05
|
angle = angle + 0.05
|
||||||
if angle > 2*math.pi then angle = angle - 2*math.pi end
|
if angle > 2*math.pi then angle = angle - 2*math.pi end
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ return function(title, curdir, exts, type)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Draw
|
-- Draw
|
||||||
gfx.startFrame(gfx.GFX_TOP)
|
gfx.start(gfx.GFX_TOP)
|
||||||
|
|
||||||
gfx.rectangle(0, 10+(sel-scroll)*15, gfx.TOP_WIDTH, 15, 0, gfx.color.RGBA8(0, 0, 200))
|
gfx.rectangle(0, 10+(sel-scroll)*15, gfx.TOP_WIDTH, 15, 0, gfx.color.RGBA8(0, 0, 200))
|
||||||
|
|
||||||
|
|
@ -112,9 +112,9 @@ return function(title, curdir, exts, type)
|
||||||
gfx.rectangle(0, 0, gfx.TOP_WIDTH, 25, 0, gfx.color.RGBA8(200, 200, 200))
|
gfx.rectangle(0, 0, gfx.TOP_WIDTH, 25, 0, gfx.color.RGBA8(200, 200, 200))
|
||||||
gfx.text(3, 3, curdir, 13, gfx.color.RGBA8(0, 0, 0))
|
gfx.text(3, 3, curdir, 13, gfx.color.RGBA8(0, 0, 0))
|
||||||
|
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
gfx.startFrame(gfx.GFX_BOTTOM)
|
gfx.start(gfx.GFX_BOTTOM)
|
||||||
|
|
||||||
gfx.text(5, 5, title)
|
gfx.text(5, 5, title)
|
||||||
gfx.text(5, 20, "Accepted file extensions: "..(exts or "all"))
|
gfx.text(5, 20, "Accepted file extensions: "..(exts or "all"))
|
||||||
|
|
@ -124,7 +124,7 @@ return function(title, curdir, exts, type)
|
||||||
keyboard.draw(5, 115)
|
keyboard.draw(5, 115)
|
||||||
end
|
end
|
||||||
|
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
gfx.render()
|
gfx.render()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ repeat
|
||||||
while true do
|
while true do
|
||||||
hid.read()
|
hid.read()
|
||||||
if hid.keys().down.start then break end
|
if hid.keys().down.start then break end
|
||||||
gfx.startFrame(gfx.GFX_TOP)
|
gfx.start(gfx.TOP)
|
||||||
gfx.wrappedText(0, 0, err, gfx.TOP_WIDTH)
|
gfx.wrappedText(0, 0, err, gfx.TOP_WIDTH)
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
gfx.render()
|
gfx.render()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ while true do
|
||||||
audio.mix(nil, leftBalance, 1-leftBalance)
|
audio.mix(nil, leftBalance, 1-leftBalance)
|
||||||
end
|
end
|
||||||
|
|
||||||
gfx.startFrame(gfx.GFX_TOP)
|
gfx.start(gfx.GFX_TOP)
|
||||||
gfx.text(5, 5, "Audio test! "..tostring(test:time()).."/"..tostring(test:duration()).."s")
|
gfx.text(5, 5, "Audio test! "..tostring(test:time()).."/"..tostring(test:duration()).."s")
|
||||||
gfx.text(5, 25, "Last audio played on channel "..tostring(channel))
|
gfx.text(5, 25, "Last audio played on channel "..tostring(channel))
|
||||||
gfx.text(5, 65, "Speed: "..(speed*100).."% - Left balance: "..(leftBalance*100).."%")
|
gfx.text(5, 65, "Speed: "..(speed*100).."% - Left balance: "..(leftBalance*100).."%")
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
gfx.render()
|
gfx.render()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ while ctr.run() do
|
||||||
data = (data.."!")
|
data = (data.."!")
|
||||||
end
|
end
|
||||||
|
|
||||||
gfx.startFrame(gfx.GFX_TOP)
|
gfx.start(gfx.GFX_TOP)
|
||||||
gfx.text(0, 0, data)
|
gfx.text(0, 0, data)
|
||||||
gfx.endFrame()
|
gfx.stop()
|
||||||
|
|
||||||
gfx.render()
|
gfx.render()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
12
source/gfx.c
12
source/gfx.c
|
|
@ -52,11 +52,11 @@ void load_map_lib(lua_State *L);
|
||||||
/***
|
/***
|
||||||
Start drawing to a screen.
|
Start drawing to a screen.
|
||||||
Must be called before any draw operation.
|
Must be called before any draw operation.
|
||||||
@function startFrame
|
@function start
|
||||||
@tparam number screen the screen to draw to (`GFX_TOP` or `GFX_BOTTOM`)
|
@tparam number screen the screen to draw to (`GFX_TOP` or `GFX_BOTTOM`)
|
||||||
@tparam[opt=GFX_LEFT] number eye the eye to draw to (`GFX_LEFT` or `GFX_RIGHT`)
|
@tparam[opt=GFX_LEFT] number eye the eye to draw to (`GFX_LEFT` or `GFX_RIGHT`)
|
||||||
*/
|
*/
|
||||||
static int gfx_startFrame(lua_State *L) {
|
static int gfx_start(lua_State *L) {
|
||||||
u8 screen = luaL_checkinteger(L, 1);
|
u8 screen = luaL_checkinteger(L, 1);
|
||||||
u8 eye = luaL_optinteger(L, 2, GFX_LEFT);
|
u8 eye = luaL_optinteger(L, 2, GFX_LEFT);
|
||||||
|
|
||||||
|
|
@ -68,9 +68,9 @@ static int gfx_startFrame(lua_State *L) {
|
||||||
/***
|
/***
|
||||||
End drawing to a screen.
|
End drawing to a screen.
|
||||||
Must be called after your draw operations.
|
Must be called after your draw operations.
|
||||||
@function endFrame
|
@function stop
|
||||||
*/
|
*/
|
||||||
static int gfx_endFrame(lua_State *L) {
|
static int gfx_stop(lua_State *L) {
|
||||||
sf2d_end_frame();
|
sf2d_end_frame();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -358,8 +358,8 @@ static int gfx_calcBoundingBox(lua_State *L) {
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static const struct luaL_Reg gfx_lib[] = {
|
static const struct luaL_Reg gfx_lib[] = {
|
||||||
{ "startFrame", gfx_startFrame },
|
{ "start", gfx_start },
|
||||||
{ "endFrame", gfx_endFrame },
|
{ "stop", gfx_stop },
|
||||||
{ "render", gfx_render },
|
{ "render", gfx_render },
|
||||||
{ "getFPS", gfx_getFPS },
|
{ "getFPS", gfx_getFPS },
|
||||||
{ "set3D", gfx_set3D },
|
{ "set3D", gfx_set3D },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue