ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
60.8k stars 10.27k forks source link

NullReferenceException in ImGui_ImplDX11_CreateFontsTexture #1377

Closed sarwar-r87 closed 7 years ago

sarwar-r87 commented 7 years ago

I have a rather strange problem, I am trying to make a DLL for DX overlay, where I inject a DLL into an application, spawn a window and draw on it. so i copies the .h and .cpp files to a different project, with no modifications. the problem is, i get the following errors:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at ImFontAtlas.GetTexDataAsRGBA32(ImFontAtlas* , Byte** out_pixels, Int32* out_width, Int32* out_height, Int32* out_bytes_per_pixel)
   at ?A0x89b026d9.ImGui_ImplDX11_CreateFontsTexture()
   at ImGui_ImplDX11_CreateDeviceObjects()
   at ImGui_ImplDX11_NewFrame()

here is the code in the project: https://pastebin.com/5rdZuTra

Here are the compiler flags

 /GS /GL /W0 /Gy /Zc:wchar_t /I"Include" /I"C:\Users\fsdfdsf\Documents\Visual Studio 2017\Projects\test\DirectXTK\Inc" /I"C:\Users\fsdfdsf\Documents\Visual Studio 2017\Projects\test\dxsdk-master\Include" /Zi /O2 /sdl /Fd"x64\Release\vc141.pdb" /Zc:inline /fp:precise /D "NDEBUG" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /clr /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Drawing.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Windows.Forms.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" /Oi /MD /Fa"x64\Release\" /EHa /nologo /Fo"x64\Release\" /Ot /Fp"x64\Release\DLL.pch" /diagnostics:classic 

   /OUT:"C:\...." /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"C:\Users\fsdfdsf\Documents\Visual Studio 2017\Projects\test\x64\Release\DLL.pdb" /DYNAMICBASE "dwmapi.lib" "glew32s.lib" "glew32.lib" "detours.lib" "opengl32.lib" "glfw3.lib" "d3d11.lib" "d3dcompiler.lib" "dxgi.lib" "imm32.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /FIXED:NO /DLL /MACHINE:X64 /OPT:REF /PGD:"C:\Users\fsdfdsf\Documents\Visual Studio 2017\Projects\battlefield\BF1C++Internal2\x64\Release\DLL.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\DLL.dll.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1 

Thank you for your help!

Cheers

ocornut commented 7 years ago

Sorry, I won't provide support for dll injection/cheaters, too many people in that community are asking and not doing basic homework or providing the right infos.

Try to find out which pointer is NULL and why. And see if your global instances are properly constructed.