CIMGUI Wrapper Help

new topic     » topic index » view thread      » older message » newer message

Hello,

I am trying to get a basic example going, but can't figure out how to wrap this one part.

Wrapper code

 
--I have the flags defined and such, I'm only posting some of the wrapper code, I can post more if needed. 
 
public atom gui = 0 
 
ifdef WINDOWS then 
	gui = open_dll("cimgui.dll") 
	elsifdef LINUX or FREEBSD then 
	gui = open_dll("libcimgui.so") 
	elsifdef OSX then 
	gui = open_dll("libcimgui.dylib") 
end ifdef 
 
if gui = -1 then 
	puts(1,"Failed to load cimgui shared library!\n") 
	abort(0) 
end if 
 
public constant ImGuiIO = define_c_struct({ 
	C_INT, --ConfigFlags 
	C_INT, --BackendFlags 
	IMVEC2, --DisplaySize 
	C_FLOAT, --DeltaTime 
	C_FLOAT, --IniSavingRate 
	C_STRING, --IniFilename 
	C_STRING, --LogFilename 
	C_FLOAT, --MouseDoubleClickTime, 
	C_FLOAT, --MouseDoubleClickMaxDist 
	C_FLOAT, --MouseDragThreshold 
	C_FLOAT, --KeyRepeatDelay 
	C_FLOAT, --KeyRepeatRate 
	C_FLOAT, --HoverDelayNormal 
	C_FLOAT, --HoverDelayShort 
	C_POINTER, --UserData 
	C_POINTER, --Fonts 
	C_FLOAT, --FontGlobalScale 
	C_BOOL, --FontAllowUserScaling 
	C_POINTER, --FontDefault 
	IMVEC2, --DisplayFramebufferScale 
	C_BOOL, --ConfigDockingNoSplit 
	C_BOOL, --ConfigDockingWithShift 
	C_BOOL, --ConfigDockingAlwaysTabBar, 
	C_BOOL, --ConfigDockingTransparentPayload 
	C_BOOL, --ConfigViewportsNoAutoMerge 
	C_BOOL, --ConfigViewportsNoTaskBarIcon 
	C_BOOL, --ConfigViewportsNoDecoration 
	C_BOOL, --ConfigViewportsNoDefaultParent, 
	C_BOOL, --MouseDrawCursor 
	C_BOOL, --ConfigMacOSXBehaviors 
	C_BOOL, --ConfigInputTrickleEventQueue 
	C_BOOL, --ConfigInputTextCursorBlink 
	C_BOOL, --ConfigInputTextEnterKeepActive 
	C_BOOL, --ConfigDragClickToInputText 
	C_BOOL, --ConfigWindowResizeFromEdges 
	C_BOOL, --ConfigWindowsMoveFromTitleBarOnly 
	C_FLOAT, --ConfigMemoryCompactTimer 
	C_BOOL, --ConfigDebugBeginReturnValueOnce 
	C_BOOL, --ConfigDebugBeginReturnValueLoop 
	C_STRING, --BackendPlatformName 
	C_STRING, --BackendRenderName 
	C_POINTER, --BackendPlatformUserData 
	C_POINTER, --BackendRendererUserData 
	C_POINTER, --BackendLanguageUserData 
	C_STRING, --GetClipardTextFn 
	C_POINTER, --SetClipboardTextFn 
	C_POINTER, --ClipboardUserData 
	C_POINTER, --SetplatFromImeDataFn 
	C_POINTER, --UnusedPadding 
	C_BOOL, --WantCaptureMouse 
	C_BOOL, --WantCaptureKeyboard 
	C_BOOL, --WantTextInput 
	C_BOOL, --WantSetMousePos 
	C_BOOL, --WantSaveIniSettings 
	C_BOOL, --NavActive 
	C_BOOL, --NavVisible 
	C_FLOAT, --Framerate 
	C_INT, --MetricsRenderVertices 
	C_INT, --MetricsRenderIndices 
	C_INT, --MetricsRenderWindows 
	C_INT, --MetricsActiveWindows 
	C_INT, --MetricsActiveAllocations 
	IMVEC2, --MouseDelta 
	{C_INT,ImGuiKey_COUNT}, --KeyMap 
	{C_BOOL,ImGuiKey_COUNT}, --KeysDown 
	{C_FLOAT,ImGuiNavInput_COUNT}, --NavInputs 
	C_POINTER, --Ctx 
	IMVEC2, --MousePos 
	{C_BOOL,5}, --MouseDown[5] 
	C_FLOAT, --MouseWheel 
	C_FLOAT, --MouseWheelH 
	C_INT, --MouseSource ImGuiMouseSource 
	C_INT, --MousehoveredViewport ImGuiID 
	C_BOOL, --KeyCtrl 
	C_BOOL, --KeyShift 
	C_BOOL, --KeyAlt 
	C_BOOL, --KeySuper 
	C_INT, --KeyMods ImGuiKeyChord 
	{C_INT,ImGuiKey_KeysData_SIZE}, --ImGuiKeyData 
	C_BOOL, --WantCaptureMouseUnlessPopupClose 
	IMVEC2, --MousePosPrev 
	{IMVEC2,5}, --MouseClickPos[5] 
	{C_DOUBLE,5}, --MouseClickedTime[5] 
	{C_BOOL,5}, --MouseClicked[5] 
	{C_BOOL,5}, --MouseDoubleClicked[5] 
	{C_UINT16,5}, --MouseClickedCount[5] 
	{C_UINT16,5}, --MouseClickedLastCount[5] 
	{C_BOOL,5}, --MouseReleased[5] 
	{C_BOOL,5}, --MouseDownOwned[5] 
	{C_BOOL,5}, --MouseDownOwnedUnlessPopupClose[5] 
	C_BOOL, --MouseWheelRequestAxisSwap 
	{C_FLOAT,5}, --MouseDownDuration[5] 
	{C_FLOAT,5}, --MouseDownDurationPrev[5] 
	{IMVEC2,5}, --MouseDragMaxDistanceAbs[5] 
	{C_FLOAT,5}, --MouseDragMiaxDistanceSqr[5] 
	C_FLOAT, --PenPressure 
	C_BOOL, --AppFocusLost 
	C_BOOL, --AppAcceptringEvents 
	C_INT8, --BackendUsingLegacyKeyArrays 
	C_BOOL, --BacendUsingLEgacyNavInputArray 
	C_INT16, --InputQueueSurrogate 
	ImVector_ImWchar --InputQueueCharacters 
}) 
 
