Пример #1
0
	void DataOutput::WriteByteArray(ByteArray& buffer,
									uint32_t offset,
									uint32_t count)
	{
		if (buffer.GetLength() < offset)
			offset = buffer.GetLength();

		if (count == 0) {
			count = buffer.GetLength()-offset;
		}

		if (count > buffer.GetLength()-offset) {
			ThrowRangeError();
		}
			
		if (count > 0) {
			Write(buffer.GetBuffer()+offset, count);
		}
	}
Пример #2
0
	void DataInput::ReadByteArray(ByteArray& buffer,
								  uint32_t offset,
								  uint32_t count)
	{
		uint32_t available = Available();
		
		if (count == 0) {
			count = available;
		}
		
		if (count > available) {
			ThrowEOFError();
		}

		// Grow the buffer if necessary
		if (offset + count >= buffer.GetLength()) {
			buffer.SetLength(offset + count);
		}

		Read(buffer.GetBuffer() + offset, count);
	}
Пример #3
0
	ByteArray Shader::GetBinary() const
	{
		ByteArray byteArray;

		Context::EnsureContext();

		GLint binaryLength = 0;
		glGetProgramiv(m_program, GL_PROGRAM_BINARY_LENGTH, &binaryLength);

		if (binaryLength > 0)
		{
			byteArray.Reserve(sizeof(UInt64) + binaryLength);

			UInt8* buffer = byteArray.GetBuffer();

			GLenum binaryFormat;
			glGetProgramBinary(m_program, binaryLength, nullptr, &binaryFormat, &buffer[sizeof(UInt64)]);

			// On stocke le format au début du binaire
			*reinterpret_cast<UInt64*>(&buffer[0]) = binaryFormat;
		}

		return byteArray;
	}