Giter Club home page Giter Club logo

ofximgui's Introduction

ofxImGui

ofxAddon that allows you to use ImGui in openFrameworks.

Screenshot

Develop Branch

The current master branch embeds an ImGui version is quite old and newer versions are not compatible anymore.
A refactored version of ofxImGui that you can try is available in the develop branch, it comes with a lot of extra (optional) features and new ImGui API methods and UI widgets.
We're looking for feedback in #110. (Tested: Desktops Win/Linux/Mac, Rpi and iOS Simulator).

Compatibility

Master branch may not be tested on all platforms. See Releases for more extensively tested versions.

Test Platforms

ofxImGui should run on the latest openFrameworks release and it's OS/IDE requirements. These are typically:

  • Mac OSX, Xcode
  • Windows 10, Visual Studio
  • Raspberry Pi
  • Linux Desktop (Ubuntu)

Examples

example-demo

imgui demo windows with some OF sepcific image loading

example-helpers

ofxImGui helper functions for interfacing with ofParameter.

example-ios

iOS specific with keyboard input helper.

Build status

ofximgui's People

Contributors

adcox avatar armadillu avatar arturoc avatar daandelange avatar dimitre avatar hamoid avatar hluisi avatar jvcleave avatar kurmanovd avatar prisonerjohn avatar s-ol avatar sphaero avatar tgfrerer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ofximgui's Issues

Random App Crash on using ImGui Menu Object

Hi all,

I am using ofxImGui for a project. Now I am almost finished and on testing (OF 0.9.8, Windows 7) problem occurs: There is one Menu object that is loading videos. When doing so the app sometimes crashes (can not really reproduce) with the following error:

Exception thrown at 0x0000000069E98240 (nvoglv64.dll) in oeShowTool_I_debug.exe: 0xC0000005: Access violation reading location 0x000000000A572390. occurred

Debugging shows me EngineGLFW.cpp, line 277:

idx_buffer += pcmd->ElemCount;

The project is quite demanding alright (projection mapping tool with warping and masking), so the problem might be somewhere else, still as it happens on using the menu object and as debugger points me to ofxImGui, I thought I ask if there's some advise how to approach this.
Find some more output of the debugger below.

Thanks for any hint
oe

		fb_height	800	int
		glDrawElements	0x0000000140375d21 {oeShowTool_I_debug.exe!glDrawElements}	void *
		glScissor	0x0000000140375d45 {oeShowTool_I_debug.exe!glScissor}	void *
-		idx_buffer	0x000000000a13ffc0 {1355}	const unsigned int *
			1355	const unsigned int
-		pcmd	0x0000000009fbb2a0 {ElemCount=24 ClipRect={x=685.000000 y=298.000000 z=1565.00000 ...} TextureId=0x0000000000000001 ...}	const ImDrawCmd *
		ElemCount	24	unsigned int
-		ClipRect	{x=685.000000 y=298.000000 z=1565.00000 ...}	ImVec4
		x	685.000000	float
		y	298.000000	float
		z	1565.00000	float
		w	601.000000	float
		TextureId	0x0000000000000001	void *
		UserCallback	0x0000000000000000	void(*)(const ImDrawList *, const ImDrawCmd *)
		UserCallbackData	0x0000000000000000	void *
-		pcmd->ClipRect	{x=685.000000 y=298.000000 z=1565.00000 ...}	const ImVec4
		x	685.000000	float
		y	298.000000	float
		z	1565.00000	float
		w	601.000000	float
		pcmd->ClipRect.w	601.000000	const float
		pcmd->ClipRect.x	685.000000	const float
		pcmd->ClipRect.y	298.000000	const float
		pcmd->ClipRect.z	1565.00000	const float
		pcmd->ElemCount	24	const unsigned int

EDIT: The crash does not happen when I am using gstreamer as ofVideoPlayer.

ImGui in a separate app window

I'm trying to build a separate ImGui settings window for my app.
I've followed the multiWindowOneAppExample which does this using ofxGui not ofxImGui

I can create a separate window with a menubar and a drop down menu like this:
image

The problem is that whenever I click in the window off the menubar or the dropdown item I lose the mouse focus, the menu drop down is greyed out and I can never get it back.

I made a simple test program to illustrate the issue
in app.h I have

	void drawGui(ofEventArgs & args);
	ofxImGui::Gui gui;
	bool flag;

in main.cpp I have

int main( ){
	// Create main window
	ofGLFWWindowSettings mainWinSettings;
	mainWinSettings.width = 1920;
	mainWinSettings.height = 240;
	mainWinSettings.resizable = true;
	shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(mainWinSettings);

	// create a separate window for imGui
	ofGLFWWindowSettings guiWinSettings;
	guiWinSettings.width = 600;
	guiWinSettings.height = 600;
	guiWinSettings.resizable = true;
	shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(guiWinSettings);

	shared_ptr<ofApp> mainApp(new ofApp);
	mainApp->setupGui();
	ofAddListener(guiWindow->events().draw, mainApp.get(), &ofApp::drawGui);

	ofRunApp(mainWindow, mainApp);
	ofRunMainLoop();
}

and in app.cpp I have

//--------------------------------------------------------------
void ofApp::setupGui() {
	gui.setup();
}
//--------------------------------------------------------------
void ofApp::drawGui(ofEventArgs & args) {
	gui.begin();
	ImGui::SetNextWindowSize(ofVec2f(ofGetWidth(), ofGetHeight()));
	ImGui::SetNextWindowPos(ofVec2f(0, 0));
	ImGuiWindowFlags window_flags = 0;
	window_flags |= ImGuiWindowFlags_NoTitleBar;
	window_flags |= ImGuiWindowFlags_NoResize;
	window_flags |= ImGuiWindowFlags_NoMove;
	window_flags |= ImGuiWindowFlags_NoSavedSettings;

	bool p_open = true;
	ImGui::Begin("gui", &p_open, window_flags);  // Menubar Window
	if (ImGui::BeginMainMenuBar()) {
		// View menu
		if (ImGui::BeginMenu("View")) {
			ImGui::Checkbox("Flag", &flag);
			ImGui::EndMenu();
		}
		ImGui::EndMainMenuBar();
	}
	ImGui::End();
	gui.end();
}

I must be missing something somewhere but I can't figure it out.
Thanks for any help

compiling on raspberry pi3 fails on ofxImGui/src/EngineOpenGLES.cpp

in the config it states

'linuxarmv6l:
#TODO needs EngineGLFW.cpp exclude "

however EngineGLFW.cpp appears to compile but appears to fail compiling
ofxImGui/src/EngineOpenGLES.cpp

/home/pi/openFrameworks/addons/ofxImGui/src/EngineOpenGLES.cpp: In member function ‘virtual bool ofxImGui::EngineOpenGLES::createDeviceObjects()’:
/home/pi/openFrameworks/addons/ofxImGui/src/EngineOpenGLES.cpp:130:3: error: ‘g_UniformLocationPosition’ was not declared in this scope
g_UniformLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position");
^
/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:336: recipe for target '/home/pi/openFrameworks/addons/obj/linuxarmv6l/Release/ofxImGui/src/EngineOpenGLES.o' failed
make[1]: *** [/home/pi/openFrameworks/addons/obj/linuxarmv6l/Release/ofxImGui/src/EngineOpenGLES.o] Error 1

//compiling on raspberry pi 3 in raspbian in of 0.9.8 with ImGui 1.49 and 1.50
//code compiles fine on mac OSx in Xcode//

ImGui :: Image use ofFbo error

GLuint id = m_ui.loadTexture(image_fbo.getTexture());
ImGui::Image((ImTextureID)(uintptr_t)id, ImVec2(fingerMovie.getWidth(), fingerMovie.getHeight()));

display blank

Add flags to Settings

It took me a while to figure out why my window positions weren't saving. Would be great if flags such as ImGuiWindowFlags_NoSavedSettings could be set in the Settings object.

AddFont should before ui.setup() otherwise font wont build

README.md is like this, but not work for me

void ofApp::setup()
{
  m_ui.setup();

  ImGuiIO * io = &ImGui::GetIO();
  io->Fonts->AddFontFromFileTTF(&ofToDataPath("NotoSans.ttf")[0], 24.f);
}

Font texture create in setup()->createDeviceObjects()

bool EngineGLFW::createDeviceObjects()
{
    ......
    unsigned char * pixels;
    int width, height;
    io->Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);

    GLuint textureid = loadTextureImage2D(pixels, width, height);
    io->Fonts->TexID = (ImTextureID)(intptr_t)textureid;

    io->Fonts->ClearTexData();

    return true;
}

So after setup(), I can't add any font, below code work for me

ImGuiIO * io = &ImGui::GetIO();
ImFontConfig font_config; font_config.OversampleH = 1; font_config.OversampleV = 1; font_config.PixelSnapH = 1; 
ImFont* f = io->Fonts->AddFontFromFileTTF("data/Deng.ttf", 18.0f, NULL, io->Fonts->GetGlyphRangesChinese());

gui.setup();

By the way, this line is important to add unicode font, or you just see white grid.

ImFontConfig font_config; font_config.OversampleH = 1; font_config.OversampleV = 1; font_config.PixelSnapH = 1; 

Failed to build example-demo on Raspberry Pi 3 & OF0.9.3/0.9.5

