Skip to content

Commit

Permalink
Check if tonumber on gl.SHADING_LANGUAGE_VERSION returns nil, a…
Browse files Browse the repository at this point in the history
…nd treat it as old (compat) profile. [fixes #2]
  • Loading branch information
nanoant committed Aug 15, 2012
1 parent 93cc8de commit 939fb88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function gl.program(shaderPaths)
-- do not append new line if it is not necessary
if glCoreProfile and not source:find('^%s*#version') then
local version = tonumber(gl.GetString(gl.SHADING_LANGUAGE_VERSION))
source = string.format('#version %d core%s%s', version * 100, source:find('^%s*/[*/]') and ' ' or "\n", source)
if version ~= nil then source = string.format('#version %d core%s%s', version * 100, source:find('^%s*/[*/]') and ' ' or "\n", source) end
end
local shader = gl.CreateShader(type)
gl.ShaderSource(shader, source)
Expand Down
3 changes: 2 additions & 1 deletion tests/glGetString.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ print(' GL_MAX_TEXTURE_IMAGE_UNITS = '..gl.Get(gl.MAX_TEXTURE_IMAGE_UNITS))
print(' GL_MAX_TEXTURE_SIZE = '..gl.Get(gl.MAX_TEXTURE_SIZE))
print('GL_MAX_VERTEX_UNIFORM_COMPONENTS = '..gl.Get(gl.MAX_VERTEX_UNIFORM_COMPONENTS))

if tonumber(gl.GetString(gl.SHADING_LANGUAGE_VERSION)) < 1.50 then
local version = tonumber(gl.GetString(gl.SHADING_LANGUAGE_VERSION))
if version == nil or version < 1.50 then
print()
print('GL_EXTENSIONS = '..gl.GetString(gl.EXTENSIONS))
end

0 comments on commit 939fb88

Please sign in to comment.