| Summary: | Render dies after SDL_SetWindowSize in other thread | ||
|---|---|---|---|
| Product: | SDL | Reporter: | alexander <aiac0692> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | CC: | amaranth72 |
| Version: | 2.0.3 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 7 | ||
SDL_Render must only be used in the main thread. This isn't a bug with SDL, just limitations of the underlying GPU APIs. A comment at the top of the SDL_render.h file mentions this as well. Similarly, I believe most of the window-related functions are not designed to be used in multiple threads either. It's OK, thanks. How I shall use Render if I host events from a mouse (SDL_MOUSEBUTTONDOWN) in other thread? To increase a window on mouse click... I shall create main thread and host events for processing of Render? Yes, that's the typical approach. Cheers, |
Good afternoon. I use the following code and I receive an error. SDL_Window * WindowTest; SDL_Renderer * RenderTest; SDL_Texture * TextureTest; void FirstThread() { WindowTest= SDL_CreateWindow(0, 0, 0, 640,480, SDL_WINDOW_SHOWN| SDL_WINDOW_FOREIGN| SDL_WINDOW_BORDERLESS); RenderTest = SDL_CreateRenderer(WindowTest,-1,SDL_RENDERER_ACCELERATED); TextureTest = SDL_CreateTexture(RenderTest, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STREAMING, 640,480); SDL_SetWindowSize(WindowTest,600,400); if(SDL_RenderClear(RenderTest)!=0) { printf("SDL_RenderClear failed: %s\n", SDL_GetError()); fflush(0); } // All OK!!! SDL_DestroyTexture(TextureTest); TextureTest = SDL_CreateTexture(RenderTest, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STREAMING, 600,400); } void SecondThread() { SDL_SetWindowSize(WindowTest,500,300); if(SDL_RenderClear(RenderTest)!=0) { printf("SDL_RenderClear failed: %s\n", SDL_GetError()); fflush(0); } // ERROR!!!! INVALIDCALL!! } int main () { boost::thread * first=new boost::thread(&FirstThread); first->join(); boost::thread * second=new boost::thread(&SecondThread); second->join(); } In other thread I can't change the size. I tried the SDL 2.0.3 version. Also I tried the version which is specified in "BUG" 1676. It doesn't work. https://bugzilla.libsdl.org/show_bug.cgi? id=1676 Help please...