Ejemplo n.º 1
0
	void handleAutotile(int x, int y, int tileInd, TileVBuffer *array)
	{
		/* Which autotile [0-7] */
		int atInd = tileInd / 48 - 1;
		/* Which tile pattern of the autotile [0-47] */
		int subInd = tileInd % 48;

		const StaticRect *pieceRect = &autotileRects[subInd*4];

		/* Iterate over the 4 tile pieces */
		for (int i = 0; i < 4; ++i)
		{
			FloatRect posRect = getAutotilePieceRect(x*32, y*32, i);
			FloatRect texRect = pieceRect[i];

			/* Adjust to atlas coordinates */
			texRect.y += atInd * autotileH;

			for (size_t k = 0; k < bufferCount(); ++k)
			{
				FloatRect _texRect = texRect;

				if (contains(atlas.animatedATs, atInd))
					_texRect.x += autotileW*k;

				SVertex v[4];
				Quad::setTexPosRect(v, _texRect, posRect);

				/* Iterate over 4 vertices */
				for (size_t i = 0; i < 4; ++i)
					array->v[k].push_back(v[i]);
			}
		}
	}
Ejemplo n.º 2
0
otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
{
    otError  error = OT_ERROR_NONE;
    uint8_t  copyLength;
    uint16_t index = 0;

    otEXPECT_ACTION(aOutput && aOutputLength, error = OT_ERROR_INVALID_ARGS);

    do
    {
        copyLength = (uint8_t)bufferCount();

        if (copyLength > aOutputLength - index)
        {
            copyLength = aOutputLength - index;
        }

        if (copyLength > 0)
        {
            for (uint32_t i = 0; i < copyLength; i++)
            {
                aOutput[i + index] = bufferGet();
            }

            generatorStart();

            index += copyLength;
        }
    } while (index < aOutputLength);

exit:
    return error;
}
Ejemplo n.º 3
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());
	}
Ejemplo n.º 4
0
	void handleTile(int x, int y, int z)
	{
		int tileInd = mapData->at(x, y, z);

		/* Check for empty space */
		if (tileInd < 48)
			return;

		int prio = samplePriority(tileInd);

		/* Check for faulty data */
		if (prio == -1)
			return;

		TileVBuffer *targetArray;

		/* Prio 0 tiles are all part of the same ground layer */
		if (prio == 0)
		{
			targetArray = &groundVert;
		}
		else
		{
			int scanInd = y + prio;
			targetArray = &scanrowVert[scanInd];
		}

		/* Check for autotile */
		if (tileInd < 48*8)
		{
			handleAutotile(x, y, tileInd, targetArray);
			return;
		}

		int tsInd = tileInd - 48*8;
		int tileX = tsInd % 8;
		int tileY = tsInd / 8;

		Vec2i texPos = TileAtlas::tileToAtlasCoor(tileX, tileY, atlas.efTilesetH, atlas.size.y);
		FloatRect texRect((float) texPos.x+.5, (float) texPos.y+.5, 31, 31);
		FloatRect posRect(x*32, y*32, 32, 32);

		SVertex v[4];
		Quad::setTexPosRect(v, texRect, posRect);

		for (size_t k = 0; k < bufferCount(); ++k)
			for (size_t i = 0; i < 4; ++i)
				targetArray->v[k].push_back(v[i]);
	}
Ejemplo n.º 5
0
void LadybugPlayerThread::run()
{
  // fill in a buffer with loaded, decoded frames
  // when full: sleep

  LadybugImage image;

  while (!shouldStop())
  {
    mStreamMutex.lock();
    bool res = mStream.readNextFrame(image);
    mStreamMutex.unlock();
    if (!res)
    {
      printf("end of stream!\n");
      stopPlayer();
      break;
    }

    if (image.isValid())
    {
      // we have a valid frame - decode and enqueue it
      processImage(mStream.currentFrame(), image);
    }
    else
    {
      fprintf(stderr, "read invalid image\n");
    }

    // if our buffer is full, take rest
    while (bufferCount() >= 5 && !shouldStop())
    {
      fprintf(stderr, "buffer full, sleeping\n");
      msleep(20);
    }
  }

  // enqueue invalid frame to signal that we've finished
  mBufferMutex.lock();
  LadybugPlayerFrame invalidFrame;
  invalidFrame.frameId = -1;
  mBuffer.enqueue(invalidFrame);
  mHasFrame.wakeOne();
  mBufferMutex.unlock();
}
Ejemplo n.º 6
0
void Effect::checkGate( double _out_sum )
{
	if( m_autoQuitDisabled )
	{
		return;
	}

	// Check whether we need to continue processing input.  Restart the
	// counter if the threshold has been exceeded.
	if( _out_sum - gate() <= typeInfo<float>::minEps() )
	{
		incrementBufferCount();
		if( bufferCount() > timeout() )
		{
			stopRunning();
			resetBufferCount();
		}
	}
	else
	{
		resetBufferCount();
	}
}
Ejemplo n.º 7
0
static inline bool bufferIsFull(void)
{
    return (bufferCount() >= RNG_BUFFER_SIZE);
}
Ejemplo n.º 8
0
static inline bool bufferIsUint32Ready(void)
{
    return (bufferCount() >= 4);
}
Ejemplo n.º 9
0
static inline bool bufferIsEmpty(void)
{
    return (bufferCount() == 0);
}