| 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 | { |