Module ncine.viewport
The table containing viewport related functions
Functions
ncine.viewport.new () | Constructs a viewport object. |
ncine.viewport.delete (viewport) | Destroys a viewport object and releases its memory |
ncine.viewport.get_type (viewport) | Returns the viewport type |
ncine.viewport.get_texture (viewport, index) | Returns the texture at the specified viewport’s FBO color attachment index, if any |
ncine.viewport.set_texture (viewport, index, texture) | Adds or removes a texture at the specified viewport’s FBO color attachment index |
ncine.viewport.get_depth_stencil_format (viewport) | Returns the depth and stencil format of the viewport’s FBO renderbuffer |
ncine.viewport.set_depth_stencil_format (viewport, depth_stencil_format) | Sets the depth and stencil format of the viewport’s FBO renderbuffer |
ncine.viewport.remove_all_textures (viewport) | Removes all textures and the depth stencil renderbuffer from the viewport’s FBO |
ncine.viewport.get_width (viewport) | Returns viewport’s FBO width or zero if no texture is present |
ncine.viewport.get_height (viewport) | Returns viewport’s FBO height or zero if no texture is present |
ncine.viewport.get_num_color_attachments (viewport) | Returns the number of color attachments of the viewport’s FBO |
ncine.viewport.get_viewport_rect (viewport) | Returns the OpenGL viewport rectangle |
ncine.viewport.set_viewport_rect (viewport, rect) | Sets the OpenGL viewport rectangle through a ncine.rect table |
ncine.viewport.set_viewport_rect (viewport, x, y, w, h) | Sets the OpenGL viewport rectangle through rectangle components |
ncine.viewport.get_scissor_rect (viewport) | Returns the OpenGL scissor test rectangle |
ncine.viewport.set_scissor_rect (viewport, rect) | Sets the OpenGL scissor test rectangle through a ncine.rect table |
ncine.viewport.set_scissor_rect (viewport, x, y, w, h) | Sets the OpenGL scissor test rectangle through rectangle components |
ncine.viewport.get_culling_rect (viewport) | Returns the rectangle for screen culling |
ncine.viewport.get_last_frame_cleared (viewport) | Returns the last frame this viewport was cleared |
ncine.viewport.get_clear_mode (viewport) | Returns the viewport clear mode |
ncine.viewport.set_clear_mode (viewport, clear_mode) | Sets the viewport clear mode |
ncine.viewport.get_clear_color (viewport) | Returns the viewport clear color as a ncine.color table |
ncine.viewport.set_clear_color (viewport, clear_color) | Sets the viewport clear color through a ncine.color table |
ncine.viewport.set_clear_color (viewport, r, g, b, a) | Sets the viewport clear color through color components |
ncine.viewport.get_rootnode (viewport) | Returns the root node |
ncine.viewport.set_rootnode (viewport, rootnode) | Sets or removes the root node |
ncine.viewport.clear_chain () | Clears the array of viewports to be drawn before the screen |
ncine.viewport.push_back_chain (viewport) | Pushes a viewport to the back of the array of viewports to be drawn before the screen |
ncine.viewport.push_front_chain (viewport) | Pushes a viewport to the front of the array of viewports to be drawn before the screen |
ncine.viewport.get_camera (viewport) | Returns the camera used for rendering |
ncine.viewport.set_camera (viewport, camera) | Sets the camera to be used for rendering |
ncine.viewport.set_glframebuffer_label (viewport, label) | Sets the OpenGL object label for the viewport framebuffer object |
Tables
viewportObj | The light user data of a viewport object |
ncine.viewport_type | Viewport types (enumeration) |
ncine.clear_mode | Clear modes (enumeration) |
ncine.depth_stencil_format | Depth and stencil formats (enumeration) |
Functions
- ncine.viewport.new ()
-
Constructs a viewport object.
Don’t forget to call ncine.viewport.delete when you are done with it!
Returns:
-
viewportObj
A new viewport object
- ncine.viewport.delete (viewport)
-
Destroys a viewport object and releases its memory
Parameters:
- viewport viewportObj The viewport object to be destroyed
- ncine.viewport.get_type (viewport)
-
Returns the viewport type
Parameters:
- viewport viewportObj
Returns:
-
ncine.viewport_type
- ncine.viewport.get_texture (viewport, index)
-
Returns the texture at the specified viewport’s FBO color attachment index, if any
Parameters:
- viewport viewportObj
- index integer
Returns:
-
ncine.texture.textureObj or nil
- ncine.viewport.set_texture (viewport, index, texture)
-
Adds or removes a texture at the specified viewport’s FBO color attachment index
Parameters:
- viewport viewportObj
- index integer
- texture ncine.texture.textureObj or nil
Returns:
-
boolean
True if a texture has been added or removed successfully
- ncine.viewport.get_depth_stencil_format (viewport)
-
Returns the depth and stencil format of the viewport’s FBO renderbuffer
Parameters:
- viewport viewportObj
Returns:
-
ncine.depth_stencil_format
- ncine.viewport.set_depth_stencil_format (viewport, depth_stencil_format)
-
Sets the depth and stencil format of the viewport’s FBO renderbuffer
Parameters:
- viewport viewportObj
- depth_stencil_format ncine.depth_stencil_format
Returns:
-
boolean
True if a new depth and stencil format has been successfully set
- ncine.viewport.remove_all_textures (viewport)
-
Removes all textures and the depth stencil renderbuffer from the viewport’s FBO
Parameters:
- viewport viewportObj
Returns:
-
boolean
True if the viewport is not the screen and all textures have been removed
- ncine.viewport.get_width (viewport)
-
Returns viewport’s FBO width or zero if no texture is present
Parameters:
- viewport viewportObj
Returns:
-
integer
- ncine.viewport.get_height (viewport)
-
Returns viewport’s FBO height or zero if no texture is present
Parameters:
- viewport viewportObj
Returns:
-
integer
- ncine.viewport.get_num_color_attachments (viewport)
-
Returns the number of color attachments of the viewport’s FBO
Parameters:
- viewport viewportObj
Returns:
-
integer
- ncine.viewport.get_viewport_rect (viewport)
-
Returns the OpenGL viewport rectangle
Parameters:
- viewport viewportObj
Returns:
-
ncine.rect
- ncine.viewport.set_viewport_rect (viewport, rect)
-
Sets the OpenGL viewport rectangle through a
ncine.rect
tableParameters:
- viewport viewportObj
- rect ncine.rect
- ncine.viewport.set_viewport_rect (viewport, x, y, w, h)
-
Sets the OpenGL viewport rectangle through rectangle components
Parameters:
- viewport viewportObj
- x integer
- y integer
- w integer
- h integer
- ncine.viewport.get_scissor_rect (viewport)
-
Returns the OpenGL scissor test rectangle
Parameters:
- viewport viewportObj
Returns:
-
ncine.rect
- ncine.viewport.set_scissor_rect (viewport, rect)
-
Sets the OpenGL scissor test rectangle through a
ncine.rect
tableParameters:
- viewport viewportObj
- rect ncine.rect
- ncine.viewport.set_scissor_rect (viewport, x, y, w, h)
-
Sets the OpenGL scissor test rectangle through rectangle components
Parameters:
- viewport viewportObj
- x integer
- y integer
- w integer
- h integer
- ncine.viewport.get_culling_rect (viewport)
-
Returns the rectangle for screen culling
Parameters:
- viewport viewportObj
Returns:
-
ncine.rect
- ncine.viewport.get_last_frame_cleared (viewport)
-
Returns the last frame this viewport was cleared
Parameters:
- viewport viewportObj
Returns:
-
integer
- ncine.viewport.get_clear_mode (viewport)
-
Returns the viewport clear mode
Parameters:
- viewport viewportObj
Returns:
-
ncine.clear_mode
- ncine.viewport.set_clear_mode (viewport, clear_mode)
-
Sets the viewport clear mode
Parameters:
- viewport viewportObj
- clear_mode ncine.clear_mode
- ncine.viewport.get_clear_color (viewport)
-
Returns the viewport clear color as a
ncine.color
tableParameters:
- viewport viewportObj
Returns:
-
ncine.color
- ncine.viewport.set_clear_color (viewport, clear_color)
-
Sets the viewport clear color through a
ncine.color
tableParameters:
- viewport viewportObj
- clear_color ncine.color
- ncine.viewport.set_clear_color (viewport, r, g, b, a)
-
Sets the viewport clear color through color components
Parameters:
- viewport viewportObj
- r number
- g number
- b number
- a number
- ncine.viewport.get_rootnode (viewport)
-
Returns the root node
Parameters:
- viewport viewportObj
Returns:
-
ncine.scenenode.scenenodeObj or nil
- ncine.viewport.set_rootnode (viewport, rootnode)
-
Sets or removes the root node
Parameters:
- viewport viewportObj
- rootnode ncine.scenenode.scenenodeObj or nil
- ncine.viewport.clear_chain ()
- Clears the array of viewports to be drawn before the screen
- ncine.viewport.push_back_chain (viewport)
-
Pushes a viewport to the back of the array of viewports to be drawn before the screen
Parameters:
- viewport viewportObj
- ncine.viewport.push_front_chain (viewport)
-
Pushes a viewport to the front of the array of viewports to be drawn before the screen
Parameters:
- viewport viewportObj
- ncine.viewport.get_camera (viewport)
-
Returns the camera used for rendering
Parameters:
- viewport viewportObj
Returns:
-
ncine.camera.cameraObj or nil
- ncine.viewport.set_camera (viewport, camera)
-
Sets the camera to be used for rendering
Parameters:
- viewport viewportObj
- camera
ncine.camera.cameraObj or nil
Can be
nil
to use the default one
- ncine.viewport.set_glframebuffer_label (viewport, label)
-
Sets the OpenGL object label for the viewport framebuffer object
Parameters:
- viewport viewportObj
- label string
Tables
- viewportObj
- The light user data of a viewport object
- ncine.viewport_type
-
Viewport types (enumeration)
Fields:
- WITH_TEXTURE
- NO_TEXTURE
- SCREEN
- ncine.clear_mode
-
Clear modes (enumeration)
Fields:
- EVERY_DRAW
- EVERY_FRAME
- THIS_FRAME_ONLY
- NEXT_FRAME_ONLY
- NEVER
- ncine.depth_stencil_format
-
Depth and stencil formats (enumeration)
Fields:
- NONE
- DEPTH16
- DEPTH24
- DEPTH24_STENCIL8