ShaderPrg.cpp (pymol-open-source-2.2.0) | : | ShaderPrg.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 56 | skipping to change at line 56 | |||
#include <stack> | #include <stack> | |||
#include <vector> | #include <vector> | |||
#define SCENEGETIMAGESIZE SceneGetWidthHeight | #define SCENEGETIMAGESIZE SceneGetWidthHeight | |||
using namespace std; | using namespace std; | |||
const float mat3identity[] = { 1., 0., 0., 0., 1., 0., 0., 0., 1. }; | const float mat3identity[] = { 1., 0., 0., 0., 1., 0., 0., 0., 1. }; | |||
#ifdef _PYMOL_ARB_SHADERS | #ifdef _PYMOL_ARB_SHADERS | |||
static | ||||
GLboolean ProgramStringIsNative(PyMOLGlobals * G, | GLboolean ProgramStringIsNative(PyMOLGlobals * G, | |||
GLenum target, GLenum format, | GLenum target, GLenum format, | |||
const string& shaderstr) | const string& shaderstr) | |||
{ | { | |||
GLint errorPos, isNative; | GLint errorPos, isNative; | |||
glProgramStringARB(target, format, shaderstr.length(), shaderstr.c_str()); | glProgramStringARB(target, format, shaderstr.length(), shaderstr.c_str()); | |||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos); | glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos); | |||
glGetProgramivARB(target, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &isNative); | glGetProgramivARB(target, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &isNative); | |||
if((errorPos == -1) && (isNative == 1)) | if((errorPos == -1) && (isNative == 1)) | |||
return GL_TRUE; | return GL_TRUE; | |||
skipping to change at line 129 | skipping to change at line 130 | |||
CShaderPrg * I = new CShaderPrg(G, name, "", ""); | CShaderPrg * I = new CShaderPrg(G, name, "", ""); | |||
I->G = G; | I->G = G; | |||
I->vid = programs[0]; | I->vid = programs[0]; | |||
I->fid = programs[1]; | I->fid = programs[1]; | |||
G->ShaderMgr->AddShaderPrg(I); | G->ShaderMgr->AddShaderPrg(I); | |||
return I; | return I; | |||
} else { | } else { | |||
glDeleteProgramsARB(2, programs); | glDeleteProgramsARB(2, programs); | |||
} | } | |||
} | } | |||
return NULL; | return nullptr; | |||
} | } | |||
int CShaderPrg::DisableARB() { | int CShaderPrg::DisableARB() { | |||
G->ShaderMgr->current_shader = 0; | G->ShaderMgr->current_shader = nullptr; | |||
glDisable(GL_FRAGMENT_PROGRAM_ARB); | glDisable(GL_FRAGMENT_PROGRAM_ARB); | |||
glDisable(GL_VERTEX_PROGRAM_ARB); | glDisable(GL_VERTEX_PROGRAM_ARB); | |||
return 1; | return 1; | |||
} | } | |||
#endif | #endif | |||
// ----------------------------------------------------------------------------- | // ----------------------------------------------------------------------------- | |||
// Uniforms and Attributes | // Uniforms and Attributes | |||
int CShaderPrg::Enable() { | int CShaderPrg::Enable() { | |||
skipping to change at line 160 | skipping to change at line 161 | |||
} | } | |||
/* if so, use the program */ | /* if so, use the program */ | |||
glUseProgram(id); | glUseProgram(id); | |||
// uniform | // uniform | |||
Set1i("isPicking", SettingGetGlobal_b(G, cSetting_pick_shading) ? 1 : G->Shade rMgr->is_picking); | Set1i("isPicking", SettingGetGlobal_b(G, cSetting_pick_shading) ? 1 : G->Shade rMgr->is_picking); | |||
return 1; | return 1; | |||
} | } | |||
int CShaderPrg::Disable() { | int CShaderPrg::Disable() { | |||
glUseProgram(0); | glUseProgram(0); | |||
G->ShaderMgr->current_shader = 0; | G->ShaderMgr->current_shader = nullptr; | |||
glBindTexture(GL_TEXTURE_2D, 0); | glBindTexture(GL_TEXTURE_2D, 0); | |||
glActiveTexture(GL_TEXTURE0); | glActiveTexture(GL_TEXTURE0); | |||
return 1; | return 1; | |||
} | } | |||
int CShaderPrg::IsLinked() { | int CShaderPrg::IsLinked() { | |||
GLint status = GL_FALSE; | GLint status = GL_FALSE; | |||
if (is_linked) { | if (is_linked) { | |||
glGetProgramiv(id, GL_LINK_STATUS, &status); | glGetProgramiv(id, GL_LINK_STATUS, &status); | |||
} | } | |||
skipping to change at line 442 | skipping to change at line 443 | |||
Set1f("shininess_0", settingSpecDirectPower); | Set1f("shininess_0", settingSpecDirectPower); | |||
Set1f("spec_value", settingSpecReflect); | Set1f("spec_value", settingSpecReflect); | |||
Set1f("shininess", settingSpecPower); | Set1f("shininess", settingSpecPower); | |||
} | } | |||
void CShaderPrg::SetBgUniforms() { | void CShaderPrg::SetBgUniforms() { | |||
auto bg_image_tilesize = SettingGet<const float*>(G, cSetting_bg_image_tilesiz e); | auto bg_image_tilesize = SettingGet<const float*>(G, cSetting_bg_image_tilesiz e); | |||
int bg_width, bg_height; | int bg_width, bg_height; | |||
int scene_width, scene_height; | int scene_width, scene_height; | |||
Set3fv("bgSolidColor", ColorGet(G, SettingGet_color(G, NULL, NULL, cSetting_bg _rgb))); | Set3fv("bgSolidColor", ColorGet(G, SettingGet_color(G, nullptr, nullptr, cSett ing_bg_rgb))); | |||
SceneGetWidthHeight(G, &scene_width, &scene_height); | SceneGetWidthHeight(G, &scene_width, &scene_height); | |||
OrthoGetBackgroundSize(G, &bg_width, &bg_height); | std::tie(bg_width, bg_height) = OrthoGetBackgroundSize(*G->Ortho); | |||
Set2f("tiledSize", bg_image_tilesize[0]/(float)scene_width, bg_image_tilesize[ 1]/(float)scene_height); | Set2f("tiledSize", bg_image_tilesize[0]/(float)scene_width, bg_image_tilesize[ 1]/(float)scene_height); | |||
Set2f("tileSize", 1.f/(float)bg_image_tilesize[0], 1.f/(float)bg_image_tilesiz e[1]); | Set2f("tileSize", 1.f/(float)bg_image_tilesize[0], 1.f/(float)bg_image_tilesiz e[1]); | |||
Set2f("viewImageSize", bg_width/(float)scene_width, bg_height/(float)scene_hei ght); | Set2f("viewImageSize", bg_width/(float)scene_width, bg_height/(float)scene_hei ght); | |||
glActiveTexture(GL_TEXTURE4); | glActiveTexture(GL_TEXTURE4); | |||
glBindTexture(GL_TEXTURE_2D, OrthoGetBackgroundTextureID(G)); | glBindTexture(GL_TEXTURE_2D, OrthoGetBackgroundTextureID(G)); | |||
if (!(uniform_set & 4)){ | if (!(uniform_set & 4)){ | |||
Set1i("bgTextureMap", 4); | Set1i("bgTextureMap", 4); | |||
uniform_set |= 4; | uniform_set |= 4; | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 6 lines changed or added |