Commit ae71471d authored by Daniel Bernar's avatar Daniel Bernar

Updated to v1.3 beta-candidate

parent 015455ce
......@@ -20,4 +20,33 @@
6. `class ShaderProgram => struct ShaderProgram`
7. Compressed textures for models
8. Added FPS meter in the sample scene
9. Other improvements and fixes
\ No newline at end of file
9. Other improvements and fixes
1.3 beta-candidate:
1. Optimization;
2. Completely changed the architecture of the engine. Now everything is divided into separate modules;
3. Removed `utils/shader_utils.cpp` and `utils/texture_utils.cpp`;
4. All engine modules are placed in the namespace `algine`;
5. `static GLuint loadTexture(const char *path)` and `class TextureArray` from `utils/texture_utils.cpp` moved into `texture.cpp`;
6. `class TextureArray => struct TextureArray`;
7. Removed many obsolete functions and structures (mainly from `algine.cpp`, `utils/texture_utils.cpp`, `utils/shader_utils.cpp`);
8. Renamed most of the structures and their members. No more ugly names like `ALGINE_PATHS_TO_SHADERS`, `ALGINE_PROCESSED_SHADERS`;
9. No more spam in the console when compiling shaders. Logs are displayed only when errors occur. The size of the log buffer is now strictly controlled, and exactly as needed to obtain this data;
10. Some functions like `setVec3`, `setVec4`, `setMat4`, `pointer` from `utils/shader_utils.cpp` (`namespace su`) moved into `algine_renderer.cpp`; `void setVec3 && setVec4 && setMat4 > #define setVec3 && setVec4 && setMat4`;
11. For compatibility with `GLM 0.9.9.0`, you must define `GLM_FORCE_CTOR_INIT`. Note: defined in `algine.cpp`;
12. Fixed comments in the example (`main.cpp`);
13. `algine_renderer.cpp`: used for rendering, has basic functions such as `setVec3`, `setVec4`, `setMat4`, `pointer`. Previously, `struct AlgineRenderer` was literally responsible for everything that multiplied by zero all the flexibility, customizability and embeddedness of the engine. Now it has only a few functions that are used for rendering. Such as: `renderQuad`, `mainPass`, `screenspacePass`, `bloomDofPass`, `bloomPass`,`dofPass`, `doubleBlendPass`, `blendPass`, `prepare`. No pointer-to-function!
<br>`algine_shader_compiler.cpp`: used for generating Algine shaders, for compiling shaders and combining them into programs, for loading ids of objects from Algine shaders, for saving shaders. It has functions of reading and writing;
<br>`algine_structs.cpp`: necessary for the operation of the engine structures
<br>`algine.cpp`: just includes all engine and `glm` files
<br>`constants.h`: engine constants (like `ALGINE_SSR_MODE_ENABLED`)
<br>`framebuffer.cpp`: create, manage, delete framebuffer
<br>`shaderprogram.cpp`: create, manage, delete shader and shader program; has functions for getting info log
<br>`texture.cpp`: create, manage, delete texture;
14. Fix in `model.cpp`: now it’s not necessary to specify paths to all textures. If the texture is not needed, its path can be `nullptr`;
15. Arguments `internalformat = GL_RGB, format = GL_RGB, type = GL_UNSIGNED_BYTE` have been added to `loadTexture`;
16. Added new effect: **SSR** (*Screen Space Reflections*). In this regard, introduced 2 new types of textures: *reflection strength map*, *jitter map*;
17. Due to decentralization of engine functions, memory consumption is reduced;
18. Other changes and improvements.
**If this new architecture is approved, then the process of creating documentation will begin, and the engine will move to the beta stage.**
\ No newline at end of file
# Algine
Algine [Al'gine] - OpenGL 3.3+ engine written in C++
Version: 1.2 alpha
Version: 1.3 beta-candidate
Supported systems: Linux (Windows in the future)
Example of using given in `main.cpp` file
Engine tested on Asus x302uv (Intel Core I5-6200U, Nvidia GeForce 920mx, 8GB RAM, Debian GNU/Linux 9.5.0, 1920x1080 screen) and showed good results
Engine tested on Asus x302uv (Intel Core I5-6200U, Nvidia GeForce 920mx, 8GB RAM, Debian GNU/Linux buster/sid, 1920x1080 screen) and showed good results
If you find any errors or you have recommendations for improving the project - a big one please let me know!
Shaders are written with the expectation that the compiler optimizes their code. In the future, the optimizer may be written
![Algine v1.2 alpha](pictures/6.png)
![Algine v1.3 beta-candidate](pictures/1.png)
# Functionality
* Textures
......@@ -27,10 +27,11 @@ Shaders are written with the expectation that the compiler optimizes their code.
* Bloom
* CMF models support
* Depth of field (DOF)
* SSR (Screen Space Reflections)
* Effect management
* Etc.
Take into account, this is a test (alpha) version! All major functions will be added in later versions.
Take into account, this is a test (beta-candidate) version! All major functions will be added in later versions.
# Dependencies
Engine has next dependencies: `glew`, `glfw`, `glm`.
......
No preview for this file type
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef ALGINE_RENDERER_CPP
#define ALGINE_RENDERER_CPP
#include <iostream>
#include <GL/glew.h>
#include <glm/vec3.hpp>
#include <glm/mat4x4.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "algine_structs.cpp"
#include "texture.cpp"
namespace algine {
static const GLfloat ALGINE_RED[4] = { 1.0, 0.0, 0.0, 0.0 };
#define clearDOFBuffer glClearBufferfv(GL_COLOR, 1, ALGINE_RED);
inline void pointer(int location, int count, GLuint buffer) {
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glVertexAttribPointer(
location, // attribute location
count, // count (2 or 3)
GL_FLOAT, // type
GL_FALSE, // is normalized?
0, // step
(void *)0 // offset
);
}
// GLuint location, glm::vec3 vec
#define setVec3(location, vec) glUniform3f(location, vec.x, vec.y, vec.z)
// GLuint location, glm::mat4 mat
#define setMat4(location, mat) glUniformMatrix4fv(location, 1, GL_FALSE, glm::value_ptr(mat))
// main, god rays, dof (float), depth (float), normal (vec3), reflection strength (float), position (vec3, in world space)
struct AlgineRenderer {
AlginePrograms programs;
AlgineParams *params;
GLuint
quadBuffers[2]; // vertexBuffer and texCoordsBuffer
struct BlusProgram {
GLuint
programId,
inPos,
inTexCoord,
samplerDof,
samplerDofBuffer;
};
BlusProgram blusPrograms[2];
bool horizontal = true, firstIteration = true; // blur variables
void renderQuad(const GLuint &inPosLocation, const GLuint &inTexCoordLocation) {
glEnableVertexAttribArray(inPosLocation);
glEnableVertexAttribArray(inTexCoordLocation);
pointer(inPosLocation, 3, quadBuffers[0]);
pointer(inTexCoordLocation, 2, quadBuffers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableVertexAttribArray(inPosLocation);
glDisableVertexAttribArray(inTexCoordLocation);
}
void mainPass(GLuint displayFBO, GLuint rboBuffer) {
glBindFramebuffer(GL_FRAMEBUFFER, displayFBO);
glBindRenderbuffer(GL_RENDERBUFFER, rboBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, params->SCR_W, params->SCR_H);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboBuffer);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void screenspacePass(GLuint ssFBO, GLuint colorMap, GLuint normalMap, GLuint ssrValuesMap, GLuint positionMap) {
glBindFramebuffer(GL_FRAMEBUFFER, ssFBO);
// developer must do this before call screenspacePass
// glBindTexture(GL_TEXTURE_2D, ssBuffer);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, params.SCR_W, params.SCR_H, 0, GL_RGBA, GL_FLOAT, NULL);
// glBindTexture(GL_TEXTURE_2D, bloomBuffer);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, params.SCR_W, params.SCR_H, 0, GL_RGBA, GL_FLOAT, NULL);
glUseProgram(programs.PROGRAM_ID_SSS);
texture2DAB(0, colorMap);
texture2DAB(1, normalMap);
texture2DAB(2, ssrValuesMap);
texture2DAB(3, positionMap);
renderQuad(programs.SSS_IN_POSITION, programs.SSS_IN_TEXCOORD);
}
void bloomDofPass(const GLuint pingpongFBO[2], const GLuint pingpongBuffers[2], const GLuint dofBuffers[2],
const GLuint bloomMap, const GLuint dofMap, const GLuint sceneMap) {
// developer must do this before call bloomDofPass
// // configuring textures
// for (int i = 0; i < 2; i++) {
// glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]);
// // bloom
// glBindTexture(GL_TEXTURE_2D, pingpongBuffers[i]);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, ALGINE_SCR_W, ALGINE_SCR_H, 0, GL_RGB, GL_FLOAT, NULL);
// // dof
// glBindTexture(GL_TEXTURE_2D, dofBuffers[i]);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, ALGINE_SCR_W, ALGINE_SCR_H, 0, GL_RGBA, GL_FLOAT, NULL);
// }
horizontal = true;
firstIteration = true;
for (int i = 0; i < params->BLUR_AMOUNT; i++) {
glUseProgram(blusPrograms[horizontal].programId);
glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]);
texture2DAB(0, firstIteration ? bloomMap : pingpongBuffers[!horizontal]); // bloom
texture2DAB(1, firstIteration ? sceneMap : dofBuffers[!horizontal]); // dof
texture2DAB(2, dofMap);
// rendering
renderQuad(blusPrograms[horizontal].inPos, blusPrograms[horizontal].inTexCoord);
horizontal = !horizontal;
if (firstIteration) firstIteration = false;
}
}
void bloomPass(const GLuint pingpongFBO[2], const GLuint pingpongBuffers[2],
const GLuint bloomMap) {
// developer must do this before call bloomPass
// // configuring textures
// glActiveTexture(GL_TEXTURE0);
// for (int i = 0; i < 2; i++) {
// // bloom
// glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]);
// glBindTexture(GL_TEXTURE_2D, pingpongBuffers[i]);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, ALGINE_SCR_W, ALGINE_SCR_H, 0, GL_RGB, GL_FLOAT, NULL);
// }
horizontal = true;
firstIteration = true;
for (int i = 0; i < params->BLUR_AMOUNT; i++) {
glUseProgram(blusPrograms[horizontal].programId);
glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]);
// bloom
glBindTexture(GL_TEXTURE_2D, firstIteration ? bloomMap : pingpongBuffers[!horizontal]);
// rendering
renderQuad(blusPrograms[horizontal].inPos, blusPrograms[horizontal].inTexCoord);
horizontal = !horizontal;
if (firstIteration) firstIteration = false;
}
}
void dofPass(const GLuint pingpongFBO[2], const GLuint dofBuffers[2],
const GLuint dofMap, const GLuint sceneMap) {
// // configuring textures
// glActiveTexture(GL_TEXTURE0);
// for (int i = 0; i < 2; i++) {
// // dof
// glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]);
// glBindTexture(GL_TEXTURE_2D, dofBuffers[i]);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, ALGINE_SCR_W, ALGINE_SCR_H, 0, GL_RGBA, GL_FLOAT, NULL);
// }
horizontal = true;
firstIteration = true;
for (int i = 0; i < params->BLUR_AMOUNT; i++) {
glUseProgram(blusPrograms[horizontal].programId);
glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]);
// dof
texture2DAB(1, firstIteration ? sceneMap : dofBuffers[!horizontal]);
texture2DAB(2, dofMap);
// rendering
renderQuad(blusPrograms[horizontal].inPos, blusPrograms[horizontal].inTexCoord);
horizontal = !horizontal;
if (firstIteration) firstIteration = false;
}
}
void doubleBlendPass(const GLuint texture0, const GLuint texture1) {
// Do not need to call glClear, because the texture is completely redrawn
glUseProgram(programs.PROGRAM_ID_BLES);
texture2DAB(0, texture0);
texture2DAB(1, texture1);
renderQuad(programs.BLES_IN_POSITION, programs.BLES_IN_TEXCOORD);
}
void blendPass(const GLuint texture0) {
// Do not need to call glClear, because the texture is completely redrawn
glUseProgram(programs.PROGRAM_ID_BLES);
texture2DAB(0, texture0);
renderQuad(programs.BLES_IN_POSITION, programs.BLES_IN_TEXCOORD);
}
void prepare() {
blusPrograms[0] = BlusProgram {
programs.PROGRAM_ID_BLUS_VERTICAL, programs.BLUS_V_IN_POSITION, programs.BLUS_V_IN_TEXCOORD, programs.BLUS_V_SAMPLER_SCENE, programs.BLUS_V_SAMPLER_DOF_BUFFER
};
blusPrograms[1] = BlusProgram {
programs.PROGRAM_ID_BLUS_HORIZONTAL, programs.BLUS_H_IN_POSITION, programs.BLUS_H_IN_TEXCOORD, programs.BLUS_H_SAMPLER_SCENE, programs.BLUS_H_SAMPLER_DOF_BUFFER
};
// creating buffers for quad rendering
static float
vertices[12] = {
-1.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, -1.0f, 0.0f
},
texCoords[8] = {
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 1.0f,
1.0f, 0.0f
};
glGenBuffers(2, quadBuffers);
glBindBuffer(GL_ARRAY_BUFFER, quadBuffers[0]); // vertices
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, quadBuffers[1]); // texCoords
glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
// blend setting
glUseProgram(programs.PROGRAM_ID_BLES);
glUniform1i(programs.BLES_SAMPLER_BLOOM_SCENE, 1); // GL_TEXTURE1
glUniform1i(programs.BLES_SAMPLER_DOF_SCENE, 0); // GL_TEXTURE0
glUniform1f(programs.BLES_EXPOSURE, params->EXPOSURE);
glUniform1f(programs.BLES_GAMMA, params->GAMMA);
// blur setting
for (size_t i = 0; i < 2; i++) {
glUseProgram(blusPrograms[i].programId);
glUniform1i(blusPrograms[i].samplerDof, 1);
glUniform1i(blusPrograms[i].samplerDofBuffer, 2);
}
// screen space setting
glUseProgram(programs.PROGRAM_ID_SSS);
glUniform1i(programs.SSS_SAMPLER_MAP_NORMAL, 1);
glUniform1i(programs.SSS_SAMPLER_MAP_SSRVALUES, 2);
glUniform1i(programs.SSS_SAMPLER_MAP_POSITION, 3);
glUseProgram(0);
}
~AlgineRenderer() {
glDeleteBuffers(2, quadBuffers);
#ifdef ALGINE_LOGGING
std::cout << "~AlgineRenderer() " << this << "\n";
#endif
}
};
}
#endif /* ALGINE_RENDERER_CPP */
\ No newline at end of file
This diff is collapsed.
#ifndef ALGINE_STRUCTS
#define ALGINE_STRUCTS
#include <iostream>
#include <GL/glew.h>
#include "constants.h"
namespace algine {
struct AlginePrograms {
// CS - color shader
GLuint
// vertex shader
CS_MAT_MODEL,
CS_MAT_VIEW,
CS_MAT_PVM,
CS_MAT_VM,
CS_SWITCH_NORMAL_MAPPING,
CS_IN_POSITION,
CS_IN_NORMAL,
CS_IN_TANGENT,
CS_IN_BITANGENT,
CS_IN_TEXCOORD,
// fragment shader
CS_VIEW_POSITION,
CS_LAMPS_COUNT,
CS_BRIGHTNESS_THRESHOLD,
CS_SHADOW_FAR_PLANE,
CS_SHADOW_DISKRADIUS_K,
CS_SHADOW_DISKRADIUS_MIN,
CS_SHADOW_BIAS,
CS_FOCAL_DEPTH,
CS_FOCAL_RANGE,
//*CS_SHADOW_MAPS, // The loading of these locations is performed by the class TextureArray (utils/texture_utils.cpp)
CS_SAMPLER_MAPPING_AMBIENT,
CS_SAMPLER_MAPPING_DIFFUSE,
CS_SAMPLER_MAPPING_SPECULAR,
CS_SAMPLER_MAPPING_NORMAL,
CS_SAMPLER_MAPPING_REFLECTIONSTRENGTH,
CS_SAMPLER_MAPPING_JITTER,
CS_COLOR_MAPPING_AMBIENT,
CS_COLOR_MAPPING_DIFFUSE,
CS_COLOR_MAPPING_SPECULAR,
CS_SWITCH_TEXTURE_MAPPING;
// *CS_LAMPS; // The loading of these locations is performed by the class Lamp (lamp.cpp)
// SS - shadow shader
GLuint
// vertex shader
SS_MAT_MODEL,
SS_IN_POSITION,
// geometry shader
// SS_MAT_SHADOW[6], // The loading of these locations is performed by the class Lamp (lamp.cpp)
// fragment shader
SS_LAMP_POSITION,
SS_FAR_PLANE;
// BLUS_HORIZONTAL - blur horizontal shader
GLuint
// vertex shader
BLUS_H_IN_POSITION,
BLUS_H_IN_TEXCOORD,
// fragment shader
BLUS_H_SAMPLER_BLOOM,
BLUS_H_SAMPLER_SCENE,
BLUS_H_SAMPLER_DOF_BUFFER,
BLUS_H_SIGMA_MIN,
BLUS_H_SIGMA_MAX,
*BLUS_H_KERNEL_BLOOM;
// BLUS_VERTICAL - blur horizontal shader
GLuint
// vertex shader
BLUS_V_IN_POSITION,
BLUS_V_IN_TEXCOORD,
// fragment shader
BLUS_V_SAMPLER_BLOOM,
BLUS_V_SAMPLER_SCENE,
BLUS_V_SAMPLER_DOF_BUFFER,
BLUS_V_SIGMA_MIN,
BLUS_V_SIGMA_MAX,
*BLUS_V_KERNEL_BLOOM;
// BLES - blend shader
GLuint
// vertex shader
BLES_IN_POSITION,
BLES_IN_TEXCOORD,
// fragment shader
BLES_SAMPLER_BLOOM_SCENE,
BLES_SAMPLER_DOF_SCENE,
BLES_EXPOSURE,
BLES_GAMMA;
// SSS - screen space shader
GLuint
// vertex shader
SSS_IN_POSITION,
SSS_IN_TEXCOORD,
// fragment shader
SSS_SAMPLER_MAP_COLOR,
SSS_SAMPLER_MAP_NORMAL,
SSS_SAMPLER_MAP_SSRVALUES,
SSS_SAMPLER_MAP_POSITION,
SSS_MAT_PROJECTION,
SSS_MAT_VIEW,
SSS_SSR_SKYCOLOR,
SSS_SSR_BINARYSEARCHCOUNT,
SSS_SSR_RAYMARCHCOUNT,
SSS_SSR_STEP,
SSS_SSR_LLIMITER,
SSS_SSR_MINRAYSTEP,
SSS_BL_VECTHRESHOLD,
SSS_BL_BRIGHTNESSTHRESHOLD;
GLuint
PROGRAM_ID_CS,
PROGRAM_ID_SS,
PROGRAM_ID_SSS,
PROGRAM_ID_BLUS_HORIZONTAL,
PROGRAM_ID_BLUS_VERTICAL,
PROGRAM_ID_BLES;
};
struct AlgineParams {
GLubyte
NORMAL_MAPPING_MODE = ALGINE_NORMAL_MAPPING_MODE_ENABLED,
SHADOW_MAPPING_MODE = ALGINE_SHADOW_MAPPING_MODE_ENABLED,
BLOOM_MODE = ALGINE_BLOOM_MODE_ENABLED,
DOF_MODE = ALGINE_DOF_MODE_ENABLED,
TEXTURE_MAPPING_MODE = ALGINE_TEXTURE_MAPPING_MODE_ENABLED,
LIGHTING_MODE = ALGINE_LIGHTING_MODE_ENABLED,
ATTENUATION_MODE = ALGINE_ATTENUATION_MODE_ENABLED,
SSR_MODE = ALGINE_SSR_MODE_ENABLED;
GLuint
MAX_LAMPS_COUNT = 8,
KERNEL_BLOOM_SIZE = 8,
KERNEL_DOF_SIZE = 8,
SCR_W = 1366,
SCR_H = 768,
BLUR_AMOUNT = 4;
GLfloat
GAMMA = 1,
EXPOSURE = 3,
KERNEL_BLOOM_SIGMA = 3;
};
struct ShadersData {
std::string
vertex,
fragment,
geometry = "";
};
#define ShadersPaths ShadersData
} // namespace algine
#endif /* ALGINE_STRUCTS */
\ No newline at end of file
#ifndef ALGINE_CONSTANTS
#define ALGINE_CONSTANTS
#define ALGINE_NORMAL_MAPPING_MODE_ENABLED 0
#define ALGINE_NORMAL_MAPPING_MODE_DUAL 1
#define ALGINE_NORMAL_MAPPING_MODE_DISABLED 2
#define ALGINE_SHADOW_MAPPING_MODE_ENABLED 3
#define ALGINE_SHADOW_MAPPING_MODE_SIMPLE 4
#define ALGINE_SHADOW_MAPPING_MODE_DISABLED 5
#define ALGINE_BLOOM_MODE_ENABLED 6
#define ALGINE_BLOOM_MODE_DISABLED 7
#define ALGINE_DOF_MODE_ENABLED 8
#define ALGINE_DOF_MODE_DISABLED 9
#define ALGINE_TEXTURE_MAPPING_MODE_ENABLED 10
#define ALGINE_TEXTURE_MAPPING_MODE_DUAL 11
#define ALGINE_TEXTURE_MAPPING_MODE_DISABLED 12
#define ALGINE_LIGHTING_MODE_ENABLED 13
#define ALGINE_LIGHTING_MODE_DISABLED 14
#define ALGINE_ATTENUATION_MODE_ENABLED 15
#define ALGINE_ATTENUATION_MODE_DISABLED 16
#define ALGINE_SSR_MODE_ENABLED 17
#define ALGINE_SSR_MODE_DISABLED 18
#endif /* ALGINE_CONSTANTS */
\ No newline at end of file
#ifndef ALGINE_FRAMEBUFFER_CPP
#define ALGINE_FRAMEBUFFER_CPP
#include <GL/glew.h>
#include "texture.cpp"
namespace algine {
#define bindFramebuffer(framebuffer) glBindFramebuffer(GL_FRAMEBUFFER, framebuffer)
struct Framebuffer {
static void create(GLuint *id) {
glGenFramebuffers(1, id);
}
static void create(GLuint *id, GLuint count) {
glGenFramebuffers(count, id);
}
static void attachTexture(GLuint textureId, GLuint colorAttachment) {
glBindTexture(GL_TEXTURE_2D, textureId);
applyDefaultTextureParams();
glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachment, GL_TEXTURE_2D, textureId, 0);
}
static void destroy(GLuint *id) {
glDeleteFramebuffers(1, id);
}
};
}
#endif /* ALGINE_FRAMEBUFFER_CPP */
\ No newline at end of file
......@@ -16,9 +16,10 @@
#include <iostream>
#include "utils/shader_utils.cpp"
#include "algine_renderer.cpp"
#include "model.cpp"
namespace algine {
#define LAMP_FAR_PLANE 32.0f
class Lamp {
......@@ -69,9 +70,9 @@ class Lamp {
void push_shininess() { glUniform1i(propLocations[3], shininess); }
void push_lampPos() { su::setVec3(propLocations[4], pos); }
void push_lampPos() { setVec3(propLocations[4], pos); }
void push_lampColor() { su::setVec3(propLocations[5], color); }
void push_lampColor() { setVec3(propLocations[5], color); }
void push_kc() { glUniform1f(propLocations[6], kc); }
......@@ -111,11 +112,11 @@ class Lamp {
}
void setLightPos() {
su::setVec3(lightPosLocation, pos);
setVec3(lightPosLocation, pos);
}
void setShadowMatrices() {
for (size_t i = 0; i < 6; i++) su::setMat4(shadowMatricesLocations[i], lightSpaceMatrices[i]);
for (size_t i = 0; i < 6; i++) setMat4(shadowMatricesLocations[i], lightSpaceMatrices[i]);
}
void updateMatrices() {
......@@ -264,4 +265,6 @@ class LampModel : public Lamp {
}
};
} // namespace algine
#endif /* ALGINE_LAMP_CPP */
\ No newline at end of file
This diff is collapsed.
......@@ -14,9 +14,9 @@
#include <iostream>
#include "lib/libcmf/arraysmaker.cpp"
#include "texture.cpp"
#include "utils/texture_utils.cpp"
namespace algine {
#define XYZ 3
#define XY 2
#define TRIANGLE 3
......@@ -113,17 +113,19 @@ class ModelBuffers {
class ModelMapping {
public:
GLuint textures[4];
GLuint textures[6];
void init(const char *atex, const char *dtex, const char *stex, const char *ntex) {
textures[0] = loadTexture(atex);
textures[1] = loadTexture(dtex);
textures[2] = loadTexture(stex);
textures[3] = loadTexture(ntex);
void init(const char *atex, const char *dtex, const char *stex, const char *ntex, const char *rstex, const char *jtex) {
textures[0] = atex != nullptr ? loadTexture(atex) : 0;
textures[1] = dtex != nullptr ? loadTexture(dtex) : 0;
textures[2] = stex != nullptr ? loadTexture(stex) : 0;
textures[3] = ntex != nullptr ? loadTexture(ntex) : 0;
textures[4] = rstex != nullptr ? loadTexture(rstex) : 0;
textures[5] = jtex != nullptr ? loadTexture(jtex) : 0;
}
void recycle() {
glDeleteTextures(4, textures);
glDeleteTextures(6, textures);
}
};
......@@ -190,23 +192,23 @@ class Model {
std::swap(angles, other.angles);
}
GLuint getVerticesBuffer() {
inline GLuint getVerticesBuffer() {
return buffers->buffers[0];
}
GLuint getNormalsBuffer() {
inline GLuint getNormalsBuffer() {
return buffers->buffers[1];
}
GLuint getTexCoordsBuffer() {
inline GLuint getTexCoordsBuffer() {
return buffers->buffers[2];
}
GLuint getTangentsBuffer() {
inline GLuint getTangentsBuffer() {
return buffers->buffers[3];
}
GLuint getBitangentsBuffer() {
inline GLuint getBitangentsBuffer() {
return buffers->buffers[4];
}
......@@ -219,4 +221,6 @@ class Model {
#undef XY
#undef TRIANGLE
} // namespace algine
#endif
\ No newline at end of file
......@@ -21,15 +21,12 @@ vec3 bloom_result;
#ifdef ALGINE_DOF_MODE_ENABLED
layout (location = 1) out vec4 dofFragColor;
uniform sampler2D image2; // dof
uniform sampler2D scene; // dof
uniform sampler2D dofBuffer;
uniform float max_sigma;
uniform float min_sigma;
float dof_kernel[DOF_KERNEL_SIZE];
vec3 dof_result;
vec4 tmp;
float fdof;
const int DOF_LCR_SIZE = DOF_KERNEL_SIZE * 2 - 1; // left-center-right (lllcrrr)
const int DOF_MEAN = DOF_LCR_SIZE / 2;
......@@ -53,14 +50,12 @@ void main() {
#ifdef ALGINE_BLOOM_MODE_ENABLED