-
Notifications
You must be signed in to change notification settings - Fork 0
Window
LibGui::Window is a wrapper for GLFWwindow*, there are two ways to initialize it:
This is the first window you create using the Init() method, it's also default window for all Objects (and other classes).
// initialize library| name of window | size of window
LibGui::Window MyInitializationWindow(LibGui::Init(), "My Initialization window",{600, 400});All windows after creation of Initialization window should be made this way.
// name of window | size of window
LibGui::Window MyNormalWindow("My normal window", {600, 400});| Type | Property | Description |
|---|---|---|
MouseCursor |
cursor |
handles mouse input for this window |
KeyTracker |
key_tracker |
tracks key states for some keys; more here/KeyTracker |
Color |
background_color |
specifies background color of this window |
float |
transparency |
transparency of whole window (including rendered content) |
bool |
CanAutoClose |
can window automatically close once user pressed [X]? |
Vec2i |
size |
[READ-ONLY] ...current size of this window |
Sets window's name to name.
Quick way to know is given key is pressed. (for more click and release properties see KeyTracker)
Examples
MyWindow.GetKeyPressed('w'); // is key W pressed?
MyWindow.GetKeyPressed(LibGui::FunctionalKey_RightShift); // is right shift pressed?Returns content in user's clipboard.
Sets user's clipboard to text.
Tells program to now render on this window, it also updates the window (input handling, window movement).
Example
while (true)
{
// start rendering here
MyWindow.Draw();
// render our beloved square [reference to Getting started]
MySquare.Render();
// now he has friend
MyAnotherSquare.Render();
// push render to screen (for another rendering you have to call MyWindow.Draw(); again)
MyWindow.PushDraw();
}Tells program to send our since-last-Draw() rendered stuff to screen.
For example see Draw() example. (I don't want to just copy the code)
If user pressed [X] button (or on other events such as Close() call), returns true, else it returns false.
Example
while (!MyWindow.ShouldClose())
{
std::cout << "I'm alive!\n";
}
std::cout << "I... was sadly closed :( \n";
std::cin.get();Closes the window, next ShouldClose() call will return true. Example
MyWindow.Close(int flags);Updates init flags to new flags. See more here
Set window icon to LibGui::Image 'img'; 'clamp' the icon must be square, so should cut or squeeze 'img' to fit.
LibGui::Image MyTurtleImage("square_turtle_logo.png");
MyWindow.SetIcon(MyTurtleImage);Returns literal screenshot of last render. transparent means if transparent parts of that render will remain transparent (this includes final image not having window background).
Example
LibGui::Image MyScreenshot = MyWindow.Screenshot();Binds current window. You probably won't need this. It's wrapper for glfwMakeContextCurrent()
Returns glfw window pointer.
At window creation, you can tell it how to behave by setting WIF (window init flags). To create them you just or together stuff from WindowInitFlag_ enum.
LibGui::MyUnresizableWindow("window", {200, 100}, LibGui::WindowInitFlag_CantBeResized);The Init() function must (along other stuff), initialize two OpenGL libraries, one of them is called glad. But to initialize glad you have to already have created a window, I solve this by making this window, initializing glad and then passing this GLFWwindow* to user, who has to, to have access to this window, create it with this dumb syntax:
LibGui::Window MyInitializationWindow(LibGui::Init(), "My Initialization window", {600, 400});Features