The background class. More...
#include <VR3Background.h>
Public Member Functions | |
Constructor and Destructor | |
VR3Background (VR3Scene *scene) | |
Constructor of the class. | |
~VR3Background () | |
Destructor of the class. | |
Background Set and Get Functions | |
void | SetBackground (const char *file_name, bool fl_skybox) |
Sets the current background. | |
VR3Texture * | GetBackground () |
Gets the current background. | |
Draw Method | |
void | Draw () |
Draw method. | |
Private Member Functions | |
VR3Background (const VR3Background &) | |
Disable default copy constructor. | |
VR3Background & | operator= (const VR3Background &) |
Disable default assignment operator. | |
VAO and VBOs Preparation Function | |
void | PrepareVAO () |
Prepares the VAO for the background. | |
Private Attributes | |
bool | m_fl_skybox |
Flag stating if the background object is a skybox. | |
VR3Texture * | m_texture |
Texture used to build the background image or skybox. | |
GLuint | m_shader_program |
Shader program to be used to render the background. | |
const GLint * | m_unilocs |
Pointer to the uniform location array defined for the program. | |
VR3Scene * | m_scene |
The scene object containing this background object. | |
GLuint | m_VAO |
VAO associated with the background. | |
GLuint | m_VBO |
Mesh VBO associated with the above VAO (vertex attributes) |
The background class.
This class represents the background for a given scene, the only entity that owns instances of this class is the VR3Scene class. The user should not have direct access to this class. A background object may either be a simple image drawn on a background plane, or a skybox drawn on a background cube that responds to the camera movements.
Definition at line 34 of file VR3Background.h.
VR3Background::VR3Background | ( | const VR3Background & | ) | [private] |
Disable default copy constructor.
VR3Background::VR3Background | ( | VR3Scene * | scene ) |
Constructor of the class.
A new VR3Background object is created with a null texture image, in this state the background is disabled. The constructor takes as argument the scene object that holds this background object (enabling fast callbacks).
[in] | scene | The scene object containing this background object |
VR3Background::~VR3Background | ( | ) |
Destructor of the class.
Deletes a VR3Background object. The VR3TextureManager is used to avoid deletion of VR3Texture objects or VR3CubeMap objects that are being used by some other entities.
void VR3Background::Draw | ( | ) |
Draw method.
This function is used to draw the background and is directly called when a scene Begin() function is called. The drawing occours differently if the background is a simple 2D image or a cube map.
VR3Texture* VR3Background::GetBackground | ( | ) |
Gets the current background.
The currently active background is returned as a VR3Texture object. The user obtains a new reference to a texture object and the VR3TextureManager is notified accordingly. The user will have to destroy() the obtained object when done.
VR3Background& VR3Background::operator= | ( | const VR3Background & | ) | [private] |
Disable default assignment operator.
void VR3Background::PrepareVAO | ( | ) | [private] |
Prepares the VAO for the background.
The VAO to be used to draw the background will always have the vertex positions and the background texture coordinates (eventually cube map coordinates). This function is used to prepare the VAO with the two required VBOs and send the data to the GL.
void VR3Background::SetBackground | ( | const char * | file_name, |
bool | fl_skybox | ||
) |
Sets the current background.
A new background image or skybox can be specified by using this function, a new VR3Texture object is generated or received from the VR3TextureManager that represents the background image or cube map. A flag is used to specify if a cubemap must be built or a standard texture. The VR3TextureManager static module is used to avoid loading the file if it was already loaded. If the file_name parameter is set to 0, the VR3Background state is resetted to the initial one (no background).
[in] | file_name | The file containing the image |
[in] | fl_skybox | true if the background is a skybox, false otherways |
bool VR3Background::m_fl_skybox [private] |
Flag stating if the background object is a skybox.
Definition at line 37 of file VR3Background.h.
VR3Scene* VR3Background::m_scene [private] |
The scene object containing this background object.
Definition at line 47 of file VR3Background.h.
GLuint VR3Background::m_shader_program [private] |
Shader program to be used to render the background.
Definition at line 42 of file VR3Background.h.
VR3Texture* VR3Background::m_texture [private] |
Texture used to build the background image or skybox.
Definition at line 39 of file VR3Background.h.
const GLint* VR3Background::m_unilocs [private] |
Pointer to the uniform location array defined for the program.
Definition at line 44 of file VR3Background.h.
GLuint VR3Background::m_VAO [private] |
VAO associated with the background.
Definition at line 50 of file VR3Background.h.
GLuint VR3Background::m_VBO [private] |
Mesh VBO associated with the above VAO (vertex attributes)
Definition at line 52 of file VR3Background.h.