Jump to content


Photo

Help Drawing Textures


  • Please log in to reply
7 replies to this topic

#1 grimdoomer

grimdoomer

    X-S Member

  • Members
  • Pip
  • 93 posts
  • Xbox Version:v1.3
  • 360 version:unknown

Posted 18 October 2008 - 04:57 AM

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.

#2 _zlinky

_zlinky

    X-S Member

  • Members
  • Pip
  • 75 posts

Posted 26 October 2008 - 06:17 PM

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.

#3 grimdoomer

grimdoomer

    X-S Member

  • Members
  • Pip
  • 93 posts
  • Xbox Version:v1.3
  • 360 version:unknown

Posted 30 October 2008 - 02:22 AM

Yes im using the D:\ path, but all i get is a white triangle. Im using a bmp texture does it matter? As for the extern call, Yes I know i must do that, I have a few external calls. It's just this one in paticular that is giving me a unresolved external symbol.

Here is the code I used to load the image:
CODE
D3DXCreateTextureFromFile(g_pd3dDevice, "D:\\Media\\test.bmp", &m_BGTexture);


#4 red_ring_of_box

red_ring_of_box

    X-S Expert

  • Members
  • PipPipPip
  • 670 posts
  • Xbox Version:v1.6
  • 360 version:v3.0 (falcon)

Posted 30 October 2008 - 09:57 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

#5 grimdoomer

grimdoomer

    X-S Member

  • Members
  • Pip
  • 93 posts
  • Xbox Version:v1.3
  • 360 version:unknown

Posted 31 October 2008 - 12:12 PM

I tried loading them as resources, I get the samething, nothing. And you have to be able to load .bmp files cus that all Team Assembly used.

But I will try Dxts.

Edited by grimdoomer, 31 October 2008 - 12:13 PM.


#6 sirlemonhead

sirlemonhead

    X-S Senior Member

  • Members
  • PipPip
  • 161 posts
  • Location:Ireland
  • Xbox Version:unk

Posted 27 November 2008 - 01:34 AM

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?

#7 grimdoomer

grimdoomer

    X-S Member

  • Members
  • Pip
  • 93 posts
  • Xbox Version:v1.3
  • 360 version:unknown

Posted 27 November 2008 - 06:22 AM

Yes I am, and it does succeed.

Here is my code:

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);
}


#8 sirlemonhead

sirlemonhead

    X-S Senior Member

  • Members
  • PipPip
  • 161 posts
  • Location:Ireland
  • Xbox Version:unk

Posted 01 December 2008 - 11:48 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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users