Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gauthier Quesnel
irritator
Commits
22b96576
Commit
22b96576
authored
Jun 07, 2021
by
Gauthier Quesnel
Browse files
unix: fix gui main function
parent
0ae07d60
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/gui/main-unix.cpp
View file @
22b96576
...
@@ -2,12 +2,13 @@
...
@@ -2,12 +2,13 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
#include "
imgui.h
"
#include "
application.hpp
"
#include "imnodes.hpp"
#include "imnodes.hpp"
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include "imgui_impl_opengl3.h"
#include "imnodes.hpp"
#include "gui.hpp"
#include <cstdio>
#include <cstdio>
#include <cstring>
#include <cstring>
...
@@ -36,7 +37,7 @@
...
@@ -36,7 +37,7 @@
// legacy_stdio_definitions.lib, which we do using this pragma. Your own
// legacy_stdio_definitions.lib, which we do using this pragma. Your own
// project should not be affected, as you are likely to link with a newer
// project should not be affected, as you are likely to link with a newer
// binary of GLFW that is adequate for your version of Visual Studio.
// binary of GLFW that is adequate for your version of Visual Studio.
#if defined(_MSC_VER) && (_MSC_VER >= 1900) && \
#if defined(_MSC_VER) && (_MSC_VER >= 1900) &&
\
!defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
!defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
#pragma comment(lib, "legacy_stdio_definitions")
#pragma comment(lib, "legacy_stdio_definitions")
#endif
#endif
...
@@ -79,8 +80,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
...
@@ -79,8 +80,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
#endif
#endif
// Create window with graphics context
// Create window with graphics context
GLFWwindow
*
window
=
glfwCreateWindow
(
GLFWwindow
*
window
=
glfwCreateWindow
(
1280
,
720
,
"irritator"
,
NULL
,
NULL
);
1280
,
720
,
"irritator"
,
NULL
,
NULL
);
if
(
window
==
NULL
)
if
(
window
==
NULL
)
return
1
;
return
1
;
glfwMakeContextCurrent
(
window
);
glfwMakeContextCurrent
(
window
);
...
@@ -94,9 +94,8 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
...
@@ -94,9 +94,8 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
bool
err
=
gladLoadGL
()
==
0
;
bool
err
=
gladLoadGL
()
==
0
;
#else
#else
bool
err
=
bool
err
=
false
;
// If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader
false
;
// If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader
// is likely to requires some form of initialization.
// is likely to requires some form of initialization.
#endif
#endif
if
(
err
)
{
if
(
err
)
{
fprintf
(
stderr
,
"Failed to initialize OpenGL loader!
\n
"
);
fprintf
(
stderr
,
"Failed to initialize OpenGL loader!
\n
"
);
...
@@ -120,7 +119,18 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
...
@@ -120,7 +119,18 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
ImGui_ImplGlfw_InitForOpenGL
(
window
,
true
);
ImGui_ImplGlfw_InitForOpenGL
(
window
,
true
);
ImGui_ImplOpenGL3_Init
(
glsl_version
);
ImGui_ImplOpenGL3_Init
(
glsl_version
);
imnodes
::
CreateContext
();
imnodes
::
CreateContext
();
irt
::
application_initialize
();
irt
::
application
app
;
if
(
!
app
.
init
())
{
imnodes
::
DestroyContext
();
ImGui_ImplOpenGL3_Shutdown
();
ImGui_ImplGlfw_Shutdown
();
ImGui
::
DestroyContext
();
glfwDestroyWindow
(
window
);
glfwTerminate
();
}
// Load Fonts
// Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can
// - If no fonts are loaded, dear imgui will use the default font. You can
...
@@ -147,8 +157,8 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
...
@@ -147,8 +157,8 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
// io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f,
// io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f,
// NULL, io.Fonts->GetGlyphRangesJapanese()); IM_ASSERT(font != NULL);
// NULL, io.Fonts->GetGlyphRangesJapanese()); IM_ASSERT(font != NULL);
//bool show_demo_window = true;
//
bool show_demo_window = true;
//bool show_another_window = false;
//
bool show_another_window = false;
ImVec4
clear_color
=
ImVec4
(
0.45
f
,
0.55
f
,
0.60
f
,
1.00
f
);
ImVec4
clear_color
=
ImVec4
(
0.45
f
,
0.55
f
,
0.60
f
,
1.00
f
);
// Main loop
// Main loop
...
@@ -169,7 +179,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
...
@@ -169,7 +179,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
ImGui_ImplGlfw_NewFrame
();
ImGui_ImplGlfw_NewFrame
();
ImGui
::
NewFrame
();
ImGui
::
NewFrame
();
if
(
!
irt
::
application_
show
())
if
(
!
app
.
show
())
glfwSetWindowShouldClose
(
window
,
GLFW_TRUE
);
glfwSetWindowShouldClose
(
window
,
GLFW_TRUE
);
// Rendering
// Rendering
...
@@ -189,7 +199,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
...
@@ -189,7 +199,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
// Cleanup
// Cleanup
irt
::
application_
shutdown
();
app
.
shutdown
();
imnodes
::
DestroyContext
();
imnodes
::
DestroyContext
();
ImGui_ImplOpenGL3_Shutdown
();
ImGui_ImplOpenGL3_Shutdown
();
...
@@ -201,4 +211,3 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
...
@@ -201,4 +211,3 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
return
0
;
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment