Updated compileSource example in docs

Signed-off-by: Alejandro Saucedo <axsauze@gmail.com>
This commit is contained in:
Alejandro Saucedo 2022-01-18 19:59:20 +00:00
parent ea983cb64d
commit 87121c459f

View file

@ -13,11 +13,15 @@ For users that are looking to quickly test the processors it is possible to use
.. code-block:: cpp
:linenos:
static std::vector<uint32_t>
static
std::vector<uint32_t>
compileSource(
const std::string& source)
{
if (system(std::string("glslangValidator --stdin -S comp -V -o tmp_kp_shader.comp.spv << END\n" + source + "\nEND").c_str()))
std::ofstream fileOut("tmp_kp_shader.comp");
fileOut << source;
fileOut.close();
if (system(std::string("glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv").c_str()))
throw std::runtime_error("Error running glslangValidator command");
std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary);
std::vector<char> buffer;
@ -25,6 +29,7 @@ For users that are looking to quickly test the processors it is possible to use
return {(uint32_t*)buffer.data(), (uint32_t*)(buffer.data() + buffer.size())};
}
Converting Shaders into C / C++ Header Files
----------------------------------