Manages the rendering system, handling the window and resources.
The core of the rendering system. Deals with setting up and shutting down the window + OpenGL context, and creating/using resources such as shaders, textures, and geometry.
This is a singleton that has shared ownership amongst all Renderer classes. When the first Renderer class is created, this RendererBase class is also created. When the last Renderer class is destroyed, this RendererBase class is also destroyed.
Users should instantiate one or more Renderer classes. Users should not instantiate RendererBase.
Users can call a subset of Renderer functionality via the RendererBase singleton. For example,
But all of the RendererBase functionality is also in Renderer, and using it may (potentially) be faster since each thread has its own Renderer and there is only one shared RendererBase. So prefer using Renderer over the RendererBase singleton, when you have a Renderer around.
|
bool | Initialize (const mathfu::vec2i &window_size, const char *window_title, WindowMode window_mode=kWindowModeWindowedScaled) |
| Initializes the renderer by initializing the Environment object. More...
|
|
void | AdvanceFrame (bool minimized, double time) |
| Swaps frames. Call this once per frame inside your main loop. More...
|
|
void | ShutDown () |
| Cleans up the resources initialized by the renderer.
|
|
void | SetWindowSize (const mathfu::vec2i &window_size) |
| Sets the window size, for when window is not owned by the renderer. More...
|
|
Shader * | CompileAndLinkShader (const char *vs_source, const char *ps_source) |
| Create a shader object from two strings containing glsl code. More...
|
|
Shader * | RecompileShader (const char *vs_source, const char *ps_source, Shader *shader) |
| Like CompileAndLinkShader, but pass in an old shader to replace. More...
|
|
bool | AllowMultiThreading () |
| Checks for multithreading API. Returns true if the graphics API allows multi-threading.
|
|
void | SetAnimation (const mathfu::AffineTransform *bone_transforms, int num_bones) |
| Set bone transforms in vertex shader uniforms. More...
|
|
const std::string & | last_error () const |
| Contains the last error that occurred, if there is one. More...
|
|
void | set_last_error (const std::string &last_error) |
|
const mathfu::vec2i & | window_size () const |
| The device's current framebuffer size. More...
|
|
mathfu::vec2i & | window_size () |
|
void | set_window_size (const mathfu::vec2i &ws) |
| Sets the window size. More...
|
|
mathfu::vec2i | GetViewportSize () |
| Get the size of the viewport. More...
|
|
Environment & | environment () |
|
double | time () const |
| Time in seconds since program start. More...
|
|
FeatureLevel | feature_level () const |
| The supported OpenGL ES feature level. More...
|
|
BlendMode | force_blend_mode () const |
| The blend that will be used for all draw calls. More...
|
|
void | set_force_blend_mode (BlendMode bm) |
| Set to override the blend mode used for all draw calls. More...
|
|
void | set_override_pixel_shader (const std::string &ps) |
| Set this force any shader that gets loaded to use this pixel shader instead (for debugging purposes). More...
|
|
int | max_vertex_uniform_components () |
| Get the max number of uniforms components (i.e. individual floats, so a mat4 needs 16 of them). More...
|
|
const FplBaseVersion * | GetFplBaseVersion () const |
| Returns the version of the FPL Base Library.
|
|
bool | SupportsTextureFormat (TextureFormat texture_format) const |
| Returns if a texture format is supported by the hardware.
|
|
bool | SupportsTextureNpot () const |
| Returns if a NPOT textures are supported by the hardware. see: https://www.opengl.org/wiki/NPOT_Texture.
|
|
RendererBaseImpl * | impl () |
|
Shader* fplbase::RendererBase::CompileAndLinkShader |
( |
const char * |
vs_source, |
|
|
const char * |
ps_source |
|
) |
| |
Create a shader object from two strings containing glsl code.
Returns nullptr upon error, with a descriptive message in glsl_error(). Attribute names in the vertex shader should be aPosition, aNormal, aTexCoord, aColor, aBoneIndices and aBoneWeights, to match whatever attributes your vertex data has.
- Parameters
-
vs_source | The source code of the vertex shader. |
ps_source | The source code of the fragment shader. |
const std::string& fplbase::RendererBase::last_error |
( |
| ) |
const |
|
inline |
Contains the last error that occurred, if there is one.
If any of the more complex loading operations (shaders, textures etc.) fail, this sting will contain a more informative error message.
Returns the last error that occurred.