Kemena3D
Loading...
Searching...
No Matches
kemena::kDriver Class Referenceabstract

Pure-virtual graphics driver interface. More...

#include <kdriver.h>

Inheritance diagram for kemena::kDriver:

Public Member Functions

virtual ~kDriver ()=default
virtual bool init (kWindow *window)=0
 Initialises the graphics context for the given window.
virtual void destroy ()=0
 Destroys the graphics context and releases all driver resources.
virtual void * getNativeContext ()=0
 Returns the native context handle (e.g. SDL_GLContext for OpenGL).
virtual kString getApiVersion ()=0
 Returns a human-readable API version kString.
virtual kString getShaderVersion ()=0
 Returns the shading language version kString.
virtual void setClearColor (float r, float g, float b, float a)=0
 Sets the colour used by the next clear() call.
virtual void clear (bool color, bool depth, bool stencil)=0
 Clears the selected buffers of the currently-bound framebuffer.
virtual void setViewport (int x, int y, int width, int height)=0
 Sets the rendering viewport.
virtual void setDepthTest (bool enable)=0
 Enables or disables the depth test.
virtual void setDepthWrite (bool enable)=0
 Enables or disables writes to the depth buffer.
virtual void setBlend (bool enable)=0
 Enables or disables colour blending.
virtual void setBlendFunc (kBlendFactor src, kBlendFactor dst)=0
 Sets the blend equation source and destination factors.
virtual void setCullFace (bool enable)=0
 Enables or disables face culling.
virtual void setCullMode (kCullMode mode)=0
 Selects which polygon faces are culled when culling is enabled.
virtual void setFrontFace (kFrontFace face)=0
 Sets the winding order that defines the front face.
virtual void setMultisample (bool enable)=0
 Enables or disables multisampling (MSAA).
virtual void setSRGBEncoding (bool enable)=0
 Enables or disables sRGB framebuffer encoding.
virtual void setSampleAlphaToCoverage (bool enable)=0
 Enables or disables alpha-to-coverage (useful for MSAA foliage).
virtual uint32_t compileShaderProgram (const char *vertSrc, const char *fragSrc)=0
 Compiles and links a vertex + fragment shader pair from GLSL source.
virtual uint32_t compileShaderProgramSpirv (const std::vector< uint8_t > &vertSpirv, const kString &vertEntry, const std::vector< uint8_t > &fragSpirv, const kString &fragEntry)=0
 Compiles and links a vertex + fragment shader pair from SPIR-V binary.
virtual void deleteShaderProgram (uint32_t id)=0
 Destroys a previously-compiled shader program.
virtual void bindShaderProgram (uint32_t id)=0
 Binds a shader program for subsequent draw calls.
virtual void unbindShaderProgram ()=0
 Unbinds the current shader program.
virtual void setUniformBool (uint32_t progId, const kString &name, bool v)=0
 Sets a boolean uniform on the given program.
virtual void setUniformInt (uint32_t progId, const kString &name, int v)=0
 Sets an integer uniform on the given program.
virtual void setUniformUint (uint32_t progId, const kString &name, uint32_t v)=0
 Sets an unsigned-integer uniform on the given program.
virtual void setUniformFloat (uint32_t progId, const kString &name, float v)=0
 Sets a float uniform on the given program.
virtual void setUniformVec2 (uint32_t progId, const kString &name, const kVec2 &v)=0
 Sets a kVec2 uniform on the given program.
virtual void setUniformVec3 (uint32_t progId, const kString &name, const kVec3 &v)=0
 Sets a kVec3 uniform on the given program.
virtual void setUniformVec4 (uint32_t progId, const kString &name, const kVec4 &v)=0
 Sets a kVec4 uniform on the given program.
virtual void setUniformMat4 (uint32_t progId, const kString &name, const kMat4 &v)=0
 Sets a kMat4 uniform on the given program.
virtual void setUniformMat4Array (uint32_t progId, const kString &name, const std::vector< kMat4 > &v)=0
 Sets a kMat4 array uniform on the given program.
virtual uint32_t createVertexArray ()=0
 Creates and returns a new vertex array object (VAO).
virtual void deleteVertexArray (uint32_t id)=0
 Destroys the given VAO.
virtual void bindVertexArray (uint32_t id)=0
 Binds the given VAO as the active vertex array.
virtual void unbindVertexArray ()=0
 Unbinds the current vertex array.