Linking bin/example-demo for linuxarmv6l g++ -o bin/example-demo obj/linuxarmv6l/Release/src/ofApp.o obj/linuxarmv6l/Release/src/main.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/EngineGLFW.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/Gui.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/EngineOpenGLES.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/BaseTheme.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/Helpers.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/BaseEngine.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/libs/imgui/src/imgui_demo.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/libs/imgui/src/imgui.o ../../../addons/obj/linuxarmv6l/Release/ofxImGui/libs/imgui/src/imgui_draw.o ../../../libs/openFrameworksCompiled/lib/linuxarmv6l/libopenFrameworks.a -Wl,-rpath=./libs:./bin/libs -Wl,--as-needed -Wl,--gc-sections -pthread -L/opt/vc/lib ../../../libs/kiss/lib/linuxarmv6l/libkiss.a ../../../libs/tess2/lib/linuxarmv6l/libtess2.a ../../../libs/poco/lib/linuxarmv6l/libPocoNetSSL.a ../../../libs/poco/lib/linuxarmv6l/libPocoNet.a ../../../libs/poco/lib/linuxarmv6l/libPocoCrypto.a ../../../libs/poco/lib/linuxarmv6l/libPocoUtil.a ../../../libs/poco/lib/linuxarmv6l/libPocoJSON.a ../../../libs/poco/lib/linuxarmv6l/libPocoXML.a ../../../libs/poco/lib/linuxarmv6l/libPocoFoundation.a -L/usr/lib/arm-linux-gnueabihf -lz -lgstapp-1.0 -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -ludev -lfontconfig -lfreetype -lsndfile -lopenal -lssl -lcrypto -lglfw -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lmpg123 -lfreeimage -lboost_filesystem -lboost_system -lXinerama -lrtaudio -lGLESv2 -lGLESv1_CM -lEGL -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lpcre -lrt -lX11 -ldl ../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/Gui.o: In functionofxImGui::Gui::setup(ofxImGui::BaseTheme_)':
Gui.cpp:(.text+0x104): undefined reference to ofxImGui::EngineOpenGLES::setup()' Gui.cpp:(.text+0x158): undefined reference tovtable for ofxImGui::EngineOpenGLES'
../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/Gui.o: In function ofxImGui::Gui::close()': Gui.cpp:(.text+0x7b0): undefined reference toofxImGui::EngineOpenGLES::exit()'
Gui.cpp:(.text+0x860): undefined reference to vtable for ofxImGui::EngineOpenGLES' ../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/Gui.o: In functionofxImGui::EngineOpenGLES::~EngineOpenGLES()':
Gui.cpp:(.text._ZN8ofxImGui14EngineOpenGLESD0Ev[_ZN8ofxImGui14EngineOpenGLESD5Ev]+0x20): undefined reference to ofxImGui::EngineOpenGLES::exit()' Gui.cpp:(.text._ZN8ofxImGui14EngineOpenGLESD0Ev[_ZN8ofxImGui14EngineOpenGLESD5Ev]+0x38): undefined reference tovtable for ofxImGui::EngineOpenGLES'
../../../addons/obj/linuxarmv6l/Release/ofxImGui/src/Gui.o: In function ofxImGui::EngineOpenGLES::~EngineOpenGLES()': Gui.cpp:(.text._ZN8ofxImGui14EngineOpenGLESD2Ev[_ZN8ofxImGui14EngineOpenGLESD5Ev]+0x20): undefined reference toofxImGui::EngineOpenGLES::exit()'
Gui.cpp:(.text._ZN8ofxImGui14EngineOpenGLESD2Ev[_ZN8ofxImGui14EngineOpenGLESD5Ev]+0x30): undefined reference to vtable for ofxImGui::EngineOpenGLES' collect2: error: ld returned 1 exit status ../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:382: recipe for target 'bin/example-demo' failed make[1]: *_\* [bin/example-demo] Error 1 make[1]: Leaving directory '/home/pi/develop/openframeworks/0.9.5/addons/ofxImGui/example-demo' ../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:125: recipe for target 'Release' failed make: **\* [Release] Error 2
It seems that some dependencies , like libraries, are not met.

Assert triggered by negative io.DeltaTime

I realized that if I let the iOS app I'm building run for 10 or 20 minutes, it triggers an assert error on line imgui.cpp:2044 on this line:

IM_ASSERT(g.IO.DeltaTime >= 0.0f);    
// Need a positive DeltaTime (zero is tolerated but will cause some timing issues)

During this time I do not interact with the app. I just let it run. I see the used values are all floats, so they should not overflow in such a short time. What could be the reason?

Maybe a simple solution would be to replace this

	float currentTime = ofGetElapsedTimef();
	if (lastTime > 0.f)
	{
		io.DeltaTime = currentTime - lastTime;
	}
	else
	{
		io.DeltaTime = 1.0f / 60.f;
	}

with this

	float currentTime = ofGetElapsedTimef();
	if (currentTime > lastTime)
	{
		io.DeltaTime = currentTime - lastTime;
	}
	else
	{
		io.DeltaTime = 1.0f / 60.f;
	}

This would avoid negative values, but it does not explain how they happen in the first place.

I'm running my app at 30 fps. Could that be an issue?

