From: Peter Schaefer Date: Tue, 26 Apr 2016 11:14:56 +0000 (+0200) Subject: useTexture ENUM X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=b8c6a8ab8aa1572dc932b014352f19a638dee82d;p=cgue_weave.git useTexture ENUM empty ShadowFS Shader correct Scene is drawn --- diff --git a/Weave/Graphix/Textures/Texture.cpp b/Weave/Graphix/Textures/Texture.cpp index 6c6b6b6..fd3edd4 100644 --- a/Weave/Graphix/Textures/Texture.cpp +++ b/Weave/Graphix/Textures/Texture.cpp @@ -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) diff --git a/Weave/Graphix/Textures/Texture.h b/Weave/Graphix/Textures/Texture.h index 997e6bb..14c76f0 100644 --- a/Weave/Graphix/Textures/Texture.h +++ b/Weave/Graphix/Textures/Texture.h @@ -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); diff --git a/Weave/Graphix/Textures/tImage.cpp b/Weave/Graphix/Textures/tImage.cpp index 6f4614b..01b5322 100644 --- a/Weave/Graphix/Textures/tImage.cpp +++ b/Weave/Graphix/Textures/tImage.cpp @@ -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*/ diff --git a/Weave/Graphix/Textures/tImage.h b/Weave/Graphix/Textures/tImage.h index de5ab57..18f262e 100644 --- a/Weave/Graphix/Textures/tImage.h +++ b/Weave/Graphix/Textures/tImage.h @@ -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; diff --git a/Weave/Scene/Scene.cpp b/Weave/Scene/Scene.cpp index 0ecfe89..8951e76 100644 --- a/Weave/Scene/Scene.cpp +++ b/Weave/Scene/Scene.cpp @@ -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)); } diff --git a/shader/shadowmapDir_FS.hlsl b/shader/shadowmapDir_FS.hlsl index 28d5b58..728168f 100644 --- a/shader/shadowmapDir_FS.hlsl +++ b/shader/shadowmapDir_FS.hlsl @@ -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); }