Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#Actualjrh2365

Posted 04 March 2013 - 07:21 PM

As far as rendering the text to a texture, you use QueryInterface<T> as mentioned above to get an IDXGISurface1 pointer, and then pass that to ID2D1Factory::CreateDxgiSurfaceRenderTarget. Then you can just use that render target like the render target in my example above.

Example of render target creation:

// create the D3D11 texture

D3D11_TEXTURE2D_DESC texDesc = {};
texDesc.ArraySize = 1;
texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
texDesc.Usage = D3D11_USAGE_DEFAULT;
texDesc.Width = 512;
texDesc.Height = 512;
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texDesc.SampleDesc.Count = 1;
texDesc.MipLevels = 1;
ID3D11Texture2D *texture;
device->CreateTexture2D(&texDesc, NULL, &texture);

// create D2D render target using texture

ID2D1RenderTarget *renderTarget;
IDXGISurface1* dxgiSurface;
texture->QueryInterface<IDXGISurface1>(&dxgiSurface);
D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(
	D2D1_RENDER_TARGET_TYPE_DEFAULT,
	D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED));
factory->CreateDxgiSurfaceRenderTarget(dxgiSurface, &props, &renderTarget);
dxgiSurface->Release();

 

 

For determining where the previous text ended on the screen...I think IDWriteFactory::CreateTextLayout and IDWriteTextLayout::GetMetrics might help. It looks like it can take care of wrapping text for you as well.


#3jrh2365

Posted 04 March 2013 - 07:20 PM

As far as rendering the text to a texture, you use QueryInterface<T> as mentioned above to get an IDXGISurface1 pointer, and then pass that to ID2D1Factory::CreateDxgiSurfaceRenderTarget. Then you can just use that render target like the render target in my example above.

Example of render target creation:
// create the D3D11 textureD3D11_TEXTURE2D_DESC texDesc = {};texDesc.ArraySize = 1;texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;texDesc.Usage = D3D11_USAGE_DEFAULT;texDesc.Width = 512;texDesc.Height = 512;texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;texDesc.SampleDesc.Count = 1;texDesc.MipLevels = 1;ID3D11Texture2D *texture;device->CreateTexture2D(&texDesc, NULL, &texture);// create D2D render target using textureID2D1RenderTarget *renderTarget;IDXGISurface1* dxgiSurface;texture->QueryInterface<IDXGISurface1>(&dxgiSurface);D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(	D2D1_RENDER_TARGET_TYPE_DEFAULT,	D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED));factory->CreateDxgiSurfaceRenderTarget(dxgiSurface, &props, &renderTarget);dxgiSurface->Release();


For determining where the previous text ended on the screen...I think IDWriteFactory::CreateTextLayout and IDWriteTextLayout::GetMetrics might help. It looks like it can take care of wrapping text for you as well.

#2jrh2365

Posted 04 March 2013 - 07:20 PM

As far as rendering the text to a texture, you use QueryInterface<T> as mentioned above to get an IDXGISurface1 pointer, and then pass that to ID2D1Factory::CreateDxgiSurfaceRenderTarget. Then you can just use that render target like the render target in my example above.

Example of render target creation:
// create the D3D11 textureD3D11_TEXTURE2D_DESC texDesc = {};texDesc.ArraySize = 1;texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;texDesc.Usage = D3D11_USAGE_DEFAULT;texDesc.Width = 512;texDesc.Height = 512;texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;texDesc.SampleDesc.Count = 1;texDesc.MipLevels = 1;ID3D11Texture2D *texture;device->CreateTexture2D(&texDesc, NULL, &texture);// create D2D render target using textureID2D1RenderTarget *renderTarget;IDXGISurface1* dxgiSurface;texture->QueryInterface<IDXGISurface1>(&dxgiSurface);D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(	D2D1_RENDER_TARGET_TYPE_DEFAULT,	D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED));factory->CreateDxgiSurfaceRenderTarget(dxgiSurface, &props, &renderTarget);dxgiSurface->Release();


For determining where the previous text ended on the screen...I think IDWriteFactory::CreateTextLayout and IDWriteTextLayout::GetMetrics might help. It looks like it can take care of wrapping text for you as well.

#1jrh2365

Posted 04 March 2013 - 07:18 PM

As far as rendering the text to a texture, you use QueryInterface<T> as mentioned above to get an IDXGISurface1 pointer, and then pass that to ID2D1Factory::CreateDxgiSurfaceRenderTarget. Then you can just use that render target like the render target in my example above.

 

Example of render target creation:

// create the D3D11 texture

D3D11_TEXTURE2D_DESC texDesc = {};
texDesc.ArraySize = 1;
texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
texDesc.Usage = D3D11_USAGE_DEFAULT;
texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
texDesc.Width = 512;
texDesc.Height = 512;
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texDesc.SampleDesc.Count = 1;
texDesc.MipLevels = 1;
ID3D11Texture2D *texture;
device->CreateTexture2D(&texDesc, NULL, &texture);

// create D2D render target using texture

ID2D1RenderTarget *renderTarget;
IDXGISurface1* dxgiSurface;
texture->QueryInterface<IDXGISurface1>(&dxgiSurface);
D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(
	D2D1_RENDER_TARGET_TYPE_DEFAULT,
	D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED));
factory->CreateDxgiSurfaceRenderTarget(dxgiSurface, &props, &renderTarget);
dxgiSurface->Release();

 

 

For determining where the previous text ended on the screen...I think IDWriteFactory::CreateTextLayout and IDWriteTextLayout::GetMetrics might help. It looks like it can take care of wrapping text for you as well.


PARTNERS