Skip to content

Commit bcd13f3

Browse files
committed
Improved backend, rendering, importing, other changes and improvements
1 parent e05e0a9 commit bcd13f3

57 files changed

Lines changed: 1255 additions & 609 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/linux-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Configure dependencies
1717
run: |
1818
sudo apt-get update
19-
sudo apt-get install pkg-config libsdl2-dev libfreeimage-dev libfmt-dev libglm-dev libgtest-dev googletest mesa-common-dev mesa-utils libopenal-dev libalut-dev
19+
sudo apt-get install pkg-config libsdl2-dev libfmt-dev libglm-dev libgtest-dev googletest mesa-common-dev mesa-utils libopenal-dev libalut-dev
2020
sudo apt-get install glslang-tools libavcodec-dev libavformat-dev libswscale-dev libavutil-dev binutils-dev libeigen3-dev libglu1-mesa-dev libbz2-dev \
2121
libzip-dev libogg-dev libopus-dev libvorbis-dev libssl-dev
2222

Common/Common.cpp

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "RenderDesc.h"
55
#include "SampleHelper.h"
66
#include <ProceduralGeometry.h>
7-
#include <internal_object_type.h>
87

98
using namespace glsample;
109
using namespace fragcore;
@@ -149,6 +148,9 @@ void CommonUtil::loadCube(MeshObject &cubeMesh, const float scale, const int seg
149148

150149
glBindVertexArray(0);
151150

151+
glBindBuffer(GL_ARRAY_BUFFER, 0);
152+
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
153+
152154
cubeMesh.nrIndicesElements = indices.size();
153155
cubeMesh.indices_offset = 0;
154156
cubeMesh.vertex_offset = 0;
@@ -244,8 +246,9 @@ void CommonUtil::updateFrameBuffer(FrameBuffer *framebuffer, const std::initiali
244246
const unsigned int height = target_desc.height;
245247
const unsigned int depth = target_desc.depth;
246248
const unsigned int multisamples = target_desc.nrSamples;
247-
const unsigned int maxLODLevels = target_desc.numlevel;
248249
const bool useMultiSampling = multisamples > 1;
250+
const unsigned int maxLODLevels = target_desc.numlevel;
251+
const bool fixedSampling = target_desc.fixedSamples;
249252

250253
const GLenum internal_format = fragcore::GLHelper::getGraphicFormat(target_desc.graphicFormat);
251254

@@ -267,7 +270,11 @@ void CommonUtil::updateFrameBuffer(FrameBuffer *framebuffer, const std::initiali
267270
texture_attachment_name.data());
268271

269272
if (useMultiSampling) {
270-
glTexImage2DMultisample(texture_type, multisamples, internal_format, width, height, GL_TRUE);
273+
if (depth > 1) {
274+
} else {
275+
glTexImage2DMultisample(texture_type, multisamples, internal_format, width, height, GL_TRUE);
276+
}
277+
271278
} else {
272279
if (depth > 1) {
273280
glTexImage3D(texture_type, 0, internal_format, width, height, depth, 0, GL_RGBA, GL_UNSIGNED_BYTE,
@@ -291,12 +298,12 @@ void CommonUtil::updateFrameBuffer(FrameBuffer *framebuffer, const std::initiali
291298
FVALIDATE_GL_CALL(glTexParameteri(texture_type, GL_TEXTURE_MAX_LOD, 0));
292299
FVALIDATE_GL_CALL(glTexParameterf(texture_type, GL_TEXTURE_LOD_BIAS, 0.0f));
293300
FVALIDATE_GL_CALL(glTexParameteri(texture_type, GL_TEXTURE_BASE_LEVEL, 0));
294-
295301
FVALIDATE_GL_CALL(glTexParameteri(texture_type, GL_TEXTURE_MAX_LEVEL, maxLODLevels));
296-
}
297302

298-
if (maxLODLevels > 0) {
299-
glGenerateMipmap(texture_type);
303+
/* */
304+
if (maxLODLevels > 1) {
305+
glGenerateMipmap(texture_type);
306+
}
300307
}
301308

302309
glBindTexture(texture_type, 0);
@@ -322,17 +329,27 @@ void CommonUtil::updateFrameBuffer(FrameBuffer *framebuffer, const std::initiali
322329
const unsigned int depth_width = depthstencil->width;
323330
const unsigned int depth_height = depthstencil->height;
324331
const unsigned int depth_depth = depthstencil->depth;
332+
const bool useMultiSampling = multisamples > 1;
333+
const bool fixedSampling = depthstencil->fixedSamples;
325334
const GLenum internal_format = fragcore::GLHelper::getGraphicFormat(depthstencil->graphicFormat);
326335

336+
/* */
327337
GLenum texture_type = fragcore::GLHelper::getTextureTarget(depthstencil->target);
328338
if (multisamples > 1) {
329339
texture_type = GL_TEXTURE_2D_MULTISAMPLE;
330340
}
331341

332342
/* */
333343
glBindTexture(texture_type, framebuffer->attachments[framebuffer->depthIndex]);
334-
if (multisamples > 0) {
335-
glTexImage2DMultisample(texture_type, multisamples, internal_format, depth_width, depth_height, GL_TRUE);
344+
if (useMultiSampling) {
345+
switch (texture_type) {
346+
case GL_TEXTURE_2D_MULTISAMPLE:
347+
glTexImage2DMultisample(texture_type, multisamples, internal_format, depth_width, depth_height,
348+
fixedSampling);
349+
default:
350+
break;
351+
}
352+
336353
} else {
337354
switch (texture_type) {
338355
case GL_TEXTURE_2D:
@@ -353,7 +370,7 @@ void CommonUtil::updateFrameBuffer(FrameBuffer *framebuffer, const std::initiali
353370
framebuffer->attachmentSize[framebuffer->depthIndex] = {depth_width, depth_height, depth_depth};
354371

355372
/* */
356-
if (multisamples <= 1) {
373+
if (!useMultiSampling) {
357374

358375
const float borderColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
359376
glTexParameterfv(texture_type, GL_TEXTURE_BORDER_COLOR, borderColor);
@@ -376,13 +393,16 @@ void CommonUtil::updateFrameBuffer(FrameBuffer *framebuffer, const std::initiali
376393
glBindTexture(texture_type, 0);
377394
switch (texture_type) {
378395
case GL_TEXTURE_2D:
396+
case GL_TEXTURE_2D_MULTISAMPLE:
379397
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, texture_type,
380398
framebuffer->attachments[framebuffer->depthIndex], 0);
381399
break;
382400
case GL_TEXTURE_CUBE_MAP:
383401
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, framebuffer->attachments[framebuffer->depthIndex],
384402
0);
385403
break;
404+
default:
405+
throw RuntimeException("Failed to bind texture attachment for framebuffer, {}", -1);
386406
}
387407
}
388408

Common/Common.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@
2222

2323
namespace glsample {
2424

25-
/* */
26-
using DrawArraysIndirectCommand = fragcore::IndirectDrawArray;
27-
using DrawElementsIndirectCommand = fragcore::IndirectDrawElement;
28-
using DrawDispatchIndirectCommand = fragcore::IndirectDispatch;
29-
30-
/* */
31-
using TextureDesc = fragcore::TextureDesc;
32-
using SamplerDesc = fragcore::SamplerDesc;
33-
3425
using MeshObject = struct geometry_object_t {
3526
/* */
3627
unsigned int vao = 0;

Common/GLDataStructure.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "RenderDesc.h"
44
#include "SampleHelper.h"
55
#include "Scene/CameraController.h"
6+
#include "Scene/RenderQueue.h"
67
#include <glm/fwd.hpp>
78
#include <glm/matrix.hpp>
89

@@ -36,10 +37,17 @@ namespace glsample {
3637
float fogHeight = 0;
3738
};
3839

39-
using GraphicShaderSettings = struct graphic_shader_settings_t {
40-
fragcore::BlendEqu blend_func_mode = fragcore::BlendEqu::eNoEqu; /* aiBlendMode*/
41-
int wireframe_mode = 0;
42-
CullingMode cullingMode;
40+
// TODO: relocate
41+
using GraphicShaderSettings = struct graphic_shader_settings_t { // Property Maybe ?
42+
fragcore::BlendEqu blend_equ = fragcore::BlendEqu::NoEqu; /* aiBlendMode*/
43+
fragcore::BlendFunc blend_color_func = fragcore::BlendFunc::One;
44+
CullingMode cullingMode = CullingMode::Back;
45+
DepthFunc DepthFunc = DepthFunc::Less;
46+
bool DepthWrite{};
47+
RenderQueue queue;
48+
49+
int wireframe_mode = 0; // TODO; change to fill mode
50+
4351
bool culling_both_side_mode = false;
4452
float clipping = 1;
4553
};

0 commit comments

Comments
 (0)