diff --git a/apps/app_demo/source/scenes/AppDemoSceneShaderBump.cpp b/apps/app_demo/source/scenes/AppDemoSceneShaderBump.cpp index aaff8d99..21c0fc69 100644 --- a/apps/app_demo/source/scenes/AppDemoSceneShaderBump.cpp +++ b/apps/app_demo/source/scenes/AppDemoSceneShaderBump.cpp @@ -21,7 +21,7 @@ AppDemoSceneShaderBump::AppDemoSceneShaderBump() : SLScene("Normal Map Bump Mapping") { - info("Normal map bump mapping combined with a spot and a directional lighting."); + info("Normal map bump mapping combined with a spot lighting."); } //----------------------------------------------------------------------------- //! All assets the should be loaded in parallel must be registered in here. @@ -29,10 +29,10 @@ void AppDemoSceneShaderBump::registerAssetsToLoad(SLAssetLoader& al) { al.addTextureToLoad(_texC, AppCommon::texturePath + - "brickwall0512_C.jpg"); + "brickwall0512_C.jpg"); al.addTextureToLoad(_texN, AppCommon::texturePath + - "brickwall0512_N.jpg"); + "brickwall0512_N.jpg"); } //----------------------------------------------------------------------------- //! After parallel loading of the assets the scene gets assembled in here. @@ -58,26 +58,17 @@ void AppDemoSceneShaderBump::assemble(SLAssetManager* am, SLSceneView* sv) light1->translation(0, 0, 5); light1->lookAt(0, 0, 0); - SLLightDirect* light2 = new SLLightDirect(am, this); - light2->ambientColor(SLCol4f(0, 0, 0)); - light2->diffuseColor(SLCol4f(1, 1, 0)); - light2->specularColor(SLCol4f(1, 1, 0)); - light2->translation(-5, -5, 5); - light2->lookAt(0, 0, 0); - light2->attenuation(1, 0, 0); - SLAnimation* anim = this->animManager().createNodeAnimation("light1_anim", 2.0f); anim->createNodeAnimTrackForEllipse(light1, 2.0f, A_x, 2.0f, - A_Y); + A_y); SLNode* scene = new SLNode; this->root3D(scene); scene->addChild(light1); - scene->addChild(light2); scene->addChild(new SLNode(new SLRectangle(am, SLVec2f(-5, -5), SLVec2f(5, 5), diff --git a/apps/app_demo/source/scenes/AppDemoSceneShaderEarth.cpp b/apps/app_demo/source/scenes/AppDemoSceneShaderEarth.cpp index 11a0f4d7..0da05858 100644 --- a/apps/app_demo/source/scenes/AppDemoSceneShaderEarth.cpp +++ b/apps/app_demo/source/scenes/AppDemoSceneShaderEarth.cpp @@ -22,8 +22,8 @@ AppDemoSceneShaderEarth::AppDemoSceneShaderEarth() { info("Complex earth shader with 7 textures: day color, night color, " "normal, height & gloss map of earth, color & alpha-map of clouds.\n" - "Use (SHIFT) & key X to change scale of the parallax mapping\n" - "Use (SHIFT) & key O to change offset of the parallax mapping"); + "Use (SHIFT) & key F2 to change scale of the parallax mapping\n" + "Use (SHIFT) & key F3 to change offset of the parallax mapping"); } //----------------------------------------------------------------------------- //! All assets the should be loaded in parallel must be registered in here. @@ -61,14 +61,14 @@ void AppDemoSceneShaderEarth::assemble(SLAssetManager* am, SLSceneView* sv) 0.002f, 0, 1, - (SLKey)'X'); + (SLKey)K_F2); SLGLUniform1f* offset = new SLGLUniform1f(UT_const, "u_offset", -0.02f, 0.002f, -1, 1, - (SLKey)'O'); + (SLKey)K_F3); this->eventHandlers().push_back(scale); this->eventHandlers().push_back(offset); _sp->addUniform1f(scale); diff --git a/apps/app_demo/source/scenes/AppDemoSceneShaderParallax.cpp b/apps/app_demo/source/scenes/AppDemoSceneShaderParallax.cpp index 4b27b868..b4ad7e3c 100644 --- a/apps/app_demo/source/scenes/AppDemoSceneShaderParallax.cpp +++ b/apps/app_demo/source/scenes/AppDemoSceneShaderParallax.cpp @@ -21,9 +21,9 @@ AppDemoSceneShaderParallax::AppDemoSceneShaderParallax() : SLScene("Parallax Bump Mapping Test") { - info("Normal map parallax mapping with a spot and a directional light" - "Use X-Key to increment (decrement w. shift) parallax scale." - "Use O-Key to increment (decrement w. shift) parallax offset.\n"); + info("Parallax mapping with a spot. " + "Use F2-Key to increment (decrement w. shift) parallax scale." + "Use F3-Key to increment (decrement w. shift) parallax offset.\n"); } //----------------------------------------------------------------------------- //! All assets the should be loaded in parallel must be registered in here. @@ -49,14 +49,14 @@ void AppDemoSceneShaderParallax::assemble(SLAssetManager* am, SLSceneView* sv) 0.002f, 0, 1, - (SLKey)'X'); + (SLKey)K_F2); SLGLUniform1f* offset = new SLGLUniform1f(UT_const, "u_offset", -0.03f, 0.002f, -1, 1, - (SLKey)'O'); + (SLKey)K_F3); this->eventHandlers().push_back(scale); this->eventHandlers().push_back(offset); _sp->addUniform1f(scale); @@ -88,25 +88,16 @@ void AppDemoSceneShaderParallax::assemble(SLAssetManager* am, SLSceneView* sv) light1->translation(0, 0, 5); light1->lookAt(0, 0, 0); - SLLightDirect* light2 = new SLLightDirect(am, this); - light2->ambientColor(SLCol4f(0, 0, 0)); - light2->diffuseColor(SLCol4f(1, 1, 0)); - light2->specularColor(SLCol4f(1, 1, 0)); - light2->translation(-5, -5, 5); - light2->lookAt(0, 0, 0); - light2->attenuation(1, 0, 0); - SLAnimation* anim = this->animManager().createNodeAnimation("light1_anim", 2.0f); anim->createNodeAnimTrackForEllipse(light1, 2.0f, A_x, 2.0f, - A_Y); + A_y); SLNode* scene = new SLNode; this->root3D(scene); scene->addChild(light1); - scene->addChild(light2); scene->addChild(new SLNode(new SLRectangle(am, SLVec2f(-5, -5), SLVec2f(5, 5), diff --git a/apps/app_demo/source/scenes/AppDemoSceneShaderWave.cpp b/apps/app_demo/source/scenes/AppDemoSceneShaderWave.cpp index 3fdf773d..f39752a7 100644 --- a/apps/app_demo/source/scenes/AppDemoSceneShaderWave.cpp +++ b/apps/app_demo/source/scenes/AppDemoSceneShaderWave.cpp @@ -23,7 +23,7 @@ AppDemoSceneShaderWave::AppDemoSceneShaderWave() { info("Vertex Shader with wave displacement. " - "Use H-Key to increment (decrement w. shift) the wave height."); + "Use F2-Key to increment (decrement w. shift) the wave height."); } //----------------------------------------------------------------------------- //! All assets the should be loaded in parallel must be registered in here. @@ -52,7 +52,7 @@ void AppDemoSceneShaderWave::assemble(SLAssetManager* am, SLSceneView* sv) 0.05f, 0.0f, 0.5f, - (SLKey)'H'); + (SLKey)K_F2); this->eventHandlers().push_back(u_h); _sp->addUniform1f(u_h); _sp->addUniform1f(new SLGLUniform1f(UT_inc, "u_t", 0.0f, 0.06f)); diff --git a/apps/app_demo/source/scenes/AppDemoSceneTextureFilter.cpp b/apps/app_demo/source/scenes/AppDemoSceneTextureFilter.cpp index 170c3949..1d0ad62f 100644 --- a/apps/app_demo/source/scenes/AppDemoSceneTextureFilter.cpp +++ b/apps/app_demo/source/scenes/AppDemoSceneTextureFilter.cpp @@ -31,13 +31,13 @@ void AppDemoSceneTextureFilter::registerAssetsToLoad(SLAssetLoader& al) al.addTextureToLoad(_texB, AppCommon::texturePath + "brick0512_C.png", - GL_LINEAR, - GL_LINEAR); + GL_NEAREST, + GL_NEAREST); al.addTextureToLoad(_texL, AppCommon::texturePath + "brick0512_C.png", - GL_NEAREST, - GL_NEAREST); + GL_LINEAR, + GL_LINEAR); al.addTextureToLoad(_texT, AppCommon::texturePath + "brick0512_C.png", diff --git a/apps/exercises/glUtils.cpp b/apps/exercises/glUtils.cpp index 4a9fea13..a7390a8d 100644 --- a/apps/exercises/glUtils.cpp +++ b/apps/exercises/glUtils.cpp @@ -412,6 +412,7 @@ GLuint glUtils::buildTexture(string textureFile, // check max. size GLint maxSize = 0; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize); + std::cout << "SLGLTexture::build: Max. texture size: " << maxSize << std::endl; if (img.width() > (GLuint)maxSize || img.height() > (GLuint)maxSize) { std::cout << "SLGLTexture::build: Texture height is too big." << std::endl; @@ -435,13 +436,13 @@ GLuint glUtils::buildTexture(string textureFile, // Copy image data to the GPU. The image can be delete afterwards glTexImage2D(GL_TEXTURE_2D, // target texture type 1D, 2D or 3D - 0, // Base level for mipmapped textures - img.format(), // internal format: e.g. GL_RGBA, see spec. - (GLsizei)img.width(), // image width + 0, // Base level for mipmapped textures + img.format(), // internal format: e.g. GL_RGBA, see spec. + (GLsizei)img.width(), // image width (GLsizei)img.height(), // image height 0, // border pixels: must be 0 img.format(), // data format: e.g. GL_RGBA, see spec. - GL_UNSIGNED_BYTE, // data type + GL_UNSIGNED_BYTE, // data type (GLvoid*)img.data()); // image data pointer // generate the mipmap levels diff --git a/modules/sl/source/SLEnums.h b/modules/sl/source/SLEnums.h index 9266bf16..35997672 100644 --- a/modules/sl/source/SLEnums.h +++ b/modules/sl/source/SLEnums.h @@ -78,7 +78,7 @@ enum SLRenderType enum SLAxis { A_x = 0, - A_Y = 1, + A_y = 1, A_z = 2 }; //----------------------------------------------------------------------------- diff --git a/modules/sl/source/gl/SLGLUniform.h b/modules/sl/source/gl/SLGLUniform.h index e2ed47ba..1f56224c 100644 --- a/modules/sl/source/gl/SLGLUniform.h +++ b/modules/sl/source/gl/SLGLUniform.h @@ -23,6 +23,16 @@ template class SLGLUniform : public SLEventHandler { public: + /** + * @brief Constructs a custom uniform variable + * @param type Type of uniform variable + * @param name Name of uniform variable + * @param value Current value + * @param inc Increment value + * @param min Minimal value + * @param max Maximal value + * @param keyInc Key F1-F10 to increment the value decrement with SHIFT key + */ SLGLUniform(SLUniformType type, const SLchar* name, T value, @@ -38,6 +48,9 @@ class SLGLUniform : public SLEventHandler _inc = inc; _type = type; _keyInc = keyInc; + + if (_keyInc != K_none && !(_keyInc >= K_F1 && _keyInc <= K_F10)) + SL_EXIT_MSG("Please use keys F1-F10 for uniform variables."); } SLGLUniform(const SLchar* name, @@ -111,13 +124,13 @@ class SLGLUniform : public SLEventHandler if (_value < _max) { _value += _inc; - // std::cout << "Uniform: " << _name.c_str() << " = " << _value << std::endl; + SL_LOG("Uniform: %s = %5.4f", _name.c_str(),(float)_value); return true; } else if (_inc == _max) // Toggle between min & max { _value = _min; - // std::cout << "Uniform: " << _name.c_str() << " = " << _value << std::endl; + SL_LOG("Uniform: %s = %5.4f", _name.c_str(),(float)_value); return true; } } @@ -126,7 +139,7 @@ class SLGLUniform : public SLEventHandler if (_value > _min) { _value -= _inc; - // std::cout << "Uniform: " << _name.c_str() << " = " << _value << std::endl; + SL_LOG("Uniform: %s = %5.4f", _name.c_str(),(float)_value); return true; } }