-
Notifications
You must be signed in to change notification settings - Fork 3
Multiple Windows? #9
Comments
it's a definite maybe, leaning on probably. just a matter of defining a good API, and knowing where the side effects would be. |
You dont need a new API... use the Thread API which currently doesnt support graphics... you also have the window namespace, and most of the graphics functions there so I guess this wouldnt be so hard |
the thread API wouldn't be any good (and you do /not/ want to deal with different windows in different threads). you'd really just want a way to mark a window/GL context as active and some window-specific management functions. @LPGhatguy probably has some input on this! |
I think it's straightforward enough to have multiple windows with SDL2, especially if the API provides a single method to switch across contexts/windows. The big thing might be requiring a reference to the window from every asset, which would end up at most an identifying integer or pointer. |
I made some plans on how such an api could look. I'll try to describe how it would work. -- First there is this function. It creates a new window
function window.newWindow(title, x, y, width, height, flags)
-- This returns a table, which I'll describe a bit down the line
end
function window.closeWindow(window)
-- This function will close the window given as argument
end
function window.setActiveWindow(window)
-- This function will set the active window to the window in the arguments
-- It ill also set the drawing context to this window
end
These functions would only work when something like multiwindow in the conf.lua is true. Next is the window table, that gets returned when a new window gets created. It has many functions on its own. window:setTitle(title) -- Sets the title of the window
window:getTitle() -- Returns the title of the window
window:setPosition(x, y) -- Sets the window position
window:getPosition() -- Returns the window position
window:setSize(width, height) -- Sets the window size
window:getSize() -- Returns the window size
window:setFocus(true/false) -- Sets the windows focus
window:hasFocus() -- Returns the windows focus
window:getID() -- Returns the window ID
window:get/setVisible() -- Gets/sets the windows visibility
window:minimize() -- Minimizes the window
window:maximize() -- Maximizes the window
window:setOnlyActiveWithFocus(true/false) -- This function defines if any events other than the
-- focus event should get raised when the window is not active
window:getOnlyActiveWithFocus() -- Returns if any other events should get raised
-- Note: Any other functions in the Love2D window api that i forgot
-- will also be available for this table
window:draw() -- This is a callback for this window. It will be called before hate.draw().
-- It could be used to have split up draw functions and that you don't have to change
-- the active window everytime in hate.draw(). The function will set the active window
-- to the window of the table, draw onit, and set the active window back to the window before. Any other hate callbacks (such as mousefocus, keypressed and such) will have the window the event happened as the last argument after the normal arguments, so it doesn't break the compatibility with love. This can be used when two windows are 'active' and you want to know which of them called for example hate.mousepressed() If you have any other ideas, or if i forgot something, please tell me. If this proposal gets adopted, I would like to write it in the next few days. |
I would like to know if you have any plans to suport multiple windows?
The text was updated successfully, but these errors were encountered: