ok remake pt4
This commit is contained in:
36
Osmium.cpp
36
Osmium.cpp
@@ -13,9 +13,10 @@ int main(int argc, char **argv) {
|
|||||||
glfwInit();
|
glfwInit();
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
//glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
|
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
|
||||||
|
|
||||||
// make the window
|
// make the window
|
||||||
GLFWwindow *window = glfwCreateWindow(640, 480, "OpenGL Demo", NULL, NULL);
|
GLFWwindow *window = glfwCreateWindow(640, 480, "OpenGL Demo", NULL, NULL);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
@@ -63,31 +64,32 @@ int main(int argc, char **argv) {
|
|||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
ImGui::BeginMainMenuBar();
|
ImGui::BeginMainMenuBar();
|
||||||
|
bool is_hovered = ImGui::IsWindowHovered();
|
||||||
|
bool is_clicked = ImGui::IsMouseClicked(0);
|
||||||
|
bool is_held = ImGui::IsMouseDown(0);
|
||||||
|
|
||||||
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) {
|
if (is_hovered && is_clicked) {
|
||||||
dragging_window = true;
|
dragging_window = true;
|
||||||
|
|
||||||
|
// Get initial mouse and window positions
|
||||||
glfwGetCursorPos(window, &drag_start_mouse_x, &drag_start_mouse_y);
|
glfwGetCursorPos(window, &drag_start_mouse_x, &drag_start_mouse_y);
|
||||||
|
|
||||||
// Get window pos
|
|
||||||
glfwGetWindowPos(window, &drag_start_window_x, &drag_start_window_y);
|
glfwGetWindowPos(window, &drag_start_window_x, &drag_start_window_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dragging_window && ImGui::IsMouseDown(0)) {
|
if (dragging_window) {
|
||||||
double current_mouse_x, current_mouse_y;
|
if (is_held) {
|
||||||
glfwGetCursorPos(window, ¤t_mouse_x, ¤t_mouse_y);
|
double current_mouse_x, current_mouse_y;
|
||||||
|
glfwGetCursorPos(window, ¤t_mouse_x, ¤t_mouse_y);
|
||||||
|
|
||||||
|
double dx = current_mouse_x - drag_start_mouse_x;
|
||||||
|
double dy = current_mouse_y - drag_start_mouse_y;
|
||||||
|
|
||||||
double dx = current_mouse_x - drag_start_mouse_x;
|
glfwSetWindowPos(window,
|
||||||
double dy = current_mouse_y - drag_start_mouse_y;
|
drag_start_window_x + static_cast<int>(dx),
|
||||||
|
drag_start_window_y + static_cast<int>(dy));
|
||||||
// Move window
|
} else {
|
||||||
glfwSetWindowPos(window,
|
dragging_window = false;
|
||||||
drag_start_window_x + static_cast<int>(dx),
|
}
|
||||||
drag_start_window_y + static_cast<int>(dy));
|
|
||||||
} else {
|
|
||||||
dragging_window = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Menu items
|
// Menu items
|
||||||
|
|||||||
Reference in New Issue
Block a user