mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
refactor GLSLExtension.cpp & add 'param' shader preprocessor directive & add PostEffect class (WIP)
This commit is contained in:
parent
531334f059
commit
1feee3a809
8 changed files with 263 additions and 97 deletions
32
test/coders/GLSLExtension.cpp
Normal file
32
test/coders/GLSLExtension.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "coders/commons.hpp"
|
||||
#include "coders/GLSLExtension.hpp"
|
||||
|
||||
TEST(GLSLExtension, processing) {
|
||||
GLSLExtension glsl;
|
||||
glsl.addHeader("sum",
|
||||
"// sum function for glsl\n"
|
||||
"float sum(float a, float b) {\n"
|
||||
" return a + b;\n"
|
||||
"}\n"
|
||||
);
|
||||
try {
|
||||
auto processed = glsl.process("test.glsl",
|
||||
"in vec2 v_uv;\n"
|
||||
"uniform sampler2D u_screen;\n"
|
||||
"\n"
|
||||
"#include /* hell\no */ < sum >\n"
|
||||
"#param float p_intensity\n"
|
||||
"\n"
|
||||
"vec4 effect() {\n"
|
||||
" vec4 color = texture(u_screen, v_uv);\n"
|
||||
" return mix(color, 1.0 - color, p_intensity);\n"
|
||||
"}\n",
|
||||
false);
|
||||
std::cout << processed << std::endl;
|
||||
} catch (const parsing_error& err) {
|
||||
std::cerr << err.errorLog() << std::endl;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue