Thread: CPU Load High

    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2006
    Location
    Houston, Texas, USA
    Posts
    392
    Rep Power
    9

    Unhappy CPU Load High


    I'm using Win32 API. And when I run the application, the CPU load is loud. And I was wondering how do I get it not be so loud. Heres the loop. Oh its not loud when it's visible, but when you minimize it or put it behind another window that covers it, its loud.

    Code:
    if(SUCCEEDED(initD3D(hWnd)))
    	{
    		if(SUCCEEDED(init_graphics()))
    		{
    			ShowWindow(hWnd, nCmdShow);
    			UpdateWindow(hWnd);
    			
    			MSG msg;
    			ZeroMemory(&msg, sizeof(MSG));
    			while(msg.message != WM_QUIT)
    			{
    				if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    				{
    					TranslateMessage(&msg);
    					DispatchMessage(&msg);
    				}
    				else
    					render_frame();
    
    				// check the 'escape' key
    				//if(KEY_DOWN(VK_ESCAPE))
    					//PostMessage(hWnd, WM_DESTROY, 0, 0);
    			}
    			
    			// clean up DirectX and COM
    			cleanD3D();
    		}
    	}
    [img]
    http://r2.fodey.com/1922b06d7e4284cce9657003fdf330220.1.gif
    [/img]






  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2007
    Posts
    8
    Rep Power
    0
    Sorry, I'm not familiar with Win32API but...

    ... I think you're rendering too many frames ... okey I will cut the jokes.

    Basicly you have the inner while loop without any 'sleeping', if you stop rendering the scene when the window is minimized, it will cycle like a fury - causing the processor to heat up.

    If I'm mistaken due to my lack of knowledge, I'm sorry...

IMN logo majestic logo threadwatch logo seochat tools logo