src/video/windowsrt/SDL_winrtrenderer.cpp
changeset 8350 ecc8c88ed82e
parent 8349 020b8b65bcfc
child 8367 df577bb2f2d7
     1.1 --- a/src/video/windowsrt/SDL_winrtrenderer.cpp	Wed Nov 21 17:38:17 2012 -0500
     1.2 +++ b/src/video/windowsrt/SDL_winrtrenderer.cpp	Wed Nov 21 23:44:58 2012 -0500
     1.3 @@ -60,10 +60,10 @@
     1.4  	auto createCubeTask = (createPSTask && createVSTask).then([this] () {
     1.5  		VertexPositionColor cubeVertices[] = 
     1.6  		{
     1.7 -			{XMFLOAT3(-1.0f, -1.0f, 0.0f),  XMFLOAT2(0.0f, 0.0f)},
     1.8 -			{XMFLOAT3(-1.0f, 1.0f, 0.0f), XMFLOAT2(0.0f, 1.0f)},
     1.9 -			{XMFLOAT3(1.0f, -1.0f, 0.0f), XMFLOAT2(1.0f, 0.0f)},
    1.10 -			{XMFLOAT3(1.0f, 1.0f, 0.0f), XMFLOAT2(1.0f, 1.0f)},
    1.11 +			{XMFLOAT3(-1.0f, -1.0f, 0.0f),  XMFLOAT2(0.0f, 1.0f)},
    1.12 +			{XMFLOAT3(-1.0f, 1.0f, 0.0f), XMFLOAT2(0.0f, 0.0f)},
    1.13 +			{XMFLOAT3(1.0f, -1.0f, 0.0f), XMFLOAT2(1.0f, 1.0f)},
    1.14 +			{XMFLOAT3(1.0f, 1.0f, 0.0f), XMFLOAT2(1.0f, 0.0f)},
    1.15  		};
    1.16  
    1.17  		m_vertexCount = ARRAYSIZE(cubeVertices);
    1.18 @@ -96,14 +96,8 @@
    1.19  		textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    1.20  		textureDesc.MiscFlags = 0;
    1.21  
    1.22 -		int numPixels = (int)m_windowBounds.Width * (int)m_windowBounds.Height;
    1.23 -		std::vector<uint8> initialTexturePixels(numPixels * 4);
    1.24 -		for (int i = 0; i < (numPixels * 4); i += 4) {
    1.25 -			initialTexturePixels[i+0] = 0xFF;
    1.26 -			initialTexturePixels[i+1] = 0x00;
    1.27 -			initialTexturePixels[i+2] = 0x00;
    1.28 -			initialTexturePixels[i+3] = 0xFF;
    1.29 -		}
    1.30 +		const int numPixels = (int)m_windowBounds.Width * (int)m_windowBounds.Height;
    1.31 +		std::vector<uint8> initialTexturePixels(numPixels * 4, 0x00);
    1.32  		D3D11_SUBRESOURCE_DATA initialTextureData = {0};
    1.33  		initialTextureData.pSysMem = (void *)&(initialTexturePixels[0]);
    1.34  		initialTextureData.SysMemPitch = (int)m_windowBounds.Width * 4;
    1.35 @@ -157,12 +151,12 @@
    1.36  	});
    1.37  }
    1.38  
    1.39 -void SDL_winrtrenderer::Render()
    1.40 +void SDL_winrtrenderer::Render(SDL_Surface * surface, SDL_Rect * rects, int numrects)
    1.41  {
    1.42 -	const float midnightBlue[] = { 0.098f, 0.098f, 0.439f, 1.000f };
    1.43 +	const float blackColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
    1.44  	m_d3dContext->ClearRenderTargetView(
    1.45  		m_renderTargetView.Get(),
    1.46 -		midnightBlue
    1.47 +		blackColor
    1.48  		);
    1.49  
    1.50  	m_d3dContext->ClearDepthStencilView(
    1.51 @@ -189,14 +183,10 @@
    1.52  			&textureMemory)
    1.53  		);
    1.54  
    1.55 -	const int max = (int)m_windowBounds.Width * (int)m_windowBounds.Height * 4;
    1.56 -	uint8 * buf = (uint8 *)textureMemory.pData;
    1.57 -	for (int i = 0; i < max; i += 4) {
    1.58 -		buf[i+0] = 0x00;
    1.59 -		buf[i+1] = 0xFF;
    1.60 -		buf[i+2] = 0x00;
    1.61 -		buf[i+3] = 0xFF;
    1.62 -	}
    1.63 +	// TODO, WinRT: only copy over the requested rects (via SDL_BlitSurface, perhaps?)
    1.64 +	// TODO, WinRT: do a sanity check on the src and dest data when updating the window surface
    1.65 +	const unsigned int numBytes = (int)m_windowBounds.Width * (int)m_windowBounds.Height * 4;
    1.66 +	memcpy(textureMemory.pData, surface->pixels, numBytes);
    1.67  
    1.68  	m_d3dContext->Unmap(
    1.69  		m_mainTexture.Get(),