love.graphics.newShader: add a compile options table parameter.

The only field currently read from the table is 'defines', which can contain either an array of define names, or name-value pairs.
For example: newShader(file, {defines={"MYFEATURE_ENABLED", MYSETTING=1}})

Fixes #1577
This commit is contained in:
Alex Szpakowski
2022-02-20 12:23:41 -04:00
parent bc1c38d361
commit 0fa00e0bdc
7 changed files with 94 additions and 28 deletions
+6 -1
View File
@@ -107,6 +107,11 @@ public:
ACCESS_WRITE = (1 << 1),
};
struct CompileOptions
{
std::map<std::string, std::string> defines;
};
struct SourceInfo
{
Language language;
@@ -236,7 +241,7 @@ public:
void getLocalThreadgroupSize(int *x, int *y, int *z);
static SourceInfo getSourceInfo(const std::string &src);
static std::string createShaderStageCode(Graphics *gfx, ShaderStageType stage, const std::string &code, const SourceInfo &info, bool gles, bool checksystemfeatures);
static std::string createShaderStageCode(Graphics *gfx, ShaderStageType stage, const std::string &code, const CompileOptions &options, const SourceInfo &info, bool gles, bool checksystemfeatures);
static bool validate(StrongRef<ShaderStage> stages[], std::string &err);