clipping

some strange clipping going on - doesn't happen with ImGui

image

how to prevent events from passing to app

how can we block events from passing to the app? e.g. when using ofApp::mousePressed etc and we want to ignore events which are handled by the ImGui, or when using ofEasyCam etc?

CPU ressource leak ?

Hello,

i have just built a basic UI with some sliders and buttons without binding anything to it.

strange behavior : when the app has the focus, everything seems ok and CPU usage is around 5% on my core i7 quad cores. but as soon as the app is out of focus (i.e. i bring my chrome browser in front) then my ImGui app suddenly eat 97% of CPU, computer gets hot and fan is going mad.

A similar app built with ofxUI and bind to OSC precesses uses around 2,7 % of CPU no matter what

Double clicking window bar causes IM_ASSERT

Might be a logic error but something like this

if(showStatsWindow)
        {
            if(ImGui::Begin("App Stats", &showStatsWindow))
            {
                ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
                ImGui::End();
            }
        }

would trigger an error here:
https://github.com/jvcleave/ofxImGui/blob/master/libs/imgui/src/imgui.cpp#L2355

if the window bar was double-clicked quickly.

The below implementation doesn't seem to have the same issue

if(showStatsWindow)
        {
            if(!ImGui::Begin("App Stats", &showStatsWindow))
            {
               ImGui::End(); 
            }else
            {
                ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
                ImGui::End();
            }
        }

I tried this PR as well but it didn't make a difference
#33

Linking error in VS2015 windows 10 64bit

Getting the following linking errors with the new version on Windows 10:

1>------ Build started: Project: test, Configuration: Debug x64 ------
1>     Creating library bin\test_debug.lib and object bin\test_debug.exp
1>ofxImGui.obj : error LNK2019: unresolved external symbol "public: unsigned int __cdecl BaseEngine::loadTextureImage2D(class ofImage_<unsigned char> &)" (?loadTextureImage2D@BaseEngine@@QEAAIAEAV?$ofImage_@E@@@Z) referenced in function "public: unsigned int __cdecl ofxImGui::loadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?loadImage@ofxImGui@@QEAAIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>ofxImGui.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl EngineGLFW::setup(struct ImGuiIO *)" (?setup@EngineGLFW@@UEAAXPEAUImGuiIO@@@Z)
1>ofxImGui.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl EngineGLFW::createDeviceObjects(void)" (?createDeviceObjects@EngineGLFW@@UEAA_NXZ)
1>ofxImGui.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl EngineGLFW::onKeyReleased(class ofKeyEventArgs &)" (?onKeyReleased@EngineGLFW@@UEAAXAEAVofKeyEventArgs@@@Z)
1>bin\test_debug.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Thanks

Hello,

Not an issue :)

just wanted to say thank you for bringing this addon. This a a great and featurefull Gui

thanks again.

Minimum window width and height since Vulkan engine added

I'm using ofxImGui under Windows with of_v0.9.7_vs_release.

My application has a window with a height of 32 pixels which I position across the top of the app window and use as a menu bar. I built it using the commit of 22 February 2017 12:56:28 and it worked well.
Now I have updated to the latest version of ofxImGui this menu bar window extends down over the app window shading it in an undesirable way.
EG
image
It seems that the minimum height of a window is now 80 pixels, if you specify anything less it is drawn as 80 pixels high

I also have a 80 pixel square window which I use for navigation which was OK before and now is rectangular:
image
It seems that the minimum width of a window is now 160 pixels, if you specify anything less it is drawn as 160 pixels.

The behaviour can be demonstrated by adding this code to ImGuiTest and adjusting the float value

	int squareSize = (int) (floatValue * 1000);
	ImGui::SetNextWindowSize(ofVec2f(squareSize, squareSize));
	bool show = true;
	ImGui::Begin("R", &show);
	
	ImGui::End();

Checking out various commits the change came with the addition of the vulkan engine 18 May 2017 20:13:25

ofParameter save special character

if ## is in the name not save to xml
ofParameter<int> min{ "##Min", 5000, 5000, 65535 }; // not save ## ? ofParameter<int> max{ "Max", 5000, 5000, 65535 }; ofParameterGroup parameters{ "Parameters", min, max };

ofXml xml;
ofSerialize(xml, parameters);
xml.save("settings.xml");

ofKeyEventArgs.codepoint not right when use IME input

according to https://github.com/ocornut/imgui/blob/master/examples/opengl3_example/imgui_impl_glfw_gl3.cpp

we should use glfwSetCharCallback(window, ImGui_ImplGlfwGL3_CharCallback) to AddInputCharacter()

since like ofKeyEventArgs.codepoint is not the right unicode char, maybe this is a oF core bug.

so I comment all AddInputCharacter in KeyPressed and KeyReleased

