• Advertisement
Sign in to follow this  

SDL_PollEvent crashes when adding an additional line.

This topic is 754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Whenever FindPath is commented out, the program runs fine,

Otherwise, it crashes, it is about to say that the stack has corrupted.

Any ideas?




#include <SDL.h>
#include <thread>
#include <chrono>
#include "general_part.h"
#include "Path.h"   

bool gbSmoothSimple = false;
bool gbDirectional = true;
bool gbCurved = true;
bool gbSmooth48 = true;
bool gbSmooth = true;
double gGranularity = 0.5f;
bool gbIgnoreBounds = true;
bool gbFixed = true;
double gTurnRadius = 0.01f;
double gShipWidth = 0.8f;
int gSearch = 8;

void initGrid();

SDL_Surface* screen = NULL;
SDL_Event event;

int main(int argc, char* argv[]) {


    SDL_WM_SetCaption("Pinter Demo", NULL);

    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);

    bool running = true;

    FPOINT start, end;

    start.x = 0.0f;
    start.y = 0.0f;

    end.x = 10.0f;
    end.y = 10.0f;

    FINFO* path = new FINFO();    

    double startDirection = 0.1f;
    while (running)
        if (SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                running = false;

        int status = FindPath(start, end, startDirection, path);


    return 0;

void initGrid() {
    for (int i = 0; i < MAX_GRIDSIZE; i++) {
        for (int j = 0; j < MAX_GRIDSIZE; j++) {
            gGrid[i][j] = false;

Share this post

Link to post
Share on other sites

Yes, run it under debugger, set breakpoint at FindPath line, step into and step by step see what's going on. Check the backtrace, check variables. This way you will solve your problem within minutes. How are we supposed to tell why it crashes if you give us only scraps of code ( without the most relevant part which is body of FindPath()  ) and without any clue what and how your code supposed to be doing? 

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement