Jump to content
  • Advertisement
Sign in to follow this  
jbrocky

DX11 DIB's in DirectX 11

This topic is 2480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I have inherited some older code that utilizes GDI with DIBs. It's sonar information and it uses BitBlit and MoveMemory to put the data on the screen. I've been asked to make this use DirectX so that we can utilize hardware acceleration and eventually manipulate it to give it some dimension like this:

pic0078.gif

The data is gathered in real time and not from a file. I've searched for the proper way of doing this, but I want to do it right for the long term. I've ripped out the display we use and put it into it's own test dialog. I've rendered a D3D View, DC, and Swapchain into the project to overlap the current Rect that is normally used. I've been trying to figure out what to do with this in regards to D3D or D2D. I believe, if I use D2D I will not be able to achieve the manipulation I desire. My questions are:

1) Is it possible to directly use a real-time (meaning not taken from a file) DIB to populate a D3D Texture? If so, what am I looking for exactly?
2) It is possible to manipulate a D2D Texture like the above in real time? I assume it would be, but it would taxing?
3) I am currently going down the path of using the ID3D11Texture2D route, utilizing the D3DX11GetImagineInfoFromMemory() function. Is this the correct route to go down?

If not, I am looking for a DIB to D3D or D2D Texture example so that I can fill it out realtime, ranging from 1- 30FPS (we ping 1-30Hz only).

If I am completely off-base with this, could you point me in the right direction?

Thanks!

jbrocky

Examples of what is currently implemented:

BOOL CDemo1::SlideDisplayDown(int nRasters/*=1*/)
{
// Shift video memory down
// Scroll bottom to top
MoveMemory((LPVOID)&m_pBits[0], (LPVOID)&m_pBits[m_iDIBWidth], m_clientBytesToScroll - m_iDIBWidth);

// Return successful
return TRUE;
}


void CDemo1::OnPaint()
{
// Create a Graphics Device Context
CPaintDC dc(this) ;
// Bit blit the device independent bitmap into the controls DC
::BitBlt(dc.m_hDC, 0, 0, m_iDIBWidth, m_iDIBHeight, m_dibHDC, 0, 0, SRCCOPY);
}


What a typical data example of sonar looks like rendered to the screen.

4125_hurricane_gate_900kHz-2.jpg

Share this post


Link to post
Share on other sites
Advertisement
1. Absolutely. When you create a texture you don't want to use the D3DX functions, they are intended for loading image files like .JPG or .PNG. Instead you can pass an array to the raw pixel values using the using the pInitialData parameter of CreateTexture2D. When you need to update the texture contents you probably don't want to create a new texture, since creating resources is slow. Instead you can use UpdateSubresource to update the texture contents. There is some performance advice about using UpdateSubresource in this presentation, around page 6. You can also use a texture created with D3D11_USAGE_DYNAMIC that you fill by calling Map with D3D11_MAP_WRITE_DISCARD, however you can't use mipmaps in that case.

2. I'm not familiar with D2D so I can't answer that, however I would assume that you could.

3.You should be fine if you go with the approach I outlined above.

Share this post


Link to post
Share on other sites
Depending on your requirements you may even be able to step back to D3D8 or 9 here. I'm thinking that you may be using ruggedized field laptops, or have a requirement to be able to run on them, and they may not have the greatest graphics acceleration. If that's the case then this is also entirely possible (via LockRect). Yes, the APIs aren't as nice to use as 11, and I'd suggest continuing with 11 if you can, but it's fair to give you advance warning before you go too far with this.

Share this post


Link to post
Share on other sites

Depending on your requirements you may even be able to step back to D3D8 or 9 here. I'm thinking that you may be using ruggedized field laptops, or have a requirement to be able to run on them, and they may not have the greatest graphics acceleration. If that's the case then this is also entirely possible (via LockRect). Yes, the APIs aren't as nice to use as 11, and I'd suggest continuing with 11 if you can, but it's fair to give you advance warning before you go too far with this.


Thank you. I will bring this to them. Appreciate it! My one concern though is the lack of support later on. How long before DX9 isn't useable? Should I even worry about this? I just don't want code that is obsolete within a year or two.

Share this post


Link to post
Share on other sites
DirectX is backwards compatible - you can still run applications today that use DirectX 3. If it wasn't, Microsoft would get a lot of complaining e-mails when peoples old games / applications stopped working on a new version of Windows.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!