From f18f1c19f709f0f57bad81b87c16a4f574efc9f5 Mon Sep 17 00:00:00 2001 From: psperl Date: Sun, 20 Jul 2008 03:17:11 +0000 Subject: [PATCH] some regressions. but clamp + wrap are being set now git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1112 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/ShaderEngine.cpp | 70 ++++++++++++++-------------- src/projectM-engine/ShaderEngine.hpp | 2 +- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/projectM-engine/ShaderEngine.cpp b/src/projectM-engine/ShaderEngine.cpp index 7bd23495a..59ef1851b 100644 --- a/src/projectM-engine/ShaderEngine.cpp +++ b/src/projectM-engine/ShaderEngine.cpp @@ -392,18 +392,10 @@ void ShaderEngine::SetupCg() void ShaderEngine::SetupCgVariables(CGprogram program, const Pipeline &pipeline, const PipelineContext &context) { - float slow_roam_cos[4] = - { 0.5 + 0.5 * cos(context.time * 0.005), 0.5 + 0.5 * cos(context.time * 0.008), 0.5 + 0.5 * cos(context.time - * 0.013), 0.5 + 0.5 * cos(context.time * 0.022) }; - float roam_cos[4] = - { 0.5 + 0.5 * cos(context.time * 0.3), 0.5 + 0.5 * cos(context.time * 1.3), 0.5 + 0.5 * cos(context.time * 5), 0.5 - + 0.5 * cos(context.time * 20) }; - float slow_roam_sin[4] = - { 0.5 + 0.5 * sin(context.time * 0.005), 0.5 + 0.5 * sin(context.time * 0.008), 0.5 + 0.5 * sin(context.time - * 0.013), 0.5 + 0.5 * sin(context.time * 0.022) }; - float roam_sin[4] = - { 0.5 + 0.5 * sin(context.time * 0.3), 0.5 + 0.5 * sin(context.time * 1.3), 0.5 + 0.5 * sin(context.time * 5), 0.5 - + 0.5 * sin(context.time * 20) }; + float slow_roam_cos[4] = { 0.5 + 0.5 * cos(context.time * 0.005), 0.5 + 0.5 * cos(context.time * 0.008), 0.5 + 0.5 * cos(context.time * 0.013), 0.5 + 0.5 * cos(context.time * 0.022) }; + float roam_cos[4] = { 0.5 + 0.5 * cos(context.time * 0.3), 0.5 + 0.5 * cos(context.time * 1.3), 0.5 + 0.5 * cos(context.time * 5), 0.5 + 0.5 * cos(context.time * 20) }; + float slow_roam_sin[4] = { 0.5 + 0.5 * sin(context.time * 0.005), 0.5 + 0.5 * sin(context.time * 0.008), 0.5 + 0.5 * sin(context.time * 0.013), 0.5 + 0.5 * sin(context.time * 0.022) }; + float roam_sin[4] = { 0.5 + 0.5 * sin(context.time * 0.3), 0.5 + 0.5 * sin(context.time * 1.3), 0.5 + 0.5 * sin(context.time * 5), 0.5 + 0.5 * sin(context.time * 20) }; cgGLSetParameter4fv(cgGetNamedParameter(program, "slow_roam_cos"), slow_roam_cos); cgGLSetParameter4fv(cgGetNamedParameter(program, "roam_cos"), roam_cos); @@ -411,10 +403,8 @@ void ShaderEngine::SetupCgVariables(CGprogram program, const Pipeline &pipeline, cgGLSetParameter4fv(cgGetNamedParameter(program, "roam_sin"), roam_sin); cgGLSetParameter1f(cgGetNamedParameter(program, "time"), context.time); - cgGLSetParameter4f(cgGetNamedParameter(program, "rand_preset"), rand_preset[0], rand_preset[1], rand_preset[2], - rand_preset[3]); - cgGLSetParameter4f(cgGetNamedParameter(program, "rand_frame"), (rand() % 100) * .01, (rand() % 100) * .01, (rand() - % 100) * .01, (rand() % 100) * .01); + cgGLSetParameter4f(cgGetNamedParameter(program, "rand_preset"), rand_preset[0], rand_preset[1], rand_preset[2], rand_preset[3]); + cgGLSetParameter4f(cgGetNamedParameter(program, "rand_frame"), (rand() % 100) * .01, (rand() % 100) * .01, (rand()% 100) * .01, (rand() % 100) * .01); cgGLSetParameter1f(cgGetNamedParameter(program, "fps"), context.fps); cgGLSetParameter1f(cgGetNamedParameter(program, "frame"), context.frame); cgGLSetParameter1f(cgGetNamedParameter(program, "progress"), context.progress); @@ -483,25 +473,18 @@ void ShaderEngine::SetupCgVariables(CGprogram program, const Pipeline &pipeline, cgGLEnableTextureParameter(cgGetNamedParameter(program, "sampler_blur3")); } - cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_lq"), 256, 256, 1.0 / (float) 256, 1.0 / (float) 256); - cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_mq"), 64, 64, 1.0 / (float) 64, 1.0 / (float) 64); - cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_hq"), 32, 32, 1.0 / (float) 32, 1.0 / (float) 32); - cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_perlin"), 512, 512, 1.0 / (float) 512, 1.0 - / (float) 512); - cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_lq_lite"), 32, 32, 1.0 / (float) 32, 1.0 - / (float) 32); + //cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_lq"), 256, 256, 1.0 / (float) 256, 1.0 / (float) 256); + //cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_mq"), 64, 64, 1.0 / (float) 64, 1.0 / (float) 64); + //cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_hq"), 32, 32, 1.0 / (float) 32, 1.0 / (float) 32); + //cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_perlin"), 512, 512, 1.0 / (float) 512, 1.0 +// / (float) 512); + //cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_lq_lite"), 32, 32, 1.0 / (float) 32, 1.0 + // / (float) 32); } void ShaderEngine::SetupUserTexture(CGprogram program, const UserTexture* texture) { - //glBindTexture(GL_TEXTURE_2D, texture->texID); - //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texture->bilinear ? GL_LINEAR : GL_NEAREST); - //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->bilinear ? GL_LINEAR : GL_NEAREST); - //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->wrap ? GL_REPEAT : GL_CLAMP); - //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture->wrap ? GL_REPEAT : GL_CLAMP); - std::string samplerName = "sampler_" + texture->qname; - //std::cout<<"Setting up "<texID<<" "<qname<texID<<" "<texsizeDefined) { std::string texsizeName = "texsize_" + texture->name; cgGLSetParameter4f(cgGetNamedParameter(program, texsizeName.c_str()), texture->width, texture->height, 1 / (float) texture->width, 1 / (float) texture->height); + checkForCgError("setting parameter texsize"); } + + +} + +void ShaderEngine::SetupUserTextureState( const UserTexture* texture) +{ + glBindTexture(GL_TEXTURE_2D, texture->texID); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texture->bilinear ? GL_LINEAR : GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->bilinear ? GL_LINEAR : GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->wrap ? GL_REPEAT : GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture->wrap ? GL_REPEAT : GL_CLAMP); } void ShaderEngine::SetupCgQVariables(Shader &shader, const PresetOutputs &q) @@ -673,7 +668,16 @@ void ShaderEngine::enableShader(Shader &shader, const Pipeline *pipeline, const if (shader.enabled) { + + + for (std::map::const_iterator pos = shader.textures.begin(); pos != shader.textures.end(); ++pos) + SetupUserTextureState( pos->second); + + CGprogram program = programs[&shader]; + for (std::map::const_iterator pos = shader.textures.begin(); pos + != shader.textures.end(); ++pos) + SetupUserTexture(program, pos->second); cgGLEnableProfile(myCgProfile); checkForCgError("enabling warp profile"); @@ -683,10 +687,6 @@ void ShaderEngine::enableShader(Shader &shader, const Pipeline *pipeline, const SetupCgVariables(program, *pipeline, *pipelineContext); - for (std::map::const_iterator pos = shader.textures.begin(); pos - != shader.textures.end(); ++pos) - SetupUserTexture(program, pos->second); - enabled = true; } } diff --git a/src/projectM-engine/ShaderEngine.hpp b/src/projectM-engine/ShaderEngine.hpp index 3b61592f6..5b09ce1cd 100644 --- a/src/projectM-engine/ShaderEngine.hpp +++ b/src/projectM-engine/ShaderEngine.hpp @@ -87,7 +87,7 @@ class ShaderEngine void SetupCgVariables(CGprogram program, const Pipeline &pipeline, const PipelineContext &pipelineContext); void SetupUserTexture(CGprogram program, const UserTexture* texture); - + void SetupUserTextureState(const UserTexture* texture); #endif