Hi, I was wondering if there was anyone here who could look through a small header file of functions (4, small functions) and tell me how I could make them faster? Or, even better, do it for me, LoL
I'm pretty new to C++, I've been studying VB from since I was 8 (I'm only 15 now :P), but I've decided to use C++ to get some speed and eventually fully step over into C++.
I'm using VC++6 Standard Edition, and I know a little ASM, too, so any optimizations in ASM would be even more greatly appreciated.
The file is attached. If you need my other source files, then I can send them, too. The main function, which the other 3 rely on, is RenderSingle, so any optimizations there are most needed.
I'm going to be using the code pretty heavily, so I need to get it as fast as possible. Also, sorry if my post seems rude because I'm not too sure how to address people on a forum :P LoL
Replace all BYTEs by unsigned ints. The int is native to the CPU and calculations with it are therefore slightly faster.
StretchBlt is slow, so the speed of your function doesn't really matter anyway, expect StretchBlt to take up ~90% of the total time the function needs.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
@CornedBee: What do you suggest I use instead of StretchBlt?
I have thought of using PatBlt to blt a square of ZoomFactor*ZoomFactor size to the hdc, how would that go?
I have also tried not StretchBlt'ing but SetPixeling the larger sizes, that was far too slow...
After having second thoughts, I think you should not be bothered to optimise it since every function calls directly/indirectly RenderSingle() which uses setpixel().
setpixel() is very slow; Recently, I wrote an app using it.
All those basic operations of assignments and for loops takes place in terms of nanoseconds, if you optimise, you only save a few cycles, compare to setpixel() which takes in terms of microseconds.
If you can, save those in bitmap files and load them once and bltbit or stretchBlt them. They are much faster.
By the way, the file extension should be *.cpp, not h. Header files is for declarations and cpp is the implementations and definitions.
Hmmkay, thanks. Where can I get JUST the DirectX7 (NOT 8!!) headers and libs? I'm on a 56k modem so I don't want to download the full SDK - I have knowledge of DirectX pretty well so I don't need documentation, but I can't find anywhere that I can download JUST the headers and libs from... :P
If possible could someone upload just them for me? It'd be helpful if they'd all be up for download, but if not, the Core, DirectDraw, DirectInput and DirectSound take preference...
DirectDraw4 comes with your windows already But if you want 7, then you will have to get the whole deal or else it wont work... i mean, you have to get the entire sdk not just a few headers.... the sdk is about ~100MB probably less!