GlistEngine
Loading...
Searching...
No Matches
gVKRenderEngine.h
Go to the documentation of this file.
1//
2// Created by sadettin on 13.08.2025.
3//
4
5#pragma once
6
7#ifndef CORE_GVKRENDERENGINE_H
8#define CORE_GVKRENDERENGINE_H
9#include "gRenderer.h"
10#include "gUbo.h"
11#include <unordered_map>
12#include <vector>
13
14// All Vulkan objects live behind these opaque types, so <vulkan/vulkan.h> is not
15// pushed into every translation unit that includes this header and the class
16// still compiles on platforms that have no Vulkan headers.
17struct gVKContext;
18struct gVKTexture;
19struct gVKFramebuffer;
20struct gVKMeshBuffer;
21struct gVKDeferredResources;
22
23// What a vertex array id stands for: the pair of buffer ids that were bound while
24// it was current, 0 meaning nothing was bound. Vulkan has no vertex array object,
25// but gVbo binds one around every upload and every draw, so remembering the pairing
26// is what lets a draw find the buffers it is about. Defined here rather than in
27// gVKMeshBuffer.h because it holds no Vulkan types and so needs no Vulkan headers.
29 GLuint vertexbuffer = 0;
30 GLuint indexbuffer = 0;
31 // A vertex array that is drawn instanced has a second array buffer holding one
32 // model matrix per instance. gVbo uploads it through the same entry points as
33 // the vertex data, so the backend tells them apart by order: the first array
34 // buffer a vertex array sees is its vertices, a later different one is the
35 // instance data. setVertexAttribDivisor confirms it.
36 GLuint instancebuffer = 0;
37};
38
39class gVKRenderEngine : public gRenderer {
40public:
41 gVKRenderEngine() = default;
42 ~gVKRenderEngine() override;
43
44 bool beginFrame() override;
45 void endFrame() override;
46 void flushQueuedDraws() override;
47
48 bool setupDeferredLighting(int width, int height) override;
49 bool resizeDeferredLighting(int width, int height) override;
52 void endDeferredLighting() override;
53 void releaseDeferredLighting() override;
54 bool isDeferredGeometryPassActive() const override;
55
56 void clear() override;
57 void clearColor(int r, int g, int b, int a = 255) override;
58 void clearColor(gColor color) override;
59 // Records a clear into the pass that is already open; see the note in the .cpp.
60 void clearColorNow(float r, float g, float b, float a);
61
62 // Takes the camera's OpenGL-style projection and stores the Vulkan equivalent.
63 // See gVKRenderEngine.cpp for what the correction is and why the Y axis is not
64 // part of it.
65 void setProjectionMatrix(glm::mat4 projectionMatrix) override;
66
67 void takeScreenshot(gImage& img, int x, int y, int width, int height) override;
68 void takeScreenshot(gImage& img) override;
69
70 void enableDepthTest() override;
71 void enableDepthTest(int depthTestType) override;
72 void setDepthTestFunc(int depthTestType) override;
73 void disableDepthTest() override;
74 bool isDepthTestEnabled() override;
75 int getDepthTestType() override;
76 void enableCulling() override;
77 void disableCulling() override;
78 void setCullFace(int face) override;
79 void setCullingDirection(int direction) override;
80
81 void enableAlphaBlending() override;
82 void setBlendMode(int blendMode) override;
83 void disableAlphaBlending() override;
84 bool isAlphaBlendingEnabled() override;
85 void enableAlphaTest() override;
86 void disableAlphaTest() override;
87 bool isAlphaTestEnabled() override;
88
89 /* -------------- gUbo ------------- */
90 GLuint genBuffers() override;
91 void deleteBuffer(GLuint& buffer) override;
92
93 void bindBuffer(GLenum target, GLuint buffer) override;
94 void unbindBuffer(GLenum target) override;
95
96 void bufSubData(GLuint buffer, int offset, int size, const void* data) override;
97 void setBufferData(GLuint buffer, const void* data, size_t size, int usage) override;
98 void setBufferRange(int index, GLuint buffer, int offset, int size) override;
99
100 /* -------------- gVbo --------------- */
101 GLuint createVAO() override;
102 void deleteVAO(GLuint& vao) override;
103
104 void bindVAO(GLuint vao) override;
105 void unbindVAO() override;
106
107 void setVertexBufferData(GLuint vbo, size_t size, const void* data, int usage) override;
108 void setIndexBufferData(GLuint ebo, size_t size, const void* data, int usage) override;
109
110 void drawArrays(int drawMode, int count) override;
111 void drawElements(int drawMode, int count) override;
112 void drawArraysInstanced(int drawMode, int count, int instanceCount) override;
113 void drawElementsInstanced(int drawMode, int count, int instanceCount) override;
114
115 void enableVertexAttrib(int index) override;
116 void disableVertexAttrib(int index) override;
117 void setVertexAttribPointer(int index, int size, int type, bool normalized, int stride, const void* pointer) override;
118 void setVertexAttribDivisor(int index, int divisor) override;
119 void setViewport(int x, int y, int width, int height) override;
120
121 /* -------------- gFbo --------------- */
122 GLuint createFramebuffer() override;
123 void deleteFramebuffer(GLuint& fbo) override;
124 void bindFramebuffer(GLuint fbo) override;
125 void checkFramebufferStatus() override;
126
127 GLuint createRenderbuffer() override;
128 void deleteRenderbuffer(GLuint& rbo) override;
129 void bindRenderbuffer(GLuint rbo) override;
130 void setRenderbufferStorage(GLenum format, int width, int height) override;
131
132 void attachTextureToFramebuffer(GLenum attachment, GLenum textarget, GLuint texId, GLuint level = 0) override;
133 void attachRenderbufferToFramebuffer(GLenum attachment, GLuint rbo) override;
134
135 void setDrawBufferNone() override;
136 void setReadBufferNone() override;
137
138 void createFullscreenQuad(GLuint& vao, GLuint& vbo) override;
139 void deleteFullscreenQuad(GLuint& vao, GLuint* vbo) override;
140
141 /* -------------- gShader --------------- */
142 // This function loads shaders without preproccesing them. Geometry source can be nullptr.
143 GLuint loadProgram(const char* vertexSource, const char* fragmentSource, const char* geometrySource) override;
144 void setShaderSourcePaths(const std::string& vertexPath, const std::string& fragmentPath) override;
145 void checkCompileErrors(GLuint shader, const std::string& type) override;
146 void setBool(GLuint uniformloc, bool value) override;
147 void setInt(GLuint uniformloc, int value) override;
148 void setUnsignedInt(GLuint uniformloc, unsigned int value) override;
149 void setFloat(GLuint uniformloc, float value) override;
150 void setVec2(GLuint uniformloc, const glm::vec2& value) override;
151 void setVec2(GLuint uniformloc, float x, float y) override;
152 void setVec3(GLuint uniformloc, const glm::vec3& value) override;
153 void setVec3(GLuint uniformloc, float x, float y, float z) override;
154 void setVec4(GLuint uniformloc, const glm::vec4& value) override;
155 void setVec4(GLuint uniformloc, float x, float y, float z, float w) override;
156 void setMat2(GLuint uniformloc, const glm::mat2& mat) override;
157 void setMat3(GLuint uniformloc, const glm::mat3& mat) override;
158 void setMat4(GLuint uniformloc, const glm::mat4& mat) override;
159 GLuint getUniformLocation(GLuint id, const std::string& name) override;
160
161 void useShader(GLuint id) const override;
162 void resetShader(GLuint id, bool loaded) const override;
163
164 void attachUbo(GLuint id, int bindingpoint, const std::string& uboName) override {
165 unsigned int blockIndex;
166 G_CHECK_GL2(blockIndex, glGetUniformBlockIndex(id, uboName.c_str()));
167 G_CHECK_GL(glUniformBlockBinding(id, blockIndex, bindingpoint));
168 /*if (blockIndex != GL_INVALID_INDEX) {
169 GLint blockSize;
170 G_CHECK_GL(glGetActiveUniformBlockiv(id, blockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &blockSize));
171
172 GLint blockAlignment;
173 G_CHECK_GL(glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &blockAlignment));
174
175 std::cout << "Uniform block alignment: " << blockAlignment << " bytes" << std::endl;
176
177 // Now 'blockSize' contains the size of the uniform block in bytes
178 std::cout << "Uniform block size: " << blockSize << " bytes" << std::endl;
179 if (ubo->getSize() != blockSize) {
180 std::cout << "Error: Uniform block size mismatch. actual size: " << ubo->getSize() << ", block size: " << blockSize << std::endl;
181 }
182 } else {
183 std::cerr << "Error: Unable to find uniform block index." << std::endl;
184 }*/
185 }
186
187 /* ------------ gPostProcessManager ------------- */
188 void clearScreen(bool color = true, bool depth = true) override;
189 void bindQuadVAO() override;
190 void drawFullscreenQuad() override;
191 void bindDefaultFramebuffer() override;
192
193 /* -------------- gGrid --------------- */
194 void drawVbo(const gVbo& vbo) override;
195 void drawVbo(const gVbo& vbo, const glm::mat4& model, const gMeshSurface& surface) override;
196
197 /* ---------------- gTexture ---------------- */
198 GLuint createTextures() override;
199 void bindTexture(GLuint texId) override;
200 void bindTexture(GLuint texId, int textureSlotNo) override;
201 void unbindTexture() override;
202 void activateTexture(int textureSlotNo = 0) override;
203 void resetTexture() override;
204 void deleteTexture(GLuint& texId) override;
205
206 void texImage2D(GLenum target, GLint internalFormat, int width, int height, GLint format, GLint type, void* data, GLint level = 0) override;
207 void setTextureMaxLevel(GLenum target, int maxLevel) override;
208 void setWrapping(GLenum target, GLint wrapS, GLint wrapT) override;
209 void setWrapping(GLenum target, GLint wrapS, GLint wrapT, GLint wrapR) override;
210
211 void setFiltering(GLenum target, GLint minFilter, GLint magFilter) override;
212 void setWrappingAndFiltering(GLenum target, GLint wrapS, GLint wrapT, GLint minFilter, GLint magFilter) override;
213 void setWrappingAndFiltering(GLenum target, GLint wrapS, GLint wrapT, GLint wrapR, GLint minFilter, GLint magFilter) override;
214 void setSwizzleMask(GLint swizzleMask[4]) override;
215
216 void readTexturePixels(unsigned char* inPixels, GLuint textureId, int width, int height, GLenum format) override;
217 void readTexturePixelsHDR(float* inPixels, GLuint textureId, int width, int height, GLenum format) override;
218
219 void generateMipMap() override;
220
221 /* ---------------- gSkybox ---------------- */
222 void bindSkyTexture(GLuint texId) override;
223 void bindSkyTexture(GLuint texId, int textureSlot) override;
224 void unbindSkyTexture() override;
225 void unbindSkyTexture(int textureSlotNo) override;
226 void generateSkyMipMap() override;
227 void enableDepthTestEqual() override;
228 void createQuad(GLuint& inQuadVAO, GLuint& inQuadVBO) override;
229 void enableCubeMap() override;
230
231 /* ---------------- gRenderObject ---------------- */
232 void pushMatrix() override;
233 void popMatrix() override;
234
235 /* ---------------- 2D draw path ---------------- */
236 // Records coloured 2D geometry into the active frame (the Vulkan side of the
237 // primitive meshes). drawMode is a GL primitive constant, the same one the mesh
238 // would hand OpenGL. No-op if no frame is active.
239 void drawColored2D(const glm::vec2* points, int count, const glm::vec4& color, const glm::mat4& mvp,
240 int drawMode = GL_TRIANGLES) override;
241
242 // Records a textured quad using the registered Vulkan texture for textureId
243 // (the Vulkan side of gImage / gTexture::draw and drawSub). No-op if the id is
244 // unknown. An unknown mask id draws unmasked rather than dropping the image.
245 void drawMesh3D(GLuint vertexArrayId, int vertexCount, int indexCount,
246 const glm::mat4& model, const gMeshSurface& surface,
247 int drawMode = GL_TRIANGLES, int instanceCount = 1) override;
248
249 bool drawSkyboxFace(GLuint textureId, const float* xyzuv, int vertexCount,
250 const glm::mat4& viewProjection) override;
251
252 bool allocateShadowMap(int width, int height) override;
253 void releaseShadowMap() override;
254 bool beginShadowPass() override;
255 void endShadowPass() override;
256 bool isShadowPassActive() const override;
257 void setShadowMapState(bool enabled, const glm::mat4& lightMatrix,
258 const glm::vec3& lightPosition, bool softShadows) override;
259
260 // Drops the gathered scene block so the next 3D draw rebuilds it; see the base
261 // declaration for why the two backends cannot share one moment for this.
262 void updateLights() override;
263
264 // Rebuilds the swapchain with the present mode the new setting asks for.
265 void setVsync(bool enabled) override;
266
267 // Rebuilds the screen render pass, its attachments and every pipeline at the new
268 // sample count. Like setVsync, the work is deferred to the next frame boundary,
269 // because this can be called from anywhere - including mid-frame with a command
270 // buffer already recording.
271 void setMultiSampling(int samples) override;
272 int getMultiSampling() const override;
273
274 void drawTexturedRect2D(GLuint textureId, GLuint maskTextureId, const glm::vec4& tint,
275 const glm::mat4& mvp,
276 const glm::vec2& uvOffset = glm::vec2(0.0f), const glm::vec2& uvScale = glm::vec2(1.0f)) override;
277 void drawTexturedTriangles2D(GLuint textureId, const glm::vec4& tint,
278 const glm::mat4& mvp, const float* xyuv, int vertexCount) override;
279
280 /* ---------------- Vulkan context ---------------- */
281 // gVKContext is opaque here (its layout lives in the .cpp), so a developer can
282 // reach the accessor rich context without this header ever pulling in
283 // <vulkan/vulkan.h>. getContext() creates the context on first access when it
284 // does not exist yet, so on a Vulkan-capable build it never returns null:
285 // getContext()->setMinApiVersion(...) before init() is safe, and init() adopts
286 // this same context. Whether the handles are actually populated is a separate
287 // question - check isInitialized() before using them. (A build without Vulkan
288 // support has no context type, so there it returns null.)
289 gVKContext* getContext();
290
291 // Takes ownership. Any context the engine already holds is torn down first -
292 // its Vulkan objects destroyed and its memory freed through cleanupVulkan() -
293 // so replacing a context never leaks the old one. The self assignment guard
294 // avoids destroying the very context being handed in. The engine frees the
295 // adopted context on cleanup.
296 void setContext(gVKContext* context);
297
298protected:
299 void init() override;
300 void cleanup() override;
301private:
302 enum class DeferredState {
303 Uninitialized,
304 Ready,
305 GeometryActive
306 };
307 DeferredState deferredstate = DeferredState::Uninitialized;
308 int deferredwidth = 0;
309 int deferredheight = 0;
310 gVKDeferredResources* deferredresources = nullptr;
311
312 mutable GLuint currentprogram = 0;
313 bool initVulkan();
314 void cleanupVulkan();
315 gVKContext* vkcontext = nullptr;
316 void updatePackUnpackAlignment(int i) override;
317
318 // Registry backing the GLuint texture ids gTexture/gImage hand out: createTextures
319 // mints an id, texImage2D fills the Vulkan texture for the currently bound id,
320 // and deleteTexture frees it. boundtextureid mirrors the OpenGL bind state that
321 // gTexture's upload path relies on.
322 std::unordered_map<GLuint, gVKTexture*> vktextures;
323 GLuint nextvktextureid = 1;
324 GLuint boundtextureid = 0;
325 // What each texture unit holds. The engine's own draws read only the one texture
326 // bound last, which is what boundtextureid is for, but a user shader can declare
327 // several samplers and point each at a unit of its own - so the units have to be
328 // remembered separately rather than collapsed onto the last bind.
329 static constexpr int GVK_TEXTURE_UNITS = 8;
330 GLuint boundtextureunits[GVK_TEXTURE_UNITS] = {};
331 int activetextureunit = 0;
332 // Offscreen render targets, one per gFbo. Each owns a render pass and a
333 // framebuffer of its own, the same shape the shadow map already uses, because
334 // this backend renders through render passes rather than dynamic rendering.
335 std::unordered_map<GLuint, gVKFramebuffer*> vkframebuffers;
336 GLuint nextvkframebufferid = 1;
337 // Renderbuffers have no Vulkan counterpart: gFbo is steered onto a sampleable
338 // depth texture instead, so these ids only have to be unique and non-zero.
339 GLuint nextvkrenderbufferid = 1;
340 // Ends whatever offscreen pass is open and hands its attachments back to the
341 // shader as sampleable textures. Safe to call when none is open.
342 void endOffscreenPass();
343 void destroyAllFramebuffers();
344 // Builds a target's render pass and framebuffer on first use.
345 bool ensureFramebufferPass(gVKFramebuffer* target);
346 // Vertex array ids. Vulkan has no such object, but gVbo binds one before every
347 // upload and every draw, so the id is what tells the backend which pair of
348 // buffers a draw is about. See gVKMeshBuffer.h.
349 std::unordered_map<GLuint, gVKVertexArray> vkvertexarrays;
350 GLuint nextvkvaoid = 1;
351 GLuint boundvaoid = 0;
352
353 // Registry backing the GLuint buffer names gVbo hands out. genBuffers mints an
354 // id, setVertexBufferData / setIndexBufferData fill it, deleteBuffer frees it.
355 // boundarraybufferid mirrors the OpenGL bind state, which is what lets a vertex
356 // array learn which buffer belongs to it.
357 std::unordered_map<GLuint, gVKMeshBuffer*> vkmeshbuffers;
358 GLuint nextvkbufferid = 1;
359 GLuint boundarraybufferid = 0;
360 GLuint boundelementbufferid = 0;
361
362 // Fetches the buffer behind an id, or null if the id was never minted. Uploading
363 // creates the VkBuffer lazily, so the entry can exist while its handle is still
364 // VK_NULL_HANDLE.
365 gVKMeshBuffer* getMeshBuffer(GLuint id);
366 void destroyAllMeshBuffers();
367
368 // A 1x1 white texture bound wherever a mesh has no map of that kind. The 3D
369 // shader samples its map bindings unconditionally from Vulkan's point of view -
370 // the "use this map" flag only decides what happens to the result - so every
371 // binding has to point at something valid. White is the identity for the
372 // multiply that follows, which keeps an unmapped material's colours untouched.
373 GLuint whitetextureid = 0;
374 bool ensureWhiteTexture();
375
376 // One identity matrix, bound as the instance buffer of a draw that is not
377 // instanced. The 3D shader always reads a per-instance model matrix, so this is
378 // what lets a single pipeline and a single shader serve both kinds of draw:
379 // multiplying by the identity leaves the mesh where its own model matrix put it.
380 gVKMeshBuffer* identityinstancebuffer = nullptr;
381 bool ensureIdentityInstanceBuffer();
382
383 // What gShadowMap last told the backend. Fed into the scene uniform block, and
384 // into the depth pass's push constant while the shadow pass is being recorded.
385 bool shadowmapenabled = false;
386 // A depth-only clear issued while recording the shadow traversal marks the
387 // start of a first-person/overlay section. The world recorded before it must
388 // remain in the shadow map, while later meshes must not become shadow casters.
389 bool shadowcasterrecordingclosed = false;
390 // Set by the depth-only clear which starts a first-person overlay. Later meshes
391 // keep lighting but do not receive the world's shadow map.
392 bool firstpersonoverlayactive = false;
393 bool shadowsoft = false;
394 glm::mat4 shadowlightmatrix{1.0f};
395 glm::vec3 shadowlightposition{0.0f};
396
397
398 // Fills the frame's scene uniform block from the renderer's camera and lights.
399 // Declared unconditionally: this header does not pull in the Vulkan guard, and
400 // the definition is what is compiled out on a build without Vulkan.
401 void updateSceneUniforms();
402 // Whether this frame's scene block has been written yet. Reset in beginFrame, so
403 // the camera and lights are gathered once per frame instead of once per mesh.
404 bool sceneuniformswritten = false;
405
406 // Consecutive opaque mesh calls are safe to combine because their relative
407 // order is preserved. Transparent meshes and caller-provided instancing stay
408 // immediate: changing either would alter the public draw semantics.
409 struct QueuedMeshDraw {
410 GLuint vertexarrayid = 0;
411 int vertexcount = 0;
412 int indexcount = 0;
413 int drawmode = GL_TRIANGLES;
414 int instancecount = 1;
415 glm::mat4 model{1.0f};
416 gMeshSurface surface{};
417 glm::vec4 tint{1.0f};
418 bool depthtest = false;
419 int depthtesttype = DEPTHTESTTYPE_LESS;
420 bool culling = false;
421 int cullface = GL_BACK;
422 int cullingdirection = GL_CCW;
423 // A digest of everything canMergeQueuedDraws compares, filled when the draw
424 // is queued. flushQueuedDraws sorts by it so that draws which could merge but
425 // arrived apart end up next to each other; the exact comparison still decides
426 // whether they really do, so a hash collision costs a missed merge and
427 // nothing else.
428 uint64_t mergekey = 0;
429 };
430 std::vector<QueuedMeshDraw> queuedmeshdraws;
431 bool flushingqueueddraws = false;
432 static uint64_t gvkQueuedDrawKey(const QueuedMeshDraw& draw);
433 bool canMergeQueuedDraws(const QueuedMeshDraw& first, const QueuedMeshDraw& next) const;
434 void recordQueuedDrawGroup(size_t first, size_t count);
435 void destroyAllTextures();
436 // The Vulkan texture behind the currently bound id, or null when there is none
437 // yet - gTexture sets filtering and wrapping both before and after the upload.
438 gVKTexture* getBoundVKTexture();
439 // The texture bound to one unit, for gVKUserShader's sampler resolution.
440 gVKTexture* getVKTextureAtUnit(int unit);
441
442 // Applies a pending setMultiSampling at a frame boundary: everything the sample
443 // count is baked into - the render pass, the depth and MSAA attachments, the
444 // framebuffers and both pipeline builds - is destroyed and rebuilt. Returns
445 // straight away when nothing was requested, which is the normal case.
446 void applyPendingSampleCount();
447 // The sample count an app asked for before the context existed, and the pending
448 // request applyPendingSampleCount acts on. 0 means "nothing pending".
449 int pendingsamplecount = 0;
450
451 // Shader hot reload. Development builds watch the .vert / .frag sources the 2D
452 // pipelines are compiled from and rebuild them when one is saved, so a shader
453 // can be tuned without restarting. Release builds compile nothing at runtime,
454 // the timestamp stays 0 and this costs one comparison per frame.
455 void checkShaderReload();
456 long long shadersourcetimestamp = 0;
457 int shaderpollcountdown = 0;
458};
459
460#endif
Definition gColor.h:17
Definition gImage.h:34
static int height
Definition gRenderer.h:711
static int width
Definition gRenderer.h:711
gRenderer()=default
static const int DEPTHTESTTYPE_LESS
Definition gRenderer.h:135
void updateLights() override
gVKRenderEngine()=default
void disableDepthTest() override
void bindQuadVAO() override
void setRenderbufferStorage(GLenum format, int width, int height) override
void checkCompileErrors(GLuint shader, const std::string &type) override
void bindTexture(GLuint texId) override
void setVec2(GLuint uniformloc, const glm::vec2 &value) override
bool isAlphaBlendingEnabled() override
bool beginFrame() override
void cleanup() override
void setInt(GLuint uniformloc, int value) override
void popMatrix() override
void setShadowMapState(bool enabled, const glm::mat4 &lightMatrix, const glm::vec3 &lightPosition, bool softShadows) override
void resetTexture() override
void setBool(GLuint uniformloc, bool value) override
void enableDepthTest() override
void drawFullscreenQuad() override
void setTextureMaxLevel(GLenum target, int maxLevel) override
void deleteTexture(GLuint &texId) override
void deleteBuffer(GLuint &buffer) override
void setVec3(GLuint uniformloc, float x, float y, float z) override
void setVertexAttribPointer(int index, int size, int type, bool normalized, int stride, const void *pointer) override
void deleteRenderbuffer(GLuint &rbo) override
void setMat2(GLuint uniformloc, const glm::mat2 &mat) override
void setVec3(GLuint uniformloc, const glm::vec3 &value) override
void endFrame() override
void drawVbo(const gVbo &vbo, const glm::mat4 &model, const gMeshSurface &surface) override
void setVsync(bool enabled) override
void readTexturePixels(unsigned char *inPixels, GLuint textureId, int width, int height, GLenum format) override
void deleteFullscreenQuad(GLuint &vao, GLuint *vbo) override
void setCullFace(int face) override
void setMat3(GLuint uniformloc, const glm::mat3 &mat) override
void generateSkyMipMap() override
void pushMatrix() override
void endShadowPass() override
void releaseShadowMap() override
void bindFramebuffer(GLuint fbo) override
void setContext(gVKContext *context)
void setBufferRange(int index, GLuint buffer, int offset, int size) override
void bindSkyTexture(GLuint texId, int textureSlot) override
void unbindSkyTexture() override
void setWrapping(GLenum target, GLint wrapS, GLint wrapT, GLint wrapR) override
void bindRenderbuffer(GLuint rbo) override
int getDepthTestType() override
void unbindSkyTexture(int textureSlotNo) override
void bindVAO(GLuint vao) override
GLuint genBuffers() override
void clearColor(gColor color) override
void setViewport(int x, int y, int width, int height) override
void setWrappingAndFiltering(GLenum target, GLint wrapS, GLint wrapT, GLint minFilter, GLint magFilter) override
void texImage2D(GLenum target, GLint internalFormat, int width, int height, GLint format, GLint type, void *data, GLint level=0) override
void clear() override
void checkFramebufferStatus() override
void flushQueuedDraws() override
void clearColorNow(float r, float g, float b, float a)
void generateMipMap() override
void setVec2(GLuint uniformloc, float x, float y) override
void init() override
void unbindTexture() override
void enableDepthTestEqual() override
bool isDepthTestEnabled() override
void setIndexBufferData(GLuint ebo, size_t size, const void *data, int usage) override
void disableCulling() override
void setMat4(GLuint uniformloc, const glm::mat4 &mat) override
void createFullscreenQuad(GLuint &vao, GLuint &vbo) override
void endDeferredLighting() override
void disableVertexAttrib(int index) override
void enableCulling() override
bool allocateShadowMap(int width, int height) override
void disableAlphaTest() override
void setUnsignedInt(GLuint uniformloc, unsigned int value) override
void attachRenderbufferToFramebuffer(GLenum attachment, GLuint rbo) override
GLuint createVAO() override
void enableAlphaTest() override
void disableAlphaBlending() override
void clearScreen(bool color=true, bool depth=true) override
void activateTexture(int textureSlotNo=0) override
GLuint createFramebuffer() override
void bufSubData(GLuint buffer, int offset, int size, const void *data) override
void setReadBufferNone() override
void setCullingDirection(int direction) override
void setBlendMode(int blendMode) override
void setVertexBufferData(GLuint vbo, size_t size, const void *data, int usage) override
void bindDefaultFramebuffer() override
void enableVertexAttrib(int index) override
void enableDepthTest(int depthTestType) override
void drawElementsInstanced(int drawMode, int count, int instanceCount) override
void drawVbo(const gVbo &vbo) override
void setMultiSampling(int samples) override
GLuint getUniformLocation(GLuint id, const std::string &name) override
bool drawSkyboxFace(GLuint textureId, const float *xyzuv, int vertexCount, const glm::mat4 &viewProjection) override
void setVertexAttribDivisor(int index, int divisor) override
void clearColor(int r, int g, int b, int a=255) override
void setFiltering(GLenum target, GLint minFilter, GLint magFilter) override
bool isAlphaTestEnabled() override
void createQuad(GLuint &inQuadVAO, GLuint &inQuadVBO) override
void setProjectionMatrix(glm::mat4 projectionMatrix) override
void resetShader(GLuint id, bool loaded) const override
bool resizeDeferredLighting(int width, int height) override
void useShader(GLuint id) const override
void setBufferData(GLuint buffer, const void *data, size_t size, int usage) override
void drawArrays(int drawMode, int count) override
void deleteVAO(GLuint &vao) override
void setSwizzleMask(GLint swizzleMask[4]) override
bool renderDeferredLightingPass() override
int getMultiSampling() const override
void setVec4(GLuint uniformloc, float x, float y, float z, float w) override
void drawArraysInstanced(int drawMode, int count, int instanceCount) override
void setWrappingAndFiltering(GLenum target, GLint wrapS, GLint wrapT, GLint wrapR, GLint minFilter, GLint magFilter) override
void setShaderSourcePaths(const std::string &vertexPath, const std::string &fragmentPath) override
void takeScreenshot(gImage &img) override
void unbindVAO() override
void enableCubeMap() override
void bindBuffer(GLenum target, GLuint buffer) override
void drawTexturedTriangles2D(GLuint textureId, const glm::vec4 &tint, const glm::mat4 &mvp, const float *xyuv, int vertexCount) override
void attachTextureToFramebuffer(GLenum attachment, GLenum textarget, GLuint texId, GLuint level=0) override
void bindSkyTexture(GLuint texId) override
void releaseDeferredLighting() override
void drawColored2D(const glm::vec2 *points, int count, const glm::vec4 &color, const glm::mat4 &mvp, int drawMode=GL_TRIANGLES) override
gVKContext * getContext()
void drawElements(int drawMode, int count) override
void unbindBuffer(GLenum target) override
void enableAlphaBlending() override
bool beginShadowPass() override
bool isDeferredGeometryPassActive() const override
void setFloat(GLuint uniformloc, float value) override
void drawMesh3D(GLuint vertexArrayId, int vertexCount, int indexCount, const glm::mat4 &model, const gMeshSurface &surface, int drawMode=GL_TRIANGLES, int instanceCount=1) override
void setVec4(GLuint uniformloc, const glm::vec4 &value) override
GLuint createRenderbuffer() override
bool setupDeferredLighting(int width, int height) override
GLuint loadProgram(const char *vertexSource, const char *fragmentSource, const char *geometrySource) override
bool beginDeferredGeometryPass() override
void takeScreenshot(gImage &img, int x, int y, int width, int height) override
void attachUbo(GLuint id, int bindingpoint, const std::string &uboName) override
Definition gVKRenderEngine.h:164
void bindTexture(GLuint texId, int textureSlotNo) override
void setWrapping(GLenum target, GLint wrapS, GLint wrapT) override
void drawTexturedRect2D(GLuint textureId, GLuint maskTextureId, const glm::vec4 &tint, const glm::mat4 &mvp, const glm::vec2 &uvOffset=glm::vec2(0.0f), const glm::vec2 &uvScale=glm::vec2(1.0f)) override
GLuint createTextures() override
void deleteFramebuffer(GLuint &fbo) override
void setDepthTestFunc(int depthTestType) override
void readTexturePixelsHDR(float *inPixels, GLuint textureId, int width, int height, GLenum format) override
~gVKRenderEngine() override
void setDrawBufferNone() override
bool isShadowPassActive() const override
Definition gVbo.h:30
float r
Definition gColor.h:22
float a
Definition gColor.h:22
float b
Definition gColor.h:22
float g
Definition gColor.h:22
#define G_CHECK_GL(fn)
Definition gRenderer.h:68
#define G_CHECK_GL2(value, fn)
Definition gRenderer.h:69
Definition gRenderer.h:290
Definition gVKRenderEngine.h:28
GLuint vertexbuffer
Definition gVKRenderEngine.h:29
GLuint indexbuffer
Definition gVKRenderEngine.h:30
GLuint instancebuffer
Definition gVKRenderEngine.h:36