| 11 | using namespace gte; |
| 12 | |
| 13 | CubeMapEffect::CubeMapEffect(std::shared_ptr<ProgramFactory> const& factory, |
| 14 | std::shared_ptr<TextureCube> const& texture, SamplerState::Filter filter, |
| 15 | SamplerState::Mode mode0, SamplerState::Mode mode1, float reflectivity) |
| 16 | : |
| 17 | mCubeTexture(texture), |
| 18 | mDepthRangeIs01(factory->GetAPI() == ProgramFactory::PF_HLSL), |
| 19 | mDynamicUpdates(false) |
| 20 | { |
| 21 | int32_t api = factory->GetAPI(); |
| 22 | mProgram = factory->CreateFromSources(*msVSSource[api], *msPSSource[api], ""); |
| 23 | if (mProgram) |
| 24 | { |
| 25 | |
| 26 | mWMatrixConstant = std::make_shared<ConstantBuffer>(sizeof(Matrix4x4<float>), true); |
| 27 | SetWMatrix(Matrix4x4<float>::Identity()); |
| 28 | |
| 29 | mCameraWorldPositionConstant = std::make_shared<ConstantBuffer>(sizeof(Vector4<float>), true); |
| 30 | SetCameraWorldPosition(Vector4<float>::Unit(3)); |
| 31 | |
| 32 | mReflectivityConstant = std::make_shared<ConstantBuffer>(sizeof(float), true); |
| 33 | SetReflectivity(reflectivity); |
| 34 | |
| 35 | mCubeSampler = std::make_shared<SamplerState>(); |
| 36 | mCubeSampler->filter = filter; |
| 37 | mCubeSampler->mode[0] = mode0; |
| 38 | mCubeSampler->mode[1] = mode1; |
| 39 | |
| 40 | auto const& vshader = mProgram->GetVertexShader(); |
| 41 | auto const& pshader = mProgram->GetPixelShader(); |
| 42 | vshader->Set("PVWMatrix", mPVWMatrixConstant); |
| 43 | vshader->Set("WMatrix", mWMatrixConstant); |
| 44 | vshader->Set("CameraWorldPosition", mCameraWorldPositionConstant); |
| 45 | pshader->Set("Reflectivity", mReflectivityConstant); |
| 46 | pshader->Set("cubeTexture", mCubeTexture, "cubeSampler", mCubeSampler); |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | LogError("Failed to compile shader programs."); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | void CubeMapEffect::UseDynamicUpdates(float dmin, float dmax) |
| 55 | { |
nothing calls this directly
no test coverage detected