virtual uint32_t createBuffer ()=0
 Creates and returns a new GPU buffer object.
virtual void deleteBuffer (uint32_t id)=0
 Destroys the given buffer.
virtual void uploadIndexBuffer (uint32_t bufferId, const void *data, size_t size)=0
 Uploads data to an index (element) buffer.
virtual void uploadVertexBuffer (uint32_t bufferId, const void *data, size_t size)=0
 Uploads data to a vertex buffer.
virtual void setVertexAttribFloat (int location, int components, int stride, size_t offset)=0
 Defines a float vertex attribute on the currently-bound VAO.
virtual void setVertexAttribInt (int location, int components, int stride, size_t offset)=0
 Defines an integer vertex attribute on the currently-bound VAO.
virtual void drawIndexed (uint32_t vaoId, int indexCount)=0
 Draws indexed triangles from the given VAO.
virtual void drawArrays (uint32_t vaoId, kPrimitiveType type, int vertexCount)=0
 Draws non-indexed primitives from the given VAO.
virtual void bindTexture2D (int unit, uint32_t id)=0
 Binds a 2D texture to the given texture unit.
virtual void bindTexture2DArray (int unit, uint32_t id)=0
 Binds a GL_TEXTURE_2D_ARRAY to a texture unit (e.g. CSM maps).
virtual void bindTextureCube (int unit, uint32_t id)=0
 Binds a cube-map texture to the given texture unit.
virtual void unbindTexture2D (int unit)=0
 Unbinds any 2D texture from the given unit.
virtual void unbindTexture2DArray (int unit)=0
 Unbinds any GL_TEXTURE_2D_ARRAY from a texture unit.
virtual void unbindTextureCube (int unit)=0
 Unbinds any cube-map texture from the given unit.
virtual void generateMipmaps2D (uint32_t id)=0
 Generates a full mipmap chain for the given 2D texture.
virtual void readTexture2DRGB (uint32_t id, int mipLevel, float *pixels)=0
 Reads one mip level of a 2D texture as 3-float-per-pixel RGB data.
virtual void readPixelsRGBA (int x, int y, uint8_t &r, uint8_t &g, uint8_t &b, uint8_t &a)=0
 Reads a single pixel from the currently-bound framebuffer.
virtual uint32_t createFramebuffer ()=0
 Creates and returns a new framebuffer object (FBO).
virtual void deleteFramebuffer (uint32_t id)=0
 Destroys the given FBO.
virtual void bindFramebuffer (uint32_t id)=0
 Binds an FBO as both read and draw framebuffer.
virtual void bindReadFramebuffer (uint32_t id)=0
 Binds an FBO as the read framebuffer only.
virtual void bindDrawFramebuffer (uint32_t id)=0
 Binds an FBO as the draw framebuffer only.
virtual void unbindFramebuffer ()=0
 Binds the default (window) framebuffer.
virtual bool isFramebufferComplete ()=0
 Checks whether the currently-bound FBO is complete.
virtual void blitFramebufferColor (int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1)=0
 Copies a colour region from the read FBO to the draw FBO.
virtual void setFramebufferDrawBuffer ()=0
 Sets the draw buffer of the current FBO to COLOR_ATTACHMENT0.
virtual uint32_t createRenderbuffer ()=0
 Creates and returns a new renderbuffer object (RBO).
virtual void deleteRenderbuffer (uint32_t id)=0
 Destroys the given RBO.
virtual void setupRenderbuffer (uint32_t rboId, int width, int height)=0
 Allocates single-sample depth+stencil storage for an RBO.
virtual void setupRenderbufferMSAA (uint32_t rboId, int samples, int width, int height)=0
 Allocates multi-sample depth+stencil storage for an RBO.
virtual void attachRenderbufferDepthStencil (uint32_t fboId, uint32_t rboId)=0
 Attaches an RBO to the depth+stencil attachment of an FBO.
virtual uint32_t createFBOColorTexture (int width, int height)=0
 Creates a single-sample colour texture suitable for FBO attachment.
virtual uint32_t createFBOColorTextureMSAA (int samples, int width, int height)=0
 Creates a multi-sample colour texture suitable for MSAA FBO attachment.
virtual uint32_t createFBODepthTexture (int width, int height)=0
 Creates a depth texture suitable for shadow-map FBO attachment.
virtual uint32_t createFBODepthTextureArray (int width, int height, int layers)=0
 Creates a layered depth texture (GL_TEXTURE_2D_ARRAY) for cascaded shadow maps — one layer per cascade.
