CaptureBuffer (class)

From PGE Wiki
Jump to: navigation, search

A caputure buffer can be used to snapshot a frame to a specific rendering priority. For example, if you capture up to -5, then you will capture all but the SMBX HUD. This capture buffer object can be passed as texture to Graphics.glDraw. (LunaLua ≥ v0.7.3.1)

Example:

local myFullCaptureBuffer = Graphics.CaptureBuffer(800, 600)

function onTick()
    myFullCaptureBuffer:captureAt(-5) -- Caputure all but HUD
    Graphics.glDraw {
        vertexCoords = {
            0,   0,
            800, 0, 
            0,   600, 
            0,   600, 
            800, 600, 
            800, 0
        }, 
        texture = myFullCaptureBuffer, 
        textureCoords = {0,0, 1,0, 0,1, 0,1, 1,1, 1,0}, 
        primitive = Graphics.GL_TRIANGLE, 
        priority = 5.1 -- Overdraw everything
    }
end


CaptureBuffer class
Type Function/Field Return values/Value type Description
Constructor myCaptureBuffer = Graphics.CaptureBuffer(int width, int height) CaptureBuffer Construct a new CaptureBuffer-Object.
Constructor CaptureBuffer:captureAt(number priority) nil Captures a frame which is rendered up to priority.