Beispiel #1
0
	void uploadBuffers()
	{
		/* Calculate total quad count */
		size_t groundQuadCount = groundVert.size() / 4;
		size_t quadCount = groundQuadCount;

		for (size_t i = 0; i < scanrowsMax; ++i)
		{
			scanrowBases[i] = quadCount;
			quadCount += scanrowVert[i].size() / 4;
		}

		scanrowBases[scanrowsMax] = quadCount;

		VBO::bind(tiles.vbo);
		VBO::allocEmpty(quadDataSize(quadCount));

		VBO::uploadSubData(0, quadDataSize(groundQuadCount), &groundVert[0]);

		for (size_t i = 0; i < scanrowsMax; ++i)
		{
			if (scanrowVert[i].empty())
				continue;

			VBO::uploadSubData(quadDataSize(scanrowBases[i]),
			                   quadDataSize(scanrowSize(i)), &scanrowVert[i][0]);
		}

		VBO::unbind();

		/* Ensure global IBO size */
		shState->ensureQuadIBO(quadCount);
	}
Beispiel #2
0
	void uploadBuffers()
	{
		scanrowCount = scanrowVert.size();
		scanrowBases.resize(scanrowCount + 1);

		/* Calculate total quad count */
		size_t groundQuadCount = groundVert.v[0].size() / 4;
		size_t quadCount = groundQuadCount;

		for (size_t i = 0; i < scanrowCount; ++i)
		{
			scanrowBases[i] = quadCount;
			quadCount += scanrowVert[i].v[0].size() / 4;
		}

		scanrowBases[scanrowCount] = quadCount;

		size_t bufferFrameQuadCount = quadCount;
		tiles.bufferFrameSize = quadCount * 6 * sizeof(uint32_t);

		quadCount *= bufferCount();

		VBO::bind(tiles.vbo);
		VBO::allocEmpty(quadDataSize(quadCount));

		for (size_t k = 0; k < bufferCount(); ++k)
		{
			VBO::uploadSubData(k*quadDataSize(bufferFrameQuadCount),
			                   quadDataSize(groundQuadCount), &groundVert.v[k][0]);

			for (size_t i = 0; i < scanrowCount; ++i)
			{
				if (scanrowVert[i].v[0].empty())
					continue;

				VBO::uploadSubData(k*quadDataSize(bufferFrameQuadCount) + quadDataSize(scanrowBases[i]),
				                   quadDataSize(scanrowSize(i)), &scanrowVert[i].v[k][0]);
			}
		}

		VBO::unbind();

		/* Ensure global IBO size */
		shState->ensureQuadIBO(quadCount*bufferCount());
	}