Colobot
Classes | Public Member Functions | List of all members
Gfx::CGL21Device Class Reference

Implementation of CDevice interface in OpenGL. More...

#include <gl21device.h>

Inheritance diagram for Gfx::CGL21Device:
Inheritance graph
[legend]

Public Member Functions

 CGL21Device (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.
 
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 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 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)
 
void SetTextureCoordGeneration (int index, TextureGenerationParams &params) override
 Sets the texture coordinate generation mode for given texture unit.
 
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)
 
void DrawPrimitive (PrimitiveType type, const VertexCol *vertices, int vertexCount) override
 Renders primitive composed 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< CFrameBufferPixelsGetFrameBufferPixels () const override
 Returns the pixels of the entire screen.
 
CFramebufferGetFramebuffer (std::string name) override
 Returns framebuffer with given name or nullptr if it doesn't exist.
 
CFramebufferCreateFramebuffer (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.
 

Detailed Description

Implementation of CDevice interface in OpenGL.

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, CGL21DeviceConfig is outside the CDevice class and must be set in CApplication.

Member Function Documentation

int Gfx::CGL21Device::ComputeSphereVisibility ( const Math::Vector center,
float  radius 
)
overridevirtual

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.

Texture Gfx::CGL21Device::CreateTexture ( CImage image,
const TextureCreateParams params 
)
overridevirtual

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.

void Gfx::CGL21Device::SetTexture ( int  index,
const Texture texture 
)
overridevirtual

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.

void Gfx::CGL21Device::SetTextureStageParams ( int  index,
const TextureStageParams params 
)
overridevirtual

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.


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