16#include <OpenGL/glu.h>
24#include <SDL3/SDL_opengl.h>
89 void clear(
bool color,
bool depth,
bool stencil)
override;
98 void setViewport(
int x,
int y,
int width,
int height)
override;
158 const std::vector<uint8_t> &fragSpirv,
159 const kString &fragEntry)
override;
315 void readPixelsRGBA(
int x,
int y, uint8_t &r, uint8_t &g, uint8_t &b, uint8_t &a)
override;
352 int dstX0,
int dstY0,
int dstX1,
int dstY1)
override;
475 SDL_GLContext glContext =
nullptr;
Pure-virtual graphics driver interface.
Definition kdriver.h:86
void attachFBODepthTextureLayer(uint32_t fboId, uint32_t texId, int layer) override
Attaches a single layer of a depth texture array as the depth attachment.
void setUniformMat4(uint32_t progId, const kString &name, const kMat4 &v) override
Sets a mat4 uniform.
void unbindFramebuffer() override
Unbinds the current FBO, restoring the default framebuffer.
void setUniformVec3(uint32_t progId, const kString &name, const kVec3 &v) override
Sets a vec3 uniform.
uint32_t createFramebuffer() override
Creates a framebuffer object.
void setDepthWrite(bool enable) override
Enables or disables writing to the depth buffer.
void drawIndexed(uint32_t vaoId, int indexCount) override
Issues an indexed draw call (triangles) for the given VAO.
~kOpenGLDriver() override
void bindVertexArray(uint32_t id) override
Binds a vertex array object.
uint32_t compileShaderProgramSpirv(const std::vector< uint8_t > &vertSpirv, const kString &vertEntry, const std::vector< uint8_t > &fragSpirv, const kString &fragEntry) override
Compiles and links a shader program from SPIR-V binaries.
void deleteFramebuffer(uint32_t id) override
Deletes a framebuffer object.
void bindShaderProgram(uint32_t id) override
Makes a shader program current for subsequent draws.
void setDepthTest(bool enable) override
Enables or disables depth testing.
void setSampleAlphaToCoverage(bool enable) override
Enables or disables alpha-to-coverage sampling.
void setUniformBool(uint32_t progId, const kString &name, bool v) override
Sets a bool uniform.
void setUniformFloat(uint32_t progId, const kString &name, float v) override
Sets a float uniform.
void setUniformVec2(uint32_t progId, const kString &name, const kVec2 &v) override
Sets a vec2 uniform.
uint32_t createFBOColorTextureMSAA(int samples, int width, int height) override
Creates a multisampled colour texture suitable for FBO attachment.
kString getShaderVersion() override
Returns the GLSL version kString.
void setMultisample(bool enable) override
Enables or disables multisample anti-aliasing.
void deleteShaderProgram(uint32_t id) override
Deletes a shader program.
void unbindShaderProgram() override
Unbinds the current shader program.
void readTexture2DRGB(uint32_t id, int mipLevel, float *pixels) override
Reads back an RGB float image from a 2D texture mip level.
bool isFramebufferComplete() override
Checks framebuffer completeness.
void bindTextureCube(int unit, uint32_t id) override
Binds a cubemap texture to a texture unit.
void setViewport(int x, int y, int width, int height) override
Sets the rendering viewport rectangle.
void attachFBOColorTextureMSAA(uint32_t fboId, uint32_t texId) override
Attaches a multisampled colour texture to colour attachment 0 of an FBO.
void bindTexture2DArray(int unit, uint32_t id) override
Binds a 2D-array texture to a texture unit.
void setFramebufferDrawBuffer() override
Sets the draw buffer of the bound FBO to colour attachment 0.
void setupRenderbuffer(uint32_t rboId, int width, int height) override
Allocates depth/stencil storage for a renderbuffer.
void attachFBOColorTexture(uint32_t fboId, uint32_t texId) override
Attaches a colour texture to colour attachment 0 of an FBO.
void setUniformVec4(uint32_t progId, const kString &name, const kVec4 &v) override
Sets a vec4 uniform.
void deleteBuffer(uint32_t id) override
Deletes a GPU buffer object.
uint32_t createFBODepthTextureArray(int width, int height, int layers) override
Creates a layered depth texture array (e.g. for cascaded shadow maps).
void attachFBODepthTexture(uint32_t fboId, uint32_t texId) override
Attaches a depth texture to the depth attachment of an FBO.
void setCullFace(bool enable) override
Enables or disables face culling.
uint32_t createRenderbuffer() override
Creates a renderbuffer object.
void unbindTexture2D(int unit) override
Unbinds the 2D texture on a unit.
void setClearColor(float r, float g, float b, float a) override
Sets the colour used to clear the colour buffer.
void setBlend(bool enable) override
Enables or disables alpha blending.
void setupRenderbufferMSAA(uint32_t rboId, int samples, int width, int height) override
Allocates multisampled depth/stencil storage for a renderbuffer.
void setUniformUint(uint32_t progId, const kString &name, uint32_t v) override
Sets an unsigned int uniform.
void drawArrays(uint32_t vaoId, kPrimitiveType type, int vertexCount) override
Issues a non-indexed draw call for the given VAO.
void deleteVertexArray(uint32_t id) override
Deletes a vertex array object.
void unbindTextureCube(int unit) override
Unbinds the cubemap texture on a unit.
void resizeFBOColorTexture(uint32_t texId, int width, int height) override
Reallocates an FBO colour texture to a new size.
uint32_t createFBOColorTexture(int width, int height) override
Creates a colour texture suitable for FBO attachment.
void setBlendFunc(kBlendFactor src, kBlendFactor dst) override
Sets the source and destination blend factors.
void setUniformInt(uint32_t progId, const kString &name, int v) override
Sets an int uniform.
kString getApiVersion() override
Returns the OpenGL version kString.
void uploadIndexBuffer(uint32_t bufferId, const void *data, size_t size) override
Uploads index data into an element array buffer (static draw).
void attachRenderbufferDepthStencil(uint32_t fboId, uint32_t rboId) override
Attaches a renderbuffer as the depth/stencil attachment of an FBO.
void bindTexture2D(int unit, uint32_t id) override
Binds a 2D texture to a texture unit.
void unbindVertexArray() override
Unbinds the current vertex array object.
uint32_t compileShaderProgram(const char *vertSrc, const char *fragSrc) override
Compiles and links a shader program from GLSL source.
void setFrontFace(kFrontFace face) override
Sets the winding order treated as front-facing.
void unbindTexture2DArray(int unit) override
Unbinds the 2D-array texture on a unit.
void readPixelsRGBA(int x, int y, uint8_t &r, uint8_t &g, uint8_t &b, uint8_t &a) override
Reads a single RGBA pixel from the current read framebuffer.
void bindFramebuffer(uint32_t id) override
Binds an FBO as both read and draw target.
uint32_t createFBODepthTexture(int width, int height) override
Creates a depth texture suitable for FBO attachment.
void setVertexAttribFloat(int location, int components, int stride, size_t offset) override
Defines a floating-point vertex attribute layout.
uint32_t createBuffer() override
Creates a GPU buffer object.
void setVertexAttribInt(int location, int components, int stride, size_t offset) override
Defines an integer vertex attribute layout.
void deleteRenderbuffer(uint32_t id) override
Deletes a renderbuffer object.
void setCullMode(kCullMode mode) override
Selects which faces are culled.
uint32_t createVertexArray() override
Creates a vertex array object.
void setUniformMat4Array(uint32_t progId, const kString &name, const std::vector< kMat4 > &v) override
Sets an array-of-mat4 uniform.
void bindReadFramebuffer(uint32_t id) override
Binds an FBO as the read target.
void resizeFBOColorTextureMSAA(uint32_t texId, int samples, int width, int height) override
Reallocates a multisampled FBO colour texture to a new size/sample count.
void generateMipmaps2D(uint32_t id) override
Generates the full mipmap chain for a 2D texture.
void blitFramebufferColor(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1) override
Blits the colour buffer between the read and draw framebuffers (nearest filter).
void setSRGBEncoding(bool enable) override
Enables or disables sRGB framebuffer encoding.
void bindDrawFramebuffer(uint32_t id) override
Binds an FBO as the draw target.
void * getNativeContext() override
Returns the raw SDL_GLContext handle.
void uploadVertexBuffer(uint32_t bufferId, const void *data, size_t size) override
Uploads vertex data into an array buffer (static draw).
void destroy() override
Destroys the SDL GL context.
bool init(kWindow *window) override
Creates an OpenGL 3.3 Core Profile context for the given window.
void clear(bool color, bool depth, bool stencil) override
Clears the selected buffers of the current framebuffer.
void deleteFBOTexture(uint32_t id) override
Deletes an FBO-managed texture.
Creates and manages an SDL3 application window.
Definition kwindow.h:32
Abstract graphics driver interface used by the engine.
#define KEMENA3D_API
Definition kexport.h:35
Application window management backed by SDL3.
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
kPrimitiveType
Primitive topology for draw calls.
Definition kdriver.h:65
kCullMode
Which polygon faces to cull.
Definition kdriver.h:46
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
glm::mat4 kMat4
4x4 float matrix.
Definition kdatatype.h:39