34 #ifdef __native_client__
51 const char *ptrStr = str.c_str();
52 GLuint shaderId = mglCreateShader(type);
53 mglShaderSource(shaderId, 1, &ptrStr,
nullptr);
54 mglCompileShader(shaderId);
58 if (isCompiled == GL_TRUE)
59 return new Shader(shaderId);
63 mglGetShaderInfoLog(shaderId, len, &len, buf);
67 mglDeleteShader(shaderId);
72 const std::string &fragment,
73 const bool isNewShader)
77 if (vertexShader ==
nullptr)
83 if (fragmentShader ==
nullptr)
89 GLuint programId = mglCreateProgram();
97 mglAttachShader(programId, vertexShader->
getShaderId());
98 mglAttachShader(programId, fragmentShader->
getShaderId());
100 mglBindFragDataLocation(programId, 0,
"outColor");
102 mglBindAttribLocation(programId, 0,
"position");
103 mglLinkProgram(programId);
106 if (isLinked == GL_TRUE)
108 mglValidateProgram(programId);
109 GLint isValidated = 0;
111 if (isValidated == GL_TRUE)
112 return new ShaderProgram(programId, vertexShader, fragmentShader);
113 mglDeleteProgram(programId);
119 char *buf =
new char[
CAST_SIZE(len) + 1];
120 mglGetProgramInfoLog(programId, len, &len, buf);
122 logger->
log(
"Program '%s, %s' compilation error: %s",
124 fragmentShader->
mIdPath.c_str(),
127 mglDeleteProgram(programId);
std::string getStringValue(const std::string &key) const
void log(const char *const log_text,...)
unsigned int getShaderId() const
ShaderProgram * getGles2Program()
ShaderProgram * createProgram(const std::string &vertex, const std::string &fragment, const bool isNewShader)
ShaderProgram * getSimpleProgram()
Shader * createShader(const unsigned int type, const std::string &fileName)
#define GL_FRAGMENT_SHADER
#define GL_VALIDATE_STATUS
#define GL_COMPILE_STATUS
#define GL_INFO_LOG_LENGTH
Resource * getShader(const unsigned int type, const std::string &name)
std::string loadTextFileString(const std::string &fileName)