Buffer CircularBuffer::readAsBuffer(uint32_t nLen, uint32_t nOffset, bool from_end) { Buffer buffer; std::string str = readAsString(nLen,nOffset,from_end); if(!str.empty()) { buffer.append(str); } return buffer; }
bool CircularBuffer::readAsBuffer(Buffer &out,uint32_t nLen, uint32_t nOffset, bool from_end) { out.retrieveAll(); std::string str = readAsString(nLen,nOffset,from_end); if(!str.empty()) { out.append(str); } return true; }
GLuint loadShaderProgram(const std::string& vsPath, const std::string& fsPath, const std::vector<std::string>& attributes) { GLuint vsID = glCreateShader(GL_VERTEX_SHADER); GLuint fsID = glCreateShader(GL_FRAGMENT_SHADER); // Compile Vertex Shader std::string source = readAsString(vsPath); char const* vsSource = source.c_str(); glShaderSource(vsID, 1, &vsSource, nullptr); glCompileShader(vsID); Logger::shaderErrorCheck(vsID, vsPath); // Compile Fragment Shader source = readAsString(fsPath); char const* fsSource = source.c_str(); glShaderSource(fsID, 1, &fsSource, nullptr); glCompileShader(fsID); Logger::shaderErrorCheck(fsID, fsPath); GLuint programID = glCreateProgram(); glAttachShader(programID, vsID); glAttachShader(programID, fsID); GLuint index = 0; for (auto& attribute : attributes) glBindAttribLocation(programID, index++, attribute.c_str()); glLinkProgram(programID); Logger::programErrorCheck(programID, vsPath, fsPath); glDeleteShader(vsID); glDeleteShader(fsID); GL_ERROR_CHECK(); return programID; }
string Buffer::readAllAsString() { return readAsString(readableBytes()); }