summaryrefslogtreecommitdiff
path: root/Runtime/Graphics/ShaderCompiler.h
blob: a9d174bbddb7a8669bb6300343595f70a5f9f4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once

#include <exception>
#include <string>
#include "Runtime/Threading/Mutex.h"
#include "Runtime/Threading/Job.h"
#include "Runtime/Graphics/RenderCommands.h"

// ±ąŅėGLSL(GameLab Shader) 

// in: .glsl path
// out: vsh & fsh
class CompileGLSLJob : public Job
{

};

// in: glsl shader
// out: vsh & fsh 
class CompileGLSLShaderJob : public Job
{

};

class GLSLCompileException : public std::exception
{
public:
    GLSLCompileException(const char* what)
        : std::exception(what)
    {
    }

};

class GLSLCompiler
{
public: 
    static void Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& cmd)/*throw GLSLCompileException*/;

private:
	static std::string GetContent(std::string& src, const char* from, const char* to);
	static std::string TrimContent(std::string& src, const char* from, const char* to);
	static bool IsLabelActive(std::string& src, const char* label);

	static void ParseCmd(std::string& cmd, RenderCommandGroup& group);
	static bool IsCommandActive(std::string& src, const char* label);
	static bool FindCmdPos(std::string& line, int* start, int* end);
	static bool IsLineCommentd(std::string& line);
	static void CommandCull(std::string& params, RenderCommandGroup& group);
	static void CommandBlend(std::string& params, RenderCommandGroup& group);
	static void CommandDepthTest(std::string& params, RenderCommandGroup& group);
	static void CommandDepthWrite(std::string& params, RenderCommandGroup& group);
	static void GetParams(const char* cmdName, std::string& params, std::string* out, int n);

};