Example #1
0
void ITexture::Load()
{
    if (!m_bLoaded && m_pTextureManager)
    {
        if (m_bCompressed)
        {
            m_pTextureManager->SetCompressedTextureData(this,(Initial::Format::IImageITX*)m_pTempData);
        } else {
            IImage *image = (IImage*)m_pTempData;
            if (image)
                m_pTextureManager->SetTextureData(this,image->GetData(),image->GetWidth(),image->GetHeight(),image->GetFormat() == 4 ? ITF_RGBA : ITF_RGB,image->GetFormat());
            /*else
            	m_pTextureManager->SetTextureData(this,NULL,m_iWidth,m_iHeight,ITF_RGB,IIF_RGB);*/
        }

        delete m_pTempData;
        m_bLoaded=true;
    }
}
Example #2
0
	void CMPIRayTracer::renderScheme1(ICamera* camera, const CScene* scene, unsigned int maxDepth)
	{
		if (!camera || !scene)
			return;

		IImage* pImageBuffer = camera->GetImageBuffer();
		mpScene = scene;

		unsigned int width = pImageBuffer->GetWidth();
		unsigned int height = pImageBuffer->GetHeight();

		CRay ray;
		CColor finalColor;

		MPI_Init(&mCommandLineParamsCount, &mCommandLineParams);

		int processId = 0;
		int processCount = 0;

		MPI_Comm_rank(MPI_COMM_WORLD, &processId);
		MPI_Comm_size(MPI_COMM_WORLD, &processCount);

		unsigned int totalSize = width * height;
		unsigned int size = totalSize / processCount;
		unsigned int bufIdx = 0;
		unsigned int x, y;
		unsigned int upperBorder = 0;
		unsigned char* pBuffer = nullptr;
		unsigned char* pResultBuffer = new unsigned char[totalSize * 3];

		int* pBlocksLengths = new int[processCount];
		int* pBlocksOffsets = new int[processCount];

		for (int i = 0; i < processCount; i++)
		{
			pBlocksLengths[i] = size * 3;
			pBlocksOffsets[i] = i * size * 3;
		}

		pBlocksLengths[processCount - 1] = (totalSize + (1 - processCount) * size) * 3;

		pBuffer = new unsigned char[pBlocksLengths[processId] * 3];

		F timeOfStart = MPI_Wtime();

		if (totalSize - size * processCount > 0)
		{
			upperBorder = (pBlocksOffsets[processId] + pBlocksLengths[processId]) / 3;

			for (unsigned int i = pBlocksOffsets[processId] / 3; i < upperBorder; i++)
			{
				x = i % width;
				y = int(i / width);

				ray = camera->ComputeRay(x, y);

				finalColor = traceRay(ray, 0).ToRange();

				pBuffer[bufIdx] = unsigned char(finalColor.r * 255);
				pBuffer[bufIdx + 1] = unsigned char(finalColor.g * 255);
				pBuffer[bufIdx + 2] = unsigned char(finalColor.b * 255);

				bufIdx += 3;
			}

			MPI_Gatherv(pBuffer, pBlocksLengths[processId], MPI_UNSIGNED_CHAR, pResultBuffer, pBlocksLengths,
				pBlocksOffsets, MPI_UNSIGNED_CHAR, 0, MPI_COMM_WORLD);
		}