• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
hiro4476

[directX] as the screen went frozen at D3DDevice->Present and leaves no error message

9 posts in this topic

I'm at my limit...
This game uses the Library which is provided by my school.
The same code works fine in my school's computer but not in my notebook.
I've been debuging this days after days (although not continuously)

The HRESULT returned from CreateDevice has no problem as far as I can see. (the result was 0 I think)
with the D3DCREATE_HARDWARE_VERTEXPROCESSING setting, the last trace is "pD3DDevice->Present.s"
and the screen went frozen, leaves no error messages.
with the D3DCREATE_SOFTWARE_VERTEXPROCESSING setting, it's extreamly slow. but won't freeze (maybe too slow to even not get to the point yet)
since it has no error messages and it's un-debug-able...
I've been googling for days, and still have no idea what's going on.

can anyone give me a direction, where should I start looking?

pSprite is a LPD3DXSPRITE
And this is the snippet in the gameLoop
[code]

while( LOOP ) {
if(pD3DDevice != NULL) {
pD3DDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(0,0,0),1.0f,0);
}

if(pD3DDevice != NULL) { pD3DDevice->BeginScene(); }
if(pSprite != NULL) { pSprite->Begin(D3DXSPRITE_ALPHABLEND); }

//draw something

if(pSprite != NULL){ pSprite->End(); }
if(pD3DDevice != NULL){
hc::trace("pD3DDevice->EndScene.s");
pD3DDevice->EndScene();
hc::trace("pD3DDevice->EndScene.e");
}

HRESULT hr;
if( pD3DDevice != NULL ) {
hc::trace("pD3DDevice : %d", pD3DDevice);
hc::trace("pD3DDevice->Present.s");
hr = pD3DDevice->Present(NULL,NULL,NULL,NULL);
hc::trace("pD3DDevice->Present.e");
}
}

[/code]

Actually, before this happened, I had "LNK1000: Internal error during IncrBuildImage" error at every compile.
the hotfix VS90-KB948127 fixed it but still....
it could be the problem of my graphic card...
my graphic card is ATI Mobility Radeon X2300. a VAIO notebook probably 2 years old.

But then if I can create something like this with no problem in compiling and executing [url="http://hiro4476.blogspot.com/2012/02/gelises851-about-demo.html"]http://hiro4476.blog...about-demo.html[/url]
it could also be something wrong within the school's Library?


Regards, Hiro
0

Share this post


Link to post
Share on other sites
You mean your program froze, or system (computer) froze?

If it's computer then I had similar problem myself. It was driver issue. Driver wasn't checking whether all parameters are set and caused silent crash. Make sure you set primitive topology, shaders and other stuff.
0

Share this post


Link to post
Share on other sites
Try to enable the DX debug runtimes (http://legalizeadulthood.wordpress.com/2009/06/28/direct3d-programming-tip-5-use-the-debug-runtime/) and watch for any errors or warnings in the output window of Visual Studio.
0

Share this post


Link to post
Share on other sites
Thanks to Tom's tip, I've managed to fix it!!
I fix it by providing a [b]D3DCREATE_MULTITHREADED[/b] tag to the [b]CreateDevice().[/b]


I also received a huge amount of
Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: xx
Direct3D9: (WARN) :Ignoring redundant SetRenderState xx
even I comment'em.
guess there are ok I think.

and thanks to Ripiz too. but the froze was a program froze.
I've also googled the primitive topology, it seems like it's a DX10 feature?
Is there a equivalent feature/setting for the DX9? might as double check it.
0

Share this post


Link to post
Share on other sites
btw, here's the Warning message,

[b]Device that was created without D3DCREATE_MULTITHREADED is being used by a thread other than the creation thread.[/b]
[b]The thread Win32 Thread has exited with code 0 (0x0).[/b]

and also, is there a way to check if a [b]D3DCREATE_MULTITHREADED [/b]is needed? like if I bring this game back to my school.
0

Share this post


Link to post
Share on other sites
D3DCREATE_MULTITHREADED is needed if the D3D device is used from more than one thread. Using the device from multiple threads is an extremely bad idea in D3D9, it has a fairly major performance penalty associated with it. If it's just for some test code then it's probably fine to use, but a "proper" game should never be using D3D from multiple threads.

If the library is provided by your school, then it must be creating the device from a different thread than your "main" thread.
0

Share this post


Link to post
Share on other sites
thanks for the tips. but I'm not sure about this "main" thread thingy.
And I don't think it's related to [url="http://stackoverflow.com/questions/266168/simple-example-of-threading-in-c"]http://stackoverflow.com/questions/266168/simple-example-of-threading-in-c[/url]

I've try moving CreateDevice and every related codes into WinMain but it's not getting any better though...
it was all in other cpp called Gp3Lib.cpp.

the original WinMain look like this
[code]
int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPreInst,LPSTR lpszCmdLine,int nCmdShow)
{
?stageInfo::readinFileTable();
?Sys_SetScreenMode();
?return DoWindow(hInstance,hPreInst,lpszCmdLine,nCmdShow);
}
[/code]


