mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Merge branch 'master' into docking
This commit is contained in:
commit
43a85dd02e
@ -112,8 +112,11 @@ Other Changes:
|
|||||||
GL function loaders early, and help users understand what they are missing. (#2421)
|
GL function loaders early, and help users understand what they are missing. (#2421)
|
||||||
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
|
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
|
||||||
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
|
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
|
||||||
|
- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
|
||||||
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
|
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
|
||||||
- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
|
- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
|
||||||
|
- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
|
||||||
|
- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
@ -134,7 +134,7 @@ Languages: (third-party bindings)
|
|||||||
|
|
||||||
Frameworks:
|
Frameworks:
|
||||||
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
||||||
- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
||||||
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
||||||
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
|
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
|
||||||
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
|
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
|
||||||
|
1
examples/.gitignore
vendored
1
examples/.gitignore
vendored
@ -33,6 +33,7 @@ example_glfw_opengl2/example_glfw_opengl2
|
|||||||
example_glfw_opengl3/example_glfw_opengl3
|
example_glfw_opengl3/example_glfw_opengl3
|
||||||
example_sdl_opengl2/example_sdl_opengl2
|
example_sdl_opengl2/example_sdl_opengl2
|
||||||
example_sdl_opengl3/example_sdl_opengl3
|
example_sdl_opengl3/example_sdl_opengl3
|
||||||
|
example_glut_opengl2/example_glut_opengl2
|
||||||
|
|
||||||
## Dear ImGui Ini files
|
## Dear ImGui Ini files
|
||||||
imgui.ini
|
imgui.ini
|
||||||
|
@ -111,7 +111,7 @@ List of Platforms Bindings in this repository:
|
|||||||
imgui_impl_osx.mm ; macOS native API
|
imgui_impl_osx.mm ; macOS native API
|
||||||
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
||||||
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
||||||
imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
|
imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
|
||||||
|
|
||||||
List of Renderer Bindings in this repository:
|
List of Renderer Bindings in this repository:
|
||||||
|
|
||||||
@ -230,9 +230,9 @@ example_allegro5/
|
|||||||
Allegro 5 example.
|
Allegro 5 example.
|
||||||
= main.cpp + imgui_impl_allegro5.cpp
|
= main.cpp + imgui_impl_allegro5.cpp
|
||||||
|
|
||||||
example_freeglut_opengl2/
|
example_glut_opengl2/
|
||||||
FreeGLUT + OpenGL2.
|
GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
|
||||||
= main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
|
= main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
|
||||||
|
|
||||||
example_marmalade/
|
example_marmalade/
|
||||||
Marmalade example using IwGx.
|
Marmalade example using IwGx.
|
||||||
|
65
examples/example_glut_opengl2/Makefile
Normal file
65
examples/example_glut_opengl2/Makefile
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#
|
||||||
|
# Cross Platform Makefile
|
||||||
|
# Compatible with Ubuntu 14.04.1 and Mac OS X
|
||||||
|
#
|
||||||
|
# Linux:
|
||||||
|
# apt-get install freeglut3-dev
|
||||||
|
#
|
||||||
|
|
||||||
|
#CXX = g++
|
||||||
|
#CXX = clang++
|
||||||
|
|
||||||
|
EXE = example_glut_opengl2
|
||||||
|
SOURCES = main.cpp
|
||||||
|
SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
|
||||||
|
SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
|
||||||
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(UNAME_S), Linux) #LINUX
|
||||||
|
ECHO_MESSAGE = "Linux"
|
||||||
|
LIBS = -lGL -lglut
|
||||||
|
|
||||||
|
CXXFLAGS = -I ../ -I../..
|
||||||
|
CXXFLAGS += -Wall -Wformat
|
||||||
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(UNAME_S), Darwin) #APPLE
|
||||||
|
ECHO_MESSAGE = "Mac OS X"
|
||||||
|
LIBS = -framework OpenGL -framework GLUT
|
||||||
|
|
||||||
|
CXXFLAGS = -I .. -I../..
|
||||||
|
CXXFLAGS += -Wall -Wformat
|
||||||
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||||
|
ECHO_MESSAGE = "Windows"
|
||||||
|
LIBS = -lgdi32 -lopengl32 -limm32 -lglut
|
||||||
|
|
||||||
|
CXXFLAGS = -I ../ -I../../
|
||||||
|
CXXFLAGS += -Wall -Wformat
|
||||||
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
%.o:%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:../%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:../../%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
all: $(EXE)
|
||||||
|
@echo Build complete for $(ECHO_MESSAGE)
|
||||||
|
|
||||||
|
$(EXE): $(OBJS)
|
||||||
|
$(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(EXE) $(OBJS)
|
@ -20,7 +20,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{F90D0333-5FB1-440D-918D-DD39A1B5187E}</ProjectGuid>
|
<ProjectGuid>{F90D0333-5FB1-440D-918D-DD39A1B5187E}</ProjectGuid>
|
||||||
<RootNamespace>example_freeglut_opengl2</RootNamespace>
|
<RootNamespace>example_glut_opengl2</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
@ -154,7 +154,7 @@
|
|||||||
<ClCompile Include="..\..\imgui_demo.cpp" />
|
<ClCompile Include="..\..\imgui_demo.cpp" />
|
||||||
<ClCompile Include="..\..\imgui_draw.cpp" />
|
<ClCompile Include="..\..\imgui_draw.cpp" />
|
||||||
<ClCompile Include="..\..\imgui_widgets.cpp" />
|
<ClCompile Include="..\..\imgui_widgets.cpp" />
|
||||||
<ClCompile Include="..\imgui_impl_freeglut.cpp" />
|
<ClCompile Include="..\imgui_impl_glut.cpp" />
|
||||||
<ClCompile Include="..\imgui_impl_opengl2.cpp" />
|
<ClCompile Include="..\imgui_impl_opengl2.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -162,7 +162,7 @@
|
|||||||
<ClInclude Include="..\..\imconfig.h" />
|
<ClInclude Include="..\..\imconfig.h" />
|
||||||
<ClInclude Include="..\..\imgui.h" />
|
<ClInclude Include="..\..\imgui.h" />
|
||||||
<ClInclude Include="..\..\imgui_internal.h" />
|
<ClInclude Include="..\..\imgui_internal.h" />
|
||||||
<ClInclude Include="..\imgui_impl_freeglut.h" />
|
<ClInclude Include="..\imgui_impl_glut.h" />
|
||||||
<ClInclude Include="..\imgui_impl_opengl2.h" />
|
<ClInclude Include="..\imgui_impl_opengl2.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
@ -22,7 +22,7 @@
|
|||||||
<ClCompile Include="..\..\imgui_draw.cpp">
|
<ClCompile Include="..\..\imgui_draw.cpp">
|
||||||
<Filter>imgui</Filter>
|
<Filter>imgui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\imgui_impl_freeglut.cpp">
|
<ClCompile Include="..\imgui_impl_glut.cpp">
|
||||||
<Filter>sources</Filter>
|
<Filter>sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\imgui_impl_opengl2.cpp">
|
<ClCompile Include="..\imgui_impl_opengl2.cpp">
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<ClInclude Include="..\..\imgui_internal.h">
|
<ClInclude Include="..\..\imgui_internal.h">
|
||||||
<Filter>imgui</Filter>
|
<Filter>imgui</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\imgui_impl_freeglut.h">
|
<ClInclude Include="..\imgui_impl_glut.h">
|
||||||
<Filter>sources</Filter>
|
<Filter>sources</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\imgui_impl_opengl2.h">
|
<ClInclude Include="..\imgui_impl_opengl2.h">
|
@ -1,13 +1,17 @@
|
|||||||
// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
|
// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
|
||||||
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
|
||||||
// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
||||||
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "../imgui_impl_freeglut.h"
|
#include "../imgui_impl_glut.h"
|
||||||
#include "../imgui_impl_opengl2.h"
|
#include "../imgui_impl_opengl2.h"
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <GLUT/glut.h>
|
||||||
|
#else
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (disable: 4505) // unreferenced local function has been removed
|
#pragma warning (disable: 4505) // unreferenced local function has been removed
|
||||||
@ -61,7 +65,7 @@ void glut_display_func()
|
|||||||
{
|
{
|
||||||
// Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
ImGui_ImplOpenGL2_NewFrame();
|
ImGui_ImplOpenGL2_NewFrame();
|
||||||
ImGui_ImplFreeGLUT_NewFrame();
|
ImGui_ImplGLUT_NewFrame();
|
||||||
|
|
||||||
my_display_code();
|
my_display_code();
|
||||||
|
|
||||||
@ -87,14 +91,16 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
// Create GLUT window
|
// Create GLUT window
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
|
#ifdef __FREEGLUT_EXT_H__
|
||||||
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
|
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
|
||||||
|
#endif
|
||||||
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
|
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
|
||||||
glutInitWindowSize(1280, 720);
|
glutInitWindowSize(1280, 720);
|
||||||
glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
|
glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
|
||||||
|
|
||||||
// Setup GLUT display function
|
// Setup GLUT display function
|
||||||
// We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
|
// We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
|
||||||
// otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
|
// otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
|
||||||
glutDisplayFunc(glut_display_func);
|
glutDisplayFunc(glut_display_func);
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
@ -108,8 +114,8 @@ int main(int argc, char** argv)
|
|||||||
//ImGui::StyleColorsClassic();
|
//ImGui::StyleColorsClassic();
|
||||||
|
|
||||||
// Setup Platform/Renderer bindings
|
// Setup Platform/Renderer bindings
|
||||||
ImGui_ImplFreeGLUT_Init();
|
ImGui_ImplGLUT_Init();
|
||||||
ImGui_ImplFreeGLUT_InstallFuncs();
|
ImGui_ImplGLUT_InstallFuncs();
|
||||||
ImGui_ImplOpenGL2_Init();
|
ImGui_ImplOpenGL2_Init();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
@ -131,7 +137,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
ImGui_ImplOpenGL2_Shutdown();
|
ImGui_ImplOpenGL2_Shutdown();
|
||||||
ImGui_ImplFreeGLUT_Shutdown();
|
ImGui_ImplGLUT_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
@ -1,33 +0,0 @@
|
|||||||
// dear imgui: Platform Binding for FreeGLUT
|
|
||||||
// This needs to be used along with a Renderer (e.g. OpenGL2)
|
|
||||||
|
|
||||||
// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
|
||||||
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
|
||||||
|
|
||||||
// Issues:
|
|
||||||
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
|
||||||
// [ ] Platform: Missing clipboard support (not supported by Glut).
|
|
||||||
// [ ] Platform: Missing gamepad support.
|
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
|
||||||
// https://github.com/ocornut/imgui
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
|
|
||||||
|
|
||||||
// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
|
|
||||||
// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
|
|
||||||
//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
|
|
@ -1,7 +1,7 @@
|
|||||||
// dear imgui: Platform Binding for FreeGLUT
|
// dear imgui: Platform Binding for GLUT/FreeGLUT
|
||||||
// This needs to be used along with a Renderer (e.g. OpenGL2)
|
// This needs to be used along with a Renderer (e.g. OpenGL2)
|
||||||
|
|
||||||
// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
||||||
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
||||||
|
|
||||||
// Issues:
|
// Issues:
|
||||||
@ -15,13 +15,18 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
|
||||||
// 2019-03-25: Misc: Made io.DeltaTime always above zero.
|
// 2019-03-25: Misc: Made io.DeltaTime always above zero.
|
||||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||||
// 2018-03-22: Added FreeGLUT Platform binding.
|
// 2018-03-22: Added GLUT Platform binding.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_freeglut.h"
|
#include "imgui_impl_glut.h"
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <GLUT/glut.h>
|
||||||
|
#else
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
||||||
@ -29,10 +34,10 @@
|
|||||||
|
|
||||||
static int g_Time = 0; // Current time, in milliseconds
|
static int g_Time = 0; // Current time, in milliseconds
|
||||||
|
|
||||||
bool ImGui_ImplFreeGLUT_Init()
|
bool ImGui_ImplGLUT_Init()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendPlatformName ="imgui_impl_freeglut";
|
io.BackendPlatformName ="imgui_impl_glut";
|
||||||
|
|
||||||
g_Time = 0;
|
g_Time = 0;
|
||||||
|
|
||||||
@ -62,24 +67,26 @@ bool ImGui_ImplFreeGLUT_Init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_InstallFuncs()
|
void ImGui_ImplGLUT_InstallFuncs()
|
||||||
{
|
{
|
||||||
glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
|
glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc);
|
||||||
glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
|
glutMotionFunc(ImGui_ImplGLUT_MotionFunc);
|
||||||
glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
|
glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc);
|
||||||
glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
|
glutMouseFunc(ImGui_ImplGLUT_MouseFunc);
|
||||||
glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
|
#ifdef __FREEGLUT_EXT_H__
|
||||||
glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
|
glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc);
|
||||||
glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
|
#endif
|
||||||
glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
|
glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc);
|
||||||
glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
|
glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc);
|
||||||
|
glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc);
|
||||||
|
glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_Shutdown()
|
void ImGui_ImplGLUT_Shutdown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_NewFrame()
|
void ImGui_ImplGLUT_NewFrame()
|
||||||
{
|
{
|
||||||
// Setup time step
|
// Setup time step
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -94,7 +101,7 @@ void ImGui_ImplFreeGLUT_NewFrame()
|
|||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
|
static void ImGui_ImplGLUT_UpdateKeyboardMods()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
int mods = glutGetModifiers();
|
int mods = glutGetModifiers();
|
||||||
@ -103,7 +110,7 @@ static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
|
|||||||
io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
|
io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
|
void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
|
||||||
{
|
{
|
||||||
// Send character to imgui
|
// Send character to imgui
|
||||||
//printf("char_down_func %d '%c'\n", c, c);
|
//printf("char_down_func %d '%c'\n", c, c);
|
||||||
@ -121,11 +128,11 @@ void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
|
|||||||
io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
|
io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
|
||||||
else
|
else
|
||||||
io.KeysDown[c] = true;
|
io.KeysDown[c] = true;
|
||||||
ImGui_ImplFreeGLUT_UpdateKeyboardMods();
|
ImGui_ImplGLUT_UpdateKeyboardMods();
|
||||||
(void)x; (void)y; // Unused
|
(void)x; (void)y; // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
|
void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
|
||||||
{
|
{
|
||||||
//printf("char_up_func %d '%c'\n", c, c);
|
//printf("char_up_func %d '%c'\n", c, c);
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -137,31 +144,31 @@ void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
|
|||||||
io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
|
io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
|
||||||
else
|
else
|
||||||
io.KeysDown[c] = false;
|
io.KeysDown[c] = false;
|
||||||
ImGui_ImplFreeGLUT_UpdateKeyboardMods();
|
ImGui_ImplGLUT_UpdateKeyboardMods();
|
||||||
(void)x; (void)y; // Unused
|
(void)x; (void)y; // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
|
void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
|
||||||
{
|
{
|
||||||
//printf("key_down_func %d\n", key);
|
//printf("key_down_func %d\n", key);
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
|
if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
|
||||||
io.KeysDown[key + 256] = true;
|
io.KeysDown[key + 256] = true;
|
||||||
ImGui_ImplFreeGLUT_UpdateKeyboardMods();
|
ImGui_ImplGLUT_UpdateKeyboardMods();
|
||||||
(void)x; (void)y; // Unused
|
(void)x; (void)y; // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
|
void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
|
||||||
{
|
{
|
||||||
//printf("key_up_func %d\n", key);
|
//printf("key_up_func %d\n", key);
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
|
if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
|
||||||
io.KeysDown[key + 256] = false;
|
io.KeysDown[key + 256] = false;
|
||||||
ImGui_ImplFreeGLUT_UpdateKeyboardMods();
|
ImGui_ImplGLUT_UpdateKeyboardMods();
|
||||||
(void)x; (void)y; // Unused
|
(void)x; (void)y; // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
|
void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.MousePos = ImVec2((float)x, (float)y);
|
io.MousePos = ImVec2((float)x, (float)y);
|
||||||
@ -175,7 +182,8 @@ void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
|
|||||||
io.MouseDown[button] = false;
|
io.MouseDown[button] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
|
#ifdef __FREEGLUT_EXT_H__
|
||||||
|
void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.MousePos = ImVec2((float)x, (float)y);
|
io.MousePos = ImVec2((float)x, (float)y);
|
||||||
@ -185,14 +193,15 @@ void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
|
|||||||
io.MouseWheel -= 1.0;
|
io.MouseWheel -= 1.0;
|
||||||
(void)button; // Unused
|
(void)button; // Unused
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
|
void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
|
void ImGui_ImplGLUT_MotionFunc(int x, int y)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.MousePos = ImVec2((float)x, (float)y);
|
io.MousePos = ImVec2((float)x, (float)y);
|
33
examples/imgui_impl_glut.h
Normal file
33
examples/imgui_impl_glut.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// dear imgui: Platform Binding for GLUT/FreeGLUT
|
||||||
|
// This needs to be used along with a Renderer (e.g. OpenGL2)
|
||||||
|
|
||||||
|
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
||||||
|
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
||||||
|
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
||||||
|
// [ ] Platform: Missing clipboard support (not supported by Glut).
|
||||||
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
// https://github.com/ocornut/imgui
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
|
||||||
|
|
||||||
|
// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
|
||||||
|
// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
|
||||||
|
//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
|
@ -20,7 +20,7 @@
|
|||||||
#include "imgui_impl_metal.h"
|
#include "imgui_impl_metal.h"
|
||||||
|
|
||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
// #import <QuartzCore/CAMetalLayer.h> // Not suported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
|
// #import <QuartzCore/CAMetalLayer.h> // Not supported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
|
||||||
#import <simd/simd.h>
|
#import <simd/simd.h>
|
||||||
|
|
||||||
#pragma mark - Support classes
|
#pragma mark - Support classes
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-04-04: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
|
||||||
// 2019-04-01: Vulkan: Support for 32-bit index buffer (#define ImDrawIdx unsigned int).
|
// 2019-04-01: Vulkan: Support for 32-bit index buffer (#define ImDrawIdx unsigned int).
|
||||||
// 2019-02-16: Vulkan: Viewport and clipping rectangles correctly using draw_data->FramebufferScale to allow retina display.
|
// 2019-02-16: Vulkan: Viewport and clipping rectangles correctly using draw_data->FramebufferScale to allow retina display.
|
||||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||||
@ -81,6 +82,23 @@ static void ImGui_ImplVulkan_ShutdownPlatformInterface();
|
|||||||
|
|
||||||
// glsl_shader.vert, compiled with:
|
// glsl_shader.vert, compiled with:
|
||||||
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
|
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
|
||||||
|
/*
|
||||||
|
#version 450 core
|
||||||
|
layout(location = 0) in vec2 aPos;
|
||||||
|
layout(location = 1) in vec2 aUV;
|
||||||
|
layout(location = 2) in vec4 aColor;
|
||||||
|
layout(push_constant) uniform uPushConstant { vec2 uScale; vec2 uTranslate; } pc;
|
||||||
|
|
||||||
|
out gl_PerVertex { vec4 gl_Position; };
|
||||||
|
layout(location = 0) out struct { vec4 Color; vec2 UV; } Out;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Out.Color = aColor;
|
||||||
|
Out.UV = aUV;
|
||||||
|
gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
|
||||||
|
}
|
||||||
|
*/
|
||||||
static uint32_t __glsl_shader_vert_spv[] =
|
static uint32_t __glsl_shader_vert_spv[] =
|
||||||
{
|
{
|
||||||
0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
@ -128,6 +146,16 @@ static uint32_t __glsl_shader_vert_spv[] =
|
|||||||
|
|
||||||
// glsl_shader.frag, compiled with:
|
// glsl_shader.frag, compiled with:
|
||||||
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
|
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
|
||||||
|
/*
|
||||||
|
#version 450 core
|
||||||
|
layout(location = 0) out vec4 fColor;
|
||||||
|
layout(set=0, binding=0) uniform sampler2D sTexture;
|
||||||
|
layout(location = 0) in struct { vec4 Color; vec2 UV; } In;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fColor = In.Color * texture(sTexture, In.UV.st);
|
||||||
|
}
|
||||||
|
*/
|
||||||
static uint32_t __glsl_shader_frag_spv[] =
|
static uint32_t __glsl_shader_frag_spv[] =
|
||||||
{
|
{
|
||||||
0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
@ -325,6 +353,12 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
|
|
||||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||||
{
|
{
|
||||||
|
// Negative offsets are illegal for vkCmdSetScissor
|
||||||
|
if (clip_rect.x < 0.0f)
|
||||||
|
clip_rect.x = 0.0f;
|
||||||
|
if (clip_rect.y < 0.0f)
|
||||||
|
clip_rect.y = 0.0f;
|
||||||
|
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
VkRect2D scissor;
|
VkRect2D scissor;
|
||||||
scissor.offset.x = (int32_t)(clip_rect.x);
|
scissor.offset.x = (int32_t)(clip_rect.x);
|
||||||
|
@ -47,6 +47,7 @@ IMGUI_IMPL_API void ImGui_ImplVulkan_InvalidateDeviceObjects();
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal / Miscellaneous Vulkan Helpers
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
|
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// You probably do NOT need to use or care about those functions.
|
// You probably do NOT need to use or care about those functions.
|
||||||
// Those functions only exist because:
|
// Those functions only exist because:
|
||||||
@ -70,6 +71,7 @@ IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysic
|
|||||||
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
|
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
|
||||||
|
|
||||||
// Helper structure to hold the data needed by one rendering frame
|
// Helper structure to hold the data needed by one rendering frame
|
||||||
|
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
|
||||||
struct ImGui_ImplVulkanH_FrameData
|
struct ImGui_ImplVulkanH_FrameData
|
||||||
{
|
{
|
||||||
uint32_t BackbufferIndex; // Keep track of recently rendered swapchain frame indices
|
uint32_t BackbufferIndex; // Keep track of recently rendered swapchain frame indices
|
||||||
@ -83,6 +85,7 @@ struct ImGui_ImplVulkanH_FrameData
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Helper structure to hold the data needed by one rendering context into one OS window
|
// Helper structure to hold the data needed by one rendering context into one OS window
|
||||||
|
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
|
||||||
struct ImGui_ImplVulkanH_WindowData
|
struct ImGui_ImplVulkanH_WindowData
|
||||||
{
|
{
|
||||||
int Width;
|
int Width;
|
||||||
|
Loading…
Reference in New Issue
Block a user