OSDN Git Service

321
authorhskwk <hosokawa.kenchi@gmail.com>
Sat, 21 Feb 2015 13:27:43 +0000 (22:27 +0900)
committerhskwk <hosokawa.kenchi@gmail.com>
Sat, 21 Feb 2015 13:27:43 +0000 (22:27 +0900)
psychlops/extension/standard/shader/psychlops_g_shader_fig.cpp
psychlops/extension/standard/shader/psychlops_g_shader_fig.h
psychlops/platform/gl/extension/psychlops_g_shader_gl.cpp

index 5e63b4f..760351d 100644 (file)
@@ -112,8 +112,12 @@ namespace Figures {
                setFunction(tmp);
        }
        void ShaderImage::setFunction(const std::string &source, ShaderInterface::Version reparse)
                setFunction(tmp);
        }
        void ShaderImage::setFunction(const std::string &source, ShaderInterface::Version reparse)
-       {
+       {\r
+               glslversion = reparse;
                switch(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);
                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);
        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)
        }
        void ShaderField::setFunction(const std::string &source, ShaderInterface::Version reparse)
-       {
+       {\r
+               glslversion = reparse;
                switch(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);
                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)
        {
        }
        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)
        {
        }
        void ShaderField::cache(const char *source, DrawableWithCache &target)
        {
index fb53ae6..530a061 100644 (file)
@@ -16,7 +16,7 @@ namespace Psychlops {
 
        class ShaderInterface {
                public:
 
        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<std::string> &args);
        };
 
                static void reparseGLSL1_1(const std::string &source, std::string &result, std::vector<std::string> &args);
        };
 
@@ -26,7 +26,8 @@ namespace Figures {
        protected:
                Shader api;
                bool initialized;
        protected:
                Shader api;
                bool initialized;
-       public:
+       public:\r
+               ShaderInterface::Version glslversion;
                std::string orig_source;
                std::vector<std::string> orig_args;
                double arg_tmp[16];
                std::string orig_source;
                std::vector<std::string> orig_args;
                double arg_tmp[16];
@@ -66,7 +67,8 @@ namespace Figures {
 
                Shader api;
                bool initialized;
 
                Shader api;
                bool initialized;
-       public:
+       public:\r
+               ShaderInterface::Version glslversion;
                std::string orig_source;
                std::vector<std::string> orig_args;
                double arg_tmp[16];
                std::string orig_source;
                std::vector<std::string> orig_args;
                double arg_tmp[16];
index dc7f443..a040e1c 100644 (file)
@@ -204,7 +204,8 @@ namespace Psychlops {
                        errormsg = logbuf;
                        delete [] logbuf;
                        throw new Exception(typeid(*this), "Shader compile failed", errormsg);
                        errormsg = logbuf;
                        delete [] logbuf;
                        throw new Exception(typeid(*this), "Shader compile failed", errormsg);
-               }
+               }\r
+std::cout << final_source << std::endl;
 \r
                if(gl2Program==0) gl2Program = glCreateProgram();
                glAttachShader(gl2Program, fragShader);
 \r
                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<std::string> &vars, Drawable &target)
        {
        }
        void ShaderAPI::cacheField(const std::string &orig_source, const std::vector<std::string> &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;
                std::string final_source = "";
 
                int mode = 0;