4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2007 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
33 #include "MEM_guardedalloc.h"
34 #include "MEM_CacheLimiterC-Api.h"
36 #include "IMB_imbuf_types.h"
37 #include "IMB_imbuf.h"
39 #include "DNA_object_types.h"
40 #include "DNA_scene_types.h"
41 #include "DNA_sound_types.h"
42 #include "DNA_userdef_types.h"
43 #include "DNA_windowmanager_types.h"
45 #include "BKE_blender.h"
46 #include "BKE_curve.h"
47 #include "BKE_displist.h"
48 #include "BKE_DerivedMesh.h"
50 #include "BKE_global.h"
51 #include "BKE_library.h"
52 #include "BKE_mball.h"
53 #include "BKE_utildefines.h"
54 #include "BKE_packedFile.h"
61 #include "BLI_blenlib.h"
63 #include "RE_pipeline.h" /* RE_ free stuff */
67 #include "BPY_extern.h"
69 #include "SYS_System.h"
75 #include "wm_window.h"
77 static void initbuttons(void)
79 // uiDefFont(UI_HELVB,
80 // BMF_GetFont(BMF_kHelveticaBold14),
81 // BMF_GetFont(BMF_kHelveticaBold12),
82 // BMF_GetFont(BMF_kHelveticaBold10),
83 // BMF_GetFont(BMF_kHelveticaBold8));
85 // BMF_GetFont(BMF_kHelvetica12),
86 // BMF_GetFont(BMF_kHelvetica12),
87 // BMF_GetFont(BMF_kHelvetica10),
88 // BMF_GetFont(BMF_kHelveticaBold8));
90 // glClearColor(.7f, .7f, .6f, 0.0);
92 G.font= BMF_GetFont(BMF_kHelvetica12);
93 G.fonts= BMF_GetFont(BMF_kHelvetica10);
94 G.fontss= BMF_GetFont(BMF_kHelveticaBold8);
96 // clear_matcopybuf(); /* XXX */
98 // glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
102 static void sound_init_listener(void)
104 G.listener = MEM_callocN(sizeof(bSoundListener), "soundlistener");
105 G.listener->gain = 1.0;
106 G.listener->dopplerfactor = 1.0;
107 G.listener->dopplervelocity = 340.29f;
110 /* only called once, for startup */
111 void WM_init(bContext *C)
114 wm_ghost_init(C); /* note: it assigns C to ghost! */
115 wm_operatortype_init();
117 set_free_windowmanager_cb(wm_close_and_free); /* library.c */
119 /* get the default database, plus a wm */
120 WM_read_homefile(C, 0);
122 wm_check(C); /* opens window(s), checks keymaps */
124 // initscreen(); /* for (visual) speed, this first, then setscreen */
127 sound_init_listener();
128 // init_node_butfuncs();
130 // XXX BIF_preview_init_dbase();
133 // XXX BIF_resources_init(); /* after homefile, to dynamically load an icon file based on theme settings */
135 // XXX BIF_filelist_init_icons();
137 // init_gl_stuff(); /* drawview.c, after homefile */
139 BLI_strncpy(G.lib, G.sce, FILE_MAX);
142 /* free strings of open recent files */
143 static void free_openrecent(void)
145 struct RecentFile *recent;
147 for(recent = G.recent_files.first; recent; recent=recent->next)
148 MEM_freeN(recent->filename);
150 BLI_freelistN(&(G.recent_files));
156 extern ListBase editNurb;
157 extern ListBase editelems;
158 extern wchar_t *copybuf;
159 extern wchar_t *copybufinfo;
161 /* called in creator.c even... tsk, split this! */
162 void WM_exit(bContext *C)
164 wm_operatortype_free();
166 free_ttfont(); /* bke_font.h */
169 end_all_verse_sessions();
176 // if (G.background == 0)
177 // sound_end_all_sounds();
180 if(G.obedit->type==OB_FONT) {
183 // else if(G.obedit->type==OB_MBALL) BLI_freelistN(&editelems);
184 // free_editMesh(G.editMesh);
188 // free_editArmature();
191 /* before free_blender so py's gc happens while library still exists */
192 /* needed at least for a rare sigsegv that can happen in pydrivers */
195 // fastshade_free_render(); /* shaded view */
196 free_blender(); /* blender.c, does entire library */
197 // free_matcopybuf();
198 // free_ipocopybuf();
199 // free_actcopybuf();
200 // free_vertexpaint();
201 // free_imagepaint();
203 /* editnurb can remain to exist outside editmode */
204 freeNurblist(&editNurb);
209 // free_languagemenu();
216 // sound_exit_audio();
217 if(G.listener) MEM_freeN(G.listener);
222 #ifdef WITH_QUICKTIME
227 // XXX BIF_resources_free();
229 // XXX BIF_filelist_free_icons();
236 // if (copybuf) MEM_freeN(copybuf);
237 // if (copybufinfo) MEM_freeN(copybufinfo);
239 /* undo free stuff */
240 // undo_editmode_clear();
242 BKE_undo_save_quit(); // saves quit.blend if global undo is on
245 BLI_freelistN(&U.themes);
246 // XXX BIF_preview_free_dbase();
251 printf("Error Totblock: %d\n",totblock);
254 // delete_autosave();
256 printf("\nBlender quit\n");
259 /* ask user to press enter when in debug mode */
261 printf("press enter key to exit...\n\n");
267 SYS_DeleteSystem(SYS_GetSystem());