Advertisement

Strange happenings

Started by July 27, 2000 12:05 PM
3 comments, last by Snowman 24 years, 4 months ago
Hello. I have some very strange things going on with my program. It involves dramatic changes in the FPS (frames per second). When I start the application, it will be running at 60 fps (fullscreen and that''s my refresh rate, so that''s as fast as it can go). Now, if I start a new game (it starts with the menu stuff) within about a second of the application starting, the game will run at 60 fps also. Now, if I wait a little bit, then try to start a new game, it will NOT run at 60 fps. More like 5. After exiting a game (it doesn''t matter if it was fast or slow), the menu stuff will once again run at 60 fps, but every game after that will be slow (the 5 fps version). At first I though that perhaps the menu code was somehow polluting the rest of my code, so I commented it out and added simple "press n for new game, q to quit" stuff. That didn''t help. My other thought was that perhaps the graphics engine was getting dragged down, but that can''t be the case because the menu stuff uses it just like the game does (the game doesn''t do much yet =P) Yet another thought was that the menu system was running in the background or something, but that can''t be happening because once the game is started fast, it stays fast. It won''t slow down (like one would expect if there was "residue" building up). I honestly have no idea what else to look at. I know it''s hard to answer a question like this with out code, so here''s some simplified code: Update() // Called every frame { switch( Mode ) { case GAME: m_pClient->Update(); break; case MENU: m_pMenu->Update(); break; } } It''s that simple, really. The stuff in the menu->update() can''t be the problem because I replaced that and it still broke. I''m 90% sure that the client->Update() can''t be breaking it because it will work sometimes, or it will start slow. I''m really lost here. I have no idea what to do. If you have any questions, suggestions, or comments PLEASE let me know! If you want me to post or explain anymore code, just ask. Thanks! -Snowman
Does your game actually run at 5fps or is your fps counter just showing 5?
There's always something smaller and something bigger. Don't sweat the small stuff and don't piss off the big stuff :)
Advertisement
It really runs at about 5 fps. That sucks too because nothing looks like it''s moving, it''s all jumpy. It''s horrible!!

-Snowman
Good news!

I found my problem. It has something to do with my multi-threading code. Now I have to try to figure out why it''s not working. I used the tutorial on flipcode.

The only thing that I can think is that it has to do with how soon the second thread is created after the first thread, hence it''s relationship to the start of the program.

So, my questions now:

1) Could the two thread start times have to do with my problems?

2) How do I go about fixing them??

I don''t understand why the threads would need to start one right after another.

Thanks for any help!

-Snowman
Well, I decided to just work around my problem. I made the thread start at the beginning of the program and just called SuspendThread() and ResumeThread() when I needed to in order to "start and stop" the thread.

Everything works great, I''m back to 60 fps for the game, every time I run it! =)

I hope my experience helps someone else with a similar problem!!

-Snowman

This topic is closed to new replies.

Advertisement