🔒 Locked
Texture Load problem...
Advertisement
Original Post
What's wrong with this?? everytime i try to load my texture, it freezes and i have to close the whole thing... bool cTexture::Load(char *Filename) { Shutdown(); if (!Filename) return Error("cTexture::Load()"); if(FAILED(D3DXCreateTextureFromFile( m_pGraphics->GetDeviceCOM(), Filename, &m_pTexture))) return Error("cTexture::Load()"); return true; } // cTexture m_Texture Pre initialized texture COM set up as well // cTexture::m_pTexture is the IDirect3DTexture9 object m_Texture.Load("Back.bmp"); i'm not getting any of the error statements.. so i don't know... any ideas?
oh sry, the shutdown() is irrelivent, it just releases the device if it's there. if not then it doens't do anything
Quote:
Original post by EvilKnuckles666
oh sry, the shutdown() is irrelivent, it just releases the device if it's there. if not then it doens't do anything
If it releases the Device, then how can you then use the device to load the texture? If so, that's pretty relevant. But maybe you meant it releases the Texture?
Are you using the Debug runtime? Any warnings written out when this code runs? (See the Forum FAQ for more details)
Can you run this in windowed mode, set a breakpoint at the entry to the function and then step through one line at a time? That will tell you where it's freezing up.
I suspect your problem is somewhere else, but the above should show you where.
well, i just took out the shutdown and it runs fine now... BUT, i'm getting an error in the Present(0,0,0,0) statement...
bool cGraphics::Display()
{
if(!m_pD3dDevice) return Error("cGraphics::Display() 1");
if(FAILED(m_pD3dDevice->Present(NULL, NULL, NULL, NULL))) return Error("cGraphics::Display() 2");
return true;
}
i keep getting that second message box
bool cGraphics::Display()
{
if(!m_pD3dDevice) return Error("cGraphics::Display() 1");
if(FAILED(m_pD3dDevice->Present(NULL, NULL, NULL, NULL))) return Error("cGraphics::Display() 2");
return true;
}
i keep getting that second message box
Are you using the Debug runtime? Any warnings written out when this code runs? (See the Forum FAQ for more details)
BTW, I have this macro'd, so I can post it all day long.
BTW, I have this macro'd, so I can post it all day long.
You really need to check the error codes. Just about almost D3D function will return a status code, which contains an error ID. That's why you need to use the SUCCEEDED and FAILED macros.
What is the return value of Present()?
Also, as Ken said, if you have the debug runtime installed, it'll tell you what's wrong, or at least give you some kind of extra information.
The only things I can think of is that you're either in a fullscreen app and you've lost focus (the device is lost), or you haven't called EndScene, so D3D thinks you're still rendering.
What is the return value of Present()?
Also, as Ken said, if you have the debug runtime installed, it'll tell you what's wrong, or at least give you some kind of extra information.
The only things I can think of is that you're either in a fullscreen app and you've lost focus (the device is lost), or you haven't called EndScene, so D3D thinks you're still rendering.
Quote:
Original post by EvilKnuckles666
well, i just took out the shutdown and it runs fine now... BUT, i'm getting an error in the Present(0,0,0,0) statement...
bool cGraphics::Display()
{
if(!m_pD3dDevice) return Error("cGraphics::Display() 1");
if(FAILED(m_pD3dDevice->Present(NULL, NULL, NULL, NULL))) return Error("cGraphics::Display() 2");
return true;
}
i keep getting that second message box
I'll go with what DrunkenHyena and Evil Steve said, but just to add a quick thing...
I'm in a hurry now, so I can't look them up - but if you browse the SDK sample code there are a lot of good macro's for checking the return type of D3D related function calls. V_RETURN() is one of them I think. They do similar to your Error( "..." ); calls but if debugging, they can actually decode the correct error message and provide a stack trace. Both of which will provide you with useful insight into whats going wrong [smile]
what do u guys mean by the debug runtime?? r u talkinga bout the debug install for the SDK? becuase i did that already and how would i be able to check the return value? i am using a fullscrean app, but i don't know if i'm lossing the device or not.
jollyjeffers, where can i find all these calls that decodes and correct the errors?? :)
jollyjeffers, where can i find all these calls that decodes and correct the errors?? :)
Quote:If you have the DirectX SDK installed, you can go to the control pannel -> DirectX, then goto the Direct3D tab, and select "Use Debug Version of Direct3D". You should then get more information in the debug output window, including error strings.
Original post by EvilKnuckles666
what do u guys mean by the debug runtime?? r u talkinga bout the debug install for the SDK? becuase i did that already and how would i be able to check the return value? i am using a fullscrean app, but i don't know if i'm lossing the device or not.
If the button is greyed out, then you have an old version of the SDK, and will have to get a newer one.
If your app is fullscreen, then your device will be lost if another app (including MSVC) takes the focus (and your app will be minimized).
The way to check for this is with TestCooperativeLevel(), or check the return value of Present(). If it's D3DERR_DEVICELOST, then your device is lost, and you'll have to reset it when you app comes back into focus (watch for WM_ACTIVATE messages to make this process easier).
i tried looking up and using the V_RETURN() but it's unidintified, which include do i need to use it?
where's the control panel ur talking about?
Quote:In Windows 2000, it's either in Start Menu -> Settings -> Control Panel, or My Computer -> Control Panel. Either takes you to the same place.
Original post by EvilKnuckles666
where's the control panel ur talking about?
It's the same for Win9x, and I presume WinXP.
ohhh, the normal control panel for windows, ok. but where's the dx tab?
If you don't have a DirectX icon, you probably have a badly installed SDK, or an out of date SDK (meaning you'll have to download the latest SDK). Here's what my control panel looks like:

