add window icon

This commit is contained in:
MihailRis
2024-07-28 23:47:49 +03:00
parent c0ba5be458
commit b021339a8a
4 changed files with 31 additions and 5 deletions
+11 -2
View File
@@ -323,13 +323,13 @@ bool Window::isFullscreen() {
}
void Window::swapBuffers() {
glfwSwapBuffers(window);
Window::resetScissor();
double currentTime = time();
if (framerate > 0 && currentTime - prevSwap < (1.0 / framerate)) {
std::this_thread::sleep_for(std::chrono::milliseconds(
static_cast<int>((1.0/framerate - (currentTime-prevSwap))*1000)));
}
glfwSwapBuffers(window);
Window::resetScissor();
prevSwap = time();
}
@@ -375,3 +375,12 @@ bool Window::tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor) {
workArea.y + (workArea.w - Window::height) / 2 + windowFrame.y / 2);
return false;
}
void Window::setIcon(const ImageData* image) {
GLFWimage icon {
static_cast<int>(image->getWidth()),
static_cast<int>(image->getHeight()),
image->getData()
};
glfwSetWindowIcon(window, 1, &icon);
}