xboxscene.org forums

Author Topic: Help Drawing Textures  (Read 187 times)

_zlinky

  • Archived User
  • Jr. Member
  • *
  • Posts: 56
Help Drawing Textures
« on: October 26, 2008, 11:17:00 AM »

QUOTE(grimdoomer @ Oct 17 2008, 11:33 PM) View Post

I've been messing with the XDk for a couple days. Now I want to start drawing some textures. I have all the necessary code in place, but it always throws an exceptions stating that it cant find the texture on the HDD. So I added some drive mounting code, thinking it might help. But when I make an extern call to IoCreateSymbolicLink I get a build error - unresolved external symbol. I can't for the life of me figure this out. Can someone please help me out? I'll be on aim a lot so you can hit me up there too.


What is the path of your texture?  Are you using "D:\\" in front of your directory?  If not, that's one fatal problem right there.  Example: Let's say texture.dds is in $(XbeDir)\Media\Textures\texture.dds... in order to load it you need to use this string "D:\\Media\\Textures\\texture.dds"

Also, when calling kernel functions directly, you need to declare them as extern functions before using them and you also need to make sure that they retain C linkage (that's if you're using C++), and make sure the parameters are correct or you will get link errors.  Example:

CODE

extern "C" {
  // Declare any kernel functions here
  extern XBOXAPI KeRaiseIrql( ... );
  extern DWORD KeTickCount;
  extern XBOXAPI IoCreateSymbolicLink( ... );
};


Let me know if this helps.
Logged

red_ring_of_box

  • Archived User
  • Sr. Member
  • *
  • Posts: 410
Help Drawing Textures
« Reply #1 on: October 30, 2008, 02:57:00 PM »

ya man the xdk cant draw bmp files you need to convert them to .xpr files. I do belive if you want to know how to draw textures there is a tutorial under X:\Program Files\Microsoft Xbox SDK\Samples\Xbox\Graphics\Tutorials where X is your drive letter. Hope this helps.  biggrin.gif
Logged

sirlemonhead

  • Archived User
  • Jr. Member
  • *
  • Posts: 89
Help Drawing Textures
« Reply #2 on: November 26, 2008, 05:34:00 PM »

BMP files work fine..

Are you checking that the call to D3DXCreateTextureFromFile succeeds or not?

   /* create direct3d texture */
   if(FAILED(D3DXCreateTextureFromFileInMemory(d3d.lpD3DDevice,
      buffer,
      sizeof(TGA_HEADER) + imageSize,
      &destTexture)))
   {
      OutputDebugString("\n no, didn't work");
   }

different function, but same method to test whether it works or not.

Can we see your code?
Logged

grimdoomer

  • Archived User
  • Jr. Member
  • *
  • Posts: 54
Help Drawing Textures
« Reply #3 on: November 26, 2008, 10:22:00 PM »

CODE

if (FAILED(D3DXCreateTextureFromFile(g_pd3dDevice, "D:\\Media\\test.bmp", &m_BGTexture)))
    {
        OutputDebugString("Error: Could not Initialize Texture!");
    }


Rendering:

CODE

VOID Render()
{
    // Clear the backbuffer to a blue color
    g_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL,
                         D3DCOLOR_XRGB(0,0,255), 1.0f, 0L );

    // Begin the scene
    g_pd3dDevice->BeginScene();

    g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
    g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
    g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) );
    g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
    g_pd3dDevice->SetTexture(0, m_BGTexture);
    g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );

    // End the scene
    g_pd3dDevice->EndScene();

    //Present
    g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
}
Logged

sirlemonhead

  • Archived User
  • Jr. Member
  • *
  • Posts: 89
Help Drawing Textures
« Reply #4 on: December 01, 2008, 03:48:00 PM »

If you want, drop me a pm if you can send me a copy of your code (zip or rar or whatever) and ill have a look for you?
Logged