def init():

    C = blender.CTX_create()
    print(C, dir(C))

    blender.BLI_threadapi_init()
    blender.RNA_init()
    blender.RE_engines_init()
    #blender.pluginapi_force_ref()
    blender.init_nodesystem()
    blender.initglobals()
    blender.IMB_init()
    #syshandle = blender.SYS_GetSystem()
    #blender.GEN_init_messaging_system()
    ba = blender.BLI_argsInit(argc, argv)
    #blender.setupArguments(C, ba, syshandle)
    blender.BLI_argsParse(ba, 1, None,
                          None)  # required, segfaults without this
    blender.sound_init_once()
    blender.init_def_material()

    C.wm_ghost_init()

    C.WM_init(argc, argv)
def init():


	C = blender.CTX_create()
	print( C, dir(C) )

	blender.BLI_threadapi_init()
	blender.RNA_init()
	blender.RE_engines_init()
	#blender.pluginapi_force_ref()
	blender.init_nodesystem()
	blender.initglobals()
	blender.IMB_init()
	#syshandle = blender.SYS_GetSystem()
	#blender.GEN_init_messaging_system()
	ba = blender.BLI_argsInit(argc, argv)
	#blender.setupArguments(C, ba, syshandle)
	blender.BLI_argsParse(ba, 1, None, None)  # required, segfaults without this
	blender.sound_init_once()
	blender.init_def_material()

	C.wm_ghost_init()

	C.WM_init( argc, argv )
Beispiel #3
0
def main():
	print('py main...')
	syshandle = 0
	C = blender.CTX_create()
	print( C )
	ba = blender.bArgs()
	#setCallbacks()
	#bprogname = os.path.join( os.path.abspath('.'), 'blender' )
	#blender.BLI_where_am_i(bprogname, len(bprogname), 'blender')		# SEGFAULTS, not important?

	blender.BLI_threadapi_init()
	blender.RNA_init()
	blender.RE_engines_init()
	blender.pluginapi_force_ref()	# deprecated?
	blender.init_nodesystem()
	blender.initglobals()			#/* blender.c */
	blender.IMB_init()
	blender.BLI_cb_init()
	#if with game engine: syshandle = blender.SYS_GetSystem()
	blender.BLI_argsParse(ba, 1, None, None)  # required, segfaults without this


	_argv = ''
	for arg in sys.argv: _argv += arg + ' '
	_argv = bytes( _argv, 'utf-8' )
	argc = len(sys.argv)
	argv = ctypes.pointer(ctypes.c_char_p(_argv))
	ba = blender.BLI_argsInit(argc, argv)
	#blender.setupArguments(C, ba, syshandle)	# missing

	print('BKE font register builtin...')
	bfont = ctypes.cast(
		blender.CTYPES_DLL.datatoc_Bfont, ctypes.POINTER(ctypes.c_void_p)
	)
	bfontsize = ctypes.cast(
		blender.CTYPES_DLL.datatoc_Bfont_size, ctypes.POINTER(ctypes.c_int)
	).contents
	print(bfontsize)

	blender.BKE_font_register_builtin(
		bfont, 
		bfontsize
	)
	blender.BLI_argsParse(ba, 1, None, None)  # required, segfaults without this

	blender.sound_init_once()
	blender.init_def_material()

	blender.BLI_argsParse(ba, 2, None, None)
	blender.BLI_argsParse(ba, 3, None, None)
	print('wm init....')
	#blender.WM_init(C, argc, argv)		# opens a window and then SEGFAULTS
	WM_init( C, argc, argv )				# no segfault, but no window appears, missing something??
	print('-----------wm init ok-------------')

	#blender.BLI_where_is_temp(btempdir, FILE_MAX, 1); /* call after loading the startup.blend so we can read U.tempdir */

	#blender.CTX_py_init_set(C, 1)		# is this safe to call?
	print('keymap init...')
	blender.WM_keymap_init( C )

	#/* OK we are ready for it */
	#BLI_argsParse(ba, 4, load_file, C);
	#BLI_argsFree(ba);
	print('wm init splash...')
	blender.WM_init_splash(C)
	#blender.WM_main(C)
	print('WM main...')
	WM_main(C)
	print('test complete')