Quick Links
  • Homepage
        - Overview
        - Download
        - Screenshots
        - Community
  • Code Sample Pack
  • Reference Guide
  • Changelog
  • Overview of GLSL Hacker
  • Live Coding
  • Hack your first GLSL Code
  • Moon3D




  • GLSL Hacker Articles

    > Compute shaders on Radeon
    > Distance functions in GLSL
    > GLSL Interpolation Qualifiers
    > Tessellation Spacing Modes
    > Normal Visualizer with GS
    > 3D Surface Plots
    > Normal Mapping
    > Circle and Disc in GLSL
    > PhysX 3 Flag Demo
    > GLSL Hacker on Raspberry Pi
    GLSL Hacker

    Reference Guide
    Host-API Lua / Python



    » Back to Homepage
    » Back to Developer's Guide Index

    gh_renderer Library


    Description
    gh_renderer is the module that talks directly with the graphics hardware.

    Number of functions: 48

    gh_renderer.set_vsync

    Description
    Enables or disables the vertical synchronization.

    Languages: Lua - Python

    Parameters
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.set_vsync(0)


    gh_renderer.point

    Description
    Enables the POINT rendering mode.

    Languages: Lua - Python

    Code sample :

    gh_renderer.point()


    gh_renderer.wireframe

    Description
    Enables the WIREFRAME (or LINE) rendering mode.

    Languages: Lua - Python

    Code sample :

    gh_renderer.wireframe()


    gh_renderer.solid

    Description
    Enables the SOLID rendering mode.

    Languages: Lua - Python

    Code sample :

    gh_renderer.solid()


    gh_renderer.get_opengl_error

    Description
    Returns the OpenGL error code or 0 if no error.

    Languages: Lua - Python

    Return Values
  • error [INTEGER]: error code.

    Code sample :

    err_code = gh_renderer.get_opengl_error()


    gh_renderer.set_viewport

    Description
    Sets the viewport.

    Languages: Lua - Python

    Parameters
  • x, y [INTEGER]: viewport offsets.
  • width, height [INTEGER]: viewport size.

    Code sample :

    gh_renderer.set_viewport(0, 0, width, height)


    gh_renderer.set_scissor

    Description
    Sets the scissor rectangle.

    Languages: Lua - Python

    Parameters
  • x, y [INTEGER]: scissor rectangle offsets.
  • width, height [INTEGER]: scissor rectangle size.

    Code sample :

    gh_renderer.set_scissor(0, 0, width, height)


    gh_renderer.set_viewport_scissor

    Description
    Sets the viewport and the scissor rectangle in the same call.

    Languages: Lua - Python

    Parameters
  • x, y [INTEGER]: offsets.
  • width, height [INTEGER]: viewport and scissor rectangle size.

    Code sample :

    gh_renderer.set_viewport_scissor(0, 0, width, height)


    gh_renderer.set_viewport_scissor_ptr

    Description
    Sets the viewport and the scissor rectangle in the same call.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • x, y [INTEGER]: offsets.
  • width, height [INTEGER]: viewport and scissor rectangle size.

    Code sample :

    gh_renderer.set_viewport_scissor_ptr(R_ptr, 0, 0, width, height)


    gh_renderer.set_scissor_state

    Description
    Enables or disable the scissor test.

    Languages: Lua - Python

    Parameters
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.set_scissor_state(1)


    gh_renderer.clear_color_buffer

    Description
    Clear the color buffer with a RGBA color.

    Languages: Lua - Python

    Parameters
  • r, g, b, a [CLAMPED_REAL]: RGBA clear color.

    Code sample :

    gh_renderer.clear_color_buffer(0, 0, 0, 1)


    gh_renderer.clear_color_buffer_ptr

    Description
    Clear the color buffer with a RGBA color.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • r, g, b, a [CLAMPED_REAL]: RGBA clear color.

    Code sample :

    gh_renderer.clear_color_buffer_ptr(R_ptr, 0, 0, 0, 1)


    gh_renderer.clear_depth_buffer

    Description
    Clear the depth buffer.

    Languages: Lua - Python

    Parameters
  • z [CLAMPED_REAL]: z buffer value.

    Code sample :

    z = 1.0
    gh_renderer.clear_depth_buffer(z)


    gh_renderer.clear_depth_buffer_ptr

    Description
    Clear the depth buffer.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • z [CLAMPED_REAL]: z buffer value.

    Code sample :

    z = 1.0
    gh_renderer.clear_depth_buffer_ptr(R_ptr, z)


    gh_renderer.clear_color_depth_buffers

    Description
    Clear the color and depth buffers in the same call.

    Languages: Lua - Python

    Parameters
  • r, g, b, a [CLAMPED_REAL]: RGBA clear color.
  • z [CLAMPED_REAL]: z buffer value.

    Code sample :

    gh_renderer.clear_color_depth_buffers(r, g, b, a, z)


    gh_renderer.clear_color_depth_buffers_ptr

    Description
    Clear the color and depth buffers in the same call.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • r, g, b, a [CLAMPED_REAL]: RGBA clear color.
  • z [CLAMPED_REAL]: z buffer value.

    Code sample :

    gh_renderer.clear_color_depth_buffers_ptr(R_ptr, r, g, b, a, z)


    gh_renderer.set_depth_test_state

    Description
    Enables or disable the depth test.

    Languages: Lua - Python

    Parameters
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.set_depth_test_state(1)


    gh_renderer.set_depth_test_state_ptr

    Description
    Enables or disable the depth test.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.set_depth_test_state_ptr(R_ptr, 1)


    gh_renderer.set_depth_test_func

    Description
    Sets the depth test function.

    Languages: Lua - Python

    Parameters
  • func_type [INTEGER]: depth test comparison function:
    • CMP_FUNC_NEVER = 0
    • CMP_FUNC_LESS = 1
    • CMP_FUNC_LESS_OR_EQUAL = 2
    • CMP_FUNC_GREATER = 3
    • CMP_FUNC_GREATER_OR_EQUAL = 4
    • CMP_FUNC_EQUAL = 5
    • CMP_FUNC_NOT_EQUAL = 6
    • CMP_FUNC_ALWAYS = 7


    Code sample :

    local CMP_FUNC_LESS = 1
    gh_renderer.set_depth_test_func(CMP_FUNC_LESS)


    gh_renderer.rasterizer_set_cull_state

    Description
    Enables or disable the face culling state.

    Languages: Lua - Python

    Parameters
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.rasterizer_set_cull_state(1)


    gh_renderer.rasterizer_set_cull_face

    Description
    Sets the face type to be culled.

    Languages: Lua - Python

    Parameters
  • face [INTEGER]: type of face: back (0), front (1) or back_and_front (2).

    Code sample :

    local BACK_FACE = 0
    gh_renderer.rasterizer_set_cull_face(BACK_FACE)
    gh_renderer.rasterizer_set_cull_state(1)


    gh_renderer.rasterizer_set_polygon_mode

    Description
    Sets the polygon rendering mode.

    Languages: Lua - Python

    Parameters
  • face [INTEGER]: type of face: back (0), front (1) or back_and_front (2).
  • mode [INTEGER]: polygon rendering mode: point (0), line (1) or solid (2).

    Code sample :

    local BACK_FRONT_FACE = 2
    local LINE = 1
    gh_renderer.rasterizer_set_polygon_mode(BACK_FRONT_FACE, LINE)


    gh_renderer.rasterizer_set_polygon_mode_ptr

    Description
    Sets the polygon rendering mode.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • face [INTEGER]: type of face: back (0), front (1) or back_and_front (2).
  • mode [INTEGER]: polygon rendering mode: point (0), line (1) or solid (2).

    Code sample :

    local BACK_FRONT_FACE = 2
    local LINE = 1
    gh_renderer.rasterizer_set_polygon_mode_ptr(R_ptr, BACK_FRONT_FACE, LINE)


    gh_renderer.rasterizer_apply_states

    Description
    Applies all states modified with gh_renderer.rasterizer_xxxx() functions.

    Languages: Lua - Python

    Code sample :

    local BACK_FACE = 0
    gh_renderer.rasterizer_set_cull_face(BACK_FACE)
    gh_renderer.rasterizer_set_cull_state(0)
    local BACK_FRONT_FACE = 2
    local LINE = 1
    gh_renderer.rasterizer_set_polygon_mode(BACK_FRONT_FACE, LINE)
    gh_renderer.rasterizer_apply_states()


    gh_renderer.rasterizer_apply_states_ptr

    Description
    Applies all states modified with gh_renderer.rasterizer_xxxx() functions.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.

    Code sample :

    local BACK_FRONT_FACE = 2
    local LINE = 1
    gh_renderer.rasterizer_set_polygon_mode_ptr(R_ptr, BACK_FRONT_FACE, LINE)
    gh_renderer.rasterizer_apply_states_ptr(R_ptr)


    gh_renderer.set_blending_state

    Description
    Enables or disables the color blending.

    Languages: Lua - Python

    Parameters
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.set_blending_state(1)


    gh_renderer.set_blending_state_ptr

    Description
    Enables or disables the color blending.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.set_blending_state_ptr(R_ptr, 1)


    gh_renderer.set_blending_factors

    Description
    Sets the source and destination blending factors.

    Languages: Lua - Python

    Parameters
  • src [INTEGER]: source factor. Possible values for source and destination factors:
    • RENDERER_BLEND_FACTOR_ZERO = 0
    • BLEND_FACTOR_ONE = 1
    • BLEND_FACTOR_SRC_ALPHA = 2
    • BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 3
    • BLEND_FACTOR_ONE_MINUS_DST_COLOR = 4
    • BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 5
    • BLEND_FACTOR_DST_COLOR = 6
    • BLEND_FACTOR_DST_ALPHA = 7
    • BLEND_FACTOR_SRC_COLOR = 8
    • BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 9
  • dst [INTEGER]: destination factor. For possible values, see the source factor.

    Code sample :

    local BLEND_FACTOR_ONE = 1
    gh_renderer.set_blending_factors(BLEND_FACTOR_ONE, BLEND_FACTOR_ONE)
    gh_renderer.set_blending_state(1)


    gh_renderer.set_blending_factors_ptr

    Description
    Sets the source and destination blending factors.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • src [INTEGER]: source factor. Possible values for source and destination factors:
    • RENDERER_BLEND_FACTOR_ZERO = 0
    • BLEND_FACTOR_ONE = 1
    • BLEND_FACTOR_SRC_ALPHA = 2
    • BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 3
    • BLEND_FACTOR_ONE_MINUS_DST_COLOR = 4
    • BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 5
    • BLEND_FACTOR_DST_COLOR = 6
    • BLEND_FACTOR_DST_ALPHA = 7
    • BLEND_FACTOR_SRC_COLOR = 8
    • BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 9
  • dst [INTEGER]: destination factor. For possible values, see the source factor.

    Code sample :

    local BLEND_FACTOR_ONE = 1
    gh_renderer.set_blending_factors_ptr(R_ptr, BLEND_FACTOR_ONE, BLEND_FACTOR_ONE)
    gh_renderer.set_blending_state_ptr(R_ptr, 1)


    gh_renderer.update_fixed_mvp_matrices

    Description
    Updates the fixed modelview and projection matrices from a camera and an object. No GPU program is required for the rendering of the object.

    Languages: Lua - Python

    Parameters
  • camera_id [INTEGER]: camera identifier.
  • object_id [INTEGER]: object identifier.

    Code sample :

    gh_renderer.update_fixed_mvp_matrices(camera_id, object_id)


    gh_renderer.update_fixed_mvp_matrices_ptr

    Description
    Updates the fixed modelview and projection matrices from a camera and an object. No GPU program is required for the rendering of the object.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • camera_ptr [POINTER]: pointer on the camera node.
  • object_ptr [POINTER]: pointer on the object node.

    Code sample :

    gh_renderer.update_fixed_mvp_matrices_ptr(R_ptr, camera_ptr, object_ptr)


    gh_renderer.get_api_version_major

    Description
    Gets OpenGL major version number.

    Languages: Lua - Python

    Return Values
  • major [INTEGER]: major version

    Code sample :

    glmajor = gh_renderer.get_api_version_major()
    if (glmajor < 4) then
    -- Tessellation not supported
    end


    gh_renderer.get_api_version_minor

    Description
    Gets OpenGL minor version number.

    Languages: Lua - Python

    Return Values
  • minor [INTEGER]: minor version

    Code sample :

    glminor = gh_renderer.get_api_version_minor()


    gh_renderer.get_api_version

    Description
    Gets the OpenGL version.

    Languages: Lua - Python

    Return Values
  • version [STRING]: OpenGL version

    Code sample :

    glversion = gh_renderer.get_api_version()


    gh_renderer.get_renderer_model

    Description
    Gets the model of the renderer (the name of the graphics card).

    Languages: Lua - Python

    Return Values
  • model [STRING]: Renderer model

    Code sample :

    glrenderer = gh_renderer.get_renderer_model()


    gh_renderer.get_renderer_vendor

    Description
    Gets the vendor of the renderer (the name of the graphics card GPU maker).

    Languages: Lua - Python

    Return Values
  • vendor [STRING]: Renderer vendor

    Code sample :

    glvendor = gh_renderer.get_renderer_vendor()


    gh_renderer.get_shading_language_version

    Description
    Gets the GLSL version.

    Languages: Lua - Python

    Return Values
  • version [STRING]: GLSL version

    Code sample :

    glsl_version = gh_renderer.get_shading_language_version()


    gh_renderer.get_num_opengl_extensions

    Description
    Returns the number of OpenGL extensions.

    Languages: Lua - Python

    Return Values
  • num [INTEGER]: number of OpenGL extensions

    Code sample :

    num_extensions = gh_renderer.get_num_opengl_extensions()


    gh_renderer.get_opengl_extension

    Description
    Returns the name of a particular OpenGL extension.

    Languages: Lua - Python

    Parameters
  • index [INTEGER]: index of the OpenGL extension: from 0 to get_num_opengl_extensions()-1.

    Return Values
  • name [STRING]: OpenGL extension name

    Code sample :

    index = 0
    gl_extension = gh_renderer.get_opengl_extension(index)


    gh_renderer.check_opengl_extension

    Description
    Checks if a particular OpenGL extension is exposed.

    Languages: Lua - Python

    Parameters
  • extension_name [STRING]: name of the extension.

    Return Values
  • name [STRING]: OpenGL extension name

    Code sample :

    if (gh_renderer.check_opengl_extension("GL_ARB_compute_shader") == 1) then
    -- OpenGL 4.3 compute shaders are supported.
    end


    gh_renderer.set_texture2d_state

    Description
    Enables or disable the texturing state of the fixed pipeline.

    Languages: Lua - Python

    Parameters
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.set_texture2d_state(state)


    gh_renderer.set_texture2d_state_ptr

    Description
    Enables or disable the texturing state of the fixed pipeline.

    Languages: Lua - Python

    Parameters
  • R_ptr [POINTER]: pointer on the current renderer.
  • state [INTEGER]: enabled (1) or disabled (0).

    Code sample :

    gh_renderer.set_texture2d_state_ptr(R_ptr, state)


    gh_renderer.display_progress_bar

    Description
    Renders a progress bar. The progress bar percent is set with gh_utils.set_progress_bar_percent(). Both functions can be used in an INIT script to draw a progress bar while loading data.

    Languages: Lua - Python

    Parameters
  • percent [REAL]: size of the progress bar: 100% means the window width.

    Code sample :

    gh_utils.set_progress_bar_percent(20)
    gh_renderer.display_progress_bar()
    ...
    ... do some stuff
    ...
    gh_utils.set_progress_bar_percent(60)
    gh_renderer.display_progress_bar()
    ...
    ... do some stuff
    ...
    gh_utils.set_progress_bar_percent(100)
    gh_renderer.display_progress_bar()



    gh_renderer.set_virtual_screen

    Description
    Sets the current virtual screen (Mac OS X only).

    Languages: Lua - Python

    Parameters
  • screen [INTEGER]: current virtual screen

    Code sample :

    gh_renderer.set_virtual_screen(screen)


    gh_renderer.get_virtual_screen

    Description
    Gets the current virtual screen (Mac OS X only).

    Languages: Lua - Python

    Return Values
  • screen [INTEGER]: current virtual screen

    Code sample :

    screen = gh_renderer.get_virtual_screen(ac_buffer, index)


    gh_renderer.get_num_virtual_screens

    Description
    Gets the number of virtual screens (Mac OS X only).

    Languages: Lua - Python

    Return Values
  • num_screens [INTEGER]: number of virtual screens

    Code sample :

    num_screens = gh_renderer.get_num_virtual_screens()


    gh_renderer.update_virtual_screen

    Description
    Updates the virtual screen. Call this function after a change of virtual screen (Mac OS X only).

    Languages: Lua - Python

    Code sample :

    gh_renderer.update_virtual_screen()


    gh_renderer.memory_barrier

    Description
    Based on OpenGL glMemoryBarrier: defines a barrier ordering memory transactions.

    Languages: Lua - Python

    Parameters
  • mask [STRING]: mask description

    Code sample :

    mask = "GL_SHADER_STORAGE_BARRIER_BIT​ GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT"
    gh_renderer.memory_barrier(mask)





  • (C)2012-2014 Geeks3D