Loading...
Searching...
No Matches
Gfx::CGL33Device Class Reference

Implementation of CDevice interface in OpenGL 3.3. More...

`#include <src/graphics/opengl/gl33device.h>`

Inheritance diagram for Gfx::CGL33Device:
[legend]

## Public Member Functions

| CGL33Device (const DeviceConfig &config)
void | DebugHook () override
| Provides a hook to debug graphics code (implementation-specific).
void | DebugLights () override
| Displays light positions to aid in debuggings.
std::string | GetName () override
| Returns a name of this device.
bool | Create () override
| Initializes the device, setting the initial state.
void | Destroy () override
| Destroys the device, releasing every acquired resource.
void | ConfigChanged (const DeviceConfig &newConfig) override
| Changes configuration.
void | BeginScene () override
| Begins drawing the 3D scene.
void | EndScene () override
| Ends drawing the 3D scene.
void | Clear () override
| Clears the screen to blank.
void | SetRenderMode (RenderMode mode) override
| Sets current rendering mode.
void | SetTransform (TransformType type, const Math::Matrix &matrix) override
| Sets the transform matrix of given type.
void | SetMaterial (const Material &material) override
| Sets the current material.
int | GetMaxLightCount () override
| Returns the maximum number of lights available.
void | SetLight (int index, const Light &light) override
| Sets the light at given index.
void | SetLightEnabled (int index, bool enabled) override
| Enables/disables the light at given index.
Texture | CreateTexture (CImage *image, const TextureCreateParams &params) override
Texture | CreateTexture (ImageData *data, const TextureCreateParams &params) override
| Creates a texture from raw image data; image data can be freed after that.
Texture | CreateDepthTexture (int width, int height, int depth) override
| Creates a depth texture with specific dimensions and depth.
void | UpdateTexture (const Texture &texture, Math::IntPoint offset, ImageData *data, TexImgFormat format) override
| Updates a part of texture from raw image data.
void | DestroyTexture (const Texture &texture) override
| Deletes a given texture, freeing it from video memory.
void | DestroyAllTextures () override
| Deletes all textures created so far.
int | GetMaxTextureStageCount () override
| Returns the maximum number of multitexture stages.
void | SetTexture (int index, const Texture &texture) override
void | SetTexture (int index, unsigned int textureId) override
| Sets the texture image by ID at given texture stage.
void | SetTextureEnabled (int index, bool enabled) override
| Enables/disables the given texture stage.
void | SetTextureStageParams (int index, const TextureStageParams &params) override
void | SetTextureStageWrap (int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override
| Sets only the texture wrap modes (for faster than thru stage params).
virtual void | DrawPrimitive (PrimitiveType type, const Vertex *vertices, int vertexCount, Color color=Color(1.0f, 1.0f, 1.0f, 1.0f)) override
| Renders primitive composed of vertices with single texture.
virtual void | DrawPrimitive (PrimitiveType type, const VertexTex2 *vertices, int vertexCount, Color color=Color(1.0f, 1.0f, 1.0f, 1.0f)) override
| Renders primitive composed of vertices with multitexturing (2 textures).
virtual void | DrawPrimitive (PrimitiveType type, const VertexCol *vertices, int vertexCount) override
| Renders primitive composed of vertices with solid color.
virtual void | DrawPrimitives (PrimitiveType type, const Vertex *vertices, int first[], int count[], int drawCount, Color color=Color(1.0f, 1.0f, 1.0f, 1.0f)) override
| Renders primitives composed of lists of vertices with single texture.
virtual void | DrawPrimitives (PrimitiveType type, const VertexTex2 *vertices, int first[], int count[], int drawCount, Color color=Color(1.0f, 1.0f, 1.0f, 1.0f)) override
| Renders primitives composed of lists of vertices with multitexturing (2 textures).
virtual void | DrawPrimitives (PrimitiveType type, const VertexCol *vertices, int first[], int count[], int drawCount) override
| Renders primitives composed of lists of vertices with solid color.
unsigned int | CreateStaticBuffer (PrimitiveType primitiveType, const Vertex *vertices, int vertexCount) override
| Creates a static buffer composed of given primitives with single texture vertices.
unsigned int | CreateStaticBuffer (PrimitiveType primitiveType, const VertexTex2 *vertices, int vertexCount) override
| Creates a static buffer composed of given primitives with multitexturing.
unsigned int | CreateStaticBuffer (PrimitiveType primitiveType, const VertexCol *vertices, int vertexCount) override
| Creates a static buffer composed of given primitives with solid color.
void | UpdateStaticBuffer (unsigned int bufferId, PrimitiveType primitiveType, const Vertex *vertices, int vertexCount) override
| Updates the static buffer composed of given primitives with single texture vertices.
void | UpdateStaticBuffer (unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2 *vertices, int vertexCount) override
| Updates the static buffer composed of given primitives with multitexturing.
void | UpdateStaticBuffer (unsigned int bufferId, PrimitiveType primitiveType, const VertexCol *vertices, int vertexCount) override
| Updates the static buffer composed of given primitives with solid color.
void | DrawStaticBuffer (unsigned int bufferId) override
| Draws a static buffer.
void | DestroyStaticBuffer (unsigned int bufferId) override
| Deletes a static buffer.
int | ComputeSphereVisibility (const Math::Vector &center, float radius) override
void | SetViewport (int x, int y, int width, int height) override
| Changes rendering viewport.
void | SetRenderState (RenderState state, bool enabled) override
| Enables/disables the given render state.
void | SetColorMask (bool red, bool green, bool blue, bool alpha) override
| Sets the color mask.
void | SetDepthTestFunc (CompFunc func) override
| Sets the function of depth test.
void | SetDepthBias (float factor, float units) override
| Sets the depth bias (constant value added to Z-coords).
void | SetAlphaTestFunc (CompFunc func, float refValue) override
| Sets the alpha test function and reference value.
void | SetBlendFunc (BlendFunc srcBlend, BlendFunc dstBlend) override
| Sets the blending functions for source and destination operations.
void | SetClearColor (const Color &color) override
| Sets the clear color.
void | SetGlobalAmbient (const Color &color) override
| Sets the global ambient color.
void | SetFogParams (FogMode mode, const Color &color, float start, float end, float density) override
| Sets the fog parameters: mode, color, start distance, end distance and density (for exp models).
void | SetCullMode (CullMode mode) override
| Sets the current cull mode.
void | SetShadeModel (ShadeModel model) override
| Sets the shade model.
void | SetShadowColor (float value) override
| Sets shadow color.
void | SetFillMode (FillMode mode) override
| Sets the current fill mode.
void | CopyFramebufferToTexture (Texture &texture, int xOffset, int yOffset, int x, int y, int width, int height) override
| Copies content of framebuffer to texture.
std::unique_ptr< CFrameBufferPixels > | GetFrameBufferPixels () const override
| Returns the pixels of the entire screen.
CFramebuffer * | GetFramebuffer (std::string name) override
| Returns framebuffer with given name or nullptr if it doesn't exist.
CFramebuffer * | CreateFramebuffer (std::string name, const FramebufferParams &params) override
| Creates new framebuffer with given name or nullptr if it's not possible.
void | DeleteFramebuffer (std::string name) override
| Deletes framebuffer.
bool | IsAnisotropySupported () override
| Checks if anisotropy is supported.
int | GetMaxAnisotropyLevel () override
| Returns max anisotropy level supported.
int | GetMaxSamples () override
| Returns max samples supported.
bool | IsShadowMappingSupported () override
| Checks if shadow mapping is supported.
int | GetMaxTextureSize () override
| Returns max texture size supported.
bool | IsFramebufferSupported () override
| Checks if framebuffers are supported.
Public Member Functions inherited from Gfx::CDevice
std::string | GetError ()
| Returns last error message or empty string.
const DeviceCapabilities & | GetCapabilities ()
| Returns device capabilities.

## Additional Inherited Members

Protected Attributes inherited from Gfx::CDevice
std::string | m_errorMessage
DeviceCapabilities | m_capabilities

## Detailed Description

Implementation of CDevice interface in OpenGL 3.3.

Provides the concrete implementation of 3D device in OpenGL.

This class should be initialized (by calling Initialize() ) only after setting the video mode by CApplication, once the OpenGL context is defined. Because of that, CGLDeviceConfig is outside the CDevice class and must be set in CApplication.

## Member Function Documentation

## DebugHook()

void Gfx::CGL33Device::DebugHook | ( |  | ) |

override virtual

Provides a hook to debug graphics code (implementation-specific).

Implements Gfx::CDevice.

## DebugLights()

void Gfx::CGL33Device::DebugLights | ( |  | ) |

override virtual

Displays light positions to aid in debuggings.

Implements Gfx::CDevice.

## GetName()

std::string Gfx::CGL33Device::GetName | ( |  | ) |

override virtual

Returns a name of this device.

Implements Gfx::CDevice.

## Create()

bool Gfx::CGL33Device::Create | ( |  | ) |

override virtual

Initializes the device, setting the initial state.

Implements Gfx::CDevice.

## Destroy()

void Gfx::CGL33Device::Destroy | ( |  | ) |

override virtual

Destroys the device, releasing every acquired resource.

Implements Gfx::CDevice.

## ConfigChanged()

void Gfx::CGL33Device::ConfigChanged | ( | const DeviceConfig & | newConfig | ) |

override virtual

Changes configuration.

Implements Gfx::CDevice.

## BeginScene()

void Gfx::CGL33Device::BeginScene | ( |  | ) |

override virtual

Begins drawing the 3D scene.

Implements Gfx::CDevice.

## EndScene()

void Gfx::CGL33Device::EndScene | ( |  | ) |

override virtual

Ends drawing the 3D scene.

Implements Gfx::CDevice.

## Clear()

void Gfx::CGL33Device::Clear | ( |  | ) |

override virtual

Clears the screen to blank.

Implements Gfx::CDevice.

## SetRenderMode()

void Gfx::CGL33Device::SetRenderMode | ( | RenderMode | mode | ) |

override virtual

Sets current rendering mode.

Implements Gfx::CDevice.

## SetTransform()

void Gfx::CGL33Device::SetTransform | ( | TransformType | type,
|  | const Math::Matrix & | matrix )

override virtual

Sets the transform matrix of given type.

Implements Gfx::CDevice.

## SetMaterial()

void Gfx::CGL33Device::SetMaterial | ( | const Material & | material | ) |

override virtual

Sets the current material.

Implements Gfx::CDevice.

## GetMaxLightCount()

int Gfx::CGL33Device::GetMaxLightCount | ( |  | ) |

override virtual

Returns the maximum number of lights available.

Implements Gfx::CDevice.

## SetLight()

void Gfx::CGL33Device::SetLight | ( | int | index,
|  | const Light & | light )

override virtual

Sets the light at given index.

Implements Gfx::CDevice.

## SetLightEnabled()

void Gfx::CGL33Device::SetLightEnabled | ( | int | index,
|  | bool | enabled )

override virtual

Enables/disables the light at given index.

Implements Gfx::CDevice.

## CreateTexture() [1/2]

Texture Gfx::CGL33Device::CreateTexture | ( | CImage * | image,
|  | const TextureCreateParams & | params )

override virtual

If image is invalid, returns invalid texture. Otherwise, returns pointer to new Texture struct. This struct must not be deleted in other way than through DeleteTexture()

Implements Gfx::CDevice.

## CreateTexture() [2/2]

Texture Gfx::CGL33Device::CreateTexture | ( | ImageData * | data,
|  | const TextureCreateParams & | params )

override virtual

Creates a texture from raw image data; image data can be freed after that.

Implements Gfx::CDevice.

## CreateDepthTexture()

Texture Gfx::CGL33Device::CreateDepthTexture | ( | int | width,
|  | int | height,
|  | int | depth )

override virtual

Creates a depth texture with specific dimensions and depth.

Implements Gfx::CDevice.

## UpdateTexture()

void Gfx::CGL33Device::UpdateTexture | ( | const Texture & | texture,
|  | Math::IntPoint | offset,
|  | ImageData * | data,
|  | TexImgFormat | format )

override virtual

Updates a part of texture from raw image data.

Implements Gfx::CDevice.

## DestroyTexture()

void Gfx::CGL33Device::DestroyTexture | ( | const Texture & | texture | ) |

override virtual

Deletes a given texture, freeing it from video memory.

Implements Gfx::CDevice.

## DestroyAllTextures()

void Gfx::CGL33Device::DestroyAllTextures | ( |  | ) |

override virtual

Deletes all textures created so far.

Implements Gfx::CDevice.

## GetMaxTextureStageCount()

int Gfx::CGL33Device::GetMaxTextureStageCount | ( |  | ) |

override virtual

Returns the maximum number of multitexture stages.

Implements Gfx::CDevice.

## SetTexture() [1/2]

void Gfx::CGL33Device::SetTexture | ( | int | index,
|  | const Texture & | texture )

override virtual

If texture is invalid, unbinds the given texture. If valid, binds the texture and enables the given texture stage. The setting is remembered, even if texturing is disabled at the moment.

Implements Gfx::CDevice.

## SetTexture() [2/2]

void Gfx::CGL33Device::SetTexture | ( | int | index,
|  | unsigned int | textureId )

override virtual

Sets the texture image by ID at given texture stage.

Implements Gfx::CDevice.

## SetTextureEnabled()

void Gfx::CGL33Device::SetTextureEnabled | ( | int | index,
|  | bool | enabled )

override virtual

Enables/disables the given texture stage.

Implements Gfx::CDevice.

## SetTextureStageParams()

void Gfx::CGL33Device::SetTextureStageParams | ( | int | index,
|  | const TextureStageParams & | params )

override virtual

Sets the texture parameters for the given texture stage. If the given texture was not set (bound) yet, nothing happens. The settings are remembered, even if texturing is disabled at the moment.

Implements Gfx::CDevice.

## SetTextureStageWrap()

void Gfx::CGL33Device::SetTextureStageWrap | ( | int | index,
|  | Gfx::TexWrapMode | wrapS,
|  | Gfx::TexWrapMode | wrapT )

override virtual

Sets only the texture wrap modes (for faster than thru stage params).

Implements Gfx::CDevice.

## DrawPrimitive() [1/3]

void Gfx::CGL33Device::DrawPrimitive | ( | PrimitiveType | type,
|  | const Vertex * | vertices,
|  | int | vertexCount,
|  | Color | color = Color(1.0f, 1.0f, 1.0f, 1.0f) )

override virtual

Renders primitive composed of vertices with single texture.

Implements Gfx::CDevice.

## DrawPrimitive() [2/3]

void Gfx::CGL33Device::DrawPrimitive | ( | PrimitiveType | type,
|  | const VertexTex2 * | vertices,
|  | int | vertexCount,
|  | Color | color = Color(1.0f, 1.0f, 1.0f, 1.0f) )

override virtual

Renders primitive composed of vertices with multitexturing (2 textures).

Implements Gfx::CDevice.

## DrawPrimitive() [3/3]

void Gfx::CGL33Device::DrawPrimitive | ( | PrimitiveType | type,
|  | const VertexCol * | vertices,
|  | int | vertexCount )

override virtual

Renders primitive composed of vertices with solid color.

Implements Gfx::CDevice.

## DrawPrimitives() [1/3]

void Gfx::CGL33Device::DrawPrimitives | ( | PrimitiveType | type,
|  | const Vertex * | vertices,
|  | int | first[],
|  | int | count[],
|  | int | drawCount,
|  | Color | color = Color(1.0f, 1.0f, 1.0f, 1.0f) )

override virtual

Renders primitives composed of lists of vertices with single texture.

Implements Gfx::CDevice.

## DrawPrimitives() [2/3]

void Gfx::CGL33Device::DrawPrimitives | ( | PrimitiveType | type,
|  | const VertexTex2 * | vertices,
|  | int | first[],
|  | int | count[],
|  | int | drawCount,
|  | Color | color = Color(1.0f, 1.0f, 1.0f, 1.0f) )

override virtual

Renders primitives composed of lists of vertices with multitexturing (2 textures).

Implements Gfx::CDevice.

## DrawPrimitives() [3/3]

void Gfx::CGL33Device::DrawPrimitives | ( | PrimitiveType | type,
|  | const VertexCol * | vertices,
|  | int | first[],
|  | int | count[],
|  | int | drawCount )

override virtual

Renders primitives composed of lists of vertices with solid color.

Implements Gfx::CDevice.

## CreateStaticBuffer() [1/3]

unsigned int Gfx::CGL33Device::CreateStaticBuffer | ( | PrimitiveType | primitiveType,
|  | const Vertex * | vertices,
|  | int | vertexCount )

inline override virtual

Creates a static buffer composed of given primitives with single texture vertices.

Implements Gfx::CDevice.

## CreateStaticBuffer() [2/3]

unsigned int Gfx::CGL33Device::CreateStaticBuffer | ( | PrimitiveType | primitiveType,
|  | const VertexTex2 * | vertices,
|  | int | vertexCount )

inline override virtual

Creates a static buffer composed of given primitives with multitexturing.

Implements Gfx::CDevice.

## CreateStaticBuffer() [3/3]

unsigned int Gfx::CGL33Device::CreateStaticBuffer | ( | PrimitiveType | primitiveType,
|  | const VertexCol * | vertices,
|  | int | vertexCount )

inline override virtual

Creates a static buffer composed of given primitives with solid color.

Implements Gfx::CDevice.

## UpdateStaticBuffer() [1/3]

void Gfx::CGL33Device::UpdateStaticBuffer | ( | unsigned int | bufferId,
|  | PrimitiveType | primitiveType,
|  | const Vertex * | vertices,
|  | int | vertexCount )

inline override virtual

Updates the static buffer composed of given primitives with single texture vertices.

Implements Gfx::CDevice.

## UpdateStaticBuffer() [2/3]

void Gfx::CGL33Device::UpdateStaticBuffer | ( | unsigned int | bufferId,
|  | PrimitiveType | primitiveType,
|  | const VertexTex2 * | vertices,
|  | int | vertexCount )

inline override virtual

Updates the static buffer composed of given primitives with multitexturing.

Implements Gfx::CDevice.

## UpdateStaticBuffer() [3/3]

void Gfx::CGL33Device::UpdateStaticBuffer | ( | unsigned int | bufferId,
|  | PrimitiveType | primitiveType,
|  | const VertexCol * | vertices,
|  | int | vertexCount )

inline override virtual

Updates the static buffer composed of given primitives with solid color.

Implements Gfx::CDevice.

## DrawStaticBuffer()

void Gfx::CGL33Device::DrawStaticBuffer | ( | unsigned int | bufferId | ) |

override virtual

Draws a static buffer.

Implements Gfx::CDevice.

## DestroyStaticBuffer()

void Gfx::CGL33Device::DestroyStaticBuffer | ( | unsigned int | bufferId | ) |

override virtual

Deletes a static buffer.

Implements Gfx::CDevice.

## ComputeSphereVisibility()

int Gfx::CGL33Device::ComputeSphereVisibility | ( | const Math::Vector & | center,
|  | float | radius )

override virtual

Tests whether a sphere is (partially) within the frustum volume Returns a mask of frustum planes for which the test is positive

Implements Gfx::CDevice.

## SetViewport()

void Gfx::CGL33Device::SetViewport | ( | int | x,
|  | int | y,
|  | int | width,
|  | int | height )

override virtual

Changes rendering viewport.

Implements Gfx::CDevice.

## SetRenderState()

void Gfx::CGL33Device::SetRenderState | ( | RenderState | state,
|  | bool | enabled )

override virtual

Enables/disables the given render state.

Implements Gfx::CDevice.

## SetColorMask()

void Gfx::CGL33Device::SetColorMask | ( | bool | red,
|  | bool | green,
|  | bool | blue,
|  | bool | alpha )

override virtual

Sets the color mask.

Implements Gfx::CDevice.

## SetDepthTestFunc()

void Gfx::CGL33Device::SetDepthTestFunc | ( | CompFunc | func | ) |

override virtual

Sets the function of depth test.

Implements Gfx::CDevice.

## SetDepthBias()

void Gfx::CGL33Device::SetDepthBias | ( | float | factor,
|  | float | units )

override virtual

Sets the depth bias (constant value added to Z-coords).

Implements Gfx::CDevice.

## SetAlphaTestFunc()

void Gfx::CGL33Device::SetAlphaTestFunc | ( | CompFunc | func,
|  | float | refValue )

override virtual

Sets the alpha test function and reference value.

Implements Gfx::CDevice.

## SetBlendFunc()

void Gfx::CGL33Device::SetBlendFunc | ( | BlendFunc | srcBlend,
|  | BlendFunc | dstBlend )

override virtual

Sets the blending functions for source and destination operations.

Implements Gfx::CDevice.

## SetClearColor()

void Gfx::CGL33Device::SetClearColor | ( | const Color & | color | ) |

override virtual

Sets the clear color.

Implements Gfx::CDevice.

## SetGlobalAmbient()

void Gfx::CGL33Device::SetGlobalAmbient | ( | const Color & | color | ) |

override virtual

Sets the global ambient color.

Implements Gfx::CDevice.

## SetFogParams()

void Gfx::CGL33Device::SetFogParams | ( | FogMode | mode,
|  | const Color & | color,
|  | float | start,
|  | float | end,
|  | float | density )

override virtual

Sets the fog parameters: mode, color, start distance, end distance and density (for exp models).

Implements Gfx::CDevice.

## SetCullMode()

void Gfx::CGL33Device::SetCullMode | ( | CullMode | mode | ) |

override virtual

Sets the current cull mode.

Implements Gfx::CDevice.

## SetShadeModel()

void Gfx::CGL33Device::SetShadeModel | ( | ShadeModel | model | ) |

override virtual

Sets the shade model.

Implements Gfx::CDevice.

## SetShadowColor()

void Gfx::CGL33Device::SetShadowColor | ( | float | value | ) |

override virtual

Sets shadow color.

Implements Gfx::CDevice.

## SetFillMode()

void Gfx::CGL33Device::SetFillMode | ( | FillMode | mode | ) |

override virtual

Sets the current fill mode.

Implements Gfx::CDevice.

## CopyFramebufferToTexture()

void Gfx::CGL33Device::CopyFramebufferToTexture | ( | Texture & | texture,
|  | int | xOffset,
|  | int | yOffset,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height )

override virtual

Copies content of framebuffer to texture.

Implements Gfx::CDevice.

## GetFrameBufferPixels()

std::unique_ptr< CFrameBufferPixels > Gfx::CGL33Device::GetFrameBufferPixels | ( |  | ) | const

override virtual

Returns the pixels of the entire screen.

Implements Gfx::CDevice.

## GetFramebuffer()

CFramebuffer * Gfx::CGL33Device::GetFramebuffer | ( | std::string | name | ) |

override virtual

Returns framebuffer with given name or nullptr if it doesn't exist.

Implements Gfx::CDevice.

## CreateFramebuffer()

CFramebuffer * Gfx::CGL33Device::CreateFramebuffer | ( | std::string | name,
|  | const FramebufferParams & | params )

override virtual

Creates new framebuffer with given name or nullptr if it's not possible.

Implements Gfx::CDevice.

## DeleteFramebuffer()

void Gfx::CGL33Device::DeleteFramebuffer | ( | std::string | name | ) |

override virtual

Deletes framebuffer.

Implements Gfx::CDevice.

## IsAnisotropySupported()

bool Gfx::CGL33Device::IsAnisotropySupported | ( |  | ) |

override virtual

Checks if anisotropy is supported.

Implements Gfx::CDevice.

## GetMaxAnisotropyLevel()

int Gfx::CGL33Device::GetMaxAnisotropyLevel | ( |  | ) |

override virtual

Returns max anisotropy level supported.

Implements Gfx::CDevice.

## GetMaxSamples()

int Gfx::CGL33Device::GetMaxSamples | ( |  | ) |

override virtual

Returns max samples supported.

Implements Gfx::CDevice.

## IsShadowMappingSupported()

bool Gfx::CGL33Device::IsShadowMappingSupported | ( |  | ) |

override virtual

Checks if shadow mapping is supported.

Implements Gfx::CDevice.

## GetMaxTextureSize()

int Gfx::CGL33Device::GetMaxTextureSize | ( |  | ) |

override virtual

Returns max texture size supported.

Implements Gfx::CDevice.

## IsFramebufferSupported()

bool Gfx::CGL33Device::IsFramebufferSupported | ( |  | ) |

override virtual

Checks if framebuffers are supported.

Implements Gfx::CDevice.

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

- src/graphics/opengl/gl33device.h
- src/graphics/opengl/gl33device.cpp