(Notice the DirectX icon)
I assume you're using Visual Studio? What version? If it's VS .NET 2003 or later, you can get the latest SDK from Here. If you have MSVC 6.0 or earlier, you'll have to try and get a copy of the summer SDK with the extras package (I have a copy of it, but it's huge, and my bandwidth is limited, so I won't link it unless you need it).

(Notice the DirectX icon)
I assume you're using Visual Studio? What version? If it's VS .NET 2003 or later, you can get the latest SDK from Here. If you have MSVC 6.0 or earlier, you'll have to try and get a copy of the summer SDK with the extras package (I have a copy of it, but it's huge, and my bandwidth is limited, so I won't link it unless you need it).
ok, i see it now.. i had to switch to classic view, i'm using winXP. i have everything set now, i'm gonna try this again
Quote:
Original post by EvilKnuckles666
i tried looking up and using the V_RETURN() but it's unidintified, which include do i need to use it?
It should be included for you if you use the normal #include
#if defined(DEBUG) | defined(_DEBUG) #ifndef V #define V(x) { hr = x; if( FAILED(hr) ) { DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } } #endif #ifndef V_RETURN #define V_RETURN(x) { hr = x; if( FAILED(hr) ) { return DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } } #endif#else #ifndef V #define V(x) { hr = x; } #endif #ifndef V_RETURN #define V_RETURN(x) { hr = x; if( FAILED(hr) ) { return hr; } } #endif#endifI just opened up one of the SDK samples ('CustomUI') and it uses them in a few places. V( ) and V_RETURN( ). Basically they test the HRESULT and if it fails, output a suitable error message, either continuing (V()) or returning (V_RETURN()).
Following the trail they go into dxut.cpp so it may well take a bit of effort to strip them out of the framework if you're not using it.
hth
Jack
hmmm... well, i tried to use it but it keeps saying it's unidentified
y am i not able to use that function still?
Quote:
Original post by EvilKnuckles666
y am i not able to use that function still?
Quote:
Following the trail they go into dxut.cpp so it may well take a bit of effort to strip them out of the framework if you're not using it.
Have you tried the debug runtime yet?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement