September 2018
Intermediate to advanced
472 pages
15h 36m
English
Start by compiling the shader pair into SPIR-V using the glslangValidator tool:
glslangValidator -G -o basic.vert.spv basic.vert.glslglslangValidator -G -o basic.frag.spv basic.frag.glsl
If successful, this produces the basic.vert.spv and basic.frag.spv SPIR-V output files.
To load your SPIR-V shaders into an OpenGL program, use glShaderBinary and glSpecializeShader. With glShaderBinary, use GL_SHADER_BINARY_FORMAT_SPIR_V as the binary format:
GLuint vertShader = glCreateShader(GL_VERTEX_SHADER);// Load the shader into a std::vectorstd::ifstream inStream("basic.vert.spv", std::ios::binary);std::istreambuf_iterator<char> startIt(inStream), endIt;std::vector<char> buffer(startIt, endIt);inStream.close();// Load using glShaderBinary ...Read now
Unlock full access