Public Member Functions | Private Attributes
vgui_section_buffer Class Reference

Holds a section of a GL image with given OpenGL buffer format and types. More...

#include <vgui_section_buffer.h>

List of all members.

Public Member Functions

 vgui_section_buffer (unsigned x, unsigned y, unsigned w, unsigned h, GLenum format_=GL_NONE, GLenum type_=GL_NONE)
 Create a w by h buffer.
 ~vgui_section_buffer ()
void set_zoom (float zoomx, float zoomy)
bool draw_as_image (float xlo, float ylo, float xhi, float yhi) const
 These methods take arguments in original image coordinates and return false on failure.
bool draw_as_rectangle (float xlo, float ylo, float xhi, float yhi) const
 Draw a the border of a section of the image.
bool draw_as_image () const
 Convenience method to draw the whole image.
bool draw_viewport_as_image () const
 Draw a precomputed viewport image section using view rendering.
bool draw_as_rectangle () const
 Convenience method to draw the whole image.
void apply (vil1_image const &, vgui_range_map_params_sptr const &)
 Grab a section from the given image.
void apply (vil_image_resource_sptr const &, vgui_range_map_params_sptr const &)
 Grab a section from the given resource.
unsigned width () const
unsigned height () const

Private Attributes

GLenum format_
GLenum type_
unsigned x_
unsigned y_
unsigned w_
unsigned h_
float zoomx_
float zoomy_
unsigned allocw_
unsigned alloch_
void * buffer_
 Pointer to pixel buffer, as given to glDrawPixels() or glTexImage2D().
bool buffer_ok_
 Did the last apply() work?.

Detailed Description

Holds a section of a GL image with given OpenGL buffer format and types.

A section_buffer is an object which holds a section of a GL image with given OpenGL buffer format and types. The constructor is responsible for allocating a suitably sized (and aligned) buffer.

The apply() method infers the format supplied by the vgui_image or vgui_image_view and performs the necessary pixel conversion.

Note that if the format and type are left unspecified, defaults will be chosen based on the current GL state. Thus, in this case, the section buffer should not be created until a GL state has been created.

The 'format' and 'type' arguments describe the image format in OpenGL terms. They are those passed to glDrawPixels(), so that 'format' may be one of GL_COLOR_INDEX, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_RGBA, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_RGB, GL_LUMINANCE, GL_LUMINANCE_ALPHA and extensions such as GL_ABGR_EXT and 'type' may be one of GL_UNSIGNED_BYTE, GL_BYTE, GL_BITMAP, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, and GL_FLOAT

Usually 'format'=GL_RGBA, 'type'=GL_UNSIGNED_BYTE works well.

Definition at line 51 of file vgui_section_buffer.h.


Constructor & Destructor Documentation

vgui_section_buffer::vgui_section_buffer ( unsigned  x,
unsigned  y,
unsigned  w,
unsigned  h,
GLenum  format_ = GL_NONE,
GLenum  type_ = GL_NONE 
)

Create a w by h buffer.

The buffer will be used to hold the GL pixels from (x,y) to (x+w-1, y+w-1) from the input image. (The input image is given via the apply() function).

Definition at line 315 of file vgui_section_buffer.cxx.

vgui_section_buffer::~vgui_section_buffer ( )

Definition at line 370 of file vgui_section_buffer.cxx.


Member Function Documentation

void vgui_section_buffer::apply ( vil1_image const &  image,
vgui_range_map_params_sptr const &  rmp 
)

Grab a section from the given image.

Definition at line 450 of file vgui_section_buffer.cxx.

void vgui_section_buffer::apply ( vil_image_resource_sptr const &  image_in,
vgui_range_map_params_sptr const &  rmp 
)

Grab a section from the given resource.

Definition at line 392 of file vgui_section_buffer.cxx.

bool vgui_section_buffer::draw_as_image ( float  xlo,
float  ylo,
float  xhi,
float  yhi 
) const

These methods take arguments in original image coordinates and return false on failure.

See .cxx file for more details. Draw a section of the image.

The parameters are in the original image coordinates.

It will return false on failure.

Definition at line 537 of file vgui_section_buffer.cxx.

bool vgui_section_buffer::draw_as_image ( ) const

Convenience method to draw the whole image.

Definition at line 552 of file vgui_section_buffer.cxx.

bool vgui_section_buffer::draw_as_rectangle ( float  xlo,
float  ylo,
float  xhi,
float  yhi 
) const

Draw a the border of a section of the image.

The parameters are in the original image coordinates.

It will return false on failure.

Definition at line 510 of file vgui_section_buffer.cxx.

bool vgui_section_buffer::draw_as_rectangle ( ) const

Convenience method to draw the whole image.

Definition at line 526 of file vgui_section_buffer.cxx.

bool vgui_section_buffer::draw_viewport_as_image ( ) const

Draw a precomputed viewport image section using view rendering.

Supports redrawing only visible section during overlay redraw

Definition at line 558 of file vgui_section_buffer.cxx.

unsigned vgui_section_buffer::height ( ) const [inline]

Definition at line 107 of file vgui_section_buffer.h.

void vgui_section_buffer::set_zoom ( float  zoomx,
float  zoomy 
) [inline]

Definition at line 67 of file vgui_section_buffer.h.

unsigned vgui_section_buffer::width ( ) const [inline]

Definition at line 106 of file vgui_section_buffer.h.


Member Data Documentation

unsigned vgui_section_buffer::alloch_ [private]

Definition at line 124 of file vgui_section_buffer.h.

unsigned vgui_section_buffer::allocw_ [private]

Definition at line 124 of file vgui_section_buffer.h.

Pointer to pixel buffer, as given to glDrawPixels() or glTexImage2D().

Definition at line 127 of file vgui_section_buffer.h.

Did the last apply() work?.

Definition at line 130 of file vgui_section_buffer.h.

GLenum vgui_section_buffer::format_ [private]

Definition at line 112 of file vgui_section_buffer.h.

unsigned vgui_section_buffer::h_ [private]

Definition at line 118 of file vgui_section_buffer.h.

GLenum vgui_section_buffer::type_ [private]

Definition at line 113 of file vgui_section_buffer.h.

unsigned vgui_section_buffer::w_ [private]

Definition at line 118 of file vgui_section_buffer.h.

unsigned vgui_section_buffer::x_ [private]

Definition at line 117 of file vgui_section_buffer.h.

unsigned vgui_section_buffer::y_ [private]

Definition at line 117 of file vgui_section_buffer.h.

float vgui_section_buffer::zoomx_ [private]

Definition at line 119 of file vgui_section_buffer.h.

float vgui_section_buffer::zoomy_ [private]

Definition at line 119 of file vgui_section_buffer.h.


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