the only thing I can suspect the odd is the "while(true){" loop at the DoWindow call
[code]
BOOL DoWindow(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow) {
[indent=1]MSG pMsg;
WNDCLASS myProg;
LPCSTR Name = "Window_Class_Name";
if (!hPreInst) {[/indent]
[indent=2]myProg.style = CS_HREDRAW | CS_VREDRAW;
myProg.lpfnWndProc = WndProc;
myProg.cbClsExtra = 0;
myProg.cbWndExtra = 0;
myProg.hInstance = hInstance;
myProg.hIcon = LoadIcon(hInstance,"MAIN");
myProg.hCursor = LoadCursor(NULL, IDC_ARROW);
myProg.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
myProg.lpszMenuName = NULL;
myProg.lpszClassName = (Name);[/indent]
[indent=2]if (!RegisterClass(&myProg)) return FALSE;[/indent]
[indent=1]}[/indent]
[indent=1]hWnd = CreateWindow( (Name), (USERNAME), ... );[/indent]
[indent=1]InitDxLib();
OnCreate();
Sys_CreateLoadThread();
InitPlayerInput();
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);[/indent]

[indent=1]while(true){[/indent]
[indent=2]if( PeekMessage( &lpMsg, NULL, 0, 0, PM_REMOVE ) ){[/indent]
[indent=3]if(lpMsg.message == WM_QUIT){ break; }
TranslateMessage(&lpMsg);
DispatchMessage(&lpMsg);[/indent]
[indent=2]} else if ( Sys_LoopControl(60) ) {[/indent]
[indent=3]FrameTime = (timeGetTime()-old_time)/F(1000);
old_time = timeGetTime();
GameLoop();[/indent]
[indent=2]}[/indent]
[indent=2]Sleep(1);[/indent]
[indent=1]}
OnDestroy();
DelDxLib();
_CrtDumpMemoryLeaks();
return((int)lpMsg.wParam);[/indent]
}
[/code]
0

Share this post


Link to post
Share on other sites
omg, that was a bad indentation!! and it look like I can not re-edit or preview before I post...
[code]BOOL DoWindow(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow) {
?MSG pMsg;
?WNDCLASS myProg;
?LPCSTR Name = "Window_Class_Name";
?if (!hPreInst) {
??myProg.style = CS_HREDRAW | CS_VREDRAW;
??myProg.lpfnWndProc = WndProc;
??myProg.cbClsExtra = 0;
??myProg.cbWndExtra = 0;
??myProg.hInstance = hInstance;
??myProg.hIcon = LoadIcon(hInstance,"MAIN");
??myProg.hCursor = LoadCursor(NULL, IDC_ARROW);
??myProg.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
??myProg.lpszMenuName = NULL;
??myProg.lpszClassName = (Name);
??if (!RegisterClass(&myProg)) return FALSE;
?}
?hWnd=CreateWindow( (Name), (USERNAME), ... );
?InitDxLib();
?OnCreate();
?Sys_CreateLoadThread();
?InitPlayerInput();
?ShowWindow(hWnd,nCmdShow);
?UpdateWindow(hWnd);
?while(true){
??if(PeekMessage(&lpMsg,NULL,0,0,PM_REMOVE)){
???if(lpMsg.message == WM_QUIT){ break; }
???TranslateMessage(&lpMsg);
???DispatchMessage(&lpMsg);
??} else if (Sys_LoopControl(60)){
???FrameTime = (timeGetTime()-old_time)/F(1000);
???old_time = timeGetTime();
???GameLoop();
??}
??Sleep(1);
?}
?OnDestroy();
?DelDxLib();
?_CrtDumpMemoryLeaks();
?return((int)lpMsg.wParam);
}[/code]
0

Share this post


Link to post
Share on other sites
I'm guessing that "Sys_CreateLoadThread();" involves creating a thread to load resources. Loading resources requires the D3D device at some point.

By the way to get rid of the annoying redundant render state messages, change the debug output level to one step below the maximum.
0

Share this post


Link to post
Share on other sites
Tahnks Adam!
you are genius!
how could I have missed that XD


although this is barely scrashing the directX.

void Sys_CreateLoadThread() {
?HANDLE newThread;
?InterlockedExchange((volatile LONG*)&_LoadEnd,0);
?newThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Sys_LoadThread,hWnd,0,NULL);
}

void Sys_LoadThread(HWND hWnd) {
?OnLoading();
?InterlockedExchange((volatile LONG*)&_LoadEnd,1);
}

and inside the OnLoading(), it's just for loops to load all the resources specified...
_LoadEnd is not been used anywhere but insides the above 2 functions.
as googled... think the WaitForSingleObject is needed but it's not been used.
I'm a lilo confused here...
so it created a new thread to load resource.
but not waiting for the loading to complete...

if that assumption is true, then probably it explains why the program yells LOADING FAIL occasionally.


ahyhow, I've restored everything back to what it was, but replaced Sys_CreateLoadThread() with the OnLoading()
so far, and I think it is sweet.


I DO think this API needs a rewrite...
besides this, I've caught quit some bugs too...


Kindly Regards to oeveryone, Hiro
0

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  
Followers 0