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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 *****
31 #include "BKE_context.h"
32 #include "BKE_global.h"
35 #include <OpenGL/OpenGL.h>
36 #define __CARBONSOUND__
37 /* XXX BIG WARNING: carbon.h can not be included in blender code, it conflicts with struct ID */
39 #include <Carbon/Carbon.h>
42 /* To avoid killing small end comps, we want to allow
43 blender to start maximised if all the followings are true :
44 - Renderer is OpenGL capable
45 - Hardware acceleration
48 We will bail out if VRAM is less than 8Mo
50 /* bad global, used in wm_window.c to open windows */
53 static int checkAppleVideoCard(void)
55 CGLRendererInfoObj rend;
57 unsigned long display_mask;
61 long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */
63 display_mask = CGDisplayIDToOpenGLDisplayMask (CGMainDisplayID() );
65 theErr = CGLQueryRendererInfo( display_mask, &rend, &nrend);
67 theErr = CGLDescribeRenderer (rend, 0, kCGLRPRendererCount, &nrend);
69 for (j = 0; j < nrend; j++) {
70 theErr = CGLDescribeRenderer (rend, j, kCGLRPVideoMemory, &value);
73 if ((theErr == 0) && (value >= 20000000)) {
74 theErr = CGLDescribeRenderer (rend, j, kCGLRPAccelerated, &value);
75 if ((theErr == 0) && (value != 0)) {
76 theErr = CGLDescribeRenderer (rend, j, kCGLRPCompliant, &value);
77 if ((theErr == 0) && (value != 0)) {
78 /*fprintf(stderr,"make it big\n");*/
79 CGLDestroyRendererInfo (rend);
88 if (maxvram < 7500000 ) { /* put a standard alert and quit*/
90 char inError[] = "* Not enough VRAM ";
91 char inText[] = "* blender needs at least 8Mb ";
95 fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram);
96 StandardAlert ( kAlertStopAlert, (ConstStr255Param) &inError, (ConstStr255Param)&inText,NULL,&junkHit);
99 CGLDestroyRendererInfo (rend);
103 static void getMacAvailableBounds(short *top, short *left, short *bottom, short *right)
105 Rect outAvailableRect;
107 GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect);
109 *top = outAvailableRect.top;
110 *left = outAvailableRect.left;
111 *bottom = outAvailableRect.bottom;
112 *right = outAvailableRect.right;
116 void wm_set_apple_prefsize(int scr_x, int scr_y)
119 /* first let us check if we are hardware accelerated and with VRAM > 16 Mo */
121 if (checkAppleVideoCard()) {
122 short top, left, bottom, right;
124 getMacAvailableBounds(&top, &left, &bottom, &right);
125 WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64);
130 /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
131 WM_setprefsize(120, 40, 850, 684);
137 #endif /* __APPLE__ */