virtual void deleteFBOTexture (uint32_t id)=0
 Destroys a texture created by createFBOColorTexture / createFBODepthTexture.
virtual void attachFBOColorTexture (uint32_t fboId, uint32_t texId)=0
 Attaches a colour texture to the colour attachment of an FBO.
virtual void attachFBOColorTextureMSAA (uint32_t fboId, uint32_t texId)=0
 Attaches a multi-sample colour texture to an MSAA FBO.
virtual void attachFBODepthTexture (uint32_t fboId, uint32_t texId)=0
 Attaches a depth texture to the depth attachment of an FBO.
virtual void attachFBODepthTextureLayer (uint32_t fboId, uint32_t texId, int layer)=0
 Attaches one layer of a depth texture array to an FBO's depth attachment (for rendering a single shadow cascade).
virtual void resizeFBOColorTexture (uint32_t texId, int width, int height)=0
 Re-allocates a colour texture with a new size (for FBO resize).
virtual void resizeFBOColorTextureMSAA (uint32_t texId, int samples, int width, int height)=0
 Re-allocates an MSAA colour texture with a new size.

Static Public Member Functions

static kDrivergetCurrent ()
 Returns the currently active driver (set via setCurrent()).
static void setCurrent (kDriver *driver)
 Sets the globally active driver.

Detailed Description

Pure-virtual graphics driver interface.

Concrete implementations (e.g. kOpenGLDriver) must override every method. Obtain the currently-active driver via kDriver::getCurrent().

Constructor & Destructor Documentation

◆ ~kDriver()

virtual kemena::kDriver::~kDriver ( )
virtualdefault

Member Function Documentation

◆ attachFBOColorTexture()

virtual void kemena::kDriver::attachFBOColorTexture ( uint32_t fboId,
uint32_t texId )
pure virtual

Attaches a colour texture to the colour attachment of an FBO.

Parameters
fboIdFBO handle.
texIdTexture handle.

Implemented in kemena::kOpenGLDriver.

◆ attachFBOColorTextureMSAA()

virtual void kemena::kDriver::attachFBOColorTextureMSAA ( uint32_t fboId,
uint32_t texId )
pure virtual

Attaches a multi-sample colour texture to an MSAA FBO.

Parameters
fboIdFBO handle.
texIdMSAA texture handle.

Implemented in kemena::kOpenGLDriver.

◆ attachFBODepthTexture()

virtual void kemena::kDriver::attachFBODepthTexture ( uint32_t fboId,
uint32_t texId )
pure virtual

Attaches a depth texture to the depth attachment of an FBO.

Also sets draw/read buffers to GL_NONE, making the FBO suitable for shadow-map rendering.

Parameters
fboIdFBO handle.
texIdDepth texture handle.

Implemented in kemena::kOpenGLDriver.

◆ attachFBODepthTextureLayer()

virtual void kemena::kDriver::attachFBODepthTextureLayer ( uint32_t fboId,
uint32_t texId,
int layer )
pure virtual

Attaches one layer of a depth texture array to an FBO's depth attachment (for rendering a single shadow cascade).

Parameters
fboIdFBO handle.
texIdDepth texture-array handle.
layerArray layer (cascade index) to render into.

Implemented in kemena::kOpenGLDriver.

◆ attachRenderbufferDepthStencil()

virtual void kemena::kDriver::attachRenderbufferDepthStencil ( uint32_t fboId,
uint32_t rboId )
pure virtual

Attaches an RBO to the depth+stencil attachment of an FBO.

Parameters
fboIdFBO handle.
rboIdRBO handle.

Implemented in kemena::kOpenGLDriver.

◆ bindDrawFramebuffer()

virtual void kemena::kDriver::bindDrawFramebuffer ( uint32_t id)
pure virtual

Binds an FBO as the draw framebuffer only.

Implemented in kemena::kOpenGLDriver.

◆ bindFramebuffer()

virtual void kemena::kDriver::bindFramebuffer ( uint32_t id)
pure virtual

Binds an FBO as both read and draw framebuffer.

Implemented in kemena::kOpenGLDriver.

◆ bindReadFramebuffer()

virtual void kemena::kDriver::bindReadFramebuffer ( uint32_t id)
pure virtual

Binds an FBO as the read framebuffer only.

Implemented in kemena::kOpenGLDriver.

◆ bindShaderProgram()

