I've been working on a project off and on in SDL for a number of months now, and I've had an issue from the start that I recently had some time to try and debug. I've been developing on Windows XP until this past week, so it was not really an issue until now.
Basically, my SDL bases game works perfectly fine on any Windows XP machine (ie. normal frame rate, shaders work no problem), but I initially noticed that if I ran the executable on Windows 7, the frame rate would only be 10-15 for no reason (on super high-end machines, ie. Phenom II X6 / 5970) but this was strictly a Windows 7 issue as indicated by testing on several different machines. Upon further investigation I realized that if I run the game from within Visual Studio 2008 on a Windows 7 machine it works perfectly (ie. 7000+ FPS w/o vsync), but as soon as I ran it from the executable instead, the frame rate would once again be between 10 and 15, and if shaders were being used via GLEW, the program would simply exit because GLEW 2.0 was unavailable.
tldr; SDL OpenGL game, works fine on XP, on Win7 works fine in VS2008 but EXE limited to 10 fps and shaders wont work
Honestly not sure what the issue could possibly be and has been baffling me for some time. If anyone has any suggestions or input, it would be greatly appreciated. It almost seems like SDL is somehow switching to software mode or some limited version of OpenGL. Also worth mentioning that the only things being rendered is some text (generated and rendered via lists) and a very simple skybox with 1024x1024 textures for each side.
My game is using SDLmain and a number of libraries, including:
SDL
SDL_ttf
GLEW
FreeImage
Qt
FMOD Ex
FBX SDK
Bullet Physics
Thanks for reading. Some code, if it helps any:
Main.cpp:
#include "Game.h"
int main(int argc, char * argv[]) {
Game * game = new Game();
if(!game->init()) { return -1; }
game->run();
delete game;
return 0;
}
It's likely that your event queue accumulates more and and more windows events until your game slows down to a crawl -- you need to process all of the window messages between each frame, not just one per frame. (Not sure if this will fix your problem, but it will certainly help...)
Oh dear, I feel ashamed for implementing that wrong. Thanks for the reply! Although this did not fix my previous issues (slow framerate, shaders unsupported), it did fix my input handling and bizarre behaviours I was experiencing with my camera which I had yet to solve, so thanks!
Still looking for a solution, though. I just can't figure what's so different with the execution of the game between being run from Visual Studio 2008 vs. from the compiled release executable.
Not as far as I know, I'm using glLists for my SkyBox, and standard OpenGL stuff for the rest, see code below. The only strange thing I'm doing is using SDL_ttf which uses SDL_Surface to blit text which I convert to an OpenGL texture. Irregardless, I don't think any of this should be an issue if it works perfectly fine from Visual Studio 2008, right?
Edit: Furthermore, there are no problems on Windows XP when running from either VS2008 or EXE. So why is it such a problem on Windows 7? I'm using platform independent libraries (ie. no STL), so I'm still completely baffled.
Found the solution to all my issues finally, after consulting some friends. Turns out Visual Studio 2008 on Windows 7 would use the operating system's version of OpenGL, and when I ran it from the EXE it used the local OpenGL32.dll which was either out of date, or built for the wrong platform. So, removing this DLL fixed all framerate issues, and now runs no problem after defaulting to the operating system's OpenGL32.dll. Hopefully this helps anyone else who runs into this issue!