From ec6f0b25cc47aa8f9880fbeb4e1ec10a0a7e87f5 Mon Sep 17 00:00:00 2001 From: hskwk Date: Sat, 21 Feb 2015 22:27:43 +0900 Subject: [PATCH] 321 --- .../standard/shader/psychlops_g_shader_fig.cpp | 27 ++++++++++++++++++---- .../standard/shader/psychlops_g_shader_fig.h | 8 ++++--- .../gl/extension/psychlops_g_shader_gl.cpp | 4 +++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/psychlops/extension/standard/shader/psychlops_g_shader_fig.cpp b/psychlops/extension/standard/shader/psychlops_g_shader_fig.cpp index 5e63b4f..760351d 100644 --- a/psychlops/extension/standard/shader/psychlops_g_shader_fig.cpp +++ b/psychlops/extension/standard/shader/psychlops_g_shader_fig.cpp @@ -112,8 +112,12 @@ namespace Figures { setFunction(tmp); } void ShaderImage::setFunction(const std::string &source, ShaderInterface::Version reparse) - { + { + glslversion = reparse; switch(reparse) { + case ShaderInterface::THROUGH: + orig_source = source; + break; case ShaderInterface::AUTO_DETECT: case ShaderInterface::GLSL1_1: ShaderInterface::reparseGLSL1_1(source, orig_source, orig_args); @@ -220,11 +224,15 @@ namespace Figures { void ShaderField::setFunction(const char* source, ShaderInterface::Version reparse) { std::string tmp(source); - setFunction(tmp); + setFunction(tmp, reparse); } void ShaderField::setFunction(const std::string &source, ShaderInterface::Version reparse) - { + { + glslversion = reparse; switch(reparse) { + case ShaderInterface::THROUGH: + orig_source = source; + break; case ShaderInterface::AUTO_DETECT: case ShaderInterface::GLSL1_1: ShaderInterface::reparseGLSL1_1(source, orig_source, orig_args); @@ -248,7 +256,18 @@ namespace Figures { } void ShaderField::cache(DrawableWithCache &target) { - api.cacheField(orig_source, orig_args, target); + switch(glslversion) { + case ShaderInterface::THROUGH: + api.cache(orig_source, orig_args, target); + break; + case ShaderInterface::AUTO_DETECT: + case ShaderInterface::GLSL1_1: + api.cacheField(orig_source, orig_args, target); + break; + default: + api.cacheField(orig_source, orig_args, target); + break; + } } void ShaderField::cache(const char *source, DrawableWithCache &target) { diff --git a/psychlops/extension/standard/shader/psychlops_g_shader_fig.h b/psychlops/extension/standard/shader/psychlops_g_shader_fig.h index fb53ae6..530a061 100644 --- a/psychlops/extension/standard/shader/psychlops_g_shader_fig.h +++ b/psychlops/extension/standard/shader/psychlops_g_shader_fig.h @@ -16,7 +16,7 @@ namespace Psychlops { class ShaderInterface { public: - enum Version { AUTO_DETECT, GLSL1_1 }; + enum Version { THROUGH, AUTO_DETECT, GLSL1_1, GLSL3_3 }; static void reparseGLSL1_1(const std::string &source, std::string &result, std::vector &args); }; @@ -26,7 +26,8 @@ namespace Figures { protected: Shader api; bool initialized; - public: + public: + ShaderInterface::Version glslversion; std::string orig_source; std::vector orig_args; double arg_tmp[16]; @@ -66,7 +67,8 @@ namespace Figures { Shader api; bool initialized; - public: + public: + ShaderInterface::Version glslversion; std::string orig_source; std::vector orig_args; double arg_tmp[16]; diff --git a/psychlops/platform/gl/extension/psychlops_g_shader_gl.cpp b/psychlops/platform/gl/extension/psychlops_g_shader_gl.cpp index dc7f443..a040e1c 100644 --- a/psychlops/platform/gl/extension/psychlops_g_shader_gl.cpp +++ b/psychlops/platform/gl/extension/psychlops_g_shader_gl.cpp @@ -204,7 +204,8 @@ namespace Psychlops { errormsg = logbuf; delete [] logbuf; throw new Exception(typeid(*this), "Shader compile failed", errormsg); - } + } +std::cout << final_source << std::endl; if(gl2Program==0) gl2Program = glCreateProgram(); glAttachShader(gl2Program, fragShader); @@ -215,6 +216,7 @@ namespace Psychlops { } void ShaderAPI::cacheField(const std::string &orig_source, const std::vector &vars, Drawable &target) { + //std::string final_source = "#version 130\r\n#extension GL_EXT_gpu_shader4 : enable\r\n\r\n"; std::string final_source = ""; int mode = 0; -- 2.11.0