![]() |
The small3d framework
|
Renderer class (OpenGL 3.3) More...
#include <Renderer.hpp>
Public Member Functions | |
| ~Renderer () | |
| Destructor. | |
| GLFWwindow * | getWindow () const |
| Get the GLFW window object, associated with the Renderer. | |
| void | generateTexture (const std::string &name, const Image &image) |
| Generate a texture on the GPU from the given image. More... | |
| void | generateTexture (const std::string &name, const std::string &text, const glm::vec3 &colour, const int fontSize=48, const std::string &fontPath="resources/fonts/CrusoeText/CrusoeText-Regular.ttf", const bool replace=true) |
| Generate a texture on the GPU that contains the given text. More... | |
| void | deleteTexture (const std::string &name) |
| Deletes the texture indicated by the given name. More... | |
| void | createRectangle (Model &rect, const glm::vec3 &topLeft, const glm::vec3 &bottomRight) |
| Populates a Model object with a rectangle stretching between the given coordinates. More... | |
| void | render (Model &model, const glm::vec3 &offset, const glm::vec3 &rotation, const glm::vec4 &colour, const std::string &textureName="", const bool perspective=true) |
| Render a Model. More... | |
| void | render (Model &model, const glm::vec3 &offset, const glm::vec3 &rotation, const std::string &textureName) |
| Render a Model. More... | |
| void | render (Model &model, const std::string &textureName, const bool perspective=true) |
| Render a Model. More... | |
| void | render (Model &model, const glm::vec4 &colour, const bool perspective=true) |
| Render a Model. More... | |
| void | render (SceneObject &sceneObject, const glm::vec4 &colour) |
| Render a SceneObject. More... | |
| void | render (SceneObject &sceneObject, const std::string &textureName) |
| Render a SceneObject. More... | |
| void | clearBuffers (Model &model) const |
| Clear a Model from the GPU buffers (the Model itself remains intact). More... | |
| void | clearBuffers (SceneObject &sceneObject) const |
| Clear a SceneObject (multiple models) from the GPU buffers (the SceneObject itself remains intact). More... | |
| void | clearScreen () const |
| Clears the screen. | |
| void | clearScreen (const glm::vec4 &colour) const |
| Clears the screen. More... | |
| void | swapBuffers () const |
| This is a double buffered system and this command swaps the buffers. | |
| Renderer (Renderer const &)=delete | |
| void | operator= (Renderer const &)=delete |
| Renderer (Renderer &&)=delete | |
| void | operator= (Renderer &&)=delete |
Static Public Member Functions | |
| static Renderer & | getInstance (const std::string &windowTitle="", const int width=0, const int height=0, const float frustumScale=1.0f, const float zNear=1.0f, const float zFar=24.0f, const float zOffsetFromCamera=-1.0f, const std::string &shadersPath="resources/shaders/", const uint32_t maxObjectsPerPass=20) |
| Get the instance of the Renderer (the Renderer is a singleton). More... | |
Public Attributes | |
| glm::vec3 | lightDirection |
| Vector, indicating the direction of the light in the scene. | |
| glm::vec3 | cameraPosition |
| The camera position in world space. | |
| glm::vec3 | cameraRotation |
| The camera rotation (around the x, y and z axes) | |
| float | lightIntensity = 1.0f |
| The light intensity (set to -1.0f if no lighting is to be used). | |
Renderer class (OpenGL 3.3)
| void small3d::Renderer::clearBuffers | ( | Model & | model | ) | const |
| void small3d::Renderer::clearBuffers | ( | SceneObject & | sceneObject | ) | const |
Clear a SceneObject (multiple models) from the GPU buffers (the SceneObject itself remains intact).
| sceneObject | The scene object |
| void small3d::Renderer::clearScreen | ( | const glm::vec4 & | colour | ) | const |
Clears the screen.
| colour | The colour with which the screen is to be cleared |
| void small3d::Renderer::createRectangle | ( | Model & | rect, |
| const glm::vec3 & | topLeft, | ||
| const glm::vec3 & | bottomRight | ||
| ) |
| void small3d::Renderer::deleteTexture | ( | const std::string & | name | ) |
Deletes the texture indicated by the given name.
| name | The name of the texture. |
| void small3d::Renderer::generateTexture | ( | const std::string & | name, |
| const Image & | image | ||
| ) |
Generate a texture on the GPU from the given image.
| name | The name by which the texture will be known |
| image | The image from which the texture will be generated |
| void small3d::Renderer::generateTexture | ( | const std::string & | name, |
| const std::string & | text, | ||
| const glm::vec3 & | colour, | ||
| const int | fontSize = 48, |
||
| const std::string & | fontPath = "resources/fonts/CrusoeText/CrusoeText-Regular.ttf", |
||
| const bool | replace = true |
||
| ) |
Generate a texture on the GPU that contains the given text.
| name | The name by which the texture will be known |
| text | The text that will be contained in the texture |
| colour | The colour of the text |
| fontSize | The size of the font which will be used |
| fontPath | Path to the TrueType font (.ttf) which will be used |
| replace | If true, an exception will be thrown if a texture with the same name already exists. Otherwise it will be overwritten. |
|
static |
Get the instance of the Renderer (the Renderer is a singleton).
| windowTitle | The title of the game's window |
| width | The width of the window. If width and height are not set or set to 0, the game will run in full screen mode. |
| height | The height of the window |
| frustumScale | How much the frustum scales the items rendered |
| zNear | Projection plane z coordinate (use positive value) |
| zFar | Far end of frustum z coordinate (use positive value) |
| zOffsetFromCamera | The position of the projection plane with regard to the camera. |
| shadersPath | The path where the shaders will be stored, relative to the application's executing directory. It defaults to the path provided by the engine, but it can be changed, so as to accommodate for executables which are going to be using it. Even though the path to the folder can be changed, the folder structure within it and the names of the shaders must remain as provided. The shader code can be changed, provided that their inputs and outputs are maintained the same. |
| maxObjectsPerPass | Ignored parameter (used for compatibility with Vulkan edition). |
| void small3d::Renderer::render | ( | Model & | model, |
| const glm::vec3 & | offset, | ||
| const glm::vec3 & | rotation, | ||
| const glm::vec4 & | colour, | ||
| const std::string & | textureName = "", |
||
| const bool | perspective = true |
||
| ) |
Render a Model.
| model | The model |
| offset | The offset (position) where to draw the model (ignored in orthographic rendering) |
| rotation | Rotation (x, y, z) (ignored in orthographic rendering) |
| colour | The colour of the model |
| textureName | The name of the texture to attach to the model (optional). The texture has to have been generated already. If this is set, the colour parameter will be ignored. |
| perspective | If true perform perspective rendering, otherwise orthographic. |
| void small3d::Renderer::render | ( | Model & | model, |
| const glm::vec3 & | offset, | ||
| const glm::vec3 & | rotation, | ||
| const std::string & | textureName | ||
| ) |
Render a Model.
| model | The model |
| offset | The offset (position) where to draw the model |
| rotation | Rotation (x, y, z) |
| textureName | The name of the texture to attach to the model. The texture has to have been generated already. |
| void small3d::Renderer::render | ( | Model & | model, |
| const std::string & | textureName, | ||
| const bool | perspective = true |
||
| ) |
Render a Model.
| model | The model |
| textureName | The name of the texture to attach to the model. The texture has to have been generated already. |
| perspective | True = perspective drawing, otherwise orthographic |
| void small3d::Renderer::render | ( | Model & | model, |
| const glm::vec4 & | colour, | ||
| const bool | perspective = true |
||
| ) |
Render a Model.
| model | The model |
| colour | The colour of the model |
| perspective | True = perspective drawing, otherwise orthographic |
| void small3d::Renderer::render | ( | SceneObject & | sceneObject, |
| const glm::vec4 & | colour | ||
| ) |
Render a SceneObject.
| sceneObject | The object |
| colour | The colour the object. |
| void small3d::Renderer::render | ( | SceneObject & | sceneObject, |
| const std::string & | textureName | ||
| ) |
Render a SceneObject.
| sceneObject | The object |
| textureName | The name of the texture to attach to the object. The texture has to have been generated already. |
1.8.15