简体   繁体   中英

SDL_Surface Segmentation Fault

so here's my problem(s). I have a class DrawMgr in which function DrawCube I call, my other class' function draw in which I use SDL_Surface. My main problem is that when I start moving the mouse over the window I created after some time it gives a segmentation fault, which when I backtrace says it has something to do with freeing the surface. The other thing is when I call the function DrawCube in the DrawManager.cpp it doesn't draw the cube.

EDIT: The problem was that I handled the "Escape" key with e.key.keysym.sym == SDLK_ESCAPE , which captured all movement within the window which made it crash. The correct way was e.type == SDL_KEYDOWN && e.key.keysym.sym...)

SDL_GetWindowSurface documentation says This surface will be freed when the window is destroyed. Do not free this surface.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM