Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Strange Phenomenom in DirectX Wrapper

This topic is 5645 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m having an unusual benefit/problem with my current DirectX wrapper. In my main file I have a basic loop that just makes sure the current window is alive, and if it is alive then it clears the screen to a purple color. graphicDevice is just a normal pointer to a Direct3d9 device. mainWnd is a basic win32 wrapper for a window class, that was acquired from the engine. The engine also has a reference to it. while( mainEngine.getWindowStatus(0) ) { mainWnd->beginAPIScene(); graphicDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(90,0,120), 1.0f, 0 ); mainWnd->endAPIScene(); mainEngine.update(); } Now the calls beginAPIScene and endAPIScene are just handlers that set some booleans to state that a scene is being drawn, and call BeginScene() and EndScene(). When mainEngine.update() is called it queries the window mainWnd and forces it to update. When mainWnd updates it tests if a scene has been drawn (ie- beginAPIScene and endAPIScene both called) and if so, it calls the normal Direct3d Present(....). STRANGE THING: I figured that due to the overhead on the above loop that it would be much faster to run the loop using only the direct3d device pointer, which I do in the following code dump: while( mainEngine.getWindowStatus(0) ) { graphicDevice->BeginScene(); graphicDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(90,0,120), 1.0f, 0 ); graphicDevice->EndScene(); graphicDevice->Present( NULL, NULL, hWnd, NULL ); } Anyhow, the strange thing is that second implementation that has only the standard overhead of the direct3d implementation actually runs slower and I have no clue why. It averages 10-20updates per second slower than the original loop with all the "overhead". Both loops do the exact same thing. It seems to me that the original loop would just simply have more instructions to accomplish the same task. ON TOP OF ALL OF THAT: mainWnd is a DirectX implementation that implements a virtual window class, and beginAPIScene and endAPIScene are implementations of virtual functions, which are supposed to be slower due to more pointer dereferencing. I''m trying to speed up things in my code and this has me seriously boggled, so any hypothesis would be much appreciated! Thanks.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!