virtual void kemena::kDriver::bindShaderProgram ( uint32_t id)
pure virtual

Binds a shader program for subsequent draw calls.

Parameters
idProgram handle.

Implemented in kemena::kOpenGLDriver.

◆ bindTexture2D()

virtual void kemena::kDriver::bindTexture2D ( int unit,
uint32_t id )
pure virtual

Binds a 2D texture to the given texture unit.

Parameters
unitTexture unit index (0-based).
idTexture handle.

Implemented in kemena::kOpenGLDriver.

◆ bindTexture2DArray()

virtual void kemena::kDriver::bindTexture2DArray ( int unit,
uint32_t id )
pure virtual

Binds a GL_TEXTURE_2D_ARRAY to a texture unit (e.g. CSM maps).

Implemented in kemena::kOpenGLDriver.

◆ bindTextureCube()

virtual void kemena::kDriver::bindTextureCube ( int unit,
uint32_t id )
pure virtual

Binds a cube-map texture to the given texture unit.

Parameters
unitTexture unit index.
idTexture handle.

Implemented in kemena::kOpenGLDriver.

◆ bindVertexArray()

virtual void kemena::kDriver::bindVertexArray ( uint32_t id)
pure virtual

Binds the given VAO as the active vertex array.

Implemented in kemena::kOpenGLDriver.

◆ blitFramebufferColor()

virtual void kemena::kDriver::blitFramebufferColor ( int srcX0,
int srcY0,
int srcX1,
int srcY1,
int dstX0,
int dstY0,
int dstX1,
int dstY1 )
pure virtual

Copies a colour region from the read FBO to the draw FBO.

Parameters
srcX0,srcY0Source region bottom-left.
srcX1,srcY1Source region top-right.
dstX0,dstY0Destination region bottom-left.
dstX1,dstY1Destination region top-right.

Implemented in kemena::kOpenGLDriver.

◆ clear()

virtual void kemena::kDriver::clear ( bool color,
bool depth,
bool stencil )
pure virtual

Clears the selected buffers of the currently-bound framebuffer.

Parameters
colorClear the colour attachment.
depthClear the depth attachment.
stencilClear the stencil attachment.

Implemented in kemena::kOpenGLDriver.

◆ compileShaderProgram()

virtual uint32_t kemena::kDriver::compileShaderProgram ( const char * vertSrc,
const char * fragSrc )
pure virtual

Compiles and links a vertex + fragment shader pair from GLSL source.

Parameters
vertSrcGLSL vertex shader source kString, or nullptr to skip.
fragSrcGLSL fragment shader source kString, or nullptr to skip.
Returns
Opaque program handle (0 on failure).

Implemented in kemena::kOpenGLDriver.

◆ compileShaderProgramSpirv()

virtual uint32_t kemena::kDriver::compileShaderProgramSpirv ( const std::vector< uint8_t > & vertSpirv,
const kString & vertEntry,
const std::vector< uint8_t > & fragSpirv,
const kString & fragEntry )
pure virtual

Compiles and links a vertex + fragment shader pair from SPIR-V binary.

Requires OpenGL 4.6 or the GL_ARB_gl_spirv extension.

Parameters
vertSpirvSPIR-V binary for the vertex stage.
vertEntryEntry-point name inside the vertex SPIR-V module.
fragSpirvSPIR-V binary for the fragment stage.
fragEntryEntry-point name inside the fragment SPIR-V module.
Returns
Opaque program handle (0 on failure or if SPIR-V is unsupported).

Implemented in kemena::kOpenGLDriver.

◆ createBuffer()

virtual uint32_t kemena::kDriver::createBuffer ( )
pure virtual

Creates and returns a new GPU buffer object.

Returns
Handle to the new buffer.

Implemented in kemena::kOpenGLDriver.

◆ createFBOColorTexture()

virtual uint32_t kemena::kDriver::createFBOColorTexture ( int width,
int height )
pure virtual

Creates a single-sample colour texture suitable for FBO attachment.

Parameters
widthTexture width in pixels.
heightTexture height in pixels.
Returns
Handle to the new texture.

Implemented in kemena::kOpenGLDriver.

◆ createFBOColorTextureMSAA()

virtual uint32_t kemena::kDriver::createFBOColorTextureMSAA ( int samples,
int width,
int height )
pure virtual

Creates a multi-sample colour texture suitable for MSAA FBO attachment.

