Sign in to follow this  
cephalo

Getting a DXGI Surface from a Texture2D

Recommended Posts

cephalo    739

Ok, I am using SharpDX with DirectX 11.1. 

 

I need to draw some text onto some textures for use on some 3D objects, not every frame, just upon initialization. I currently have debugging text (FPS counter etc.) working in my app that obtains a dxgi surface from my swap chain like so:

            surface = swapChain.GetBackBuffer<dxgi.Surface>(0);
 

Now, to get a surface from a blank texture for text drawing, as far as I can tell I would do this:

            surface = texture.QueryInterface<dxgi.Surface>();
 

However, since Texture2Ds can have mip levels and even texture arrays this seems rather ambiguous. Does QueryInterface merely assume the top level mip and top index of the array? I don't even know if I'm on the right track here.

 

Share this post


Link to post
Share on other sites
Buckeye    10747

I currently have debugging text..

Are you talking about using GDI?

 


However, since Texture2Ds can have mip levels and even texture arrays this seems rather ambiguous. Does QueryInterface merely assume the top level mip and top index of the array?

 

Read the docs. They're your friend (sometimes).

 

If the 2D texture has only a single MIP-map level and does not consist of an array of textures, QueryInterface succeeds and returns a pointer to the IDXGISurface1 interface pointer. Otherwise, QueryInterface fails and does not return the pointer to IDXGISurface1.
Edited by Buckeye

Share this post


Link to post
Share on other sites
cephalo    739

Why are you using a DXGI surface? You shouldn't need to access DXGI interfaces just to draw onto a texture.

 

Oh, I forgot to say that I am using DirectWrite.

 

 


I currently have debugging text..

Are you talking about using GDI?

 

 

 


However, since Texture2Ds can have mip levels and even texture arrays this seems rather ambiguous. Does QueryInterface merely assume the top level mip and top index of the array?

 

Read the docs. They're your friend (sometimes).

 

If the 2D texture has only a single MIP-map level and does not consist of an array of textures, QueryInterface succeeds and returns a pointer to the IDXGISurface1 interface pointer. Otherwise, QueryInterface fails and does not return the pointer to IDXGISurface1.

 

 

Thanks Buckeye! For my debugging text, I am using DirectWrite directly on the back buffer, for which there is a handy surface getting function. Wow, the docs had my answer! That's never happened to me... tongue.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this