diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile
deleted file mode 100644
index 91d1b14..0000000
--- a/examples/opengl_example/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with Ubuntu 14.04.1 and Mac OS X
-#
-#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
-#
-
-#CXX = g++
-
-EXE = opengl_example
-OBJS = main.o imgui_impl_glfw.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- LIBS += -L/usr/local/lib -lglfw3
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
-# CXXFLAGS += -D__APPLE__
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), MINGW64_NT-6.3)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile
deleted file mode 100644
index 91d1b14..0000000
--- a/examples/opengl_example/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with Ubuntu 14.04.1 and Mac OS X
-#
-#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
-#
-
-#CXX = g++
-
-EXE = opengl_example
-OBJS = main.o imgui_impl_glfw.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- LIBS += -L/usr/local/lib -lglfw3
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
-# CXXFLAGS += -D__APPLE__
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), MINGW64_NT-6.3)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/examples/opengl_example/build_win32.bat b/examples/opengl_example/build_win32.bat
deleted file mode 100644
index 278381c..0000000
--- a/examples/opengl_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile
deleted file mode 100644
index 91d1b14..0000000
--- a/examples/opengl_example/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with Ubuntu 14.04.1 and Mac OS X
-#
-#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
-#
-
-#CXX = g++
-
-EXE = opengl_example
-OBJS = main.o imgui_impl_glfw.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- LIBS += -L/usr/local/lib -lglfw3
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
-# CXXFLAGS += -D__APPLE__
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), MINGW64_NT-6.3)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/examples/opengl_example/build_win32.bat b/examples/opengl_example/build_win32.bat
deleted file mode 100644
index 278381c..0000000
--- a/examples/opengl_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp
deleted file mode 100644
index 2d1f5c1..0000000
--- a/examples/opengl_example/imgui_impl_glfw.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#include
-#include "imgui_impl_glfw.h"
-
-// GLFW
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// Data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MousePressed[3] = { false, false, false };
-static float g_MouseWheel = 0.0f;
-static GLuint g_FontTexture = 0;
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// If text or lines are blurry when integrating ImGui in your engine:
-// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // We are using the OpenGL fixed pipeline to make the example code simpler to read!
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Render command lists
- #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos)));
- glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
- #undef OFFSETOF
-
- // Restore modified state
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glPopAttrib();
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
-}
-
-static const char* ImGui_ImplGlfw_GetClipboardText()
-{
- return glfwGetClipboardString(g_Window);
-}
-
-static void ImGui_ImplGlfw_SetClipboardText(const char* text)
-{
- glfwSetClipboardString(g_Window, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MousePressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
-{
- g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
-}
-
-void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfw_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-void ImGui_ImplGlfw_InvalidateDeviceObjects()
-{
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
-{
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
- io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
- }
-
- return true;
-}
-
-void ImGui_ImplGlfw_Shutdown()
-{
- ImGui_ImplGlfw_InvalidateDeviceObjects();
- ImGui::Shutdown();
-}
-
-void ImGui_ImplGlfw_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplGlfw_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
- }
- else
- {
- io.MousePos = ImVec2(-1,-1);
- }
-
- for (int i = 0; i < 3; i++)
- {
- io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- g_MousePressed[i] = false;
- }
-
- io.MouseWheel = g_MouseWheel;
- g_MouseWheel = 0.0f;
-
- // Hide OS mouse cursor if ImGui is drawing it
- glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
-
- // Start the frame
- ImGui::NewFrame();
-}
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile
deleted file mode 100644
index 91d1b14..0000000
--- a/examples/opengl_example/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with Ubuntu 14.04.1 and Mac OS X
-#
-#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
-#
-
-#CXX = g++
-
-EXE = opengl_example
-OBJS = main.o imgui_impl_glfw.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- LIBS += -L/usr/local/lib -lglfw3
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
-# CXXFLAGS += -D__APPLE__
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), MINGW64_NT-6.3)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/examples/opengl_example/build_win32.bat b/examples/opengl_example/build_win32.bat
deleted file mode 100644
index 278381c..0000000
--- a/examples/opengl_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp
deleted file mode 100644
index 2d1f5c1..0000000
--- a/examples/opengl_example/imgui_impl_glfw.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#include
-#include "imgui_impl_glfw.h"
-
-// GLFW
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// Data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MousePressed[3] = { false, false, false };
-static float g_MouseWheel = 0.0f;
-static GLuint g_FontTexture = 0;
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// If text or lines are blurry when integrating ImGui in your engine:
-// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // We are using the OpenGL fixed pipeline to make the example code simpler to read!
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Render command lists
- #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos)));
- glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
- #undef OFFSETOF
-
- // Restore modified state
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glPopAttrib();
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
-}
-
-static const char* ImGui_ImplGlfw_GetClipboardText()
-{
- return glfwGetClipboardString(g_Window);
-}
-
-static void ImGui_ImplGlfw_SetClipboardText(const char* text)
-{
- glfwSetClipboardString(g_Window, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MousePressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
-{
- g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
-}
-
-void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfw_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-void ImGui_ImplGlfw_InvalidateDeviceObjects()
-{
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
-{
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
- io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
- }
-
- return true;
-}
-
-void ImGui_ImplGlfw_Shutdown()
-{
- ImGui_ImplGlfw_InvalidateDeviceObjects();
- ImGui::Shutdown();
-}
-
-void ImGui_ImplGlfw_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplGlfw_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
- }
- else
- {
- io.MousePos = ImVec2(-1,-1);
- }
-
- for (int i = 0; i < 3; i++)
- {
- io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- g_MousePressed[i] = false;
- }
-
- io.MouseWheel = g_MouseWheel;
- g_MouseWheel = 0.0f;
-
- // Hide OS mouse cursor if ImGui is drawing it
- glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
-
- // Start the frame
- ImGui::NewFrame();
-}
diff --git a/examples/opengl_example/imgui_impl_glfw.h b/examples/opengl_example/imgui_impl_glfw.h
deleted file mode 100644
index 07dd96f..0000000
--- a/examples/opengl_example/imgui_impl_glfw.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
-IMGUI_API void ImGui_ImplGlfw_Shutdown();
-IMGUI_API void ImGui_ImplGlfw_NewFrame();
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
-
-// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks.
-// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile
deleted file mode 100644
index 91d1b14..0000000
--- a/examples/opengl_example/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with Ubuntu 14.04.1 and Mac OS X
-#
-#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
-#
-
-#CXX = g++
-
-EXE = opengl_example
-OBJS = main.o imgui_impl_glfw.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- LIBS += -L/usr/local/lib -lglfw3
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
-# CXXFLAGS += -D__APPLE__
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), MINGW64_NT-6.3)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/examples/opengl_example/build_win32.bat b/examples/opengl_example/build_win32.bat
deleted file mode 100644
index 278381c..0000000
--- a/examples/opengl_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp
deleted file mode 100644
index 2d1f5c1..0000000
--- a/examples/opengl_example/imgui_impl_glfw.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#include
-#include "imgui_impl_glfw.h"
-
-// GLFW
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// Data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MousePressed[3] = { false, false, false };
-static float g_MouseWheel = 0.0f;
-static GLuint g_FontTexture = 0;
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// If text or lines are blurry when integrating ImGui in your engine:
-// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // We are using the OpenGL fixed pipeline to make the example code simpler to read!
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Render command lists
- #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos)));
- glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
- #undef OFFSETOF
-
- // Restore modified state
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glPopAttrib();
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
-}
-
-static const char* ImGui_ImplGlfw_GetClipboardText()
-{
- return glfwGetClipboardString(g_Window);
-}
-
-static void ImGui_ImplGlfw_SetClipboardText(const char* text)
-{
- glfwSetClipboardString(g_Window, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MousePressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
-{
- g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
-}
-
-void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfw_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-void ImGui_ImplGlfw_InvalidateDeviceObjects()
-{
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
-{
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
- io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
- }
-
- return true;
-}
-
-void ImGui_ImplGlfw_Shutdown()
-{
- ImGui_ImplGlfw_InvalidateDeviceObjects();
- ImGui::Shutdown();
-}
-
-void ImGui_ImplGlfw_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplGlfw_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
- }
- else
- {
- io.MousePos = ImVec2(-1,-1);
- }
-
- for (int i = 0; i < 3; i++)
- {
- io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- g_MousePressed[i] = false;
- }
-
- io.MouseWheel = g_MouseWheel;
- g_MouseWheel = 0.0f;
-
- // Hide OS mouse cursor if ImGui is drawing it
- glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
-
- // Start the frame
- ImGui::NewFrame();
-}
diff --git a/examples/opengl_example/imgui_impl_glfw.h b/examples/opengl_example/imgui_impl_glfw.h
deleted file mode 100644
index 07dd96f..0000000
--- a/examples/opengl_example/imgui_impl_glfw.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
-IMGUI_API void ImGui_ImplGlfw_Shutdown();
-IMGUI_API void ImGui_ImplGlfw_NewFrame();
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
-
-// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks.
-// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp
deleted file mode 100644
index a844db5..0000000
--- a/examples/opengl_example/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-#include
-#include "imgui_impl_glfw.h"
-#include
-#include
-
-static void error_callback(int error, const char* description)
-{
- fprintf(stderr, "Error %d: %s\n", error, description);
-}
-
-int main(int, char**)
-{
- // Setup window
- glfwSetErrorCallback(error_callback);
- if (!glfwInit())
- return 1;
- GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
- glfwMakeContextCurrent(window);
-
- // Setup ImGui binding
- ImGui_ImplGlfw_Init(window, true);
-
- // Load Fonts
- // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
- //ImGuiIO& io = ImGui::GetIO();
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
- //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
-
- bool show_test_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImColor(114, 144, 154);
-
- // Main loop
- while (!glfwWindowShouldClose(window))
- {
- glfwPollEvents();
- ImGui_ImplGlfw_NewFrame();
-
- // 1. Show a simple window
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
- {
- static float f = 0.0f;
- ImGui::Text("Hello, world!");
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
- ImGui::ColorEdit3("clear color", (float*)&clear_color);
- if (ImGui::Button("Test Window")) show_test_window ^= 1;
- if (ImGui::Button("Another Window")) show_another_window ^= 1;
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- }
-
- // 2. Show another simple window, this time using an explicit Begin/End pair
- if (show_another_window)
- {
- ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello");
- ImGui::End();
- }
-
- // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
- if (show_test_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
- ImGui::ShowTestWindow(&show_test_window);
- }
-
- // Rendering
- int display_w, display_h;
- glfwGetFramebufferSize(window, &display_w, &display_h);
- glViewport(0, 0, display_w, display_h);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- ImGui::Render();
- glfwSwapBuffers(window);
- }
-
- // Cleanup
- ImGui_ImplGlfw_Shutdown();
- glfwTerminate();
-
- return 0;
-}
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile
deleted file mode 100644
index 91d1b14..0000000
--- a/examples/opengl_example/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with Ubuntu 14.04.1 and Mac OS X
-#
-#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
-#
-
-#CXX = g++
-
-EXE = opengl_example
-OBJS = main.o imgui_impl_glfw.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- LIBS += -L/usr/local/lib -lglfw3
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
-# CXXFLAGS += -D__APPLE__
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), MINGW64_NT-6.3)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/examples/opengl_example/build_win32.bat b/examples/opengl_example/build_win32.bat
deleted file mode 100644
index 278381c..0000000
--- a/examples/opengl_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp
deleted file mode 100644
index 2d1f5c1..0000000
--- a/examples/opengl_example/imgui_impl_glfw.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#include
-#include "imgui_impl_glfw.h"
-
-// GLFW
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// Data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MousePressed[3] = { false, false, false };
-static float g_MouseWheel = 0.0f;
-static GLuint g_FontTexture = 0;
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// If text or lines are blurry when integrating ImGui in your engine:
-// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // We are using the OpenGL fixed pipeline to make the example code simpler to read!
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Render command lists
- #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos)));
- glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
- #undef OFFSETOF
-
- // Restore modified state
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glPopAttrib();
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
-}
-
-static const char* ImGui_ImplGlfw_GetClipboardText()
-{
- return glfwGetClipboardString(g_Window);
-}
-
-static void ImGui_ImplGlfw_SetClipboardText(const char* text)
-{
- glfwSetClipboardString(g_Window, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MousePressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
-{
- g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
-}
-
-void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfw_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-void ImGui_ImplGlfw_InvalidateDeviceObjects()
-{
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
-{
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
- io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
- }
-
- return true;
-}
-
-void ImGui_ImplGlfw_Shutdown()
-{
- ImGui_ImplGlfw_InvalidateDeviceObjects();
- ImGui::Shutdown();
-}
-
-void ImGui_ImplGlfw_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplGlfw_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
- }
- else
- {
- io.MousePos = ImVec2(-1,-1);
- }
-
- for (int i = 0; i < 3; i++)
- {
- io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- g_MousePressed[i] = false;
- }
-
- io.MouseWheel = g_MouseWheel;
- g_MouseWheel = 0.0f;
-
- // Hide OS mouse cursor if ImGui is drawing it
- glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
-
- // Start the frame
- ImGui::NewFrame();
-}
diff --git a/examples/opengl_example/imgui_impl_glfw.h b/examples/opengl_example/imgui_impl_glfw.h
deleted file mode 100644
index 07dd96f..0000000
--- a/examples/opengl_example/imgui_impl_glfw.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
-IMGUI_API void ImGui_ImplGlfw_Shutdown();
-IMGUI_API void ImGui_ImplGlfw_NewFrame();
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
-
-// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks.
-// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp
deleted file mode 100644
index a844db5..0000000
--- a/examples/opengl_example/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-#include
-#include "imgui_impl_glfw.h"
-#include
-#include
-
-static void error_callback(int error, const char* description)
-{
- fprintf(stderr, "Error %d: %s\n", error, description);
-}
-
-int main(int, char**)
-{
- // Setup window
- glfwSetErrorCallback(error_callback);
- if (!glfwInit())
- return 1;
- GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
- glfwMakeContextCurrent(window);
-
- // Setup ImGui binding
- ImGui_ImplGlfw_Init(window, true);
-
- // Load Fonts
- // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
- //ImGuiIO& io = ImGui::GetIO();
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
- //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
-
- bool show_test_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImColor(114, 144, 154);
-
- // Main loop
- while (!glfwWindowShouldClose(window))
- {
- glfwPollEvents();
- ImGui_ImplGlfw_NewFrame();
-
- // 1. Show a simple window
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
- {
- static float f = 0.0f;
- ImGui::Text("Hello, world!");
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
- ImGui::ColorEdit3("clear color", (float*)&clear_color);
- if (ImGui::Button("Test Window")) show_test_window ^= 1;
- if (ImGui::Button("Another Window")) show_another_window ^= 1;
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- }
-
- // 2. Show another simple window, this time using an explicit Begin/End pair
- if (show_another_window)
- {
- ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello");
- ImGui::End();
- }
-
- // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
- if (show_test_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
- ImGui::ShowTestWindow(&show_test_window);
- }
-
- // Rendering
- int display_w, display_h;
- glfwGetFramebufferSize(window, &display_w, &display_h);
- glViewport(0, 0, display_w, display_h);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- ImGui::Render();
- glfwSwapBuffers(window);
- }
-
- // Cleanup
- ImGui_ImplGlfw_Shutdown();
- glfwTerminate();
-
- return 0;
-}
diff --git a/examples/opengl_example/opengl_example.vcxproj b/examples/opengl_example/opengl_example.vcxproj
deleted file mode 100644
index 4b354b6..0000000
--- a/examples/opengl_example/opengl_example.vcxproj
+++ /dev/null
@@ -1,169 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {9CDA7840-B7A5-496D-A527-E95571496D18}
- opengl_example
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
- opengl32.lib;glfw3.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
- opengl32.lib;glfw3.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
-
-
- true
- true
- true
- $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
- opengl32.lib;glfw3.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
-
-
- true
- true
- true
- $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
- opengl32.lib;glfw3.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile
deleted file mode 100644
index 91d1b14..0000000
--- a/examples/opengl_example/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with Ubuntu 14.04.1 and Mac OS X
-#
-#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
-#
-
-#CXX = g++
-
-EXE = opengl_example
-OBJS = main.o imgui_impl_glfw.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- LIBS += -L/usr/local/lib -lglfw3
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
-# CXXFLAGS += -D__APPLE__
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), MINGW64_NT-6.3)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/examples/opengl_example/build_win32.bat b/examples/opengl_example/build_win32.bat
deleted file mode 100644
index 278381c..0000000
--- a/examples/opengl_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp
deleted file mode 100644
index 2d1f5c1..0000000
--- a/examples/opengl_example/imgui_impl_glfw.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#include
-#include "imgui_impl_glfw.h"
-
-// GLFW
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// Data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MousePressed[3] = { false, false, false };
-static float g_MouseWheel = 0.0f;
-static GLuint g_FontTexture = 0;
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// If text or lines are blurry when integrating ImGui in your engine:
-// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // We are using the OpenGL fixed pipeline to make the example code simpler to read!
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Render command lists
- #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos)));
- glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
- #undef OFFSETOF
-
- // Restore modified state
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glPopAttrib();
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
-}
-
-static const char* ImGui_ImplGlfw_GetClipboardText()
-{
- return glfwGetClipboardString(g_Window);
-}
-
-static void ImGui_ImplGlfw_SetClipboardText(const char* text)
-{
- glfwSetClipboardString(g_Window, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MousePressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
-{
- g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
-}
-
-void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfw_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-void ImGui_ImplGlfw_InvalidateDeviceObjects()
-{
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
-{
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
- io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
- }
-
- return true;
-}
-
-void ImGui_ImplGlfw_Shutdown()
-{
- ImGui_ImplGlfw_InvalidateDeviceObjects();
- ImGui::Shutdown();
-}
-
-void ImGui_ImplGlfw_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplGlfw_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
- }
- else
- {
- io.MousePos = ImVec2(-1,-1);
- }
-
- for (int i = 0; i < 3; i++)
- {
- io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- g_MousePressed[i] = false;
- }
-
- io.MouseWheel = g_MouseWheel;
- g_MouseWheel = 0.0f;
-
- // Hide OS mouse cursor if ImGui is drawing it
- glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
-
- // Start the frame
- ImGui::NewFrame();
-}
diff --git a/examples/opengl_example/imgui_impl_glfw.h b/examples/opengl_example/imgui_impl_glfw.h
deleted file mode 100644
index 07dd96f..0000000
--- a/examples/opengl_example/imgui_impl_glfw.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
-IMGUI_API void ImGui_ImplGlfw_Shutdown();
-IMGUI_API void ImGui_ImplGlfw_NewFrame();
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
-
-// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks.
-// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp
deleted file mode 100644
index a844db5..0000000
--- a/examples/opengl_example/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-#include
-#include "imgui_impl_glfw.h"
-#include
-#include
-
-static void error_callback(int error, const char* description)
-{
- fprintf(stderr, "Error %d: %s\n", error, description);
-}
-
-int main(int, char**)
-{
- // Setup window
- glfwSetErrorCallback(error_callback);
- if (!glfwInit())
- return 1;
- GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
- glfwMakeContextCurrent(window);
-
- // Setup ImGui binding
- ImGui_ImplGlfw_Init(window, true);
-
- // Load Fonts
- // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
- //ImGuiIO& io = ImGui::GetIO();
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
- //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
-
- bool show_test_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImColor(114, 144, 154);
-
- // Main loop
- while (!glfwWindowShouldClose(window))
- {
- glfwPollEvents();
- ImGui_ImplGlfw_NewFrame();
-
- // 1. Show a simple window
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
- {
- static float f = 0.0f;
- ImGui::Text("Hello, world!");
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
- ImGui::ColorEdit3("clear color", (float*)&clear_color);
- if (ImGui::Button("Test Window")) show_test_window ^= 1;
- if (ImGui::Button("Another Window")) show_another_window ^= 1;
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- }
-
- // 2. Show another simple window, this time using an explicit Begin/End pair
- if (show_another_window)
- {
- ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello");
- ImGui::End();
- }
-
- // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
- if (show_test_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
- ImGui::ShowTestWindow(&show_test_window);
- }
-
- // Rendering
- int display_w, display_h;
- glfwGetFramebufferSize(window, &display_w, &display_h);
- glViewport(0, 0, display_w, display_h);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- ImGui::Render();
- glfwSwapBuffers(window);
- }
-
- // Cleanup
- ImGui_ImplGlfw_Shutdown();
- glfwTerminate();
-
- return 0;
-}
diff --git a/examples/opengl_example/opengl_example.vcxproj b/examples/opengl_example/opengl_example.vcxproj
deleted file mode 100644
index 4b354b6..0000000
--- a/examples/opengl_example/opengl_example.vcxproj
+++ /dev/null
@@ -1,169 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {9CDA7840-B7A5-496D-A527-E95571496D18}
- opengl_example
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
- opengl32.lib;glfw3.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
- opengl32.lib;glfw3.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
-
-
- true
- true
- true
- $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
- opengl32.lib;glfw3.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
-
-
- true
- true
- true
- $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
- opengl32.lib;glfw3.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/opengl_example/opengl_example.vcxproj.filters b/examples/opengl_example/opengl_example.vcxproj.filters
deleted file mode 100644
index f2282bf..0000000
--- a/examples/opengl_example/opengl_example.vcxproj.filters
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- imgui
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 616d727..ccdb194 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,6 @@
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
script:
- - make -C examples/opengl_example
+ - make -C examples/opengl2_example
- make -C examples/opengl3_example
diff --git a/README.md b/README.md
index ea0d463..88b9bae 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
-ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
+ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
@@ -33,6 +33,8 @@
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
+_A common misunderstanding is that some people think immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions as called by the user. Some lazy IMGUI-style librairies may work this way but this is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are rather optimal and you can render them later, in your app or even remotely._
+
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
Demo
@@ -109,7 +111,7 @@
How do you use ImGui on a platform that may not have a mouse or keyboard?
-I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
+I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
Can you create elaborate/serious tools with ImGui?
@@ -170,12 +172,13 @@
Double-chocolate sponsors:
- Media Molecule
- Mobigame
+- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society.
+- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon.
And other supporters; thanks!
diff --git a/examples/.gitignore b/examples/.gitignore
index 4170445..54d1539 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -15,11 +15,11 @@
directx11_example/Release/*
directx11_example/ipch/*
directx11_example/x64/*
-opengl_example/Debug/*
-opengl_example/Release/*
-opengl_example/ipch/*
-opengl_example/x64/*
-opengl_example/opengl_example
+opengl2_example/Debug/*
+opengl2_example/Release/*
+opengl2_example/ipch/*
+opengl2_example/x64/*
+opengl2_example/opengl_example
opengl3_example/Debug/*
opengl3_example/Release/*
opengl3_example/ipch/*
diff --git a/examples/README.txt b/examples/README.txt
index df2e86d..54be766 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -8,11 +8,13 @@
TL;DR;
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - Refer to 'opengl_example' to understand how the library is setup, it is the simplest one.
+ - Refer to 'opengl2_example' to LEARN how the library is setup, it is the simplest one.
The other examples requires more boilerplate and are harder to read.
+ - If you are using OpenGL in your application, probably use an opengl3_xxx backend.
+ Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by drivers.
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
to your project and use them unmodified.
- - If you have your own engine, you probably want to start from 'opengl_example' and adapt it to
+ - If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
your engine, but you can read the other examples as well.
ImGui is highly portable and only requires a few things to run:
@@ -36,20 +38,19 @@
At 60 FPS your experience should be pleasant. Consider that OS mouse cursors are typically drawn through
a specific hardware accelerated route and may feel smoother than other GPU rendered contents. You may
experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, to visualize
-the lag between an hardware cursor and a software cursor. It might be beneficial to the user experience
+the lag between a hardware cursor and a software cursor. It might be beneficial to the user experience
to switch to a software rendered cursor when an interactive drag is in progress.
Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
-opengl_example/
- OpenGL example, using GLFW + fixed pipeline.
- This is simple and should work for all OpenGL enabled applications.
- Prefer following this example to learn how ImGui works!
- (You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
- by calling "glUseProgram(0)" before ImGui::Render.)
+opengl2_example/
+ GLFW + OpenGL example (old fixed pipeline).
+ This is simple to read. Prefer following this example to learn how ImGui works!
+ (You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
+ pipeline by calling "glUseProgram(0)" before ImGui::Render.)
opengl3_example/
- OpenGL example, using GLFW/GL3W + programmable pipeline.
+ GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
This uses more modern OpenGL calls and custom shaders. It's more messy.
directx9_example/
@@ -68,8 +69,8 @@
On iOS, Using Synergy to access keyboard/mouse data from server computer.
Synergy keyboard integration is rather hacky.
-sdl_opengl_example/
- SDL2 + OpenGL example.
+sdl_opengl2_example/
+ SDL2 + OpenGL example (old fixed pipeline).
sdl_opengl3_example/
SDL2 + OpenGL3 example.
diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp
index c7ba110..f9dade1 100644
--- a/examples/allegro5_example/imgui_impl_a5.cpp
+++ b/examples/allegro5_example/imgui_impl_a5.cpp
@@ -46,8 +46,8 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.size());
- for (int i = 0; i < cmd_list->VtxBuffer.size(); ++i)
+ vertices.resize(cmd_list->VtxBuffer.Size);
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
{
const ImDrawVert &dv = cmd_list->VtxBuffer[i];
ImDrawVertAllegro v;
@@ -61,12 +61,12 @@
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.size());
- for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
+ indices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
diff --git a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
index b286c4d..63d7d72 100644
--- a/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ b/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
@@ -191,7 +191,7 @@
// connect it to the address and port we passed in to getaddrinfo():
int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
if (!ret) {
- NSLog( @"Connect suceeded...");
+ NSLog( @"Connect succeeded...");
} else {
NSLog( @"Connect failed, %d", ret );
}
@@ -648,7 +648,7 @@
ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- int needed_vtx_size = cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
+ const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
if (g_VboSize < needed_vtx_size)
{
// Grow our buffer if needed
@@ -659,11 +659,12 @@
unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!vtx_data)
continue;
- memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
+ memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
glUnmapBuffer(GL_ARRAY_BUFFER);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
diff --git a/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
index 5d7776d..be43fb6 100644
--- a/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ b/examples/apple_example/imguiex.xcodeproj/project.pbxproj
@@ -97,7 +97,7 @@
isa = PBXGroup;
children = (
1A1A0F4D1CB3C54D0090F036 /* libglfw3.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl_example */,
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
@@ -114,15 +114,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 1A1A0F351CB3A1B20090F036 /* opengl_example */ = {
+ 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
isa = PBXGroup;
children = (
1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw.cpp */,
1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw.h */,
1A1A0F391CB3A1B20090F036 /* main.cpp */,
);
- name = opengl_example;
- path = ../../opengl_example;
+ name = opengl2_example;
+ path = ../../opengl2_example;
sourceTree = "";
};
6D1E39141B35EEF10017B40F /* usynergy */ = {
diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp
index bccee87..c604df0 100644
--- a/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/examples/directx10_example/imgui_impl_dx10.cpp
@@ -87,10 +87,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unmap();
g_pIB->Unmap();
@@ -189,7 +189,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -205,7 +205,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -345,7 +345,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp
index 11f66f0..b7da6e0 100644
--- a/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/examples/directx11_example/imgui_impl_dx11.cpp
@@ -89,10 +89,10 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.size();
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
@@ -194,7 +194,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -210,7 +210,7 @@
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -347,7 +347,7 @@
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
- // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [prefered solution]
+ // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp
index bb309a8..b009de7 100644
--- a/examples/directx9_example/imgui_impl_dx9.cpp
+++ b/examples/directx9_example/imgui_impl_dx9.cpp
@@ -73,8 +73,8 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
- for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
{
vtx_dst->pos[0] = vtx_src->pos.x;
vtx_dst->pos[1] = vtx_src->pos.y;
@@ -85,8 +85,8 @@
vtx_dst++;
vtx_src++;
}
- memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.size();
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
}
g_pVB->Unlock();
g_pIB->Unlock();
@@ -138,7 +138,7 @@
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
@@ -150,11 +150,11 @@
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.size();
+ vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore the DX9 state
diff --git a/examples/imgui_examples_msvc2010.sln b/examples/imgui_examples_msvc2010.sln
index b7e6a25..8c1cd2a 100644
--- a/examples/imgui_examples_msvc2010.sln
+++ b/examples/imgui_examples_msvc2010.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl_example", "opengl_example\opengl_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp
index 12d5dfa..c1856a0 100644
--- a/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/examples/marmalade_example/imgui_impl_marmalade.cpp
@@ -40,9 +40,8 @@
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- int nVert = cmd_list->VtxBuffer.size();
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ const int nVert = cmd_list->VtxBuffer.Size;
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
@@ -62,12 +61,12 @@
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list,pcmd);
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
diff --git a/examples/opengl2_example/Makefile b/examples/opengl2_example/Makefile
new file mode 100644
index 0000000..bd79d1b
--- /dev/null
+++ b/examples/opengl2_example/Makefile
@@ -0,0 +1,60 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+#
+# if you using Mac OS X:
+# You'll need glfw
+# http://www.glfw.org
+#
+
+#CXX = g++
+
+EXE = opengl2_example
+OBJS = main.o imgui_impl_glfw.o
+OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -lglfw3
+
+ CXXFLAGS = -I../../ -I/usr/local/include
+ CXXFLAGS += -Wall -Wformat
+# CXXFLAGS += -D__APPLE__
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), MINGW64_NT-6.3)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+.cpp.o:
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm $(EXE) $(OBJS)
+
diff --git a/examples/opengl2_example/build_win32.bat b/examples/opengl2_example/build_win32.bat
new file mode 100644
index 0000000..28e6752
--- /dev/null
+++ b/examples/opengl2_example/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..cd8e60d
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.cpp
@@ -0,0 +1,290 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#include
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#define GLFW_EXPOSE_NATIVE_WGL
+#include
+#endif
+
+// Data
+static GLFWwindow* g_Window = NULL;
+static double g_Time = 0.0f;
+static bool g_MousePressed[3] = { false, false, false };
+static float g_MouseWheel = 0.0f;
+static GLuint g_FontTexture = 0;
+
+// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
+// If text or lines are blurry when integrating ImGui in your engine:
+// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
+void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // We are using the OpenGL fixed pipeline to make the example code simpler to read!
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
+
+ // Setup viewport, orthographic projection matrix
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // Render command lists
+ #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)((char*)vtx_buffer + OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ #undef OFFSETOF
+
+ // Restore modified state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+static const char* ImGui_ImplGlfw_GetClipboardText()
+{
+ return glfwGetClipboardString(g_Window);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(const char* text)
+{
+ glfwSetClipboardString(g_Window, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+{
+ if (action == GLFW_PRESS && button >= 0 && button < 3)
+ g_MousePressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
+{
+ g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
+}
+
+void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ (void)mods; // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+bool ImGui_ImplGlfw_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplGlfw_InvalidateDeviceObjects()
+{
+ if (g_FontTexture)
+ {
+ glDeleteTextures(1, &g_FontTexture);
+ ImGui::GetIO().Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
+{
+ g_Window = window;
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+#ifdef _WIN32
+ io.ImeWindowHandle = glfwGetWin32Window(g_Window);
+#endif
+
+ if (install_callbacks)
+ {
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ return true;
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ ImGui_ImplGlfw_InvalidateDeviceObjects();
+ ImGui::Shutdown();
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplGlfw_CreateDeviceObjects();
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
+ if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
+ }
+ else
+ {
+ io.MousePos = ImVec2(-1,-1);
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ g_MousePressed[i] = false;
+ }
+
+ io.MouseWheel = g_MouseWheel;
+ g_MouseWheel = 0.0f;
+
+ // Hide OS mouse cursor if ImGui is drawing it
+ glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
+
+ // Start the frame
+ ImGui::NewFrame();
+}
diff --git a/examples/opengl2_example/imgui_impl_glfw.h b/examples/opengl2_example/imgui_impl_glfw.h
new file mode 100644
index 0000000..07dd96f
--- /dev/null
+++ b/examples/opengl2_example/imgui_impl_glfw.h
@@ -0,0 +1,29 @@
+// ImGui GLFW binding with OpenGL
+// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
+
+// If your context is GL3/GL3 then prefer using the code in opengl3_example.
+// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
+// We cannot do that from GL2 code because the function doesn't exist.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct GLFWwindow;
+
+IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
+IMGUI_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_API void ImGui_ImplGlfw_NewFrame();
+
+// Use if you want to reset your rendering device without losing ImGui state.
+IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
+IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
+
+// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// Provided here if you want to chain callbacks.
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl2_example/main.cpp b/examples/opengl2_example/main.cpp
new file mode 100644
index 0000000..a844db5
--- /dev/null
+++ b/examples/opengl2_example/main.cpp
@@ -0,0 +1,89 @@
+// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include
+#include "imgui_impl_glfw.h"
+#include
+#include
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(error_callback);
+ if (!glfwInit())
+ return 1;
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ glfwMakeContextCurrent(window);
+
+ // Setup ImGui binding
+ ImGui_ImplGlfw_Init(window, true);
+
+ // Load Fonts
+ // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
+ //ImGuiIO& io = ImGui::GetIO();
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
+ //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ bool show_test_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImColor(114, 144, 154);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
+ ImGui_ImplGlfw_NewFrame();
+
+ // 1. Show a simple window
+ // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
+ {
+ static float f = 0.0f;
+ ImGui::Text("Hello, world!");
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+ ImGui::ColorEdit3("clear color", (float*)&clear_color);
+ if (ImGui::Button("Test Window")) show_test_window ^= 1;
+ if (ImGui::Button("Another Window")) show_another_window ^= 1;
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ }
+
+ // 2. Show another simple window, this time using an explicit Begin/End pair
+ if (show_another_window)
+ {
+ ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
+ ImGui::Begin("Another Window", &show_another_window);
+ ImGui::Text("Hello");
+ ImGui::End();
+ }
+
+ // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
+ if (show_test_window)
+ {
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
+ ImGui::ShowTestWindow(&show_test_window);
+ }
+
+ // Rendering
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui::Render();
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/examples/opengl2_example/opengl2_example.vcxproj b/examples/opengl2_example/opengl2_example.vcxproj
new file mode 100644
index 0000000..bea2104
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj
@@ -0,0 +1,169 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9CDA7840-B7A5-496D-A527-E95571496D18}
+ opengl2_example
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ true
+ true
+ $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ opengl32.lib;glfw3.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl2_example/opengl2_example.vcxproj.filters b/examples/opengl2_example/opengl2_example.vcxproj.filters
new file mode 100644
index 0000000..f2282bf
--- /dev/null
+++ b/examples/opengl2_example/opengl2_example.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile
index b8e2d83..c824f99 100644
--- a/examples/opengl3_example/Makefile
+++ b/examples/opengl3_example/Makefile
@@ -3,9 +3,10 @@
# Compatible with Ubuntu 14.04.1 and Mac OS X
#
#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
+# You will need GLFW (http://www.glfw.org)
+#
+# apt-get install libglfw-dev # Linux
+# brew install glfw # Mac OS X
#
#CXX = g++
@@ -31,8 +32,9 @@
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -lglfw3
+ #LIBS += -L/usr/local/lib -lglfw
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
+ CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
CXXFLAGS += -Wall -Wformat
# CXXFLAGS += -D__APPLE__
CFLAGS = $(CXXFLAGS)
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 0e3a754..6552e59 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -55,6 +55,7 @@
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
@@ -89,13 +90,14 @@
const ImDrawIdx* idx_buffer_offset = 0;
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
- for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++)
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
@@ -124,6 +126,7 @@
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@@ -175,7 +178,7 @@
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
GLint last_texture;
diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile
deleted file mode 100644
index 91d1b14..0000000
--- a/examples/opengl_example/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with Ubuntu 14.04.1 and Mac OS X
-#
-#
-# if you using Mac OS X:
-# You'll need glfw
-# http://www.glfw.org
-#
-
-#CXX = g++
-
-EXE = opengl_example
-OBJS = main.o imgui_impl_glfw.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- LIBS += -L/usr/local/lib -lglfw3
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
-# CXXFLAGS += -D__APPLE__
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), MINGW64_NT-6.3)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/examples/opengl_example/build_win32.bat b/examples/opengl_example/build_win32.bat
deleted file mode 100644
index 278381c..0000000
--- a/examples/opengl_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp
deleted file mode 100644
index 2d1f5c1..0000000
--- a/examples/opengl_example/imgui_impl_glfw.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#include
-#include "imgui_impl_glfw.h"
-
-// GLFW
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// Data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MousePressed[3] = { false, false, false };
-static float g_MouseWheel = 0.0f;
-static GLuint g_FontTexture = 0;
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// If text or lines are blurry when integrating ImGui in your engine:
-// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // We are using the OpenGL fixed pipeline to make the example code simpler to read!
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Render command lists
- #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
- const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
- glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos)));
- glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
- #undef OFFSETOF
-
- // Restore modified state
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glPopAttrib();
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
-}
-
-static const char* ImGui_ImplGlfw_GetClipboardText()
-{
- return glfwGetClipboardString(g_Window);
-}
-
-static void ImGui_ImplGlfw_SetClipboardText(const char* text)
-{
- glfwSetClipboardString(g_Window, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MousePressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
-{
- g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
-}
-
-void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfw_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-void ImGui_ImplGlfw_InvalidateDeviceObjects()
-{
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
-{
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
- io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
- }
-
- return true;
-}
-
-void ImGui_ImplGlfw_Shutdown()
-{
- ImGui_ImplGlfw_InvalidateDeviceObjects();
- ImGui::Shutdown();
-}
-
-void ImGui_ImplGlfw_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplGlfw_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
- }
- else
- {
- io.MousePos = ImVec2(-1,-1);
- }
-
- for (int i = 0; i < 3; i++)
- {
- io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- g_MousePressed[i] = false;
- }
-
- io.MouseWheel = g_MouseWheel;
- g_MouseWheel = 0.0f;
-
- // Hide OS mouse cursor if ImGui is drawing it
- glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
-
- // Start the frame
- ImGui::NewFrame();
-}
diff --git a/examples/opengl_example/imgui_impl_glfw.h b/examples/opengl_example/imgui_impl_glfw.h
deleted file mode 100644
index 07dd96f..0000000
--- a/examples/opengl_example/imgui_impl_glfw.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// ImGui GLFW binding with OpenGL
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-
-// If your context is GL3/GL3 then prefer using the code in opengl3_example.
-// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
-// We cannot do that from GL2 code because the function doesn't exist.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
-IMGUI_API void ImGui_ImplGlfw_Shutdown();
-IMGUI_API void ImGui_ImplGlfw_NewFrame();
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
-
-// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks.
-// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp
deleted file mode 100644
index a844db5..0000000
--- a/examples/opengl_example/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-#include
-#include "imgui_impl_glfw.h"
-#include
-#include
-
-static void error_callback(int error, const char* description)
-{
- fprintf(stderr, "Error %d: %s\n", error, description);
-}
-
-int main(int, char**)
-{
- // Setup window
- glfwSetErrorCallback(error_callback);
- if (!glfwInit())
- return 1;
- GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
- glfwMakeContextCurrent(window);
-
- // Setup ImGui binding
- ImGui_ImplGlfw_Init(window, true);
-
- // Load Fonts
- // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
- //ImGuiIO& io = ImGui::GetIO();
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
- //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
- //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
-
- bool show_test_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImColor(114, 144, 154);
-
- // Main loop
- while (!glfwWindowShouldClose(window))
- {
- glfwPollEvents();
- ImGui_ImplGlfw_NewFrame();
-
- // 1. Show a simple window
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
- {
- static float f = 0.0f;
- ImGui::Text("Hello, world!");
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
- ImGui::ColorEdit3("clear color", (float*)&clear_color);
- if (ImGui::Button("Test Window")) show_test_window ^= 1;
- if (ImGui::Button("Another Window")) show_another_window ^= 1;
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- }
-
- // 2. Show another simple window, this time using an explicit Begin/End pair
- if (show_another_window)
- {
- ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello");
- ImGui::End();
- }
-
- // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
- if (show_test_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
- ImGui::ShowTestWindow(&show_test_window);
- }
-
- // Rendering
- int display_w, display_h;
- glfwGetFramebufferSize(window, &display_w, &display_h);
- glViewport(0, 0, display_w, display_h);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- ImGui::Render();
- glfwSwapBuffers(window);
- }
-
- // Cleanup
- ImGui_ImplGlfw_Shutdown();
- glfwTerminate();
-
- return 0;
-}
diff --git a/examples/opengl_example/opengl_example.vcxproj b/examples/opengl_example/opengl_example.vcxproj
deleted file mode 100644
index 4b354b6..0000000
--- a/examples/opengl_example/opengl_example.vcxproj
+++ /dev/null
@@ -1,169 +0,0 @@
-
-
-