////////////////////////////////////////////////////////////////////////////////
// Filename: d3dclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _D3DCLASS_H_
#define _D3DCLASS_H_


/////////////
// LINKING //
/////////////
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3dcompiler.lib")


//////////////
// INCLUDES //
//////////////
#include "imguiManager.h"
#include "d3d11.h"
#include "font_shader_class.h"
#include "font_class.h"
#include "text_class.h"

using namespace DirectX;

////////////////////////////////////////////////////////////////////////////////
// Class name: d_3d_class
////////////////////////////////////////////////////////////////////////////////
class d_3d_class
{
public:
	d_3d_class();
	d_3d_class(const d_3d_class&);
	~d_3d_class();

	virtual bool initialize(int, int, bool, HWND, bool, float, float);
	void shutdown();

	virtual void begin_scene(float, float, float, float);
	virtual void end_scene();

	ID3D11Device* get_device();
	ID3D11DeviceContext* get_device_context();
	//XMMATRIX get_projection_matrix(XMMATRIX& projectionMatrix);
	IDXGISwapChain* swap_chain;
	IDXGISwapChain* get_swap_chain();
	void resize_swap_chain(int, int);
	void set_vsync(bool vsync);


	XMMATRIX get_projection_matrix() const { return projection_matrix_; };
	XMMATRIX get_world_matrix() const { return world_matrix_;};
	XMMATRIX get_ortho_matrix() const { return ortho_matrix_; };

	void get_video_card_info(char*, int&);

	void set_back_buffer_render_target();
	void reset_viewport();

	void release_resources();
	void reset_resources(int newWidth, int newHeight);
	
	void turn_z_buffer_on();
	void turn_z_buffer_off();

	void enable_alpha_blending();
	void disable_alpha_blending();

private:
	bool vsync_enabled_;
	int video_card_memory_;
	char video_card_description_[128];
	ID3D11Device* device_;
	ID3D11DeviceContext* device_context_;
	ID3D11RenderTargetView* render_target_view_;
	ID3D11Texture2D* depth_stencil_buffer_;
	ID3D11DepthStencilState* depth_stencil_state_;
	ID3D11DepthStencilView* depth_stencil_view_;
	ID3D11RasterizerState* raster_state_;
	XMMATRIX projection_matrix_;
	XMMATRIX world_matrix_;
	XMMATRIX ortho_matrix_;
	D3D11_VIEWPORT viewport_;
	ID3D11DepthStencilState* depth_disabled_stencil_state_;
	ID3D11BlendState* alpha_enable_blending_state_;
	ID3D11BlendState* alpha_disable_blending_state_;
};

#endif