Easy3D 2.6.1
Loading...
Searching...
No Matches
OpenglUtil Class Reference

Utilities for OpenGL initialization and states query. More...

#include <easy3d/renderer/opengl_util.h>

Static Public Member Functions

static bool init ()
 Initialize OpenGL.
 
static bool is_initialized ()
 Check if OpenGL is initialized.
 
static int gl_profile ()
 Get the OpenGL profile.
 
static bool is_supported (const std::string &name)
 Check if a specific OpenGL feature is supported.
 
static bool has_extension (const std::string &name)
 Check if a specific OpenGL extension is available.
 
static std::string glew_version ()
 Get the GLEW version.
 
static std::string gl_vendor ()
 Get the OpenGL vendor.
 
static std::string gl_renderer ()
 Get the OpenGL renderer.
 
static std::string gl_version ()
 Get the OpenGL version.
 
static std::string gl_extensions ()
 Get the OpenGL extensions.
 
static std::string glsl_version ()
 Get the GLSL version.
 
static int gl_major_version ()
 Get the major version of OpenGL.
 
static int gl_minor_version ()
 Get the minor version of OpenGL.
 
static float glew_version_number ()
 Get the GLEW version number.
 
static float gl_version_number ()
 Get the OpenGL version number.
 
static float glsl_version_number ()
 Get the GLSL version number.
 
static int samples ()
 Get the number of samples.
 
static void viewport (int &x, int &y, int &width, int &height)
 Query the OpenGL viewport. The parameters are the same as in glViewport(x, y, width, height)
 
static int total_gpu_memory ()
 Get the total GPU memory.
 
static int available_gpu_memory ()
 Get the available GPU memory.
 
static void set_output (std::ostream *out)
 Set the output stream for the messages.
 
static void get_current_buffer_info ()
 Get current bound buffer info.
 
static void get_buffer_info (unsigned int target, int bufferName)
 Get the buffer information.
 
static void get_vao_info (unsigned int buffer)
 Get VAO information, including its attributes.
 
static void get_program_info (unsigned int program)
 Get detailed info for a program.
 
static void get_attributes_info (unsigned int program)
 Get detailed info for attributes in a program.
 
static void get_uniforms_info (unsigned int program)
 Get info for all active uniforms in a program.
 
static void get_uniform_info (unsigned int program, const std::string &uniName)
 Get a uniform's value(s).
 
static void get_uniform_in_block_info (unsigned int program, const std::string &blockName, const std::string &uniName)
 Get the values for a uniform in a named block.
 

Detailed Description

Utilities for OpenGL initialization and states query.

Member Function Documentation

◆ available_gpu_memory()

int available_gpu_memory ( )
static

Get the available GPU memory.

Returns
The available GPU memory in MB.

◆ get_attributes_info()

void get_attributes_info ( unsigned int program)
static

Get detailed info for attributes in a program.

display detailed info for attributes in a program

Parameters
programThe program ID.

◆ get_buffer_info()

void get_buffer_info ( unsigned int target,
int bufferName )
static

Get the buffer information.

display the buffer information

Parameters
targetThe target buffer.
bufferNameThe name of the buffer.

◆ get_current_buffer_info()

void get_current_buffer_info ( )
static

Get current bound buffer info.

display current bound buffer info

◆ get_program_info()

void get_program_info ( unsigned int program)
static

Get detailed info for a program.

display detailed info for a program

Parameters
programThe program ID.

◆ get_uniform_in_block_info()

void get_uniform_in_block_info ( unsigned int program,
const std::string & blockName,
const std::string & uniName )
static

Get the values for a uniform in a named block.

display the values for a uniform in a named block

Parameters
programThe program ID.
blockNameThe name of the block.
uniNameThe name of the uniform.

◆ get_uniform_info()

void get_uniform_info ( unsigned int program,
const std::string & uniName )
static

Get a uniform's value(s).

display a uniform's value(s)

Parameters
programThe program ID.
uniNameThe name of the uniform.

◆ get_uniforms_info()

