SetScissorClip

From OxeyeWiki

(Difference between revisions)
Jump to: navigation, search
Jeb (Talk | contribs)
(Created page with '{{VideoMethod | video.setScissorClip(x, y, width, height) | Sets the video device's "scissor clip" area. This area is a rectangle on the screen in which rendering should be allow...')
Newer edit →

Revision as of 07:50, 5 March 2009

video.setScissorClip(x, y, width, height)

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
x An integer The left edge of the rectangle.
y An integer The top edge of the rectangle.
width An integer The width of the rectangle.
height An integer The height of the rectangle.
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