VertexBuffer::VertexBuffer(RenderContext* rc, const VertexDeclaration& decl, const BinaryDataStorage& data, BufferDrawType vertexDrawType, const std::string& aName) : APIObject(aName), _rc(rc), _decl(decl), _drawType(vertexDrawType) { GLuint buffer = 0; glGenBuffers(1, &buffer); setAPIHandle(buffer); setData(data.data(), data.dataSize()); }
void Renderer::readFramebufferData(const vec2i& size, TextureFormat format, DataType dataType, BinaryDataStorage& data) { ET_ASSERT((8 * data.size()) >= (size.square() * bitsPerPixelForTextureFormat(format, dataType))); glReadPixels(0, 0, size.x, size.y, textureFormatValue(format), dataTypeValue(dataType), data.data()); checkOpenGLError("glReadPixels"); }
void PVRLoader::loadInfoFromStream(std::istream& stream, TextureDescription& desc) { std::istream::off_type offset = stream.tellg(); desc.minimalDataSize = 32; desc.dataLayout = TextureDataLayout_MipsFirst; PVRHeader2 header2 = { }; stream.read(reinterpret_cast<char*>(&header2), sizeof(header2)); if (header2.dwPVR == pvrHeader2) { PVRLoader::loadInfoFromV2Header(header2, desc); } else { stream.seekg(offset, std::ios_base::beg); PVRHeader3 header3 = { }; BinaryDataStorage meta; stream.read(reinterpret_cast<char*>(&header3), sizeof(header3)); if (header3.version == PVRHeaderV3Version) { if (header3.metaDataSize > 0) { meta.resize(header3.metaDataSize); stream.read(meta.binary(), header3.metaDataSize); } PVRLoader::loadInfoFromV3Header(header3, meta, desc); } else { log::error("Unrecognized PVR input stream"); } } }