export constant xImVec2_ImVec2_Nil = define_c_func(gui,"+ImVec2_ImVec2_Nil",{},C_POINTER) 
 
public function ImVec2_ImVec2_Nil() 
	return c_func(xImVec2_ImVec2_Nil,{}) 
end function 
 
export constant xImVec2_destroy = define_c_proc(gui,"+ImVec2_destroy",{C_POINTER}) 
 
public procedure ImVec2_destroy(atom self) 
	c_proc(xImVec2_destroy,{self}) 
end procedure 
 
export constant xImVec2_ImVec2_Float = define_c_func(gui,"+ImVec2_ImVec2_Float",{C_FLOAT,C_FLOAT},C_POINTER) 
 
public function ImVec2_ImVec2_Float(atom x,atom y) 
	return c_func(xImVec2_ImVec2_Float,{x,y}) 
end function 
 
public constant xigCreateContext = define_c_func(gui,"+igCreateContext",{C_POINTER},C_POINTER) 
 
public function igCreateContext(atom shared_font_atlas) 
	return c_func(xigCreateContext,{shared_font_atlas}) 
end function 
 
public constant xigDestroyContext = define_c_proc(gui,"+igDestroyContext",{C_POINTER}) 
 
public procedure igDestroyContext(atom ctx) 
	c_proc(xigDestroyContext,{ctx}) 
end procedure 
 
public constant xigGetCurrentContext = define_c_func(gui,"+igGetCurrentContext",{},C_POINTER) 
 
public function igGetCurrentContext() 
	return c_func(xigGetCurrentContext,{}) 
end function 
 
public constant xigGetIO = define_c_func(gui,"+igGetIO",{},C_POINTER) 
 
public function igGetIO() 
	return c_func(xigGetIO,{}) 
end function 
 
public constant xigNewFrame = define_c_proc(gui,"+igNewFrame",{}) 
 
public procedure igNewFrame() 
	c_proc(xigNewFrame,{}) 
end procedure 
 
public constant xigEndFrame = define_c_proc(gui,"+EndFrame",{}) 
 
public procedure igEndFrame() 
	c_proc(xigEndFrame,{}) 
end procedure 
 
public constant xigRender = define_c_proc(gui,"+igRender",{}) 
 
public procedure igRender() 
	c_proc(xigRender,{}) 
end procedure 
 
public constant xigShowDemoWindow = define_c_proc(gui,"+igShowDemoWindow",{C_POINTER}) 
 
public procedure igShowDemoWindow(atom p_open) 
	 c_proc(xigShowDemoWindow,{p_open}) 
end procedure 
 
public constant xigGetVersion = define_c_func(gui,"+igGetVersion",{},C_STRING) 
 
public function igGetVersion() 
	return c_func(xigGetVersion,{}) 
end function 
 
public constant xigBegin = define_c_func(gui,"+igBegin",{C_STRING,C_POINTER,C_INT},C_BOOL) 
 
public function igBegin(sequence name,atom p_open,atom flags) 
	return c_func(xigBegin,{name,p_open,flags}) 
end function 
 
public constant xigEnd = define_c_proc(gui,"+igEnd",{}) 
 
public procedure igEnd() 
	c_proc(xigEnd,{}) 
end procedure 
 
public constant xigText = define_c_proc(gui,"+igText",{C_STRING}) 
 
public procedure igText(sequence fmt) 
	c_proc(xigText,{fmt}) 
end procedure 

Part of example I'm trying to wrap is here: https://github.com/cimgui/cimgui/blob/docking_inter/test/main.c

Structs here: https://github.com/cimgui/cimgui/blob/docking_inter/cimgui.h

//Part of the ImGuiIO struct 
struct ImGuiIO 
{ 
    ImGuiConfigFlags ConfigFlags; 
    ImGuiBackendFlags BackendFlags; 
    ImVec2 DisplaySize; 
} 

  ImVec2 display_size; 
    display_size.x = 1920; 
    display_size.y = 1080; 
    io->DisplaySize = display_size; 
 
Trying to convert this part into Euphoria code using allocate_struct and peek_struct is where I'm kinda stumped 

I'm just trying to get a basic frame showing.

5/28/23 - Updated demo. No errors, but nothing comes up.

include std/ffi.e 
include std/machine.e 
 
include cimgui.e 
 
procedure main() 
 
	igCreateContext(NULL) 
	 
	atom io = igGetIO() 
	 
	atom x = 800 
	atom y = 600 
	atom vec_size = ImVec2_ImVec2_Float(x,y) 
	 
	--frame needs size or error comes up 
	atom io_s = allocate_struct(ImGuiIO) 
	atom size = peek_struct(io,vec_size) 
 
	igNewFrame() 
 
	igBegin("MainWin",NULL,ImGuiWindowFlags_NoTitleBar) 
	 
	igText("Hello World") 
	 
	igEnd() 
	 
	igShowDemoWindow(NULL) 
	 
	igRender() 
	 
	igDestroyContext(NULL) 
end procedure 
 
main() 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu