Jump to content
  • Advertisement

Nyap

Member
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

132 Neutral

About Nyap

  • Rank
    Member

Personal Information

  • Interests
    |programmer|
  1. Nyap

    TTF_Quit segmentation fault

    I came up with the cleaner solution of defining main as part of the framework like so: int game(int argc, char** argv); int main(int argc, char** argv) {     Builder::init();     int returnValue = game(argc,argv);     Builder::deinit();     return returnValue; } And then obviously in the game you use game() instead of main()
  2. Nyap

    TTF_Quit segmentation fault

    That's a useful command I'll have to remember it (I still don't understand the cause of the error though)  
  3. Nyap

    TTF_Quit segmentation fault

      Have you been able to run your program in gdb or another debugger? I find that it sometimes shows me exactly where things went wrong, although in this case I wonder if the crash is separated from the introduced problem. Valgrind is also a good option if this is a memory issue, as it can tell you if you have issues with memory management.   Looking at font.cpp, I see that you do TTF_CloseFont on your pointer before you assign a new font to it, so that seems correct. Your destructor runs TTF_CloseFont(). Is it possible that the mFont is already closed by this point? The docs don't say what happens if you call CloseFont on an already closed font, so I am not sure what may happen. Sounds like a good experiment to try.   Oh, I just saw that your Builder::deinit() is calling SDL_Quit() before TTF_Quit(). SDL_Quit() should be called last. See https://wiki.libsdl.org/SDL_Quit "If you start a subsystem using a call to that subsystem's init function (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(), then you must use that subsystem's quit function (SDL_VideoQuit()) to shut it down before calling SDL_Quit()."   I hope this helps!   I added a check in ~Font() and re-ordered the quit functions so SDL_Quit() is last, but it didn't work. gdb says this:
  4. I'm writing a framework for my games which can be found at https://github.com/Nyapp/Builder It works well until the program has to exit, and then it gets a segfault. It has something to do with TTF_Quit() because I removed it from Builder::deinit() (which quits all 4 SDL libraries) and then it disappears. Help?
  5. OK, I admit I should have included more information   I want to automate the interactive online homeworks at showmyhomework.co.uk - I'm not a lazy kid, I just thought it would be an interesting project   I want it to be hidden so that the interface is cleaner   And it doesn't relate to game development, because I put it in the general programming section
  6. How could you do this? I'd prefer if the bot was hidden (as in the website isn't visible on the GUI when the bot does its thing)
  7. Nyap

    Class segmentation fault

    I added the following code to aggressiveEntity::shoot()//Copy temp to myBullets delete[] myBullets; myBullets=temp;-now I get this:
  8. Nyap

    Class segmentation fault

    oops I forgot to upload my latest changes to the code<br> the owner variable isn't there anymore, and I think that only now have I decided to start using an array of pointers to Bullet's scattered around in the heap instead of the Bullet's being laid out sequentially in memory
  9. The code can be found here: https://github.com/Nyapp/Cell/blob/master/src/classes/aggressive.h https://github.com/Nyapp/Cell/blob/master/src/classes/bullet.h But basically I have an array of pointers, that are all assigned a Bullet class using the new operator. However, when one of those Bullet classes tries to write to one of it's variables (like in Bullet::update()), a segfault occurs. And I tried viewing a few variables using which are supposed to be zero-initialized using cout, but I get a bunch of garbage
  10. I need the address of the owner so that the owner can delete the bullet from memory - unless there's some other way I could do it? Also, how do you forward declare a member function? (Bullet uses aggressiveEntity::destroyBullet(int))
  11. &nbsp; &nbsp; It would be helpful if you included the compiler error message. EDIT: That said, in AGGRESSIVE_CLASS you have "class Bullet" randomly near the top, which at the very least would need a semi-colon if you're wanting to forward-declare it. &nbsp; ok I fixed that random "class Bullet" and I also had to link to the source code because every time I edit the post everything between the code tags goes on one line
  12. So here's the two classes I'm having trouble with (they are in seperate header files) aggressiveEntity: https://github.com/Nyapp/Cell/blob/master/src/classes/aggressive.h Bullet: https://github.com/Nyapp/Cell/blob/master/src/classes/bullet.h as you can see, aggressiveEntities have an array of Bullets and Bullets have a pointer to their owner entity.
  13. Here's the code: https://github.com/Nyapp/Cell/blob/master/src/engine_classes.h The TTF_CloseFont() that I'm having trouble with is in Text::~Text(). When I close the game, I get a segfault. What am I doing wrong?
  14. ok so turns out that I was just being an idiot and forgot to copy the backbuffer to the frontbuffer (now that i've fixed it, it works at 3K FPS). that's also why nothing was appearing in the window dddddddddeeeeeeeeeeeerrrrrrrrrrrrrrrppppppppppppp I'll take all these tips into consideration though thanks
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!