void get_uniforms_info ( unsigned int program)
static

Get info for all active uniforms in a program.

Parameters
programThe program ID.

◆ get_vao_info()

void get_vao_info ( unsigned int buffer)
static

Get VAO information, including its attributes.

display detailed VAO info

Parameters
bufferThe VAO buffer.

◆ gl_extensions()

std::string gl_extensions ( )
static

Get the OpenGL extensions.

Returns
The OpenGL extensions as a string.

◆ gl_major_version()

int gl_major_version ( )
static

Get the major version of OpenGL.

Returns
The major version of OpenGL.

◆ gl_minor_version()

int gl_minor_version ( )
static

Get the minor version of OpenGL.

Returns
The minor version of OpenGL.

◆ gl_profile()

int gl_profile ( )
static

Get the OpenGL profile.

Returns
Either GL_CONTEXT_CORE_PROFILE_BIT or GL_CONTEXT_COMPATIBILITY_PROFILE_BIT.

◆ gl_renderer()

std::string gl_renderer ( )
static

Get the OpenGL renderer.

Returns
The OpenGL renderer as a string.

◆ gl_vendor()

std::string gl_vendor ( )
static

Get the OpenGL vendor.

Returns
The OpenGL vendor as a string.

◆ gl_version()

std::string gl_version ( )
static

Get the OpenGL version.

Returns
The OpenGL version as a string.

◆ gl_version_number()

float gl_version_number ( )
static

Get the OpenGL version number.

Returns
The OpenGL version number.

◆ glew_version()

std::string glew_version ( )
static

Get the GLEW version.

Returns
The GLEW version as a string.

◆ glew_version_number()

float glew_version_number ( )
static

Get the GLEW version number.

Returns
The GLEW version number.

◆ glsl_version()

std::string glsl_version ( )
static

Get the GLSL version.

Returns
The GLSL version as a string.

◆ glsl_version_number()

float glsl_version_number ( )
static

Get the GLSL version number.

Returns
The GLSL version number.

◆ has_extension()

bool has_extension ( const std::string & name)
static

Check if a specific OpenGL extension is available.

Parameters
nameThe name of the extension, e.g., "GL\_EXT\_framebuffer\_object".
Returns
true if the extension is available, false otherwise.

◆ init()

bool init ( )
static

Initialize OpenGL.

Returns
true if initialization is successful, false otherwise.
Examples
Tutorial_203_Viewer_wxWidgets/main.cpp, and Tutorial_204_Viewer_Qt/main.cpp.

◆ is_initialized()

bool is_initialized ( )
static

Check if OpenGL is initialized.

Returns
true if OpenGL is initialized, false otherwise.

◆ is_supported()

bool is_supported ( const std::string & name)
static

Check if a specific OpenGL feature is supported.

Parameters
nameThe name of the feature, e.g., "GL\_VERSION\_3\_2", "GL\_ARB\_vertex\_array\_object".
Returns
true if the feature is supported, false otherwise.

◆ samples()

int samples ( )
static

Get the number of samples.

Returns
The number of samples.
Examples
Tutorial_203_Viewer_wxWidgets/main.cpp.

◆ set_output()

void set_output ( std::ostream * out)
static

Set the output stream for the messages.

Parameters
outThe output stream. If null, LOG(INFO) is the default output stream.

◆ total_gpu_memory()

int total_gpu_memory ( )
static

Get the total GPU memory.

Returns
The total GPU memory in MB. Returns 0 if the query fails.
Note
OpenGL >= 2.0 is required. Currently, only NVidia GPUs are supported.

◆ viewport()

void viewport ( int & x,
int & y,
int & width,
int & height )
static

Query the OpenGL viewport. The parameters are the same as in glViewport(x, y, width, height)

Parameters
xThe lower left corner x-coordinate of the viewport rectangle, in pixels.
yThe lower left corner y-coordinate of the viewport rectangle, in pixels.
widthThe width of the viewport.
heightThe height of the viewport.
Examples
Tutorial_203_Viewer_wxWidgets/main.cpp.

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