Jump to content
  • Advertisement
Sign in to follow this  
fread

DirectX9 - create cubemap texture from memory?

This topic is 1488 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

Hiho I have six 512x512 RGBA images loaded in memory. I want to create a DirectX9 cubemap Here's my code: why is it failing?

 IDirect3DCubeTexture9 *tex;
 HRESULT hr = pDev->CreateCubeTexture(512, 1, D3DUSAGE_WRITEONLY, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex, 0);
 if(FAILED(hr)) {
        // i think im ggetting error here 
          // ERRROR output
}
 for(int i = 0; i < 6; i++)
 { 
LPDIRECT3DSURFACE9 face; hr = tex->GetCubeMapSurface(_D3DCUBEMAP_FACES(D3DCUBEMAP_FACE_POSITIVE_X+i), 0, &face);
 if(FAILED(hr)) 
{
        // ERRROR output 
}
 D3DLOCKED_RECT rect;
 hr = face->LockRect(&rect, 0, 0);
 if (FAILED(hr))
 { 
          // ERRROR output
 } 
CopyRGBAPixelsTo(i,rect.pBits); 
hr = face->UnlockRect(); 
if (FAILED(hr))
 { 
          // ERRROR output
 }

 }
Edited by fread

Share this post


Link to post
Share on other sites
Advertisement

Where does the error occur, and what is the error code?

 

You can determine the error as follows (I can;t remember whether the header is dxerr9.h or dxerr.h):

#include <dxerr.h> // dxerr9.h maybe
// also add dxerr.lib or dxerr9.lib to the linker inputs
...
HRESULT hr = pDev->Create..();
if( FAILED(hr) )
{
   MessageBox(NULL, DXGetErrorDescription( hr ), "Failed some function call..", MB_OK);
   return false;
}

Share this post


Link to post
Share on other sites

thank you guys, i managed to fix it, but when rendering cubemap with shaders (texCube stuff) the corners of my skybox are "cut off". They are black, while the rest of cubemap is drawn valid. What's wrong?

Share this post


Link to post
Share on other sites

It sounds as though the skybox corners are going beyond your far clipping plane.  One way to resolve this is to set up a new viewport for your skybox, with MinZ and MaxZ both set to 1, then draw your skybox as a 10x10x10 cube (you may need to make this slightly larger depending on your near clipping plane) centered on the viewpoint.  Restore the old viewport when done.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!