Parameters
samplesSample count.
widthTexture width in pixels.
heightTexture height in pixels.
Returns
Handle to the new texture.

Implemented in kemena::kOpenGLDriver.

◆ createFBODepthTexture()

virtual uint32_t kemena::kDriver::createFBODepthTexture ( int width,
int height )
pure virtual

Creates a depth texture suitable for shadow-map FBO attachment.

Parameters
widthTexture width in pixels.
heightTexture height in pixels.
Returns
Handle to the new texture.

Implemented in kemena::kOpenGLDriver.

◆ createFBODepthTextureArray()

virtual uint32_t kemena::kDriver::createFBODepthTextureArray ( int width,
int height,
int layers )
pure virtual

Creates a layered depth texture (GL_TEXTURE_2D_ARRAY) for cascaded shadow maps — one layer per cascade.

Parameters
widthPer-layer width in pixels.
heightPer-layer height in pixels.
layersNumber of array layers (cascades).
Returns
Handle to the new array texture.

Implemented in kemena::kOpenGLDriver.

◆ createFramebuffer()

virtual uint32_t kemena::kDriver::createFramebuffer ( )
pure virtual

Creates and returns a new framebuffer object (FBO).

Returns
Handle to the new FBO.

Implemented in kemena::kOpenGLDriver.

◆ createRenderbuffer()

virtual uint32_t kemena::kDriver::createRenderbuffer ( )
pure virtual

Creates and returns a new renderbuffer object (RBO).

Returns
Handle to the new RBO.

Implemented in kemena::kOpenGLDriver.

◆ createVertexArray()

virtual uint32_t kemena::kDriver::createVertexArray ( )
pure virtual

Creates and returns a new vertex array object (VAO).

Returns
Handle to the new VAO.

Implemented in kemena::kOpenGLDriver.

◆ deleteBuffer()

virtual void kemena::kDriver::deleteBuffer ( uint32_t id)
pure virtual

Destroys the given buffer.

Implemented in kemena::kOpenGLDriver.

◆ deleteFBOTexture()

virtual void kemena::kDriver::deleteFBOTexture ( uint32_t id)
pure virtual

Destroys a texture created by createFBOColorTexture / createFBODepthTexture.

Implemented in kemena::kOpenGLDriver.

◆ deleteFramebuffer()

virtual void kemena::kDriver::deleteFramebuffer ( uint32_t id)
pure virtual

Destroys the given FBO.

Implemented in kemena::kOpenGLDriver.

◆ deleteRenderbuffer()

virtual void kemena::kDriver::deleteRenderbuffer ( uint32_t id)
pure virtual

Destroys the given RBO.

Implemented in kemena::kOpenGLDriver.

◆ deleteShaderProgram()

virtual void kemena::kDriver::deleteShaderProgram ( uint32_t id)
pure virtual

Destroys a previously-compiled shader program.

Parameters
idProgram handle returned by compileShaderProgram().

Implemented in kemena::kOpenGLDriver.

◆ deleteVertexArray()

virtual void kemena::kDriver::deleteVertexArray ( uint32_t id)
pure virtual

Destroys the given VAO.

Implemented in kemena::kOpenGLDriver.

◆ destroy()

virtual void kemena::kDriver::destroy ( )
pure virtual

Destroys the graphics context and releases all driver resources.

Implemented in kemena::kOpenGLDriver.

◆ drawArrays()

virtual void kemena::kDriver::drawArrays ( uint32_t vaoId,
kPrimitiveType type,
int vertexCount )
pure virtual

Draws non-indexed primitives from the given VAO.

Parameters
vaoIdVAO handle.
typePrimitive topology.
vertexCountNumber of vertices to draw.

Implemented in kemena::kOpenGLDriver.

◆ drawIndexed()

virtual void kemena::kDriver::drawIndexed ( uint32_t vaoId,
int indexCount )
pure virtual

Draws indexed triangles from the given VAO.

Parameters
vaoIdVAO handle.
indexCountNumber of indices to draw.

Implemented in kemena::kOpenGLDriver.

◆ generateMipmaps2D()

virtual void kemena::kDriver::generateMipmaps2D ( uint32_t id)
pure virtual

Generates a full mipmap chain for the given 2D texture.

Parameters
idTexture handle.

Implemented in kemena::kOpenGLDriver.

◆ getApiVersion()

virtual kString kemena::kDriver::getApiVersion ( )
pure virtual

Returns a human-readable API version kString.

Returns
e.g. "4.6.0 NVIDIA 546.01".

