MushMachine/framework/opengl_renderer/test/builtins.cpp

62 lines
1.5 KiB
C++
Raw Normal View History

2022-02-21 00:42:18 +01:00
#include <gtest/gtest.h>
#include <mm/engine.hpp>
#include <mm/services/filesystem.hpp>
#include <mm/services/sdl_service.hpp>
#include <mm/services/opengl_renderer.hpp>
//#include <mm/opengl/res/shaders_builtin.hpp>
#include <mm/opengl/shader.hpp>
#include <mm/opengl/shader_builder.hpp>
#include <mm/fs_const_archiver.hpp> // include only works on files rn
static const char* argv0 = "";
TEST(builtins, all) {
MM::Engine engine;
engine.addService<MM::Services::FilesystemService>(argv0);
ASSERT_TRUE(engine.enableService<MM::Services::FilesystemService>());
engine.addService<MM::Services::SDLService>();
ASSERT_TRUE(engine.enableService<MM::Services::SDLService>());
engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); // adds builtins
engine.update();
FS_CONST_MOUNT_FILE("/shaders/test_frag.glsl",
GLSL_VERSION_STRING
R"(
#ifdef GL_ES
precision mediump float;
#endif
#include "/shaders/builtin/sampling.glsl"
#include "/shaders/builtin/tonemapping.glsl"
#include "/shaders/builtin/hashing.glsl"
2022-04-14 18:03:55 +02:00
#include "/shaders/builtin/noise.glsl"
2022-02-21 00:42:18 +01:00
void main() {
}
)");
auto sb = MM::OpenGL::ShaderBuilder::start();
2022-02-22 01:46:39 +01:00
sb.addStageVertex("void main() { gl_Position = vec4(0.0); }");
2022-02-21 00:42:18 +01:00
sb.addStageFragmentF(engine, "/shaders/test_frag.glsl");
auto shader = sb.finish();
ASSERT_TRUE(shader);
}
int main(int argc, char** argv) {
argv0 = argv[0];
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}