OverlayEffect::OverlayEffect(ProgramFactory& factory, int windowWidth, int windowHeight, int textureWidth, int textureHeight, SamplerState::Filter filter, SamplerState::Mode mode0, SamplerState::Mode mode1, bool useColorPShader) : mWindowWidth(static_cast<float>(windowWidth)), mWindowHeight(static_cast<float>(windowHeight)) { Initialize(windowWidth, windowHeight, textureWidth, textureHeight); int i = factory.GetAPI(); std::string psSource = (useColorPShader ? *msPSColorSource[i] : *msPSGraySource[i]); mProgram = factory.CreateFromSources(*msVSSource[i], psSource, ""); if (mProgram) { std::shared_ptr<SamplerState> sampler = std::make_shared<SamplerState>(); sampler->filter = filter; sampler->mode[0] = mode0; sampler->mode[1] = mode1; mProgram->GetPShader()->Set("imageSampler", sampler); mEffect = std::make_shared<VisualEffect>(mProgram); } }
VertexColorEffect::VertexColorEffect(ProgramFactory& factory) : mPVWMatrix(nullptr) { int i = factory.GetAPI(); mProgram = factory.CreateFromSources(*msVSSource[i], *msPSSource[i], ""); if (mProgram) { mPVWMatrixConstant = std::make_shared<ConstantBuffer>( sizeof(Matrix4x4<float>), true); mPVWMatrix = mPVWMatrixConstant->Get<Matrix4x4<float>>(); *mPVWMatrix = Matrix4x4<float>::Identity(); mProgram->GetVShader()->Set("PVWMatrix", mPVWMatrixConstant); } }
OverlayEffect::OverlayEffect(ProgramFactory& factory, int windowWidth, int windowHeight, int textureWidth, int textureHeight, std::string const& psSource) : mWindowWidth(static_cast<float>(windowWidth)), mWindowHeight(static_cast<float>(windowHeight)) { int i = factory.GetAPI(); Initialize(windowWidth, windowHeight, textureWidth, textureHeight); mProgram = factory.CreateFromSources(*msVSSource[i], psSource, ""); if (mProgram) { mEffect = std::make_shared<VisualEffect>(mProgram); } }