Implemented in kemena::kOpenGLDriver.

◆ getCurrent()

kDriver * kemena::kDriver::getCurrent ( )
inlinestatic

Returns the currently active driver (set via setCurrent()).

Returns
Pointer to the active driver, or nullptr if none is set.

◆ getNativeContext()

virtual void * kemena::kDriver::getNativeContext ( )
pure virtual

Returns the native context handle (e.g. SDL_GLContext for OpenGL).

Returns
Opaque pointer; cast to the appropriate type for your backend.

Implemented in kemena::kOpenGLDriver.

◆ getShaderVersion()

virtual kString kemena::kDriver::getShaderVersion ( )
pure virtual

Returns the shading language version kString.

Returns
e.g. "4.60 NVIDIA".

Implemented in kemena::kOpenGLDriver.

◆ init()

virtual bool kemena::kDriver::init ( kWindow * window)
pure virtual

Initialises the graphics context for the given window.

Parameters
windowTarget window; must not be nullptr for GL backends.
Returns
true on success.

Implemented in kemena::kOpenGLDriver.

◆ isFramebufferComplete()

virtual bool kemena::kDriver::isFramebufferComplete ( )
pure virtual

Checks whether the currently-bound FBO is complete.

Returns
true if the FBO is ready for rendering.

Implemented in kemena::kOpenGLDriver.

◆ readPixelsRGBA()

virtual void kemena::kDriver::readPixelsRGBA ( int x,
int y,
uint8_t & r,
uint8_t & g,
uint8_t & b,
uint8_t & a )
pure virtual

Reads a single pixel from the currently-bound framebuffer.

Uses the bottom-left origin convention (OpenGL standard). Primarily used for color-ID object picking.

Parameters
xPixel x coordinate from the left edge.
yPixel y coordinate from the bottom edge.
rOutput red channel [0, 255].
gOutput green channel [0, 255].
bOutput blue channel [0, 255].
aOutput alpha channel [0, 255].

Implemented in kemena::kOpenGLDriver.

◆ readTexture2DRGB()

virtual void kemena::kDriver::readTexture2DRGB ( uint32_t id,
int mipLevel,
float * pixels )
pure virtual

Reads one mip level of a 2D texture as 3-float-per-pixel RGB data.

Primarily used for auto-exposure luminance sampling.

Parameters
idTexture handle.
mipLevelMip level to read.
pixelsDestination buffer; must be large enough for the mip's texels.

Implemented in kemena::kOpenGLDriver.

◆ resizeFBOColorTexture()

virtual void kemena::kDriver::resizeFBOColorTexture ( uint32_t texId,
int width,
int height )
pure virtual

Re-allocates a colour texture with a new size (for FBO resize).

Parameters
texIdTexture handle.
widthNew width in pixels.
heightNew height in pixels.

Implemented in kemena::kOpenGLDriver.

◆ resizeFBOColorTextureMSAA()

virtual void kemena::kDriver::resizeFBOColorTextureMSAA ( uint32_t texId,
int samples,
int width,
int height )
pure virtual

Re-allocates an MSAA colour texture with a new size.

Parameters
texIdTexture handle.
samplesSample count.
widthNew width in pixels.
heightNew height in pixels.

Implemented in kemena::kOpenGLDriver.

◆ setBlend()

virtual void kemena::kDriver::setBlend ( bool enable)
pure virtual

Enables or disables colour blending.

Parameters
enabletrue to enable.

Implemented in kemena::kOpenGLDriver.

◆ setBlendFunc()

virtual void kemena::kDriver::setBlendFunc ( kBlendFactor src,
kBlendFactor dst )
pure virtual

Sets the blend equation source and destination factors.

Parameters
srcSource factor.
dstDestination factor.

Implemented in kemena::kOpenGLDriver.

◆ setClearColor()

virtual void kemena::kDriver::setClearColor ( float r,
float g,
float b,
float a )
pure virtual

Sets the colour used by the next clear() call.

Parameters
rRed [0, 1].
gGreen [0, 1].
bBlue [0, 1].
aAlpha [0, 1].

Implemented in kemena::kOpenGLDriver.

◆ setCullFace()

virtual void kemena::kDriver::setCullFace ( bool enable)
pure virtual

Enables or disables face culling.

Parameters
enabletrue to enable.

Implemented in kemena::kOpenGLDriver.

◆ setCullMode()

