Meorawr31439 (talk | contribs) (Initial documentation for SetFrameBuffer) Tag: WoW API docs |
(No difference)
|
Revision as of 18:43, 1 August 2021
The API is no longer being updated here until further notice. |
Controls whether or not a frame is rendered to its own framebuffer prior to being composited into the UI.
Frame:SetFrameBuffer(enabled)
Arguments
- enabled
- boolean -
true
to enable rendering this frame to a framebuffer, orfalse
to disable.
Details
- Use of this flag allows frames to work around specific alpha-related issues when rendering.
- The frame must be configured to flatten render layers (Frame:SetFlattensRenderLayers) for this flag to have any effect. Failure to configure this may result in an invisible frame, or potentially assertion errors on test clients.
- The frame will be rendered to a framebuffer as if it were fully opaque. Any configured alpha for the frame is not inherited by direct children, causing their effective alpha to be 1 unless they themselves have a distinct alpha value. This can cause overlapping child frames to no longer blend together once rendered. The alpha value assigned to the frame is only applied once the framebuffer is composited atop the UI scene.
Example
The following snippet will create a frame in the middle of the screen with two rows of partially transparent textures in the middle, with a checkbox below the frame to toggle the framebuffer flag that is disabled by default.
Toggling the checkbox will demonstrate the effects of the flag; the top row of textures will become less opaque while enabled, and the bottom row will not blend their alpha together such that the green texture in the middle will obscure the overlapping edges of its adjacent textures.
local function CreateColoredTexture(parent, color)
local texture = parent:CreateTexture()
texture:SetColorTexture(color:GetRGB())
return texture
end
local function CreateColoredFrame(parent, color)
local frame = CreateFrame("Frame", nil, parent)
frame.Color = CreateColoredTexture(frame, color)
frame.Color:SetAllPoints(frame)
return frame
end
FrameBufferTestMixin = {}
function FrameBufferTestMixin:OnLoad()
local ItemWidth = 128
local ItemHeight = 64
local GridStride = 3
local ColorsByColumn = { CreateColor(1, 0, 0), CreateColor(0, 1, 0), CreateColor(0, 0, 1) }
local LevelsByColumn = { 1, 2, 1 }
self:SetToplevel(true)
self:SetFrameBuffer(false)
self:SetAlpha(0.5)
self:SetSize(ItemWidth * GridStride, ItemHeight * 3)
self.Background = CreateColoredFrame(self, CreateColor(0, 0, 0))
self.Background:SetFrameLevel(self:GetFrameLevel())
self.Background:SetAllPoints(self)
self.GridItems = {}
for i = 1, 3 do
local texture = CreateColoredTexture(self, ColorsByColumn[i])
texture:SetSize(ItemWidth, ItemHeight)
texture:SetDrawLayer("ARTWORK", LevelsByColumn[i])
table.insert(self.GridItems, texture)
end
for i = 1, 3 do
local frame = CreateColoredFrame(self, ColorsByColumn[i])
frame:SetSize(ItemWidth, ItemHeight)
frame:SetFrameLevel(self:GetFrameLevel() + LevelsByColumn[i])
table.insert(self.GridItems, frame)
end
do
local stride = 3
local paddingX = -32
local paddingY = 16
local direction = GridLayoutMixin.Direction.TopLeftToBottomRight
local initialAnchor = AnchorUtil.CreateAnchor("TOPLEFT", self, "TOPLEFT", 32, -24)
local layout = AnchorUtil.CreateGridLayout(direction, stride, paddingX, paddingY)
AnchorUtil.GridLayout(self.GridItems, initialAnchor, layout)
end
end
function FrameBufferTestMixin:ToggleFramebuffer()
self.framebuffer = not self.framebuffer
self:SetFrameBuffer(self.framebuffer)
end
FrameBufferTestFrame = Mixin(CreateFrame("Frame", nil, UIParent), FrameBufferTestMixin)
FrameBufferTestFrame:OnLoad()
FrameBufferTestFrame:SetPoint("CENTER")
FrameBufferToggleButton = CreateFrame("CheckButton", nil, UIParent, "UICheckButtonTemplate")
FrameBufferToggleButton:SetPoint("TOP", FrameBufferTestFrame, "BOTTOM")
FrameBufferToggleButton:SetScript("OnClick", function() FrameBufferTestFrame:ToggleFramebuffer() end)
Patch changes
Retail
- Patch 9.1.0 (2021-06-29): Added.
Classic
- Patch 2.5.2 (2021-08-31): Added.