main.cpp (pymol-v1.8.6.0.tar.bz2) | : | main.cpp (pymol-v2.1.0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 54 | skipping to change at line 54 | |||
#include "P.h" | #include "P.h" | |||
#include "PConv.h" | #include "PConv.h" | |||
#include "Ortho.h" | #include "Ortho.h" | |||
#include "Scene.h" | #include "Scene.h" | |||
#include "Seq.h" | #include "Seq.h" | |||
#include "Util.h" | #include "Util.h" | |||
#include "Control.h" | #include "Control.h" | |||
#include "Movie.h" | #include "Movie.h" | |||
#include "Executive.h" | #include "Executive.h" | |||
int _gScaleFactor = 1; | ||||
#ifdef _PYMOL_NO_MAIN | #ifdef _PYMOL_NO_MAIN | |||
int MainSavingUnderWhileIdle(void) | int MainSavingUnderWhileIdle(void) | |||
{ | { | |||
return 0; | return 0; | |||
} | } | |||
#ifdef _MACPYMOL_XCODE | #ifdef _MACPYMOL_XCODE | |||
void MainBlock(void) | void MainBlock(void) | |||
skipping to change at line 570 | skipping to change at line 572 | |||
if(PyErr_Occurred()) | if(PyErr_Occurred()) | |||
PyErr_Print(); | PyErr_Print(); | |||
PXDecRef(PYOBJECT_CALLMETHOD | PXDecRef(PYOBJECT_CALLMETHOD | |||
(G->P_inst->obj, "adapt_to_hardware", "O", G->P_inst->obj)); | (G->P_inst->obj, "adapt_to_hardware", "O", G->P_inst->obj)); | |||
if(PyErr_Occurred()) | if(PyErr_Occurred()) | |||
PyErr_Print(); | PyErr_Print(); | |||
if(G->StereoCapable) { | ||||
OrthoAddOutput(G, | ||||
" OpenGL quad-buffer stereo 3D detected and enabled.\n");; | ||||
} else { | ||||
if(G->LaunchStatus & cPyMOLGlobals_LaunchStatus_StereoFailed) { | ||||
OrthoAddOutput(G, | ||||
"Error: The requested stereo 3D visualization mode is n | ||||
ot available.\n"); | ||||
} | ||||
} | ||||
if(G->LaunchStatus & cPyMOLGlobals_LaunchStatus_MultisampleFailed) { | ||||
OrthoAddOutput(G, | ||||
"Error: The requested multisampling mode is not available.\ | ||||
n"); | ||||
} | ||||
if(G->Option->incentive_product) { /* perform incentive product initializat ion (if any) */ | if(G->Option->incentive_product) { /* perform incentive product initializat ion (if any) */ | |||
PyRun_SimpleString("try:\n import ipymol\nexcept:\n pass\n"); | PyRun_SimpleString("try:\n import ipymol\nexcept:\n pass\n"); | |||
if(PyErr_Occurred()) | if(PyErr_Occurred()) | |||
PyErr_Print(); | PyErr_Print(); | |||
} | } | |||
PXDecRef(PYOBJECT_CALLMETHOD(G->P_inst->obj, "exec_deferred", "O", G->P_inst ->obj)); | PXDecRef(PYOBJECT_CALLMETHOD(G->P_inst->obj, "exec_deferred", "O", G->P_inst ->obj)); | |||
if(PyErr_Occurred()) | if(PyErr_Occurred()) | |||
PyErr_Print(); | PyErr_Print(); | |||
skipping to change at line 848 | skipping to change at line 835 | |||
/*========================================================================*/ | /*========================================================================*/ | |||
static void MainKey(unsigned char k, int x, int y) | static void MainKey(unsigned char k, int x, int y) | |||
{ | { | |||
PyMOLGlobals *G = SingletonPyMOLGlobals; | PyMOLGlobals *G = SingletonPyMOLGlobals; | |||
CMain *I = G->Main; | CMain *I = G->Main; | |||
int glMod; | int glMod; | |||
glMod = p_glutGetModifiers(); | glMod = p_glutGetModifiers(); | |||
#if defined(_PYMOL_OSX) && !defined(_PYMOL_LIB) | ||||
// MacOS GLUT.framework: swap delete and backspace | ||||
switch (k) { | ||||
case 0x08: k = 0x7f; break; | ||||
case 0x7f: k = 0x08; break; | ||||
} | ||||
#endif | ||||
PRINTFB(G, FB_Main, FB_Blather) | PRINTFB(G, FB_Main, FB_Blather) | |||
" MainKey: code:%d modifiers:0x%02x x:%d y:%d\n", k, glMod, x, y ENDFB(G); | " MainKey: code:%d modifiers:0x%02x x:%d y:%d\n", k, glMod, x, y ENDFB(G); | |||
if(PLockAPIAsGlut(G, false)) { | if(PLockAPIAsGlut(G, false)) { | |||
I->IdleMode = 0; /* restore responsiveness */ | I->IdleMode = 0; /* restore responsiveness */ | |||
I->Modifiers = ((glMod & P_GLUT_ACTIVE_SHIFT) ? cOrthoSHIFT : 0) | | I->Modifiers = ((glMod & P_GLUT_ACTIVE_SHIFT) ? cOrthoSHIFT : 0) | | |||
((glMod & P_GLUT_ACTIVE_CTRL) ? cOrthoCTRL : 0) | | ((glMod & P_GLUT_ACTIVE_CTRL) ? cOrthoCTRL : 0) | | |||
((glMod & P_GLUT_ACTIVE_ALT) ? cOrthoALT : 0); | ((glMod & P_GLUT_ACTIVE_ALT) ? cOrthoALT : 0); | |||
skipping to change at line 920 | skipping to change at line 915 | |||
if(G->HaveGUI) { | if(G->HaveGUI) { | |||
glViewport(0, 0, (GLint) width, (GLint) height); | glViewport(0, 0, (GLint) width, (GLint) height); | |||
if((!PyMOLInstance) || | if((!PyMOLInstance) || | |||
(width != OrthoGetWidth(G)) || (height != OrthoGetHeight(G))) { | (width != OrthoGetWidth(G)) || (height != OrthoGetHeight(G))) { | |||
/* wipe the screen ASAP to prevent display of garbage... */ | /* wipe the screen ASAP to prevent display of garbage... */ | |||
int draw_both = G->StereoCapable && | int draw_both = G->StereoCapable && | |||
((SceneGetStereo(G) == 1) || | ((SceneGetStereo(G) == 1) || | |||
SettingGetGlobal_b(G, cSetting_stereo_double_pump_mono)); | SettingGetGlobal_b(G, cSetting_stereo_double_pump_mono)); | |||
glClearColor(0.0, 0.0, 0.0, 1.0); | SceneGLClearColor(0.0, 0.0, 0.0, 1.0); | |||
if(draw_both) { | if(draw_both) { | |||
OrthoDrawBuffer(G, GL_FRONT_LEFT); | OrthoDrawBuffer(G, GL_FRONT_LEFT); | |||
glClear(GL_COLOR_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT); | |||
OrthoDrawBuffer(G, GL_FRONT_RIGHT); | OrthoDrawBuffer(G, GL_FRONT_RIGHT); | |||
glClear(GL_COLOR_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT); | |||
OrthoDrawBuffer(G, GL_BACK_LEFT); | OrthoDrawBuffer(G, GL_BACK_LEFT); | |||
glClear(GL_COLOR_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT); | |||
OrthoDrawBuffer(G, GL_BACK_RIGHT); | OrthoDrawBuffer(G, GL_BACK_RIGHT); | |||
glClear(GL_COLOR_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT); | |||
} else { | } else { | |||
skipping to change at line 1019 | skipping to change at line 1014 | |||
/*========================================================================*/ | /*========================================================================*/ | |||
static void MainInit(PyMOLGlobals * G) | static void MainInit(PyMOLGlobals * G) | |||
{ | { | |||
CMain *I = (G->Main = Calloc(CMain, 1)); | CMain *I = (G->Main = Calloc(CMain, 1)); | |||
/* Data structure is zeroed on start...no need for explicit zero inits */ | /* Data structure is zeroed on start...no need for explicit zero inits */ | |||
I->DeferReshapeDeferral = 1; | I->DeferReshapeDeferral = 1; | |||
PyMOL_Start(PyMOLInstance); | PyMOL_Start(PyMOLInstance); | |||
PyMOL_ConfigureShadersGL(PyMOLInstance); | ||||
// moved to PyMOL_DrawWithoutLock | ||||
// PyMOL_ConfigureShadersGL(PyMOLInstance); | ||||
PyMOL_SetSwapBuffersFn(PyMOLInstance, (PyMOLSwapBuffersFn *) p_glutSwapBuffers ); | PyMOL_SetSwapBuffersFn(PyMOLInstance, (PyMOLSwapBuffersFn *) p_glutSwapBuffers ); | |||
I->ReshapeTime = (I->IdleTime = UtilGetSeconds(G)); | I->ReshapeTime = (I->IdleTime = UtilGetSeconds(G)); | |||
I->DrawGovernorActive = false; | I->DrawGovernorActive = false; | |||
I->DrawSignalled = true; | I->DrawSignalled = true; | |||
I->DrawDelay = 0.01; /* 100 FPS max */ | I->DrawDelay = 0.01; /* 100 FPS max */ | |||
I->DrawAfter = 0.0; | I->DrawAfter = 0.0; | |||
I->DrawDeferred = false; | I->DrawDeferred = false; | |||
} | } | |||
skipping to change at line 1053 | skipping to change at line 1050 | |||
int theWindow = G->Main->TheWindow; | int theWindow = G->Main->TheWindow; | |||
#endif | #endif | |||
#ifdef _PYMOL_OSX | #ifdef _PYMOL_OSX | |||
int game_mode = G->Option->game_mode; | int game_mode = G->Option->game_mode; | |||
int haveGUI = G->HaveGUI; | int haveGUI = G->HaveGUI; | |||
int theWindow = G->Main->TheWindow; | int theWindow = G->Main->TheWindow; | |||
#endif | #endif | |||
/* END PROPRIETARY CODE SEGMENT */ | /* END PROPRIETARY CODE SEGMENT */ | |||
PyMOL_PushValidContext(PyMOLInstance); | ||||
PyMOL_Stop(PyMOLInstance); | ||||
PyMOL_PopValidContext(PyMOLInstance); | ||||
FreeP(G->Main); | FreeP(G->Main); | |||
PyMOL_Free(PyMOLInstance); | ||||
if(owned_options) | if(owned_options) | |||
PyMOLOptions_Free(owned_options); /* clean up launch options if we're supp osed to */ | PyMOLOptions_Free(owned_options); /* clean up launch options if we're supp osed to */ | |||
MemoryDebugDump(); /* this is a no-op unless memory debugging is en abled */ | MemoryDebugDump(); /* this is a no-op unless memory debugging is en abled */ | |||
if(show_message) { | if(show_message) { | |||
printf(" PyMOL: normal program termination.\n"); | printf(" PyMOL: normal program termination.\n"); | |||
} | } | |||
skipping to change at line 1477 | skipping to change at line 1469 | |||
{ | { | |||
int display_mode_possible = false; | int display_mode_possible = false; | |||
if(G->Option->stereo_mode > 1) | if(G->Option->stereo_mode > 1) | |||
G->Option->force_stereo = 0; | G->Option->force_stereo = 0; | |||
switch (G->Option->force_stereo) { | switch (G->Option->force_stereo) { | |||
case -1: /* force mono */ | case -1: /* force mono */ | |||
G->StereoCapable = 0; | G->StereoCapable = 0; | |||
break; | break; | |||
case 1: /* force quad buffer stereo (if possible) */ | ||||
G->Option->stereo_mode = cStereo_quadbuffer; | ||||
case 0: /* default/autodetect */ | case 0: /* default/autodetect */ | |||
#ifdef _PYMOL_SHARP3D | #ifdef _PYMOL_SHARP3D | |||
G->Option->stereo_mode = cStereo_stencil_custom; | G->Option->stereo_mode = cStereo_stencil_custom; | |||
#endif | #endif | |||
switch (G->Option->stereo_mode) { | switch (G->Option->stereo_mode) { | |||
case cStereo_default: | case cStereo_default: | |||
case cStereo_quadbuffer: | case cStereo_quadbuffer: | |||
p_glutInitDisplayMode(P_GLUT_RGBA | P_GLUT_DEPTH | multisample_mask | | p_glutInitDisplayMode(P_GLUT_RGBA | P_GLUT_DEPTH | multisample_mask | | |||
P_GLUT_DOUBLE | P_GLUT_STEREO); | P_GLUT_DOUBLE | P_GLUT_STEREO); | |||
display_mode_possible = p_glutGet(P_GLUT_DISPLAY_MODE_POSSIBLE); | display_mode_possible = p_glutGet(P_GLUT_DISPLAY_MODE_POSSIBLE); | |||
skipping to change at line 1538 | skipping to change at line 1532 | |||
G->Option->stereo_mode = 0; | G->Option->stereo_mode = 0; | |||
} | } | |||
break; | break; | |||
case cStereo_anaglyph: /* nothing special required for anaglyph */ | case cStereo_anaglyph: /* nothing special required for anaglyph */ | |||
G->StereoCapable = 1; | G->StereoCapable = 1; | |||
break; | break; | |||
default: /* fall through */ | default: /* fall through */ | |||
break; | break; | |||
} | } | |||
break; | break; | |||
case 1: /* force quad buffer stereo (if possible) */ | ||||
p_glutInitDisplayMode(P_GLUT_RGBA | P_GLUT_DEPTH | multisample_mask | | ||||
P_GLUT_DOUBLE | P_GLUT_STEREO); | ||||
display_mode_possible = p_glutGet(P_GLUT_DISPLAY_MODE_POSSIBLE); | ||||
if(multisample_mask && (!display_mode_possible)) { | ||||
G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_MultisampleFailed; | ||||
p_glutInitDisplayMode(P_GLUT_RGBA | P_GLUT_DEPTH | P_GLUT_DOUBLE | | ||||
P_GLUT_STEREO); | ||||
display_mode_possible = p_glutGet(P_GLUT_DISPLAY_MODE_POSSIBLE); | ||||
} | ||||
if(display_mode_possible) { | ||||
G->StereoCapable = 1; | ||||
} else { | ||||
G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_StereoFailed; | ||||
} | ||||
break; | ||||
} | } | |||
/* fallback behavior */ | /* fallback behavior */ | |||
if(!display_mode_possible) { | if(!display_mode_possible) { | |||
G->LaunchStatus &= ~cPyMOLGlobals_LaunchStatus_MultisampleFailed; | ||||
p_glutInitDisplayMode(P_GLUT_RGBA | P_GLUT_DEPTH | multisample_mask | | p_glutInitDisplayMode(P_GLUT_RGBA | P_GLUT_DEPTH | multisample_mask | | |||
P_GLUT_DOUBLE); | P_GLUT_DOUBLE); | |||
display_mode_possible = p_glutGet(P_GLUT_DISPLAY_MODE_POSSIBLE); | display_mode_possible = p_glutGet(P_GLUT_DISPLAY_MODE_POSSIBLE); | |||
G->StereoCapable = 0; | G->StereoCapable = 0; | |||
} | } | |||
if(multisample_mask && (!display_mode_possible)) { | if(multisample_mask && (!display_mode_possible)) { | |||
G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_MultisampleFailed; | G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_MultisampleFailed; | |||
p_glutInitDisplayMode(P_GLUT_RGBA | P_GLUT_DEPTH | P_GLUT_DOUBLE); | p_glutInitDisplayMode(P_GLUT_RGBA | P_GLUT_DEPTH | P_GLUT_DOUBLE); | |||
display_mode_possible = p_glutGet(P_GLUT_DISPLAY_MODE_POSSIBLE); | display_mode_possible = p_glutGet(P_GLUT_DISPLAY_MODE_POSSIBLE); | |||
End of changes. 10 change blocks. | ||||
40 lines changed or deleted | 17 lines changed or added |