Ortho.cpp (pymol-v2.1.0.tar.bz2) | : | Ortho.cpp (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
#include"Seq.h" | #include"Seq.h" | |||
#include"Text.h" | #include"Text.h" | |||
#include"PyMOLOptions.h" | #include"PyMOLOptions.h" | |||
#include"PyMOL.h" | #include"PyMOL.h" | |||
#include"Movie.h" | #include"Movie.h" | |||
#include "ShaderMgr.h" | #include "ShaderMgr.h" | |||
#include "Vector.h" | #include "Vector.h" | |||
#include "CGO.h" | #include "CGO.h" | |||
#include "MyPNG.h" | #include "MyPNG.h" | |||
#include "MacPyMOL.h" | #include "MacPyMOL.h" | |||
#include "File.h" | ||||
#ifndef true | #ifndef true | |||
#define true 1 | #define true 1 | |||
#endif | #endif | |||
#ifndef false | #ifndef false | |||
#define false 0 | #define false 0 | |||
#endif | #endif | |||
#define OrthoSaveLines 0xFF | #define OrthoSaveLines 0xFF | |||
skipping to change at line 120 | skipping to change at line 121 | |||
/* packing information */ | /* packing information */ | |||
int WizardHeight; | int WizardHeight; | |||
int TextBottom; | int TextBottom; | |||
int IssueViewportWhenReleased; | int IssueViewportWhenReleased; | |||
GLuint bg_texture_id; | GLuint bg_texture_id; | |||
short bg_texture_needs_update; | short bg_texture_needs_update; | |||
CGO *bgCGO; | CGO *bgCGO; | |||
int bgWidth, bgHeight; | int bgWidth, bgHeight; | |||
void *bgData; | void *bgData; // this is the image data set from CMol, takes precedence of bg _gradient or bg_image_filename | |||
CGO *orthoCGO, *orthoFastCGO; | CGO *orthoCGO, *orthoFastCGO; | |||
}; | }; | |||
int OrthoBackgroundDataIsSet(PyMOLGlobals *G){ | int OrthoBackgroundDataIsSet(PyMOLGlobals *G){ | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
return (I->bgData && (I->bgWidth > 0 && I->bgHeight > 0)); | return (I->bgData && (I->bgWidth > 0 && I->bgHeight > 0)); | |||
// return (I->bgCGO != NULL && (I->bgWidth > 0 && I->bgHeight > 0)); | // return (I->bgCGO != NULL && (I->bgWidth > 0 && I->bgHeight > 0)); | |||
} | } | |||
void *OrthoBackgroundDataGet(PyMOLGlobals *G, int *width, int *height){ | void *OrthoBackgroundDataGet(PyMOLGlobals *G, int *width, int *height){ | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
skipping to change at line 201 | skipping to change at line 202 | |||
if(click_side) | if(click_side) | |||
*click_side = -1; | *click_side = -1; | |||
} | } | |||
} | } | |||
return x; | return x; | |||
} | } | |||
void OrthoDrawBuffer(PyMOLGlobals * G, GLenum mode) | void OrthoDrawBuffer(PyMOLGlobals * G, GLenum mode) | |||
{ | { | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
if((mode != I->ActiveGLBuffer) && G->HaveGUI && G->ValidContext) { | ||||
if (mode == GL_BACK) { | ||||
mode = G->DRAW_BUFFER0; | ||||
} | ||||
if(!hasFrameBufferBinding() && (mode != I->ActiveGLBuffer) && G->HaveGUI && G- | ||||
>ValidContext) { | ||||
#ifndef PURE_OPENGL_ES_2 | #ifndef PURE_OPENGL_ES_2 | |||
if(glGetError()) { | ||||
PRINTFB(G, FB_OpenGL, FB_Warnings) | ||||
" WARNING: BEFORE glDrawBuffer caused GL error\n" ENDFB(G); | ||||
} | ||||
glDrawBuffer(mode); | glDrawBuffer(mode); | |||
if(glGetError()) { | ||||
PRINTFB(G, FB_OpenGL, FB_Warnings) | ||||
" WARNING: glDrawBuffer caused GL error\n" ENDFB(G); | ||||
} | ||||
#endif | #endif | |||
I->ActiveGLBuffer = mode; | I->ActiveGLBuffer = mode; | |||
} | } | |||
} | } | |||
int OrthoGetDirty(PyMOLGlobals * G) | int OrthoGetDirty(PyMOLGlobals * G) | |||
{ | { | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
return I->DirtyFlag; | return I->DirtyFlag; | |||
} | } | |||
skipping to change at line 625 | skipping to change at line 623 | |||
float busyValue = 0.0F; | float busyValue = 0.0F; | |||
if(I->BusyStatus[1]) { | if(I->BusyStatus[1]) { | |||
busyValue = (I->BusyStatus[0] * 1.0F / I->BusyStatus[1]); | busyValue = (I->BusyStatus[0] * 1.0F / I->BusyStatus[1]); | |||
} | } | |||
if(I->BusyStatus[3]) { | if(I->BusyStatus[3]) { | |||
busyValue = (I->BusyStatus[2] * 1.0F / I->BusyStatus[3]); | busyValue = (I->BusyStatus[2] * 1.0F / I->BusyStatus[3]); | |||
} | } | |||
MacPyMOL_SetProgress(busyValue); | MacPyMOL_SetProgress(busyValue); | |||
/* END PROPRIETARY CODE SEGMENT */ | /* END PROPRIETARY CODE SEGMENT */ | |||
#else | #else | |||
if(G->HaveGUI && G->ValidContext) { | if(G->HaveGUI && G->ValidContext | |||
// only draw into GL_FRONT if default draw buffer is GL_BACK | ||||
// (not the case for QOpenGLWidget) | ||||
&& G->DRAW_BUFFER0 == GL_BACK) { | ||||
char *c; | char *c; | |||
int x, y; | int x, y; | |||
float white[3] = { 1, 1, 1 }; | float white[3] = { 1, 1, 1 }; | |||
int draw_both = SceneMustDrawBoth(G); | int draw_both = SceneMustDrawBoth(G); | |||
CGO *orthoCGO = I->orthoCGO; | ||||
OrthoPushMatrix(G); | OrthoPushMatrix(G); | |||
{ | { | |||
int pass = 0; | int pass = 0; | |||
SceneGLClear(G, GL_DEPTH_BUFFER_BIT); | SceneGLClear(G, GL_DEPTH_BUFFER_BIT); | |||
while(1) { | while(1) { | |||
if(draw_both) { | if(draw_both) { | |||
if(!pass) | if(!pass) | |||
OrthoDrawBuffer(G, GL_FRONT_LEFT); | OrthoDrawBuffer(G, GL_FRONT_LEFT); | |||
else | else | |||
OrthoDrawBuffer(G, GL_FRONT_RIGHT); | OrthoDrawBuffer(G, GL_FRONT_RIGHT); | |||
skipping to change at line 660 | skipping to change at line 660 | |||
glVertex2i(0, I->Height - cBusyHeight); | glVertex2i(0, I->Height - cBusyHeight); | |||
glVertex2i(cBusyWidth, I->Height - cBusyHeight); | glVertex2i(cBusyWidth, I->Height - cBusyHeight); | |||
glEnd(); | glEnd(); | |||
glColor3fv(white); | glColor3fv(white); | |||
#endif | #endif | |||
y = I->Height - cBusyMargin; | y = I->Height - cBusyMargin; | |||
c = I->BusyMessage; | c = I->BusyMessage; | |||
if(*c) { | if(*c) { | |||
TextSetColor(G, white); | TextSetColor(G, white); | |||
TextSetPos2i(G, cBusyMargin, y - (cBusySpacing / 2)); | TextSetPos2i(G, cBusyMargin, y - (cBusySpacing / 2)); | |||
TextDrawStr(G, c ORTHOCGOARGVAR); | TextDrawStr(G, c, NULL); | |||
y -= cBusySpacing; | y -= cBusySpacing; | |||
} | } | |||
if(I->BusyStatus[1]) { | if(I->BusyStatus[1]) { | |||
glBegin(GL_LINE_LOOP); | glBegin(GL_LINE_LOOP); | |||
glVertex2i(cBusyMargin, y); | glVertex2i(cBusyMargin, y); | |||
glVertex2i(cBusyWidth - cBusyMargin, y); | glVertex2i(cBusyWidth - cBusyMargin, y); | |||
glVertex2i(cBusyWidth - cBusyMargin, y - cBusyBar); | glVertex2i(cBusyWidth - cBusyMargin, y - cBusyBar); | |||
glVertex2i(cBusyMargin, y - cBusyBar); | glVertex2i(cBusyMargin, y - cBusyBar); | |||
glEnd(); | glEnd(); | |||
skipping to change at line 854 | skipping to change at line 854 | |||
/*========================================================================*/ | /*========================================================================*/ | |||
void OrthoKey(PyMOLGlobals * G, unsigned char k, int x, int y, int mod) | void OrthoKey(PyMOLGlobals * G, unsigned char k, int x, int y, int mod) | |||
{ | { | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
char buffer[OrthoLineLength]; | char buffer[OrthoLineLength]; | |||
int curLine; | int curLine; | |||
PRINTFB(G, FB_Ortho, FB_Blather) | PRINTFB(G, FB_Ortho, FB_Blather) | |||
" OrthoKey: %c (%d), x %d y %d, mod %d\n", k, k, x, y, mod ENDFB(G); | " OrthoKey: %c (%d), x %d y %d, mod %d\n", k, k, x, y, mod ENDFB(G); | |||
if(!I->InputFlag) { | OrthoRestorePrompt(G); | |||
if(I->Saved[0]) { | ||||
if(I->CurChar) { | ||||
OrthoNewLine(G, NULL, true); | ||||
} | ||||
curLine = I->CurLine & OrthoSaveLines; | ||||
strcpy(I->Line[curLine], I->Saved); | ||||
I->Saved[0] = 0; | ||||
I->CurChar = I->SavedCC; | ||||
I->PromptChar = I->SavedPC; | ||||
} else { | ||||
if(I->CurChar) { | ||||
OrthoNewLine(G, I->Prompt, true); | ||||
} else { | ||||
curLine = I->CurLine & OrthoSaveLines; | ||||
strcpy(I->Line[curLine], I->Prompt); | ||||
I->CurChar = (I->PromptChar = strlen(I->Prompt)); | ||||
} | ||||
} | ||||
I->InputFlag = 1; | ||||
} | ||||
if(mod == 4) { /* alt */ | if(mod == 4) { /* alt */ | |||
OrthoKeyAlt(G, k); | OrthoKeyAlt(G, k); | |||
} else if (mod == 3) { /* chsh */ | } else if (mod == 3) { /* chsh */ | |||
OrthoKeyCtSh(G,(unsigned int) (k+64)); | OrthoKeyCtSh(G,(unsigned int) (k+64)); | |||
} else if((k > 32) && (k != 127)) { | } else if((k > 32) && (k != 127)) { | |||
curLine = add_normal_char(I, k); | curLine = add_normal_char(I, k); | |||
} else | } else | |||
switch (k) { | switch (k) { | |||
case 32: /* spacebar */ | case 32: /* spacebar */ | |||
if((!OrthoArrowsGrabbed(G)) && | if((!OrthoArrowsGrabbed(G)) && | |||
skipping to change at line 1064 | skipping to change at line 1045 | |||
OrthoRemoveAutoOverlay(G); | OrthoRemoveAutoOverlay(G); | |||
curLine = I->CurLine & OrthoSaveLines; | curLine = I->CurLine & OrthoSaveLines; | |||
I->Line[curLine][I->CurChar] = 0; | I->Line[curLine][I->CurChar] = 0; | |||
strcpy(buffer, I->Line[curLine] + I->PromptChar); | strcpy(buffer, I->Line[curLine] + I->PromptChar); | |||
#ifndef _PYMOL_NOPY | #ifndef _PYMOL_NOPY | |||
if(buffer[0]) { | if(buffer[0]) { | |||
strcpy(I->History[I->HistoryLine], buffer); | strcpy(I->History[I->HistoryLine], buffer); | |||
I->HistoryLine = (I->HistoryLine + 1) & OrthoHistoryLines; | I->HistoryLine = (I->HistoryLine + 1) & OrthoHistoryLines; | |||
I->History[I->HistoryLine][0] = 0; | I->History[I->HistoryLine][0] = 0; | |||
I->HistoryView = I->HistoryLine; | I->HistoryView = I->HistoryLine; | |||
OrthoNewLine(G, NULL, true); | OrthoNewLine(G, NULL, true); | |||
if(WordMatch(G, buffer, "quit", true) == 0) /* don't log quit */ | if(WordMatch(G, buffer, "quit", true) == 0) /* don't log quit */ | |||
PLog(G, buffer, cPLog_pml); | PLog(G, buffer, cPLog_pml); | |||
OrthoDirty(G); /* this will force a redraw, if necessary */ | OrthoDirty(G); /* this will force a redraw, if necessary */ | |||
PParse(G, buffer); | PParse(G, buffer); | |||
OrthoRestorePrompt(G); | OrthoRestorePrompt(G); | |||
} | } | |||
#endif | #endif | |||
I->CursorChar = -1; | I->CursorChar = -1; | |||
} | } | |||
skipping to change at line 1160 | skipping to change at line 1142 | |||
/* if(I->CurChar) | /* if(I->CurChar) | |||
{ */ | { */ | |||
if(I->CurChar) | if(I->CurChar) | |||
OrthoFeedbackIn(G, I->Line[I->CurLine & OrthoSaveLines]); | OrthoFeedbackIn(G, I->Line[I->CurLine & OrthoSaveLines]); | |||
else | else | |||
OrthoFeedbackIn(G, " "); | OrthoFeedbackIn(G, " "); | |||
bool do_print = Feedback(G, FB_Python, FB_Output); | bool do_print = Feedback(G, FB_Python, FB_Output); | |||
bool do_print_with_escapes = false; | bool do_print_with_escapes = false; | |||
#if !defined(_WIN32) && !defined(_WEBGL) && !defined(_PYMOL_LIB) | ||||
do_print_with_escapes = do_print | ||||
&& SettingGetGlobal_b(G, cSetting_colored_feedback) | ||||
&& isatty(STDOUT_FILENO); | ||||
#endif | ||||
// print as-is if stdout supports ANSI Escape sequences | ||||
if (do_print_with_escapes) { | ||||
printf("%s", I->Line[I->CurLine & OrthoSaveLines]); | ||||
} | ||||
// strip ANSI Escape sequences (in-place) | ||||
UtilStripANSIEscapes(I->Line[I->CurLine & OrthoSaveLines]); | ||||
if (do_print) { | if (do_print) { | |||
if (!do_print_with_escapes) { | if (!do_print_with_escapes) { | |||
printf("%s", I->Line[I->CurLine & OrthoSaveLines]); | printf("%s", I->Line[I->CurLine & OrthoSaveLines]); | |||
} | } | |||
if(crlf) { | if(crlf) { | |||
putchar('\n'); | putchar('\n'); | |||
} | } | |||
fflush(stdout); | fflush(stdout); | |||
} | } | |||
skipping to change at line 1296 | skipping to change at line 1292 | |||
* to bg_rgb_bottom is bg_gradient is set | * to bg_rgb_bottom is bg_gradient is set | |||
*/ | */ | |||
#define BACKGROUND_TEXTURE_SIZE 256 | #define BACKGROUND_TEXTURE_SIZE 256 | |||
GLuint OrthoGetBackgroundTextureID(PyMOLGlobals * G){ | GLuint OrthoGetBackgroundTextureID(PyMOLGlobals * G){ | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
return I->bg_texture_id; | return I->bg_texture_id; | |||
} | } | |||
void OrthoInvalidateBackgroundTexture(PyMOLGlobals * G){ | ||||
COrtho *I = G->Ortho; | ||||
if (I->bg_texture_id){ | ||||
glDeleteTextures(1, &I->bg_texture_id); | ||||
I->bg_texture_id = 0; | ||||
I->bg_texture_needs_update = 1; | ||||
} | ||||
if (I->bgCGO){ | ||||
CGOFree(I->bgCGO); | ||||
} | ||||
} | ||||
void OrthoBackgroundTextureNeedsUpdate(PyMOLGlobals * G){ | void OrthoBackgroundTextureNeedsUpdate(PyMOLGlobals * G){ | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
I->bg_texture_needs_update = 1; | I->bg_texture_needs_update = 1; | |||
} | } | |||
void bg_grad(PyMOLGlobals * G) { | void bg_grad(PyMOLGlobals * G) { | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
float top[3]; | float top[3]; | |||
float bottom[3]; | float bottom[3]; | |||
int bg_gradient = SettingGet_b(G, NULL, NULL, cSetting_bg_gradient); | int bg_gradient = SettingGet_b(G, NULL, NULL, cSetting_bg_gradient); | |||
int bg_image_mode = SettingGet_b(G, NULL, NULL, cSetting_bg_image_mode); | ||||
const char * bg_image_filename = SettingGetGlobal_s(G, cSetting_bg_image_filen | ||||
ame); | ||||
short bg_image = bg_image_filename && bg_image_filename[0]; | ||||
short bg_is_solid = 0; | short bg_is_solid = 0; | |||
short is_repeat = bg_gradient ? 0 : 1; | ||||
int ok = true; | int ok = true; | |||
copy3f(ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_bg_rgb_top)), top) ; | copy3f(ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_bg_rgb_top)), top) ; | |||
copy3f(ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_bg_rgb_bottom)), b ottom); | copy3f(ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_bg_rgb_bottom)), b ottom); | |||
if (!bg_gradient){ | if (!bg_gradient && !bg_image && !I->bgData){ | |||
float zero[3] = { 0.f, 0.f, 0.f } ; | const float *bg_rgb = ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_b | |||
float *bg_rgb = ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_bg_rgb) | g_rgb)); | |||
); | SceneGLClearColor(bg_rgb[0], bg_rgb[1], bg_rgb[2], 1.0); | |||
bg_is_solid = !equal3f(bg_rgb, zero); | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); | |||
if (!bg_is_solid) | ||||
return; | return; | |||
} | } | |||
if (!CShaderMgr_ShadersPresent(G->ShaderMgr)){ | if (!G->ShaderMgr->ShadersPresent()){ | |||
float zero[3] = { 0.f, 0.f, 0.f } ; | float zero[3] = { 0.f, 0.f, 0.f } ; | |||
float *bg_rgb = ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_bg_rgb) ); | const float *bg_rgb = ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_b g_rgb)); | |||
bg_is_solid = !equal3f(bg_rgb, zero); | bg_is_solid = !equal3f(bg_rgb, zero); | |||
if (bg_is_solid){ | ||||
SceneGLClearColor(bg_rgb[0], bg_rgb[1], bg_rgb[2], 1.0); | SceneGLClearColor(bg_rgb[0], bg_rgb[1], bg_rgb[2], 1.0); | |||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); | |||
} | ||||
return; | return; | |||
} | ||||
if (bg_image || I->bgData){ | ||||
is_repeat = (bg_image_mode==0 || bg_image_mode==1) ? 0 : 1; | ||||
} | } | |||
glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | |||
{ | { | |||
if (!I->bgCGO) { | if (!I->bgCGO) { | |||
CGO *cgo = CGONew(G), *cgo2 = NULL; | CGO *cgo = CGONew(G), *cgo2 = NULL; | |||
ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); | ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); | |||
if (ok) | if (ok) | |||
ok &= CGOVertex(cgo, -1.f, -1.f, 0.98f); | ok &= CGOVertex(cgo, -1.f, -1.f, 0.98f); | |||
skipping to change at line 1355 | skipping to change at line 1367 | |||
ok &= CGOEnd(cgo); | ok &= CGOEnd(cgo); | |||
if (ok) | if (ok) | |||
ok &= CGOStop(cgo); | ok &= CGOStop(cgo); | |||
if (ok) | if (ok) | |||
cgo2 = CGOCombineBeginEnd(cgo, 0); | cgo2 = CGOCombineBeginEnd(cgo, 0); | |||
CHECKOK(ok, cgo2); | CHECKOK(ok, cgo2); | |||
CGOFree(cgo); | CGOFree(cgo); | |||
if (ok) | if (ok) | |||
I->bgCGO = CGOOptimizeToVBONotIndexed(cgo2, 0); | I->bgCGO = CGOOptimizeToVBONotIndexed(cgo2, 0); | |||
if (ok){ | if (ok){ | |||
CGOChangeShadersTo(I->bgCGO, GL_DEFAULT_SHADER, GL_BACKGROUND_SHADER); | CGOChangeShadersTo(I->bgCGO, GL_DEFAULT_SHADER_WITH_SETTINGS, GL_BACKGROU ND_SHADER); | |||
I->bgCGO->use_shader = true; | I->bgCGO->use_shader = true; | |||
} else { | } else { | |||
CGOFree(I->bgCGO); | CGOFree(I->bgCGO); | |||
I->bgCGO = NULL; | ||||
} | } | |||
CGOFree(cgo2); | CGOFree(cgo2); | |||
} | } | |||
if (ok && !bg_is_solid && (I->bgData && (!I->bg_texture_id || I->bg_texture_ needs_update))){ | if (ok && !bg_is_solid && (I->bgData && (!I->bg_texture_id || I->bg_texture_ needs_update))){ | |||
short is_new = !I->bg_texture_id; | short is_new = !I->bg_texture_id; | |||
if (is_new){ | if (is_new){ | |||
glGenTextures(1, &I->bg_texture_id); | glGenTextures(1, &I->bg_texture_id); | |||
} | } | |||
glActiveTexture(GL_TEXTURE4); | glActiveTexture(GL_TEXTURE4); | |||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | |||
glBindTexture(GL_TEXTURE_2D, I->bg_texture_id); | glBindTexture(GL_TEXTURE_2D, I->bg_texture_id); | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | GL_CLAMP_TO_EDGE); | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : | ||||
GL_CLAMP_TO_EDGE); | ||||
{ | { | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_linea | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | r); | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? G | ||||
L_LINEAR : GL_NEAREST); | ||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? G | ||||
L_LINEAR : GL_NEAREST); | ||||
} | } | |||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | |||
I->bgWidth, I->bgHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)I->bgData); | I->bgWidth, I->bgHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)I->bgData); | |||
bg_image = false; | ||||
bg_gradient = I->bg_texture_needs_update = 0; | ||||
} | ||||
if (ok && !bg_is_solid && (bg_image && (!I->bg_texture_id || I->bg_texture_n | ||||
eeds_update))){ | ||||
// checking to see if bg_image_filename can be loaded into texture | ||||
ImageType *bgImage = Calloc(ImageType, 1); | ||||
if(MyPNGRead(bg_image_filename, | ||||
(unsigned char **) &bgImage->data, | ||||
(unsigned int *) &bgImage->width, (unsigned int *) &bgImage->h | ||||
eight)) { | ||||
short is_new = !I->bg_texture_id; | ||||
int buff_total = bgImage->width * bgImage->height; | ||||
I->bgWidth = bgImage->width; | ||||
I->bgHeight = bgImage->height; | ||||
bgImage->size = buff_total * 4; | ||||
if (is_new){ | ||||
glGenTextures(1, &I->bg_texture_id); | ||||
} | ||||
glActiveTexture(GL_TEXTURE4); | ||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | ||||
glBindTexture(GL_TEXTURE_2D, I->bg_texture_id); | ||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : | ||||
GL_CLAMP_TO_EDGE); | ||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : | ||||
GL_CLAMP_TO_EDGE); | ||||
{ | ||||
int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_lin | ||||
ear); | ||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? | ||||
GL_LINEAR : GL_NEAREST); | ||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? | ||||
GL_LINEAR : GL_NEAREST); | ||||
} | ||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | ||||
bgImage->width, bgImage->height, 0, GL_RGBA, GL_UNSIGNED_BYT | ||||
E, (GLvoid*)bgImage->data); | ||||
FreeP(bgImage->data); | ||||
bg_gradient = I->bg_texture_needs_update = 0; | bg_gradient = I->bg_texture_needs_update = 0; | |||
} else { | ||||
I->bgWidth = 0; | ||||
I->bgHeight = 0; | ||||
PRINTFB(G, FB_Ortho, FB_Errors) | ||||
"Ortho: bg_grad: bg_image_filename='%s' cannot be loaded, unset\n", bg_ | ||||
image_filename | ||||
ENDFB(G); | ||||
SettingSetGlobal_s(G, cSetting_bg_image_filename, ""); | ||||
G->ShaderMgr->Reload_All_Shaders(); | ||||
} | ||||
FreeP(bgImage); | ||||
} | } | |||
if (ok && !bg_is_solid && bg_gradient && (!I->bg_texture_id || I->bg_texture _needs_update)){ | if (ok && !bg_is_solid && bg_gradient && (!I->bg_texture_id || I->bg_texture _needs_update)){ | |||
short is_new = !I->bg_texture_id; | short is_new = !I->bg_texture_id; | |||
int tex_dim = BACKGROUND_TEXTURE_SIZE; | int tex_dim = BACKGROUND_TEXTURE_SIZE; | |||
int buff_total = tex_dim * tex_dim; | int buff_total = tex_dim * tex_dim; | |||
unsigned char *temp_buffer = Alloc(unsigned char, buff_total * 4); | unsigned char *temp_buffer = Alloc(unsigned char, buff_total * 4); | |||
I->bg_texture_needs_update = 0; | I->bg_texture_needs_update = 0; | |||
I->bgWidth = BACKGROUND_TEXTURE_SIZE; | I->bgWidth = BACKGROUND_TEXTURE_SIZE; | |||
I->bgHeight = BACKGROUND_TEXTURE_SIZE; | I->bgHeight = BACKGROUND_TEXTURE_SIZE; | |||
if (is_new){ | if (is_new){ | |||
glGenTextures(1, &I->bg_texture_id); | glGenTextures(1, &I->bg_texture_id); | |||
} | } | |||
glActiveTexture(GL_TEXTURE4); | glActiveTexture(GL_TEXTURE4); | |||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | |||
glBindTexture(GL_TEXTURE_2D, I->bg_texture_id); | glBindTexture(GL_TEXTURE_2D, I->bg_texture_id); | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | GL_CLAMP_TO_EDGE); | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : | ||||
GL_CLAMP_TO_EDGE); | ||||
{ | { | |||
int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_linea r); | int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_linea r); | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST); | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST); | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST); | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST); | |||
} | } | |||
UtilZeroMem(temp_buffer, buff_total * 4); | UtilZeroMem(temp_buffer, buff_total * 4); | |||
{ | { | |||
int a, b; | int a, b; | |||
unsigned char *q, val[4]; | unsigned char *q, val[4]; | |||
skipping to change at line 1433 | skipping to change at line 1487 | |||
*(q++) = val[2]; | *(q++) = val[2]; | |||
*(q++) = 255; | *(q++) = 255; | |||
} | } | |||
} | } | |||
} | } | |||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | |||
tex_dim, tex_dim, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)temp_ buffer); | tex_dim, tex_dim, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)temp_ buffer); | |||
FreeP(temp_buffer); | FreeP(temp_buffer); | |||
} | } | |||
if (ok && I->bgCGO) { | if (ok && I->bgCGO) { | |||
CShaderPrg *shaderPrg = CShaderPrg_Get_BackgroundShader(G); | ||||
if (shaderPrg){ | ||||
CGORenderGL(I->bgCGO, NULL, NULL, NULL, NULL, NULL); | CGORenderGL(I->bgCGO, NULL, NULL, NULL, NULL, NULL); | |||
CShaderPrg_Disable(shaderPrg); | ||||
glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | |||
} | ||||
} | } | |||
} | } | |||
glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | |||
} | } | |||
void OrthoDoDraw(PyMOLGlobals * G, int render_mode) | void OrthoDoDraw(PyMOLGlobals * G, int render_mode) | |||
{ | { | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
CGO *orthoCGO = NULL; | CGO *orthoCGO = NULL; | |||
int x, y; | int x, y; | |||
int l, lcount; | int l, lcount; | |||
char *str; | char *str; | |||
float *v; | ||||
int showLines; | int showLines; | |||
int height; | int height; | |||
int overlay, text; | int overlay, text; | |||
int rightSceneMargin; | int rightSceneMargin; | |||
int internal_feedback; | int internal_feedback; | |||
int times = 1, origtimes = 0; | int times = 1, origtimes = 0; | |||
int double_pump = false; | int double_pump = false; | |||
float *bg_color; | const float *bg_color; | |||
int skip_prompt = 0; | int skip_prompt = 0; | |||
int render = false; | int render = false; | |||
int internal_gui_mode = SettingGetGlobal_i(G, cSetting_internal_gui_mode); | int internal_gui_mode = SettingGetGlobal_i(G, cSetting_internal_gui_mode); | |||
int generate_shader_cgo = 0; | int generate_shader_cgo = 0; | |||
I->RenderMode = render_mode; | I->RenderMode = render_mode; | |||
if(SettingGetGlobal_b(G, cSetting_seq_view)) { | if(SettingGetGlobal_b(G, cSetting_seq_view)) { | |||
SeqUpdate(G); | SeqUpdate(G); | |||
I->HaveSeqViewer = true; | I->HaveSeqViewer = true; | |||
} else if(I->HaveSeqViewer) { | } else if(I->HaveSeqViewer) { | |||
SeqUpdate(G); | SeqUpdate(G); | |||
I->HaveSeqViewer = false; | I->HaveSeqViewer = false; | |||
} | } | |||
if(SettingGet_i(G, NULL, NULL, cSetting_internal_prompt)) | if(SettingGet_i(G, NULL, NULL, cSetting_internal_prompt)) | |||
skipping to change at line 1518 | skipping to change at line 1568 | |||
default: | default: | |||
rightSceneMargin = 0; | rightSceneMargin = 0; | |||
break; | break; | |||
} | } | |||
} else { | } else { | |||
rightSceneMargin = 0; | rightSceneMargin = 0; | |||
} | } | |||
internal_feedback = SettingGetGlobal_i(G, cSetting_internal_feedback); | internal_feedback = SettingGetGlobal_i(G, cSetting_internal_feedback); | |||
v = ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_bg_rgb)); | ||||
overlay = OrthoGetOverlayStatus(G); | overlay = OrthoGetOverlayStatus(G); | |||
switch (overlay) { | switch (overlay) { | |||
case -1: /* auto overlay */ | case -1: /* auto overlay */ | |||
overlay = I->CurLine - I->AutoOverlayStopLine; | overlay = I->CurLine - I->AutoOverlayStopLine; | |||
if(overlay < 0) { | if(overlay < 0) { | |||
overlay += (OrthoSaveLines + 1); | overlay += (OrthoSaveLines + 1); | |||
} | } | |||
if(internal_feedback > 1) { | if(internal_feedback > 1) { | |||
overlay -= (internal_feedback - 1); | overlay -= (internal_feedback - 1); | |||
} | } | |||
skipping to change at line 1571 | skipping to change at line 1620 | |||
double_pump = false; | double_pump = false; | |||
} | } | |||
I->DrawTime = -I->LastDraw; | I->DrawTime = -I->LastDraw; | |||
I->LastDraw = UtilGetSeconds(G); | I->LastDraw = UtilGetSeconds(G); | |||
I->DrawTime += I->LastDraw; | I->DrawTime += I->LastDraw; | |||
ButModeSetRate(G, (float) I->DrawTime); | ButModeSetRate(G, (float) I->DrawTime); | |||
if(render && (render_mode < 2)) | if(render && (render_mode < 2)) | |||
SceneRender(G, NULL, 0, 0, NULL, 0, 0, 0, | SceneRender(G, NULL, 0, 0, NULL, 0, 0, 0, | |||
SettingGetGlobal_b(G, cSetting_image_copy_always), 0); | SettingGetGlobal_b(G, cSetting_image_copy_always)); | |||
else if (text){ | else if (text){ | |||
SceneRender(G, NULL, 0, 0, NULL, 0, 0, 0, | bg_grad(G); // only render the background for text | |||
SettingGetGlobal_b(G, cSetting_image_copy_always), 1 /* just_b | ||||
ackground */); | ||||
} | } | |||
SceneGLClearColor(0.0, 0.0, 0.0, 1.0); | SceneGLClearColor(0.0, 0.0, 0.0, 1.0); | |||
origtimes = times; | origtimes = times; | |||
while(times--) { | while(times--) { | |||
switch (times) { | switch (times) { | |||
case 1: | case 1: | |||
OrthoDrawBuffer(G, GL_BACK_LEFT); | OrthoDrawBuffer(G, GL_BACK_LEFT); | |||
skipping to change at line 1596 | skipping to change at line 1644 | |||
case 0: | case 0: | |||
if(double_pump) { | if(double_pump) { | |||
OrthoDrawBuffer(G, GL_BACK_RIGHT); | OrthoDrawBuffer(G, GL_BACK_RIGHT); | |||
} else | } else | |||
OrthoDrawBuffer(G, GL_BACK); | OrthoDrawBuffer(G, GL_BACK); | |||
break; | break; | |||
} | } | |||
OrthoPushMatrix(G); | OrthoPushMatrix(G); | |||
if (CShaderMgr_ShadersPresent(G->ShaderMgr)){ | if (G->ShaderMgr->ShadersPresent()){ | |||
if(SettingGetGlobal_b(G, cSetting_internal_gui) && | if(SettingGetGlobal_b(G, cSetting_internal_gui) && | |||
SettingGetGlobal_b(G, cSetting_use_shaders)){ | SettingGetGlobal_b(G, cSetting_use_shaders)){ | |||
CGO *orthoFastCGO = CGONew(G); | CGO *orthoFastCGO = CGONew(G); | |||
if (I->orthoFastCGO) | ||||
CGOFree(I->orthoFastCGO); | CGOFree(I->orthoFastCGO); | |||
I->orthoFastCGO = NULL; | ||||
if (BlockRecursiveFastDraw(I->Blocks ORTHOFASTCGOARGVAR)){ | if (BlockRecursiveFastDraw(I->Blocks ORTHOFASTCGOARGVAR)){ | |||
int ok = true; | int ok = true; | |||
CGO *expandedCGO; | CGO *expandedCGO; | |||
CGOStop(orthoFastCGO); | CGOStop(orthoFastCGO); | |||
expandedCGO = CGOExpandDrawTextures(orthoFastCGO, 0); | expandedCGO = CGOExpandDrawTextures(orthoFastCGO, 0); | |||
CHECKOK(ok, expandedCGO); | CHECKOK(ok, expandedCGO); | |||
if (ok) | if (ok) | |||
I->orthoFastCGO = CGOOptimizeScreenTexturesAndPolygons(expandedCGO, 0); | I->orthoFastCGO = CGOOptimizeScreenTexturesAndPolygons(expandedCGO, 0); | |||
CHECKOK(ok, I->orthoFastCGO); | CHECKOK(ok, I->orthoFastCGO); | |||
CGOFree(orthoFastCGO); | CGOFree(orthoFastCGO); | |||
CGOFree(expandedCGO); | CGOFree(expandedCGO); | |||
if (ok){ | ||||
CGOStop(I->orthoFastCGO); | ||||
I->orthoFastCGO->use_shader = true; | ||||
} else { | ||||
CGOFree(I->orthoFastCGO); | ||||
} | ||||
} else { | } else { | |||
CGOFree(orthoFastCGO); | CGOFree(orthoFastCGO); | |||
orthoFastCGO = NULL; | ||||
} | } | |||
if (!I->orthoCGO){ | if (!I->orthoCGO){ | |||
orthoCGO = CGONew(G); | orthoCGO = CGONew(G); | |||
generate_shader_cgo = true; | generate_shader_cgo = true; | |||
} else { | } else { | |||
OrthoRenderCGO(G); | OrthoRenderCGO(G); | |||
OrthoPopMatrix(G); | OrthoPopMatrix(G); | |||
continue; | continue; | |||
} | } | |||
} | } | |||
skipping to change at line 1760 | skipping to change at line 1799 | |||
TextSetColor(G, I->TextColor); | TextSetColor(G, I->TextColor); | |||
} | } | |||
} else | } else | |||
TextSetColor(G, I->OverlayColor); | TextSetColor(G, I->OverlayColor); | |||
TextSetPos2i(G, x, y); | TextSetPos2i(G, x, y); | |||
if(str) { | if(str) { | |||
TextDrawStr(G, str ORTHOCGOARGVAR); | TextDrawStr(G, str ORTHOCGOARGVAR); | |||
if((lcount == 1) && (I->InputFlag)) { | if((lcount == 1) && (I->InputFlag)) { | |||
if(!skip_prompt) { | if(!skip_prompt) { | |||
if(I->CursorChar >= 0) { | if(I->CursorChar >= 0) { | |||
TextSetPos2i(G, x + 8 * I->CursorChar, y); | TextSetPos2i(G, x + cOrthoCharWidth * I->CursorChar, y); | |||
} | } | |||
TextDrawChar(G, '_' ORTHOCGOARGVAR); | TextDrawChar(G, '_' ORTHOCGOARGVAR); | |||
} | } | |||
} | } | |||
} | } | |||
l = (I->CurLine - (lcount + skip_prompt)) & OrthoSaveLines; | l = (I->CurLine - (lcount + skip_prompt)) & OrthoSaveLines; | |||
y = y + cOrthoLineHeight; | y = y + cOrthoLineHeight; | |||
} | } | |||
} | } | |||
skipping to change at line 1789 | skipping to change at line 1828 | |||
BlockRecursiveDraw(I->Blocks ORTHOCGOARGVAR); | BlockRecursiveDraw(I->Blocks ORTHOCGOARGVAR); | |||
block->active = active_tmp; | block->active = active_tmp; | |||
} else { | } else { | |||
BlockRecursiveDraw(I->Blocks ORTHOCGOARGVAR); | BlockRecursiveDraw(I->Blocks ORTHOCGOARGVAR); | |||
} | } | |||
PRINTFD(G, FB_Ortho) | PRINTFD(G, FB_Ortho) | |||
" OrthoDoDraw: blocks drawn.\n" ENDFD; | " OrthoDoDraw: blocks drawn.\n" ENDFD; | |||
if(I->LoopFlag) { | if(I->LoopFlag) { | |||
const float *vc = ColorGet(G, cColorFront); | ||||
if (generate_shader_cgo){ | if (generate_shader_cgo){ | |||
CGOColor(orthoCGO, 1.f, 1.f, 1.f); | CGOColor(orthoCGO, vc[0], vc[1], vc[2]); | |||
CGOBegin(orthoCGO, GL_TRIANGLE_STRIP); | CGOBegin(orthoCGO, GL_TRIANGLE_STRIP); | |||
CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.bottom, 0.f); | CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.bottom, 0.f); | |||
CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.top+1, 0.f); | CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.top+1, 0.f); | |||
CGOVertex(orthoCGO, I->LoopRect.left+1, I->LoopRect.bottom, 0.f); | CGOVertex(orthoCGO, I->LoopRect.left+1, I->LoopRect.bottom, 0.f); | |||
CGOVertex(orthoCGO, I->LoopRect.left+1, I->LoopRect.top+1, 0.f); | CGOVertex(orthoCGO, I->LoopRect.left+1, I->LoopRect.top+1, 0.f); | |||
CGOEnd(orthoCGO); | CGOEnd(orthoCGO); | |||
CGOBegin(orthoCGO, GL_TRIANGLE_STRIP); | CGOBegin(orthoCGO, GL_TRIANGLE_STRIP); | |||
CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.top, 0.f); | CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.top, 0.f); | |||
CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.top+1, 0.f); | CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.top+1, 0.f); | |||
skipping to change at line 1817 | skipping to change at line 1857 | |||
CGOVertex(orthoCGO, I->LoopRect.right+1, I->LoopRect.bottom, 0.f); | CGOVertex(orthoCGO, I->LoopRect.right+1, I->LoopRect.bottom, 0.f); | |||
CGOVertex(orthoCGO, I->LoopRect.right+1, I->LoopRect.top+1, 0.f); | CGOVertex(orthoCGO, I->LoopRect.right+1, I->LoopRect.top+1, 0.f); | |||
CGOEnd(orthoCGO); | CGOEnd(orthoCGO); | |||
CGOBegin(orthoCGO, GL_TRIANGLE_STRIP); | CGOBegin(orthoCGO, GL_TRIANGLE_STRIP); | |||
CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.bottom, 0.f); | CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.bottom, 0.f); | |||
CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.bottom+1, 0.f); | CGOVertex(orthoCGO, I->LoopRect.left, I->LoopRect.bottom+1, 0.f); | |||
CGOVertex(orthoCGO, I->LoopRect.right, I->LoopRect.bottom, 0.f); | CGOVertex(orthoCGO, I->LoopRect.right, I->LoopRect.bottom, 0.f); | |||
CGOVertex(orthoCGO, I->LoopRect.right, I->LoopRect.bottom+1, 0.f); | CGOVertex(orthoCGO, I->LoopRect.right, I->LoopRect.bottom+1, 0.f); | |||
CGOEnd(orthoCGO); | CGOEnd(orthoCGO); | |||
} else { | } else { | |||
glColor3f(1.0, 1.0, 1.0); | glColor3f(vc[0], vc[1], vc[2]); | |||
glBegin(GL_LINE_LOOP); | glBegin(GL_LINE_LOOP); | |||
glVertex2i(I->LoopRect.left, I->LoopRect.top); | glVertex2i(I->LoopRect.left, I->LoopRect.top); | |||
glVertex2i(I->LoopRect.right, I->LoopRect.top); | glVertex2i(I->LoopRect.right, I->LoopRect.top); | |||
glVertex2i(I->LoopRect.right, I->LoopRect.bottom); | glVertex2i(I->LoopRect.right, I->LoopRect.bottom); | |||
glVertex2i(I->LoopRect.left, I->LoopRect.bottom); | glVertex2i(I->LoopRect.left, I->LoopRect.bottom); | |||
glVertex2i(I->LoopRect.left, I->LoopRect.top); | glVertex2i(I->LoopRect.left, I->LoopRect.top); | |||
glEnd(); | glEnd(); | |||
} | } | |||
} | } | |||
skipping to change at line 1862 | skipping to change at line 1902 | |||
if(Feedback(G, FB_OpenGL, FB_Debugging)) | if(Feedback(G, FB_OpenGL, FB_Debugging)) | |||
PyMOLCheckOpenGLErr("OrthoDoDraw final checkpoint"); | PyMOLCheckOpenGLErr("OrthoDoDraw final checkpoint"); | |||
} /* while */ | } /* while */ | |||
} | } | |||
if (generate_shader_cgo){ | if (generate_shader_cgo){ | |||
int ok = true; | int ok = true; | |||
/* This implements one shader for both text and solid polygons rendered for | { | |||
the orthoCGO */ | #ifdef SHOW_FONT_TEXTURE | |||
/* This shows the font texture in the middle of the screen, we might want | ||||
to debug it */ | ||||
CGO *testOrthoCGO = orthoCGO; | ||||
// CGO *testOrthoCGO = CGONew(G); | ||||
float minx = 100.f, maxx = 612.f, miny = 100.f, maxy = 612.f; | ||||
short texcoord = true; | ||||
CGOAlpha(testOrthoCGO, .5f); | ||||
CGOColor(testOrthoCGO, 0.f, 0.f, 0.f); | ||||
CGOBegin(testOrthoCGO, GL_TRIANGLE_STRIP); | ||||
if (texcoord) | ||||
CGOTexCoord2f(testOrthoCGO, 1.f, 1.f); | ||||
CGOVertex(testOrthoCGO, maxx, maxy, 0.f); | ||||
if (texcoord) | ||||
CGOTexCoord2f(testOrthoCGO, 1.f, 0.f); | ||||
CGOVertex(testOrthoCGO, maxx, miny, 0.f); | ||||
if (texcoord) | ||||
CGOTexCoord2f(testOrthoCGO, 0.f, 1.f); | ||||
CGOVertex(testOrthoCGO, minx, maxy, 0.f); | ||||
if (texcoord) | ||||
CGOTexCoord2f(testOrthoCGO, 0.f, 0.f); | ||||
CGOVertex(testOrthoCGO, minx, miny, 0.f); | ||||
CGOEnd(testOrthoCGO); | ||||
CGOStop(testOrthoCGO); | ||||
#else | ||||
CGOStop(orthoCGO); | CGOStop(orthoCGO); | |||
#endif | ||||
} | ||||
{ | { | |||
CGO *expandedCGO = CGOExpandDrawTextures(orthoCGO, 0); | CGO *expandedCGO = CGOExpandDrawTextures(orthoCGO, 0); | |||
CHECKOK(ok, expandedCGO); | CHECKOK(ok, expandedCGO); | |||
if (ok) | if (ok) | |||
I->orthoCGO = CGOOptimizeScreenTexturesAndPolygons(expandedCGO, 0); | I->orthoCGO = CGOOptimizeScreenTexturesAndPolygons(expandedCGO, 0); | |||
CHECKOK(ok, I->orthoCGO); | ||||
CGOFree(orthoCGO); | CGOFree(orthoCGO); | |||
CGOFree(expandedCGO); | CGOFree(expandedCGO); | |||
if (ok){ | ||||
CGOStop(I->orthoCGO); | ||||
I->orthoCGO->use_shader = true; | ||||
} | ||||
while(origtimes--){ | while(origtimes--){ | |||
switch (origtimes){ | switch (origtimes){ | |||
case 1: | case 1: | |||
OrthoDrawBuffer(G, GL_BACK_LEFT); | OrthoDrawBuffer(G, GL_BACK_LEFT); | |||
break; | break; | |||
case 0: | case 0: | |||
if(double_pump) { | if(double_pump) { | |||
OrthoDrawBuffer(G, GL_BACK_RIGHT); | OrthoDrawBuffer(G, GL_BACK_RIGHT); | |||
} else | } else | |||
skipping to change at line 1905 | skipping to change at line 1966 | |||
I->DirtyFlag = false; | I->DirtyFlag = false; | |||
PRINTFD(G, FB_Ortho) | PRINTFD(G, FB_Ortho) | |||
" OrthoDoDraw: leaving...\n" ENDFD; | " OrthoDoDraw: leaving...\n" ENDFD; | |||
} | } | |||
void OrthoRenderCGO(PyMOLGlobals * G){ | void OrthoRenderCGO(PyMOLGlobals * G){ | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
if (I->orthoCGO) { | if (I->orthoCGO) { | |||
SceneDrawImageOverlay(G, NULL); | SceneDrawImageOverlay(G, 0, NULL); | |||
glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | |||
glEnable(GL_BLEND); | glEnable(GL_BLEND); | |||
if (I->orthoCGO) | if (I->orthoCGO) | |||
CGORenderGL(I->orthoCGO, NULL, NULL, NULL, NULL, NULL); | CGORenderGL(I->orthoCGO, NULL, NULL, NULL, NULL, NULL); | |||
if (I->orthoFastCGO) | if (I->orthoFastCGO) | |||
CGORenderGL(I->orthoFastCGO, NULL, NULL, NULL, NULL, NULL); | CGORenderGL(I->orthoFastCGO, NULL, NULL, NULL, NULL, NULL); | |||
CShaderPrg_Disable(CShaderPrg_Get_Current_Shader(G)); | if (G->ShaderMgr->Get_Current_Shader()) | |||
G->ShaderMgr->Get_Current_Shader()->Disable(); | ||||
glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | |||
} | } | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
void OrthoDrawWizardPrompt(PyMOLGlobals * G ORTHOCGOARG) | void OrthoDrawWizardPrompt(PyMOLGlobals * G ORTHOCGOARG) | |||
{ | { | |||
/* assumes PMGUI */ | /* assumes PMGUI */ | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
char *vla, *p; | char *vla, *p; | |||
int nLine; | int nLine; | |||
int x, y, xx; | int x, y; | |||
int nChar, c, ll; | int nChar, c, ll; | |||
int maxLen; | int maxLen; | |||
BlockRect rect; | BlockRect rect; | |||
int prompt_mode = SettingGetGlobal_i(G, cSetting_wizard_prompt_mode); | int prompt_mode = SettingGetGlobal_i(G, cSetting_wizard_prompt_mode); | |||
int gui_mode = SettingGetGlobal_b(G, cSetting_internal_gui_mode); | int gui_mode = SettingGetGlobal_b(G, cSetting_internal_gui_mode); | |||
float *text_color = I->WizardTextColor; | float *text_color = I->WizardTextColor; | |||
float black[3] = { 0.0F, 0.0F, 0.0F }; | float black[3] = { 0.0F, 0.0F, 0.0F }; | |||
if(I->WizardPromptVLA && prompt_mode) { | if(I->WizardPromptVLA && prompt_mode) { | |||
vla = I->WizardPromptVLA; | vla = I->WizardPromptVLA; | |||
skipping to change at line 1960 | skipping to change at line 2021 | |||
p = vla; | p = vla; | |||
ll = 0; | ll = 0; | |||
c = nChar; | c = nChar; | |||
while(c > 0) { | while(c > 0) { | |||
if(!*p) { | if(!*p) { | |||
if(maxLen < ll) | if(maxLen < ll) | |||
maxLen = ll; | maxLen = ll; | |||
ll = 0; | ll = 0; | |||
p++; | p++; | |||
c--; | c--; | |||
} else if(((*p) == '\\') && /* color encoded */ | } else if(TextStartsWithColorCode(p)) { | |||
(p[1] >= '0') && (p[1] <= '9') && (p[2] >= '0') && (p[2] <= '9 | ||||
') && (p[3] >= '0') && (p[3] <= '9')) { /* relying upon short-circuit logic to a | ||||
void overrun */ | ||||
p += 4; | p += 4; | |||
c -= 4; | c -= 4; | |||
} else { | } else { | |||
ll++; | ll++; | |||
p++; | p++; | |||
c--; | c--; | |||
} | } | |||
} | } | |||
/* determine the coordinates from which to draw the text; | /* determine the coordinates from which to draw the text; | |||
skipping to change at line 2032 | skipping to change at line 2092 | |||
x = rect.left + cWizardBorder; | x = rect.left + cWizardBorder; | |||
y = rect.top - (cWizardBorder + cOrthoLineHeight); | y = rect.top - (cWizardBorder + cOrthoLineHeight); | |||
vla = I->WizardPromptVLA; | vla = I->WizardPromptVLA; | |||
/* count max line length */ | /* count max line length */ | |||
TextSetColor(G, text_color); | TextSetColor(G, text_color); | |||
TextSetPos2i(G, x, y); | TextSetPos2i(G, x, y); | |||
xx = x; | ||||
p = vla; | p = vla; | |||
ll = 0; | ll = 0; | |||
c = nChar; | c = nChar; | |||
/* set the char color, position the characters and draw the text */ | /* set the char color, position the characters and draw the text */ | |||
while(c > 0) { | while(c > 0) { | |||
if(*p) { | if(TextSetColorFromCode(G, p, text_color)) { | |||
if((*p == '\\') && (*(p + 1)) && (*(p + 2)) && (*(p + 3))) { | p += 4; | |||
if(*(p + 1) == '-') { | c -= 4; | |||
TextSetColor(G, text_color); | ||||
p += 4; | ||||
c -= 4; | ||||
} else { | ||||
TextSetColor3f(G, (*(p + 1) - '0') / 9.0F, (*(p + 2) - '0') / 9.0F | ||||
, | ||||
(*(p + 3) - '0') / 9.0F); | ||||
p += 4; | ||||
c -= 4; | ||||
} | ||||
TextSetPos2i(G, xx, y); | ||||
} | ||||
} | } | |||
if(c--) { | if(c--) { | |||
if(*p) { | if(*p) { | |||
TextDrawChar(G, *p ORTHOCGOARGVAR); | TextDrawChar(G, *p ORTHOCGOARGVAR); | |||
xx = xx + 8; | ||||
} | } | |||
if(!*(p++)) { | if(!*(p++)) { | |||
y = y - cOrthoLineHeight; | y = y - cOrthoLineHeight; | |||
xx = x; | ||||
TextSetPos2i(G, x, y); | TextSetPos2i(G, x, y); | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
static void OrthoLayoutPanel(PyMOLGlobals * G, | static void OrthoLayoutPanel(PyMOLGlobals * G, | |||
int m_top, int m_left, int m_bottom, int m_right) | int m_top, int m_left, int m_bottom, int m_right) | |||
skipping to change at line 2258 | skipping to change at line 2304 | |||
block = NULL; | block = NULL; | |||
while(ListIterate(I->Blocks, block, next)) | while(ListIterate(I->Blocks, block, next)) | |||
if(block->fReshape) { | if(block->fReshape) { | |||
block->fReshape(block, width, height); | block->fReshape(block, width, height); | |||
} | } | |||
WizardRefresh(G); /* safe to call even if no wizard exists */ | WizardRefresh(G); /* safe to call even if no wizard exists */ | |||
} | } | |||
SceneInvalidateStencil(G); | SceneInvalidateStencil(G); | |||
ShaderMgrResetUniformSet(G); | G->ShaderMgr->ResetUniformSet(); | |||
OrthoInvalidateDoDraw(G); | OrthoInvalidateDoDraw(G); | |||
OrthoDirty(G); | OrthoDirty(G); | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
void OrthoReshapeWizard(PyMOLGlobals * G, ov_size wizHeight) | void OrthoReshapeWizard(PyMOLGlobals * G, ov_size wizHeight) | |||
{ | { | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
I->WizardHeight = wizHeight; | I->WizardHeight = wizHeight; | |||
skipping to change at line 2310 | skipping to change at line 2356 | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
Block *block = NULL; | Block *block = NULL; | |||
int handled = 0; | int handled = 0; | |||
PRINTFB(G, FB_Ortho, FB_Blather) | PRINTFB(G, FB_Ortho, FB_Blather) | |||
"OrthoButton: button:%d, state=%d, x=%d, y=%d, mod=%d\n", | "OrthoButton: button:%d, state=%d, x=%d, y=%d, mod=%d\n", | |||
button,state,x,y,mod | button,state,x,y,mod | |||
ENDFB(G); | ENDFB(G); | |||
switch (button) { | switch (button) { | |||
case 3: | case P_GLUT_BUTTON_SCROLL_FORWARD: | |||
case 4: | case P_GLUT_BUTTON_SCROLL_BACKWARD: | |||
if((button != I->ActiveButton) && (I->ActiveButton>=0) && (I->ActiveButton<3 )) { | if((button != I->ActiveButton) && (I->ActiveButton>=0) && (I->ActiveButton<3 )) { | |||
/* suppress wheel events when a button is already pushed */ | /* suppress wheel events when a button is already pushed */ | |||
return 1; | return 1; | |||
} | } | |||
block = SceneGetBlock(G); | ||||
break; | ||||
} | } | |||
if(I->WrapXFlag) { | if(I->WrapXFlag) { | |||
if(state == P_GLUT_DOWN) { | if(state == P_GLUT_DOWN) { | |||
x = get_wrap_x(x, NULL, G->Option->winX, &I->WrapClickSide); | x = get_wrap_x(x, NULL, G->Option->winX, &I->WrapClickSide); | |||
} else { | } else { | |||
x = get_wrap_x(x, &I->LastX, G->Option->winX, &I->WrapClickSide); | x = get_wrap_x(x, &I->LastX, G->Option->winX, &I->WrapClickSide); | |||
} | } | |||
} else { | } else { | |||
I->WrapClickSide = 0; | I->WrapClickSide = 0; | |||
skipping to change at line 2541 | skipping to change at line 2585 | |||
I->DirtyFlag = true; | I->DirtyFlag = true; | |||
I->ActiveGLBuffer = GL_NONE; | I->ActiveGLBuffer = GL_NONE; | |||
I->LastDraw = UtilGetSeconds(G); | I->LastDraw = UtilGetSeconds(G); | |||
I->DrawTime = 0.0; | I->DrawTime = 0.0; | |||
I->bg_texture_id = 0; | I->bg_texture_id = 0; | |||
I->bg_texture_needs_update = 0; | I->bg_texture_needs_update = 0; | |||
I->bgCGO = NULL; | I->bgCGO = NULL; | |||
I->bgWidth = I->bgHeight = 0; | I->bgWidth = I->bgHeight = 0; | |||
I->bgData = NULL; | I->bgData = NULL; | |||
I->orthoCGO = NULL; | I->orthoCGO = NULL; | |||
I->orthoFastCGO = NULL; | ||||
if(showSplash) { | if(showSplash) { | |||
OrthoSplash(G); | OrthoSplash(G); | |||
I->SplashFlag = true; | I->SplashFlag = true; | |||
} | } | |||
/* OrthoFeedbackIn(G," "); */ | /* OrthoFeedbackIn(G," "); */ | |||
I->CurLine++; | I->CurLine++; | |||
#ifndef _PYMOL_LIB | #ifndef _PYMOL_LIB | |||
/* prompt (and typing) should only be shown for PyMOL, not libpymol */ | /* prompt (and typing) should only be shown for PyMOL, not libpymol */ | |||
strcpy(I->Prompt, "PyMOL>"); | strcpy(I->Prompt, "PyMOL>"); | |||
skipping to change at line 2597 | skipping to change at line 2643 | |||
QueueFree(I->feedback); | QueueFree(I->feedback); | |||
I->feedback = NULL; | I->feedback = NULL; | |||
if(I->deferred) { | if(I->deferred) { | |||
DeferredFree(I->deferred); | DeferredFree(I->deferred); | |||
I->deferred = NULL; | I->deferred = NULL; | |||
} | } | |||
if (I->bgData){ | if (I->bgData){ | |||
FreeP(I->bgData); | FreeP(I->bgData); | |||
I->bgData = NULL; | I->bgData = NULL; | |||
} | } | |||
if (I->bgCGO){ | ||||
CGOFree(I->bgCGO); | CGOFree(I->bgCGO); | |||
} | CGOFree(I->orthoCGO); | |||
CGOFree(I->orthoFastCGO); | ||||
FreeP(G->Ortho); | FreeP(G->Ortho); | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
void OrthoPushMatrix(PyMOLGlobals * G) | void OrthoPushMatrix(PyMOLGlobals * G) | |||
{ | { | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
if(G->HaveGUI && G->ValidContext) { | if(G->HaveGUI && G->ValidContext) { | |||
skipping to change at line 2748 | skipping to change at line 2794 | |||
break; | break; | |||
} | } | |||
} | } | |||
if(execFlag) { | if(execFlag) { | |||
printf("[%s]\n", I->Line[curLine]); | printf("[%s]\n", I->Line[curLine]); | |||
OrthoParseCurrentLine(G); | OrthoParseCurrentLine(G); | |||
} else | } else | |||
I->InputFlag = true; | I->InputFlag = true; | |||
} | } | |||
void OrthoSetBackgroundImage(PyMOLGlobals * G, const char *image_data, int width | ||||
, int height){ | ||||
COrtho *I = G->Ortho; | ||||
int buff_total = width * height; | ||||
short should_update = 0; | ||||
if (I->bgData){ | ||||
FreeP(I->bgData); | ||||
I->bgData = NULL; | ||||
I->bgWidth = 0; | ||||
I->bgHeight = 0; | ||||
should_update = 1; | ||||
} | ||||
if (buff_total){ | ||||
I->bgData = Alloc(unsigned char, buff_total*4); | ||||
I->bgWidth = width; | ||||
I->bgHeight = height; | ||||
memcpy(I->bgData, image_data, buff_total * 4); | ||||
should_update = 1; | ||||
#ifdef _PYMOL_IOS | ||||
{ /* for now, the background is black for background images */ | ||||
float bg[] = {0.f, 0.f, 0.f }; | ||||
ColorUpdateFront(G, bg); | ||||
ExecutiveInvalidateRep(G, "all", cRepAll, cRepInvColor); | ||||
} | ||||
#endif | ||||
} | ||||
if (should_update){ | ||||
G->ShaderMgr->Reload_All_Shaders(); | ||||
I->bg_texture_needs_update = 1; | ||||
} | ||||
} | ||||
void OrthoInvalidateDoDraw(PyMOLGlobals * G) | void OrthoInvalidateDoDraw(PyMOLGlobals * G) | |||
{ | { | |||
COrtho *I = G->Ortho; | COrtho *I = G->Ortho; | |||
if (I->orthoCGO){ | if (I->orthoCGO){ | |||
CGOFree(I->orthoCGO); | CGOFree(I->orthoCGO); | |||
I->orthoCGO = NULL; | ||||
PyMOL_NeedRedisplay(G->PyMOL); | PyMOL_NeedRedisplay(G->PyMOL); | |||
} | } | |||
} | } | |||
End of changes. 68 change blocks. | ||||
118 lines changed or deleted | 209 lines changed or added |