137 virtual void clear(
bool color,
bool depth,
bool stencil) = 0;
146 virtual void setViewport(
int x,
int y,
int width,
int height) = 0;
234 const std::vector<uint8_t> &fragSpirv,
416 virtual void readPixelsRGBA(
int x,
int y, uint8_t &r, uint8_t &g, uint8_t &b, uint8_t &a) = 0;
455 int dstX0,
int dstY0,
int dstX1,
int dstY1) = 0;
Pure-virtual graphics driver interface.
Definition kdriver.h:86
virtual void setUniformMat4(uint32_t progId, const kString &name, const kMat4 &v)=0
Sets a kMat4 uniform on the given program.
virtual void bindReadFramebuffer(uint32_t id)=0
Binds an FBO as the read framebuffer only.
virtual void unbindTexture2DArray(int unit)=0
Unbinds any GL_TEXTURE_2D_ARRAY from a texture unit.
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 bindShaderProgram(uint32_t id)=0
Binds a shader program for subsequent draw calls.
virtual kString getShaderVersion()=0
Returns the shading language version kString.
virtual void generateMipmaps2D(uint32_t id)=0
Generates a full mipmap chain for the given 2D texture.
virtual void unbindTexture2D(int unit)=0
Unbinds any 2D texture from the given unit.
virtual uint32_t createFBODepthTexture(int width, int height)=0
Creates a depth texture suitable for shadow-map FBO attachment.
virtual void setCullFace(bool enable)=0
Enables or disables face culling.
virtual void setBlend(bool enable)=0
Enables or disables colour blending.
virtual void uploadIndexBuffer(uint32_t bufferId, const void *data, size_t size)=0
Uploads data to an index (element) buffer.
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 setClearColor(float r, float g, float b, float a)=0
Sets the colour used by the next clear() call.
virtual void unbindTextureCube(int unit)=0
Unbinds any cube-map texture from the given 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 resizeFBOColorTextureMSAA(uint32_t texId, int samples, int width, int height)=0
Re-allocates an MSAA colour texture with a new size.
virtual void clear(bool color, bool depth, bool stencil)=0
Clears the selected buffers of the currently-bound framebuffer.
virtual void uploadVertexBuffer(uint32_t bufferId, const void *data, size_t size)=0
Uploads data to a vertex buffer.
virtual void setUniformVec4(uint32_t progId, const kString &name, const kVec4 &v)=0
Sets a kVec4 uniform on the given program.
virtual void deleteShaderProgram(uint32_t id)=0
Destroys a previously-compiled shader program.
virtual void deleteVertexArray(uint32_t id)=0
Destroys the given VAO.
virtual void drawArrays(uint32_t vaoId, kPrimitiveType type, int vertexCount)=0
Draws non-indexed primitives from the given VAO.
virtual void deleteBuffer(uint32_t id)=0
Destroys the given buffer.
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 void setViewport(int x, int y, int width, int height)=0
Sets the rendering viewport.
virtual void setMultisample(bool enable)=0
Enables or disables multisampling (MSAA).
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 setFramebufferDrawBuffer()=0
Sets the draw buffer of the current FBO to COLOR_ATTACHMENT0.
static void setCurrent(kDriver *driver)
Sets the globally active driver.
Definition kdriver.h:601
virtual kString getApiVersion()=0
Returns a human-readable API version kString.
virtual void setCullMode(kCullMode mode)=0
Selects which polygon faces are culled when culling is enabled.
virtual void setDepthTest(bool enable)=0
Enables or disables the depth test.
virtual void setUniformVec3(uint32_t progId, const kString &name, const kVec3 &v)=0
Sets a kVec3 uniform on the given program.
virtual bool isFramebufferComplete()=0
Checks whether the currently-bound FBO is complete.
virtual void bindFramebuffer(uint32_t id)=0
Binds an FBO as both read and draw framebuffer.
virtual uint32_t createFBOColorTexture(int width, int height)=0
Creates a single-sample colour texture suitable for FBO attachment.
virtual void setupRenderbuffer(uint32_t rboId, int width, int height)=0
Allocates single-sample depth+stencil storage for an RBO.
virtual void attachFBOColorTextureMSAA(uint32_t fboId, uint32_t texId)=0
Attaches a multi-sample colour texture to an MSAA FBO.
virtual void attachFBOColorTexture(uint32_t fboId, uint32_t texId)=0
Attaches a colour texture to the colour attachment of an FBO.
virtual void attachRenderbufferDepthStencil(uint32_t fboId, uint32_t rboId)=0
Attaches an RBO to the depth+stencil attachment of an FBO.
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 void setFrontFace(kFrontFace face)=0
Sets the winding order that defines the front face.
virtual void setupRenderbufferMSAA(uint32_t rboId, int samples, int width, int height)=0
Allocates multi-sample depth+stencil storage for an RBO.
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 setUniformFloat(uint32_t progId, const kString &name, float v)=0
Sets a float 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 unbindVertexArray()=0
Unbinds the current vertex array.
virtual void attachFBODepthTexture(uint32_t fboId, uint32_t texId)=0
Attaches a depth texture to the depth attachment of an FBO.
virtual void destroy()=0
Destroys the graphics context and releases all driver resources.
virtual ~kDriver()=default
virtual void * getNativeContext()=0
Returns the native context handle (e.g. SDL_GLContext for OpenGL).
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 drawIndexed(uint32_t vaoId, int indexCount)=0
Draws indexed triangles from the given VAO.
virtual void bindTextureCube(int unit, uint32_t id)=0
Binds a cube-map texture to the given texture unit.
virtual void setBlendFunc(kBlendFactor src, kBlendFactor dst)=0
Sets the blend equation source and destination factors.
virtual uint32_t createBuffer()=0
Creates and returns a new GPU buffer object.
virtual void setUniformInt(uint32_t progId, const kString &name, int v)=0
Sets an integer uniform on the given program.
virtual void unbindShaderProgram()=0
Unbinds the current shader program.
virtual uint32_t createVertexArray()=0
Creates and returns a new vertex array object (VAO).
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 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 unbindFramebuffer()=0
Binds the default (window) framebuffer.
virtual void deleteFramebuffer(uint32_t id)=0
Destroys the given FBO.
virtual void setDepthWrite(bool enable)=0
Enables or disables writes to the depth buffer.
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 cascad...
virtual uint32_t createFBOColorTextureMSAA(int samples, int width, int height)=0
Creates a multi-sample colour texture suitable for MSAA FBO attachment.
virtual void deleteRenderbuffer(uint32_t id)=0
Destroys the given RBO.
virtual void bindTexture2D(int unit, uint32_t id)=0
Binds a 2D texture to the given texture unit.
static kDriver * getCurrent()
Returns the currently active driver (set via setCurrent()).
Definition kdriver.h:595
virtual void deleteFBOTexture(uint32_t id)=0
Destroys a texture created by createFBOColorTexture / createFBODepthTexture.
virtual uint32_t createFramebuffer()=0
Creates and returns a new framebuffer object (FBO).
virtual void setUniformBool(uint32_t progId, const kString &name, bool v)=0
Sets a boolean uniform on the given program.
virtual bool init(kWindow *window)=0
Initialises the graphics context for the given window.
virtual void bindVertexArray(uint32_t id)=0
Binds the given VAO as the active vertex array.
virtual void setUniformVec2(uint32_t progId, const kString &name, const kVec2 &v)=0
Sets a kVec2 uniform on the given program.
virtual uint32_t createRenderbuffer()=0
Creates and returns a new renderbuffer object (RBO).
virtual void bindDrawFramebuffer(uint32_t id)=0
Binds an FBO as the draw framebuffer only.
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 shad...
Creates and manages an SDL3 application window.
Definition kwindow.h:32
Core type aliases, enumerations, structs, and utility functions used throughout the engine.
Symbol visibility / linkage macro for the Kemena3D library.
#define KEMENA3D_API
Definition kexport.h:35
Top-level Kemena3D engine namespace.
Definition kanimation.h:23
std::string kString
Standard string alias.
Definition kdatatype.h:42
kFrontFace
Winding order that defines the front face of a polygon.
Definition kdriver.h:56
@ CCW
Counter-clockwise winding = front face.
Definition kdriver.h:57
@ CW
Clockwise winding = front face.
Definition kdriver.h:58
kPrimitiveType
Primitive topology for draw calls.
Definition kdriver.h:65
@ TRIANGLE_STRIP
Triangle strip.
Definition kdriver.h:67
@ POINTS
Individual point sprites.
Definition kdriver.h:71
@ TRIANGLE_FAN
Triangle fan.
Definition kdriver.h:68
@ TRIANGLES
Independent triangles (3 vertices each).
Definition kdriver.h:66
@ LINES
Independent line segments (2 vertices each).
Definition kdriver.h:69
@ LINE_STRIP
Connected line strip.
Definition kdriver.h:70
kCullMode
Which polygon faces to cull.
Definition kdriver.h:46
@ BACK
Cull back-facing polygons.
Definition kdriver.h:47
@ FRONT
Cull front-facing polygons.
Definition kdriver.h:48
@ FRONT_AND_BACK
Cull all polygons (geometry only, still runs shaders).
Definition kdriver.h:49
glm::vec2 kVec2
2-component float vector.
Definition kdatatype.h:32
glm::vec4 kVec4
4-component float vector.
Definition kdatatype.h:34
glm::vec3 kVec3
3-component float vector.
Definition kdatatype.h:33
kBlendFactor
Source/destination blend factors for alpha blending.
Definition kdriver.h:31
@ SRC_COLOR
Factor = source colour.
Definition kdriver.h:36
@ ZERO
Factor = 0.
Definition kdriver.h:32
@ DST_ALPHA
Factor = destination alpha.
Definition kdriver.h:38
@ ONE_MINUS_SRC_ALPHA
Factor = 1 - source alpha.
Definition kdriver.h:35
@ ONE_MINUS_DST_ALPHA
Factor = 1 - destination alpha.
Definition kdriver.h:39
@ SRC_ALPHA
Factor = source alpha.
Definition kdriver.h:34
@ ONE
Factor = 1.
Definition kdriver.h:33
@ ONE_MINUS_SRC_COLOR
Factor = 1 - source colour.
Definition kdriver.h:37
glm::mat4 kMat4
4x4 float matrix.
Definition kdatatype.h:39