Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple windows? #2

Closed
itdaniher opened this issue Aug 26, 2013 · 8 comments
Closed

multiple windows? #2

itdaniher opened this issue Aug 26, 2013 · 8 comments

Comments

@itdaniher
Copy link
Contributor

The SDL2 announcement claims

Support for multiple windows

However, with this somewhat trimmed down version of my graphing code, I get a segfault with this traceback / memory profile instead of a pair of windows like this when I try spawn a pair of windows and renderers in tasks separated across OS threads.

I haven't had a chance to source dive, but figured I'd post the issue and start discussion.

@AngryLawyer
Copy link
Member

I'm going to say I've probably ballsed up somewhere. I'll create a Demo case to try and reproduce/solve it, once I'm back home.

@AngryLawyer
Copy link
Member

Quick guess - could it be because you're calling SDLInit multiple times? I'm pretty sure that blew up some of my tests in SDL_gfx where I was initing multiple times, one for each demo window, accidentally. Switching to one sdl2::init in the Main thread might solve it all.

@AngryLawyer
Copy link
Member

If it is that, it might be an idea for us to move SDL_Init into a closure-thingy, although as you can SDL_Init different components at different times I'm not quite sure how to tackle this elegantly. Or sanely.

@itdaniher
Copy link
Contributor Author

moving

sdl2::init([sdl2::InitVideo]);

into main() solved the segfaulting, but attempts to create a new window with sdl2::video::OpenGL always fail with "OpenGL context already created."

Dropping that flag lets N windows be created without too much fuss, but I don't know what it costs us in terms of acceleration / if there's a better way to keep opengl contexts from stepping on eachother.

Thanks!

@AngryLawyer
Copy link
Member

You're welcome! Certainly wasn't expecting people to try using this so early in development.

The docs are unclear, but it simply says 'Usable with OpenGL context', so it's possible that it's used to do behind-the-scene prepping for using SDL with OpenGL, as I'm not sure that can support multiple renderers.

So, yeah, try just leaving it out, I guess. As long as you use Renderer rather than Surface it should be pushing the work to the video card. Should.

edit: ah yes, here we go: Renderer picks whether you're using the graphics card. http://wiki.libsdl.org/SDL_RendererFlags

@itdaniher
Copy link
Contributor Author

You're welcome! Certainly wasn't expecting people to try using this so early in development.

I need multiple windows and GPU accelerated 2D canvases enough to put up with short-term instabilities and brokenness. Don't mind helping with development work, either. SDL2 is fairly exciting!

@AngryLawyer
Copy link
Member

It certainly is! Are you happy to have this marked as fixed?

@itdaniher
Copy link
Contributor Author

Yeah, I'll remember to make a note about this as we approach a release, or better yet, bake it into a demo.

Thanks!

AngryLawyer pushed a commit that referenced this issue Nov 5, 2016
Cobrand pushed a commit that referenced this issue Dec 2, 2016
fix compile error: struct field default now private
Cobrand pushed a commit that referenced this issue Dec 2, 2016
Cobrand pushed a commit that referenced this issue Dec 2, 2016
Pass FPSmanager size as size_t to malloc instead of u64.
waych added a commit to waych/rust-sdl2 that referenced this issue Apr 23, 2021
This adds back the ability to compile the debug version of SDL2 when the
cargo build is a debug build.  Previous attempt (PR Rust-SDL2#1081) broke dynamic
linking bundled builds on Windows, forgetting to copy the resulting DLL
correctly and misspecifying the name of the library in that case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants