+ CGGammaValue table_red [GAMMA_TABLE_SIZE];
+ CGGammaValue table_green [GAMMA_TABLE_SIZE];
+ CGGammaValue table_blue [GAMMA_TABLE_SIZE];
+ CGTableCount actualsize = 0;
+ unsigned int i;
+
+ // Get the gamma ramps from the system
+ if (CGGetDisplayTransferByTable(CGMainDisplayID(), GAMMA_TABLE_SIZE, table_red, table_green, table_blue, &actualsize) != CGDisplayNoErr)
+ {
+ Con_Print("VID_GetGamma: ERROR: CGGetDisplayTransferByTable failed!\n");
+ return false;
+ }
+ if (actualsize != GAMMA_TABLE_SIZE)
+ {
+ Con_Printf("VID_GetGamma: ERROR: invalid gamma table size (%u != %u)\n", actualsize, GAMMA_TABLE_SIZE);
+ return false;
+ }
+
+ // Convert the 3 float tables into 1 unsigned short table
+ for (i = 0; i < GAMMA_TABLE_SIZE; i++)
+ ramps[i] = table_red[i] * 65535.0f;
+ for (i = 0; i < GAMMA_TABLE_SIZE; i++)
+ ramps[i + GAMMA_TABLE_SIZE] = table_green[i] * 65535.0f;
+ for (i = 0; i < GAMMA_TABLE_SIZE; i++)
+ ramps[i + 2 * GAMMA_TABLE_SIZE] = table_blue[i] * 65535.0f;
+
+ return true;