Jump to content

  • Log In with Google      Sign In   
  • Create Account

hiro4476

Member Since 18 Aug 2007
Offline Last Active Mar 21 2012 06:00 AM

Posts I've Made

In Topic: [directX] as the screen went frozen at D3DDevice->Present and leaves no e...

03 March 2012 - 02:02 PM

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

In Topic: [directX] as the screen went frozen at D3DDevice->Present and leaves no e...

29 February 2012 - 06:45 PM

omg, that was a bad indentation!! and it look like I can not re-edit or preview before I post...
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);
}

In Topic: [directX] as the screen went frozen at D3DDevice->Present and leaves no e...

29 February 2012 - 06:42 PM

thanks for the tips. but I'm not sure about this "main" thread thingy.
And I don't think it's related to http://stackoverflow.com/questions/266168/simple-example-of-threading-in-c

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
int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPreInst,LPSTR lpszCmdLine,int nCmdShow)
{
 stageInfo::readinFileTable();
 Sys_SetScreenMode();
 return DoWindow(hInstance,hPreInst,lpszCmdLine,nCmdShow);
}


the only thing I can suspect the odd is the "while(true){" loop at the DoWindow call
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]
}

In Topic: [directX] as the screen went frozen at D3DDevice->Present and leaves no e...

28 February 2012 - 09:42 AM

btw, here's the Warning message,

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

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

In Topic: [directX] as the screen went frozen at D3DDevice->Present and leaves no e...

28 February 2012 - 08:57 AM

Thanks to Tom's tip, I've managed to fix it!!
I fix it by providing a D3DCREATE_MULTITHREADED tag to the CreateDevice().


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.

PARTNERS