CLWProgram CLWProgram::CreateFromFile(char const* filename, char const** headernames, int numheaders, char const* buildopts, CLWContext context) { std::vector<char> sourcecode; load_file_contents(filename, sourcecode, false); std::vector<std::vector<char> > headers; std::vector<char const*> headerstrs; std::vector<size_t> headerssizes; if (numheaders > 0) { for (int i = 0; i < numheaders; ++i) { std::vector<char> headersource; load_file_contents(headernames[i], headersource, false); headerssizes.push_back(headersource.size()); headers.push_back(std::move(headersource)); headerstrs.push_back(&headers[i][0]); } return CreateFromSource(&sourcecode[0], sourcecode.size(), &headerstrs[0], headernames, &headerssizes[0], numheaders, buildopts, context); } else { return CreateFromSource(&sourcecode[0], sourcecode.size(), buildopts, context); } }
bool ShaderStage::CreateFromFile(const std::wstring& fullPath, ShaderType type) { if (m_bCreated) return false; std::string src; if (!FileReader::ReadSync(fullPath, src)) { // throw "File not found: " + filePath + "\n" return false; } return CreateFromSource(src, type); }
CLWProgram CLWProgram::CreateFromFile(char const* filename, char const* buildopts, CLWContext context) { std::vector<char> sourcecode; load_file_contents(filename, sourcecode, false); return CreateFromSource(&sourcecode[0], sourcecode.size(), buildopts, context); }