I recently started porting using SDL (1.2.15) to SDL2 (2.0.0) and previously depended on using the SDL_ttf (2.0.11) extension library to render fonts. When I try to use the same text library that I used with SDL version 1 with SDL2 (admittedly not yet officially released), it compiles just fine. When I run the executable, though (I am using VS2012 for the desktop at the moment), I get the following error:
Unhandled exception at 0x6C7D8C24 (SDL2.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000045.
From what I can assemble, this is due to the following bits of code. I created the Window class to encapsulate some common SDL functions:
window.cpp:
SDL_Texture* Window::RenderText(const std::string &message, const std::string &fontFile, SDL_Color color, int fontSize){
Will work
SDL_Texture *texture = SDL_CreateTextureFromSurface(mRenderer.get(), surf);
where the created SDL_Surface is incompatible with the definition of Surface SDL2, and therefore, when it tries to convert SDL_Surface to SDL_Texture, it is inverted.
I donβt think that I am the only one who has encountered this problem, so there is a workaround / updated version of SDL_ttf that fixes this, or should I hold on when switching to SDL2 until I can get the fonts to work
source share