Sign in to follow this  
macmoy

DirectX9 Blank Screen problem

Recommended Posts

I went to school and open visual C++ 2008 express edition. DirectX SDK is already installed there and directories are correctly pointed. When making a window from scratch(just like in http://www.directxtutorial.com) it runs smoothly. But when I added the codes of having directx enabled window. it crashes. using breakpoints, i found out that d3ddev is NULL. i don't know why. when i tried the same codes in my laptop, it works. as well as others PC. actually, inside my school's Lab, there are 13 PCs, 2 of those PCs works. I mean this dx blank window worked on those 2 Pc's but on the rest, it crashes. What could be the problem.. please.. i need it as soon as possible because we need to make it work before Sunday this week. Thanks a lot..

Share this post


Link to post
Share on other sites
here's the code of giving d3ddev a value.

Quote:


d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
App.hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);



But for those 13 Pc's the d3ddev is still NULL after this line. It should have a value.

Share this post


Link to post
Share on other sites
Quote:
just like in http://www.directxtutorial.com

Don't use that site! Arguments against directxtutorial.com here. (Especially see Evil Steve's posts)

If you want good DirectX tutorials, check out Evil Steve's tutorials here.

As for your question, you might be trying to create a device that your computer's hardware can't support. There could be several reasons why d3ddev is NULL. Make sure you check the HRESULT return value from the Direct3D functions.

Share this post


Link to post
Share on other sites
how will i know the error of hresult?

HRESULT hr = d3d->CreateDevice();

I put a breakpoint after that. and hr has a value of long negative numbers.
how will i know the reason of that issue?

I tried to use both hardware and software vertex processing but didn't solve the issue.

Share this post


Link to post
Share on other sites
You could try googling the error code.

Evil Steve's tutorials show how to properly check error codes, and includes a way to get meaningful information from those HRESULT codes.

Share this post


Link to post
Share on other sites
First, make sure you're using the debug runtimes. That'll tell you if you're making a mistake in your code.

Second, you must check the return value for all functions that you care about failing (I.e. all functions that return a pointer, fill in a struct you rely on, etc). To do that, you use the SUCCEEDED or FAILED macro to tell you if the return value is a success or failure code (D3D_OK is not the only success code, there's over 2 billion others), and if you want to display the error code in an error log or message window, use DXGetErrorString to convert it into a human readable error message, or DXGetErrorDescription to give a more detailed error (Although that's usually not worth displaying to the user).

Share this post


Link to post
Share on other sites
waaa.. please help.. the return of DXGetErrorString and DXGetErrorDescription is "Not Available" I went to the Lab, the HRESULT value is -2005530518

What is that error? please help me find a way to fix this. I already tried to use the mode.Format but it also gives D3DFMT_X8R8G8B8. so no changes. please help..thanks..

Share this post


Link to post
Share on other sites
Quote:
Original post by macmoy
waaa.. please help.. the return of DXGetErrorString and DXGetErrorDescription is "Not Available" I went to the Lab, the HRESULT value is -2005530518

What is that error? please help me find a way to fix this. I already tried to use the mode.Format but it also gives D3DFMT_X8R8G8B8. so no changes. please help..thanks..
That is the error. That error code is D3DERR_NOTAVAILABLE. The debug runtimes (linked above) will tell you why you're getting that error.

Share this post


Link to post
Share on other sites
huh?? so where can i find the info? is this the info?
Quote:

Direct3D9: :====> ENTER: DLLMAIN(00e6e6e0): Process Attach: 00000f54, tid=00000944
Direct3D9: :====> EXIT: DLLMAIN(00e6e6e0): Process Attach: 00000f54
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO
Direct3D9: (INFO) :======================= Hal HWVP device selected

Direct3D9: (INFO) :HalDevice Driver style 9

Direct3D9: :BackBufferCount not specified, considered default 1
Direct3D9: :DoneExclusiveMode


how will i solve this?

Why is that there are 2 computers that can run the application while there are 13 which can't?

Share this post


Link to post
Share on other sites
go to start
dx skd
dx utilities

dx error look up

i always confused by this minus something numbers
but i thin the error means


HRESULT: 0x8876086a (2289436778)
Name: D3DERR_NOTAVAILABLE
Description: Not available
Severity code: Failed
Facility Code: FACILITY_D3D (2166)
Error Code: 0x086a (2154)


so i am realative sure that the hardware of the 13 comps isnt suficient enough to run DX9

in the utils directori there is also a DX CAPS viewer check whit it if the hardware is capable of DX9



Share this post


Link to post
Share on other sites
Quote:
Original post by macmoy
huh?? so where can i find the info? is this the info?
Quote:

