Jump to content

  • Log In with Google      Sign In   
  • Create Account

Flimflam

Member Since 27 Oct 2005
Offline Last Active Dec 28 2013 10:01 PM

Posts I've Made

In Topic: QueryPerformanceCounter Win32 timer slower than normal

12 November 2013 - 04:17 AM

And for people complaining that "it takes all the CPU", relax - first, the CPU is there to be used, and secondly, the CPU is not doing very much work at all when just waiting for the delta time to elapse to draw the next frame (so it won't overheat or anything - it's not as if it were running Linpack in the meantime). Context switches are expensive, let the operating system handle these details for you and write code without worrying about them - it knows what it's doing better than you do. If you really cannot deal with this, then you can always try and change the timer resolution with timeBeginPeriod(), to, for instance, 1 ms, and then use Sleep(), which will give some better results, but be warned that this may still cause your framerate to jitter to up to +- 1 ms if your thread happens to be sleeping as you cross the 16.67ms threshold.

 

Actually, if you have a busy wait loop running like that, it actually will run the processor ragged, and if they're on a laptop it's going to be eating their battery to its fullest.  If they're committed to a tight loop, however, you don't need to call Sleep every frame. Every 10-15 frames should be enough to give the CPU a breather, maybe even more, and over such a period of time, the time eaten by sleep will be barely noticeable.  

 

However I really don't think I'd advise a loop like that. I second the notion that limiting your main rendering framerate should be handled by vsync because there is almost no reason to do it yourself and lots of reasons why you wouldn't want to do it yourself.


In Topic: DirectX 9.0c: DrawTextA() Onto DirectX Texture?

11 November 2013 - 07:35 PM

Didn't you ask the very same question yesterday? Why make a new thread?


In Topic: Why XML is all the rage now?

11 November 2013 - 02:42 AM

Honestly, I think XML might be hated a bit too religiously these days. Many of the biggest things make the biggest targets for criticism. Unless you're going full-featured in your XML usage, it's plenty readable and if you make proper use of attributes, it isn't that much bigger than things like JSON.


In Topic: DirectX 9.0c: Draw TTF Text On DirectX Sprite?

11 November 2013 - 12:23 AM

You're already on the right track, it sorta looks like. D3DX provides the ID3DXFont interface for loading system fonts and drawing with them, and your code seems to be calling into that interface, just not at the right time. You can't draw to the textures/sprites as you load them, if that's what you're asking (without render targets or direct texture editing) but you can draw the text over the buttons when it comes time to render everything.

 

Just call the ID3DXFont:DrawText method when you're calling the draw code, after you've drawn your buttons. 


In Topic: DirectX 9: Best Method To Limit FPS?

31 October 2013 - 11:53 PM

 


I just want the game engine to run at a constant 60 Frames Per Second on any computer.

If all you care about is 60FPS, then call Present() with the D3DPRESENT_INTERVAL_ONE flag. This will enable vsync, limiting your FPS to the monitor refresh rate.

 

This probably isn't the most reliable method if he intends on getting 60fps across the board. The number of 120hz monitors are increasing rapidly, so those individuals will be getting locked at twice the speed of others with 60hz displays. 


PARTNERS