SetScissorClip

From OxeyeWiki

(Difference between revisions)
Jump to: navigation, search
(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...')
 
(One intermediate revision not shown)
Line 1: Line 1:
{{VideoMethod
{{VideoMethod
|
|
-
video.setScissorClip(x, y, width, height)
+
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.
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.
Line 9: Line 9:
Use [[clearScissorClip]] to reset the clip again.
Use [[clearScissorClip]] to reset the clip again.
|
|
-
{{MethodParam|x|An integer|The left edge of the rectangle.}}
+
{{MethodParam|left|An integer|The left edge of the rectangle (inclusive).}}
-
{{MethodParam|y|An integer|The top edge of the rectangle.}}
+
{{MethodParam|top|An integer|The top edge of the rectangle (inclusive).}}
-
{{MethodParam|width|An integer|The width of the rectangle.}}
+
{{MethodParam|right|An integer|The right edge of the rectangle (exclusive).}}
-
{{MethodParam|height|An integer|The height of the rectangle.}}
+
{{MethodParam|bottom|An integer|The bottom edge of the rectangle (exclusive).}}
|
|
Returns nothing.
Returns nothing.

Latest revision as of 02:05, 25 January 2010

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