mirror of
https://github.com/love2d/love.git
synced 2026-08-12 16:40:57 +02:00
Move some Lua code around to work around VS2013's 16kB limitation for C++ raw string literals.
--HG-- branch : minor
This commit is contained in:
@@ -22,6 +22,9 @@ misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
--]]
|
||||
|
||||
local table_concat = table.concat
|
||||
local ipairs = ipairs
|
||||
|
||||
function love.graphics.newVideo(file, settings)
|
||||
settings = settings == nil and {} or settings
|
||||
if type(settings) ~= "table" then error("bad argument #2 to newVideo (expected table)", 2) end
|
||||
@@ -47,5 +50,40 @@ function love.graphics.newVideo(file, settings)
|
||||
return video
|
||||
end
|
||||
|
||||
function love.graphics._transformGLSLErrorMessages(message)
|
||||
local shadertype = message:match("Cannot compile (%a+) shader code")
|
||||
local compiling = shadertype ~= nil
|
||||
if not shadertype then
|
||||
shadertype = message:match("Error validating (%a+) shader")
|
||||
end
|
||||
if not shadertype then return message end
|
||||
local lines = {}
|
||||
local prefix = compiling and "Cannot compile " or "Error validating "
|
||||
lines[#lines+1] = prefix..shadertype.." shader code:"
|
||||
for l in message:gmatch("[^\n]+") do
|
||||
-- nvidia: 0(<linenumber>) : error/warning [NUMBER]: <error message>
|
||||
local linenumber, what, message = l:match("^0%((%d+)%)%s*:%s*(%w+)[^:]+:%s*(.+)$")
|
||||
if not linenumber then
|
||||
-- AMD: ERROR 0:<linenumber>: error/warning(#[NUMBER]) [ERRORNAME]: <errormessage>
|
||||
linenumber, what, message = l:match("^%w+: 0:(%d+):%s*(%w+)%([^%)]+%)%s*(.+)$")
|
||||
end
|
||||
if not linenumber then
|
||||
-- macOS (?): ERROR: 0:<linenumber>: <errormessage>
|
||||
what, linenumber, message = l:match("^(%w+): %d+:(%d+): (.+)$")
|
||||
end
|
||||
if not linenumber and l:match("^ERROR:") then
|
||||
what = l
|
||||
end
|
||||
if linenumber and what and message then
|
||||
lines[#lines+1] = ("Line %d: %s: %s"):format(linenumber, what, message)
|
||||
elseif what then
|
||||
lines[#lines+1] = what
|
||||
end
|
||||
end
|
||||
-- did not match any known error messages
|
||||
if #lines == 1 then return message end
|
||||
return table_concat(lines, "\n")
|
||||
end
|
||||
|
||||
-- DO NOT REMOVE THE NEXT LINE. It is used to load this file as a C++ string.
|
||||
--)luastring"--"
|
||||
|
||||
@@ -434,41 +434,6 @@ function love.graphics._shaderCodeToGLSL(gles, arg1, arg2)
|
||||
return vertexcode, pixelcode
|
||||
end
|
||||
|
||||
function love.graphics._transformGLSLErrorMessages(message)
|
||||
local shadertype = message:match("Cannot compile (%a+) shader code")
|
||||
local compiling = shadertype ~= nil
|
||||
if not shadertype then
|
||||
shadertype = message:match("Error validating (%a+) shader")
|
||||
end
|
||||
if not shadertype then return message end
|
||||
local lines = {}
|
||||
local prefix = compiling and "Cannot compile " or "Error validating "
|
||||
lines[#lines+1] = prefix..shadertype.." shader code:"
|
||||
for l in message:gmatch("[^\n]+") do
|
||||
-- nvidia: 0(<linenumber>) : error/warning [NUMBER]: <error message>
|
||||
local linenumber, what, message = l:match("^0%((%d+)%)%s*:%s*(%w+)[^:]+:%s*(.+)$")
|
||||
if not linenumber then
|
||||
-- AMD: ERROR 0:<linenumber>: error/warning(#[NUMBER]) [ERRORNAME]: <errormessage>
|
||||
linenumber, what, message = l:match("^%w+: 0:(%d+):%s*(%w+)%([^%)]+%)%s*(.+)$")
|
||||
end
|
||||
if not linenumber then
|
||||
-- macOS (?): ERROR: 0:<linenumber>: <errormessage>
|
||||
what, linenumber, message = l:match("^(%w+): %d+:(%d+): (.+)$")
|
||||
end
|
||||
if not linenumber and l:match("^ERROR:") then
|
||||
what = l
|
||||
end
|
||||
if linenumber and what and message then
|
||||
lines[#lines+1] = ("Line %d: %s: %s"):format(linenumber, what, message)
|
||||
elseif what then
|
||||
lines[#lines+1] = what
|
||||
end
|
||||
end
|
||||
-- did not match any known error messages
|
||||
if #lines == 1 then return message end
|
||||
return table_concat(lines, "\n")
|
||||
end
|
||||
|
||||
local defaultcode = {
|
||||
vertex = [[
|
||||
vec4 position(mat4 clipSpaceFromLocal, vec4 localPosition) {
|
||||
|
||||
Reference in New Issue
Block a user