bool M2DFx::compileShader(const M2DShader& shader) { glCompileShader(shader.id); GLint result = 0xDEADBEEF; glGetShaderiv(shader.id, GL_COMPILE_STATUS, &result); if(!result) { std::cout << "Could not compile shader: " << shader.id << std::endl; outputShaderLog(shader.id); return false; } return true; }
//----------------------------------------------------------------------------// GLuint OpenGLES2Shader::compile(GLuint type, const std::string &source) { // Create shader object checkGLErrors(); GLuint shader = glCreateShader(type); if (shader == 0) { std::stringstream stringStream; stringStream << "Critical Error - Could not create shader object of type:" << type << "."; CEGUI_THROW(RendererException(stringStream.str().c_str())); return 0; } checkGLErrors(); // Define shader source and compile const char* src = source.data(); int len = source.size(); glShaderSource(shader, 1, &src, &len); glCompileShader(shader); // Check for errors GLint status; glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if (status != GL_TRUE) { outputShaderLog(shader); return 0; } checkGLErrors(); return shader; }