-
Notifications
You must be signed in to change notification settings - Fork 26
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
Implement SetSize #8
Conversation
Move existing code for setting canvas size to SetSize(). Maintains existing behaviour of filling the browser window by default.
Hi @Omustardo, thanks for the PR! The code looks reasonable. But let's discuss the idea of what it means to implement First, I can see in your window, err := glfw.CreateWindow(*windowWidth, *windowHeight, "Tetris", nil, nil)
if err != nil {
panic(err)
}
// glfw.CreateWindow ignores input size for WebGL/HTML canvas so set it here.
window.SetSize(*windowWidth, *windowHeight) I would like to keep the API of this package as close to the desktop GLFW as possible, so if we're going to implement I can see in the commit message you tried to preserve current behavior... But I don't think that's neccessary. If we have a good solution for setting size other than fullscreen, then it should be available everywhere. However, let's talk about what it means to have a GLFW window size that's smaller (or larger) than the browser window it's inside of. As you know, the current implementation takes a "hacky" alternative solution - it starts to treat the window width and height as optional "hints" and simply discards them, opting to let the browser window act as the proxy for the GLFW window size. So when user resizes the browser window, it resizes the GLFW window. I've tried your implementation on And with your patch: I have the following high level questions about your proposed behavior:
Let me know what your thoughts are. :) |
Hi shurcooL, The basis for all of the questions relies on what exactly is the GopherJS/HTML equivalent of the GLFW window. I'd consider it to be the canvas element alone, since that's all that we render into. It's not entirely accurate, since input handling affects the rest of the page (e.g. you can't right click in the whitespace in the tetris demo), but perhaps it's as close to a standard desktop GLFW window as can be expected. If that's not a good assumption, then the rest of this logic is going to be wrong, but it's a starting point.
|
Actually, @Omustardo, let's move the high level discussion into an issue. I've made #9 for it. |
Following discussion in goxjs/glfw#8
Start adding the Window API, with stubs for the browser
Move existing code for setting canvas size to SetSize(). Maintains existing behavior of filling the browser window by default.
I'm not sure how to test this besides running it with a demo.
It works for a tetris demo: https://github.com/Omustardo/tetris/tree/master/webgl-tetris