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 *****
31 #include "BKE_global.h"
34 #include <OpenGL/OpenGL.h>
35 #define __CARBONSOUND__
36 /* XXX BIG WARNING: carbon.h can not be included in blender code, it conflicts with struct ID */
38 #include <Carbon/Carbon.h>
41 /* To avoid killing small end comps, we want to allow
42 blender to start maximised if all the followings are true :
43 - Renderer is OpenGL capable
44 - Hardware acceleration
47 We will bail out if VRAM is less than 8Mo
49 /* bad global, used in wm_window.c to open windows */
52 static int checkAppleVideoCard(void)
54 CGLRendererInfoObj rend;
56 unsigned long display_mask;
60 long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */
62 display_mask = CGDisplayIDToOpenGLDisplayMask (CGMainDisplayID() );
64 theErr = CGLQueryRendererInfo( display_mask, &rend, &nrend);
66 theErr = CGLDescribeRenderer (rend, 0, kCGLRPRendererCount, &nrend);
68 for (j = 0; j < nrend; j++) {
69 theErr = CGLDescribeRenderer (rend, j, kCGLRPVideoMemory, &value);
72 if ((theErr == 0) && (value >= 20000000)) {
73 theErr = CGLDescribeRenderer (rend, j, kCGLRPAccelerated, &value);
74 if ((theErr == 0) && (value != 0)) {
75 theErr = CGLDescribeRenderer (rend, j, kCGLRPCompliant, &value);
76 if ((theErr == 0) && (value != 0)) {
77 /*fprintf(stderr,"make it big\n");*/
78 CGLDestroyRendererInfo (rend);
87 if (maxvram < 7500000 ) { /* put a standard alert and quit*/
89 char inError[] = "* Not enough VRAM ";
90 char inText[] = "* blender needs at least 8Mb ";
94 fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram);
95 StandardAlert ( kAlertStopAlert, (ConstStr255Param) &inError, (ConstStr255Param)&inText,NULL,&junkHit);
98 CGLDestroyRendererInfo (rend);
102 static void getMacAvailableBounds(short *top, short *left, short *bottom, short *right)
104 Rect outAvailableRect;
106 GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect);
108 *top = outAvailableRect.top;
109 *left = outAvailableRect.left;
110 *bottom = outAvailableRect.bottom;
111 *right = outAvailableRect.right;
115 void wm_set_apple_prefsize(int scr_x, int scr_y)
118 /* first let us check if we are hardware accelerated and with VRAM > 16 Mo */
120 if (checkAppleVideoCard()) {
121 short top, left, bottom, right;
123 getMacAvailableBounds(&top, &left, &bottom, &right);
124 WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64);
129 /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
130 WM_setprefsize(120, 40, 850, 684);
136 #endif /* __APPLE__ */