mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-14 21:48:30 +01:00
cimgui with glfw and opengl3 implementations
This commit is contained in:
1012
cimgui/cimgui.cpp
1012
cimgui/cimgui.cpp
File diff suppressed because it is too large
Load Diff
2373
cimgui/cimgui.h
2373
cimgui/cimgui.h
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,8 @@ typedef unsigned __int64 ImU64;
|
|||||||
typedef unsigned long long ImU64;
|
typedef unsigned long long ImU64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct GLFWwindow;
|
||||||
|
|
||||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||||
#include "imgui_structs.h"
|
#include "imgui_structs.h"
|
||||||
#endif // CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
#endif // CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||||
|
@@ -6,8 +6,9 @@ rem gcc -E -C -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS ../../imgui/imgui.h | luajit.e
|
|||||||
rem gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS ../../imgui/imgui.h | luajit.exe ./generator.lua > out.txt
|
rem gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS ../../imgui/imgui.h | luajit.exe ./generator.lua > out.txt
|
||||||
rem gcc -E -CC -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS ../../imgui/imgui.h > imgui_structs2.raw
|
rem gcc -E -CC -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS ../../imgui/imgui.h > imgui_structs2.raw
|
||||||
|
|
||||||
gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS ../../imgui/imgui.h > 1.txt
|
gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_APIX="" ../../imgui/imgui.h ../../imgui/examples/imgui_impl_glfw.h ../../imgui/examples/imgui_impl_opengl3.h > 1.txt
|
||||||
type 1.txt | luajit.exe ./generator.lua true > out.txt
|
|
||||||
|
type 1.txt | luajit.exe ./generator.lua true imgui imgui_impl_glfw imgui_impl_opengl3 > out.txt
|
||||||
|
|
||||||
rem gcc -E -C -traditional-cpp -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS ../../imgui/imgui.h > 1Ctra.txt
|
rem gcc -E -C -traditional-cpp -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS ../../imgui/imgui.h > 1Ctra.txt
|
||||||
rem type 1CTra.txt | luajit.exe ./generator.lua true > out.txt
|
rem type 1CTra.txt | luajit.exe ./generator.lua true > out.txt
|
||||||
|
@@ -2,8 +2,11 @@
|
|||||||
--script for auto_funcs.h and auto_funcs.cpp generation
|
--script for auto_funcs.h and auto_funcs.cpp generation
|
||||||
--expects Lua 5.1 or luajit
|
--expects Lua 5.1 or luajit
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
local script_args = {...}
|
||||||
|
local locations = {}
|
||||||
|
for i=2,#script_args do table.insert(locations,script_args[i]) end
|
||||||
-- first script argument to use gcc or not
|
-- first script argument to use gcc or not
|
||||||
local USEGCC = ({...})[1] == "true"
|
local USEGCC = script_args[1] == "true"
|
||||||
print("USEGCC",USEGCC)
|
print("USEGCC",USEGCC)
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
--this table has the functions to be skipped in generation
|
--this table has the functions to be skipped in generation
|
||||||
@@ -64,6 +67,8 @@ local function imguilines(file)
|
|||||||
end
|
end
|
||||||
-- skip
|
-- skip
|
||||||
elseif #iflevels == 0 then
|
elseif #iflevels == 0 then
|
||||||
|
-- drop IMGUI_APIX
|
||||||
|
line = line:gsub("IMGUI_APIX","")
|
||||||
-- drop IMGUI_API
|
-- drop IMGUI_API
|
||||||
line = line:gsub("IMGUI_API","")
|
line = line:gsub("IMGUI_API","")
|
||||||
return line
|
return line
|
||||||
@@ -73,9 +78,12 @@ local function imguilines(file)
|
|||||||
return location_it
|
return location_it
|
||||||
end
|
end
|
||||||
--iterates lines from a gcc -E in a specific location
|
--iterates lines from a gcc -E in a specific location
|
||||||
local function location(file,locpath)
|
local function location(file,locpathT)
|
||||||
local location_re = '^# %d+ "([^"]*)"'
|
local location_re = '^# %d+ "([^"]*)"'
|
||||||
local path_re = '^(.*[\\/])('..locpath..')%.h$'
|
local path_reT = {}
|
||||||
|
for i,locpath in ipairs(locpathT) do
|
||||||
|
table.insert(path_reT,'^(.*[\\/])('..locpath..')%.h$')
|
||||||
|
end
|
||||||
local in_location = false
|
local in_location = false
|
||||||
local function location_it()
|
local function location_it()
|
||||||
repeat
|
repeat
|
||||||
@@ -85,9 +93,10 @@ local function location(file,locpath)
|
|||||||
-- Is this a location pragma?
|
-- Is this a location pragma?
|
||||||
local location_match = line:match(location_re)
|
local location_match = line:match(location_re)
|
||||||
if location_match then
|
if location_match then
|
||||||
-- If we are transitioning to a header we need to parse, set the flag
|
in_location = false
|
||||||
local path_match,aaa = location_match:match(path_re)
|
for i,path_re in ipairs(path_reT) do
|
||||||
in_location = (path_match ~= nil)
|
if location_match:match(path_re) then in_location = true; break end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif in_location then
|
elseif in_location then
|
||||||
return line
|
return line
|
||||||
@@ -156,6 +165,7 @@ local function get_manuals(def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function getcimguiname(stname,funcname)
|
local function getcimguiname(stname,funcname)
|
||||||
|
if #stname == 0 then return funcname end --top level
|
||||||
local pre = (stname == "ImGui") and "ig" or stname.."_"
|
local pre = (stname == "ImGui") and "ig" or stname.."_"
|
||||||
return pre..funcname
|
return pre..funcname
|
||||||
end
|
end
|
||||||
@@ -414,7 +424,8 @@ local function func_parser()
|
|||||||
local defT = defsT[cimguiname][#defsT[cimguiname]]
|
local defT = defsT[cimguiname][#defsT[cimguiname]]
|
||||||
defT.defaults = {}
|
defT.defaults = {}
|
||||||
--for k,def in args:gmatch("([%w%s%*_]+)=([%w_%(%)%s,%*]+)[,%)]") do
|
--for k,def in args:gmatch("([%w%s%*_]+)=([%w_%(%)%s,%*]+)[,%)]") do
|
||||||
for k,def in args:gmatch("([%w_]+)=([%w_%(%)%s,%*%.%-]+)[,%)]") do
|
--for k,def in args:gmatch("([%w_]+)=([%w_%(%)%s,%*%.%-]+)[,%)]") do
|
||||||
|
for k,def in args:gmatch('([%w_]+)=([%w_%(%)%s,%*%.%-%%"]+)[,%)]') do
|
||||||
defT.defaults[k]=def
|
defT.defaults[k]=def
|
||||||
end
|
end
|
||||||
defT.cimguiname = cimguiname
|
defT.cimguiname = cimguiname
|
||||||
@@ -605,7 +616,7 @@ local function func_header_generate(FP)
|
|||||||
local manual = get_manuals(def)
|
local manual = get_manuals(def)
|
||||||
if not manual and def.ret then --not constructor
|
if not manual and def.ret then --not constructor
|
||||||
local addcoment = def.comment or ""
|
local addcoment = def.comment or ""
|
||||||
if def.stname == "ImGui" then
|
if def.stname == "ImGui" or def.stname == "" then --ImGui namespace or top level
|
||||||
table.insert(outtab,"CIMGUI_API".." "..def.ret.." "..(def.ov_cimguiname or def.cimguiname)..def.args..";"..addcoment.."\n")
|
table.insert(outtab,"CIMGUI_API".." "..def.ret.." "..(def.ov_cimguiname or def.cimguiname)..def.args..";"..addcoment.."\n")
|
||||||
else
|
else
|
||||||
local empty = def.args:match("^%(%)") --no args
|
local empty = def.args:match("^%(%)") --no args
|
||||||
@@ -626,7 +637,7 @@ local function func_implementation(FP)
|
|||||||
local cimf = FP.defsT[t.cimguiname]
|
local cimf = FP.defsT[t.cimguiname]
|
||||||
local def = cimf[t.signature]
|
local def = cimf[t.signature]
|
||||||
local manual = get_manuals(def)
|
local manual = get_manuals(def)
|
||||||
if not manual and def.ret then --not constructor
|
if not manual and def.ret and def.stname~="" then --not constructor or manual or top level
|
||||||
local ptret = def.retref and "&" or ""
|
local ptret = def.retref and "&" or ""
|
||||||
-- local castret = def.ret:gsub("[^%s]+",function(x)
|
-- local castret = def.ret:gsub("[^%s]+",function(x)
|
||||||
-- local y = x:gsub("%*","")
|
-- local y = x:gsub("%*","")
|
||||||
@@ -688,7 +699,7 @@ local iterator = (USEGCC and location) or imguilines
|
|||||||
print("iterator",iterator)
|
print("iterator",iterator)
|
||||||
print(location, imguilines)
|
print(location, imguilines)
|
||||||
|
|
||||||
for line in iterator(io.input(),"imgui") do
|
for line in iterator(io.input(),locations) do
|
||||||
local line, comment = split_comment(line)
|
local line, comment = split_comment(line)
|
||||||
STP.insert(line,comment)
|
STP.insert(line,comment)
|
||||||
FP.insert(line,comment)
|
FP.insert(line,comment)
|
||||||
|
@@ -2,7 +2,8 @@ rem this is used to rebuild imgui_structs.h
|
|||||||
rem set your PATH if necessary for gcc and lua with:
|
rem set your PATH if necessary for gcc and lua with:
|
||||||
set PATH=%PATH%;C:\luaGL;
|
set PATH=%PATH%;C:\luaGL;
|
||||||
|
|
||||||
type ..\..\imgui\imgui.h | luajit.exe ./generator.lua false > out.txt
|
rem type ..\..\imgui\imgui.h | luajit.exe ./generator.lua false > out.txt
|
||||||
|
type ..\..\imgui\imgui.h ..\..\imgui\examples\imgui_impl_glfw.h ..\..\imgui\examples\imgui_impl_opengl3.h | luajit.exe ./generator.lua false > out.txt
|
||||||
|
|
||||||
cmd /k
|
cmd /k
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user