Quick Links
- Homepage
- Downloads
- Code Sample Pack
- Gallery
- Forum

Documentation
- Overview
- GLSL Programs
- Live Coding
- Hack your first
  GLSL program

- Reference guide

Follow GLSL Hacker

GLSL Hacker @ Twitter

GLSL Hacker

Reference Guide
Host-API Lua / Python



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

gh_camera Library


Description
gh_camera is the module that manages cameras: creation, destruction, setting the parameters (position, filed of view, etc.).

Number of functions: 12

gh_camera.create_perspective

Description
Creates a perspective camera with default values (fov=60, znear=1, zfar=1000, aspect=win_width/win/height).

Languages: Lua - Python

Parameters
  • pos_x, pos_y, pos_z [REAL]: position of the camera.
  • lookat_x, lookat_y, lookat_z [REAL]: look at point of the camera.

    Return Values
  • camera [INTEGER]: camera identifier

    Code sample :

    camera = gh_camera.create_perspective(0, 20, 0, 0, 0, 0)


    gh_camera.create_persp

    Description
    Creates a perspective camera.

    Languages: Lua - Python

    Parameters
  • fov [REAL]: field of view in degres.
  • aspect [REAL]: aspect ration (usually screen_width / screen_height).
  • znear [REAL]: near clipping plane.
  • zfar [REAL]: far clipping plane.

    Return Values
  • camera [INTEGER]: camera identifier

    Code sample :

    camera = gh_camera.create_persp(60, 1.333, 0.1, 1000.0)


    gh_camera.update_persp

    Description
    Updates a perspective camera.

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.
  • fov [REAL]: field of view in degres.
  • aspect [REAL]: aspect ration (usually screen_width / screen_height).
  • znear [REAL]: near clipping plane.
  • zfar [REAL]: far clipping plane.

    Code sample :

    gh_camera.update_persp(camera, 60, 1.333, 0.1, 1000.0)


    gh_camera.create_orthographic

    Description
    Creates an orthographic camera with default values: left, right, top, bottom are derived from the window size.

    Languages: Lua - Python

    Return Values
  • camera [INTEGER]: camera identifier

    Code sample :

    camera = gh_camera.create_orthographic()


    gh_camera.create_ortho

    Description
    Creates an orthographic camera.

    Languages: Lua - Python

    Parameters
  • left [REAL]: left clipping plane.
  • right [REAL]: right clipping plane.
  • bottom [REAL]: bottom clipping plane.
  • top [REAL]: top clipping plane.
  • znear [REAL]: near clipping plane.
  • zfar [REAL]: far clipping plane.

    Return Values
  • camera [INTEGER]: camera identifier

    Code sample :

    w = screen_width
    h = screen_height
    camera = gh_camera.create_ortho(-w/2, w/2, -h/2, h/2, -1.0, 1.0)


    gh_camera.update_ortho

    Description
    Updates an orthographic camera.

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.
  • left [REAL]: left clipping plane.
  • right [REAL]: right clipping plane.
  • bottom [REAL]: bottom clipping plane.
  • top [REAL]: top clipping plane.
  • znear [REAL]: near clipping plane.
  • zfar [REAL]: far clipping plane.

    Code sample :

    w = screen_width
    h = screen_height
    gh_camera.update_ortho(camera, -w/2, w/2, -h/2, h/2, -1.0, 1.0)


    gh_camera.set_viewport

    Description
    Sets the camera viewport.

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.
  • x [REAL]: x offset - default: 0.
  • y [REAL]: y offset - default: 0.
  • width [REAL]: width of the viewport.
  • height [REAL]: height of the viewport.

    Code sample :

    gh_camera.set_viewport(camera, 0, 0, screen_width, screen_height)


    gh_camera.set_position

    Description
    Sets the camera position.

    Languages: Lua - Python

    Alias: setpos

    Parameters
  • camera [INTEGER]: camera identifier.
  • x, y, z [REAL]: 3D position of the camera.

    Code sample :

    gh_camera.set_position(camera, 0, 10, 20)


    gh_camera.set_lookat

    Description
    Sets the camera look at point (what point in space the camera is looking).

    Languages: Lua - Python

    Alias: setlookat

    Parameters
  • camera [INTEGER]: camera identifier.
  • x, y, z [REAL]: 3D position of that target point.

    Code sample :

    -- Look at the center of the scene:
    gh_camera.set_lookat(camera, 0, 0, 0)


    gh_camera.set_upvec

    Description
    Sets the camera up vector.

    Languages: Lua - Python

    Alias: setupvec

    Parameters
  • camera [INTEGER]: camera identifier.
  • x, y, z [REAL]: direction of the up vector.

    Code sample :

    -- Th up vector is the unit Y axis.
    gh_camera.set_upvec(camera, 0, 1, 0)


    gh_camera.load_fixed_mvp_matrices

    Description
    Loads the fixed projection and (model)view matrices.

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.
  • load_proj_mat [INTEGER]: 1 to load the projection matrix, 0 otherwise.
  • load_view_mat [INTEGER]: 1 to load the view matrix, 0 otherwise.
  • object_id [INTEGER]: Sets the object that will be used to update the modelview matrix. Set it to 0 to not use the object.

    Code sample :

    gh_camera.load_fixed_mvp_matrices(camera, load_proj_mat, load_view_mat, 0)


    gh_camera.bind

    Description
    Bind the camera to the renderer: the viewport and projection/view matrices are applied. Thi sfunction is useful in conjunction with the gh_object.render() function.

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.

    Code sample :

    gh_camera.bind(camera)






  • (C)2012 Geeks3D