Add OpenGL 4.6 backend for NanoVG

This commit introduces a new header file `nanovg_gl46.h` that implements
the NanoVG rendering context using OpenGL 4.6. The new backend utilizes
Direct State Access (DSA) functions, immutable texture storage, and
explicit layout qualifiers. It includes definitions for creating and
deleting the rendering context, as well as functions for handling images
with OpenGL 4.6.
This commit is contained in:
Diego Lopes
2026-03-21 14:00:59 -04:00
parent 47be135221
commit 6200b74e77
12 changed files with 1849 additions and 2 deletions

BIN
samples/font.otf Normal file

Binary file not shown.

View File

@@ -1,5 +1,11 @@
effect = nil
video = nil
ctx = nil
timeDisplayText = ""
dateDisplayText = ""
timer = 0.0
function _create()
video = Texture.FromGStreamer("filesrc location=" .. Resolve("video.mkv"))
@@ -21,10 +27,28 @@ function _create()
}
]]
effect = Effect.new(fxSrc)
ctx = GraphicsContext.new()
local fontPath = Resolve("font.otf")
ctx:CreateFont("font", fontPath)
UpdateTimeAndDate()
end
function UpdateTimeAndDate()
local now = os.date("*t")
timeDisplayText = string.format("%02d:%02d", now.hour, now.min)
dateDisplayText = os.date("%A, %B %d, %Y")
end
function _update(dt)
timer = timer + dt
if timer >= 0.5 then
timer = 0.0
UpdateTimeAndDate()
end
end
function _render()
@@ -32,4 +56,23 @@ function _render()
effect:Use()
effect:SetTexture("uTexture", video, 0)
effect:Render()
ctx:BeginFrame(DesktopSize.x, DesktopSize.y, DesktopSize.x / DesktopSize.y)
local xPos = 80.0
local yPos = 120.0
local timeFontSize = 80
local dateFontSize = 28
ctx:FontSize(timeFontSize)
ctx:FontFace("font")
ctx:FillColor(RGBAf(1, 1, 1, 0.75))
ctx:TextAlign(Align.RIGHT | Align.BOTTOM)
ctx:Text(Displays[1].x + Displays[1].z - xPos, Displays[1].y + Displays[1].w - yPos, timeDisplayText)
ctx:FontSize(dateFontSize)
ctx:FillColor(RGBAf(1, 1, 1, 0.45))
ctx:Text(Displays[1].x + Displays[1].z - xPos, Displays[1].y + Displays[1].w - (yPos + timeFontSize + 8), dateDisplayText)
ctx:EndFrame()
end