void BaseEngine::onKeyPressed(ofKeyEventArgs& event)
{
    int key = event.keycode;
    io->KeysDown[key] = true;
    //io->AddInputCharacter((unsigned short)event.codepoint);
}
void EngineGLFW::onKeyReleased(ofKeyEventArgs& event)
{
    int key = event.keycode;
    io->KeysDown[key] = false;

    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];
    if(key < GLFW_KEY_ESCAPE)
    {
        //io->AddInputCharacter((unsigned short)event.codepoint);
    }
}

And add CharCallback then all works

void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow*, unsigned int c)
{
    ImGuiIO& io = ImGui::GetIO();
    if (c > 0 && c < 0x10000)
        io.AddInputCharacter((unsigned short)c);
}
void EngineGLFW::setup(ImGuiIO* io_)
{
    ......
    ofAddListener(ofEvents().keyReleased, this, &EngineGLFW::onKeyReleased);

    ofAddListener(ofEvents().keyPressed, (BaseEngine*)this, &BaseEngine::onKeyPressed);
    ofAddListener(ofEvents().mousePressed, (BaseEngine*)this, &BaseEngine::onMousePressed);
    ofAddListener(ofEvents().mouseReleased, (BaseEngine*)this, &BaseEngine::onMouseReleased);
    ofAddListener(ofEvents().mouseScrolled, (BaseEngine*)this, &BaseEngine::onMouseScrolled);
    ofAddListener(ofEvents().windowResized, (BaseEngine*)this, &BaseEngine::onWindowResized);

    auto ptr = static_cast<ofAppGLFWWindow*>(ofGetWindowPtr());
    glfwSetCharCallback(ptr->getGLFWWindow(), ImGui_ImplGlfwGL3_CharCallback);
}

oF not use this CallBack in glfw setting, so it's fine we use here.

Can't run the example on the PI

Hi, I posted on the wrong github but this is the original post:

I would like to run your library on the PI.
But when compiling the example I get the following error:

HOST_OS=Linux
checking pkg-config libraries: cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0
Compiling OF library for Release
make[1]: Entering directory '/home/pi/openFrameworks/libs/openFrameworksCompiled/project'
HOST_OS=Linux
checking pkg-config libraries: cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0
HOST_OS=Linux
checking pkg-config libraries: cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0
HOST_OS=Linux
checking pkg-config libraries: cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0
Done!
make[1]: Leaving directory '/home/pi/openFrameworks/libs/openFrameworksCompiled/project'

Compiling example-demo for Release
make[1]: Entering directory '/home/pi/openFrameworks/addons/ofxImGui/example-demo'
HOST_OS=Linux
checking pkg-config libraries: cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0
Compiling /home/pi/openFrameworks/addons/ofxImGui/example-demo/src/ofApp.cpp
g++ -c -O3 -DNDEBUG -Wall -std=c++14 -DGCC_HAS_REGEX -march=armv6 -mfpu=vfp -mfloat-abi=hard -fPIC -ftree-vectorize -Wno-psabi -pipe -DOF_USING_GTK -DOF_USING_GTK -DTARGET_RASPBERRY_PI -DSTANDALONE -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/AL -I/usr/include/alsa -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/home/pi/openFrameworks/libs/fmodex/include -I/home/pi/openFrameworks/libs/glfw/include -I/home/pi/openFrameworks/libs/glfw/include/GLFW -I/home/pi/openFrameworks/libs/kiss/include -I/home/pi/openFrameworks/libs/poco/include -I/home/pi/openFrameworks/libs/tess2/include -I/home/pi/openFrameworks/libs/utf8cpp/include -I/home/pi/openFrameworks/libs/utf8cpp/include/utf8 -I/home/pi/openFrameworks/libs/openFrameworks -I/home/pi/openFrameworks/libs/openFrameworks/utils -I/home/pi/openFrameworks/libs/openFrameworks/3d -I/home/pi/openFrameworks/libs/openFrameworks/graphics -I/home/pi/openFrameworks/libs/openFrameworks/gl -I/home/pi/openFrameworks/libs/openFrameworks/sound -I/home/pi/openFrameworks/libs/openFrameworks/types -I/home/pi/openFrameworks/libs/openFrameworks/app -I/home/pi/openFrameworks/libs/openFrameworks/video -I/home/pi/openFrameworks/libs/openFrameworks/events -I/home/pi/openFrameworks/libs/openFrameworks/math -I/home/pi/openFrameworks/libs/openFrameworks/communication -I/home/pi/openFrameworks/addons/ofxImGui/example-demo/src -I/home/pi/openFrameworks/addons/ofxImGui/src -I/home/pi/openFrameworks/addons/ofxImGui/libs -I/home/pi/openFrameworks/addons/ofxImGui/libs/imgui -I/home/pi/openFrameworks/addons/ofxImGui/libs/imgui/src -MMD -MP -MF obj/linuxarmv6l/Release/src/ofApp.d -MT obj/linuxarmv6l/Release/src/ofApp.o -o obj/linuxarmv6l/Release/src/ofApp.o -c /home/pi/openFrameworks/addons/ofxImGui/example-demo/src/ofApp.cpp
/home/pi/openFrameworks/addons/ofxImGui/example-demo/src/ofApp.cpp:37:1: error: stray ‘\32’ in program
ofLogVerbose() << "textureSourceID: " << textureSourceID;
^
/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:200: recipe for target 'obj/linuxarmv6l/Release/src/ofApp.o' failed
make[1]: *** [obj/linuxarmv6l/Release/src/ofApp.o] Error 1
make[1]: Leaving directory '/home/pi/openFrameworks/addons/ofxImGui/example-demo'
/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:125: recipe for target 'Release' failed
make: *** [Release] Error 2

I hope someone can help.


here the answers:

https://ubuntuforums.org/showthread.php?t=2256084 ?

and:

That error appears to be in a source file for https://github.com/jvcleave/ofxImGui/ which is the binding for OpenFramework, so please report there, thanks!

opengl error

int main()
{

ofGLWindowSettings glWindowSettings;
glWindowSettings.width = 1280;
glWindowSettings.height = 720;
glWindowSettings.setGLVersion(4,1);
ofCreateWindow(glWindowSettings);

ofRunApp(new ofApp());

}

error:
0x0339FE7A exception thrown at (located Morphing Software debug.exe in): 0xC0000005: reading location 0x00000000 access violation occurs.
If applicable for this exception handler, the program can continue to operate safely.

Not distinguishing between left and right mouse clicks

I'm trying to implement a right click context menu but ImGui is not distinguishing between left and right mouse clicks.

It seems that any mouse click fills up all the IO.MouseDown array.

You can clearly see this on the ImGui demo if you press and hold any button in the Keyboard Mouse and Focus tree, the mouse down times for all 5 buttons increment together

I've been trying to investigate this but I'm not at all familiar with the code. Any help or suggestions would be greatly appreciated

How can I change the title of "Debug" window?

How can I change the title of "Debug" window?I mean for example I want to make that window's name "App" instead of "Debug", is it possible?

Also, it looks like ofxImGui is the most advanced GUI addon for Openframeworks, thanks for creating it :)

Could ImGui::IsMouseHoveringAnyWindow replace settings.mouseOverGui?

I was wondering if this code (helpers.cpp) is required:

// Check if the mouse cursor is over this gui window.
const auto windowBounds = ofRectangle(settings.windowPos, settings.windowSize.x, settings.windowSize.y);
settings.mouseOverGui |= windowBounds.inside(ofGetMouseX(), ofGetMouseY());

when we can do:

if(ImGui::IsMouseHoveringAnyWindow()) {
    ofDrawEllipse(ofRandomWidth(), ofRandomHeight(), 20, 20);
}

There's also ImGui::IsMouseHoveringWindow().

Side note: it would be very helpful to have some documentation (even a paragraph), especially about ImGui vs ofxImGui, what's the benefit of BeginWindow vs Begin, why is ofxImGui needed or what does it make simpler. It's not so obvious when looking at the source code of both projects. Still, I'm happy that both exist 💃

Duplicate key input

void BaseEngine::onKeyPressed(ofKeyEventArgs& event)
{
    int key = event.keycode;
    io->KeysDown[key] = true;
    io->AddInputCharacter((unsigned short)event.codepoint);
}

void EngineGLFW::onKeyReleased(ofKeyEventArgs& event)
{
    int key = event.keycode;
    io->KeysDown[key] = false;

    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];
    if(key < GLFW_KEY_ESCAPE)
    {
        io->AddInputCharacter((unsigned short)event.codepoint);
    }
}

press and release add same codepoint, if I try input 'a', input text will be 'aa'

Clicks not registered

Compiled and ran example-demo on OS X 10.11.5 Mid-2015 Macbook Pro. The trackpad on these laptops has two click "types": one is triggered with a light tap, the other is triggered by a more forceful push. The second option always has the desired effect of clicking on the ImGui element. The first option, however, does not. Often the click is not registered by ImGui and the button isn't pressed or the menu item doesn't expand.

I added a logger line to the mouse press event in the ofApp::mousePressed function and it catches every single mouse press. I also tested the vanilla ImGui examples (https://github.com/ocornut/imgui) and they work perfectly.

This leads me to believe that there is some synchronization issue between the OF window detecting the mouse event and that event being passed down to the BaseEngine and other classes. A more forceful click lasts longer, so perhaps it is picked up over multiple frames and transmitted properly.

suport for textures without alpha

Hello,

I made some changes regarding loading textures for use in bottoms, so images don't need to have an alpha channel.

Best,
Andrei

BasEngine.h

// mode can be GL_RGB
GLuint loadTextureImage2D(unsigned char * pixels, int width, int height, int mode = GL_RGBA);

BaseEngine.cpp

GLuint BaseEngine::loadTextureImage2D(unsigned char * pixels, int width, int height, int mode)
{
GLint last_texture;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);

GLuint new_texture;
glGenTextures(1, &new_texture);
glBindTexture(GL_TEXTURE_2D, new_texture);
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,
             mode,
             width, height,
             0,
             mode,
             GL_UNSIGNED_BYTE,
             pixels
             );

glBindTexture(GL_TEXTURE_2D, last_texture);

return new_texture;

};

ofxImGui.cpp

GLuint ofxImGui::loadPixels(ofPixels& pixels)
{
return engine->loadTextureImage2D(pixels.getData(),
pixels.getWidth(),
pixels.getHeight(),
pixels.getBytesPerPixel() == 4 ? GL_RGBA : GL_RGB);
}

Shift + Letter Requires Long Hold

This issue is similar to #37. When typing in a textInput box, you have to hold Shift and a letter down for a longer than usual to get a capitalized letter. Similar result with Shift + Tab - holding Shift for a second and then pressing tab will result in the desired behavior.

I've looked at the code a bit but having figured out how to solve this issue. I tried adding

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];

to the BaseEngine::onKeyReleased function because I thought perhaps the Shift key wasn't being registered, but that didn't help.

As with issue #37, the opengl_example in the ImGui project demonstrates the desired behavior, so the issue must lie somewhere between OF and the functions in ofxImGui that pass the key events to ImGui.

Thoughts?

mouse rightbutton click not working on osx 10.9

Hey Jason,
Awesome addon! Just played with it for a while an I loved it.
I cant right clic to get contextual menus, edit colors, etc. although it happens to work with the mouse third button. I´m using an Apple mighty mouse. In the mouse status panel in the example it shows that it gets:
left mouse button as number 0, middle mouse button as number 1 and right mouse button as number 2 which sound fine for me. I'll try to dig deeper in order to get whats going on but maybe you know how to fix this.
All the best!

Design Approach

welcome @procedural !

One thing I am thinking design-wise is to move the ofAddListener stuff into setup() as opposed to the constructor.

A lot of times when I use GUIs is just to debug and the way it is now we are kinda strapped in with the constructor.

The other thing is just to use the ImGui namespace (at least in any examples/demos) unless the ui:: namespace has extra stuff. This way people can just copy and paste existing ImGui example code without have to change it.

how to use dynamic textures

Hi,
Im trying to use this addon to show dynamic images in the GUi. For this Im using the texture inside of an FBO. Not sure how i should link or bind the texture to resolve this.

Here is my code. Texture is visible in the Draw app but not inside the GUI. May be some of you know how to do it properly.
Cheers.

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    myFBO.allocate(255, 255);
    myGui.setup();
}

//--------------------------------------------------------------
void ofApp::update(){

    myFBO.begin();
    ofSetColor(255);
    ofRect(0, 0, 255, 255);
    ofSetColor(0);
    ofEllipse(ofVec2f(mouseX, mouseY), 10, 10);
    myFBO.end();

}

//--------------------------------------------------------------
void ofApp::draw(){

    ofSetColor(255);

    myFBO.draw(255, 255, 255, 255);

    //required to call this at beginning
    myGui.begin();

    ImGui::Text("Hello");
    ImGui::Image((ImTextureID)(uintptr_t)myFBO.getTexture().getTextureData().textureID, ImVec2(255, 255));

    //required to call this at end
    myGui.end();


}

Compilation error in project using ofxCv on Windows

In a project that also includes ofxCv, I get the following compilation error:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(936,5): warning MSB8027: Two or more files with the name of Helpers.cpp will produce outputs to the same location. This can lead to an incorrect build result.  The files involved are ..\..\..\addons\ofxCv\libs\ofxCv\src\Helpers.cpp, ..\..\..\addons\ofxImGui\src\Helpers.cpp.

I guess the error is pretty self-explanatory. MSVC can't handle the same filename existing twice in the same project and I indeed get a linker error later on.

The solution would be for either ofxCv or ofxImGui or both to rename Helpers.cpp/.h

See also the corresponding ofxCv issue.

Compile errors in QT (windows)

I am trying to compile the addon in MSYS2 but I got an strange linker error

addons/ofxImGui/libs/imgui/src/imgui.cpp:9190: undefined reference to 'ImmGetContext@4' addons/ofxImGui/libs/imgui/src/imgui.cpp:9196: undefined reference to 'ImmSetCompositionWindow@8'

Any idea of what could be causing that error? In QT/Linux works like a charm

Could not change fonts

I try to load a CJK font after gui.setup() :

