|
Blender
V2.59
|
00001 /* 00002 * $Id: wm_apple.c 37030 2011-05-31 01:15:44Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2007 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * 00024 * Contributor(s): Blender Foundation 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00033 /* note, this file builds on apple-carbon only! */ 00034 00035 #include "BKE_context.h" 00036 #include "BKE_global.h" 00037 #include "WM_api.h" 00038 00039 #include <OpenGL/OpenGL.h> 00040 #define __CARBONSOUND__ 00041 /* XXX BIG WARNING: carbon.h can not be included in blender code, it conflicts with struct ID */ 00042 #define ID ID_ 00043 #include <Carbon/Carbon.h> 00044 00045 00046 /* To avoid killing small end comps, we want to allow 00047 blender to start maximised if all the followings are true : 00048 - Renderer is OpenGL capable 00049 - Hardware acceleration 00050 - VRAM > 16 Mo 00051 00052 We will bail out if VRAM is less than 8Mo 00053 */ 00054 /* bad global, used in wm_window.c to open windows */ 00055 int macPrefState = 0; 00056 00057 static int checkAppleVideoCard(void) 00058 { 00059 CGLRendererInfoObj rend; 00060 long theErr; 00061 unsigned long display_mask; 00062 long nrend; 00063 int j; 00064 long value; 00065 long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */ 00066 00067 display_mask = CGDisplayIDToOpenGLDisplayMask (CGMainDisplayID() ); 00068 00069 theErr = CGLQueryRendererInfo( display_mask, &rend, &nrend); 00070 if (theErr == 0) { 00071 theErr = CGLDescribeRenderer (rend, 0, kCGLRPRendererCount, &nrend); 00072 if (theErr == 0) { 00073 for (j = 0; j < nrend; j++) { 00074 theErr = CGLDescribeRenderer (rend, j, kCGLRPVideoMemory, &value); 00075 if (value > maxvram) 00076 maxvram = value; 00077 if ((theErr == 0) && (value >= 20000000)) { 00078 theErr = CGLDescribeRenderer (rend, j, kCGLRPAccelerated, &value); 00079 if ((theErr == 0) && (value != 0)) { 00080 theErr = CGLDescribeRenderer (rend, j, kCGLRPCompliant, &value); 00081 if ((theErr == 0) && (value != 0)) { 00082 /*fprintf(stderr,"make it big\n");*/ 00083 CGLDestroyRendererInfo (rend); 00084 macPrefState = 8; 00085 return 1; 00086 } 00087 } 00088 } 00089 } 00090 } 00091 } 00092 if (maxvram < 7500000 ) { /* put a standard alert and quit*/ 00093 SInt16 junkHit; 00094 char inError[] = "* Not enough VRAM "; 00095 char inText[] = "* blender needs at least 8Mb "; 00096 inError[0] = 16; 00097 inText[0] = 28; 00098 00099 fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram); 00100 StandardAlert ( kAlertStopAlert, (ConstStr255Param) &inError, (ConstStr255Param)&inText,NULL,&junkHit); 00101 abort(); 00102 } 00103 CGLDestroyRendererInfo (rend); 00104 return 0; 00105 } 00106 00107 static void getMacAvailableBounds(short *top, short *left, short *bottom, short *right) 00108 { 00109 Rect outAvailableRect; 00110 00111 GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect); 00112 00113 *top = outAvailableRect.top; 00114 *left = outAvailableRect.left; 00115 *bottom = outAvailableRect.bottom; 00116 *right = outAvailableRect.right; 00117 } 00118 00119 00120 void wm_set_apple_prefsize(int scr_x, int scr_y) 00121 { 00122 00123 /* first let us check if we are hardware accelerated and with VRAM > 16 Mo */ 00124 00125 if (checkAppleVideoCard()) { 00126 short top, left, bottom, right; 00127 00128 getMacAvailableBounds(&top, &left, &bottom, &right); 00129 WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64); 00130 G.windowstate= 0; 00131 00132 } else { 00133 00134 /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */ 00135 WM_setprefsize(120, 40, 850, 684); 00136 G.windowstate= 0; 00137 } 00138 }