Thread: SDL CSprite.draw segfault. Very confusing.

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    SDL CSprite.draw segfault. Very confusing.

    Code:
                                    if (map->used[i][a] == 1)
    			        {
    					cout << "Used tile!\n";
    					int x = (i * tile_width) - CamOffX;
    					int y = (a * tile_height) - CamOffY;
    					map->tile[i][a].set(x, y);
    					cout << "Set tile!\nX/Y: " << x << '/' << y << endl;
    					map->tile[i][a].draw();
    					cout << "Drawn Tile!\n";
    				}
    Map is a struct containing the CSprite (the csprite class can be found at the cone3d.gamedev.net SDL tutorials).

    It sets just fine, but when i try to draw it, SDL parachute gets deployed on a segfault.

    Will post entire code if needed. Thanks in advance.
    Last edited by Blizzarddog; 12-09-2005 at 06:18 AM.
    This war, like the next war, is a war to end war.

  2. #2
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Update: Anything done with the x and y values after teh cout << x << y line segfaults it, including

    Code:
    drawString(screen, font, 0, 0, "X: %d, Y: %d", x, y);
    I don't think it likes me.

    I even pulled it all out of a structure and got the same results.
    This war, like the next war, is a war to end war.

  3. #3
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Okay, I traced it away from the csprite and that particular function. Since it no longer has to do with this subject, Ill make a new thread.
    This war, like the next war, is a war to end war.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. malloc() resulting in a SegFault?!
    By cipher82 in forum C++ Programming
    Replies: 21
    Last Post: 09-18-2008, 11:24 AM
  2. Problems compiling this SDL app
    By Rider in forum C++ Programming
    Replies: 3
    Last Post: 03-27-2007, 12:22 PM
  3. SDL segfault when trying to draw to screen
    By Blizzarddog in forum Game Programming
    Replies: 2
    Last Post: 12-09-2005, 07:53 AM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. sdl in c++
    By Klinerr1 in forum C++ Programming
    Replies: 8
    Last Post: 07-07-2002, 07:46 AM