]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
useTexture ENUM
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 26 Apr 2016 11:14:56 +0000 (13:14 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 26 Apr 2016 11:14:56 +0000 (13:14 +0200)
empty ShadowFS Shader
correct Scene is drawn

Weave/Graphix/Textures/Texture.cpp
Weave/Graphix/Textures/Texture.h
Weave/Graphix/Textures/tImage.cpp
Weave/Graphix/Textures/tImage.h
Weave/Scene/Scene.cpp
shader/shadowmapDir_FS.hlsl

index 6c6b6b677769abcc746e28b470843890c9a8f1b8..fd3edd4da1f88f6dd5cf908febe3933fddb03348 100644 (file)
@@ -9,6 +9,8 @@
 using std::string;
 using std::unordered_map;
 
+string bindTargets[] = {"uColorTexture", "uBlendTexture", "uPointLightXP", "uPointLightXM", "uPointLightYP", "uPointLightYM", "uPointLightZP", "uPointLightZM" };
+
 
 Texture::Texture(texTarget _target)
        : texture_target(GL_TEXTURE_2D)
@@ -117,40 +119,14 @@ void Texture::unbindTexture()
        glGenTextures(1, &handle);
 }
 
-void Texture::useTexture(unsigned int _unit) const
+void Texture::useTexture(bindTarget _unit) const
 {
 
        /* bind Texture*/
        glActiveTexture(GL_TEXTURE0 + _unit);
        glBindTexture(texture_target, handle);
-       
-       switch (_unit)
-       {
-       case 1:
-               Shader::getShader()->setUniformLocation("uBlendTexture", _unit);
-               break;
-       case 2:
-               Shader::getShader()->setUniformLocation("upointLightxp", _unit);
-               break;
-       case 3:
-               Shader::getShader()->setUniformLocation("upointLightxm", _unit);
-               break;
-       case 4:
-               Shader::getShader()->setUniformLocation("upointLightyp", _unit);
-               break;
-       case 5:
-               Shader::getShader()->setUniformLocation("upointLightym", _unit);
-               break;
-       case 6:
-               Shader::getShader()->setUniformLocation("upointLightzp", _unit);
-               break;
-       case 7:
-               Shader::getShader()->setUniformLocation("upointLightzm", _unit);
-               break;
-       default:
-               Shader::getShader()->setUniformLocation("uColorTexture", _unit);
-               break;
-       }
+
+       Shader::getShader()->setUniformLocation(bindTargets[_unit], _unit);
 }
 
 void Texture::updateSize(unsigned int _width, unsigned int _height)
index 997e6bbf78441e9c3ae9bc35626e8b2f62edd7dd..14c76f0cb135ba8042f8ecaec6c0ced6e68154ac 100644 (file)
@@ -13,18 +13,29 @@ enum texTarget {
        texT_IMAGE
 };
 
+enum bindTarget {
+       uCOLOR = 0,
+       uBLEND = 1,
+       uPLightXP = 2,
+       uPLightXM = 3,
+       uPLightYP = 4,
+       uPLightYM = 5,
+       uPLightZP = 6,
+       uPLightZM = 7,
+}; //Don't forget to assign the correct name in bindTargets at the beginning of Texture.cpp!
+
 class Texture
 {
 public:
        static Texture* newTImage(const std::string& path, const vec4& material);
        static void deleteTImage(const unsigned int handle);
 
-       Texture(texTarget target = texT_COLORBUFFER);
+       Texture(texTarget = texT_COLORBUFFER);
        ~Texture();
 
        virtual void bindTexture(unsigned int width = 0, unsigned int height = 0);
        virtual void unbindTexture();
-       virtual void useTexture(unsigned int i=0) const;
+       virtual void useTexture(bindTarget = uCOLOR) const;
 
        virtual void updateSize(unsigned int width = 0, unsigned int height = 0);
 
index 6f4614bc4b5b32139a9380008f5120863cab92f7..01b5322b3e2ee0c641a09ea2f25693401e41abc4 100644 (file)
@@ -46,7 +46,7 @@ void tImage::bindTexture(unsigned int _width, unsigned int _height)
        
 }
 
-void tImage::useTexture(unsigned int _unit) const
+void tImage::useTexture(bindTarget _unit) const
 {
 
        /* bind Texture*/
index de5ab5734f564e8a107fb3fe53d91da363a75bcd..18f262ec83abfc29d2beb832ba47d2b6e46ebdce 100644 (file)
@@ -14,7 +14,7 @@ public:
        virtual ~tImage();
 
        virtual void bindTexture(unsigned int width = 0, unsigned int height = 0) override;
-       virtual void useTexture(unsigned int i=0) const override;
+       virtual void useTexture(bindTarget = uCOLOR) const override;
 
        operator std::string() const;
 
index 0ecfe891721072fd4f80def668b325bc99012e16..8951e769eb8be322f4815115b0e943cf26aabcfa 100644 (file)
@@ -290,11 +290,11 @@ void Scene::draw() const
                /* BLEND BRIGHTNESS TO ORIGINAL*/
                Shader::getShader(SH_BLEND)->useShader();
                render->clearBuffer();
-               //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+               glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                //SceneObjects.front()->gTexture()->useTexture();
-               shadowdir->getTexture()->useTexture();
-               //render->getTexture(0)->useTexture();
-               blurPingPong[!horizontal]->getTexture()->useTexture(1);
+               //shadowdir->getTexture()->useTexture();
+               render->getTexture(0)->useTexture(uCOLOR);
+               blurPingPong[!horizontal]->getTexture()->useTexture(uBLEND);
                Model::getPlaneModel()->drawModel(mat4(1.f));
        }
 
index 28d5b58cfafd4403f4ba85f64ac0f03f8e95b83c..728168f4e8cfe02034a7e2ac696230427067d89e 100644 (file)
@@ -3,6 +3,6 @@
 
 void main()
 {
-       gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
+       //gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
 }