Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

SDL Functions failing and causing segfaults, and I don't know why

$
0
0
I am attempting to make a Pong game using SDL. I'm trying to render text on the screen, but segfaults prevent the code from running. I ran it in gdb, and found that the segfaults occur because SDL_QueryTexture doesn't give the ints passed into it any values. I put a statement to print SDL_GetError() after SDL_QueryTexture, and it says: "Failed loading SHCORE.DLL: The specified module could not be found." This wasn't happening after I made some adjustments to my code, so I believe the code is causing this problem. The relevant code is below: In case the rest of the code has a part in this, the entire .cpp file is attached. void loadText(string s) { SDL_Color color = {255,255,255}; SDL_Surface* textsurface = TTF_RenderText_Solid(font, s.c_str(), color); if(textsurface == NULL) { cout << "Could not rendertext onto surface" << endl; } texture = SDL_CreateTextureFromSurface(r,textsurface); if(texture == NULL) { cout << "Could not make texture" << SDL_GetError() << endl; } SDL_QueryTexture(texture, NULL, NULL, w, h); cout << SDL_GetError() << endl; SDL_FreeSurface(textsurface); textsurface = NULL; //cout << "Texture query error" << SDL_GetError() << endl; } void textRender(int x, int y) { destinationrect = {x,y,*w,*h}; if (SDL_RenderCopy(r,texture,NULL,&destinationrect) < 0) { cout << "Rendercopy error" << SDL_GetError() << endl; } } test.cpp OpenSans-Regular.ttf

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>