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_camera Library


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

Number of functions: 16

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)


    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.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_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.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.get_position

    Description
    Gets the camera position.

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.

    Return Values
  • camera [x, y, z]: camera identifier

    Code sample :

    x, y, z = gh_camera.get_position(camera)


    gh_camera.get_view

    Description
    Gets the camera direction (z axis).

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.

    Return Values
  • camera [x, y, z]: camera identifier

    Code sample :

    x, y, z = gh_camera.get_position(camera)


    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, w [REAL]: 4D position of that target point. If w=1, target is a point, otherwise target is a direction

    Code sample :

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


    gh_camera.set_pitch

    Description
    Sets the camera pitch angle (x axis).

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.
  • pitch [REAL]: pitch in degrees.

    Code sample :

    gh_camera.set_pitch(camera, pitch)


    gh_camera.set_position

    Description
    Sets the camera position.

    Languages: Lua - Python

    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_roll

    Description
    Sets the camera roll angle (z axis).

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.
  • roll [REAL]: roll in degrees.

    Code sample :

    gh_camera.set_roll(camera, roll)


    gh_camera.set_upvec

    Description
    Sets the camera up vector.

    Languages: Lua - Python

    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.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_yaw

    Description
    Sets the camera yaw angle (y axis).

    Languages: Lua - Python

    Parameters
  • camera [INTEGER]: camera identifier.
  • yaw [REAL]: yaw in degrees.

    Code sample :

    gh_camera.set_yaw(camera, yaw)


    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.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)





  • (C)2012-2013 Geeks3D