-
Notifications
You must be signed in to change notification settings - Fork 27
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
How to think of windows, resizing, monitors, fullscreen mode in context of a browser. #9
Comments
In #8 (comment), @Omustardo said:
I think thinking of canvas as the equivalent of a window is one approach. It's viable. But it's not the only approach. Let's first enumerate all the viable alternatives and compare them. Here's what I can think of that can map to a GLFW window:
Currently, The observation I made was that too many window abstractions are not helpful. It's counter-productive to have a window (GLFW window as the canvas element) inside the browser window. The user can already move and resize the browser window, why would they want to move a canvas element window inside the browser window? So I decided to go with 2 and forfeited the ability to control the window size at creation time, as well as programmatically resizing the window. Instead, the user controls window size and position by resizing and moving the browser window. This seems to work well. If a game or app cannot use a given size, it can simply add padding around the unused area and draw in the center.
They can, but it's hard and I think it's simpler to just draw what you want into a larger window. That way you only deal with OpenGL, instead of doing that and also having to deal with HTML. However, an option I've thought of but haven't explored yet is to create new popup windows with However, I haven't tried it yet and don't know how well it'd work in practice. Popup windows are not great in 2016, and they work poorly on mobile devices, etc. There's another potential use of goxjs/glfw in the browser that isn't supported currently. What if you want to have multiple windows on the same HTML page. That would work with approach 1, but not 2. It'd also work with 3 though. Just wanted to share my thoughts and context on what I've already tried @Omustardo. I would classify #8 as a PR that tries to change from approach 2 into 1, but I'm not sure it's a good idea. I'm open to change my mind if there are compelling arguments, but it just seems 2 is the simplest and best overall solution for now. Let me know what you think. |
I thought about the issue since last posting and came to the same conclusion. Maintaining desktop GLFW behavior in the browser requires taking the whole window. Using only a canvas leads to behavior that doesn't exist for desktop windows, and would be difficult/(impossible?) to work around with the same API. Having a new popup is an interesting option - arguably most similar to a new desktop window, but I agree that the disadvantages of popups make it not worthwhile. I've adapted the tetris code to pad the edges and I think it looks much better than before. Thanks for taking the time to discuss this and for all of the work you put into these libraries. I've really enjoyed being able to put together something graphical on the web, while still working in the clean environment that Go provides. |
Sorry to necropost on this, but I've been looking to use glfw for game development in Go (for a 2d, browser-based MMO). I'm considering ways to implement various methods that are currently panicking. What if the browser window is the monitor and the canvas is the window? That would give the most consistent behavior coming from native development. Since changing window size is disabled on most browsers (for good reason), this would allow us to provide consistent behavior (setsize = resize canvas, moveto = set canvas offsets). |
This is a tracking issue for this subject, it's meant to contain the relevant discussion and planning. So it's completely okay to post here.
Please see and read in full detail my #9 (comment) above. It outlines 3 possible approaches that I've considered, and discusses the trade-offs between them. Approach 1 is the canvas idea you're asking about. |
Start adding the Joystick API, with stubs for the browser
This issue is to discuss how to think about and how to map the GLFW desktop concepts such as windows, resizing, monitors, fullscreen mode, etc., in the context of a browser. It resumes the discussion started in #8.
The text was updated successfully, but these errors were encountered: