compile shader

First of all, you can determine whether an implementation supports online
shader compilation by checking for the value of GL_SHADER_COMPILER
using glGetBooleanv. If this value is GL_TRUE, then the implementation
supports online shader source compilation. If this value is GL_FALSE, then
only binary shaders are supported (more on that next). Given that an
online compiler is supported, this means you can specify your shaders using
glShaderSource as we have done so far in our examples. There is one thing
you can do to try to mitigate the resource impact of shader compilation.
Once you are finished compiling any shaders for your application, you can
call glReleaseShaderCompiler. This function provides a hint to the
implementation that you are done with the shader compiler and it can free
its resources. Note that this function is only a hint, if you decide to compile
more shaders using glCompileShader, the implementation will need to
reallocate its resources for the compiler.


Example 4-4 Querying for Whether a Shader Compiler is Available

GLboolean shaderCompiler;
GLint numBinaryFormats;
GLint *formats;
// Determine if a shader compiler available
glGetBooleanv(GL_SHADER_COMPILER, &shaderCompiler);
// Determine binary formats available
glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &numBinaryFormats);
formats = malloc(sizeof(GLint) * numBinaryFormats);
glGetIntegerv(GL_SHADER_BINARY_FORMATS, formats);

// "formats" now holds the list of supported binary formats


void glShaderBinary(GLint n, const GLuint* shaders,
GLenum binaryFormat,
const void* binary, GLint length)
n the number of shader objects in the shaders array

shaders an array of shader object handles. Depending on the specific binary format requirements,this will be either a vertex shader object, a fragment shader object, or both.This is defined by the vendor’s shader binary format extension

binaryFormat the vendor-specific binary format token 

binary pointer to the binary data generated by the offline compiler

length the number of bytes in the binary data



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值