MCPcopy Create free account
hub / github.com/dfranx/SHADERed / LoadBufferFromFile

Method LoadBufferFromFile

src/SHADERed/Objects/ObjectManager.cpp:766–792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764 return ret;
765 }
766 bool ObjectManager::LoadBufferFromFile(BufferObject* buf, const std::string& str)
767 {
768 ed::Logger::Get().Log("Loading buffer data from a file");
769
770 std::string bPath = m_parser->GetProjectPath(str);
771 std::ifstream bufRead(bPath, std::ios::binary | std::ios::ate);
772 size_t bufSize = bufRead.tellg();
773 bufRead.seekg(0, std::ios::beg);
774
775 bool ret = bufRead.is_open();
776 if (ret) {
777 buf->Size = bufSize;
778 buf->Data = realloc(buf->Data, bufSize);
779 char* data = (char*)calloc(1, bufSize);
780 bufRead.read(data, bufSize);
781 memcpy(buf->Data, data, bufSize);
782 free(data);
783
784 glBindBuffer(GL_UNIFORM_BUFFER, buf->ID);
785 glBufferData(GL_UNIFORM_BUFFER, buf->Size, buf->Data, GL_STATIC_DRAW); // upload data
786 glBindBuffer(GL_UNIFORM_BUFFER, 0);
787 }
788
789 bufRead.close();
790
791 return ret;
792 }
793
794 bool ObjectManager::ReloadTexture(ObjectManagerItem* item, const std::string& newPath)
795 {

Callers 1

UpdateMethod · 0.80

Calls 5

LogMethod · 0.80
GetProjectPathMethod · 0.80
is_openMethod · 0.80
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected