33Fermer35
NilLe 31/12/2015 à 21:35
Folco (./33) :
De plus, tu fais des opérations sur une texture sans savoir si elle existe, donc si ça déconne, le message d'erreur ne sera pas clair.
Ah oui, mince, ça m'apprendra à ne pas chercher à comprendre le code triso

Bon, spontanément et plus sérieusement, voilà ma solution, qui correspond à ce qui a déjà été proposé :
m_Texture = SDL_CreateTexture(Game::get()->renderer(), px, SDL_TEXTUREACCESS_TARGET, width, height); if (m_Texture != nullptr) { throw Exception(ERROR_SDL_STR); } if ((SDL_SetTextureBlendMode(m_Texture, SDL_BLENDMODE_BLEND) == 0) || (SDL_SetRenderDrawColor(Game::get()->renderer(), 0, 0, 0, 0) == 0) || (SDL_RenderClear(Game::get()->renderer()) == 0) || (SDL_SetRenderTarget(Game::get()->renderer(), m_Texture) == 0)) { cleanup(); throw Exception(ERROR_SDL_STR); }
avec, éventuellement, cette variante (ça dépend des possibles évolutions de ton code) :
bool err = false; m_Texture = SDL_CreateTexture(Game::get()->renderer(), px, SDL_TEXTUREACCESS_TARGET, width, height); if (m_Texture != nullptr) { if ((SDL_SetTextureBlendMode(m_Texture, SDL_BLENDMODE_BLEND) == 0) || (SDL_SetRenderDrawColor(Game::get()->renderer(), 0, 0, 0, 0) == 0) || (SDL_RenderClear(Game::get()->renderer()) == 0) || (SDL_SetRenderTarget(Game::get()->renderer(), m_Texture) == 0)) { cleanup(); err = true; } } else { err = true; } if (err) { throw Exception(ERROR_SDL_STR); }