13# ifdef WIN32_LEAN_AND_MEAN
14# undef WIN32_LEAN_AND_MEAN
19# pragma comment(linker, "/include:cpu_check_win32")
23#if defined(WITH_TBB_MALLOC) && defined(_MSC_VER) && defined(NDEBUG)
24# pragma comment(lib, "tbbmalloc_proxy.lib")
25# pragma comment(linker, "/include:__TBB_malloc_proxy")
61#ifndef WITH_PYTHON_MODULE
86#ifdef WITH_OPENGL_BACKEND
97# include <floatingpoint.h>
101# include "binreloc.h"
112#if defined(WITH_PYTHON_MODULE) && defined(__APPLE__)
114# include <crt_externs.h>
115char **environ =
nullptr;
118#if defined(WITH_TBB_MALLOC) && defined(__linux__)
119# include <tbb/scalable_allocator.h>
130#if (defined(WITH_TBB_MALLOC) && defined(_MSC_VER) && defined(NDEBUG) && defined(WITH_GMP)) || \
133# include "tbb/scalable_allocator.h"
137 return scalable_malloc(
size);
141 return scalable_realloc(ptr, new_size);
168#if defined(WIN32) && !defined(WITH_PYTHON_MODULE)
169# define USE_WIN32_UNICODE_ARGS
201 fputs(errorStr, stderr);
218#ifndef WITH_PYTHON_MODULE
222#ifdef USE_WIN32_UNICODE_ARGS
238#ifndef WITH_PYTHON_MODULE
239 if (app_init_data->
ba) {
241 app_init_data->
ba =
nullptr;
245#ifdef USE_WIN32_UNICODE_ARGS
246 if (app_init_data->argv) {
247 while (app_init_data->argv_num) {
248 free((
void *)app_init_data->argv[--app_init_data->argv_num]);
250 free((
void *)app_init_data->argv);
251 app_init_data->argv =
nullptr;
297#ifdef WITH_PYTHON_MODULE
298static void *main_python_evil_C =
nullptr;
301int main_python_enter(
int argc,
const char **argv);
303void main_python_exit()
305 WM_exit_ex((bContext *)main_python_evil_C,
true,
false);
306 main_python_evil_C =
nullptr;
310# define main blender::main_python_enter
321#if defined(__APPLE__)
333#ifdef USE_WIN32_UNICODE_ARGS
343#ifndef WITH_PYTHON_MODULE
352 app_init_data.
early_exit = &app_init_data_early_exit;
360 setvbuf(stdout,
nullptr, _IONBF, 0);
371# ifdef USE_WIN32_UNICODE_ARGS
376 wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
377 app_init_data.argv =
static_cast<char **
>(malloc(argc *
sizeof(
char *)));
378 for (
int i = 0; i < argc; i++) {
384 app_init_data.argv_num = argc;
386 const char **argv =
const_cast<const char **
>(app_init_data.argv);
390#if defined(WITH_OPENGL_BACKEND) && BLI_SUBPROCESS_SUPPORT
391 if (
STREQ(argv[0],
"--compilation-subprocess")) {
393 GPU_compilation_subprocess_run(argv[1]);
398#if defined(WITH_TBB_MALLOC) && defined(__linux__)
400 scalable_allocation_mode(TBBMALLOC_USE_HUGE_PAGES, 1);
409 for (i = 0; i < argc; i++) {
410 if (
STR_ELEM(argv[i],
"-d",
"--debug",
"--debug-memory",
"--debug-all")) {
411 printf(
"Switching to fully guarded memory allocator.\n");
415 if (
STR_ELEM(argv[i],
"--",
"-c",
"--command")) {
425 const tm *tm = gmtime(&temp_time);
431 const char *unknown =
"date-unknown";
448 app_init_data_early_exit.
C =
C;
450#ifdef WITH_PYTHON_MODULE
452 environ = *_NSGetEnviron();
456 main_python_evil_C =
C;
467#if defined(WITH_TBB_MALLOC) && defined(_MSC_VER) && defined(NDEBUG) && defined(WITH_GMP)
473#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE) && !defined(WITH_HEADLESS)
475 if (argc == 2 &&
STRPREFIX(argv[1],
"-psn_")) {
476 static char firstfilebuf[512];
482 argv[1] = firstfilebuf;
511#ifndef WITH_PYTHON_MODULE
515 app_init_data.
ba = ba;
524 G.factory_startup =
true;
535#ifdef WITH_PYTHON_MODULE
536 const bool use_flush_denormals_to_zero =
false;
538 const bool use_flush_denormals_to_zero =
true;
545#ifndef WITH_PYTHON_MODULE
588#if defined(WITH_PYTHON_MODULE) || defined(WITH_HEADLESS)
608#ifndef WITH_PYTHON_MODULE
609 if (
G.background == 0) {
620 "WARNING: Blender compiled without Python!\n"
621 "This is not intended for typical usage.\n"
632#ifndef WITH_PYTHON_MODULE
645#ifndef WITH_PYTHON_MODULE
650#ifdef USE_WIN32_UNICODE_ARGS
655#ifndef WITH_PYTHON_MODULE
663 exit_code =
G.is_break ? EXIT_FAILURE : EXIT_SUCCESS;
General operations, lookup, etc. for materials.
A general argument parsing module.
void CLG_output_use_basename_set(int value)
void CLG_output_use_memory_set(int value)
void CLG_output_use_source_set(int value)
void CLG_fatal_fn_set(void(*fatal_fn)(void *file_handle))
void CLG_output_use_timestamp_set(int value)
blenloader genfile private function prototypes
const char datatoc_bfont_pfb[]
int datatoc_bfont_pfb_size
int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define BLI_STATIC_ASSERT(a, msg)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
ulong build_commit_timestamp
void * gmp_realloc(void *ptr, size_t, size_t new_size)
void * gmp_alloc(size_t size)
void gmp_free(void *ptr, size_t)
void gmp_blender_init_allocator()
void MEM_init_memleak_detection()
void libmv_initLogging(const char *argv0)
void MEM_use_guarded_allocator()
void free(Subdiv *subdiv)
void register_common_functions()
void BKE_sound_force_device(const char *device)
void BLI_args_destroy(struct bArgs *ba)
void DEG_free_node_types()
int main_arg_deferred_handle()
char * STRNCPY(char(&dst)[N], const char *src)
void BKE_brush_system_init()
void BKE_blender_globals_init()
void RE_texture_rng_init()
void WM_main(bContext *C)
void WM_exit_ex(bContext *C, const bool do_python_exit, const bool do_user_exit_actions)
void WM_exit(bContext *C, const int exit_code)
void main_signal_setup(void)
void BKE_sound_init_once()
void BKE_blender_atexit_unregister(void(*func)(void *user_data), const void *user_data)
void WM_init(bContext *C, int argc, const char **argv)
void WM_init_splash_on_startup(bContext *C)
int main_args_handle_load_file(int, const char **argv, void *data)
void BLI_system_max_open_files_ensure()
void BLI_setenv(const char *env, const char *val) ATTR_NONNULL(1)
void BLI_threadapi_init()
static void callback_main_atexit(void *user_data)
ApplicationState app_state
void FRS_set_context(struct bContext *C)
void CCL_implicit_sharing_init()
void main_signal_setup_background(void)
static void callback_clg_fatal(void *fp)
static void main_callback_setup()
static void restore_ld_preload()
void main_arg_deferred_free()
void BKE_materials_init()
void CTX_free(bContext *C)
static void callback_mem_error(const char *errorStr)
void main_args_setup(bContext *C, bArgs *ba, bool all)
void(*) MEM_set_error_callback(void(*func)(const char *))
void BLI_setenv_if_new(const char *env, const char *val) ATTR_NONNULL(1)
void BKE_appdir_program_path_init(const char *argv0) ATTR_NONNULL(1)
void BLI_system_backtrace(FILE *fp)
void BKE_vfont_builtin_register(const void *mem, int size)
void BKE_blender_globals_clear()
void BKE_cpp_types_init()
void DEG_register_node_types()
void BLI_task_scheduler_init(bool use_flush_denormals_to_zero=true)
void BKE_particle_init_rng()
struct bArgs * BLI_args_create(int argc, const char **argv)
void BKE_callback_global_init()
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
@ ARG_PASS_SETTINGS_FORCE
void BKE_blender_atexit_register(void(*func)(void *user_data), void *user_data)
void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
struct BA_ArgCallback_Deferred * main_arg_deferred
struct blender::ApplicationState::@204252132227047363156276311014221143207211224327 exit_code_on_error
struct blender::ApplicationState::@015013240256342036154333030232065173037361052222 signal
CreatorAtExitData_EarlyExit * early_exit
char * alloc_utf_8_from_16(const wchar_t *in16, size_t add)