Jump to content

context:DrawImage in GUI


TEPA6ANT
 Share

Recommended Posts

You would want to use gui:DrawImage(). This will use either 3D rendering or the system 2D drawing commands, depending on how the GUI is being used.

The GUI system does not handle "textures" it handles "images", which can be a texture behind-the-scenes but it is set up to work direct drawing onto windows.

This is being done so that the future editor can use the exact same GUI.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

The panel script actually already supports images. However, you need to call widget:Redraw() after setting the image to trigger a re-render. I am adding an internal call to make this automatic.

local window = Window:Create()
local context = Context:Create(window)
local gui = GUI:Create(context)
local base = gui:GetBase()
base:SetScript("Scripts/GUI/Panel.lua")

x=20
y=20

widget = Widget:Panel(x,y,400,120,base)
local image = gui:LoadImage("Materials/Common/splash.tex")
widget:SetImage(image)
widget:Redraw()

while true do
        if window:Closed() then return end
        if window:KeyHit(Key.Escape) then return end
        
        context:Sync()
end

As for custom shaders, the GUI system is not as flexible as the general 2D drawing system, and it has no concept of "shaders" right now because it needs to render the same things with the OS 2D drawing commands.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...