SetScissorClip

From OxeyeWiki

Revision as of 02:05, 25 January 2010 by Thewreck (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

video.setScissorClip(left, top, right, bottom)

Sets the video device's "scissor clip" area. This area is a rectangle on the screen in which rendering should be allowed. All pixels that are rendered outside of this rectangle will not be displayed.

The scissor clip can be used, for example, to create split-screen multiplayer. To do this, render the whole game twice, using an on-screen off-set for the second half. See the example below.

Use clearScissorClip to reset the clip again.

Parameter Expected Type Description
left An integer The left edge of the rectangle (inclusive).
top An integer The top edge of the rectangle (inclusive).
right An integer The right edge of the rectangle (exclusive).
bottom An integer The bottom edge of the rectangle (exclusive).
Returns

Returns nothing.

Daisymoon Video Lib

Example

local function renderSplit(offsetX, offsetY)
   -- render all sprites etc
end

local function renderAll()

   local screenW, screenH = video.getScreenSize()

   -- split vertically (one view on the left and one on the right)
   local halfWidth = screenW / 2

   -- render player A's view
   video.setScissorClip(0, 0, halfWidth, screenH)
   renderSplit(0, 0)

   -- render player B's view
   video.setScissorClip(halfWidth, 0, screenW, screenH)
   renderSplit(halfWidth, 0)

   -- reset clip
   video.clearScissorClip()

   -- render shared stuff here, such as top layer GUI etc
end
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox