I'm having some weird slowdown problems in my program written in C.
I have the following code:
typedef struct {
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 alpha;
} COLOUR;
COLOUR get_colour(int r, int g, int b, int alpha) {
COLOUR colour;
colour.r = r;
colour.g = g;
colour.b = b;
colour.alpha = alpha;
return colour;
}
Then I insert something like this into my main loop, just to reproduce my problem:
for (i = 0; i < 640 * 480; i++) {
blue = get_colour(0, 0, 255, 255);
yellow = get_colour(255, 255, 0, 255);
}
This works fine until it slows down.
BUT, if I translate the code for my get_colour () function into a separate .C file (I prefer to store such functions in a library), I start the slowdown. Just a simple for-loop above causes the frame rate to drop from 100 to fps to 70 frames per second.
Moving the code for my get_colour () function returns to the same .C file as the rest of the code returns the normal speed.
What causes this?
- GCC MinGW, - .
.