Switched to imgui fork https://github.com/thedmd/imgui/commits/feature/docking-layout-external/ commit 899d85eb9489796f73a4dc67ad86892729707ce9
This commit is contained in:
+27
-41
@@ -5,6 +5,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "backends/imgui_impl_glfw.h"
|
||||
#include "backends/imgui_impl_opengl3.h"
|
||||
#include "imgui.h"
|
||||
#include "imnodes.h"
|
||||
#define SOKOL_IMPL
|
||||
@@ -438,22 +439,23 @@ void sokol_logger(
|
||||
int main() {
|
||||
// window and GL context via GLFW and flextGL
|
||||
glfwInit();
|
||||
const char* glsl_version = "#version 130";
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_SAMPLES, cMSAASampleCount);
|
||||
GLFWwindow* w =
|
||||
GLFWwindow* window =
|
||||
glfwCreateWindow(Width, Height, "ATP Editor", nullptr, nullptr);
|
||||
glfwMakeContextCurrent(w);
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
load_application_config("animtestbed_config.json");
|
||||
if (gApplicationConfig.window_position[0] != 0
|
||||
|| gApplicationConfig.window_position[1] != 0) {
|
||||
glfwSetWindowPos(
|
||||
w,
|
||||
window,
|
||||
gApplicationConfig.window_position[0],
|
||||
gApplicationConfig.window_position[1]);
|
||||
}
|
||||
@@ -461,30 +463,11 @@ int main() {
|
||||
if (gApplicationConfig.window_size[0] != 0
|
||||
|| gApplicationConfig.window_size[1] != 0) {
|
||||
glfwSetWindowSize(
|
||||
w,
|
||||
window,
|
||||
gApplicationConfig.window_size[0],
|
||||
gApplicationConfig.window_size[1]);
|
||||
}
|
||||
|
||||
// GLFW to ImGui input forwarding
|
||||
glfwSetMouseButtonCallback(
|
||||
w,
|
||||
[](GLFWwindow*, int btn, int action, int /*mods*/) {
|
||||
if ((btn >= 0) && (btn < 3)) {
|
||||
ImGui::GetIO().MouseDown[btn] = (action == GLFW_PRESS);
|
||||
}
|
||||
});
|
||||
glfwSetCursorPosCallback(w, [](GLFWwindow*, double pos_x, double pos_y) {
|
||||
ImGui::GetIO().MousePos.x = float(pos_x);
|
||||
ImGui::GetIO().MousePos.y = float(pos_y);
|
||||
});
|
||||
glfwSetScrollCallback(w, [](GLFWwindow*, double /*pos_x*/, double pos_y) {
|
||||
ImGui::GetIO().MouseWheel = float(pos_y);
|
||||
});
|
||||
|
||||
glfwSetKeyCallback(w, ImGui_ImplGlfw_KeyCallback);
|
||||
glfwSetCharCallback(w, ImGui_ImplGlfw_CharCallback);
|
||||
|
||||
// setup sokol_gfx and sokol_time
|
||||
stm_setup();
|
||||
sg_desc desc = {
|
||||
@@ -541,6 +524,9 @@ int main() {
|
||||
14,
|
||||
&font_config);
|
||||
|
||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
|
||||
// ImNodes
|
||||
ImNodes::CreateContext();
|
||||
|
||||
@@ -633,7 +619,7 @@ int main() {
|
||||
ax::NodeEditor::CreateEditor(&gApplicationConfig.graph_editor.config);
|
||||
|
||||
// draw loop
|
||||
while (!glfwWindowShouldClose(w)) {
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
// Update time
|
||||
state.time.frame = stm_sec(
|
||||
stm_round_to_common_refresh_rate(stm_laptime(&state.time.laptime)));
|
||||
@@ -652,17 +638,17 @@ int main() {
|
||||
|
||||
// Update window state
|
||||
glfwGetWindowPos(
|
||||
w,
|
||||
window,
|
||||
&gApplicationConfig.window_position[0],
|
||||
&gApplicationConfig.window_position[1]);
|
||||
|
||||
glfwGetWindowSize(
|
||||
w,
|
||||
window,
|
||||
&gApplicationConfig.window_size[0],
|
||||
&gApplicationConfig.window_size[1]);
|
||||
|
||||
int cur_width, cur_height;
|
||||
glfwGetFramebufferSize(w, &cur_width, &cur_height);
|
||||
glfwGetFramebufferSize(window, &cur_width, &cur_height);
|
||||
|
||||
// this is standard ImGui demo code
|
||||
io.DisplaySize = ImVec2(float(cur_width), float(cur_height));
|
||||
@@ -670,11 +656,11 @@ int main() {
|
||||
ImGui::NewFrame();
|
||||
|
||||
// handle input
|
||||
handle_mouse(w, &gGuiInputState);
|
||||
handle_mouse(window, &gGuiInputState);
|
||||
|
||||
if (!glfwGetMouseButton(w, GLFW_MOUSE_BUTTON_RIGHT)) {
|
||||
if (!glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT)) {
|
||||
gControlMode = ControlMode::ControlModeNone;
|
||||
glfwSetInputMode(w, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
Camera_Update(
|
||||
&state.camera,
|
||||
offscreen_viewport.size[0],
|
||||
@@ -689,28 +675,28 @@ int main() {
|
||||
float camera_accel[3] = {0.f, 0.f, 0.f};
|
||||
float accel_scale = 100.0;
|
||||
|
||||
if (glfwGetKey(w, GLFW_KEY_LEFT_SHIFT)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT)) {
|
||||
accel_scale *= 3.;
|
||||
} else if (glfwGetKey(w, GLFW_KEY_LEFT_CONTROL)) {
|
||||
} else if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL)) {
|
||||
accel_scale /= 3.;
|
||||
}
|
||||
|
||||
if (glfwGetKey(w, GLFW_KEY_W)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_W)) {
|
||||
camera_accel[0] -= accel_scale;
|
||||
}
|
||||
if (glfwGetKey(w, GLFW_KEY_S)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_S)) {
|
||||
camera_accel[0] += accel_scale;
|
||||
}
|
||||
if (glfwGetKey(w, GLFW_KEY_C)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_C)) {
|
||||
camera_accel[1] -= accel_scale;
|
||||
}
|
||||
if (glfwGetKey(w, GLFW_KEY_SPACE)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_SPACE)) {
|
||||
camera_accel[1] += accel_scale;
|
||||
}
|
||||
if (glfwGetKey(w, GLFW_KEY_A)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_A)) {
|
||||
camera_accel[2] -= accel_scale;
|
||||
}
|
||||
if (glfwGetKey(w, GLFW_KEY_D)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_D)) {
|
||||
camera_accel[2] += accel_scale;
|
||||
}
|
||||
|
||||
@@ -729,7 +715,7 @@ int main() {
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
if (ImGui::BeginMenu("File")) {
|
||||
if (ImGui::MenuItem("Quit")) {
|
||||
glfwSetWindowShouldClose(w, true);
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
@@ -804,7 +790,7 @@ int main() {
|
||||
if (gControlMode == ControlMode::ControlModeNone) {
|
||||
gControlMode = ControlMode::ControlModeFPS;
|
||||
Camera_CalcFromMatrix(&state.camera, &state.camera.mtxView[0]);
|
||||
glfwSetInputMode(w, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1068,7 +1054,7 @@ int main() {
|
||||
sg_end_pass();
|
||||
|
||||
sg_commit();
|
||||
glfwSwapBuffers(w);
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user