Direct3D9: :====> ENTER: DLLMAIN(00e6e6e0): Process Attach: 00000f54, tid=00000944
Direct3D9: :====> EXIT: DLLMAIN(00e6e6e0): Process Attach: 00000f54
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO
Direct3D9: (INFO) :======================= Hal HWVP device selected

Direct3D9: (INFO) :HalDevice Driver style 9

Direct3D9: :BackBufferCount not specified, considered default 1
Direct3D9: :DoneExclusiveMode


how will i solve this?

Why is that there are 2 computers that can run the application while there are 13 which can't?
That output shows that CreateDevice succeeded: "Direct3D9: (INFO) :======================= Hal HWVP device selected". The error you're getting is coming from somewhere else.

Share this post


Link to post
Share on other sites
uhmm.. maybe posting the whole code will help us solve this..


#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>

#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

HWND hWnd;
LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
MSG msg;

void LoadDX()
{
D3DPRESENT_PARAMETERS d3dpp;
d3d=Direct3DCreate9(32);
ZeroMemory(&d3dpp,sizeof(d3dpp));
d3dpp.hDeviceWindow=hWnd;
d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat=D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth=800;
d3dpp.BackBufferHeight=600;
d3dpp.Windowed=1;

d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&d3ddev);
}

void RenderDX()
{
d3ddev->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(80, 150, 100),1.0f,0);
d3ddev->BeginScene();

d3ddev->EndScene();
d3ddev->Present(0,0,0,0);
}

void CleanDX()
{
d3ddev->Release();
d3d->Release();
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{

WNDCLASS wc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hbrBackground=(HBRUSH)GetStockObject(0);
wc.hCursor=LoadCursor(0,IDC_ARROW);
wc.hIcon=LoadIcon(0,IDI_APPLICATION);
wc.hInstance=hInstance;
wc.lpfnWndProc=WndProc;
wc.lpszClassName="mje";
wc.lpszMenuName=0;
wc.style=0;
RegisterClass(&wc);

hWnd = CreateWindowEx(0,"mje","DXReady App",WS_OVERLAPPEDWINDOW,200,100,800,600,0,0,hInstance,0);


ShowWindow(hWnd,1);
ShowCursor(true);

LoadDX();

bool Running = true;
while(Running)
{
if(PeekMessage(&msg,0,0,0,PM_REMOVE))
{
if(msg.message==WM_QUIT){Running=false;}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Sleep(16);
RenderDX();

}
/*Clean*/

CleanDX();
DestroyWindow(hWnd);
UnregisterClass("mje",hInstance);
return msg.wParam;
}


Share this post


Link to post
Share on other sites
The original problem of that code causing it to crash is because you're not checking any return values. CreateDevice() fails, so d3ddev is null, so it'll crash when you call d3ddev->Clear().

Other than that, CreateDevice() will fail is any of the parameters are wrong, or there's no 3D hardware acceleration - which is probably the problem you're experiencing. If there's not a D3D9 driver installed, you can't create a device, and CreateDevice() will fail.

Share this post


Link to post
Share on other sites
no D3D9 driver makes sense. question: is it possible that the SDK is installed yet no D3D9 Driver?


if Yes, how to install the D3D9 driver? is it the DirectX9 Runtime Installer?

Share this post


Link to post
Share on other sites
Quote:
Original post by macmoy
no D3D9 driver makes sense. question: is it possible that the SDK is installed yet no D3D9 Driver?

if Yes, how to install the D3D9 driver? is it the DirectX9 Runtime Installer?
Yes, it's entirely possible. You can write D3D9 apps if you don't have a D3D9 driver installed.

You just need to install the video driver for whatever the hardware is, e.g. the NVidia display driver, etc.

However - check that's actually the problem; the debug output you posted doesn't seem to be from a machine where it's failing - that output says that CreateDevice succeeded (Or rather it doesn't say it failed, and the debug runtimes will ALWAYS tell you when a function fails).

Share this post


Link to post
Share on other sites
aw!! so where might be the problem then? 2 pc lets the code run + other pc like my laptop, other students laptop etc. but those 11 can run the code.. :((

Share this post


Link to post
Share on other sites
Quote:
Original post by macmoy
aw!! so where might be the problem then? 2 pc lets the code run + other pc like my laptop, other students laptop etc. but those 11 can run the code.. :((
I don't know, you'll need to find out from the debug output. But D3DERR_NOTAVAILABLE means (According to the docs) "This device does not support the queried technique.", which happens when you try to create a device without any D3D hardware (And it probably happens in other cases too).
The debug runtimes will be able to tell you exactly what feature isn't available (And therefore which one you're not checking for support of - which could be any at the moment).
You should really be checking that D3DFMT_X8R8G8B8 is a valid backbuffer format, and it's a valid format for windowed mode (Which is done with CheckDeviceFormat()).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this