GUI drawn directly on a window
This code creates a GUI directly on a window, with no OpenGL rendering context created at all. The same scripts can be used for widgets created on a window, a rendering context, or a texture:
--Initialize Steamworks (optional)
Steamworks:Initialize()
--Set the application title
title="$PROJECT_TITLE"
--Create a window
local windowstyle = window.Titlebar + window.Resizable + window.Hidden
if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+window.FullScreen end
window=Window:Create(title,0,0,System:GetProperty("screenwidth","1024"),System:GetProperty("screenheight","768"),windowstyle)
local gui = GUI:Create(window)
gui:GetBase():SetScript("Scripts/GUI/Panel.lua")
local widget = Widget:Create(20,20,75,30,gui:GetBase())
widget:SetScript("Scripts/GUI/Button.lua")
window:Show()
while window:KeyDown(Key.Escape)==false do
--If window has been closed, end the program
if window:Closed() then break end
end
You can try the attached executable to see it working. Notice the zip file contains no textures, shaders, etc. because no rendering context is ever initialized.
-
6
8 Comments
Recommended Comments