PyMOL.cpp (pymol-v2.1.0.tar.bz2) | : | PyMOL.cpp (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
skipping to change at line 71 | skipping to change at line 71 | |||
#include "TestPyMOL.h" | #include "TestPyMOL.h" | |||
#include "TypeFace.h" | #include "TypeFace.h" | |||
#include "PlugIOManager.h" | #include "PlugIOManager.h" | |||
#include "MovieScene.h" | #include "MovieScene.h" | |||
#include "Lex.h" | #include "Lex.h" | |||
#include "PyMOL.h" | #include "PyMOL.h" | |||
#include "PyMOLGlobals.h" | #include "PyMOLGlobals.h" | |||
#include "PyMOLOptions.h" | #include "PyMOLOptions.h" | |||
#include "Feedback.h" | #include "Feedback.h" | |||
#include "GraphicsUtil.h" | ||||
#include "ShaderMgr.h" | #include "ShaderMgr.h" | |||
#include "Version.h" | #include "Version.h" | |||
#ifndef _PYMOL_NOPY | #ifndef _PYMOL_NOPY | |||
PyMOLGlobals *SingletonPyMOLGlobals = NULL; | PyMOLGlobals *SingletonPyMOLGlobals = NULL; | |||
#endif | #endif | |||
/* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | /* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | |||
#ifndef _PYMOL_NOPY | #ifndef _PYMOL_NOPY | |||
skipping to change at line 1500 | skipping to change at line 1501 | |||
int n_color = word_count(color); | int n_color = word_count(color); | |||
/* to do */ | /* to do */ | |||
if(color && n_color) { | if(color && n_color) { | |||
color_vla = VLAlloc(float, n_color * 3); | color_vla = VLAlloc(float, n_color * 3); | |||
if(color_vla) { | if(color_vla) { | |||
WordType colorName; | WordType colorName; | |||
int a; | int a; | |||
for(a = 0; a < n_color; a++) { | for(a = 0; a < n_color; a++) { | |||
color = next_word(color, colorName, sizeof(colorName)); | color = next_word(color, colorName, sizeof(colorName)); | |||
{ | { | |||
float *src = ColorGetNamed(I->G, colorName); | const float *src = ColorGetNamed(I->G, colorName); | |||
float *dst = color_vla + 3 * a; | float *dst = color_vla + 3 * a; | |||
copy3f(src, dst); | copy3f(src, dst); | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
if(ok) { | if(ok) { | |||
ok = ExecutiveRampNew(I->G, name, map, range_vla, | ok = ExecutiveRampNew(I->G, name, map, range_vla, | |||
color_vla, state, s1, beyond, within, sigma, | color_vla, state, s1, beyond, within, sigma, | |||
skipping to change at line 1834 | skipping to change at line 1835 | |||
0, /* read_stdin */ | 0, /* read_stdin */ | |||
0, /* presentation */ | 0, /* presentation */ | |||
0, /* defer builds mode */ | 0, /* defer builds mode */ | |||
0, /* full screen mode */ | 0, /* full screen mode */ | |||
-1, /* sphere mode */ | -1, /* sphere mode */ | |||
0, /* stereo capable */ | 0, /* stereo capable */ | |||
0, /* stereo mode */ | 0, /* stereo mode */ | |||
-1, /* zoom mode */ | -1, /* zoom mode */ | |||
0, /* launch_status */ | 0, /* launch_status */ | |||
0, /* no quit */ | 0, /* no quit */ | |||
0, /* gldebug */ | ||||
}; | }; | |||
CPyMOLOptions *PyMOLOptions_New(void) | CPyMOLOptions *PyMOLOptions_New(void) | |||
{ | { | |||
CPyMOLOptions *result = NULL; | CPyMOLOptions *result = NULL; | |||
result = Calloc(CPyMOLOptions, 1); | result = Calloc(CPyMOLOptions, 1); | |||
if(result) | if(result) | |||
*result = Defaults; | *result = Defaults; | |||
return result; | return result; | |||
} | } | |||
skipping to change at line 1873 | skipping to change at line 1875 | |||
BTW: PyMOL doesn't itself need the GC, but end-user code | BTW: PyMOL doesn't itself need the GC, but end-user code | |||
might. */ | might. */ | |||
PyRun_SimpleString("import gc"); | PyRun_SimpleString("import gc"); | |||
PyRun_SimpleString("gc.disable()"); | PyRun_SimpleString("gc.disable()"); | |||
#endif | #endif | |||
/* END PROPRIETARY CODE SEGMENT */ | /* END PROPRIETARY CODE SEGMENT */ | |||
PyEval_InitThreads(); | PyEval_InitThreads(); | |||
#if PY_MAJOR_VERSION < 3 | ||||
PyUnicode_SetDefaultEncoding("utf-8"); /* is this safe & legal? */ | ||||
#endif | ||||
PyRun_SimpleString("import sys"); | PyRun_SimpleString("import sys"); | |||
PyRun_SimpleString("import os"); | PyRun_SimpleString("import os"); | |||
PyRun_SimpleString("sys.path.insert(0,os.environ['PYMOL_PATH']+'/modules')"); | PyRun_SimpleString("sys.path.insert(0,os.environ['PYMOL_PATH']+'/modules')"); | |||
/* initialize our embedded C modules */ | /* initialize our embedded C modules */ | |||
init_cmd(); | init_cmd(); | |||
PyRun_SimpleString("import pymol"); | PyRun_SimpleString("import pymol"); | |||
/* parse arguments */ | /* parse arguments */ | |||
skipping to change at line 2099 | skipping to change at line 2098 | |||
I->DrawnFlag = false; | I->DrawnFlag = false; | |||
I->RedisplayFlag = true; | I->RedisplayFlag = true; | |||
G->Ready = true; | G->Ready = true; | |||
} | } | |||
/* This function is necessary to be called from PyMOL_StartWithPython | /* This function is necessary to be called from PyMOL_StartWithPython | |||
which is called before the PYMOL_API is instantiated, thus | which is called before the PYMOL_API is instantiated, thus | |||
it is not necessary (and you can't) lock the API */ | it is not necessary (and you can't) lock the API */ | |||
void PyMOL_ConfigureShadersGL_WithoutLock(CPyMOL * I){ | void PyMOL_ConfigureShadersGL_WithoutLock(CPyMOL * I){ | |||
ShaderMgrConfig(I->G); | I->done_ConfigureShaders = false; | |||
// ShaderMgr->Config() moved to PyMOL_DrawWithoutLock | ||||
} | } | |||
/* This function is called from CMol and needs to lock | /* This function is called from CMol and needs to lock | |||
the PYMOL_API */ | the PYMOL_API */ | |||
void PyMOL_ConfigureShadersGL(CPyMOL * I){ | void PyMOL_ConfigureShadersGL(CPyMOL * I){ | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
PyMOL_ConfigureShadersGL_WithoutLock(I); | PyMOL_ConfigureShadersGL_WithoutLock(I); | |||
PYMOL_API_UNLOCK | PYMOL_API_UNLOCK | |||
} | } | |||
skipping to change at line 2160 | skipping to change at line 2160 | |||
AtomInfoFree(G); | AtomInfoFree(G); | |||
ButModeFree(G); | ButModeFree(G); | |||
ControlFree(G); | ControlFree(G); | |||
SeekerFree(G); | SeekerFree(G); | |||
SeqFree(G); | SeqFree(G); | |||
SelectorFree(G); | SelectorFree(G); | |||
MovieFree(G); | MovieFree(G); | |||
SceneFree(G); | SceneFree(G); | |||
MovieScenesFree(G); | MovieScenesFree(G); | |||
OrthoFree(G); | OrthoFree(G); | |||
CShaderMgrFree(G); | DeleteP(G->ShaderMgr); | |||
SettingFreeGlobal(G); | SettingFreeGlobal(G); | |||
CharacterFree(G); | CharacterFree(G); | |||
TextFree(G); | TextFree(G); | |||
TypeFree(G); | TypeFree(G); | |||
TextureFree(G); | TextureFree(G); | |||
SphereFree(G); | SphereFree(G); | |||
PlugIOManagerFree(G); | PlugIOManagerFree(G); | |||
PFree(G); | PFree(G); | |||
CGORendererFree(G); | CGORendererFree(G); | |||
ColorFree(G); | ColorFree(G); | |||
skipping to change at line 2313 | skipping to change at line 2313 | |||
if(G->LaunchStatus & cPyMOLGlobals_LaunchStatus_MultisampleFailed) { | if(G->LaunchStatus & cPyMOLGlobals_LaunchStatus_MultisampleFailed) { | |||
FeedbackAddColored(G, | FeedbackAddColored(G, | |||
"Error: The requested multisampling mode is not available.\n", | "Error: The requested multisampling mode is not available.\n", | |||
FB_Errors); | FB_Errors); | |||
} | } | |||
} | } | |||
#ifndef PURE_OPENGL_ES_2 | #ifndef PURE_OPENGL_ES_2 | |||
static void check_gl_stereo_capable(PyMOLGlobals * G) | static void check_gl_stereo_capable(PyMOLGlobals * G) | |||
{ | { | |||
// quad buffer stereo available? | ||||
GLboolean state; | GLboolean state; | |||
glGetBooleanv(GL_STEREO, &state); | glGetBooleanv(GL_STEREO, &state); | |||
G->StereoCapable = state; | G->StereoCapable = state || G->Option->force_stereo > 0; | |||
if (!state && G->Option->force_stereo > 0) { | ||||
printf("Warning: forcing stereo despite GL_STEREO=0\n"); | ||||
} | ||||
// stereo request feedback | ||||
if (state && G->Option->stereo_mode == cStereo_default) { | if (state && G->Option->stereo_mode == cStereo_default) { | |||
SettingSetGlobal_i(G, cSetting_stereo_mode, cStereo_quadbuffer); | SettingSetGlobal_i(G, cSetting_stereo_mode, cStereo_quadbuffer); | |||
} else if (!state && G->Option->stereo_mode == cStereo_quadbuffer) { | } else if (!state && G->Option->stereo_mode == cStereo_quadbuffer) { | |||
G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_StereoFailed; | G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_StereoFailed; | |||
} | } | |||
// multisample request feedback | ||||
if (G->Option->multisample) { | if (G->Option->multisample) { | |||
GLint samplebuffers = 0; | GLint samplebuffers = 0; | |||
glGetIntegerv(GL_SAMPLE_BUFFERS, &samplebuffers); | glGetIntegerv(GL_SAMPLE_BUFFERS, &samplebuffers); | |||
if (!samplebuffers) { | if (!samplebuffers) { | |||
G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_MultisampleFailed; | G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_MultisampleFailed; | |||
} | } | |||
} | } | |||
// GL_BACK if GL_DOUBLEBUFFER else GL_FRONT | ||||
// With QOpenGLWidget -> framebuffer object | ||||
GLint buf; | ||||
glGetIntegerv(GL_DRAW_BUFFER0, &buf); | ||||
if (!buf) { | ||||
printf("Warning: GL_DRAW_BUFFER0=0 -> using GL_BACK\n"); | ||||
buf = GL_BACK; | ||||
} | ||||
G->DRAW_BUFFER0 = buf; | ||||
// double buffer check | ||||
glGetBooleanv(GL_DOUBLEBUFFER, &state); | ||||
if (!state && buf <= GL_BACK) { | ||||
printf("Warning: GL_DOUBLEBUFFER=0\n"); | ||||
} | ||||
// default framebuffer | ||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &buf); | ||||
G->ShaderMgr->default_framebuffer_id = buf; | ||||
} | } | |||
#endif | #endif | |||
void PyMOL_DrawWithoutLock(CPyMOL * I) | void PyMOL_DrawWithoutLock(CPyMOL * I) | |||
{ | { | |||
if (!I->done_ConfigureShaders) { | if (!I->done_ConfigureShaders) { | |||
I->done_ConfigureShaders = true; | I->done_ConfigureShaders = true; | |||
I->G->HaveGUI = I->G->Option->pmgui; | I->G->HaveGUI = I->G->Option->pmgui; | |||
#ifndef PURE_OPENGL_ES_2 | #ifndef PURE_OPENGL_ES_2 | |||
// stereo test with PyQt5 on Linux is broken (QTBUG-59636), so we | // stereo test with PyQt5 on Linux is broken (QTBUG-59636), so we | |||
// test for stereo here | // test for stereo here | |||
if (I->G->HaveGUI && !I->G->StereoCapable) { | if (I->G->HaveGUI) | |||
{ | ||||
check_gl_stereo_capable(I->G); | check_gl_stereo_capable(I->G); | |||
} | } | |||
#endif | #endif | |||
PyMOL_LaunchStatus_Feedback(I->G); | PyMOL_LaunchStatus_Feedback(I->G); | |||
PyMOL_ConfigureShadersGL_WithoutLock(I); | I->G->ShaderMgr->Config(); | |||
// OpenGL debugging (glewInit must be called first) | ||||
if (I->G->Option->gldebug) { | ||||
#ifdef GL_DEBUG_OUTPUT | ||||
if (!glDebugMessageCallback) { | ||||
printf("glDebugMessageCallback not available\n"); | ||||
} else { | ||||
glDebugMessageCallback(gl_debug_proc, NULL); | ||||
glEnable(GL_DEBUG_OUTPUT); | ||||
} | ||||
#else | ||||
printf("GL_DEBUG_OUTPUT not available\n"); | ||||
#endif | ||||
} | ||||
} | } | |||
PyMOLGlobals * G = I->G; | PyMOLGlobals * G = I->G; | |||
if(I->ModalDraw) { | if(I->ModalDraw) { | |||
if(G->HaveGUI) { | if(G->HaveGUI) { | |||
PyMOL_PushValidContext(I); | PyMOL_PushValidContext(I); | |||
setup_gl_state(); | setup_gl_state(); | |||
} | } | |||
{ | { | |||
PyMOLModalDrawFn *fn = I->ModalDraw; | PyMOLModalDrawFn *fn = I->ModalDraw; | |||
End of changes. 13 change blocks. | ||||
9 lines changed or deleted | 50 lines changed or added |