#ifndef _WATERSHADERCLASS_H_
#define _WATERSHADERCLASS_H_


//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
#include "macro.h"
using namespace DirectX;
using namespace std;


////////////////////////////////////////////////////////////////////////////////
// Class name: water_shader_class
////////////////////////////////////////////////////////////////////////////////
class water_shader_class
{
private:
    struct matrix_buffer_type
    {
        XMMATRIX world;
        XMMATRIX view;
        XMMATRIX projection;
    };

    struct reflection_buffer_type
    {
        XMMATRIX reflection;
    };

    struct water_buffer_type
    {
        float water_translation;
        float reflect_refract_scale;
        XMFLOAT2 padding;
    };

public:
    water_shader_class();
    water_shader_class(const water_shader_class&);
    ~water_shader_class();

    bool initialize(ID3D11Device*, HWND);
    void shutdown();
    bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
        ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);

private:
    bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
    void shutdown_shader();
    void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);

    bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
        ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
    void render_shader(ID3D11DeviceContext*, int);

private:
    ID3D11VertexShader* vertex_shader_;
    ID3D11PixelShader* pixel_shader_;
    ID3D11InputLayout* layout_;
    ID3D11Buffer* matrix_buffer_;
    ID3D11SamplerState* sample_state_;
    ID3D11Buffer* reflection_buffer_;
    ID3D11Buffer* water_buffer_;
};

#endif