virtual void kemena::kDriver::setCullMode ( kCullMode mode)
pure virtual

Selects which polygon faces are culled when culling is enabled.

Parameters
modeCull mode.

Implemented in kemena::kOpenGLDriver.

◆ setCurrent()

void kemena::kDriver::setCurrent ( kDriver * driver)
inlinestatic

Sets the globally active driver.

Parameters
driverDriver to make current.

◆ setDepthTest()

virtual void kemena::kDriver::setDepthTest ( bool enable)
pure virtual

Enables or disables the depth test.

Parameters
enabletrue to enable.

Implemented in kemena::kOpenGLDriver.

◆ setDepthWrite()

virtual void kemena::kDriver::setDepthWrite ( bool enable)
pure virtual

Enables or disables writes to the depth buffer.

Parameters
enabletrue to allow writes.

Implemented in kemena::kOpenGLDriver.

◆ setFramebufferDrawBuffer()

virtual void kemena::kDriver::setFramebufferDrawBuffer ( )
pure virtual

Sets the draw buffer of the current FBO to COLOR_ATTACHMENT0.

Required after attaching colour textures to ensure correct rendering.

Implemented in kemena::kOpenGLDriver.

◆ setFrontFace()

virtual void kemena::kDriver::setFrontFace ( kFrontFace face)
pure virtual

Sets the winding order that defines the front face.

Parameters
faceFront-face winding.

Implemented in kemena::kOpenGLDriver.

◆ setMultisample()

virtual void kemena::kDriver::setMultisample ( bool enable)
pure virtual

Enables or disables multisampling (MSAA).

Parameters
enabletrue to enable.

Implemented in kemena::kOpenGLDriver.

◆ setSampleAlphaToCoverage()

virtual void kemena::kDriver::setSampleAlphaToCoverage ( bool enable)
pure virtual

Enables or disables alpha-to-coverage (useful for MSAA foliage).

Parameters
enabletrue to enable.

Implemented in kemena::kOpenGLDriver.

◆ setSRGBEncoding()

virtual void kemena::kDriver::setSRGBEncoding ( bool enable)
pure virtual

Enables or disables sRGB framebuffer encoding.

Parameters
enabletrue to write in sRGB; false for linear output.

Implemented in kemena::kOpenGLDriver.

◆ setUniformBool()

virtual void kemena::kDriver::setUniformBool ( uint32_t progId,
const kString & name,
bool v )
pure virtual

Sets a boolean uniform on the given program.

Implemented in kemena::kOpenGLDriver.

◆ setUniformFloat()

virtual void kemena::kDriver::setUniformFloat ( uint32_t progId,
const kString & name,
float v )
pure virtual

Sets a float uniform on the given program.

Implemented in kemena::kOpenGLDriver.

◆ setUniformInt()

virtual void kemena::kDriver::setUniformInt ( uint32_t progId,
const kString & name,
int v )
pure virtual

Sets an integer uniform on the given program.

Implemented in kemena::kOpenGLDriver.

◆ setUniformMat4()

virtual void kemena::kDriver::setUniformMat4 ( uint32_t progId,
const kString & name,
const kMat4 & v )
pure virtual

Sets a kMat4 uniform on the given program.

Implemented in kemena::kOpenGLDriver.

◆ setUniformMat4Array()

virtual void kemena::kDriver::setUniformMat4Array ( uint32_t progId,
const kString & name,
const std::vector< kMat4 > & v )
pure virtual

Sets a kMat4 array uniform on the given program.

Parameters
progIdProgram handle.
nameUniform array name.
vArray of kMat4 values.

Implemented in kemena::kOpenGLDriver.

◆ setUniformUint()

virtual void kemena::kDriver::setUniformUint ( uint32_t progId,
const kString & name,
uint32_t v )
pure virtual

Sets an unsigned-integer uniform on the given program.

Implemented in kemena::kOpenGLDriver.

◆ setUniformVec2()

virtual void kemena::kDriver::setUniformVec2 ( uint32_t progId,
const kString & name,
const kVec2 & v )
pure virtual

Sets a kVec2 uniform on the given program.

Implemented in kemena::kOpenGLDriver.

◆ setUniformVec3()

virtual void kemena::kDriver::setUniformVec3 ( uint32_t progId,
const kString & name,
const kVec3 & v )
pure virtual

Sets a kVec3 uniform on the given program.

Implemented in kemena::kOpenGLDriver.

◆ setUniformVec4()

virtual void kemena::kDriver::setUniformVec4 ( uint32_t progId,
const kString & name,
const kVec4 & v )
pure virtual

Sets a kVec4 uniform on the given program.

Implemented in kemena::kOpenGLDriver.

◆ setupRenderbuffer()

virtual void kemena::kDriver::setupRenderbuffer ( uint32_t rboId,
int width,
int height )
pure virtual

Allocates single-sample depth+stencil storage for an RBO.

Parameters
rboIdTarget RBO handle.
widthStorage width in pixels.
heightStorage height in pixels.

Implemented in kemena::kOpenGLDriver.

◆ setupRenderbufferMSAA()

virtual void kemena::kDriver::setupRenderbufferMSAA ( uint32_t rboId,
int samples,
int width,
int height )
pure virtual

Allocates multi-sample depth+stencil storage for an RBO.

Parameters
rboIdTarget RBO handle.
samplesMSAA sample count.
widthStorage width in pixels.
heightStorage height in pixels.

Implemented in kemena::kOpenGLDriver.

◆ setVertexAttribFloat()

virtual void kemena::kDriver::setVertexAttribFloat ( int location,
int components,
int stride,
size_t offset )
pure virtual

Defines a float vertex attribute on the currently-bound VAO.

Also enables the attribute array at location.

Parameters
locationShader attribute location.
componentsNumber of float components (1–4).
strideByte distance between consecutive elements.
offsetByte offset of the first element within the buffer.

Implemented in kemena::kOpenGLDriver.

◆ setVertexAttribInt()

virtual void kemena::kDriver::setVertexAttribInt ( int location,
int components,
int stride,
size_t offset )
pure virtual

Defines an integer vertex attribute on the currently-bound VAO.

Uses the integer variant (glVertexAttribIPointer). Also enables the attribute array at location.

Parameters
locationShader attribute location.
componentsNumber of integer components (1–4).
strideByte distance between consecutive elements.
offsetByte offset of the first element within the buffer.

Implemented in kemena::kOpenGLDriver.

◆ setViewport()

virtual void kemena::kDriver::setViewport ( int x,
int y,
int width,
int height )
pure virtual

Sets the rendering viewport.

Parameters
xLeft edge in pixels.
yBottom edge in pixels (OpenGL convention).
widthViewport width in pixels.
heightViewport height in pixels.

Implemented in kemena::kOpenGLDriver.

◆ unbindFramebuffer()

virtual void kemena::kDriver::unbindFramebuffer ( )
pure virtual

Binds the default (window) framebuffer.

Implemented in kemena::kOpenGLDriver.

◆ unbindShaderProgram()

virtual void kemena::kDriver::unbindShaderProgram ( )
pure virtual

Unbinds the current shader program.

Implemented in kemena::kOpenGLDriver.

◆ unbindTexture2D()

virtual void kemena::kDriver::unbindTexture2D ( int unit)
pure virtual

Unbinds any 2D texture from the given unit.

Implemented in kemena::kOpenGLDriver.

◆ unbindTexture2DArray()

virtual void kemena::kDriver::unbindTexture2DArray ( int unit)
pure virtual

Unbinds any GL_TEXTURE_2D_ARRAY from a texture unit.

Implemented in kemena::kOpenGLDriver.

◆ unbindTextureCube()

virtual void kemena::kDriver::unbindTextureCube ( int unit)
pure virtual

Unbinds any cube-map texture from the given unit.

Implemented in kemena::kOpenGLDriver.

◆ unbindVertexArray()

virtual void kemena::kDriver::unbindVertexArray ( )
pure virtual

Unbinds the current vertex array.

Implemented in kemena::kOpenGLDriver.

◆ uploadIndexBuffer()

virtual void kemena::kDriver::uploadIndexBuffer ( uint32_t bufferId,
const void * data,
size_t size )
pure virtual

Uploads data to an index (element) buffer.

Parameters
bufferIdTarget buffer handle.
dataPointer to index data.
sizeSize of the data in bytes.

Implemented in kemena::kOpenGLDriver.

◆ uploadVertexBuffer()

virtual void kemena::kDriver::uploadVertexBuffer ( uint32_t bufferId,
const void * data,
size_t size )
pure virtual

Uploads data to a vertex buffer.

Parameters
bufferIdTarget buffer handle.
dataPointer to vertex data.
sizeSize of the data in bytes.

Implemented in kemena::kOpenGLDriver.


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