Skip to main content
GameDev.net gamedev.net
🔒 Locked

Weird IdleLoop Problem

Started by BumpMapped Aug 30, 2008 at 3:31 PM 0 replies 600+ views
Original Post
BumpMapped
BumpMapped
Hello all, i'm getting quite mad about an FPS glitch i have in my application, the program is divided in two sections, the main app is done in VB.NET (i know i know.. but my coworker can't understand C++) while the D3D renderer is a C++ DLL. The app uses the idle event to render while there aren't messages to be processed in the window message loop. The rendering is done in windowed mode. VB.NET Side: Private Sub Form1_Idle(ByVal sender As System.Object, ByVal e As System.EventArgs) While AppStillIdle() = True Aggiorna() DisegnaStatistiche() End While End Sub Private Function AppStillIdle() As Boolean Dim mex As System.Windows.Forms.Message AppStillIdle = Not PeekMessage(mex, IntPtr.Zero, 0, 0, 0) End Function 'Aggiorna()' does a bunch of things and takes responsability to update the d3d rendering by calling one export of the C++ DLL, so far so good. ------------ This is how i initialize Direct3D in the C++ DLL: ZeroMemory(&pres, sizeof(D3DPRESENT_PARAMETERS)); pres.Windowed = TRUE; pres.SwapEffect = D3DSWAPEFFECT_FLIP; pres.BackBufferFormat = D3DFMT_UNKNOWN; pres.EnableAutoDepthStencil = TRUE; pres.AutoDepthStencilFormat = D3DFMT_D24S8; pres.PresentationInterval = D3DPRESENT_INTERVAL_ONE; Engine = new Dispositivo(pres, hMainWindow, WindowWidth, WindowHeight); ------------ The scene i am rendering atm is very simple, infact if i remove the D3DPRESENT_INTERVAL_ONE parameter but use D3DPRESENT_INTERVAL_IMMEDIATE the whole thing runs at 600+ fps (thanks also to my lovely 8800GT), with VSYNC on im getting NOT costant FPS, and you want to know the weird thing ? if i move the mouse fast and keep moving it the FPS i get are perfect constant VerticalRefreshLimit(Tm) (god bless it) frames per second. I have tried using different swap effect flags and so on but the problem stays. Rendering from a timer makes it a quite more stable but i really do not like the idea vs the use of idle loop. My understanding is that maybe Windows is not playing nice with my app when the app is not receiving windows messages and while it is the app gets more attention ? Maybe i need to boost the priority of my process ? How would a poor "getting pissed and insane" programmer fix this ? [Edited by - BumpMapped on August 30, 2008 3:47:37 PM]
FippyDarkpaw
FippyDarkpaw
If possible, maybe try to programatically invoking an input event every update?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.