hi i have a problem with sdl 1.3:
when calling:
SDL_DestroyTexture()
i crash with an unhandled exception. has anybody an idea what could goes wrong??
code snippet:
Code:
void connect()
{
SDL_Init(SDL_INIT_VIDEO);
SDL_SelectVideoDisplay(params_.displayId_);
SDL_DisplayMode requestedMode;
requestedMode.w = params_.widthInPixels_;
requestedMode.h = params_.heightInPixels_;
requestedMode.refresh_rate = static_cast<int>(params_.frequencyInHz_ + 0.5);
requestedMode.format = static_cast<UInt>(SDL_PIXELFORMAT_RGBA8888);
if (SDL_GetClosestDisplayMode(&requestedMode, &mode_) == NULL)
throw Error("Image size is not supported by selected display.");
Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL;
window_ = SDL_CreateWindow("Output", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, params_.widthInPixels_, params_.heightInPixels_, flags);
if (window_ == NULL)
throw Error("Could not create window for output.");
SDL_SetWindowDisplayMode(window_, &mode_);
SDL_CreateRenderer(window_, -1, SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED );
SDL_SelectRenderer(window_);
texture_ = SDL_CreateTexture(mode_.format, SDL_TEXTUREACCESS_STREAMING, params_.widthInPixels_, params_.heightInPixels_);
if (texture_ == NULL)
throw Error("Could not create texture for output.");
imagebuffer_ = new Uint32[mode_.w * mode_.h];
if (imagebuffer_ == NULL)
throw Error("Out of memory.");
}
void disconnect()
{
if (isSDLOk_)
{
if (imagebuffer_ != NULL)
{
delete imagebuffer_;
}
if (texture_ != NULL)
{
SDL_DestroyTexture(texture_);
texture_ = NULL;
}
if (window_ != NULL)
{
SDL_DestroyWindow(window_);
window_ = NULL;
}
SDL_SelectVideoDisplay(0);
SDL_Quit();
isSDLOk_ = false;
}
}
as far as i don’t call the lines it doesn’t crash by my intention of using sdl neither
Code:
SDL_CreateRenderer(window_, -1, SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED );
SDL_SelectRenderer(window_);
any ideas what could go wrong in here?
thx,
mp