void ofApp::setup()
{
ofSetLogLevel(OF_LOG_VERBOSE);
//required call
gui.setup();
ImGui::GetIO().MouseDrawCursor = false;
// Load Fonts
ImFontConfig font_config;
ImGuiIO& io = ImGui::GetIO();
//ImGui::PopFont();
if(io.Fonts->AddFontFromFileTTF("notosans.otf", 15.0f, &font_config, io.Fonts
->GetGlyphRangesChinese())){
std::cout<<"********* Font loaded!"<<std::endl;
}else{
std::cout<<"xxxxxxxxx Font failed to load!"<<std::endl;
}
// ......................

It seems that the font could be loaded, but the whole window texts remain the same as the original look. These code lines actually work well in the ImGui opengl demo examples.

And I try to load fonts in EngineGLFW.cpp:

bool EngineGLFW::createFontsTexture()
{
// Build texture atlas
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
io.Fonts->AddFontFromFileTTF("notosans.otf", 15.0f, &font_config, io.Fonts
->GetGlyphRangesChinese())
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
// .............

This time, it got crashed by a segmentation fault.

I also tried to load another Latin-based font like ProggyClean.ttf companied with ImGui, and the problem remains the same.

ctrl-c / ctrl-v clipboard callbacks never called on OSX

Hi, on OSX I can't have TextInput copy/paste working. Dunno if it's me but BaseEngine::getClipboardString() and BaseEngine::setClipboardString() are never called...

I tried with ctrl-c ctrl-v keys, also with cmd-c cmd-v keys (with io.ShortcutsUseSuperKey = true)

Using cmd-c or cmd-v erases the input's content and add a 'c' or a 'v'

Ubuntu 14.0.4 without programmable pipeline

Hey and thanks for making this OF ImGui wrapper! :D

I noticed a small issue using it on Ubuntu 14.0.4 : (in the demo and other apps using ofxImGui)
When I set FORCE_PROGRAMMABLE to 0, the ofApp shows it's normal graphical output, but the UI is completely invisible. Meanwhile the console logs that all shaders compiled correctly.

It could be a false alarm because I'm using the x.org Nouveau NVidia driver and I'm not able to switch it off as my hardware is broken with the official (proprietary) Nvidia driver.

So is this a bug or is it specifically related to my configuration ? (or rather an ImGui bug?)

Some system information:

  • [verbose] GL Version:3.3 (Core Profile) Mesa 10.5.9
  • uname -r 3.19.0.43-generic

retina support

Not sure if I've missed something, was trying to use this on a retina screen (Mac) with HighDPI enabled. Everything's really small. I found setting io.DisplayFramebufferScale to 2,2 makes everything bigger but still the mouse events happen in the wrong place. Any ideas?

ctrl key

I was trying to understand why CTRL + Click was not working on sliders, when I looked at BaseEngine. I think onKeyPressed should look like:

void BaseEngine::onKeyPressed(ofKeyEventArgs& event)
{
    if (event.key == OF_KEY_CONTROL) {
        io->KeyCtrl = true; // this makes ctrl + click work on sliders
    }
    else {
        int key = event.keycode;
        io->KeysDown[key] = true;
    }


    //io->AddInputCharacter((unsigned short)event.codepoint);
}

Best,
Andrei

Images

I'm trying to get images to work but no matter what I do, I only see the font texture. My guess is that it has something to do with the fontTexture.bind() in ofxImGui::renderDrawLists(). Any suggestions?

Thnaks :)

Please add ofColor conversion to IM_VEC4_CLASS_EXTRA in imconfig.h

This will allow for easy use of ImColor( ofColor()), etc...

Currently mine looks like this:

#define MyVec2 ofVec2f
#define MyVec4 ofVec4f
#define MyColor ofColor

#define IM_VEC2_CLASS_EXTRA                                                 \
ImVec2(const MyVec2& f) { x = f.x; y = f.y; }                       \
operator MyVec2() const { return MyVec2(x,y); }

#define IM_VEC4_CLASS_EXTRA                                                 \
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; }     \
operator MyVec4() const { return MyVec4(x,y,z,w); }   \
ImVec4(const MyColor& f) { float sc = 1.0f/255.0f; x = f.r*sc; y = f.g*sc ; z = f.b*sc; w = f.a*sc; }   \
operator MyColor() const { return MyColor((int) (x*255.0f+0.5f), (int) (y*255.0f+0.5f), (int) (z*255.0f+0.5f), (int) (w*255.0f+0.5f)); }

#define ImDrawIdx ofIndexType

ImGui::GetClipboardText() not working for win32

GetClipboardText() returns garbage.

Lines 49 & 50 of EngineGLFW replace the imgui clipboard functions with OF ones

		io.SetClipboardTextFn = &BaseEngine::setClipboardString;
		io.GetClipboardTextFn = &BaseEngine::getClipboardString;

But they don't work. I think it's because they return strings and char * is expected, but I can't quite see it.

These default functions are set up in imgui.cpp:

    GetClipboardTextFn = GetClipboardTextFn_DefaultImpl;   // Platform dependent default implementations
    SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;

If I comment out the two lines from EngineGLFW which override them everything then works well for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.