SCM Library
Spherical Cube Map rendering library
 All Classes Files Functions Variables Friends Pages
Public Member Functions | List of all members
scm_image Class Reference

An scm_image represents an SCM data file in use by an scm_scene. More...

#include <scm-image.hpp>

Public Member Functions

 scm_image (scm_system *)
 Initialize a new empty image for use in the given SCM system.
 
 ~scm_image ()
 Finalize this image's SCM file.
 
Configuration modifiers
void set_scm (const std::string &s)
 Configure this image to read data from the named SCM file. More...
 
void set_name (const std::string &s)
 Set the name by which GLSL sampler uniforms may access this image. More...
 
void set_channel (int c)
 Set the channel index for this image. More...
 
void set_normal_min (float k)
 Set the input value to be mapped onto 0 in the output.
 
void set_normal_max (float k)
 Set the input value to be mapped onto 1 in the output.
 
Configuration queries
const std::string & get_scm () const
 
const std::string & get_name () const
 
int get_channel () const
 
float get_normal_min () const
 
float get_normal_max () const
 
bool is_channel (int c) const
 
bool is_height () const
 
Internal Interface
void init_uniforms (GLuint)
 Request and store GLSL uniform locations for this image's parameters.
 
void bind (GLuint, GLuint) const
 Set all GLSL uniform values for this image and bind the cache's texture.
 
void unbind (GLuint) const
 Unbind the cache's texture by binding the texture unit to zero.
 
void bind_page (GLuint, int, int, long long) const
 Set the GLSL uniforms necessary to map a page of texture data. More...
 
void unbind_page (GLuint, int) const
 Set the texture mapping uniforms to reference cache line zero (which is always blank).
 
void touch_page (int, long long) const
 Set the last-used time of a page.
 
float get_page_sample (const double *) const
 Sample this image at the given location, returning a normalized result. More...
 
void get_page_bounds (long long, float &, float &) const
 Determine the minimum and maximum values of one page, returning a normalized result. More...
 
bool get_page_status (long long) const
 Return true if a page is present in this image. More...
 

Detailed Description

An scm_image represents an SCM data file in use by an scm_scene.

This object is largely responsible for mapping SCM data onto OpenGL state, including OpenGL textures and GLSL uniforms. Notably, this includes those parameters mapping texture coordinates onto a scm_cache texture atlas.

Member Function Documentation

void scm_image::set_scm ( const std::string &  s)

Configure this image to read data from the named SCM file.

This method can have ripple effects throughout the SCM system...

  1. If this image was previously configured to read from a different SCM, then that SCM is released. This might trigger the destruction of an scm_file if its reference count goes to zero, and might also trigger the destruction of an scm_cache if the file count of that cache goes to zero. In the event of an scm_cache destruction, all of that cache's loader threads are asked to exit and waited upon.
    See Also
    scm_system::release_scm
  2. The nemed SCM is aquired. If it is not already open, this will trigger the construction of a new scm_file object, and possibly the construction of an scm_cache. In the event of an scm_cache construction, loader threads for that cache are launched.
    See Also
    scm_system::acquire_scm
    So, while the scm_system makes every effort to minimize the effort of SCM data access, significant setup may be necessary, and it all starts here.
void scm_image::set_name ( const std::string &  s)

Set the name by which GLSL sampler uniforms may access this image.

The name "height" indicates that this image gives height map data, and that an subsequent ground-level queries may use this image.

See Also
scm_scene::get_minimum_ground
scm_scene::get_current_ground
void scm_image::set_channel ( int  c)

Set the channel index for this image.

In this case "channel" indicates left-eye (0), right-eye (1), etc. rather than red (0), green (1), or similar.

void scm_image::bind_page ( GLuint  program,
int  d,
int  t,
long long  i 
) const

Set the GLSL uniforms necessary to map a page of texture data.

Parameters
programGLSL program object
dSCM page depth.
tCurrent time
iSCM page index.
float scm_image::get_page_sample ( const double *  v) const

Sample this image at the given location, returning a normalized result.

See Also
scm_scene::get_page_sample
void scm_image::get_page_bounds ( long long  i,
float &  r0,
float &  r1 
) const

Determine the minimum and maximum values of one page, returning a normalized result.

See Also
scm_scene::get_page_bounds
bool scm_image::get_page_status ( long long  i) const

Return true if a page is present in this image.

See Also
scm_scene::get_page_status

The documentation for this class was generated from the following files: