Easy3D 2.6.1
Loading...
Searching...
No Matches
easy3d::opengl Namespace Reference

OpenGL-related functionalities for reading pixel/depth data from the framebuffer. More...

Functions

bool check_gl_error (const std::string &file, const std::string &function, int line, std::ostream &os=std::cerr)
 Checks the last OpenGL error.
 
bool check_frame_buffer_error (const std::string &file, const std::string &function, int line, std::ostream &os=std::cerr)
 Checks the last framebuffer error.
 
bool gl_error (std::string &msg)
 Checks if there was an OpenGL error. If there was an error, the error message will be stored in "msg".
 
bool frame_buffer_error (std::string &msg)
 Checks if there was a framebuffer error. If there was an error, the error message will be stored in "msg".
 
void setup_gl_debug_callback ()
 Set up a debug callback for OpenGL.
 
void read_color (unsigned char rgba[4], int x, int y)
 Read color value at pixel (x, y) from the current non-multisample framebuffer.
 
void read_color_ms (unsigned char rgba[4], int x, int y)
 Read color value at pixel (x, y) from the current multisample framebuffer.
 
void read_depth (float &depth, int x, int y)
 Read depth value at pixel (x, y) from the current non-multisample framebuffer.
 
void read_depth_ms (float &depth, int x, int y)
 Read depth value at pixel (x, y) from the current multisample framebuffer.
 
void read_color (std::vector< unsigned char > &buffer, unsigned int format, bool flip_vertically=true)
 Read color data of the current non-multisample framebuffer into a specified buffer.
 
void read_color_ms (std::vector< unsigned char > &buffer, unsigned int format, bool flip_vertically=true)
 Read color data of the current multisample framebuffer into a specified buffer.
 
void snapshot_color (const std::string &file_name)
 Snapshot the color render buffer of the current non-multisample framebuffer into an image file. This is very useful for debugging.
 
void snapshot_color_ms (const std::string &file_name)
 Snapshot the color render buffer of the current multisample framebuffer into an image file. This is very useful for debugging.
 
void read_depth (std::vector< float > &buffer, bool flip_vertically=true)
 Read the depth data of the current non-multisample framebuffer into a specified buffer.
 
void read_depth_ms (std::vector< float > &buffer, bool flip_vertically=true)
 Read the depth data of the current multisample framebuffer into a specified buffer.
 
void snapshot_depth (const std::string &file_name)
 Snapshot the depth render buffer of the current non-multisample framebuffer into an image file. This is very useful for debugging.
 
void snapshot_depth_ms (const std::string &file_name)
 Snapshot the depth render buffer of the current multisample framebuffer into an image file. This is very useful for debugging.
 

Detailed Description

OpenGL-related functionalities for reading pixel/depth data from the framebuffer.

For multisample-version functions, a normal framebuffer is created for bliting color/depth from the multisample framebuffer object. For high-frequent queries, you'd better create a normal fbo for bliting operations. This way, you can avoid frequently allocating and deallocating GPU memories.

Function Documentation

◆ check_frame_buffer_error()

bool check_frame_buffer_error ( const std::string & file,
const std::string & function,
int line,
std::ostream & os = std::cerr )

Checks the last framebuffer error.

Parameters
fileThe file name where the error occurred.
functionThe function name where the error occurred.
lineThe line number where the error occurred.
osThe output stream to write the error message. Default is std::cerr.
Returns
false if an error indeed occurred.
See also
check_gl_error.

◆ check_gl_error()

bool check_gl_error ( const std::string & file,
const std::string & function,
int line,
std::ostream & os = std::cerr )

Checks the last OpenGL error.

Parameters
fileThe file name where the error occurred.
functionThe function name where the error occurred.
lineThe line number where the error occurred.
osThe output stream to write the error message. Default is std::cerr.
Returns
false if an error indeed occurred.
See also
check_frame_buffer_error.

◆ frame_buffer_error()

bool frame_buffer_error ( std::string & msg)

Checks if there was a framebuffer error. If there was an error, the error message will be stored in "msg".

Parameters
msgThe error message.
Returns
false if an error occurred.
See also
frame_buffer_error.

◆ gl_error()

bool gl_error ( std::string & msg)

Checks if there was an OpenGL error. If there was an error, the error message will be stored in "msg".

Parameters
msgThe error message.
Returns
false if an error occurred.
See also
frame_buffer_error.

◆ read_color() [1/2]

void read_color ( std::vector< unsigned char > & buffer,
unsigned int format,
bool flip_vertically = true )

Read color data of the current non-multisample framebuffer into a specified buffer.

Parameters
bufferThe buffer to store the color data.
formatThe format of the pixel data. Supported formats: GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA.
flip_verticallyFlip the image data vertically if it is true (default value). This is convenient for OpenGL applications where the first pixel in the output array is expected to be the bottom left corner of the image.
See also
read_color_ms.

◆ read_color() [2/2]

void read_color ( unsigned char rgba[4],
int x,
int y )

Read color value at pixel (x, y) from the current non-multisample framebuffer.

Parameters
rgbaThe color value.
xThe x-coordinate of the pixel, represented in the OpenGL coordinate system.
yThe y-coordinate of the pixel, represented in the OpenGL coordinate system.
See also
read_color_ms.

◆ read_color_ms() [1/2]

void read_color_ms ( std::vector< unsigned char > & buffer,
unsigned int format,
bool flip_vertically = true )

Read color data of the current multisample framebuffer into a specified buffer.

Parameters
bufferThe buffer to store the color data.
formatThe format of the pixel data. Supported formats: GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA.
flip_verticallyFlip the image data vertically if it is true (default value). This is convenient for OpenGL applications where the first pixel in the output array is expected to be the bottom left corner of the image.
See also
read_color.

◆ read_color_ms() [2/2]

void read_color_ms ( unsigned char rgba[4],
int x,
int y )

Read color value at pixel (x, y) from the current multisample framebuffer.

Parameters
rgbaThe color value.
xThe x-coordinate of the pixel, represented in the OpenGL coordinate system.
yThe y-coordinate of the pixel, represented in the OpenGL coordinate system.

◆ read_depth() [1/2]

void read_depth ( float & depth,
int x,
int y )

Read depth value at pixel (x, y) from the current non-multisample framebuffer.

Parameters
depthThe depth value.
xThe x-coordinate of the pixel, represented in the OpenGL coordinate system.
yThe y-coordinate of the pixel, represented in the OpenGL coordinate system.
See also
read_depth_ms.

◆ read_depth() [2/2]

void read_depth ( std::vector< float > & buffer,
bool flip_vertically = true )

Read the depth data of the current non-multisample framebuffer into a specified buffer.

Parameters
bufferThe buffer to store the depth data.
flip_verticallyFlip the image data vertically if it is true (default value). This is convenient for OpenGL applications where the first pixel in the output array is expected to be the bottom left corner of the image.
See also
read_depth_ms.

◆ read_depth_ms() [1/2]

void read_depth_ms ( float & depth,
int x,
int y )

Read depth value at pixel (x, y) from the current multisample framebuffer.

Parameters
depthThe depth value.
xThe x-coordinate of the pixel, represented in the OpenGL coordinate system.
yThe y-coordinate of the pixel, represented in the OpenGL coordinate system.
See also
read_depth.

◆ read_depth_ms() [2/2]

void read_depth_ms ( std::vector< float > & buffer,
bool flip_vertically = true )

Read the depth data of the current multisample framebuffer into a specified buffer.

Parameters
bufferThe buffer to store the depth data.
flip_verticallyFlip the image data vertically if it is true (default value). This is convenient for OpenGL applications where the first pixel in the output array is expected to be the bottom left corner of the image.
See also
read_depth.

◆ setup_gl_debug_callback()

void setup_gl_debug_callback ( )

Set up a debug callback for OpenGL.

Note
This has effect only if the working OpenGL version is >= 4.3.
Examples
Tutorial_203_Viewer_wxWidgets/main.cpp, and Tutorial_204_Viewer_Qt/main.cpp.

◆ snapshot_color()

void snapshot_color ( const std::string & file_name)

Snapshot the color render buffer of the current non-multisample framebuffer into an image file. This is very useful for debugging.

Parameters
file_nameThe file name of the image file. Supported formats: png, jpg, bmp, tga, and ppm. File format is determined by the extension of the file name.
See also
snapshot_color_ms.

◆ snapshot_color_ms()

void snapshot_color_ms ( const std::string & file_name)

Snapshot the color render buffer of the current multisample framebuffer into an image file. This is very useful for debugging.

Parameters
file_nameThe file name of the image file. Supported formats: png, jpg, bmp, tga, and ppm. File format is determined by the extension of the file name.
See also
snapshot_color.

◆ snapshot_depth()

void snapshot_depth ( const std::string & file_name)

Snapshot the depth render buffer of the current non-multisample framebuffer into an image file. This is very useful for debugging.

Parameters
file_nameThe file name of the image file. Supported formats: png, jpg, bmp, tga, and ppm. File format is determined by the extension of the file name.
See also
snapshot_depth_ms.

◆ snapshot_depth_ms()

void snapshot_depth_ms ( const std::string & file_name)

Snapshot the depth render buffer of the current multisample framebuffer into an image file. This is very useful for debugging.

Parameters
file_nameThe file name of the image file. Supported formats: png, jpg, bmp, tga, and ppm. File format is determined by the extension of the file name.
See also
snapshot_depth.