Minor - Refactor name - V10.5.0

This commit is contained in:
2025-05-21 16:40:27 +02:00
parent 24203060be
commit f9d4523f09
113 changed files with 5200 additions and 5017 deletions

View File

@@ -1,64 +0,0 @@
#pragma once
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
class CelshadeClass
{
private :
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct CameraBufferType
{
XMFLOAT3 cameraPosition;
float padding;
};
struct SunLightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT4 ambientColor;
XMFLOAT3 sunDirection;
float intensity;
};
public :
CelshadeClass();
CelshadeClass(const CelshadeClass&);
~CelshadeClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext* deviceContex, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection,float intensity);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_matrixBuffer;
ID3D11Buffer* m_cameraBuffer;
ID3D11Buffer* m_sunlightBuffer;
ID3D11Buffer* m_sunlightColorBuffer;
ID3D11Buffer* m_sunlightPositionBuffer;
};

View File

@@ -1,59 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: multitextureshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _MULTITEXTURESHADERCLASS_H_
#define _MULTITEXTURESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: MultiTextureShaderClass
////////////////////////////////////////////////////////////////////////////////
class MultiTextureShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
MultiTextureShaderClass();
MultiTextureShaderClass(const MultiTextureShaderClass&);
~MultiTextureShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
};
#endif

View File

@@ -0,0 +1,55 @@
#ifndef _ALPHAMAPSHADERCLASS_H_
#define _ALPHAMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: alpha_map_shader_class
////////////////////////////////////////////////////////////////////////////////
class alpha_map_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
alpha_map_shader_class();
alpha_map_shader_class(const alpha_map_shader_class&);
~alpha_map_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
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, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@@ -1,55 +0,0 @@
#ifndef _ALPHAMAPSHADERCLASS_H_
#define _ALPHAMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: AlphaMapShaderClass
////////////////////////////////////////////////////////////////////////////////
class AlphaMapShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
AlphaMapShaderClass();
AlphaMapShaderClass(const AlphaMapShaderClass&);
~AlphaMapShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
};
#endif

View File

@@ -0,0 +1,85 @@
#pragma once
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
class celshade_class
{
private :
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct camera_buffer_type
{
XMFLOAT3 cameraPosition;
float padding;
};
struct sun_light_buffer_type
{
XMFLOAT4 diffuse_color;
XMFLOAT4 ambient_color;
XMFLOAT3 sun_direction;
float intensity;
};
public :
celshade_class();
celshade_class(const celshade_class&);
~celshade_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(
ID3D11DeviceContext* device_context,
int index_count,
XMMATRIX world_matrix,
XMMATRIX view_matrix, XMMATRIX
projection_matrix,
ID3D11ShaderResourceView* texture,
XMFLOAT4 diffuse_color,
XMFLOAT4 ambient_color,
XMFLOAT3 sun_direction,
float intensity
);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(
ID3D11DeviceContext* device_context,
XMMATRIX world_matrix,
XMMATRIX view_matrix,
XMMATRIX projection_matrix,
ID3D11ShaderResourceView* texture,
XMFLOAT4 ambient_color,
XMFLOAT4 diffuse_color,
XMFLOAT3 light_direction,
float sun_intensity
);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* matrix_buffer_;
ID3D11Buffer* camera_buffer_;
ID3D11Buffer* sunlight_buffer_;
ID3D11Buffer* sunlight_color_buffer_;
ID3D11Buffer* sunlight_position_buffer_;
};

View File

@@ -18,12 +18,12 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: ColorShaderClass
// Class name: color_shader_class
////////////////////////////////////////////////////////////////////////////////
class ColorShaderClass
class color_shader_class
{
private:
struct MatrixBufferType
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
@@ -31,27 +31,27 @@ private:
};
public:
ColorShaderClass();
ColorShaderClass(const ColorShaderClass&);
~ColorShaderClass();
color_shader_class();
color_shader_class(const color_shader_class&);
~color_shader_class();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX);
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX);
void RenderShader(ID3D11DeviceContext*, int);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
};
#endif

View File

@@ -0,0 +1,62 @@
#ifndef _FONTSHADERCLASS_H_
#define _FONTSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: font_shader_class
////////////////////////////////////////////////////////////////////////////////
class font_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct pixel_buffer_type
{
XMFLOAT4 pixelColor;
};
public:
font_shader_class();
font_shader_class(const font_shader_class&);
~font_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4);
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, ID3D11ShaderResourceView*, XMFLOAT4);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* pixel_buffer_;
};
#endif

View File

@@ -1,62 +0,0 @@
#ifndef _FONTSHADERCLASS_H_
#define _FONTSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: FontShaderClass
////////////////////////////////////////////////////////////////////////////////
class FontShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct PixelBufferType
{
XMFLOAT4 pixelColor;
};
public:
FontShaderClass();
FontShaderClass(const FontShaderClass&);
~FontShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_pixelBuffer;
};
#endif

View File

@@ -0,0 +1,57 @@
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTMAPSHADERCLASS_H_
#define _LIGHTMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: light_map_shader_class
////////////////////////////////////////////////////////////////////////////////
class light_map_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
light_map_shader_class();
light_map_shader_class(const light_map_shader_class&);
~light_map_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
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, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@@ -0,0 +1,92 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTSHADERCLASS_H_
#define _LIGHTSHADERCLASS_H_
#pragma once
/////////////
// GLOBALS //
/////////////
constexpr int num_lights = 4;
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: light_shader_class
////////////////////////////////////////////////////////////////////////////////
class light_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct camera_buffer_type
{
XMFLOAT3 cameraPosition;
float padding;
};
struct light_buffer_type
{
XMFLOAT4 ambientColor;
XMFLOAT4 diffuseColor;
XMFLOAT3 lightDirection;
float padding; // Added extra padding so structure is a multiple of 16 for CreateBuffer function requirements.
float specularPower;
XMFLOAT4 specularColor;
};
struct light_color_buffer_type
{
XMFLOAT4 diffuseColor[num_lights];
};
struct light_position_buffer_type
{
XMFLOAT4 lightPosition[num_lights];
};
public:
light_shader_class();
light_shader_class(const light_shader_class&);
~light_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
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, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* matrix_buffer_;
ID3D11Buffer* camera_buffer_;
ID3D11Buffer* light_buffer_;
ID3D11Buffer* light_color_buffer_;
ID3D11Buffer* light_position_buffer_;
};
#endif

View File

@@ -1,57 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTMAPSHADERCLASS_H_
#define _LIGHTMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: LightMapShaderClass
////////////////////////////////////////////////////////////////////////////////
class LightMapShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
LightMapShaderClass();
LightMapShaderClass(const LightMapShaderClass&);
~LightMapShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
};
#endif

View File

@@ -1,92 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTSHADERCLASS_H_
#define _LIGHTSHADERCLASS_H_
#pragma once
/////////////
// GLOBALS //
/////////////
const int NUM_LIGHTS = 4;
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: LightShaderClass
////////////////////////////////////////////////////////////////////////////////
class LightShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct CameraBufferType
{
XMFLOAT3 cameraPosition;
float padding;
};
struct LightBufferType
{
XMFLOAT4 ambientColor;
XMFLOAT4 diffuseColor;
XMFLOAT3 lightDirection;
float padding; // Added extra padding so structure is a multiple of 16 for CreateBuffer function requirements.
float specularPower;
XMFLOAT4 specularColor;
};
struct LightColorBufferType
{
XMFLOAT4 diffuseColor[NUM_LIGHTS];
};
struct LightPositionBufferType
{
XMFLOAT4 lightPosition[NUM_LIGHTS];
};
public:
LightShaderClass();
LightShaderClass(const LightShaderClass&);
~LightShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_matrixBuffer;
ID3D11Buffer* m_cameraBuffer;
ID3D11Buffer* m_lightBuffer;
ID3D11Buffer* m_lightColorBuffer;
ID3D11Buffer* m_lightPositionBuffer;
};
#endif

View File

@@ -1 +0,0 @@
#pragma once

View File

@@ -0,0 +1,59 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: multitextureshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _MULTITEXTURESHADERCLASS_H_
#define _MULTITEXTURESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: multi_texture_shader_class
////////////////////////////////////////////////////////////////////////////////
class multi_texture_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
multi_texture_shader_class();
multi_texture_shader_class(const multi_texture_shader_class&);
~multi_texture_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
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, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@@ -0,0 +1,64 @@
#ifndef _NORMALMAPSHADERCLASS_H_
#define _NORMALMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: normal_map_shader_class
////////////////////////////////////////////////////////////////////////////////
class normal_map_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct light_buffer_type
{
XMFLOAT4 diffuse_color;
XMFLOAT3 light_direction;
float padding;
};
public:
normal_map_shader_class();
normal_map_shader_class(const normal_map_shader_class&);
~normal_map_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
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, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* light_buffer_;
};
#endif

View File

@@ -1,64 +0,0 @@
#ifndef _NORMALMAPSHADERCLASS_H_
#define _NORMALMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: NormalMapShaderClass
////////////////////////////////////////////////////////////////////////////////
class NormalMapShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct LightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT3 lightDirection;
float padding;
};
public:
NormalMapShaderClass();
NormalMapShaderClass(const NormalMapShaderClass&);
~NormalMapShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_lightBuffer;
};
#endif

View File

@@ -0,0 +1,65 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: reflectionshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _REFLECTIONSHADERCLASS_H_
#define _REFLECTIONSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: reflection_shader_class
////////////////////////////////////////////////////////////////////////////////
class reflection_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct reflection_buffer_type
{
XMMATRIX reflection_matrix;
};
public:
reflection_shader_class();
reflection_shader_class(const reflection_shader_class&);
~reflection_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMMATRIX);
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, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMMATRIX);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* reflection_buffer_;
};
#endif

View File

@@ -1,65 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: reflectionshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _REFLECTIONSHADERCLASS_H_
#define _REFLECTIONSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: ReflectionShaderClass
////////////////////////////////////////////////////////////////////////////////
class ReflectionShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct ReflectionBufferType
{
XMMATRIX reflectionMatrix;
};
public:
ReflectionShaderClass();
ReflectionShaderClass(const ReflectionShaderClass&);
~ReflectionShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMMATRIX);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMMATRIX);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_reflectionBuffer;
};
#endif

View File

@@ -0,0 +1,72 @@
#ifndef _REFRACTIONSHADERCLASS_H_
#define _REFRACTIONSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: refraction_shader_class
////////////////////////////////////////////////////////////////////////////////
class refraction_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct light_buffer_type
{
XMFLOAT4 ambient_color;
XMFLOAT4 diffuse_color;
XMFLOAT4 light_position;
XMFLOAT3 light_direction;
float padding;
};
struct clip_plane_buffer_type
{
XMFLOAT4 clip_plane;
};
public:
refraction_shader_class();
refraction_shader_class(const refraction_shader_class&);
~refraction_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
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, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* matrix_buffer_;
ID3D11Buffer* light_buffer_;
ID3D11Buffer* clip_plane_buffer_;
};
#endif

View File

@@ -1,72 +0,0 @@
#ifndef _REFRACTIONSHADERCLASS_H_
#define _REFRACTIONSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: RefractionShaderClass
////////////////////////////////////////////////////////////////////////////////
class RefractionShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct LightBufferType
{
XMFLOAT4 ambientColor;
XMFLOAT4 diffuseColor;
XMFLOAT4 lightPosition;
XMFLOAT3 lightDirection;
float padding;
};
struct ClipPlaneBufferType
{
XMFLOAT4 clipPlane;
};
public:
RefractionShaderClass();
RefractionShaderClass(const RefractionShaderClass&);
~RefractionShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_matrixBuffer;
ID3D11Buffer* m_lightBuffer;
ID3D11Buffer* m_clipPlaneBuffer;
};
#endif

View File

@@ -0,0 +1,67 @@
#ifndef _SHADERMANAGERCLASS_H_
#define _SHADERMANAGERCLASS_H_
// Inclure les en-têtes nécessaires
#include <d3d11.h>
#include <DirectXMath.h>
#include <vector>
#include "texture_shader_class.h"
#include "normal_map_shader_class.h"
#include "multi_texture_shader_class.h"
#include "translate_shader_class.h"
#include "alpha_map_shader_class.h"
#include "spec_map_shader_class.h"
#include "transparent_shader_class.h"
#include "light_shader_class.h"
#include "light_map_shader_class.h"
#include "refraction_shader_class.h"
#include "water_shader_class.h"
#include "celshade_class.h"
#include "skybox_shader_class.h"
#include "sunlight_shader_class.h"
using namespace DirectX;
class shader_manager_class
{
public:
shader_manager_class();
shader_manager_class(const shader_manager_class&);
~shader_manager_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render_texture_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
bool render_normal_map_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
bool render_multitexture_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool render_translate_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
bool render_alpha_map_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool render_spec_map_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
bool render_transparent_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
bool renderlight_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
bool renderlight_map_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool render_refraction_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
bool render_water_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
bool render_cel_shading_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool render_sunlight_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool render_skybox_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
private:
texture_shader_class* texture_shader_;
normal_map_shader_class* normal_map_shader_;
multi_texture_shader_class* multitexture_shader_;
translate_shader_class* translate_shader_;
alpha_map_shader_class* alpha_map_shader_;
spec_map_shader_class* spec_map_shader_;
transparent_shader_class* transparent_shader_;
light_shader_class* light_shader_;
light_map_shader_class* light_map_shader_;
refraction_shader_class* refraction_shader_;
water_shader_class* water_shader_;
celshade_class* cel_shading_shader_;
sunlight_shader_class* sunlight_shader_;
skybox_shader_class* skybox_shader_;
};
#endif

View File

@@ -1,67 +0,0 @@
#ifndef _SHADERMANAGERCLASS_H_
#define _SHADERMANAGERCLASS_H_
// Inclure les en-têtes nécessaires
#include <d3d11.h>
#include <DirectXMath.h>
#include <vector>
#include "textureshaderclass.h"
#include "normalmapshaderclass.h"
#include "multitextureshaderclass.h"
#include "translateshaderclass.h"
#include "alphamapshaderclass.h"
#include "specmapshaderclass.h"
#include "transparentshaderclass.h"
#include "lightshaderclass.h"
#include "lightmapshaderclass.h"
#include "refractionshaderclass.h"
#include "watershaderclass.h"
#include "celshadingshader.h"
#include "SkyboxShaderClass.h"
#include "sunlightshaderclass.h"
using namespace DirectX;
class ShaderManagerClass
{
public:
ShaderManagerClass();
ShaderManagerClass(const ShaderManagerClass&);
~ShaderManagerClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool RenderTextureShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
bool RenderNormalMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
bool RenderMultitextureShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool RenderTranslateShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
bool RenderAlphaMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool RenderSpecMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
bool RenderTransparentShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
bool RenderlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
bool RenderlightMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool RenderRefractionShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
bool RenderWaterShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
bool RenderCelShadingShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool RenderSunlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool RenderSkyboxShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
private:
TextureShaderClass* m_TextureShader;
NormalMapShaderClass* m_NormalMapShader;
MultiTextureShaderClass* m_MultitextureShader;
TranslateShaderClass* m_TranslateShader;
AlphaMapShaderClass* m_AlphaMapShader;
SpecMapShaderClass* m_SpecMapShader;
TransparentShaderClass* m_TransparentShader;
LightShaderClass* m_LightShader;
LightMapShaderClass* m_LightMapShader;
RefractionShaderClass* m_RefractionShader;
WaterShaderClass* m_WaterShader;
CelshadeClass* m_CelShadingShader;
SunlightShaderClass* m_SunlightShader;
SkyboxShaderClass* m_SkyboxShader;
};
#endif

View File

@@ -8,7 +8,7 @@
using namespace DirectX;
using namespace std;
class SkyboxShaderClass
class skybox_shader_class
{
private :
@@ -39,9 +39,9 @@ class SkyboxShaderClass
};
public :
SkyboxShaderClass();
SkyboxShaderClass(const SkyboxShaderClass&);
~SkyboxShaderClass();
skybox_shader_class();
skybox_shader_class(const skybox_shader_class&);
~skybox_shader_class();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();

View File

@@ -0,0 +1,72 @@
#ifndef _SPECMAPSHADERCLASS_H_
#define _SPECMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: spec_map_shader_class
////////////////////////////////////////////////////////////////////////////////
class spec_map_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct light_buffer_type
{
XMFLOAT4 diffuse_color;
XMFLOAT4 specular_color;
float specular_power;
XMFLOAT3 light_direction;
};
struct camera_buffer_type
{
XMFLOAT3 camera_position;
float padding;
};
public:
spec_map_shader_class();
spec_map_shader_class(const spec_map_shader_class&);
~spec_map_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, 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, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* light_buffer_;
ID3D11Buffer* camera_buffer_;
};
#endif

View File

@@ -1,72 +0,0 @@
#ifndef _SPECMAPSHADERCLASS_H_
#define _SPECMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: SpecMapShaderClass
////////////////////////////////////////////////////////////////////////////////
class SpecMapShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct LightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT4 specularColor;
float specularPower;
XMFLOAT3 lightDirection;
};
struct CameraBufferType
{
XMFLOAT3 cameraPosition;
float padding;
};
public:
SpecMapShaderClass();
SpecMapShaderClass(const SpecMapShaderClass&);
~SpecMapShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_lightBuffer;
ID3D11Buffer* m_cameraBuffer;
};
#endif

View File

@@ -0,0 +1,68 @@
#pragma once
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
class sunlight_shader_class
{
private :
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct camera_buffer_type
{
XMFLOAT3 camera_position;
float padding;
};
struct sun_light_buffer_type
{
XMFLOAT4 diffuse_color;
XMFLOAT4 ambient_color;
XMFLOAT3 sun_direction;
float intensity;
};
struct sun_light_color_buffer_type
{
XMFLOAT4 sun_color;
};
public :
sunlight_shader_class();
sunlight_shader_class(const sunlight_shader_class&);
~sunlight_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3,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, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* matrix_buffer_;
ID3D11Buffer* camera_buffer_;
ID3D11Buffer* sunlight_buffer_;
ID3D11Buffer* sunlight_color_buffer_;
ID3D11Buffer* sunlight_position_buffer_;
};

View File

@@ -1,68 +0,0 @@
#pragma once
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
class SunlightShaderClass
{
private :
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct CameraBufferType
{
XMFLOAT3 cameraPosition;
float padding;
};
struct SunLightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT4 ambientColor;
XMFLOAT3 sunDirection;
float intensity;
};
struct SunLightColorBufferType
{
XMFLOAT4 sunColor;
};
public :
SunlightShaderClass();
SunlightShaderClass(const SunlightShaderClass&);
~SunlightShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3,float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_matrixBuffer;
ID3D11Buffer* m_cameraBuffer;
ID3D11Buffer* m_sunlightBuffer;
ID3D11Buffer* m_sunlightColorBuffer;
ID3D11Buffer* m_sunlightPositionBuffer;
};

View File

@@ -0,0 +1,56 @@
#ifndef _TEXTURESHADERCLASS_H_
#define _TEXTURESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: texture_shader_class
////////////////////////////////////////////////////////////////////////////////
class texture_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
texture_shader_class();
texture_shader_class(const texture_shader_class&);
~texture_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
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, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@@ -1,56 +0,0 @@
#ifndef _TEXTURESHADERCLASS_H_
#define _TEXTURESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: TextureShaderClass
////////////////////////////////////////////////////////////////////////////////
class TextureShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
TextureShaderClass();
TextureShaderClass(const TextureShaderClass&);
~TextureShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
};
#endif

View File

@@ -0,0 +1,63 @@
#ifndef _TRANSLATESHADERCLASS_H_
#define _TRANSLATESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: translate_shader_class
////////////////////////////////////////////////////////////////////////////////
class translate_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct translate_buffer_type
{
float translation;
XMFLOAT3 padding;
};
public:
translate_shader_class();
translate_shader_class(const translate_shader_class&);
~translate_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, 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, ID3D11ShaderResourceView*, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* translate_buffer_;
};
#endif

View File

@@ -1,63 +0,0 @@
#ifndef _TRANSLATESHADERCLASS_H_
#define _TRANSLATESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: TranslateShaderClass
////////////////////////////////////////////////////////////////////////////////
class TranslateShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct TranslateBufferType
{
float translation;
XMFLOAT3 padding;
};
public:
TranslateShaderClass();
TranslateShaderClass(const TranslateShaderClass&);
~TranslateShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_translateBuffer;
};
#endif

View File

@@ -0,0 +1,63 @@
#ifndef _TRANSPARENTSHADERCLASS_H_
#define _TRANSPARENTSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: transparent_shader_class
////////////////////////////////////////////////////////////////////////////////
class transparent_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct transparent_buffer_type
{
float blend_amount;
XMFLOAT3 padding;
};
public:
transparent_shader_class();
transparent_shader_class(const transparent_shader_class&);
~transparent_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, 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, ID3D11ShaderResourceView*, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* transparent_buffer_;
};
#endif

View File

@@ -1,63 +0,0 @@
#ifndef _TRANSPARENTSHADERCLASS_H_
#define _TRANSPARENTSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: TransparentShaderClass
////////////////////////////////////////////////////////////////////////////////
class TransparentShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct TransparentBufferType
{
float blendAmount;
XMFLOAT3 padding;
};
public:
TransparentShaderClass();
TransparentShaderClass(const TransparentShaderClass&);
~TransparentShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_transparentBuffer;
};
#endif

View File

@@ -0,0 +1,70 @@
#ifndef _WATERSHADERCLASS_H_
#define _WATERSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
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

View File

@@ -1,70 +0,0 @@
#ifndef _WATERSHADERCLASS_H_
#define _WATERSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: WaterShaderClass
////////////////////////////////////////////////////////////////////////////////
class WaterShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct ReflectionBufferType
{
XMMATRIX reflection;
};
struct WaterBufferType
{
float waterTranslation;
float reflectRefractScale;
XMFLOAT2 padding;
};
public:
WaterShaderClass();
WaterShaderClass(const WaterShaderClass&);
~WaterShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_reflectionBuffer;
ID3D11Buffer* m_waterBuffer;
};
#endif

View File

@@ -1,46 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: cameraclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _CAMERACLASS_H_
#define _CAMERACLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: CameraClass
////////////////////////////////////////////////////////////////////////////////
class CameraClass
{
public:
CameraClass();
CameraClass(const CameraClass&);
~CameraClass();
void SetPosition(float, float, float);
void SetRotation(float, float, float);
XMFLOAT3 GetPosition();
XMFLOAT3 GetRotation();
void Render();
XMMATRIX GetViewMatrix(XMMATRIX& viewMatrix) const;
void RenderReflection(float);
void GetReflectionViewMatrix(XMMATRIX&) const;
private:
float m_positionX, m_positionY, m_positionZ;
float m_rotationX, m_rotationY, m_rotationZ;
XMMATRIX m_viewMatrix;
XMMATRIX m_reflectionViewMatrix;
};
#endif

View File

@@ -67,12 +67,12 @@ public:
case LogLevel::Info: return LogLevelInfo{ "Info", 0, ImVec4(0.0f, 1.0f, 0.0f, 1.0f) };
case LogLevel::Warning: return LogLevelInfo{ "Warning", 1, ImVec4(1.0f, 1.0f, 0.0f, 1.0f) };
case LogLevel::Error: return LogLevelInfo{ "Error", 2, ImVec4(1.0f, 0.0f, 0.0f, 1.0f) };
case LogLevel::Shutdown: return LogLevelInfo{ "Shutdown", 3, ImVec4(0.5f, 0.0f, 0.0f, 1.0f) };
case LogLevel::Initialize: return LogLevelInfo{ "Initialize", 4, ImVec4(0.0f, 1.0f, 1.0f, 1.0f) };
case LogLevel::Shutdown: return LogLevelInfo{ "shutdown", 3, ImVec4(0.5f, 0.0f, 0.0f, 1.0f) };
case LogLevel::Initialize: return LogLevelInfo{ "initialize", 4, ImVec4(0.0f, 1.0f, 1.0f, 1.0f) };
case LogLevel::Update: return LogLevelInfo{ "Update", 5, ImVec4(1.0f, 0.0f, 1.0f, 1.0f) };
case LogLevel::Render: return LogLevelInfo{ "Render", 6, ImVec4(1.0f, 1.0f, 1.0f, 1.0f) };
case LogLevel::Render: return LogLevelInfo{ "render", 6, ImVec4(1.0f, 1.0f, 1.0f, 1.0f) };
case LogLevel::Input: return LogLevelInfo{ "Input", 7, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Physics: return LogLevelInfo{ "Physics", 8, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Physics: return LogLevelInfo{ "physics", 8, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Audio: return LogLevelInfo{ "Audio", 9, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Network: return LogLevelInfo{ "Network", 10, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Scripting: return LogLevelInfo{ "Scripting", 11, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };

View File

@@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include "d3dclass.h"
#include "d_3d_class.h"
#include "object.h"
class Skybox
@@ -11,9 +11,9 @@ public:
Skybox();
~Skybox();
void Initialize(D3DClass* d3dClassRef); // Get all the required references
void Initialize(d_3d_class* d3dClassRef); // Get all the required references
Object* ConstructSkybox();
object* ConstructSkybox();
// Variables
@@ -23,8 +23,8 @@ public:
private:
D3DClass* m_d3dClassRef; // Reference to the D3DClass instance
Object* m_Skybox;
d_3d_class* m_d3dClassRef; // Reference to the d_3d_class instance
object* m_Skybox;
};

View File

@@ -0,0 +1,325 @@
#ifndef _APPLICATIONCLASS_H_
#define _APPLICATIONCLASS_H_
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "d_3d_class.h"
#include "camera_class.h"
#include "object.h"
#include "light_class.h"
#include <vector>
#include <filesystem>
#include "bitmap_class.h"
#include "sprite_class.h"
#include "timer_class.h"
#include "font_shader_class.h"
#include "font_class.h"
#include "text_class.h"
#include "fps_class.h"
#include "input_class.h"
#include "shader_manager_class.h"
#include "modellistclass.h"
#include "position_class.h"
#include "frustumclass.h"
#include "render_texture_class.h"
#include "display_plane_class.h"
#include "translate_shader_class.h"
#include "reflection_shader_class.h"
#include "physics.h"
#include "frustum.h"
#include "skybox.h"
#include <fstream>
#include <WICTextureLoader.h>
#include <comdef.h> // Pour _com_error
#include <chrono>
#include <thread>
#include <map>
#include <algorithm>
#include <DirectXMath.h>
#include <mutex>
/////////////
// GLOBALS //
/////////////
constexpr bool full_screen = false;
constexpr float screen_depth = 1000.0f;
constexpr float screen_near = 0.3f;
struct input
{
bool key_left = false;
bool key_right = false;
bool key_up = false;
bool key_down = false;
};
////////////////////////////////////////////////////////////////////////////////
// Class name: application_class
////////////////////////////////////////////////////////////////////////////////
class application_class
{
public:
application_class();
~application_class();
d_3d_class* get_direct_3d();
render_texture_class* get_scene_texture() const { return scene_texture_; };
render_texture_class* get_render_texture() const { return render_texture_; };
render_texture_class* get_refraction_texture() const { return refraction_texture_; };
render_texture_class* get_reflection_texture() const { return reflection_texture_; };
int get_total_vertex_count() const;
int get_total_triangle_count() const;
int get_visible_triangle_count() const;
void create_big_cube(int side_count);
void process_terrain_generation();
bool initialize(int, int, HWND, bool is_vulkan);
void shutdown();
bool frame(input_class*);
void physics_thread_function();
int get_physics_tick_rate() const { return physics_tick_rate_; };
void set_physics_tick_rate(int physics_tick_rate) { physics_tick_rate_ = physics_tick_rate; };
int get_screen_width() const;
void set_screen_width(int screen_width);
int get_screen_height() const;
void set_screen_height(int screen_height);
float get_speed() const { return speed_; };
void set_speed(const float speed) { this->speed_ = speed; };
void add_cube();
void delete_kobject(int index);
size_t get_cube_count() const { return cubes_.size(); };
size_t get_terrain_cube_count() const { return terrain_chunk_.size(); };
std::vector<object*> get_cubes() const { return cubes_; };
std::vector<object*> get_terrain_cubes() const { return terrain_chunk_; };
std::vector<object*> get_kobjects() const { return object_; };
void add_kobject(std::wstring& filepath);
void set_path(WCHAR* path) { path_ = path; };
void set_w_folder(const std::filesystem::path& w_folder) { w_folder_ = w_folder; };
void generate_terrain();
void delete_terrain();
XMVECTOR get_light_position(int index);
XMVECTOR get_light_color(int index);
void set_light_position(int index, XMVECTOR position);
void set_light_color(int index, XMVECTOR color);
std::vector<light_class*> get_lights() const { return lights_; };
light_class* get_sun_light() const { return sun_light_; };
bool get_should_quit() const { return should_quit_; };
void set_should_quit(const bool should_quit) { should_quit_ = should_quit; };
void set_cel_shading(const bool enable) { enable_cel_shading_ = enable; };
void set_vsync(bool vsync);
bool get_vsync() const { return vsync_enabled_; };
HWND get_hwnd() const;
void set_hwnd(HWND hwnd);
bool is_windowed() const;
void set_windowed(bool windowed);
void set_window_size(const ImVec2 size) { window_size_ = size; };
ImVec2 get_window_size() const { return window_size_; };
float get_aspect_ratio() const { return static_cast<float>(screen_width_) / static_cast<float>(screen_height_); };
physics* get_physics() const { return physics_; };
// ------------------------------------- //
// --------------- Stats --------------- //
// ------------------------------------- //
int get_current_fps() const;
int get_min_fps() const;
int get_max_fps() const;
float get_frame_time() const;
int get_draw_calls() const;
void reset_fps_stats();
void increment_draw_call_count();
void reset_draw_call_count();
// ----------------------------------- //
// ------------- Culling ------------- //
// ----------------------------------- //
frustum get_frustum() const { return frustum_culling_; };
void set_frustum(const frustum& frustum) { frustum_culling_ = frustum; };
void construct_frustum();
int get_render_count() const { return render_count_; };
void set_render_count(const int render_count) { render_count_ = render_count; };
float get_frustum_tolerance() const { return frustum_culling_tolerance_; };
void set_frustum_tolerance(const float frustum_tolerance) { frustum_culling_tolerance_ = frustum_tolerance; };
bool get_can_fixed_update() const { return can_fixed_update_; };
void set_can_fixed_update(bool can_fixed_update) { can_fixed_update_ = can_fixed_update; };
ID3D11ShaderResourceView* get_back_buffer_srv() const {return back_buffer_srv_;};
// Save and load scene
void save_scene();
bool load_scene();
void set_scene_path(const std::string& path) { scene_path_ = path; };
std::wstring get_scene_path();
std::string convert_w_string_to_string(const std::wstring& w_str);
private:
bool render(float, float, float, float, float);
bool render_physics(bool key_left, bool key_right, bool key_up, bool key_down, float delta_time);
bool update_mouse_strings(int, int, bool);
bool update_fps();
bool update_render_count_string(int);
bool render_scene_to_texture(float);
bool render_refraction_to_texture();
bool render_reflection_to_texture();
bool render_pass(const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
void update_skybox_position();
public :
std::vector<ID3D11ShaderResourceView*> textures;
private :
// Thread de culling
std::thread culling_thread_;
std::atomic<bool> culling_active_;
std::mutex objects_mutex_;
void culling_thread_function();
std::mutex terrain_mutex_;
std::vector<std::tuple<float, float, float, std::string, int>> terrain_generation_data_;
bool terrain_generation_ready_;
int next_terrain_object_id_;
// ------------------------------------- //
// ------------- DIRECT3D -------------- //
// ------------------------------------- //
d_3d_class* direct_3d_;
IDXGISwapChain* swap_chain_;
model_class* model_,* ground_model_, * wall_model_, * bath_model_, * water_model_;
ModelListClass* model_list_;
bool vsync_enabled_ = true;
HWND hwnd_;
bool windowed_;
std::string scene_path_;
// ------------------------------------- //
// ------------- RENDERING ------------- //
// ------------------------------------- //
XMMATRIX base_view_matrix_;
render_texture_class* render_texture_, * refraction_texture_, * reflection_texture_;
render_texture_class* scene_texture_;
display_plane_class* display_plane_;
int screen_width_, screen_height_;
camera_class* camera_;
position_class* position_;
int drawcalls_;
// ------------------------------------ //
// ------------- OBJECTS -------------- //
// ------------------------------------ //
object* selected_object_;
std::vector<object*> cubes_;
std::vector<object*> terrain_chunk_;
float speed_ = 0.1f; // speed for the demo spinning object
std::vector<object*> object_;
std::vector<object*> imported_object_;
int object_id_ = 0;
std::vector<std::reference_wrapper<std::vector<object*>>> render_queues_;
std::vector<object*> skybox_;
// ----------------------------------- //
// ------------- LIGHTS -------------- //
// ----------------------------------- //
light_class* m_light_;
std::vector<light_class*> lights_;
int num_lights_;
light_class* sun_light_;
XMFLOAT3 true_light_position_;
model_class* light_model_;
// ----------------------------------- //
// ------------- SHADERS ------------- //
// ----------------------------------- //
shader_manager_class* shader_manager_;
font_shader_class* font_shader_;
bitmap_class* bitmap_;
sprite_class* sprite_;
bool enable_cel_shading_;
// ----------------------------------- //
// ------------ VARIABLES ------------ //
// ----------------------------------- //
float water_height_, water_translation_;
wchar_t* path_;
std::filesystem::path w_folder_;
// ------------------------------------------------- //
// ------------- FPS AND INFO ON SCREEN ------------ //
// ------------------------------------------------- //
timer_class* timer_;
text_class* mouse_strings_;
text_class* render_count_string_;
font_class* font_;
fps_class* fps_;
text_class* fps_string_;
int previous_fps_;
// ------------------------------------------------- //
// ------------------- OTHER ----------------------- //
// ------------------------------------------------- //
bool should_quit_;
physics* physics_;
float gravity_;
XMVECTOR previous_position_;
ImVec2 window_size_;
int physics_tick_rate_ = 50;
bool can_fixed_update_ = false;
std::thread physics_thread_;
ID3D11Texture2D* back_buffer_texture_;
ID3D11ShaderResourceView* back_buffer_srv_;
// ------------------------------------------------- //
// ------------------- Culling --------------------- //
// ------------------------------------------------- //
frustum frustum_culling_;
int render_count_;
float frustum_culling_tolerance_ = 5.f;
// ------------------------------------------------- //
// -------------------- Input ---------------------- //
// ------------------------------------------------- //
input inputs_;
};
#endif

View File

@@ -1,327 +0,0 @@
#ifndef _APPLICATIONCLASS_H_
#define _APPLICATIONCLASS_H_
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "d3dclass.h"
#include "cameraclass.h"
#include "object.h"
#include "lightclass.h"
#include <vector>
#include <filesystem>
#include "bitmapclass.h"
#include "spriteclass.h"
#include "timerclass.h"
#include "fontshaderclass.h"
#include "fontclass.h"
#include "textclass.h"
#include "fpsclass.h"
#include "inputclass.h"
#include "shadermanagerclass.h"
#include "modellistclass.h"
#include "positionclass.h"
#include "frustumclass.h"
#include "rendertextureclass.h"
#include "displayplaneclass.h"
#include "translateshaderclass.h"
#include "reflectionshaderclass.h"
#include "physics.h"
#include "frustum.h"
#include "skybox.h"
#include <fstream>
#include <WICTextureLoader.h>
#include <comdef.h> // Pour _com_error
#include <chrono>
#include <thread>
#include <map>
#include <algorithm>
#include <DirectXMath.h>
#include <mutex>
/////////////
// GLOBALS //
/////////////
const bool FULL_SCREEN = false;
const float SCREEN_DEPTH = 1000.0f;
const float SCREEN_NEAR = 0.3f;
struct Input
{
bool m_KeyLeft = false;
bool m_KeyRight = false;
bool m_KeyUp = false;
bool m_KeyDown = false;
};
////////////////////////////////////////////////////////////////////////////////
// Class name: ApplicationClass
////////////////////////////////////////////////////////////////////////////////
class ApplicationClass
{
public:
ApplicationClass();
~ApplicationClass();
D3DClass* GetDirect3D();
RenderTextureClass* GetSceneTexture() const { return m_SceneTexture; };
RenderTextureClass* GetRenderTexture() const { return m_RenderTexture; };
RenderTextureClass* GetRefractionTexture() const { return m_RefractionTexture; };
RenderTextureClass* GetReflectionTexture() const { return m_ReflectionTexture; };
int GetTotalVertexCount() const;
int GetTotalTriangleCount() const;
int GetVisibleTriangleCount() const;
void CreateBigCube(int sideCount);
void ProcessTerrainGeneration();
bool Initialize(int, int, HWND, bool IsVulkan);
void Shutdown();
bool Frame(InputClass*);
void PhysicsThreadFunction();
int GetPhysicsTickRate() const { return m_PhysicsTickRate; };
void SetPhysicsTickRate(int physicsTickRate) { m_PhysicsTickRate = physicsTickRate; };
int GetScreenWidth() const;
void SetScreenWidth(int screenWidth);
int GetScreenHeight() const;
void SetScreenHeight(int screenHeight);
float GetSpeed() const { return m_speed; };
void SetSpeed(float speed) { this->m_speed = speed; };
void AddCube();
void DeleteKobject(int index);
size_t GetCubeCount() const { return m_cubes.size(); };
size_t GetTerrainCubeCount() const { return m_terrainChunk.size(); };
std::vector<Object*> GetCubes() const { return m_cubes; };
std::vector<Object*> GetTerrainCubes() const { return m_terrainChunk; };
std::vector<Object*> GetKobjects() const { return m_object; };
void AddKobject(std::wstring& filepath);
void SetPath(WCHAR* path) { m_path = path; };
void SetWFolder(std::filesystem::path WFolder) { m_WFolder = WFolder; };
void GenerateTerrain();
void DeleteTerrain();
XMVECTOR GetLightPosition(int index);
XMVECTOR GetLightColor(int index);
void SetLightPosition(int index, XMVECTOR color);
void SetLightColor(int index, XMVECTOR color);
void DeleteLight(int index);
void AddLight();
std::vector<LightClass*> GetLights() const { return m_Lights; };
LightClass* GetSunLight() const { return m_SunLight; };
bool GetShouldQuit() const { return m_ShouldQuit; };
void SetShouldQuit(bool shouldQuit) { m_ShouldQuit = shouldQuit; };
void SetCelShading(bool enable) { m_enableCelShading = enable; };
void SetVsync(bool vsync);
bool GetVsync() const { return VSYNC_ENABLED; };
HWND GetHwnd() const;
void SetHwnd(HWND hwnd);
bool IsWindowed() const;
void SetWindowed(bool windowed);
void SetWindowSize(ImVec2 size) { windowSize = size; };
ImVec2 GetWindowSize() const { return windowSize; };
float GetAspectRatio() const { return (float)m_screenWidth / (float)m_screenHeight; };
Physics* GetPhysics() const { return m_Physics; };
// ------------------------------------- //
// --------------- Stats --------------- //
// ------------------------------------- //
int GetCurrentFps() const;
int GetMinFps() const;
int GetMaxFps() const;
float GetFrameTime() const;
int GetDrawCalls() const;
void ResetFpsStats();
void IncrementDrawCallCount();
void ResetDrawCallCount();
// ----------------------------------- //
// ------------- Culling ------------- //
// ----------------------------------- //
Frustum GetFrustum() const { return m_FrustumCulling; };
void SetFrustum(Frustum frustum) { m_FrustumCulling = frustum; };
void ConstructFrustum();
int GetRenderCount() const { return m_renderCount; };
void SetRenderCount(int renderCount) { m_renderCount = renderCount; };
float GetFrustumTolerance() const { return m_FrustumCullingTolerance; };
void SetFrustumTolerance(float frustumTolerance) { m_FrustumCullingTolerance = frustumTolerance; };
bool GetCanFixedUpdate() const { return CanFixedUpdate; };
void SetCanFixedUpdate(bool canFixedUpdate) { CanFixedUpdate = canFixedUpdate; };
ID3D11ShaderResourceView* GetBackBufferSRV() const {return m_BackBufferSRV;};
// Save and load scene
void SaveScene();
bool LoadScene();
void SetScenePath(std::string path) { m_scenePath = path; };
std::wstring GetScenePath();
std::string ConvertWStringToString(const std::wstring& wstr);
private:
bool Render(float, float, float, float, float);
bool RenderPhysics(bool keyLeft, bool keyRight, bool keyUp, bool keyDown, float deltaTime);
bool UpdateMouseStrings(int, int, bool);
bool UpdateFps();
bool UpdateRenderCountString(int);
bool RenderSceneToTexture(float);
bool RenderRefractionToTexture();
bool RenderReflectionToTexture();
bool RenderPass(const std::vector<std::reference_wrapper<std::vector<Object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
void UpdateSkyboxPosition();
public :
std::vector<ID3D11ShaderResourceView*> textures;
private :
// Thread de culling
std::thread m_CullingThread;
std::atomic<bool> m_CullingActive;
std::mutex m_ObjectsMutex;
void CullingThreadFunction();
std::mutex m_TerrainMutex;
std::vector<std::tuple<float, float, float, std::string, int>> m_TerrainGenerationData;
bool m_TerrainGenerationReady;
int m_NextTerrainObjectId;
// ------------------------------------- //
// ------------- DIRECT3D -------------- //
// ------------------------------------- //
D3DClass* m_Direct3D;
IDXGISwapChain* m_swapChain;
ModelClass* m_Model,* m_GroundModel, * m_WallModel, * m_BathModel, * m_WaterModel;
ModelListClass* m_ModelList;
bool VSYNC_ENABLED = true;
HWND m_hwnd;
bool m_windowed;
std::string m_scenePath;
// ------------------------------------- //
// ------------- RENDERING ------------- //
// ------------------------------------- //
XMMATRIX m_baseViewMatrix;
RenderTextureClass* m_RenderTexture, * m_RefractionTexture, * m_ReflectionTexture;
RenderTextureClass* m_SceneTexture;
DisplayPlaneClass* m_DisplayPlane;
int m_screenWidth, m_screenHeight;
CameraClass* m_Camera;
PositionClass* m_Position;
int m_drawcalls;
// ------------------------------------ //
// ------------- OBJECTS -------------- //
// ------------------------------------ //
Object* m_SelectedObject;
std::vector<Object*> m_cubes;
std::vector<Object*> m_terrainChunk;
float m_speed = 0.1f; // speed for the demo spinning object
std::vector<Object*> m_object;
std::vector<Object*> m_ImportedObject;
int m_ObjectId = 0;
std::vector<std::reference_wrapper<std::vector<Object*>>> m_RenderQueues;
std::vector<Object*> m_Skybox;
// ----------------------------------- //
// ------------- LIGHTS -------------- //
// ----------------------------------- //
LightClass* m_Light;
std::vector<LightClass*> m_Lights;
int m_numLights;
LightClass* m_SunLight;
XMFLOAT3 TrueLightPosition;
ModelClass* m_LightModel;
// ----------------------------------- //
// ------------- SHADERS ------------- //
// ----------------------------------- //
ShaderManagerClass* m_ShaderManager;
FontShaderClass* m_FontShader;
BitmapClass* m_Bitmap;
SpriteClass* m_Sprite;
bool m_enableCelShading;
// ----------------------------------- //
// ------------ VARIABLES ------------ //
// ----------------------------------- //
float m_waterHeight, m_waterTranslation;
wchar_t* m_path;
std::filesystem::path m_WFolder;
// ------------------------------------------------- //
// ------------- FPS AND INFO ON SCREEN ------------ //
// ------------------------------------------------- //
TimerClass* m_Timer;
TextClass* m_MouseStrings;
TextClass* m_RenderCountString;
FontClass* m_Font;
FpsClass* m_Fps;
TextClass* m_FpsString;
int m_previousFps;
// ------------------------------------------------- //
// ------------------- OTHER ----------------------- //
// ------------------------------------------------- //
bool m_ShouldQuit;
Physics* m_Physics;
float m_gravity;
XMVECTOR m_previousPosition;
ImVec2 windowSize;
int m_PhysicsTickRate = 50;
bool CanFixedUpdate = false;
std::thread m_PhysicsThread;
ID3D11Texture2D* m_BackBufferTexture;
ID3D11ShaderResourceView* m_BackBufferSRV;
// ------------------------------------------------- //
// ------------------- Culling --------------------- //
// ------------------------------------------------- //
Frustum m_FrustumCulling;
int m_renderCount;
float m_FrustumCullingTolerance = 5.f;
// ------------------------------------------------- //
// -------------------- Input ---------------------- //
// ------------------------------------------------- //
Input m_Inputs;
};
#endif

View File

@@ -0,0 +1,59 @@
#ifndef _BITMAPCLASS_H_
#define _BITMAPCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "texture_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: bitmap_class
////////////////////////////////////////////////////////////////////////////////
class bitmap_class
{
private:
struct vertex_type
{
XMFLOAT3 position;
XMFLOAT2 texture;
};
public:
bitmap_class();
bitmap_class(const bitmap_class&);
~bitmap_class();
bool initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, char*, int, int);
void shutdown();
bool render(ID3D11DeviceContext*);
int get_index_count();
ID3D11ShaderResourceView* get_texture();
void set_render_location(int, int);
private:
bool initialize_buffers(ID3D11Device*);
void shutdown_buffers();
bool update_buffers(ID3D11DeviceContext*);
void render_buffers(ID3D11DeviceContext*);
bool load_texture(ID3D11Device*, ID3D11DeviceContext*, char*);
void release_texture();
private:
ID3D11Buffer* vertex_buffer_, * index_buffer_;
int vertex_count_, index_count_, screen_width_, screen_height_, bitmap_width_, bitmap_height_, render_x_, render_y_, prev_pos_x_, prev_pos_y_;
texture_class* texture_;
};
#endif

View File

@@ -1,59 +0,0 @@
#ifndef _BITMAPCLASS_H_
#define _BITMAPCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: BitmapClass
////////////////////////////////////////////////////////////////////////////////
class BitmapClass
{
private:
struct VertexType
{
XMFLOAT3 position;
XMFLOAT2 texture;
};
public:
BitmapClass();
BitmapClass(const BitmapClass&);
~BitmapClass();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, char*, int, int);
void Shutdown();
bool Render(ID3D11DeviceContext*);
int GetIndexCount();
ID3D11ShaderResourceView* GetTexture();
void SetRenderLocation(int, int);
private:
bool InitializeBuffers(ID3D11Device*);
void ShutdownBuffers();
bool UpdateBuffers(ID3D11DeviceContext*);
void RenderBuffers(ID3D11DeviceContext*);
bool LoadTexture(ID3D11Device*, ID3D11DeviceContext*, char*);
void ReleaseTexture();
private:
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
int m_vertexCount, m_indexCount, m_screenWidth, m_screenHeight, m_bitmapWidth, m_bitmapHeight, m_renderX, m_renderY, m_prevPosX, m_prevPosY;
TextureClass* m_Texture;
};
#endif

View File

@@ -0,0 +1,46 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: cameraclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _CAMERACLASS_H_
#define _CAMERACLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: camera_class
////////////////////////////////////////////////////////////////////////////////
class camera_class
{
public:
camera_class();
camera_class(const camera_class&);
~camera_class();
void set_position(float, float, float);
void set_rotation(float, float, float);
XMFLOAT3 get_position();
XMFLOAT3 get_rotation();
void render();
XMMATRIX get_view_matrix(XMMATRIX& view_matrix) const;
void render_reflection(float);
void get_reflection_view_matrix(XMMATRIX&) const;
private:
float position_x_, position_y_, position_z_;
float rotation_x_, rotation_y_, rotation_z_;
XMMATRIX view_matrix_;
XMMATRIX reflection_view_matrix_;
};
#endif

View File

@@ -1,90 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// 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 "fontshaderclass.h"
#include "fontclass.h"
#include "textclass.h"
using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: D3DClass
////////////////////////////////////////////////////////////////////////////////
class D3DClass
{
public:
D3DClass();
D3DClass(const D3DClass&);
~D3DClass();
bool Initialize(int, int, bool, HWND, bool, float, float);
void Shutdown();
void BeginScene(float, float, float, float);
void EndScene();
ID3D11Device* GetDevice();
ID3D11DeviceContext* GetDeviceContext();
//XMMATRIX GetProjectionMatrix(XMMATRIX& projectionMatrix);
IDXGISwapChain* m_swapChain;
IDXGISwapChain* GetSwapChain();
void ResizeSwapChain(int, int);
void SetVsync(bool vsync);
XMMATRIX GetProjectionMatrix() const { return m_projectionMatrix; };
XMMATRIX GetWorldMatrix() const { return m_worldMatrix;};
XMMATRIX GetOrthoMatrix() const { return m_orthoMatrix; };
void GetVideoCardInfo(char*, int&);
void SetBackBufferRenderTarget();
void ResetViewport();
void ReleaseResources();
void ResetResources(int newWidth, int newHeight);
void TurnZBufferOn();
void TurnZBufferOff();
void EnableAlphaBlending();
void DisableAlphaBlending();
private:
bool m_vsync_enabled;
int m_videoCardMemory;
char m_videoCardDescription[128];
ID3D11Device* m_device;
ID3D11DeviceContext* m_deviceContext;
ID3D11RenderTargetView* m_renderTargetView;
ID3D11Texture2D* m_depthStencilBuffer;
ID3D11DepthStencilState* m_depthStencilState;
ID3D11DepthStencilView* m_depthStencilView;
ID3D11RasterizerState* m_rasterState;
XMMATRIX m_projectionMatrix;
XMMATRIX m_worldMatrix;
XMMATRIX m_orthoMatrix;
D3D11_VIEWPORT m_viewport;
ID3D11DepthStencilState* m_depthDisabledStencilState;
ID3D11BlendState* m_alphaEnableBlendingState;
ID3D11BlendState* m_alphaDisableBlendingState;
};
#endif

View File

@@ -0,0 +1,90 @@
////////////////////////////////////////////////////////////////////////////////
// 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();
bool initialize(int, int, bool, HWND, bool, float, float);
void shutdown();
void begin_scene(float, float, float, float);
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

View File

@@ -5,13 +5,13 @@
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "d3dclass.h"
#include "d_3d_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: DisplayPlaneClass
// Class name: display_plane_class
////////////////////////////////////////////////////////////////////////////////
class DisplayPlaneClass
class display_plane_class
{
private:
struct VertexType
@@ -21,9 +21,9 @@ private:
};
public:
DisplayPlaneClass();
DisplayPlaneClass(const DisplayPlaneClass&);
~DisplayPlaneClass();
display_plane_class();
display_plane_class(const display_plane_class&);
~display_plane_class();
bool Initialize(ID3D11Device*, float, float);
void Shutdown();

View File

@@ -13,13 +13,13 @@ using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
#include "texture_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: FontClass
// Class name: font_class
////////////////////////////////////////////////////////////////////////////////
class FontClass
class font_class
{
private:
struct FontType
@@ -35,9 +35,9 @@ private:
};
public:
FontClass();
FontClass(const FontClass&);
~FontClass();
font_class();
font_class(const font_class&);
~font_class();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int);
void Shutdown();
@@ -56,7 +56,7 @@ private:
private:
FontType* m_Font;
TextureClass* m_Texture;
texture_class* m_Texture;
float m_fontHeight;
int m_spaceSize;
};

View File

@@ -15,14 +15,14 @@
#include <mmsystem.h>
////////////////////////////////////////////////////////////////////////////////
// Class name: FpsClass
// Class name: fps_class
////////////////////////////////////////////////////////////////////////////////
class FpsClass
class fps_class
{
public:
FpsClass();
FpsClass(const FpsClass&);
~FpsClass();
fps_class();
fps_class(const fps_class&);
~fps_class();
void Initialize();
void Frame();

View File

@@ -0,0 +1,22 @@
#pragma once
#include <chrono>
class fps_limiter {
public:
explicit fps_limiter(const float target_fps = 60.0f)
: min_delta_(1.0f / target_fps), last_time_(std::chrono::high_resolution_clock::now()) {}
// Retourne true si la fonction peut etre executee
bool should_run() {
const auto now = std::chrono::high_resolution_clock::now();
if (const float elapsed = std::chrono::duration<float>(now - last_time_).count(); elapsed >= min_delta_) {
last_time_ = now;
return true;
}
return false;
}
private:
float min_delta_;
std::chrono::high_resolution_clock::time_point last_time_;
};

View File

@@ -1,7 +1,7 @@
#include <DirectXMath.h>
using namespace DirectX;
class Frustum
class frustum
{
public:
void ConstructFrustum(float screenDepth, XMMATRIX projectionMatrix, XMMATRIX viewMatrix);

View File

@@ -4,15 +4,24 @@
#include "Logger.h"
#include "sceneManager.h"
#include "fps_limiter.h"
#include <imgui.h>
#include <imgui_impl_dx11.h>
#include <imgui_impl_win32.h>
#include <windows.h>
#include <deque>
#include "rendertextureclass.h"
#include <functional>
class ApplicationClass;
#include "render_texture_class.h"
class application_class;
struct widget_entry
{
bool* show;
std::function<void()> func;
};
class imguiManager
{
@@ -22,29 +31,32 @@ public:
bool Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext);
void Shutdown();
void Render(ApplicationClass* app);
void Render();
void NewFrame();
void SetupDockspace(ApplicationClass* app);
void SetupDockspace();
// Widgets
void WidgetSpeedSlider(float* speed);
void WidgetButton();
void WidgetFPS();
void WidgetAddObject(ApplicationClass* app);
void WidgetAddObject();
void WidgetObjectWindow(ApplicationClass* app);
void WidgetTerrainWindow(ApplicationClass* app);
void WidgetLightWindow(ApplicationClass* app);
void WidgetEngineSettingsWindow(ApplicationClass* app);
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
void WidgetLogWindow(ApplicationClass* app);
void WidgetRenderStats(ApplicationClass* app);
void WidgetObjectWindow();
void WidgetTerrainWindow();
void WidgetLightWindow();
void WidgetEngineSettingsWindow();
void WidgetRenderWindow(ImVec2 availableSize);
void WidgetLogWindow();
void WidgetRenderStats();
bool ImGuiWidgetRenderer(ApplicationClass* app);
bool ImGuiWidgetRenderer();
void SetWindowSize(ImVec2 size) { windowSize = size; }
ImVec2 GetWindowSize() const { return windowSize; }
// Getters
void SetApp(application_class* app) { app_ = app; }
// Shader toggles
bool m_EnableCelShading;
@@ -59,6 +71,9 @@ private:
// ----------------- Variables ----------------- //
// --------------------------------------------- //
std::vector<widget_entry> widgets_;
application_class* app_;
bool showObjectWindow;
bool showTerrainWindow;
@@ -83,9 +98,12 @@ private:
ID3D11DeviceContext* m_deviceContext;
ImVec2 windowSize;
RenderTextureClass* m_renderTexture;
render_texture_class* m_renderTexture;
const std::deque<Logger::LogEntry>& logBuffer = Logger::Get().GetLogBuffer();
int current_fps_, min_fps_, max_fps_, draw_calls_, total_vertex_count_, total_triangle_count_, visible_triangle_count_;
float current_frame_time_, min_frame_time_, max_frame_time_ ;
};
#endif

View File

@@ -19,14 +19,14 @@
#include <dinput.h>
////////////////////////////////////////////////////////////////////////////////
// Class name: InputClass
// Class name: input_class
////////////////////////////////////////////////////////////////////////////////
class InputClass
class input_class
{
public:
InputClass();
InputClass(const InputClass&);
~InputClass();
input_class();
input_class(const input_class&);
~input_class();
bool Initialize(HINSTANCE, HWND, int, int);
void Shutdown();

View File

@@ -14,14 +14,14 @@ using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: LightClass
// Class name: light_class
////////////////////////////////////////////////////////////////////////////////
class LightClass
class light_class
{
public:
LightClass();
LightClass(const LightClass&);
~LightClass();
light_class();
light_class(const light_class&);
~light_class();
void SetAmbientColor(float, float, float, float);
void SetDiffuseColor(float, float, float, float);

View File

@@ -20,7 +20,7 @@ using namespace std;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
#include "texture_class.h"
enum class TextureType
{
@@ -46,7 +46,7 @@ struct TextureContainer
std::vector<std::wstring> alphaPaths;
// Get the vector of textures based on the type
// Get the vector of textures_ based on the type
std::vector<ID3D11ShaderResourceView*>& Get(TextureType type) const {
switch (type) {
case TextureType::Diffuse: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(diffuse);
@@ -57,7 +57,7 @@ struct TextureContainer
}
}
// Get the vector of textures paths based on the type
// Get the vector of textures_ paths based on the type
std::vector<std::wstring> GetPaths(TextureType type) const {
switch (type)
{
@@ -87,7 +87,7 @@ struct TextureContainer
return L"";
}
// Release all textures and textures paths
// Release all textures_ and textures_ paths
void ReleaseAll() {
ReleaseVector(diffuse);
@@ -145,9 +145,9 @@ private:
}
};
////////////////////////////////////////////////////////////////////////////////
// Class name: ModelClass
// Class name: model_class
////////////////////////////////////////////////////////////////////////////////
class ModelClass
class model_class
{
protected:
@@ -200,15 +200,15 @@ protected:
};
public:
ModelClass();
ModelClass(const ModelClass&) = delete;
ModelClass& operator=(const ModelClass&) = delete;
~ModelClass();
model_class();
model_class(const model_class&) = delete;
model_class& operator=(const model_class&) = delete;
~model_class();
//bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
//bool initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
// Nouvelle surcharge avec TextureContainer
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, const TextureContainer&);
// Nouvelle méthode - initialisation sans textures
// Nouvelle méthode - initialisation sans textures_
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*);
void Shutdown();
void Render(ID3D11DeviceContext*);
@@ -218,7 +218,7 @@ public:
// TEXTURE //
//ID3D11ShaderResourceView* GetTexture(int index) const;
//ID3D11ShaderResourceView* get_texture(int index) const;
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const;
//bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index);

View File

@@ -1,9 +1,9 @@
#pragma once
#include "modelclass.h"
#include "model_class.h"
#include <WICTextureLoader.h>
#include <SimpleMath.h>
#include "d3dclass.h"
#include "d_3d_class.h"
enum class ObjectType
{
@@ -26,14 +26,14 @@ enum class ShaderType
ALPHA_MAPPING
};
class Object : public ModelClass
class object : public model_class
{
public:
Object();
~Object();
object();
~object();
Object(const Object&) = delete;
Object& operator=(const Object&) = delete;
object(const object&) = delete;
object& operator=(const object&) = delete;
void SetScaleMatrix(XMMATRIX scaleMatrix);
void SetRotateMatrix(XMMATRIX rotateMatrix);
@@ -103,7 +103,7 @@ public:
void LaunchObject();
bool LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
D3DClass* m_Direct3D);
d_3d_class* m_Direct3D);
bool SetupInstancing(ID3D11Device* device, const std::vector<XMMATRIX>& instanceTransforms);
void EnableInstancing(bool enabled);
void SetInstanceCount(int count);

View File

@@ -4,21 +4,21 @@
#include "object.h"
#include "math.h"
class Physics : public Object
class physics : public object
{
public:
Physics();
explicit Physics(const Physics&); // Use explicit to avoid implicit conversion
~Physics();
physics();
explicit physics(const physics&); // Use explicit to avoid implicit conversion
~physics();
XMVECTOR GetGravity() const; // Get the gravity value
void SetGravity(XMVECTOR gravity); // Define the gravity value
void ApplyGravity(Object*, float); // Apply gravity to an object
void AddForce(Object*, XMVECTOR);
bool IsColliding(Object*, Object*);
bool CubesOverlap(Object*, Object*);
bool SpheresOverlap(Object*, Object*);
bool SphereCubeOverlap(Object*, Object*);
void ApplyGravity(object*, float); // Apply gravity to an object
void AddForce(object*, XMVECTOR);
bool IsColliding(object*, object*);
bool CubesOverlap(object*, object*);
bool SpheresOverlap(object*, object*);
bool SphereCubeOverlap(object*, object*);
private:
XMVECTOR m_gravity;

View File

@@ -9,14 +9,14 @@
////////////////////////////////////////////////////////////////////////////////
// Class name: PositionClass
// Class name: position_class
////////////////////////////////////////////////////////////////////////////////
class PositionClass
class position_class
{
public:
PositionClass();
PositionClass(const PositionClass&);
~PositionClass();
position_class();
position_class(const position_class&);
~position_class();
void SetFrameTime(float);
void GetRotation(float&, float&) const;

View File

@@ -15,14 +15,14 @@ using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: RenderTextureClass
// Class name: render_texture_class
////////////////////////////////////////////////////////////////////////////////
class RenderTextureClass
class render_texture_class
{
public:
RenderTextureClass();
RenderTextureClass(const RenderTextureClass&);
~RenderTextureClass();
render_texture_class();
render_texture_class(const render_texture_class&);
~render_texture_class();
bool Initialize(ID3D11Device*, int, int, float, float, int);
void Shutdown();

View File

@@ -13,13 +13,13 @@ using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
#include "texture_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: SpriteClass
// Class name: sprite_class
////////////////////////////////////////////////////////////////////////////////
class SpriteClass
class sprite_class
{
private:
struct VertexType
@@ -29,9 +29,9 @@ private:
};
public:
SpriteClass();
SpriteClass(const SpriteClass&);
~SpriteClass();
sprite_class();
sprite_class(const sprite_class&);
~sprite_class();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, char*, int, int);
void Shutdown();
@@ -55,7 +55,7 @@ private:
private:
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
int m_vertexCount, m_indexCount, m_screenWidth, m_screenHeight, m_bitmapWidth, m_bitmapHeight, m_renderX, m_renderY, m_prevPosX, m_prevPosY;
TextureClass* m_Textures;
texture_class* m_Textures;
float m_frameTime, m_cycleTime;
int m_currentTexture, m_textureCount;
};

View File

@@ -0,0 +1,72 @@
#ifndef _SYSTEMCLASS_H_
#define _SYSTEMCLASS_H_
#define WIN32_LEAN_AND_MEAN
static bool DEBUG_MODE = true;
#include "Logger.h"
#include "input_class.h"
#include "application_class.h"
#include "imguiManager.h"
#include <mutex>
#include <filesystem>
#include <commdlg.h>
#include "../resources.h"
#include <chrono>
class system_class
{
public:
system_class();
system_class(const system_class&);
~system_class();
bool initialize();
void shutdown();
void run();
LRESULT CALLBACK message_handler(HWND, UINT, WPARAM, LPARAM);
void send_path(wchar_t* path, std::filesystem::path w_folder);
protected:
bool frame();
void initialize_windows(int&, int&);
void shutdown_windows();
private:
LPCWSTR application_name_;
HINSTANCE hinstance_;
HWND hwnd_;
input_class* input_;
application_class* application_;
imguiManager* imgui_manager_;
int initial_window_width_;
int initial_window_height_;
bool is_direct_3d_initialized_;
bool is_resizing_ = false;
bool is_debug_key_pressed_ = false;
std::mutex render_mutex_;
};
/////////////////////////
// FUNCTION PROTOTYPES //
/////////////////////////
static LRESULT CALLBACK wnd_proc(HWND, UINT, WPARAM, LPARAM);
/////////////
// GLOBALS //
/////////////
static system_class* application_handle = 0;
#endif

View File

@@ -1,73 +0,0 @@
#ifndef _SYSTEMCLASS_H_
#define _SYSTEMCLASS_H_
#define WIN32_LEAN_AND_MEAN
static bool DEBUG_MODE = true;
#include "Logger.h"
#include "inputclass.h"
#include "applicationclass.h"
#include "imguiManager.h"
#include <mutex>
#include <filesystem>
#include <commdlg.h>
#include "../resources.h"
#include <chrono>
class SystemClass
{
public:
SystemClass();
SystemClass(const SystemClass&);
~SystemClass();
bool Initialize();
void Shutdown();
void Run();
LRESULT CALLBACK MessageHandler(HWND, UINT, WPARAM, LPARAM);
void SendPath(wchar_t* path, std::filesystem::path WFolder);
void GetScenePath();
protected:
bool Frame();
void InitializeWindows(int&, int&);
void ShutdownWindows();
private:
LPCWSTR m_applicationName;
HINSTANCE m_hinstance;
HWND m_hwnd;
InputClass* m_Input;
ApplicationClass* m_Application;
imguiManager* m_imguiManager;
int m_initialWindowWidth;
int m_initialWindowHeight;
bool m_isDirect3DInitialized;
bool m_isResizing = false;
bool m_IsDebugKeyPressed = false;
std::mutex renderMutex;
};
/////////////////////////
// FUNCTION PROTOTYPES //
/////////////////////////
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
/////////////
// GLOBALS //
/////////////
static SystemClass* ApplicationHandle = 0;
#endif

View File

@@ -5,11 +5,11 @@
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "fontclass.h"
#include "font_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: TextClass
// Class name: text_class
////////////////////////////////////////////////////////////////////////////////
class TextClass
class text_class
{
private:
struct VertexType
@@ -19,21 +19,21 @@ private:
};
public:
TextClass();
TextClass(const TextClass&);
~TextClass();
text_class();
text_class(const text_class&);
~text_class();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, int, FontClass*, char*, int, int, float, float, float);
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, int, font_class*, char*, int, int, float, float, float);
void Shutdown();
void Render(ID3D11DeviceContext*);
int GetIndexCount();
bool UpdateText(ID3D11DeviceContext*, FontClass*, char*, int, int, float, float, float);
bool UpdateText(ID3D11DeviceContext*, font_class*, char*, int, int, float, float, float);
XMFLOAT4 GetPixelColor();
private:
bool InitializeBuffers(ID3D11Device*, ID3D11DeviceContext*, FontClass*, char*, int, int, float, float, float);
bool InitializeBuffers(ID3D11Device*, ID3D11DeviceContext*, font_class*, char*, int, int, float, float, float);
void ShutdownBuffers();
void RenderBuffers(ID3D11DeviceContext*);

View File

@@ -11,9 +11,9 @@
////////////////////////////////////////////////////////////////////////////////
// Class name: TextureClass
// Class name: texture_class
////////////////////////////////////////////////////////////////////////////////
class TextureClass
class texture_class
{
private:
struct TargaHeader
@@ -26,9 +26,9 @@ private:
};
public:
TextureClass();
TextureClass(const TextureClass&);
~TextureClass();
texture_class();
texture_class(const texture_class&);
~texture_class();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, std::string);
void Shutdown();

View File

@@ -10,14 +10,14 @@
////////////////////////////////////////////////////////////////////////////////
// Class name: TimerClass
// Class name: timer_class
////////////////////////////////////////////////////////////////////////////////
class TimerClass
class timer_class
{
public:
TimerClass();
TimerClass(const TimerClass&);
~TimerClass();
timer_class();
timer_class(const timer_class&);
~timer_class();
bool Initialize();
void Frame();

View File

@@ -1,29 +1,29 @@
#include "alphamapshaderclass.h"
#include "alpha_map_shader_class.h"
AlphaMapShaderClass::AlphaMapShaderClass()
alpha_map_shader_class::alpha_map_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
AlphaMapShaderClass::AlphaMapShaderClass(const AlphaMapShaderClass& other)
alpha_map_shader_class::alpha_map_shader_class(const alpha_map_shader_class& other)
{
}
AlphaMapShaderClass::~AlphaMapShaderClass()
alpha_map_shader_class::~alpha_map_shader_class()
{
}
bool AlphaMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool alpha_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing AlphaMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@@ -46,8 +46,8 @@ bool AlphaMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -58,23 +58,23 @@ bool AlphaMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void AlphaMapShaderClass::Shutdown()
void alpha_map_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool AlphaMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool alpha_map_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -82,13 +82,13 @@ bool AlphaMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCo
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -102,7 +102,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
D3D11_SAMPLER_DESC samplerDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -115,7 +115,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -134,7 +134,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -146,7 +146,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -154,7 +154,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -191,7 +191,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -207,14 +207,14 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -237,7 +237,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -250,53 +250,53 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
void AlphaMapShaderClass::ShutdownShader()
void alpha_map_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
Logger::Get().Log("Releasing sampler state", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
Logger::Get().Log("Sampler state released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
Logger::Get().Log("Releasing constant buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
Logger::Get().Log("Constant buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the layout.
if (m_layout)
if (layout_)
{
Logger::Get().Log("Releasing layout", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
Logger::Get().Log("Layout released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
Logger::Get().Log("Releasing pixel shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
Logger::Get().Log("Pixel shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
Logger::Get().Log("Releasing vertex shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
Logger::Get().Log("Vertex shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
@@ -306,7 +306,7 @@ void AlphaMapShaderClass::ShutdownShader()
}
void AlphaMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void alpha_map_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -342,12 +342,12 @@ void AlphaMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWN
}
bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool alpha_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
@@ -357,7 +357,7 @@ bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -365,7 +365,7 @@ bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -373,13 +373,13 @@ bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@@ -390,20 +390,20 @@ bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
}
void AlphaMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void alpha_map_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,34 +1,34 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "CelShadingShader.h"
#include "celshade_class.h"
CelshadeClass::CelshadeClass()
celshade_class::celshade_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_sampleState = 0;
m_matrixBuffer = 0;
m_cameraBuffer = 0;
m_sunlightBuffer = 0;
m_sunlightColorBuffer = 0;
m_sunlightPositionBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
camera_buffer_ = 0;
sunlight_buffer_ = 0;
sunlight_color_buffer_ = 0;
sunlight_position_buffer_ = 0;
}
CelshadeClass::CelshadeClass(const CelshadeClass& other)
celshade_class::celshade_class(const celshade_class& other)
{
}
CelshadeClass::~CelshadeClass()
celshade_class::~celshade_class()
{
}
bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
bool celshade_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -52,8 +52,8 @@ bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -66,22 +66,22 @@ bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void CelshadeClass::Shutdown()
void celshade_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool CelshadeClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
bool celshade_class::render(ID3D11DeviceContext* deviceContext, int index_count, XMMATRIX world_matrix, XMMATRIX view_matrix, XMMATRIX projection_matrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuse_color, XMFLOAT4 ambient_color, XMFLOAT3 sun_direction, float sunIntensity)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
result = set_shader_parameters(deviceContext, world_matrix, view_matrix, projection_matrix, texture, diffuse_color, ambient_color, sun_direction, sunIntensity);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -89,13 +89,13 @@ bool CelshadeClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, X
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, index_count);
return true;
}
bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -109,7 +109,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_BUFFER_DESC sunlightBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -120,7 +120,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
{
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
else
{
@@ -135,7 +135,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
{
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
else
{
@@ -145,7 +145,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -153,7 +153,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -189,7 +189,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]);
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_layout);
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -219,7 +219,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -228,14 +228,14 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -244,14 +244,14 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
sunlightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
sunlightBufferDesc.ByteWidth = sizeof(SunLightBufferType);
sunlightBufferDesc.ByteWidth = sizeof(sun_light_buffer_type);
sunlightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
sunlightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
sunlightBufferDesc.MiscFlags = 0;
sunlightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &m_sunlightBuffer);
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &sunlight_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -266,70 +266,70 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
void CelshadeClass::ShutdownShader()
void celshade_class::shutdown_shader()
{
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffers.
if (m_sunlightColorBuffer)
if (sunlight_color_buffer_)
{
m_sunlightColorBuffer->Release();
m_sunlightColorBuffer = 0;
sunlight_color_buffer_->Release();
sunlight_color_buffer_ = 0;
}
if (m_sunlightPositionBuffer)
if (sunlight_position_buffer_)
{
m_sunlightPositionBuffer->Release();
m_sunlightPositionBuffer = 0;
sunlight_position_buffer_->Release();
sunlight_position_buffer_ = 0;
}
// Release the light constant buffer.
if (m_sunlightBuffer)
if (sunlight_buffer_)
{
m_sunlightBuffer->Release();
m_sunlightBuffer = 0;
sunlight_buffer_->Release();
sunlight_buffer_ = 0;
}
// Release the camera constant buffer.
if (m_cameraBuffer)
if (camera_buffer_)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
camera_buffer_->Release();
camera_buffer_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -338,7 +338,7 @@ void CelshadeClass::ShutdownShader()
}
void CelshadeClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void celshade_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@@ -374,98 +374,98 @@ void CelshadeClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd
}
bool CelshadeClass::SetShaderParameters(
ID3D11DeviceContext* deviceContext,
XMMATRIX worldMatrix,
XMMATRIX viewMatrix,
XMMATRIX projectionMatrix,
bool celshade_class::set_shader_parameters(
ID3D11DeviceContext* device_context,
XMMATRIX world_matrix,
XMMATRIX view_matrix,
XMMATRIX projection_matrix,
ID3D11ShaderResourceView* texture,
XMFLOAT4 ambientColor,
XMFLOAT4 diffuseColor,
XMFLOAT3 lightDirection,
float sunIntensity
XMFLOAT4 ambient_color,
XMFLOAT4 diffuse_color,
XMFLOAT3 light_direction,
float sun_intensity
)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
CameraBufferType* dataPtr2;
SunLightBufferType* dataPtr3;
matrix_buffer_type* dataPtr;
camera_buffer_type* dataPtr2;
sun_light_buffer_type* dataPtr3;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
worldMatrix = XMMatrixTranspose(worldMatrix);
viewMatrix = XMMatrixTranspose(viewMatrix);
projectionMatrix = XMMatrixTranspose(projectionMatrix);
world_matrix = XMMatrixTranspose(world_matrix);
view_matrix = XMMatrixTranspose(view_matrix);
projection_matrix = XMMatrixTranspose(projection_matrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = device_context->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
dataPtr->view = viewMatrix;
dataPtr->projection = projectionMatrix;
dataPtr->world = world_matrix;
dataPtr->view = view_matrix;
dataPtr->projection = projection_matrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
device_context->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
device_context->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the sunlight constant buffer so it can be written to.
result = deviceContext->Map(m_sunlightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = device_context->Map(sunlight_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (SunLightBufferType*)mappedResource.pData;
dataPtr3 = (sun_light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr3->ambientColor = ambientColor;
dataPtr3->diffuseColor = diffuseColor;
dataPtr3->sunDirection = lightDirection;
dataPtr3->intensity = sunIntensity;
dataPtr3->ambient_color = ambient_color;
dataPtr3->diffuse_color = diffuse_color;
dataPtr3->sun_direction = light_direction;
dataPtr3->intensity = sun_intensity;
// Unlock the constant buffer.
deviceContext->Unmap(m_sunlightBuffer, 0);
device_context->Unmap(sunlight_buffer_, 0);
// Set the position of the sunlight constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the sunlight constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_sunlightBuffer);
device_context->PSSetConstantBuffers(bufferNumber, 1, &sunlight_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
device_context->PSSetShaderResources(0, 1, &texture);
return true;
}
void CelshadeClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void celshade_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,29 +1,29 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: colorshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "colorshaderclass.h"
#include "color_shader_class.h"
ColorShaderClass::ColorShaderClass()
color_shader_class::color_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
}
ColorShaderClass::ColorShaderClass(const ColorShaderClass& other)
color_shader_class::color_shader_class(const color_shader_class& other)
{
}
ColorShaderClass::~ColorShaderClass()
color_shader_class::~color_shader_class()
{
}
bool ColorShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool color_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing ColorShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing color_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@@ -47,35 +47,35 @@ bool ColorShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("ColorShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("color_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void ColorShaderClass::Shutdown()
void color_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool ColorShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool color_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -83,12 +83,12 @@ bool ColorShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -101,7 +101,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
D3D11_BUFFER_DESC matrixBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -114,7 +114,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -133,7 +133,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -145,7 +145,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -153,7 +153,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -183,7 +183,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -199,14 +199,14 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -218,43 +218,43 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
return true;
}
void ColorShaderClass::ShutdownShader()
void color_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
Logger::Get().Log("Releasing matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
Logger::Get().Log("Matrix buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the layout.
if (m_layout)
if (layout_)
{
Logger::Get().Log("Releasing layout", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
Logger::Get().Log("Layout released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
Logger::Get().Log("Releasing pixel shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
Logger::Get().Log("Pixel shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
Logger::Get().Log("Releasing vertex shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
Logger::Get().Log("Vertex shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
@@ -263,7 +263,7 @@ void ColorShaderClass::ShutdownShader()
return;
}
void ColorShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void color_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -298,14 +298,14 @@ void ColorShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
return;
}
bool ColorShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool color_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix)
{
Logger::Get().Log("Setting shader parameters", __FILE__, __LINE__);
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
@@ -314,7 +314,7 @@ bool ColorShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -322,7 +322,7 @@ bool ColorShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -330,27 +330,27 @@ bool ColorShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finanly set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
return true;
}
void ColorShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void color_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,30 +1,30 @@
#include "fontshaderclass.h"
#include "font_shader_class.h"
FontShaderClass::FontShaderClass()
font_shader_class::font_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_pixelBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
pixel_buffer_ = 0;
}
FontShaderClass::FontShaderClass(const FontShaderClass& other)
font_shader_class::font_shader_class(const font_shader_class& other)
{
}
FontShaderClass::~FontShaderClass()
font_shader_class::~font_shader_class()
{
}
bool FontShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool font_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing FontShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing font_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@@ -47,35 +47,35 @@ bool FontShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("FontShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("font_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void FontShaderClass::Shutdown()
void font_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool FontShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool font_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 pixelColor)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, pixelColor);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, pixelColor);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -83,12 +83,12 @@ bool FontShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount,
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -103,7 +103,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
D3D11_BUFFER_DESC pixelBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -116,7 +116,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -135,7 +135,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -147,7 +147,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -155,7 +155,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -185,7 +185,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -201,14 +201,14 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -231,7 +231,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -240,14 +240,14 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// Setup the description of the dynamic pixel constant buffer that is in the pixel shader.
pixelBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
pixelBufferDesc.ByteWidth = sizeof(PixelBufferType);
pixelBufferDesc.ByteWidth = sizeof(pixel_buffer_type);
pixelBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
pixelBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
pixelBufferDesc.MiscFlags = 0;
pixelBufferDesc.StructureByteStride = 0;
// Create the pixel constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&pixelBufferDesc, NULL, &m_pixelBuffer);
result = device->CreateBuffer(&pixelBufferDesc, NULL, &pixel_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -259,50 +259,50 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
return true;
}
void FontShaderClass::ShutdownShader()
void font_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the pixel constant buffer.
if (m_pixelBuffer)
if (pixel_buffer_)
{
m_pixelBuffer->Release();
m_pixelBuffer = 0;
pixel_buffer_->Release();
pixel_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -310,7 +310,7 @@ void FontShaderClass::ShutdownShader()
return;
}
void FontShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void font_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -345,15 +345,15 @@ void FontShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hw
return;
}
bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool font_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 pixelColor)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
PixelBufferType* dataPtr2;
pixel_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@@ -362,7 +362,7 @@ bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XM
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -370,7 +370,7 @@ bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XM
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -378,19 +378,19 @@ bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XM
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the pixel constant buffer so it can be written to.
result = deviceContext->Map(m_pixelBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(pixel_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -398,36 +398,36 @@ bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XM
}
// Get a pointer to the data in the pixel constant buffer.
dataPtr2 = (PixelBufferType*)mappedResource.pData;
dataPtr2 = (pixel_buffer_type*)mappedResource.pData;
// Copy the pixel color into the pixel constant buffer.
dataPtr2->pixelColor = pixelColor;
// Unlock the pixel constant buffer.
deviceContext->Unmap(m_pixelBuffer, 0);
deviceContext->Unmap(pixel_buffer_, 0);
// Set the position of the pixel constant buffer in the pixel shader.
bufferNumber = 0;
// Now set the pixel constant buffer in the pixel shader with the updated value.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_pixelBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &pixel_buffer_);
return true;
}
void FontShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void font_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,29 +1,29 @@
#include "lightmapshaderclass.h"
#include "light_map_shader_class.h"
LightMapShaderClass::LightMapShaderClass()
light_map_shader_class::light_map_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
LightMapShaderClass::LightMapShaderClass(const LightMapShaderClass& other)
light_map_shader_class::light_map_shader_class(const light_map_shader_class& other)
{
}
LightMapShaderClass::~LightMapShaderClass()
light_map_shader_class::~light_map_shader_class()
{
}
bool LightMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool light_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@@ -46,37 +46,37 @@ bool LightMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("LightMapShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("light_map_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void LightMapShaderClass::Shutdown()
void light_map_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool LightMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool light_map_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -84,13 +84,13 @@ bool LightMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCo
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
HRESULT result;
@@ -103,7 +103,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
D3D11_SAMPLER_DESC samplerDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -116,7 +116,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -135,7 +135,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -147,7 +147,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -155,7 +155,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -192,7 +192,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -208,14 +208,14 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -238,7 +238,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -251,52 +251,52 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
void LightMapShaderClass::ShutdownShader()
void light_map_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down LightMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("Shutting down light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("LightMapShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("light_map_shader_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
return;
}
void LightMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void light_map_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -332,12 +332,12 @@ void LightMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWN
}
bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool light_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
@@ -347,7 +347,7 @@ bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -355,7 +355,7 @@ bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -363,13 +363,13 @@ bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@@ -379,19 +379,19 @@ bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
}
void LightMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void light_map_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,36 +1,36 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "lightshaderclass.h"
#include "light_shader_class.h"
LightShaderClass::LightShaderClass()
light_shader_class::light_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_sampleState = 0;
m_matrixBuffer = 0;
m_cameraBuffer = 0;
m_lightBuffer = 0;
m_lightColorBuffer = 0;
m_lightPositionBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
camera_buffer_ = 0;
light_buffer_ = 0;
light_color_buffer_ = 0;
light_position_buffer_ = 0;
}
LightShaderClass::LightShaderClass(const LightShaderClass& other)
light_shader_class::light_shader_class(const light_shader_class& other)
{
}
LightShaderClass::~LightShaderClass()
light_shader_class::~light_shader_class()
{
}
bool LightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool light_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
wchar_t vsFilename[128];
wchar_t psFilename[128];
@@ -52,36 +52,36 @@ bool LightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("LightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("light_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void LightShaderClass::Shutdown()
void light_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool LightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool light_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientClor[])
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientClor);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientClor);
if(!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -89,13 +89,13 @@ bool LightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -112,7 +112,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
D3D11_BUFFER_DESC lightPositionBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -124,7 +124,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -142,7 +142,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -154,7 +154,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -162,7 +162,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -200,7 +200,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(),
&m_layout);
&layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -230,7 +230,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -239,14 +239,14 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -257,14 +257,14 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the camera dynamic constant buffer that is in the vertex shader.
cameraBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
cameraBufferDesc.ByteWidth = sizeof(CameraBufferType);
cameraBufferDesc.ByteWidth = sizeof(camera_buffer_type);
cameraBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
cameraBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
cameraBufferDesc.MiscFlags = 0;
cameraBufferDesc.StructureByteStride = 0;
// Create the camera constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&cameraBufferDesc, NULL, &m_cameraBuffer);
result = device->CreateBuffer(&cameraBufferDesc, NULL, &camera_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create camera buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -273,14 +273,14 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic constant buffer that is in the pixel shader.
lightColorBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightColorBufferDesc.ByteWidth = sizeof(LightColorBufferType);
lightColorBufferDesc.ByteWidth = sizeof(light_color_buffer_type);
lightColorBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightColorBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightColorBufferDesc.MiscFlags = 0;
lightColorBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&lightColorBufferDesc, NULL, &m_lightColorBuffer);
result = device->CreateBuffer(&lightColorBufferDesc, NULL, &light_color_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create light color buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -289,14 +289,14 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic constant buffer that is in the vertex shader.
lightPositionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightPositionBufferDesc.ByteWidth = sizeof(LightPositionBufferType);
lightPositionBufferDesc.ByteWidth = sizeof(light_position_buffer_type);
lightPositionBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightPositionBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightPositionBufferDesc.MiscFlags = 0;
lightPositionBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&lightPositionBufferDesc, NULL, &m_lightPositionBuffer);
result = device->CreateBuffer(&lightPositionBufferDesc, NULL, &light_position_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create light position buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -309,79 +309,79 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
void LightShaderClass::ShutdownShader()
void light_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("Shutting down light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffers.
if (m_lightColorBuffer)
if (light_color_buffer_)
{
m_lightColorBuffer->Release();
m_lightColorBuffer = 0;
light_color_buffer_->Release();
light_color_buffer_ = 0;
}
if (m_lightPositionBuffer)
if (light_position_buffer_)
{
m_lightPositionBuffer->Release();
m_lightPositionBuffer = 0;
light_position_buffer_->Release();
light_position_buffer_ = 0;
}
// Release the light constant buffer.
if (m_lightBuffer)
if (light_buffer_)
{
m_lightBuffer->Release();
m_lightBuffer = 0;
light_buffer_->Release();
light_buffer_ = 0;
}
// Release the camera constant buffer.
if (m_cameraBuffer)
if (camera_buffer_)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
camera_buffer_->Release();
camera_buffer_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("LightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("light_shader_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
return;
}
void LightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void light_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@@ -417,15 +417,15 @@ void LightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
}
bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientColor[])
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
unsigned int bufferNumber;
MatrixBufferType* dataPtr;
LightPositionBufferType* dataPtr2;
LightColorBufferType* dataPtr3;
matrix_buffer_type* dataPtr;
light_position_buffer_type* dataPtr2;
light_color_buffer_type* dataPtr3;
// Transpose the matrices to prepare them for the shader.
worldMatrix = XMMatrixTranspose(worldMatrix);
@@ -433,7 +433,7 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -441,7 +441,7 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -449,16 +449,16 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Now set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the camera constant buffer so it can be written to.
result = deviceContext->Map(m_cameraBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(camera_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map camera buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -466,7 +466,7 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Lock the light position constant buffer so it can be written to.
result = deviceContext->Map(m_lightPositionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_position_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map light position buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -474,28 +474,28 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Get a pointer to the data in the constant buffer.
dataPtr2 = (LightPositionBufferType*)mappedResource.pData;
dataPtr2 = (light_position_buffer_type*)mappedResource.pData;
// Copy the light position variables into the constant buffer.
for (int i = 0; i < NUM_LIGHTS; i++)
for (int i = 0; i < num_lights; i++)
{
dataPtr2->lightPosition[i] = lightPosition[i];
}
// Unlock the constant buffer.
deviceContext->Unmap(m_lightPositionBuffer, 0);
deviceContext->Unmap(light_position_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 1;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_lightPositionBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &light_position_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the light color constant buffer so it can be written to.
result = deviceContext->Map(m_lightColorBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_color_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map light color buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -503,41 +503,41 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (LightColorBufferType*)mappedResource.pData;
dataPtr3 = (light_color_buffer_type*)mappedResource.pData;
// Copy the light color variables into the constant buffer.
for (int i = 0; i < NUM_LIGHTS; i++)
for (int i = 0; i < num_lights; i++)
{
dataPtr3->diffuseColor[i] = diffuseColor[i];
}
// Unlock the constant buffer.
deviceContext->Unmap(m_lightColorBuffer, 0);
deviceContext->Unmap(light_color_buffer_, 0);
// Set the position of the constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightColorBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_color_buffer_);
return true;
}
void LightShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void light_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,32 +1,32 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: multitextureshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "multitextureshaderclass.h"
#include "multi_texture_shader_class.h"
MultiTextureShaderClass::MultiTextureShaderClass()
multi_texture_shader_class::multi_texture_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
MultiTextureShaderClass::MultiTextureShaderClass(const MultiTextureShaderClass& other)
multi_texture_shader_class::multi_texture_shader_class(const multi_texture_shader_class& other)
{
}
MultiTextureShaderClass::~MultiTextureShaderClass()
multi_texture_shader_class::~multi_texture_shader_class()
{
}
bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool multi_texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing MultiTextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@@ -49,35 +49,35 @@ bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("MultiTextureShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("multi_texture_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void MultiTextureShaderClass::Shutdown()
void multi_texture_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool MultiTextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool multi_texture_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
Logger::Get().Log("Failed to set the shader parameters that it will use for rendering", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -85,12 +85,12 @@ bool MultiTextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int ind
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing the shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -104,7 +104,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
D3D11_SAMPLER_DESC samplerDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -117,7 +117,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -136,7 +136,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -148,7 +148,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the vertex shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -156,7 +156,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the pixel shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -193,7 +193,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the vertex input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -209,14 +209,14 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -239,7 +239,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the texture sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -251,43 +251,43 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
return true;
}
void MultiTextureShaderClass::ShutdownShader()
void multi_texture_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down the shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -295,7 +295,7 @@ void MultiTextureShaderClass::ShutdownShader()
return;
}
void MultiTextureShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void multi_texture_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -330,12 +330,12 @@ void MultiTextureShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage,
return;
}
bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool multi_texture_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
@@ -345,7 +345,7 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to lock the constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -353,7 +353,7 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -361,13 +361,13 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@@ -376,19 +376,19 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
return true;
}
void MultiTextureShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void multi_texture_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,28 +1,28 @@
#include "normalmapshaderclass.h"
#include "normal_map_shader_class.h"
NormalMapShaderClass::NormalMapShaderClass()
normal_map_shader_class::normal_map_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_lightBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
light_buffer_ = 0;
}
NormalMapShaderClass::NormalMapShaderClass(const NormalMapShaderClass& other)
normal_map_shader_class::normal_map_shader_class(const normal_map_shader_class& other)
{
}
NormalMapShaderClass::~NormalMapShaderClass()
normal_map_shader_class::~normal_map_shader_class()
{
}
bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool normal_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing normal map shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -47,8 +47,8 @@ bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__);
@@ -61,22 +61,22 @@ bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void NormalMapShaderClass::Shutdown()
void normal_map_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool NormalMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool normal_map_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, lightDirection, diffuseColor);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, lightDirection, diffuseColor);
if (!result)
{
Logger::Get().Log("Failed to set the shader parameters that will be used for rendering", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -84,13 +84,13 @@ bool NormalMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexC
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing normal map shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -105,7 +105,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
D3D11_BUFFER_DESC lightBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -118,7 +118,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -137,7 +137,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -149,7 +149,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the vertex shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -157,7 +157,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the pixel shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -210,7 +210,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the vertex input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -226,14 +226,14 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -256,7 +256,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the texture sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -265,14 +265,14 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
lightBufferDesc.ByteWidth = sizeof(light_buffer_type);
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightBufferDesc.MiscFlags = 0;
lightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&lightBufferDesc, NULL, &m_lightBuffer);
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the light constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -285,50 +285,50 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
}
void NormalMapShaderClass::ShutdownShader()
void normal_map_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down normal map shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffer.
if (m_lightBuffer)
if (light_buffer_)
{
m_lightBuffer->Release();
m_lightBuffer = 0;
light_buffer_->Release();
light_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Successfully shut down normal map shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -337,7 +337,7 @@ void NormalMapShaderClass::ShutdownShader()
}
void NormalMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void normal_map_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -373,14 +373,14 @@ void NormalMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HW
}
bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool normal_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
LightBufferType* dataPtr2;
light_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@@ -389,7 +389,7 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to lock the constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -397,7 +397,7 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -405,20 +405,20 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
deviceContext->PSSetShaderResources(1, 1, &texture2);
// Lock the light constant buffer so it can be written to.
result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to lock the light constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -426,21 +426,21 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
}
// Get a pointer to the data in the constant buffer.
dataPtr2 = (LightBufferType*)mappedResource.pData;
dataPtr2 = (light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr2->diffuseColor = diffuseColor;
dataPtr2->lightDirection = lightDirection;
dataPtr2->diffuse_color = diffuseColor;
dataPtr2->light_direction = lightDirection;
dataPtr2->padding = 0.0f;
// Unlock the constant buffer.
deviceContext->Unmap(m_lightBuffer, 0);
deviceContext->Unmap(light_buffer_, 0);
// Set the position of the light constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the light constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@@ -450,19 +450,19 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
}
void NormalMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void normal_map_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,25 +1,25 @@
#include "reflectionshaderclass.h"
#include "reflection_shader_class.h"
ReflectionShaderClass::ReflectionShaderClass()
reflection_shader_class::reflection_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_reflectionBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
reflection_buffer_ = 0;
}
ReflectionShaderClass::ReflectionShaderClass(const ReflectionShaderClass& other)
reflection_shader_class::reflection_shader_class(const reflection_shader_class& other)
{
}
ReflectionShaderClass::~ReflectionShaderClass()
reflection_shader_class::~reflection_shader_class()
{
}
bool ReflectionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool reflection_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing reflection shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -44,8 +44,8 @@ bool ReflectionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -57,22 +57,22 @@ bool ReflectionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return true;
}
void ReflectionShaderClass::Shutdown()
void reflection_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool ReflectionShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool reflection_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, ID3D11ShaderResourceView* reflectionTexture, XMMATRIX reflectionMatrix)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, reflectionTexture, reflectionMatrix);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, reflectionTexture, reflectionMatrix);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -80,12 +80,12 @@ bool ReflectionShaderClass::Render(ID3D11DeviceContext* deviceContext, int index
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing reflection shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -100,7 +100,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
D3D11_BUFFER_DESC reflectionBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -113,7 +113,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -131,7 +131,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -143,7 +143,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -151,7 +151,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -180,7 +180,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -196,14 +196,14 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -225,7 +225,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -233,14 +233,14 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
// Setup the description of the reflection dynamic constant buffer that is in the vertex shader.
reflectionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
reflectionBufferDesc.ByteWidth = sizeof(ReflectionBufferType);
reflectionBufferDesc.ByteWidth = sizeof(reflection_buffer_type);
reflectionBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
reflectionBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
reflectionBufferDesc.MiscFlags = 0;
reflectionBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &m_reflectionBuffer);
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &reflection_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -252,50 +252,50 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
return true;
}
void ReflectionShaderClass::ShutdownShader()
void reflection_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down reflection shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the reflection constant buffer.
if (m_reflectionBuffer)
if (reflection_buffer_)
{
m_reflectionBuffer->Release();
m_reflectionBuffer = 0;
reflection_buffer_->Release();
reflection_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Reflection shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -304,7 +304,7 @@ void ReflectionShaderClass::ShutdownShader()
}
void ReflectionShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void reflection_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -339,14 +339,14 @@ void ReflectionShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, H
return;
}
bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool reflection_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, ID3D11ShaderResourceView* reflectionTexture, XMMATRIX reflectionMatrix)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
ReflectionBufferType* dataPtr2;
reflection_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@@ -358,7 +358,7 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
reflectionMatrix = XMMatrixTranspose(reflectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -366,7 +366,7 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -374,16 +374,16 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the reflection constant buffer so it can be written to.
result = deviceContext->Map(m_reflectionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(reflection_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -391,19 +391,19 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
}
// Get a pointer to the data in the matrix constant buffer.
dataPtr2 = (ReflectionBufferType*)mappedResource.pData;
dataPtr2 = (reflection_buffer_type*)mappedResource.pData;
// Copy the matrix into the reflection constant buffer.
dataPtr2->reflectionMatrix = reflectionMatrix;
dataPtr2->reflection_matrix = reflectionMatrix;
// Unlock the reflection constant buffer.
deviceContext->Unmap(m_reflectionBuffer, 0);
deviceContext->Unmap(reflection_buffer_, 0);
// Set the position of the reflection constant buffer in the vertex shader.
bufferNumber = 1;
// Now set the reflection constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_reflectionBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &reflection_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
@@ -415,19 +415,19 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
}
void ReflectionShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void reflection_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render the geometry.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,29 +1,29 @@
#include "refractionshaderclass.h"
#include "refraction_shader_class.h"
RefractionShaderClass::RefractionShaderClass()
refraction_shader_class::refraction_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_lightBuffer = 0;
m_clipPlaneBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
light_buffer_ = 0;
clip_plane_buffer_ = 0;
}
RefractionShaderClass::RefractionShaderClass(const RefractionShaderClass& other)
refraction_shader_class::refraction_shader_class(const refraction_shader_class& other)
{
}
RefractionShaderClass::~RefractionShaderClass()
refraction_shader_class::~refraction_shader_class()
{
}
bool RefractionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool refraction_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
bool result;
wchar_t vsFilename[128];
@@ -44,8 +44,8 @@ bool RefractionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
return false;
@@ -55,35 +55,35 @@ bool RefractionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void RefractionShaderClass::Shutdown()
void refraction_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool RefractionShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool refraction_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor[], XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 clipPlane)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
if (!result)
{
return false;
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
HRESULT result;
ID3D10Blob* errorMessage;
@@ -97,7 +97,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
D3D11_BUFFER_DESC clipPlaneBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -110,7 +110,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -129,7 +129,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -141,14 +141,14 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
return false;
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
return false;
@@ -184,7 +184,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
return false;
@@ -199,14 +199,14 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
return false;
@@ -228,7 +228,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
return false;
@@ -237,14 +237,14 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
// Note that ByteWidth always needs to be a multiple of 16 if using D3D11_BIND_CONSTANT_BUFFER or CreateBuffer will fail.
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
lightBufferDesc.ByteWidth = sizeof(light_buffer_type);
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightBufferDesc.MiscFlags = 0;
lightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&lightBufferDesc, NULL, &m_lightBuffer);
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
if (FAILED(result))
{
return false;
@@ -252,14 +252,14 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Setup the description of the clip plane dynamic constant buffer that is in the vertex shader.
clipPlaneBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
clipPlaneBufferDesc.ByteWidth = sizeof(ClipPlaneBufferType);
clipPlaneBufferDesc.ByteWidth = sizeof(clip_plane_buffer_type);
clipPlaneBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
clipPlaneBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
clipPlaneBufferDesc.MiscFlags = 0;
clipPlaneBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&clipPlaneBufferDesc, NULL, &m_clipPlaneBuffer);
result = device->CreateBuffer(&clipPlaneBufferDesc, NULL, &clip_plane_buffer_);
if (FAILED(result))
{
return false;
@@ -269,62 +269,62 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
void RefractionShaderClass::ShutdownShader()
void refraction_shader_class::shutdown_shader()
{
// Release the clip plane constant buffer.
if (m_clipPlaneBuffer)
if (clip_plane_buffer_)
{
m_clipPlaneBuffer->Release();
m_clipPlaneBuffer = 0;
clip_plane_buffer_->Release();
clip_plane_buffer_ = 0;
}
// Release the light constant buffer.
if (m_lightBuffer)
if (light_buffer_)
{
m_lightBuffer->Release();
m_lightBuffer = 0;
light_buffer_->Release();
light_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
return;
}
void RefractionShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void refraction_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -360,15 +360,15 @@ void RefractionShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, H
}
bool RefractionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor[], XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 clipPlane)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
ClipPlaneBufferType* dataPtr2;
LightBufferType* dataPtr3;
clip_plane_buffer_type* dataPtr2;
light_buffer_type* dataPtr3;
// Transpose the matrices to prepare them for the shader.
@@ -377,14 +377,14 @@ bool RefractionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -392,81 +392,81 @@ bool RefractionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the clip plane constant buffer so it can be written to.
result = deviceContext->Map(m_clipPlaneBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(clip_plane_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if(FAILED(result))
{
return false;
}
// Get a pointer to the data in the clip plane constant buffer.
dataPtr2 = (ClipPlaneBufferType*)mappedResource.pData;
dataPtr2 = (clip_plane_buffer_type*)mappedResource.pData;
// Copy the clip plane into the clip plane constant buffer.
dataPtr2->clipPlane = clipPlane;
dataPtr2->clip_plane = clipPlane;
// Unlock the buffer.
deviceContext->Unmap(m_clipPlaneBuffer, 0);
deviceContext->Unmap(clip_plane_buffer_, 0);
// Set the position of the clip plane constant buffer in the vertex shader.
bufferNumber = 1;
// Now set the clip plane constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_clipPlaneBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &clip_plane_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the light constant buffer so it can be written to.
result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if(FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (LightBufferType*)mappedResource.pData;
dataPtr3 = (light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr3->ambientColor = ambientColor[0];
dataPtr3->diffuseColor = diffuseColor[0];
dataPtr3->lightPosition = lightPosition[0];
dataPtr3->lightDirection = lightDirection;
dataPtr3->ambient_color = ambientColor[0];
dataPtr3->diffuse_color = diffuseColor[0];
dataPtr3->light_position = lightPosition[0];
dataPtr3->light_direction = lightDirection;
// Unlock the constant buffer.
deviceContext->Unmap(m_lightBuffer, 0);
deviceContext->Unmap(light_buffer_, 0);
// Set the position of the light constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the light constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_buffer_);
return true;
}
void RefractionShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void refraction_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render the geometry.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -0,0 +1,479 @@
#include "shader_manager_class.h"
shader_manager_class::shader_manager_class()
{
texture_shader_ = 0;
normal_map_shader_ = 0;
multitexture_shader_ = 0;
translate_shader_ = 0;
alpha_map_shader_ = 0;
spec_map_shader_ = 0;
transparent_shader_ = 0;
light_shader_ = 0;
light_map_shader_ = 0;
refraction_shader_ = 0;
water_shader_ = 0;
cel_shading_shader_ = 0;
}
shader_manager_class::shader_manager_class(const shader_manager_class& other)
{
}
shader_manager_class::~shader_manager_class()
{
}
bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing shader_manager_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
// Create and initialize the texture shader object.
texture_shader_ = new texture_shader_class;
result = texture_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the normal map shader object.
normal_map_shader_ = new normal_map_shader_class;
result = normal_map_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing normal_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the multitexture shader object.
multitexture_shader_ = new multi_texture_shader_class;
result = multitexture_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the translate shader object.
translate_shader_ = new translate_shader_class;
result = translate_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the alpha map shader object.
alpha_map_shader_ = new alpha_map_shader_class;
result = alpha_map_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the specular map shader object.
spec_map_shader_ = new spec_map_shader_class;
result = spec_map_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing spec_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the transparent shader object.
transparent_shader_ = new transparent_shader_class;
result = transparent_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the light shader object.
light_shader_ = new light_shader_class;
result = light_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the light map shader object.
light_map_shader_ = new light_map_shader_class;
result = light_map_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the refraction shader object.
refraction_shader_ = new refraction_shader_class;
result = refraction_shader_->initialize(device, hwnd);
if (!result)
{
return false;
}
// Create and initialize the water shader object.
water_shader_ = new water_shader_class;
result = water_shader_->initialize(device, hwnd);
if (!result)
{
return false;
}
cel_shading_shader_ = new celshade_class;
result = cel_shading_shader_->initialize(device, hwnd);
if (!result)
{
return false;
}
sunlight_shader_ = new sunlight_shader_class;
result = sunlight_shader_->initialize(device, hwnd);
if (!result)
{
return false;
}
skybox_shader_ = new skybox_shader_class;
result = skybox_shader_->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing skybox_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("shader_manager_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void shader_manager_class::shutdown()
{
Logger::Get().Log("Shutting down shader_manager_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the normal map shader object.
if (normal_map_shader_)
{
normal_map_shader_->shutdown();
delete normal_map_shader_;
normal_map_shader_ = 0;
}
// Release the texture shader object.
if (texture_shader_)
{
texture_shader_->shutdown();
delete texture_shader_;
texture_shader_ = 0;
}
// Release the multitexture shader object.
if (multitexture_shader_)
{
multitexture_shader_->shutdown();
delete multitexture_shader_;
multitexture_shader_ = 0;
}
// Release the translate shader object.
if (translate_shader_)
{
translate_shader_->shutdown();
delete translate_shader_;
translate_shader_ = 0;
}
// Release the alpha map shader object.
if (alpha_map_shader_)
{
alpha_map_shader_->shutdown();
delete alpha_map_shader_;
alpha_map_shader_ = 0;
}
// Release the specular map shader object.
if (spec_map_shader_)
{
spec_map_shader_->shutdown();
delete spec_map_shader_;
spec_map_shader_ = 0;
}
// Release the transparent shader object.
if (transparent_shader_)
{
transparent_shader_->shutdown();
delete transparent_shader_;
transparent_shader_ = 0;
}
// Release the light shader object.
if (light_shader_)
{
light_shader_->shutdown();
delete light_shader_;
light_shader_ = 0;
}
// Release the light map shader object.
if (light_map_shader_)
{
light_map_shader_->shutdown();
delete light_map_shader_;
light_map_shader_ = 0;
}
// Release the refraction shader object.
if (refraction_shader_)
{
refraction_shader_->shutdown();
delete refraction_shader_;
refraction_shader_ = 0;
}
// Release the water shader object.
if (water_shader_)
{
water_shader_->shutdown();
delete water_shader_;
water_shader_ = 0;
}
// Release the cel shading shader object.
if (cel_shading_shader_)
{
cel_shading_shader_->shutdown();
delete cel_shading_shader_;
cel_shading_shader_ = 0;
}
if (sunlight_shader_)
{
sunlight_shader_->shutdown();
delete sunlight_shader_;
sunlight_shader_ = 0;
}
if (skybox_shader_)
{
skybox_shader_->Shutdown();
delete skybox_shader_;
skybox_shader_ = 0;
}
Logger::Get().Log("shader_manager_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
bool shader_manager_class::render_texture_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture)
{
bool result;
result = texture_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture);
if (!result)
{
Logger::Get().Log("Error rendering texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_normal_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* colorTexture, ID3D11ShaderResourceView* normalTexture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
bool result;
result = normal_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, colorTexture, normalTexture, lightDirection, diffuseColor);
if (!result)
{
Logger::Get().Log("Error rendering normal_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_multitexture_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = multitexture_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
Logger::Get().Log("Error rendering multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_translate_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, float valeur)
{
bool result;
result = translate_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, valeur);
if (!result)
{
Logger::Get().Log("Error rendering translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_alpha_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3)
{
bool result;
result = alpha_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
if (!result)
{
Logger::Get().Log("Error rendering alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_spec_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3,
XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 cameraPosition, XMFLOAT4 specularColor, float specularPower)
{
bool result;
result = spec_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection,
diffuseColor, cameraPosition, specularColor, specularPower);
if (!result)
{
Logger::Get().Log("Error rendering spec_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_transparent_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, float blendAmount)
{
bool result;
result = transparent_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, blendAmount);
if (!result)
{
Logger::Get().Log("Error rendering transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::renderlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientColor[])
{
bool result;
result = light_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientColor);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::renderlight_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = light_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_refraction_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor[], XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 clipPlane)
{
bool result;
result = refraction_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_water_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
XMMATRIX reflectionMatrix, ID3D11ShaderResourceView* reflectionTexture, ID3D11ShaderResourceView* refractionTexture,
ID3D11ShaderResourceView* normalTexture, float waterTranslation, float reflectRefractScale)
{
bool result;
result = water_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_cel_shading_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = cel_shading_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_sunlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = sunlight_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_skybox_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = skybox_shader_->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}

View File

@@ -1,479 +0,0 @@
#include "shadermanagerclass.h"
ShaderManagerClass::ShaderManagerClass()
{
m_TextureShader = 0;
m_NormalMapShader = 0;
m_MultitextureShader = 0;
m_TranslateShader = 0;
m_AlphaMapShader = 0;
m_SpecMapShader = 0;
m_TransparentShader = 0;
m_LightShader = 0;
m_LightMapShader = 0;
m_RefractionShader = 0;
m_WaterShader = 0;
m_CelShadingShader = 0;
}
ShaderManagerClass::ShaderManagerClass(const ShaderManagerClass& other)
{
}
ShaderManagerClass::~ShaderManagerClass()
{
}
bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing ShaderManagerClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
// Create and initialize the texture shader object.
m_TextureShader = new TextureShaderClass;
result = m_TextureShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing TextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the normal map shader object.
m_NormalMapShader = new NormalMapShaderClass;
result = m_NormalMapShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing NormalMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the multitexture shader object.
m_MultitextureShader = new MultiTextureShaderClass;
result = m_MultitextureShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing MultiTextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the translate shader object.
m_TranslateShader = new TranslateShaderClass;
result = m_TranslateShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing TranslateShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the alpha map shader object.
m_AlphaMapShader = new AlphaMapShaderClass;
result = m_AlphaMapShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing AlphaMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the specular map shader object.
m_SpecMapShader = new SpecMapShaderClass;
result = m_SpecMapShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing SpecMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the transparent shader object.
m_TransparentShader = new TransparentShaderClass;
result = m_TransparentShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing TransparentShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the light shader object.
m_LightShader = new LightShaderClass;
result = m_LightShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the light map shader object.
m_LightMapShader = new LightMapShaderClass;
result = m_LightMapShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing LightMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the refraction shader object.
m_RefractionShader = new RefractionShaderClass;
result = m_RefractionShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
// Create and initialize the water shader object.
m_WaterShader = new WaterShaderClass;
result = m_WaterShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
m_CelShadingShader = new CelshadeClass;
result = m_CelShadingShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
m_SunlightShader = new SunlightShaderClass;
result = m_SunlightShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
m_SkyboxShader = new SkyboxShaderClass;
result = m_SkyboxShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing SkyboxShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("ShaderManagerClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void ShaderManagerClass::Shutdown()
{
Logger::Get().Log("Shutting down ShaderManagerClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the normal map shader object.
if (m_NormalMapShader)
{
m_NormalMapShader->Shutdown();
delete m_NormalMapShader;
m_NormalMapShader = 0;
}
// Release the texture shader object.
if (m_TextureShader)
{
m_TextureShader->Shutdown();
delete m_TextureShader;
m_TextureShader = 0;
}
// Release the multitexture shader object.
if (m_MultitextureShader)
{
m_MultitextureShader->Shutdown();
delete m_MultitextureShader;
m_MultitextureShader = 0;
}
// Release the translate shader object.
if (m_TranslateShader)
{
m_TranslateShader->Shutdown();
delete m_TranslateShader;
m_TranslateShader = 0;
}
// Release the alpha map shader object.
if (m_AlphaMapShader)
{
m_AlphaMapShader->Shutdown();
delete m_AlphaMapShader;
m_AlphaMapShader = 0;
}
// Release the specular map shader object.
if (m_SpecMapShader)
{
m_SpecMapShader->Shutdown();
delete m_SpecMapShader;
m_SpecMapShader = 0;
}
// Release the transparent shader object.
if (m_TransparentShader)
{
m_TransparentShader->Shutdown();
delete m_TransparentShader;
m_TransparentShader = 0;
}
// Release the light shader object.
if (m_LightShader)
{
m_LightShader->Shutdown();
delete m_LightShader;
m_LightShader = 0;
}
// Release the light map shader object.
if (m_LightMapShader)
{
m_LightMapShader->Shutdown();
delete m_LightMapShader;
m_LightMapShader = 0;
}
// Release the refraction shader object.
if (m_RefractionShader)
{
m_RefractionShader->Shutdown();
delete m_RefractionShader;
m_RefractionShader = 0;
}
// Release the water shader object.
if (m_WaterShader)
{
m_WaterShader->Shutdown();
delete m_WaterShader;
m_WaterShader = 0;
}
// Release the cel shading shader object.
if (m_CelShadingShader)
{
m_CelShadingShader->Shutdown();
delete m_CelShadingShader;
m_CelShadingShader = 0;
}
if (m_SunlightShader)
{
m_SunlightShader->Shutdown();
delete m_SunlightShader;
m_SunlightShader = 0;
}
if (m_SkyboxShader)
{
m_SkyboxShader->Shutdown();
delete m_SkyboxShader;
m_SkyboxShader = 0;
}
Logger::Get().Log("ShaderManagerClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
bool ShaderManagerClass::RenderTextureShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture)
{
bool result;
result = m_TextureShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture);
if (!result)
{
Logger::Get().Log("Error rendering TextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderNormalMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* colorTexture, ID3D11ShaderResourceView* normalTexture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
bool result;
result = m_NormalMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, colorTexture, normalTexture, lightDirection, diffuseColor);
if (!result)
{
Logger::Get().Log("Error rendering NormalMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderMultitextureShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = m_MultitextureShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
Logger::Get().Log("Error rendering MultiTextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderTranslateShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, float valeur)
{
bool result;
result = m_TranslateShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, valeur);
if (!result)
{
Logger::Get().Log("Error rendering TranslateShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderAlphaMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3)
{
bool result;
result = m_AlphaMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
if (!result)
{
Logger::Get().Log("Error rendering AlphaMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderSpecMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3,
XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 cameraPosition, XMFLOAT4 specularColor, float specularPower)
{
bool result;
result = m_SpecMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection,
diffuseColor, cameraPosition, specularColor, specularPower);
if (!result)
{
Logger::Get().Log("Error rendering SpecMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderTransparentShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, float blendAmount)
{
bool result;
result = m_TransparentShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, blendAmount);
if (!result)
{
Logger::Get().Log("Error rendering TransparentShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderlightShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientColor[])
{
bool result;
result = m_LightShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientColor);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderlightMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = m_LightMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderRefractionShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor[], XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 clipPlane)
{
bool result;
result = m_RefractionShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderWaterShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
XMMATRIX reflectionMatrix, ID3D11ShaderResourceView* reflectionTexture, ID3D11ShaderResourceView* refractionTexture,
ID3D11ShaderResourceView* normalTexture, float waterTranslation, float reflectRefractScale)
{
bool result;
result = m_WaterShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderCelShadingShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = m_CelShadingShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderSunlightShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = m_SunlightShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderSkyboxShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = m_SkyboxShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}

View File

@@ -1,10 +1,10 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "SkyboxShaderClass.h"
#include "skybox_shader_class.h"
SkyboxShaderClass::SkyboxShaderClass()
skybox_shader_class::skybox_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
@@ -18,17 +18,17 @@ SkyboxShaderClass::SkyboxShaderClass()
}
SkyboxShaderClass::SkyboxShaderClass(const SkyboxShaderClass& other)
skybox_shader_class::skybox_shader_class(const skybox_shader_class& other)
{
}
SkyboxShaderClass::~SkyboxShaderClass()
skybox_shader_class::~skybox_shader_class()
{
}
bool SkyboxShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool skybox_shader_class::Initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -60,13 +60,13 @@ bool SkyboxShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
Logger::Get().Log("SkyboxShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("skybox_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void SkyboxShaderClass::Shutdown()
void skybox_shader_class::Shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
@@ -74,7 +74,7 @@ void SkyboxShaderClass::Shutdown()
return;
}
bool SkyboxShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool skybox_shader_class::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
@@ -95,7 +95,7 @@ bool SkyboxShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCoun
}
bool SkyboxShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -266,7 +266,7 @@ bool SkyboxShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
void SkyboxShaderClass::ShutdownShader()
void skybox_shader_class::ShutdownShader()
{
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -338,7 +338,7 @@ void SkyboxShaderClass::ShutdownShader()
}
void SkyboxShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void skybox_shader_class::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@@ -374,7 +374,7 @@ void SkyboxShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND
}
bool SkyboxShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
bool skybox_shader_class::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
@@ -443,7 +443,7 @@ bool SkyboxShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
return true;
}
void SkyboxShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void skybox_shader_class::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);

View File

@@ -1,29 +1,29 @@
#include "specmapshaderclass.h"
#include "spec_map_shader_class.h"
SpecMapShaderClass::SpecMapShaderClass()
spec_map_shader_class::spec_map_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_lightBuffer = 0;
m_cameraBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
light_buffer_ = 0;
camera_buffer_ = 0;
}
SpecMapShaderClass::SpecMapShaderClass(const SpecMapShaderClass& other)
spec_map_shader_class::spec_map_shader_class(const spec_map_shader_class& other)
{
}
SpecMapShaderClass::~SpecMapShaderClass()
spec_map_shader_class::~spec_map_shader_class()
{
}
bool SpecMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool spec_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
bool result;
wchar_t vsFilename[128];
@@ -44,8 +44,8 @@ bool SpecMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
return false;
@@ -55,15 +55,15 @@ bool SpecMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void SpecMapShaderClass::Shutdown()
void spec_map_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool SpecMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool spec_map_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3,
XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 cameraPosition, XMFLOAT4 specularColor, float specularPower)
{
@@ -71,7 +71,7 @@ bool SpecMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCou
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection, diffuseColor,
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection, diffuseColor,
cameraPosition, specularColor, specularPower);
if (!result)
{
@@ -79,13 +79,13 @@ bool SpecMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCou
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
HRESULT result;
ID3D10Blob* errorMessage;
@@ -99,7 +99,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
D3D11_BUFFER_DESC cameraBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -112,7 +112,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -131,7 +131,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -143,14 +143,14 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
return false;
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
return false;
@@ -202,7 +202,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
return false;
@@ -217,14 +217,14 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
return false;
@@ -246,7 +246,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
return false;
@@ -254,14 +254,14 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
lightBufferDesc.ByteWidth = sizeof(light_buffer_type);
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightBufferDesc.MiscFlags = 0;
lightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&lightBufferDesc, NULL, &m_lightBuffer);
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
if (FAILED(result))
{
return false;
@@ -269,14 +269,14 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Setup the description of the camera dynamic constant buffer that is in the vertex shader.
cameraBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
cameraBufferDesc.ByteWidth = sizeof(CameraBufferType);
cameraBufferDesc.ByteWidth = sizeof(camera_buffer_type);
cameraBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
cameraBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
cameraBufferDesc.MiscFlags = 0;
cameraBufferDesc.StructureByteStride = 0;
// Create the camera constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&cameraBufferDesc, NULL, &m_cameraBuffer);
result = device->CreateBuffer(&cameraBufferDesc, NULL, &camera_buffer_);
if (FAILED(result))
{
return false;
@@ -286,62 +286,62 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
}
void SpecMapShaderClass::ShutdownShader()
void spec_map_shader_class::shutdown_shader()
{
// Release the camera constant buffer.
if (m_cameraBuffer)
if (camera_buffer_)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
camera_buffer_->Release();
camera_buffer_ = 0;
}
// Release the light constant buffer.
if (m_lightBuffer)
if (light_buffer_)
{
m_lightBuffer->Release();
m_lightBuffer = 0;
light_buffer_->Release();
light_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
return;
}
void SpecMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void spec_map_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -376,16 +376,16 @@ void SpecMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND
return;
}
bool SpecMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3,
XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 cameraPosition, XMFLOAT4 specularColor, float specularPower)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
LightBufferType* dataPtr2;
CameraBufferType* dataPtr3;
light_buffer_type* dataPtr2;
camera_buffer_type* dataPtr3;
// Transpose the matrices to prepare them for the shader.
@@ -394,14 +394,14 @@ bool SpecMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -409,13 +409,13 @@ bool SpecMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@@ -423,69 +423,69 @@ bool SpecMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
deviceContext->PSSetShaderResources(2, 1, &texture3);
// Lock the light constant buffer so it can be written to.
result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr2 = (LightBufferType*)mappedResource.pData;
dataPtr2 = (light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr2->diffuseColor = diffuseColor;
dataPtr2->lightDirection = lightDirection;
dataPtr2->specularColor = specularColor;
dataPtr2->specularPower = specularPower;
dataPtr2->diffuse_color = diffuseColor;
dataPtr2->light_direction = lightDirection;
dataPtr2->specular_color = specularColor;
dataPtr2->specular_power = specularPower;
// Unlock the constant buffer.
deviceContext->Unmap(m_lightBuffer, 0);
deviceContext->Unmap(light_buffer_, 0);
// Set the position of the light constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the light constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_buffer_);
// Lock the camera constant buffer so it can be written to.
result = deviceContext->Map(m_cameraBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(camera_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (CameraBufferType*)mappedResource.pData;
dataPtr3 = (camera_buffer_type*)mappedResource.pData;
// Copy the camera position into the constant buffer.
dataPtr3->cameraPosition = cameraPosition;
dataPtr3->camera_position = cameraPosition;
// Unlock the camera constant buffer.
deviceContext->Unmap(m_cameraBuffer, 0);
deviceContext->Unmap(camera_buffer_, 0);
// Set the position of the camera constant buffer in the vertex shader as the second buffer.
bufferNumber = 1;
// Now set the camera constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_cameraBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &camera_buffer_);
return true;
}
void SpecMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void spec_map_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this model.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the model.
// render the model.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,34 +1,34 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "sunlightshaderclass.h"
#include "sunlight_shader_class.h"
SunlightShaderClass::SunlightShaderClass()
sunlight_shader_class::sunlight_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_sampleState = 0;
m_matrixBuffer = 0;
m_cameraBuffer = 0;
m_sunlightBuffer = 0;
m_sunlightColorBuffer = 0;
m_sunlightPositionBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
camera_buffer_ = 0;
sunlight_buffer_ = 0;
sunlight_color_buffer_ = 0;
sunlight_position_buffer_ = 0;
}
SunlightShaderClass::SunlightShaderClass(const SunlightShaderClass& other)
sunlight_shader_class::sunlight_shader_class(const sunlight_shader_class& other)
{
}
SunlightShaderClass::~SunlightShaderClass()
sunlight_shader_class::~sunlight_shader_class()
{
}
bool SunlightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool sunlight_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -52,8 +52,8 @@ bool SunlightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -66,22 +66,22 @@ bool SunlightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void SunlightShaderClass::Shutdown()
void sunlight_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool SunlightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool sunlight_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -89,13 +89,13 @@ bool SunlightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCo
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -109,7 +109,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_BUFFER_DESC sunlightBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -120,7 +120,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
{
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
else
{
@@ -135,7 +135,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
{
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
else
{
@@ -145,7 +145,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -153,7 +153,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -189,7 +189,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]);
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_layout);
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -219,7 +219,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -228,14 +228,14 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -244,14 +244,14 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
sunlightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
sunlightBufferDesc.ByteWidth = sizeof(SunLightBufferType);
sunlightBufferDesc.ByteWidth = sizeof(sun_light_buffer_type);
sunlightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
sunlightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
sunlightBufferDesc.MiscFlags = 0;
sunlightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &m_sunlightBuffer);
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &sunlight_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -266,70 +266,70 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
void SunlightShaderClass::ShutdownShader()
void sunlight_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffers.
if (m_sunlightColorBuffer)
if (sunlight_color_buffer_)
{
m_sunlightColorBuffer->Release();
m_sunlightColorBuffer = 0;
sunlight_color_buffer_->Release();
sunlight_color_buffer_ = 0;
}
if (m_sunlightPositionBuffer)
if (sunlight_position_buffer_)
{
m_sunlightPositionBuffer->Release();
m_sunlightPositionBuffer = 0;
sunlight_position_buffer_->Release();
sunlight_position_buffer_ = 0;
}
// Release the light constant buffer.
if (m_sunlightBuffer)
if (sunlight_buffer_)
{
m_sunlightBuffer->Release();
m_sunlightBuffer = 0;
sunlight_buffer_->Release();
sunlight_buffer_ = 0;
}
// Release the camera constant buffer.
if (m_cameraBuffer)
if (camera_buffer_)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
camera_buffer_->Release();
camera_buffer_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -338,7 +338,7 @@ void SunlightShaderClass::ShutdownShader()
}
void SunlightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void sunlight_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@@ -374,13 +374,13 @@ void SunlightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWN
}
bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
bool sunlight_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
CameraBufferType* dataPtr2;
SunLightBufferType* dataPtr3;
matrix_buffer_type* dataPtr;
camera_buffer_type* dataPtr2;
sun_light_buffer_type* dataPtr3;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
@@ -389,14 +389,14 @@ bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -404,38 +404,38 @@ bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the sunlight constant buffer so it can be written to.
result = deviceContext->Map(m_sunlightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(sunlight_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (SunLightBufferType*)mappedResource.pData;
dataPtr3 = (sun_light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr3->ambientColor = ambientColor;
dataPtr3->diffuseColor = diffuseColor;
dataPtr3->sunDirection = lightDirection;
dataPtr3->ambient_color = ambientColor;
dataPtr3->diffuse_color = diffuseColor;
dataPtr3->sun_direction = lightDirection;
dataPtr3->intensity = sunIntensity;
// Unlock the constant buffer.
deviceContext->Unmap(m_sunlightBuffer, 0);
deviceContext->Unmap(sunlight_buffer_, 0);
// Set the position of the sunlight constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the sunlight constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_sunlightBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &sunlight_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
@@ -443,19 +443,19 @@ bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
return true;
}
void SunlightShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void sunlight_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,27 +1,27 @@
#include "textureshaderclass.h"
#include "texture_shader_class.h"
TextureShaderClass::TextureShaderClass()
texture_shader_class::texture_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
TextureShaderClass::TextureShaderClass(const TextureShaderClass& other)
texture_shader_class::texture_shader_class(const texture_shader_class& other)
{
}
TextureShaderClass::~TextureShaderClass()
texture_shader_class::~texture_shader_class()
{
}
bool TextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing texture shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -45,8 +45,8 @@ bool TextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -58,22 +58,22 @@ bool TextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return true;
}
void TextureShaderClass::Shutdown()
void texture_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool TextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool texture_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -81,12 +81,12 @@ bool TextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCou
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -100,7 +100,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
D3D11_SAMPLER_DESC samplerDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -112,7 +112,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -131,7 +131,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -143,7 +143,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -151,7 +151,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -180,7 +180,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -196,14 +196,14 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -225,7 +225,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -237,43 +237,43 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
return true;
}
void TextureShaderClass::ShutdownShader()
void texture_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -281,7 +281,7 @@ void TextureShaderClass::ShutdownShader()
return;
}
void TextureShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void texture_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -316,12 +316,12 @@ void TextureShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND
return;
}
bool TextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool texture_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
@@ -331,7 +331,7 @@ bool TextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -339,7 +339,7 @@ bool TextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -347,31 +347,31 @@ bool TextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finanly set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
return true;
}
void TextureShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void texture_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,30 +1,30 @@
#include "translateshaderclass.h"
#include "translate_shader_class.h"
TranslateShaderClass::TranslateShaderClass()
translate_shader_class::translate_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_translateBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
translate_buffer_ = 0;
}
TranslateShaderClass::TranslateShaderClass(const TranslateShaderClass& other)
translate_shader_class::translate_shader_class(const translate_shader_class& other)
{
}
TranslateShaderClass::~TranslateShaderClass()
translate_shader_class::~translate_shader_class()
{
}
bool TranslateShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool translate_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initilaizing TranslateShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initilaizing translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@@ -47,36 +47,36 @@ bool TranslateShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("TranslateShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("translate_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void TranslateShaderClass::Shutdown()
void translate_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool TranslateShaderClass::Render(ID3D11DeviceContext * deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool translate_shader_class::render(ID3D11DeviceContext * deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView * texture, float translation)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, translation);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, translation);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -84,13 +84,13 @@ bool TranslateShaderClass::Render(ID3D11DeviceContext * deviceContext, int index
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WCHAR * vsFilename, WCHAR * psFilename)
bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd, WCHAR * vsFilename, WCHAR * psFilename)
{
Logger::Get().Log("Initializing translate shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -105,7 +105,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
D3D11_BUFFER_DESC translateBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -118,7 +118,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -137,7 +137,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -149,7 +149,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -157,7 +157,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -186,7 +186,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -202,14 +202,14 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -232,7 +232,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -241,14 +241,14 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// Setup the description of the texture translation dynamic constant buffer that is in the pixel shader.
translateBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
translateBufferDesc.ByteWidth = sizeof(TranslateBufferType);
translateBufferDesc.ByteWidth = sizeof(translate_buffer_type);
translateBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
translateBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
translateBufferDesc.MiscFlags = 0;
translateBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&translateBufferDesc, NULL, &m_translateBuffer);
result = device->CreateBuffer(&translateBufferDesc, NULL, &translate_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create translate buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -261,50 +261,50 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
}
void TranslateShaderClass::ShutdownShader()
void translate_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down translate shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the texture translation constant buffer.
if (m_translateBuffer)
if (translate_buffer_)
{
m_translateBuffer->Release();
m_translateBuffer = 0;
translate_buffer_->Release();
translate_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Translate shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -313,7 +313,7 @@ void TranslateShaderClass::ShutdownShader()
}
void TranslateShaderClass::OutputShaderErrorMessage(ID3D10Blob * errorMessage, HWND hwnd, WCHAR * shaderFilename)
void translate_shader_class::output_shader_error_message(ID3D10Blob * errorMessage, HWND hwnd, WCHAR * shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -349,14 +349,14 @@ void TranslateShaderClass::OutputShaderErrorMessage(ID3D10Blob * errorMessage, H
}
bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool translate_shader_class::set_shader_parameters(ID3D11DeviceContext * deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView * texture, float translation)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
TranslateBufferType* dataPtr2;
translate_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@@ -365,7 +365,7 @@ bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceConte
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -373,7 +373,7 @@ bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceConte
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -381,19 +381,19 @@ bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceConte
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the texture translation constant buffer so it can be written to.
result = deviceContext->Map(m_translateBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(translate_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map translate buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -401,37 +401,37 @@ bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceConte
}
// Get a pointer to the data in the texture translation constant buffer.
dataPtr2 = (TranslateBufferType*)mappedResource.pData;
dataPtr2 = (translate_buffer_type*)mappedResource.pData;
// Copy the translation value into the texture translation constant buffer.
dataPtr2->translation = translation;
// Unlock the buffer.
deviceContext->Unmap(m_translateBuffer, 0);
deviceContext->Unmap(translate_buffer_, 0);
// Set the position of the texture translation constant buffer in the pixel shader.
bufferNumber = 0;
// Now set the texture translation constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_translateBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &translate_buffer_);
return true;
}
void TranslateShaderClass::RenderShader(ID3D11DeviceContext * deviceContext, int indexCount)
void translate_shader_class::render_shader(ID3D11DeviceContext * deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,30 +1,30 @@
#include "transparentshaderclass.h"
#include "transparent_shader_class.h"
TransparentShaderClass::TransparentShaderClass()
transparent_shader_class::transparent_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_transparentBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
transparent_buffer_ = 0;
}
TransparentShaderClass::TransparentShaderClass(const TransparentShaderClass& other)
transparent_shader_class::transparent_shader_class(const transparent_shader_class& other)
{
}
TransparentShaderClass::~TransparentShaderClass()
transparent_shader_class::~transparent_shader_class()
{
}
bool TransparentShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool transparent_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing TransparentShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@@ -47,36 +47,36 @@ bool TransparentShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("TransparentShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("transparent_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void TransparentShaderClass::Shutdown()
void transparent_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool TransparentShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool transparent_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, float blend)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, blend);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, blend);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -84,13 +84,13 @@ bool TransparentShaderClass::Render(ID3D11DeviceContext* deviceContext, int inde
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing transparent shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -105,7 +105,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
D3D11_BUFFER_DESC transparentBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -118,7 +118,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -137,7 +137,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -149,7 +149,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -157,7 +157,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -186,7 +186,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -202,14 +202,14 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -232,7 +232,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -241,14 +241,14 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// Setup the description of the transparent dynamic constant buffer that is in the pixel shader.
transparentBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
transparentBufferDesc.ByteWidth = sizeof(TransparentBufferType);
transparentBufferDesc.ByteWidth = sizeof(transparent_buffer_type);
transparentBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
transparentBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
transparentBufferDesc.MiscFlags = 0;
transparentBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&transparentBufferDesc, NULL, &m_transparentBuffer);
result = device->CreateBuffer(&transparentBufferDesc, NULL, &transparent_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create transparent buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -261,50 +261,50 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
}
void TransparentShaderClass::ShutdownShader()
void transparent_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down transparent shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the transparent constant buffer.
if (m_transparentBuffer)
if (transparent_buffer_)
{
m_transparentBuffer->Release();
m_transparentBuffer = 0;
transparent_buffer_->Release();
transparent_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Transparent shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -313,7 +313,7 @@ void TransparentShaderClass::ShutdownShader()
}
void TransparentShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void transparent_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -348,14 +348,14 @@ void TransparentShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage,
return;
}
bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool transparent_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, float blend)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
TransparentBufferType* dataPtr2;
transparent_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@@ -364,7 +364,7 @@ bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCont
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -372,7 +372,7 @@ bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCont
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -380,19 +380,19 @@ bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCont
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the transparent constant buffer so it can be written to.
result = deviceContext->Map(m_transparentBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(transparent_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map transparent buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -400,37 +400,37 @@ bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCont
}
// Get a pointer to the data in the transparent constant buffer.
dataPtr2 = (TransparentBufferType*)mappedResource.pData;
dataPtr2 = (transparent_buffer_type*)mappedResource.pData;
// Copy the alpha blending value into the transparent constant buffer.
dataPtr2->blendAmount = blend;
dataPtr2->blend_amount = blend;
// Unlock the buffer.
deviceContext->Unmap(m_transparentBuffer, 0);
deviceContext->Unmap(transparent_buffer_, 0);
// Set the position of the transparent constant buffer in the pixel shader.
bufferNumber = 0;
// Now set the transparent constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_transparentBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &transparent_buffer_);
return true;
}
void TransparentShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void transparent_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render the geometry.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,29 +1,29 @@
#include "watershaderclass.h"
#include "water_shader_class.h"
WaterShaderClass::WaterShaderClass()
water_shader_class::water_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_sampleState = 0;
m_matrixBuffer = 0;
m_reflectionBuffer = 0;
m_waterBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
reflection_buffer_ = 0;
water_buffer_ = 0;
}
WaterShaderClass::WaterShaderClass(const WaterShaderClass& other)
water_shader_class::water_shader_class(const water_shader_class& other)
{
}
WaterShaderClass::~WaterShaderClass()
water_shader_class::~water_shader_class()
{
}
bool WaterShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool water_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
bool result;
wchar_t vsFilename[128];
@@ -44,8 +44,8 @@ bool WaterShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
return false;
@@ -55,15 +55,15 @@ bool WaterShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void WaterShaderClass::Shutdown()
void water_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool WaterShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool water_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
XMMATRIX reflectionMatrix, ID3D11ShaderResourceView* reflectionTexture, ID3D11ShaderResourceView* refractionTexture,
ID3D11ShaderResourceView* normalTexture, float waterTranslation, float reflectRefractScale)
{
@@ -71,7 +71,7 @@ bool WaterShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
if (!result)
{
@@ -79,13 +79,13 @@ bool WaterShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
HRESULT result;
ID3D10Blob* errorMessage;
@@ -99,7 +99,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
D3D11_BUFFER_DESC waterBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@@ -112,7 +112,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@@ -131,7 +131,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@@ -143,14 +143,14 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
return false;
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
return false;
@@ -178,7 +178,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
return false;
@@ -193,14 +193,14 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
return false;
@@ -222,7 +222,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
return false;
@@ -230,14 +230,14 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the reflection dynamic constant buffer that is in the vertex shader.
reflectionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
reflectionBufferDesc.ByteWidth = sizeof(ReflectionBufferType);
reflectionBufferDesc.ByteWidth = sizeof(reflection_buffer_type);
reflectionBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
reflectionBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
reflectionBufferDesc.MiscFlags = 0;
reflectionBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &m_reflectionBuffer);
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &reflection_buffer_);
if (FAILED(result))
{
return false;
@@ -245,14 +245,14 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the water dynamic constant buffer that is in the pixel shader.
waterBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
waterBufferDesc.ByteWidth = sizeof(WaterBufferType);
waterBufferDesc.ByteWidth = sizeof(water_buffer_type);
waterBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
waterBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
waterBufferDesc.MiscFlags = 0;
waterBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&waterBufferDesc, NULL, &m_waterBuffer);
result = device->CreateBuffer(&waterBufferDesc, NULL, &water_buffer_);
if (FAILED(result))
{
return false;
@@ -262,62 +262,62 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
void WaterShaderClass::ShutdownShader()
void water_shader_class::shutdown_shader()
{
// Release the water constant buffer.
if (m_waterBuffer)
if (water_buffer_)
{
m_waterBuffer->Release();
m_waterBuffer = 0;
water_buffer_->Release();
water_buffer_ = 0;
}
// Release the reflection constant buffer.
if (m_reflectionBuffer)
if (reflection_buffer_)
{
m_reflectionBuffer->Release();
m_reflectionBuffer = 0;
reflection_buffer_->Release();
reflection_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
return;
}
void WaterShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void water_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@@ -352,16 +352,16 @@ void WaterShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
return;
}
bool WaterShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, XMMATRIX reflectionMatrix,
bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, XMMATRIX reflectionMatrix,
ID3D11ShaderResourceView* reflectionTexture, ID3D11ShaderResourceView* refractionTexture, ID3D11ShaderResourceView* normalTexture,
float waterTranslation, float reflectRefractScale)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
ReflectionBufferType* dataPtr2;
WaterBufferType* dataPtr3;
reflection_buffer_type* dataPtr2;
water_buffer_type* dataPtr3;
// Transpose the matrices to prepare them for the shader.
worldMatrix = XMMatrixTranspose(worldMatrix);
@@ -370,14 +370,14 @@ bool WaterShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
reflectionMatrix = XMMatrixTranspose(reflectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@@ -385,35 +385,35 @@ bool WaterShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finanly set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the reflection constant buffer so it can be written to.
result = deviceContext->Map(m_reflectionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(reflection_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr2 = (ReflectionBufferType*)mappedResource.pData;
dataPtr2 = (reflection_buffer_type*)mappedResource.pData;
// Copy the reflection matrix into the constant buffer.
dataPtr2->reflection = reflectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_reflectionBuffer, 0);
deviceContext->Unmap(reflection_buffer_, 0);
// Set the position of the reflection constant buffer in the vertex shader.
bufferNumber = 1;
// Finally set the reflection constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_reflectionBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &reflection_buffer_);
// Set the reflection texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &reflectionTexture);
@@ -425,45 +425,45 @@ bool WaterShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
deviceContext->PSSetShaderResources(2, 1, &normalTexture);
// Lock the water constant buffer so it can be written to.
result = deviceContext->Map(m_waterBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(water_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (WaterBufferType*)mappedResource.pData;
dataPtr3 = (water_buffer_type*)mappedResource.pData;
// Copy the water data into the constant buffer.
dataPtr3->waterTranslation = waterTranslation;
dataPtr3->reflectRefractScale = reflectRefractScale;
dataPtr3->water_translation = waterTranslation;
dataPtr3->reflect_refract_scale = reflectRefractScale;
dataPtr3->padding = XMFLOAT2(0.0f, 0.0f);
// Unlock the constant buffer.
deviceContext->Unmap(m_waterBuffer, 0);
deviceContext->Unmap(water_buffer_, 0);
// Set the position of the water constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the water constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_waterBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &water_buffer_);
return true;
}
void WaterShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void water_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@@ -1,9 +1,9 @@
#include "systemclass.h"
#include "system_class.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
{
SystemClass* System;
system_class* System;
bool result;
wchar_t path[MAX_PATH];
@@ -17,19 +17,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
std::filesystem::path WFolder = exePath.parent_path();
// Create the system object.
System = new SystemClass;
System = new system_class;
// Initialize and run the system object.
result = System->Initialize();
// initialize and run the system object.
result = System->initialize();
if (result)
{
Logger::Get().Log("System initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
System->SendPath(path,WFolder);
System->Run();
System->send_path(path,WFolder);
System->run();
}
// Shutdown and release the system object.
System->Shutdown();
// shutdown and release the system object.
System->shutdown();
delete System;
System = 0;

View File

@@ -18,12 +18,12 @@ Skybox::~Skybox()
translations.clear();
}
void Skybox::Initialize(D3DClass* d3dClassRef)
void Skybox::Initialize(d_3d_class* d3dClassRef)
{
m_d3dClassRef = d3dClassRef;
}
Object* Skybox::ConstructSkybox()
object* Skybox::ConstructSkybox()
{
Logger::Get().Log("Construct skybox", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -40,7 +40,7 @@ Object* Skybox::ConstructSkybox()
for (const auto& textureFilename : skyboxTextures)
{
ID3D11ShaderResourceView* texture = nullptr;
HRESULT result = DirectX::CreateWICTextureFromFile(m_d3dClassRef->GetDevice(), m_d3dClassRef->GetDeviceContext(), textureFilename.c_str(), nullptr, &texture);
HRESULT result = DirectX::CreateWICTextureFromFile(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), textureFilename.c_str(), nullptr, &texture);
if (FAILED(result))
{
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -51,8 +51,8 @@ Object* Skybox::ConstructSkybox()
}
// Create the model object
m_Skybox = new Object();
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->GetDevice(), m_d3dClassRef->GetDeviceContext(), modelFilename, SkyboxTextures);
m_Skybox = new object();
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), modelFilename, SkyboxTextures);
if (!result)
{
Logger::Get().Log("Could not initialize the skybox model object", __FILE__, __LINE__, Logger::LogLevel::Error);

View File

@@ -1,39 +1,39 @@
#include "bitmapclass.h"
#include "bitmap_class.h"
BitmapClass::BitmapClass()
bitmap_class::bitmap_class()
{
m_vertexBuffer = 0;
m_indexBuffer = 0;
m_Texture = 0;
vertex_buffer_ = 0;
index_buffer_ = 0;
texture_ = 0;
}
BitmapClass::BitmapClass(const BitmapClass& other)
bitmap_class::bitmap_class(const bitmap_class& other)
{
}
BitmapClass::~BitmapClass()
bitmap_class::~bitmap_class()
{
}
bool BitmapClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, int screenWidth, int screenHeight, char* textureFilename, int renderX, int renderY)
bool bitmap_class::initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, int screenWidth, int screenHeight, char* textureFilename, int renderX, int renderY)
{
Logger::Get().Log("Initializing bitmap class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
// Store the screen size.
m_screenWidth = screenWidth;
m_screenHeight = screenHeight;
screen_width_ = screenWidth;
screen_height_ = screenHeight;
// Store where the bitmap should be rendered to.
m_renderX = renderX;
m_renderY = renderY;
render_x_ = renderX;
render_y_ = renderY;
// Initialize the vertex and index buffer that hold the geometry for the bitmap quad.
result = InitializeBuffers(device);
// initialize the vertex and index buffer that hold the geometry for the bitmap quad.
result = initialize_buffers(device);
if (!result)
{
Logger::Get().Log("Failed to initialize buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -41,7 +41,7 @@ bool BitmapClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
}
// Load the texture for this bitmap.
result = LoadTexture(device, deviceContext, textureFilename);
result = load_texture(device, deviceContext, textureFilename);
if (!result)
{
Logger::Get().Log("Failed to load texture", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -53,24 +53,24 @@ bool BitmapClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
return true;
}
void BitmapClass::Shutdown()
void bitmap_class::shutdown()
{
// Release the bitmap texture.
ReleaseTexture();
release_texture();
// Release the vertex and index buffers.
ShutdownBuffers();
shutdown_buffers();
return;
}
bool BitmapClass::Render(ID3D11DeviceContext* deviceContext)
bool bitmap_class::render(ID3D11DeviceContext* deviceContext)
{
bool result;
// Update the buffers if the position of the bitmap has changed from its original position.
result = UpdateBuffers(deviceContext);
result = update_buffers(deviceContext);
if (!result)
{
Logger::Get().Log("Failed to update buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -78,60 +78,60 @@ bool BitmapClass::Render(ID3D11DeviceContext* deviceContext)
}
// Put the vertex and index buffers on the graphics pipeline to prepare them for drawing.
RenderBuffers(deviceContext);
render_buffers(deviceContext);
return true;
}
int BitmapClass::GetIndexCount()
int bitmap_class::get_index_count()
{
return m_indexCount;
return index_count_;
}
ID3D11ShaderResourceView* BitmapClass::GetTexture()
ID3D11ShaderResourceView* bitmap_class::get_texture()
{
return m_Texture->GetTexture();
return texture_->GetTexture();
}
bool BitmapClass::InitializeBuffers(ID3D11Device* device)
bool bitmap_class::initialize_buffers(ID3D11Device* device)
{
Logger::Get().Log("Initializing buffers", __FILE__, __LINE__, Logger::LogLevel::Initialize);
VertexType* vertices;
vertex_type* vertices;
unsigned long* indices;
D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
D3D11_SUBRESOURCE_DATA vertexData, indexData;
HRESULT result;
int i;
// Initialize the previous rendering position to negative one.
m_prevPosX = -1;
m_prevPosY = -1;
// initialize the previous rendering position to negative one.
prev_pos_x_ = -1;
prev_pos_y_ = -1;
// Set the number of vertices in the vertex array.
m_vertexCount = 6;
vertex_count_ = 6;
// Set the number of indices in the index array.
m_indexCount = m_vertexCount;
index_count_ = vertex_count_;
// Create the vertex array.
vertices = new VertexType[m_vertexCount];
vertices = new vertex_type[vertex_count_];
// Create the index array.
indices = new unsigned long[m_indexCount];
indices = new unsigned long[index_count_];
// Initialize vertex array to zeros at first.
memset(vertices, 0, (sizeof(VertexType) * m_vertexCount));
// initialize vertex array to zeros at first.
memset(vertices, 0, (sizeof(vertex_type) * vertex_count_));
// Load the index array with data.
for (i = 0; i < m_indexCount; i++)
for (i = 0; i < index_count_; i++)
{
indices[i] = i;
}
// Set up the description of the dynamic vertex buffer.
vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
vertexBufferDesc.ByteWidth = sizeof(VertexType) * m_vertexCount;
vertexBufferDesc.ByteWidth = sizeof(vertex_type) * vertex_count_;
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
vertexBufferDesc.MiscFlags = 0;
@@ -143,7 +143,7 @@ bool BitmapClass::InitializeBuffers(ID3D11Device* device)
vertexData.SysMemSlicePitch = 0;
// Now finally create the vertex buffer.
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &vertex_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -152,7 +152,7 @@ bool BitmapClass::InitializeBuffers(ID3D11Device* device)
// Set up the description of the index buffer.
indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(unsigned long) * m_indexCount;
indexBufferDesc.ByteWidth = sizeof(unsigned long) * index_count_;
indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;
@@ -164,7 +164,7 @@ bool BitmapClass::InitializeBuffers(ID3D11Device* device)
indexData.SysMemSlicePitch = 0;
// Create the index buffer.
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
result = device->CreateBuffer(&indexBufferDesc, &indexData, &index_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create index buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -183,25 +183,25 @@ bool BitmapClass::InitializeBuffers(ID3D11Device* device)
return true;
}
void BitmapClass::ShutdownBuffers()
void bitmap_class::shutdown_buffers()
{
Logger::Get().Log("Shutting down buffers", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the index buffer.
if (m_indexBuffer)
if (index_buffer_)
{
Logger::Get().Log("Releasing index buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_indexBuffer->Release();
m_indexBuffer = 0;
index_buffer_->Release();
index_buffer_ = 0;
Logger::Get().Log("Index buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the vertex buffer.
if (m_vertexBuffer)
if (vertex_buffer_)
{
Logger::Get().Log("Releasing vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_vertexBuffer->Release();
m_vertexBuffer = 0;
vertex_buffer_->Release();
vertex_buffer_ = 0;
Logger::Get().Log("Vertex buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
@@ -210,38 +210,38 @@ void BitmapClass::ShutdownBuffers()
return;
}
bool BitmapClass::UpdateBuffers(ID3D11DeviceContext* deviceContent)
bool bitmap_class::update_buffers(ID3D11DeviceContext* deviceContent)
{
float left, right, top, bottom;
VertexType* vertices;
vertex_type* vertices;
D3D11_MAPPED_SUBRESOURCE mappedResource;
VertexType* dataPtr;
vertex_type* dataPtr;
HRESULT result;
// If the position we are rendering this bitmap to hasn't changed then don't update the vertex buffer.
if ((m_prevPosX == m_renderX) && (m_prevPosY == m_renderY))
if ((prev_pos_x_ == render_x_) && (prev_pos_y_ == render_y_))
{
return true;
}
// If the rendering location has changed then store the new position and update the vertex buffer.
m_prevPosX = m_renderX;
m_prevPosY = m_renderY;
prev_pos_x_ = render_x_;
prev_pos_y_ = render_y_;
// Create the vertex array.
vertices = new VertexType[m_vertexCount];
vertices = new vertex_type[vertex_count_];
// Calculate the screen coordinates of the left side of the bitmap.
left = (float)((m_screenWidth / 2) * -1) + (float)m_renderX;
left = (float)((screen_width_ / 2) * -1) + (float)render_x_;
// Calculate the screen coordinates of the right side of the bitmap.
right = left + (float)m_bitmapWidth;
right = left + (float)bitmap_width_;
// Calculate the screen coordinates of the top of the bitmap.
top = (float)(m_screenHeight / 2) - (float)m_renderY;
top = (float)(screen_height_ / 2) - (float)render_y_;
// Calculate the screen coordinates of the bottom of the bitmap.
bottom = top - (float)m_bitmapHeight;
bottom = top - (float)bitmap_height_;
// Load the vertex array with data.
// First triangle.
@@ -265,7 +265,7 @@ bool BitmapClass::UpdateBuffers(ID3D11DeviceContext* deviceContent)
vertices[5].texture = XMFLOAT2(1.0f, 1.0f);
// Lock the vertex buffer.
result = deviceContent->Map(m_vertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContent->Map(vertex_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -273,13 +273,13 @@ bool BitmapClass::UpdateBuffers(ID3D11DeviceContext* deviceContent)
}
// Get a pointer to the data in the constant buffer.
dataPtr = (VertexType*)mappedResource.pData;
dataPtr = (vertex_type*)mappedResource.pData;
// Copy the data into the vertex buffer.
memcpy(dataPtr, (void*)vertices, (sizeof(VertexType) * m_vertexCount));
memcpy(dataPtr, (void*)vertices, (sizeof(vertex_type) * vertex_count_));
// Unlock the vertex buffer.
deviceContent->Unmap(m_vertexBuffer, 0);
deviceContent->Unmap(vertex_buffer_, 0);
// Release the pointer reference.
dataPtr = 0;
@@ -291,21 +291,21 @@ bool BitmapClass::UpdateBuffers(ID3D11DeviceContext* deviceContent)
return true;
}
void BitmapClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
void bitmap_class::render_buffers(ID3D11DeviceContext* deviceContext)
{
unsigned int stride;
unsigned int offset;
// Set vertex buffer stride and offset.
stride = sizeof(VertexType);
stride = sizeof(vertex_type);
offset = 0;
// Set the vertex buffer to active in the input assembler so it can be rendered.
deviceContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);
deviceContext->IASetVertexBuffers(0, 1, &vertex_buffer_, &stride, &offset);
// Set the index buffer to active in the input assembler so it can be rendered.
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
deviceContext->IASetIndexBuffer(index_buffer_, DXGI_FORMAT_R32_UINT, 0);
// Set the type of primitive that should be rendered from this vertex buffer, in this case triangles.
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
@@ -313,15 +313,15 @@ void BitmapClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
return;
}
bool BitmapClass::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* filename)
bool bitmap_class::load_texture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* filename)
{
bool result;
// Create and initialize the texture object.
m_Texture = new TextureClass;
texture_ = new texture_class;
result = m_Texture->Initialize(device, deviceContext, filename);
result = texture_->Initialize(device, deviceContext, filename);
if (!result)
{
Logger::Get().Log("Failed to initialize texture object", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -329,22 +329,22 @@ bool BitmapClass::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceC
}
// Store the size in pixels that this bitmap should be rendered at.
m_bitmapWidth = m_Texture->GetWidth();
m_bitmapHeight = m_Texture->GetHeight();
bitmap_width_ = texture_->GetWidth();
bitmap_height_ = texture_->GetHeight();
return true;
}
void BitmapClass::ReleaseTexture()
void bitmap_class::release_texture()
{
Logger::Get().Log("Releasing texture", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the texture object.
if (m_Texture)
if (texture_)
{
Logger::Get().Log("Releasing texture object", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_Texture->Shutdown();
delete m_Texture;
m_Texture = 0;
texture_->Shutdown();
delete texture_;
texture_ = 0;
Logger::Get().Log("Texture object released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
@@ -353,9 +353,9 @@ void BitmapClass::ReleaseTexture()
return;
}
void BitmapClass::SetRenderLocation(int x, int y)
void bitmap_class::set_render_location(int x, int y)
{
m_renderX = x;
m_renderY = y;
render_x_ = x;
render_y_ = y;
return;
}

View File

@@ -1,58 +1,58 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: cameraclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "cameraclass.h"
#include "camera_class.h"
CameraClass::CameraClass()
camera_class::camera_class()
{
m_positionX = 0.0f;
m_positionY = 0.0f;
m_positionZ = 0.0f;
position_x_ = 0.0f;
position_y_ = 0.0f;
position_z_ = 0.0f;
m_rotationX = 0.0f;
m_rotationY = 0.0f;
m_rotationZ = 0.0f;
rotation_x_ = 0.0f;
rotation_y_ = 0.0f;
rotation_z_ = 0.0f;
}
CameraClass::CameraClass(const CameraClass& other)
camera_class::camera_class(const camera_class& other)
{
}
CameraClass::~CameraClass()
camera_class::~camera_class()
{
}
void CameraClass::SetPosition(float x, float y, float z)
void camera_class::set_position(float x, float y, float z)
{
m_positionX = x;
m_positionY = y;
m_positionZ = z;
position_x_ = x;
position_y_ = y;
position_z_ = z;
return;
}
void CameraClass::SetRotation(float x, float y, float z)
void camera_class::set_rotation(float x, float y, float z)
{
m_rotationX = x;
m_rotationY = y;
m_rotationZ = z;
rotation_x_ = x;
rotation_y_ = y;
rotation_z_ = z;
return;
}
XMFLOAT3 CameraClass::GetPosition()
XMFLOAT3 camera_class::get_position()
{
return XMFLOAT3(m_positionX, m_positionY, m_positionZ);
return XMFLOAT3(position_x_, position_y_, position_z_);
}
XMFLOAT3 CameraClass::GetRotation()
XMFLOAT3 camera_class::get_rotation()
{
return XMFLOAT3(m_rotationX, m_rotationY, m_rotationZ);
return XMFLOAT3(rotation_x_, rotation_y_, rotation_z_);
}
void CameraClass::Render()
void camera_class::render()
{
XMFLOAT3 up, position, lookAt;
XMVECTOR upVector, positionVector, lookAtVector;
@@ -69,9 +69,9 @@ void CameraClass::Render()
upVector = XMLoadFloat3(&up);
// Setup the position of the camera in the world.
position.x = m_positionX;
position.y = m_positionY;
position.z = m_positionZ;
position.x = position_x_;
position.y = position_y_;
position.z = position_z_;
// Load it into a XMVECTOR structure.
positionVector = XMLoadFloat3(&position);
@@ -85,9 +85,9 @@ void CameraClass::Render()
lookAtVector = XMLoadFloat3(&lookAt);
// Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians.
pitch = m_rotationX * 0.0174532925f;
yaw = m_rotationY * 0.0174532925f;
roll = m_rotationZ * 0.0174532925f;
pitch = rotation_x_ * 0.0174532925f;
yaw = rotation_y_ * 0.0174532925f;
roll = rotation_z_ * 0.0174532925f;
// Create the rotation matrix from the yaw, pitch, and roll values.
rotationMatrix = XMMatrixRotationRollPitchYaw(pitch, yaw, roll);
@@ -100,18 +100,18 @@ void CameraClass::Render()
lookAtVector = XMVectorAdd(positionVector, lookAtVector);
// Finally create the view matrix from the three updated vectors.
m_viewMatrix = XMMatrixLookAtLH(positionVector, lookAtVector, upVector);
view_matrix_ = XMMatrixLookAtLH(positionVector, lookAtVector, upVector);
return;
}
XMMATRIX CameraClass::GetViewMatrix(XMMATRIX& viewMatrix) const
XMMATRIX camera_class::get_view_matrix(XMMATRIX& view_matrix) const
{
viewMatrix = m_viewMatrix;
return viewMatrix;
view_matrix = view_matrix_;
return view_matrix;
}
void CameraClass::RenderReflection(float height)
void camera_class::render_reflection(float height)
{
XMFLOAT3 up, position, lookAt;
XMVECTOR upVector, positionVector, lookAtVector;
@@ -128,9 +128,9 @@ void CameraClass::RenderReflection(float height)
upVector = XMLoadFloat3(&up);
// Setup the position of the camera in the world.
position.x = m_positionX;
position.y = -m_positionY + (height * 2.0f);
position.z = m_positionZ;
position.x = position_x_;
position.y = -position_y_ + (height * 2.0f);
position.z = position_z_;
// Load it into a XMVECTOR structure.
positionVector = XMLoadFloat3(&position);
@@ -144,9 +144,9 @@ void CameraClass::RenderReflection(float height)
lookAtVector = XMLoadFloat3(&lookAt);
// Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians.
pitch = (-1.0f * m_rotationX) * 0.0174532925f; // Invert for reflection
yaw = m_rotationY * 0.0174532925f;
roll = m_rotationZ * 0.0174532925f;
pitch = (-1.0f * rotation_x_) * 0.0174532925f; // Invert for reflection
yaw = rotation_y_ * 0.0174532925f;
roll = rotation_z_ * 0.0174532925f;
// Create the rotation matrix from the yaw, pitch, and roll values.
rotationMatrix = XMMatrixRotationRollPitchYaw(pitch, yaw, roll);
@@ -159,13 +159,13 @@ void CameraClass::RenderReflection(float height)
lookAtVector = XMVectorAdd(positionVector, lookAtVector);
// Finally create the view matrix from the three updated vectors.
m_reflectionViewMatrix = XMMatrixLookAtLH(positionVector, lookAtVector, upVector);
reflection_view_matrix_ = XMMatrixLookAtLH(positionVector, lookAtVector, upVector);
return;
}
void CameraClass::GetReflectionViewMatrix(XMMATRIX& reflectionViewMatrix) const
void camera_class::get_reflection_view_matrix(XMMATRIX& reflectionViewMatrix) const
{
reflectionViewMatrix = m_reflectionViewMatrix;
reflectionViewMatrix = reflection_view_matrix_;
return;
}

View File

@@ -1,36 +1,36 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: d3dclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "d3dclass.h"
#include "d_3d_class.h"
D3DClass::D3DClass()
d_3d_class::d_3d_class()
{
m_swapChain = 0;
m_device = 0;
m_deviceContext = 0;
m_renderTargetView = 0;
m_depthStencilBuffer = 0;
m_depthStencilState = 0;
m_depthStencilView = 0;
m_rasterState = 0;
m_depthDisabledStencilState = 0;
m_alphaEnableBlendingState = 0;
m_alphaDisableBlendingState = 0;
swap_chain = 0;
device_ = 0;
device_context_ = 0;
render_target_view_ = 0;
depth_stencil_buffer_ = 0;
depth_stencil_state_ = 0;
depth_stencil_view_ = 0;
raster_state_ = 0;
depth_disabled_stencil_state_ = 0;
alpha_enable_blending_state_ = 0;
alpha_disable_blending_state_ = 0;
}
D3DClass::D3DClass(const D3DClass& other)
d_3d_class::d_3d_class(const d_3d_class& other)
{
}
D3DClass::~D3DClass()
d_3d_class::~d_3d_class()
{
}
bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hwnd, bool fullscreen, float screenDepth, float screenNear)
bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND hwnd, bool fullscreen, float screenDepth, float screenNear)
{
Logger::Get().Log("Initializing D3Dclass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -55,7 +55,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
D3D11_BLEND_DESC blendStateDescription;
// Store the vsync setting.
m_vsync_enabled = vsync;
vsync_enabled_ = vsync;
// Create a DirectX graphics interface factory.
result = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory);
@@ -128,10 +128,10 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
}
// Store the dedicated video card memory in megabytes.
m_videoCardMemory = (int)(adapterDesc.DedicatedVideoMemory / 1024 / 1024);
video_card_memory_ = (int)(adapterDesc.DedicatedVideoMemory / 1024 / 1024);
// Convert the name of the video card to a character array and store it.
error = wcstombs_s(&stringLength, m_videoCardDescription, 128, adapterDesc.Description, 128);
error = wcstombs_s(&stringLength, video_card_description_, 128, adapterDesc.Description, 128);
if (error != 0)
{
Logger::Get().Log("Failed to convert video card name to character array", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -154,7 +154,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
factory->Release();
factory = 0;
// Initialize the swap chain description.
// initialize the swap chain description.
ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));
// Set to a single back buffer.
@@ -168,7 +168,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
// Set the refresh rate of the back buffer.
if (m_vsync_enabled)
if (vsync_enabled_)
{
swapChainDesc.BufferDesc.RefreshRate.Numerator = numerator;
swapChainDesc.BufferDesc.RefreshRate.Denominator = denominator;
@@ -214,7 +214,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
// Create the swap chain, Direct3D device, and Direct3D device context.
result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &featureLevel, 1,
D3D11_SDK_VERSION, &swapChainDesc, &m_swapChain, &m_device, NULL, &m_deviceContext);
D3D11_SDK_VERSION, &swapChainDesc, &swap_chain, &device_, NULL, &device_context_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create swap chain, device and device context", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -222,7 +222,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
}
// Get the pointer to the back buffer.
result = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferPtr);
result = swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferPtr);
if (FAILED(result))
{
Logger::Get().Log("Failed to get pointer to back buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -230,7 +230,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
}
// Create the render target view with the back buffer pointer.
result = m_device->CreateRenderTargetView(backBufferPtr, NULL, &m_renderTargetView);
result = device_->CreateRenderTargetView(backBufferPtr, NULL, &render_target_view_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create render target view", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -241,7 +241,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
backBufferPtr->Release();
backBufferPtr = 0;
// Initialize the description of the depth buffer.
// initialize the description of the depth buffer.
ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc));
// Set up the description of the depth buffer.
@@ -258,14 +258,14 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
depthBufferDesc.MiscFlags = 0;
// Create the texture for the depth buffer using the filled out description.
result = m_device->CreateTexture2D(&depthBufferDesc, NULL, &m_depthStencilBuffer);
result = device_->CreateTexture2D(&depthBufferDesc, NULL, &depth_stencil_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create texture for depth buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Initialize the description of the stencil state.
// initialize the description of the stencil state.
ZeroMemory(&depthStencilDesc, sizeof(depthStencilDesc));
// Set up the description of the stencil state.
@@ -290,7 +290,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
// Create the depth stencil state.
result = m_device->CreateDepthStencilState(&depthStencilDesc, &m_depthStencilState);
result = device_->CreateDepthStencilState(&depthStencilDesc, &depth_stencil_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create depth stencil state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -298,9 +298,9 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
}
// Set the depth stencil state.
m_deviceContext->OMSetDepthStencilState(m_depthStencilState, 1);
device_context_->OMSetDepthStencilState(depth_stencil_state_, 1);
// Initialize the depth stencil view.
// initialize the depth stencil view.
ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
// Set up the depth stencil view description.
@@ -309,7 +309,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
depthStencilViewDesc.Texture2D.MipSlice = 0;
// Create the depth stencil view.
result = m_device->CreateDepthStencilView(m_depthStencilBuffer, &depthStencilViewDesc, &m_depthStencilView);
result = device_->CreateDepthStencilView(depth_stencil_buffer_, &depthStencilViewDesc, &depth_stencil_view_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create depth stencil view", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -317,7 +317,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
}
// Bind the render target view and depth stencil buffer to the output render pipeline.
m_deviceContext->OMSetRenderTargets(1, &m_renderTargetView, m_depthStencilView);
device_context_->OMSetRenderTargets(1, &render_target_view_, depth_stencil_view_);
// Setup the raster description which will determine how and what polygons will be drawn.
rasterDesc.AntialiasedLineEnable = false;
@@ -332,7 +332,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
rasterDesc.SlopeScaledDepthBias = 0.0f;
// Create the rasterizer state from the description we just filled out.
result = m_device->CreateRasterizerState(&rasterDesc, &m_rasterState);
result = device_->CreateRasterizerState(&rasterDesc, &raster_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create rasterizer state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -340,31 +340,31 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
}
// Now set the rasterizer state.
m_deviceContext->RSSetState(m_rasterState);
device_context_->RSSetState(raster_state_);
// Setup the viewport for rendering.
m_viewport.Width = (float)screenWidth;
m_viewport.Height = (float)screenHeight;
m_viewport.MinDepth = 0.0f;
m_viewport.MaxDepth = 1.0f;
m_viewport.TopLeftX = 0.0f;
m_viewport.TopLeftY = 0.0f;
viewport_.Width = (float)screenWidth;
viewport_.Height = (float)screenHeight;
viewport_.MinDepth = 0.0f;
viewport_.MaxDepth = 1.0f;
viewport_.TopLeftX = 0.0f;
viewport_.TopLeftY = 0.0f;
// Create the viewport.
m_deviceContext->RSSetViewports(1, &m_viewport);
device_context_->RSSetViewports(1, &viewport_);
// Setup the projection matrix.
fieldOfView = 3.141592654f / 4.0f;
screenAspect = (float)screenWidth / (float)screenHeight;
// Create the projection matrix for 3D rendering.
m_projectionMatrix = XMMatrixPerspectiveFovLH(fieldOfView, screenAspect, screenNear, screenDepth);
projection_matrix_ = XMMatrixPerspectiveFovLH(fieldOfView, screenAspect, screenNear, screenDepth);
// Initialize the world matrix to the identity matrix.
m_worldMatrix = XMMatrixIdentity();
// initialize the world matrix to the identity matrix.
world_matrix_ = XMMatrixIdentity();
// Create an orthographic projection matrix for 2D rendering.
m_orthoMatrix = XMMatrixOrthographicLH((float)screenWidth, (float)screenHeight, screenNear, screenDepth);
ortho_matrix_ = XMMatrixOrthographicLH((float)screenWidth, (float)screenHeight, screenNear, screenDepth);
// Clear the second depth stencil state before setting the parameters.
ZeroMemory(&depthDisabledStencilDesc, sizeof(depthDisabledStencilDesc));
@@ -387,7 +387,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
depthDisabledStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
// Create the state using the device.
result = m_device->CreateDepthStencilState(&depthDisabledStencilDesc, &m_depthDisabledStencilState);
result = device_->CreateDepthStencilState(&depthDisabledStencilDesc, &depth_disabled_stencil_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create depth disabled stencil state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -408,7 +408,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
blendStateDescription.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
// Create the blend state using the description.
result = m_device->CreateBlendState(&blendStateDescription, &m_alphaEnableBlendingState);
result = device_->CreateBlendState(&blendStateDescription, &alpha_enable_blending_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create alpha enabled blend state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -419,7 +419,7 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
blendStateDescription.RenderTarget[0].BlendEnable = FALSE;
// Create the blend state using the description.
result = m_device->CreateBlendState(&blendStateDescription, &m_alphaDisableBlendingState);
result = device_->CreateBlendState(&blendStateDescription, &alpha_disable_blending_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create alpha disabled blend state", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -430,81 +430,81 @@ bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hw
}
void D3DClass::Shutdown()
void d_3d_class::shutdown()
{
Logger::Get().Log("Shutting down D3Dclass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Before shutting down set to windowed mode or when you release the swap chain it will throw an exception.
if (m_swapChain)
if (swap_chain)
{
m_swapChain->SetFullscreenState(false, NULL);
swap_chain->SetFullscreenState(false, NULL);
}
if (m_alphaEnableBlendingState)
if (alpha_enable_blending_state_)
{
m_alphaEnableBlendingState->Release();
m_alphaEnableBlendingState = 0;
alpha_enable_blending_state_->Release();
alpha_enable_blending_state_ = 0;
}
if (m_alphaDisableBlendingState)
if (alpha_disable_blending_state_)
{
m_alphaDisableBlendingState->Release();
m_alphaDisableBlendingState = 0;
alpha_disable_blending_state_->Release();
alpha_disable_blending_state_ = 0;
}
if (m_depthDisabledStencilState)
if (depth_disabled_stencil_state_)
{
m_depthDisabledStencilState->Release();
m_depthDisabledStencilState = 0;
depth_disabled_stencil_state_->Release();
depth_disabled_stencil_state_ = 0;
}
if (m_rasterState)
if (raster_state_)
{
m_rasterState->Release();
m_rasterState = 0;
raster_state_->Release();
raster_state_ = 0;
}
if (m_depthStencilView)
if (depth_stencil_view_)
{
m_depthStencilView->Release();
m_depthStencilView = 0;
depth_stencil_view_->Release();
depth_stencil_view_ = 0;
}
if (m_depthStencilState)
if (depth_stencil_state_)
{
m_depthStencilState->Release();
m_depthStencilState = 0;
depth_stencil_state_->Release();
depth_stencil_state_ = 0;
}
if (m_depthStencilBuffer)
if (depth_stencil_buffer_)
{
m_depthStencilBuffer->Release();
m_depthStencilBuffer = 0;
depth_stencil_buffer_->Release();
depth_stencil_buffer_ = 0;
}
if (m_renderTargetView)
if (render_target_view_)
{
m_renderTargetView->Release();
m_renderTargetView = 0;
render_target_view_->Release();
render_target_view_ = 0;
}
if (m_deviceContext)
if (device_context_)
{
m_deviceContext->Release();
m_deviceContext = 0;
device_context_->Release();
device_context_ = 0;
}
if (m_device)
if (device_)
{
m_device->Release();
m_device = 0;
device_->Release();
device_ = 0;
}
if (m_swapChain)
if (swap_chain)
{
m_swapChain->Release();
m_swapChain = 0;
swap_chain->Release();
swap_chain = 0;
}
Logger::Get().Log("D3Dclass shutdown", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -513,7 +513,7 @@ void D3DClass::Shutdown()
}
void D3DClass::BeginScene(float red, float green, float blue, float alpha)
void d_3d_class::begin_scene(float red, float green, float blue, float alpha)
{
float color[4];
@@ -525,115 +525,115 @@ void D3DClass::BeginScene(float red, float green, float blue, float alpha)
color[3] = alpha;
// Clear the back buffer.
m_deviceContext->ClearRenderTargetView(m_renderTargetView, color);
device_context_->ClearRenderTargetView(render_target_view_, color);
// Clear the depth buffer.
m_deviceContext->ClearDepthStencilView(m_depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
device_context_->ClearDepthStencilView(depth_stencil_view_, D3D11_CLEAR_DEPTH, 1.0f, 0);
return;
}
void D3DClass::EndScene()
void d_3d_class::end_scene()
{
// Present the back buffer to the screen since rendering is complete.
if (m_vsync_enabled)
if (vsync_enabled_)
{
// Lock to screen refresh rate.
m_swapChain->Present(1, 0);
swap_chain->Present(1, 0);
}
else
{
// Present as fast as possible.
m_swapChain->Present(0, 0);
swap_chain->Present(0, 0);
}
return;
}
ID3D11Device* D3DClass::GetDevice()
ID3D11Device* d_3d_class::get_device()
{
return m_device;
return device_;
}
ID3D11DeviceContext* D3DClass::GetDeviceContext()
ID3D11DeviceContext* d_3d_class::get_device_context()
{
return m_deviceContext;
return device_context_;
}
void D3DClass::GetVideoCardInfo(char* cardName, int& memory)
void d_3d_class::get_video_card_info(char* cardName, int& memory)
{
strcpy_s(cardName, 128, m_videoCardDescription);
memory = m_videoCardMemory;
strcpy_s(cardName, 128, video_card_description_);
memory = video_card_memory_;
return;
}
void D3DClass::SetBackBufferRenderTarget()
void d_3d_class::set_back_buffer_render_target()
{
// Bind the render target view and depth stencil buffer to the output render pipeline.
m_deviceContext->OMSetRenderTargets(1, &m_renderTargetView, m_depthStencilView);
device_context_->OMSetRenderTargets(1, &render_target_view_, depth_stencil_view_);
return;
}
void D3DClass::ResetViewport()
void d_3d_class::reset_viewport()
{
// Set the viewport.
m_deviceContext->RSSetViewports(1, &m_viewport);
device_context_->RSSetViewports(1, &viewport_);
return;
}
void D3DClass::ReleaseResources()
void d_3d_class::release_resources()
{
Logger::Get().Log("Releasing D3D resources", __FILE__, __LINE__);
// libere la vue
if (m_renderTargetView)
if (render_target_view_)
{
m_renderTargetView->Release();
m_renderTargetView = 0;
render_target_view_->Release();
render_target_view_ = 0;
}
// libere le buffer de profondeur
if (m_depthStencilBuffer)
if (depth_stencil_buffer_)
{
m_depthStencilBuffer->Release();
m_depthStencilBuffer = 0;
depth_stencil_buffer_->Release();
depth_stencil_buffer_ = 0;
}
// libere la vue de profondeur
if (m_depthStencilView)
if (depth_stencil_view_)
{
m_depthStencilView->Release();
m_depthStencilView = 0;
depth_stencil_view_->Release();
depth_stencil_view_ = 0;
}
Logger::Get().Log("D3D resources released", __FILE__, __LINE__);
}
// Reset the resources for the swap chain
void D3DClass::ResetResources(int newWidth, int newHeight)
void d_3d_class::reset_resources(int newWidth, int newHeight)
{
Logger::Get().Log("Resetting D3D resources", __FILE__, __LINE__);
HRESULT result;
ID3D11Texture2D* backBuffer;
result = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBuffer);
result = swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBuffer);
if (FAILED(result))
{
Logger::Get().Log("Failed to get back buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return;
}
result = m_device->CreateRenderTargetView(backBuffer, NULL, &m_renderTargetView);
result = device_->CreateRenderTargetView(backBuffer, NULL, &render_target_view_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create render target view", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -669,14 +669,14 @@ void D3DClass::ResetResources(int newWidth, int newHeight)
depthStencilViewDesc.Texture2D.MipSlice = 0;
// Other depthStencilDesc settings...
result = m_device->CreateTexture2D(&depthBufferDesc, NULL, &m_depthStencilBuffer);
result = device_->CreateTexture2D(&depthBufferDesc, NULL, &depth_stencil_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create depth stencil buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return;
}
result = m_device->CreateDepthStencilView(m_depthStencilBuffer, &depthStencilViewDesc, &m_depthStencilView);
result = device_->CreateDepthStencilView(depth_stencil_buffer_, &depthStencilViewDesc, &depth_stencil_view_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create depth stencil view", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -684,15 +684,15 @@ void D3DClass::ResetResources(int newWidth, int newHeight)
}
// Set the new render target and depth/stencil views for rendering
m_deviceContext->OMSetRenderTargets(1, &m_renderTargetView, m_depthStencilView);
device_context_->OMSetRenderTargets(1, &render_target_view_, depth_stencil_view_);
}
IDXGISwapChain* D3DClass::GetSwapChain()
IDXGISwapChain* d_3d_class::get_swap_chain()
{
return m_swapChain;
return swap_chain;
}
void D3DClass::ResizeSwapChain(int newWidth, int newHeight)
void d_3d_class::resize_swap_chain(int newWidth, int newHeight)
{
// log the new width and height
@@ -701,11 +701,11 @@ void D3DClass::ResizeSwapChain(int newWidth, int newHeight)
HRESULT result;
// Release existing DirectX resources
ReleaseResources();
m_deviceContext->Flush();
release_resources();
device_context_->Flush();
// Resize the swap chain
result = m_swapChain->ResizeBuffers(0, newWidth, newHeight, DXGI_FORMAT_UNKNOWN, 0);
result = swap_chain->ResizeBuffers(0, newWidth, newHeight, DXGI_FORMAT_UNKNOWN, 0);
if (FAILED(result))
{
Logger::Get().Log("Failed to resize swap chain", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -713,28 +713,28 @@ void D3DClass::ResizeSwapChain(int newWidth, int newHeight)
}
// Reset the resources
ResetResources(newWidth, newHeight);
reset_resources(newWidth, newHeight);
// Update the viewport
m_viewport.Width = static_cast<float>(newWidth);
m_viewport.Height = static_cast<float>(newHeight);
m_deviceContext->RSSetViewports(1, &m_viewport);
viewport_.Width = static_cast<float>(newWidth);
viewport_.Height = static_cast<float>(newHeight);
device_context_->RSSetViewports(1, &viewport_);
}
void D3DClass::TurnZBufferOn()
void d_3d_class::turn_z_buffer_on()
{
m_deviceContext->OMSetDepthStencilState(m_depthStencilState, 1);
device_context_->OMSetDepthStencilState(depth_stencil_state_, 1);
return;
}
void D3DClass::TurnZBufferOff()
void d_3d_class::turn_z_buffer_off()
{
m_deviceContext->OMSetDepthStencilState(m_depthDisabledStencilState, 1);
device_context_->OMSetDepthStencilState(depth_disabled_stencil_state_, 1);
return;
}
void D3DClass::EnableAlphaBlending()
void d_3d_class::enable_alpha_blending()
{
float blendFactor[4];
@@ -746,12 +746,12 @@ void D3DClass::EnableAlphaBlending()
blendFactor[3] = 0.0f;
// Turn on the alpha blending.
m_deviceContext->OMSetBlendState(m_alphaEnableBlendingState, blendFactor, 0xffffffff);
device_context_->OMSetBlendState(alpha_enable_blending_state_, blendFactor, 0xffffffff);
return;
}
void D3DClass::DisableAlphaBlending()
void d_3d_class::disable_alpha_blending()
{
float blendFactor[4];
@@ -763,12 +763,12 @@ void D3DClass::DisableAlphaBlending()
blendFactor[3] = 0.0f;
// Turn off the alpha blending.
m_deviceContext->OMSetBlendState(m_alphaDisableBlendingState, blendFactor, 0xffffffff);
device_context_->OMSetBlendState(alpha_disable_blending_state_, blendFactor, 0xffffffff);
return;
}
void D3DClass::SetVsync(bool vsync)
void d_3d_class::set_vsync(bool vsync)
{
m_vsync_enabled = vsync;
vsync_enabled_ = vsync;
}

View File

@@ -1,29 +1,29 @@
#include "displayplaneclass.h"
#include "display_plane_class.h"
DisplayPlaneClass::DisplayPlaneClass()
display_plane_class::display_plane_class()
{
m_vertexBuffer = 0;
m_indexBuffer = 0;
}
DisplayPlaneClass::DisplayPlaneClass(const DisplayPlaneClass& other)
display_plane_class::display_plane_class(const display_plane_class& other)
{
}
DisplayPlaneClass::~DisplayPlaneClass()
display_plane_class::~display_plane_class()
{
}
bool DisplayPlaneClass::Initialize(ID3D11Device* device, float width, float height)
bool display_plane_class::Initialize(ID3D11Device* device, float width, float height)
{
Logger::Get().Log("Initializing DisplayPlaneClass, width: " + std::to_string(width) + ", height: " + std::to_string(height), __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing display_plane_class, width: " + std::to_string(width) + ", height: " + std::to_string(height), __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
// Initialize the vertex and index buffer that hold the geometry for the button.
// initialize the vertex and index buffer that hold the geometry for the button.
result = InitializeBuffers(device, width, height);
if (!result)
{
@@ -35,7 +35,7 @@ bool DisplayPlaneClass::Initialize(ID3D11Device* device, float width, float heig
}
void DisplayPlaneClass::Shutdown()
void display_plane_class::Shutdown()
{
// Release the vertex and index buffers.
ShutdownBuffers();
@@ -44,7 +44,7 @@ void DisplayPlaneClass::Shutdown()
}
void DisplayPlaneClass::Render(ID3D11DeviceContext* deviceContext)
void display_plane_class::Render(ID3D11DeviceContext* deviceContext)
{
// Put the vertex and index buffers on the graphics pipeline to prepare them for drawing.
RenderBuffers(deviceContext);
@@ -53,12 +53,12 @@ void DisplayPlaneClass::Render(ID3D11DeviceContext* deviceContext)
}
int DisplayPlaneClass::GetIndexCount()
int display_plane_class::GetIndexCount()
{
return m_indexCount;
}
bool DisplayPlaneClass::InitializeBuffers(ID3D11Device* device, float width, float height)
bool display_plane_class::InitializeBuffers(ID3D11Device* device, float width, float height)
{
Logger::Get().Log("Initializing buffers", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -164,7 +164,7 @@ bool DisplayPlaneClass::InitializeBuffers(ID3D11Device* device, float width, flo
}
void DisplayPlaneClass::ShutdownBuffers()
void display_plane_class::ShutdownBuffers()
{
Logger::Get().Log("Shutting down Plane buffers", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -188,7 +188,7 @@ void DisplayPlaneClass::ShutdownBuffers()
}
void DisplayPlaneClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
void display_plane_class::RenderBuffers(ID3D11DeviceContext* deviceContext)
{
unsigned int stride;
unsigned int offset;

View File

@@ -1,22 +1,22 @@
#include "fontclass.h"
#include "font_class.h"
FontClass::FontClass()
font_class::font_class()
{
m_Font = 0;
m_Texture = 0;
}
FontClass::FontClass(const FontClass& other)
font_class::font_class(const font_class& other)
{
}
FontClass::~FontClass()
font_class::~font_class()
{
}
bool FontClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, int fontChoice)
bool font_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, int fontChoice)
{
Logger::Get().Log("Initializing font class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -66,7 +66,7 @@ bool FontClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCont
return true;
}
void FontClass::Shutdown()
void font_class::Shutdown()
{
// Release the font texture.
ReleaseTexture();
@@ -77,7 +77,7 @@ void FontClass::Shutdown()
return;
}
bool FontClass::LoadFontData(char* filename)
bool font_class::LoadFontData(char* filename)
{
Logger::Get().Log(("Loading font data from %s", filename), __FILE__, __LINE__);
@@ -123,7 +123,7 @@ bool FontClass::LoadFontData(char* filename)
return true;
}
void FontClass::ReleaseFontData()
void font_class::ReleaseFontData()
{
// Release the font data array.
if (m_Font)
@@ -135,7 +135,7 @@ void FontClass::ReleaseFontData()
return;
}
bool FontClass::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* filename)
bool font_class::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* filename)
{
Logger::Get().Log(("Loading font texture from %s", filename), __FILE__, __LINE__);
@@ -143,7 +143,7 @@ bool FontClass::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCon
// Create and initialize the font texture object.
m_Texture = new TextureClass;
m_Texture = new texture_class;
result = m_Texture->Initialize(device, deviceContext, filename);
if (!result)
@@ -157,7 +157,7 @@ bool FontClass::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCon
return true;
}
void FontClass::ReleaseTexture()
void font_class::ReleaseTexture()
{
// Release the texture object.
if (m_Texture)
@@ -170,12 +170,12 @@ void FontClass::ReleaseTexture()
return;
}
ID3D11ShaderResourceView* FontClass::GetTexture()
ID3D11ShaderResourceView* font_class::GetTexture()
{
return m_Texture->GetTexture();
}
void FontClass::BuildVertexArray(void* vertices, char* sentence, float drawX, float drawY)
void font_class::BuildVertexArray(void* vertices, char* sentence, float drawX, float drawY)
{
VertexType* vertexPtr;
int numLetters, index, i, letter;
@@ -236,7 +236,7 @@ void FontClass::BuildVertexArray(void* vertices, char* sentence, float drawX, fl
return;
}
int FontClass::GetSentencePixelLength(char* sentence)
int font_class::GetSentencePixelLength(char* sentence)
{
int pixelLength, numLetters, i, letter;
@@ -262,7 +262,7 @@ int FontClass::GetSentencePixelLength(char* sentence)
return pixelLength;
}
int FontClass::GetFontHeight()
int font_class::GetFontHeight()
{
return (int)m_fontHeight;
}

View File

@@ -1,21 +1,21 @@
#include "fpsclass.h"
#include "fps_class.h"
FpsClass::FpsClass()
fps_class::fps_class()
{
}
FpsClass::FpsClass(const FpsClass& other)
fps_class::fps_class(const fps_class& other)
{
}
FpsClass::~FpsClass()
fps_class::~fps_class()
{
}
void FpsClass::Initialize()
void fps_class::Initialize()
{
m_fps = 0;
m_count = 0;
@@ -28,7 +28,7 @@ void FpsClass::Initialize()
return;
}
void FpsClass::Frame()
void fps_class::Frame()
{
unsigned int currentTime = timeGetTime();
@@ -55,28 +55,28 @@ void FpsClass::Frame()
return;
}
int FpsClass::GetMinFps() const
int fps_class::GetMinFps() const
{
return m_minFps;
}
int FpsClass::GetMaxFps() const
int fps_class::GetMaxFps() const
{
return m_maxFps;
}
float FpsClass::GetFrameTime() const
float fps_class::GetFrameTime() const
{
return m_frameTime;
}
void FpsClass::ResetStats()
void fps_class::ResetStats()
{
m_minFps = INT_MAX;
m_maxFps = 0;
}
int FpsClass::GetFps()
int fps_class::GetFps()
{
return m_fps;
}

View File

@@ -1,6 +1,6 @@
#include "frustum.h"
void Frustum::ConstructFrustum(float screenDepth, XMMATRIX projectionMatrix, XMMATRIX viewMatrix)
void frustum::ConstructFrustum(float screenDepth, XMMATRIX projectionMatrix, XMMATRIX viewMatrix)
{
XMMATRIX matrix;
XMVECTOR planes[6];
@@ -56,7 +56,7 @@ void Frustum::ConstructFrustum(float screenDepth, XMMATRIX projectionMatrix, XMM
}
}
bool Frustum::CheckCube(float xCenter, float yCenter, float zCenter, float radius, float tolerance)
bool frustum::CheckCube(float xCenter, float yCenter, float zCenter, float radius, float tolerance)
{
// V<>rifiez chaque plan du frustum pour voir si le cube est <20> l'int<6E>rieur
for (int i = 0; i < 6; i++)

View File

@@ -1,16 +1,37 @@
#include "imguiManager.h"
#include "applicationclass.h"
#include "application_class.h"
static fps_limiter fpsLimiter(60.0f);
imguiManager::imguiManager()
{
io = nullptr;
m_frameTimeHistoryIndex = 0;
current_fps_ = 0;
min_fps_ = 0;
max_fps_ = 0;
draw_calls_ = 0;
total_vertex_count_ = 0;
total_triangle_count_ = 0;
visible_triangle_count_ = 0;
current_frame_time_ = 0;
// Initialiser l'historique des frametimes <20> z<>ro
for (int i = 0; i < FRAME_HISTORY_COUNT; i++)
{
m_frameTimeHistory[i] = 0.0f;
}
widgets_ = {
{&showObjectWindow, [&](){WidgetObjectWindow();}},
{&showEngineSettingsWindow, [&](){WidgetEngineSettingsWindow();}},
{&showTerrainWindow, [&](){WidgetTerrainWindow();}},
{&showLightWindow, [&](){WidgetLightWindow();}},
{&showLogWindow, [&](){WidgetLogWindow();}},
{&showOldSceneWindow, [&](){WidgetRenderWindow(ImVec2(800, 600));}},
{&showStatsWindow, [&](){WidgetRenderStats();}}
};
}
imguiManager::~imguiManager()
@@ -154,17 +175,17 @@ void imguiManager::Shutdown()
Logger::Get().Log("imgui shutdown", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
void imguiManager::Render(ApplicationClass* app)
void imguiManager::Render()
{
ImGui::Render();
//app->GetDirect3D()->TurnZBufferOff();
//app->GetDirect3D()->EnableAlphaBlending();
//app->get_direct_3d()->turn_z_buffer_off();
//app->get_direct_3d()->enable_alpha_blending();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
//app->GetDirect3D()->DisableAlphaBlending();
//app->GetDirect3D()->TurnZBufferOn();
//app->get_direct_3d()->disable_alpha_blending();
//app->get_direct_3d()->turn_z_buffer_on();
}
void imguiManager::NewFrame()
@@ -174,7 +195,7 @@ void imguiManager::NewFrame()
ImGui::NewFrame();
}
void imguiManager::SetupDockspace(ApplicationClass* app) {
void imguiManager::SetupDockspace() {
// Configuration du style pour supprimer l'espace autour des fen<65>tres dock<63>es
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
@@ -212,16 +233,16 @@ void imguiManager::SetupDockspace(ApplicationClass* app) {
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
ImGui::MenuItem("Render Stats", NULL, &showStatsWindow);
ImGui::MenuItem("render Stats", NULL, &showStatsWindow);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Scene")) {
if (ImGui::MenuItem("Save Scene")) {
app->SaveScene();
app_->save_scene();
}
if (ImGui::MenuItem("Load Scene")) {
app->LoadScene();
app_->load_scene();
}
ImGui::EndMenu();
}
@@ -247,13 +268,13 @@ void imguiManager::WidgetButton()
ImGui::Text("counter = %d", counter);
}
void imguiManager::WidgetAddObject(ApplicationClass* app)
void imguiManager::WidgetAddObject()
{
if (ImGui::CollapsingHeader("Objects"))
{
if (ImGui::Button("Add Cube"))
{
app->AddCube();
app_->add_cube();
}
ImGui::SameLine();
if (ImGui::Button("Import Object"))
@@ -333,22 +354,22 @@ void imguiManager::WidgetAddObject(ApplicationClass* app)
// Remplacer les antislashs par des slashs
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
app->AddKobject(relativePath);
app_->add_kobject(relativePath);
}
}
}
ImGui::SameLine();
ImGui::Text("Number of cubes: %d", app->GetCubeCount());
ImGui::Text("Number of cubes: %d", app_->get_cube_count());
}
}
void imguiManager::WidgetObjectWindow(ApplicationClass* app)
void imguiManager::WidgetObjectWindow()
{
ImGui::Begin("Objects", &showObjectWindow);
int index = 0;
for (auto& object : app->GetKobjects())
for (auto& object : app_->get_kobjects())
{
std::string headerName = object->GetName() + " " + std::to_string(index);
if (ImGui::CollapsingHeader(headerName.c_str()))
@@ -381,7 +402,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
ImGui::Separator();
// D<>finir les types de textures
// D<>finir les types de textures_
std::vector<std::string> textureCategories = {
"Diffuse", "Normal", "Specular", "Alpha"
};
@@ -391,7 +412,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
TextureType::Specular, TextureType::Alpha
};
// Cr<43>er un espace pour afficher les textures avec d<>filement
// Cr<43>er un espace pour afficher les textures_ avec d<>filement
ImGui::BeginChild("TextureChild", ImVec2(0, 200), true, ImGuiWindowFlags_HorizontalScrollbar);
// Pour chaque type de texture
@@ -404,14 +425,14 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
ImGui::Text("%s:", typeName.c_str());
ImGui::SameLine();
// Compter combien de textures de ce type existent
// Compter combien de textures_ de ce type existent
int textureCount = 0;
while (object->GetTexture(type, textureCount) != nullptr)
{
textureCount++;
}
// Afficher toutes les textures existantes
// Afficher toutes les textures_ existantes
ImGui::BeginGroup();
for (int texIndex = 0; texIndex < textureCount; texIndex++)
{
@@ -496,7 +517,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
std::string deleteLabel = "Delete##" + std::to_string(index);
if (ImGui::Button(deleteLabel.c_str()))
{
app->DeleteKobject(index);
app_->delete_kobject(index);
}
ImGui::Separator();
@@ -547,8 +568,8 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
ImGui::Separator();
// Physics
std::string physicsLabel = "Physics##" + std::to_string(index);
// physics
std::string physicsLabel = "physics##" + std::to_string(index);
if (ImGui::Checkbox(physicsLabel.c_str(), &m_isPhyiscsEnabled))
{
@@ -629,17 +650,17 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
ImGui::End();
}
void imguiManager::WidgetTerrainWindow(ApplicationClass* app)
void imguiManager::WidgetTerrainWindow()
{
ImGui::Begin("Terrain", &showTerrainWindow);
ImGui::Text("Number of terrain cubes: %d", app->GetTerrainCubeCount());
ImGui::Text("Number of terrain cubes: %d", app_->get_terrain_cube_count());
ImGui::Separator();
if (ImGui::Button("Generate Flat Terrain"))
{
app->GenerateTerrain();
app_->generate_terrain();
}
ImGui::Separator();
@@ -657,14 +678,14 @@ void imguiManager::WidgetTerrainWindow(ApplicationClass* app)
if (ImGui::Button("Generate BigCube Terrain"))
{
app->CreateBigCube(m_SideCount);
app_->create_big_cube(m_SideCount);
}
ImGui::Separator();
if (ImGui::Button("Delete All Terrain Cubes"))
{
app->DeleteTerrain();
app_->delete_terrain();
}
@@ -672,76 +693,45 @@ void imguiManager::WidgetTerrainWindow(ApplicationClass* app)
ImGui::End();
}
bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
bool imguiManager::ImGuiWidgetRenderer()
{
// Start the Dear ImGui frame
NewFrame();
// Setup the dockspace
SetupDockspace(app);
SetupDockspace();
//ImGui Widget
ImGui::Begin("Khaotic Engine", NULL);
float speed = app->GetSpeed();
float speed = app_->get_speed();
WidgetSpeedSlider(&speed);
app->SetSpeed(speed);
app_->set_speed(speed);
WidgetButton();
// WidgetFPS();
WidgetAddObject(app);
WidgetAddObject();
ImGui::End();
// Show windows if their corresponding variables are true
if (showObjectWindow)
// Read the widget list and call the function if the show variable is true
for (const auto& entry : widgets_)
{
WidgetObjectWindow(app);
}
if (showTerrainWindow)
{
WidgetTerrainWindow(app);
}
if (showLightWindow)
{
WidgetLightWindow(app);
}
if (showEngineSettingsWindow)
{
WidgetEngineSettingsWindow(app);
}
if (showLogWindow)
{
WidgetLogWindow(app);
}
if (showOldSceneWindow)
{
WidgetRenderWindow(app, ImVec2(800, 600));
}
if (showStatsWindow)
{
WidgetRenderStats(app);
if (*entry.show == true) {entry.func();}
}
//render imgui
Render(app);
Render();
return true;
}
void imguiManager::WidgetLightWindow(ApplicationClass* app)
void imguiManager::WidgetLightWindow()
{
ImGui::Begin("Light", &showLightWindow);
// Sun light settings
LightClass* sunLight = app->GetSunLight();
light_class* sunLight = app_->get_sun_light();
// Direction input
XMFLOAT3 direction = sunLight->GetDirection();
float dir[3] = { direction.x, direction.y, direction.z };
@@ -770,13 +760,13 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app)
// Area light settings
for(auto& light : app->GetLights())
for(auto& light : app_->get_lights())
{
std::string headerName = "Light " + std::to_string(index);
if (ImGui::CollapsingHeader(headerName.c_str()))
{
XMVECTOR position = app->GetLightPosition(index);
XMVECTOR color = app->GetLightColor(index);
XMVECTOR position = app_->get_light_position(index);
XMVECTOR color = app_->get_light_color(index);
float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) };
float col[3] = { XMVectorGetX(color), XMVectorGetY(color), XMVectorGetZ(color) };
@@ -785,12 +775,12 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app)
if (ImGui::DragFloat3(posLabel.c_str(), pos))
{
app->SetLightPosition(index, XMVectorSet(pos[0], pos[1], pos[2], 0.0f));
app_->set_light_position(index, XMVectorSet(pos[0], pos[1], pos[2], 0.0f));
}
if (ImGui::ColorEdit3(colLabel.c_str(), col))
{
app->SetLightColor(index, XMVectorSet(col[0], col[1], col[2], 0.0f));
app_->set_light_color(index, XMVectorSet(col[0], col[1], col[2], 0.0f));
}
}
@@ -800,18 +790,18 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app)
ImGui::End();
}
void imguiManager::WidgetEngineSettingsWindow(ApplicationClass* app)
void imguiManager::WidgetEngineSettingsWindow()
{
ImGui::Begin("Engine Settings", &showEngineSettingsWindow);
// Begining Of General Setting
ImGui::Text("General");
// Checkbox for toggling vsync globally in the application class by calling the SetVsync function in the application class when the checkbox state changes
bool vsync = app->GetVsync();
// Checkbox for toggling vsync globally in the application class by calling the set_vsync function in the application class when the checkbox state changes
bool vsync = app_->get_vsync();
if (ImGui::Checkbox("Vsync", &vsync))
{
app->SetVsync(vsync);
app_->set_vsync(vsync);
}
// End Of General Setting
@@ -820,37 +810,37 @@ void imguiManager::WidgetEngineSettingsWindow(ApplicationClass* app)
ImGui::Text("Culling");
// float input for frustum tolerance
float frustumTolerance = app->GetFrustumTolerance();
float frustumTolerance = app_->get_frustum_tolerance();
if (ImGui::DragFloat("Frustum Tolerance", &frustumTolerance, 0.1f, 0.0f, 100.0f))
{
app->SetFrustumTolerance(frustumTolerance);
app_->set_frustum_tolerance(frustumTolerance);
}
// End Of Culling Setting
ImGui::Separator();
// Physics section
ImGui::Text("Physics");
// physics section
ImGui::Text("physics");
// Input To set the Fixed Update Interval
int physicsInterval = app->GetPhysicsTickRate();
if (ImGui::InputInt("Physics Tick Rate", &physicsInterval))
int physicsInterval = app_->get_physics_tick_rate();
if (ImGui::InputInt("physics Tick Rate", &physicsInterval))
{
app->SetPhysicsTickRate(physicsInterval);
app_->set_physics_tick_rate(physicsInterval);
}
// Input to change the gravity on same line
XMVECTOR gravity = app->GetPhysics()->GetGravity();
XMVECTOR gravity = app_->get_physics()->GetGravity();
float gravityValues[3] = { XMVectorGetX(gravity), XMVectorGetY(gravity), XMVectorGetZ(gravity) };
if (ImGui::DragFloat3("Gravity", gravityValues))
{
app->GetPhysics()->SetGravity(XMVectorSet(gravityValues[0], gravityValues[1], gravityValues[2], 0.0f));
app_->get_physics()->SetGravity(XMVectorSet(gravityValues[0], gravityValues[1], gravityValues[2], 0.0f));
}
ImGui::End();
}
void imguiManager::WidgetLogWindow(ApplicationClass* app)
void imguiManager::WidgetLogWindow()
{
ImGui::Begin("Log Window" , &showLogWindow);
@@ -931,9 +921,9 @@ void imguiManager::WidgetLogWindow(ApplicationClass* app)
ImGui::End();
}
void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize)
void imguiManager::WidgetRenderWindow(ImVec2 availableSize)
{
ImGui::Begin("Render Window");
ImGui::Begin("render Window");
ImVec2 oldWindowSize = windowSize;
windowSize = ImGui::GetContentRegionAvail();
@@ -941,12 +931,12 @@ void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSiz
// Si la taille de la fen<65>tre a chang<6E>, ajustez la taille de la fen<65>tre de l'application
if (oldWindowSize.x != windowSize.x || oldWindowSize.y != windowSize.y)
{
app->SetWindowSize(windowSize);
app_->set_window_size(windowSize);
}
// Get the aspect ratio of the scene in app
float aspectRatio = app->GetAspectRatio();
float aspectRatio = app_->get_aspect_ratio();
// calculate the size of the window
if (windowSize.x / windowSize.y > aspectRatio)
{
@@ -957,40 +947,48 @@ void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSiz
windowSize.y = windowSize.x / aspectRatio;
}
ID3D11ShaderResourceView* texture = app->GetSceneTexture()->GetShaderResourceView();
ID3D11ShaderResourceView* texture = app_->get_scene_texture()->GetShaderResourceView();
if (texture)
{
// Affichez la scenne projet<65> sur texture dans une fen<65>tre ImGui
// alpha blend is not enable to render the texture
app->GetDirect3D()->TurnZBufferOff();
app->GetDirect3D()->EnableAlphaBlending();
app_->get_direct_3d()->turn_z_buffer_off();
app_->get_direct_3d()->enable_alpha_blending();
ImGui::Image((ImTextureID)texture, windowSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(1, 1, 1, 1));
}
else
{
ImGui::Text("Render texture is not available.");
ImGui::Text("render texture is not available.");
}
ImGui::End();
}
void imguiManager::WidgetRenderStats(ApplicationClass* app)
void imguiManager::WidgetRenderStats()
{
ImGui::Begin("Render Stats");
ImGui::Begin("render Stats");
// R<>cup<75>rer le frametime actuel et le mettre dans l'historique
float currentFrameTime = app->GetFrameTime();
m_frameTimeHistory[m_frameTimeHistoryIndex] = currentFrameTime;
current_fps_ = app_->get_current_fps();
min_fps_ = app_->get_min_fps();
max_fps_ = app_->get_max_fps();
draw_calls_ = app_->get_draw_calls();
total_vertex_count_ = app_->get_total_vertex_count();
total_triangle_count_ = app_->get_total_triangle_count();
visible_triangle_count_ = app_->get_visible_triangle_count();
current_frame_time_ = app_->get_frame_time();
m_frameTimeHistory[m_frameTimeHistoryIndex] = current_frame_time_;
m_frameTimeHistoryIndex = (m_frameTimeHistoryIndex + 1) % FRAME_HISTORY_COUNT;
ImGui::Text("FPS: %d", app->GetCurrentFps());
ImGui::Text("FPS: %d", current_fps_);
ImGui::SameLine();
ImGui::Text("Min Fps: %d", app->GetMinFps());
ImGui::Text("Min Fps: %d", min_fps_);
ImGui::SameLine();
ImGui::Text("Max Fps: %d", app->GetMaxFps());
ImGui::Text("Max Fps: %d", max_fps_);
ImGui::Separator();
@@ -1013,7 +1011,7 @@ void imguiManager::WidgetRenderStats(ApplicationClass* app)
frameTimeMax += margin;
// Afficher le graphique
ImGui::Text("Frame Time: %.3f ms", currentFrameTime * 1000.0f);
ImGui::Text("Frame Time: %.3f ms", current_frame_time_ * 1000.0f);
ImGui::PlotLines("FrameTimeGraph", // Au lieu de cha<68>ne vide ""
m_frameTimeHistory,
FRAME_HISTORY_COUNT,
@@ -1023,16 +1021,16 @@ void imguiManager::WidgetRenderStats(ApplicationClass* app)
frameTimeMax,
ImVec2(0, 80));
ImGui::Text("Draw Calls: %d", app->GetDrawCalls());
ImGui::Text("Draw Calls: %d", draw_calls_);
ImGui::Separator();
ImGui::Text("Statistiques de rendu:");
ImGui::Text("Vertices total: %d", app->GetTotalVertexCount());
ImGui::Text("Vertices total: %d", total_vertex_count_);
ImGui::Text("Triangles total: %d", app->GetTotalTriangleCount());
ImGui::Text("Triangles total: %d", total_triangle_count_);
ImGui::SameLine();
ImGui::Text("Triangles visibles: %d", app->GetVisibleTriangleCount());
ImGui::Text("Triangles visibles: %d", visible_triangle_count_);
ImGui::End();
}

View File

@@ -1,7 +1,7 @@
#include "inputclass.h"
#include "input_class.h"
InputClass::InputClass()
input_class::input_class()
{
m_directInput = 0;
m_keyboard = 0;
@@ -10,16 +10,16 @@ InputClass::InputClass()
}
InputClass::InputClass(const InputClass& other)
input_class::input_class(const input_class& other)
{
}
InputClass::~InputClass()
input_class::~input_class()
{
}
bool InputClass::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)
bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)
{
Logger::Get().Log("Initializing input class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -118,7 +118,7 @@ bool InputClass::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int
}
void InputClass::KeyDown(unsigned int input)
void input_class::KeyDown(unsigned int input)
{
// If a key is pressed then save that state in the key array.
Logger::Get().Log("Key down: " + std::to_string(input), __FILE__, __LINE__, Logger::LogLevel::Input);
@@ -127,7 +127,7 @@ void InputClass::KeyDown(unsigned int input)
}
void InputClass::KeyUp(unsigned int input)
void input_class::KeyUp(unsigned int input)
{
// If a key is released then clear that state in the key array.
m_keys[input] = false;
@@ -135,13 +135,13 @@ void InputClass::KeyUp(unsigned int input)
}
bool InputClass::IsKeyDown(unsigned int key) const
bool input_class::IsKeyDown(unsigned int key) const
{
// Return what state the key is in (pressed/not pressed).
return m_keys[key];
}
void InputClass::Shutdown()
void input_class::Shutdown()
{
Logger::Get().Log("Shutting down input class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@@ -173,7 +173,7 @@ void InputClass::Shutdown()
return;
}
bool InputClass::Frame()
bool input_class::Frame()
{
bool result;
@@ -200,7 +200,7 @@ bool InputClass::Frame()
return true;
}
bool InputClass::ReadKeyboard()
bool input_class::ReadKeyboard()
{
HRESULT result;
@@ -224,7 +224,7 @@ bool InputClass::ReadKeyboard()
return true;
}
bool InputClass::ReadMouse()
bool input_class::ReadMouse()
{
HRESULT result;
@@ -248,7 +248,7 @@ bool InputClass::ReadMouse()
return true;
}
void InputClass::ProcessInput()
void input_class::ProcessInput()
{
// Update the location of the mouse cursor based on the change of the mouse location during the frame.
m_mouseX += m_mouseState.lX;
@@ -264,7 +264,7 @@ void InputClass::ProcessInput()
return;
}
bool InputClass::IsEscapePressed() const
bool input_class::IsEscapePressed() const
{
// Do a bitwise and on the keyboard state to check if the escape key is currently being pressed.
if (m_keyboardState[DIK_ESCAPE] & 0x80)
@@ -275,7 +275,7 @@ bool InputClass::IsEscapePressed() const
return false;
}
bool InputClass::IsLeftArrowPressed() const
bool input_class::IsLeftArrowPressed() const
{
if (m_keyboardState[DIK_LEFT] & 0x80)
{
@@ -286,7 +286,7 @@ bool InputClass::IsLeftArrowPressed() const
}
bool InputClass::IsRightArrowPressed() const
bool input_class::IsRightArrowPressed() const
{
if (m_keyboardState[DIK_RIGHT] & 0x80)
{
@@ -296,7 +296,7 @@ bool InputClass::IsRightArrowPressed() const
return false;
}
bool InputClass::IsUpArrowPressed() const
bool input_class::IsUpArrowPressed() const
{
if (m_keyboardState[DIK_UP] & 0x80)
{
@@ -307,7 +307,7 @@ bool InputClass::IsUpArrowPressed() const
}
bool InputClass::IsDownArrowPressed() const
bool input_class::IsDownArrowPressed() const
{
if (m_keyboardState[DIK_DOWN] & 0x80)
{
@@ -321,7 +321,7 @@ bool InputClass::IsDownArrowPressed() const
// Les touches correspondent aux claviers QWERTY //
///////////////////////////////////////////////////
bool InputClass::IsAPressed() const
bool input_class::IsAPressed() const
{
// Touche A sur QWERTY, Q sur AZERTY
if (m_keyboardState[DIK_A] & 0x80)
@@ -332,7 +332,7 @@ bool InputClass::IsAPressed() const
return false;
}
bool InputClass::IsDPressed() const
bool input_class::IsDPressed() const
{
if (m_keyboardState[DIK_D] & 0x80)
{
@@ -342,7 +342,7 @@ bool InputClass::IsDPressed() const
return false;
}
bool InputClass::IsWPressed() const
bool input_class::IsWPressed() const
{
// Touche W sur QWERTY, Z sur AZERTY
if (m_keyboardState[DIK_W] & 0x80)
@@ -353,7 +353,7 @@ bool InputClass::IsWPressed() const
return false;
}
bool InputClass::IsSPressed() const
bool input_class::IsSPressed() const
{
if (m_keyboardState[DIK_S] & 0x80)
{
@@ -363,7 +363,7 @@ bool InputClass::IsSPressed() const
return false;
}
bool InputClass::IsQPressed() const
bool input_class::IsQPressed() const
{
// Touche Q sur QWERTY, A sur AZERTY
if (m_keyboardState[DIK_Q] & 0x80)
@@ -374,7 +374,7 @@ bool InputClass::IsQPressed() const
return false;
}
bool InputClass::IsEPressed() const
bool input_class::IsEPressed() const
{
if (m_keyboardState[DIK_E] & 0x80)
{
@@ -384,14 +384,14 @@ bool InputClass::IsEPressed() const
return false;
}
void InputClass::GetMouseLocation(int& mouseX, int& mouseY) const
void input_class::GetMouseLocation(int& mouseX, int& mouseY) const
{
mouseX = m_mouseX;
mouseY = m_mouseY;
return;
}
bool InputClass::IsLeftMousePressed() const
bool input_class::IsLeftMousePressed() const
{
// Check the left mouse button state.
if (m_mouseState.rgbButtons[0] & 0x80)
@@ -402,7 +402,7 @@ bool InputClass::IsLeftMousePressed() const
return false;
}
bool InputClass::IsRightMousePressed() const
bool input_class::IsRightMousePressed() const
{
// Check the left mouse button state.
if (m_mouseState.rgbButtons[1] & 0x80)
@@ -413,7 +413,7 @@ bool InputClass::IsRightMousePressed() const
return false;
}
bool InputClass::IsScrollUp() const
bool input_class::IsScrollUp() const
{
if (m_mouseState.lZ > 0)
{
@@ -423,7 +423,7 @@ bool InputClass::IsScrollUp() const
return false;
}
bool InputClass::IsScrollDown() const
bool input_class::IsScrollDown() const
{
if (m_mouseState.lZ < 0)
{

View File

@@ -1,24 +1,24 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "lightclass.h"
#include "light_class.h"
LightClass::LightClass()
light_class::light_class()
{
}
LightClass::LightClass(const LightClass& other)
light_class::light_class(const light_class& other)
{
}
LightClass::~LightClass()
light_class::~light_class()
{
}
void LightClass::SetAmbientColor(float red, float green, float blue, float alpha)
void light_class::SetAmbientColor(float red, float green, float blue, float alpha)
{
m_ambientColor = XMFLOAT4(red, green, blue, alpha);
return;
@@ -26,66 +26,66 @@ void LightClass::SetAmbientColor(float red, float green, float blue, float alpha
void LightClass::SetDiffuseColor(float red, float green, float blue, float alpha)
void light_class::SetDiffuseColor(float red, float green, float blue, float alpha)
{
m_diffuseColor = XMFLOAT4(red, green, blue, alpha);
return;
}
void LightClass::SetDirection(float x, float y, float z)
void light_class::SetDirection(float x, float y, float z)
{
m_direction = XMFLOAT3(x, y, z);
return;
}
void LightClass::SetSpecularColor(float red, float green, float blue, float alpha)
void light_class::SetSpecularColor(float red, float green, float blue, float alpha)
{
m_specularColor = XMFLOAT4(red, green, blue, alpha);
return;
}
void LightClass::SetSpecularPower(float power)
void light_class::SetSpecularPower(float power)
{
m_specularPower = power;
return;
}
void LightClass::SetPosition(float x, float y, float z)
void light_class::SetPosition(float x, float y, float z)
{
m_position = XMFLOAT4(x, y, z, 1.0f);
return;
}
XMFLOAT4 LightClass::GetAmbientColor()
XMFLOAT4 light_class::GetAmbientColor()
{
return m_ambientColor;
}
XMFLOAT4 LightClass::GetDiffuseColor()
XMFLOAT4 light_class::GetDiffuseColor()
{
return m_diffuseColor;
}
XMFLOAT3 LightClass::GetDirection()
XMFLOAT3 light_class::GetDirection()
{
return m_direction;
}
XMFLOAT4 LightClass::GetSpecularColor()
XMFLOAT4 light_class::GetSpecularColor()
{
return m_specularColor;
}
float LightClass::GetSpecularPower()
float light_class::GetSpecularPower()
{
return m_specularPower;
}
XMFLOAT4 LightClass::GetPosition()
XMFLOAT4 light_class::GetPosition()
{
return m_position;
}

View File

@@ -1,7 +1,7 @@
#include "modelclass.h"
#include "model_class.h"
ModelClass::ModelClass()
model_class::model_class()
{
m_vertexBuffer = 0;
m_indexBuffer = 0;
@@ -18,14 +18,14 @@ ModelClass::ModelClass()
m_Textures.alphaPaths.clear();
}
ModelClass::~ModelClass()
model_class::~model_class()
{
// Destructor
Shutdown();
}
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, const TextureContainer& textures) {
bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, const TextureContainer& textures) {
bool result = Initialize(device, deviceContext, modelFilename);
if (!result) {
@@ -37,7 +37,7 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
return true;
}
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename) {
bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename) {
bool result;
@@ -61,7 +61,7 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
return true;
}
void ModelClass::Shutdown()
void model_class::Shutdown()
{
// Release the model textures.
ReleaseTextures();
@@ -76,7 +76,7 @@ void ModelClass::Shutdown()
}
void ModelClass::Render(ID3D11DeviceContext* deviceContext)
void model_class::Render(ID3D11DeviceContext* deviceContext)
{
// Put the vertex and index buffers on the graphics pipeline to prepare them for drawing.
RenderBuffers(deviceContext);
@@ -85,16 +85,16 @@ void ModelClass::Render(ID3D11DeviceContext* deviceContext)
}
int ModelClass::GetIndexCount()
int model_class::GetIndexCount()
{
return m_indexCount;
}
ID3D11ShaderResourceView* ModelClass::GetTexture(TextureType type, int index) const {
ID3D11ShaderResourceView* model_class::GetTexture(TextureType type, int index) const {
return m_Textures.GetTexture(type, index);
}
bool ModelClass::InitializeBuffers(ID3D11Device* device)
bool model_class::InitializeBuffers(ID3D11Device* device)
{
VertexType* vertices;
@@ -174,13 +174,13 @@ bool ModelClass::InitializeBuffers(ID3D11Device* device)
}
void ModelClass::ShutdownBuffers()
void model_class::ShutdownBuffers()
{
if (m_indexBuffer) { m_indexBuffer->Release(); m_indexBuffer = nullptr; }
if (m_vertexBuffer) { m_vertexBuffer->Release(); m_vertexBuffer = nullptr; }
}
void ModelClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
void model_class::RenderBuffers(ID3D11DeviceContext* deviceContext)
{
unsigned int stride;
unsigned int offset;
@@ -202,14 +202,14 @@ void ModelClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
return;
}
void ModelClass::ReleaseTextures()
void model_class::ReleaseTextures()
{
// Utilise la méthode ReleaseAll de TextureContainer
m_Textures.ReleaseAll();
}
bool ModelClass::LoadModel(char* filename)
bool model_class::LoadModel(char* filename)
{
std::string fileStr(filename);
@@ -232,7 +232,7 @@ bool ModelClass::LoadModel(char* filename)
}
}
bool ModelClass::LoadObjModel(char* filename)
bool model_class::LoadObjModel(char* filename)
{
// Lecture optimisée du fichier en mode binaire
std::ifstream fin(filename, std::ios::in | std::ios::binary);
@@ -338,7 +338,7 @@ bool ModelClass::LoadObjModel(char* filename)
return true;
}
bool ModelClass::LoadTxtModel(char* filename)
bool model_class::LoadTxtModel(char* filename)
{
ifstream fin;
char input;
@@ -394,7 +394,7 @@ bool ModelClass::LoadTxtModel(char* filename)
return true;
}
void ModelClass::CalculateModelVectors()
void model_class::CalculateModelVectors()
{
int faceCount, i, index;
TempVertexType vertex1, vertex2, vertex3;
@@ -459,7 +459,7 @@ void ModelClass::CalculateModelVectors()
}
}
void ModelClass::CalculateTangentBinormal(TempVertexType vertex1, TempVertexType vertex2, TempVertexType vertex3, VectorType& tangent, VectorType& binormal)
void model_class::CalculateTangentBinormal(TempVertexType vertex1, TempVertexType vertex2, TempVertexType vertex3, VectorType& tangent, VectorType& binormal)
{
float vector1[3], vector2[3];
@@ -513,7 +513,7 @@ void ModelClass::CalculateTangentBinormal(TempVertexType vertex1, TempVertexType
binormal.z = binormal.z / length;
}
void ModelClass::ReleaseModel()
void model_class::ReleaseModel()
{
if (m_model)
@@ -523,7 +523,7 @@ void ModelClass::ReleaseModel()
}
}
bool ModelClass::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer)
bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer)
{
HRESULT hResult;
@@ -582,7 +582,7 @@ bool ModelClass::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* devi
return true;
}
bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type, int index) {
bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type, int index) {
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
HRESULT result;
@@ -643,7 +643,7 @@ bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* device
return true;
}
bool ModelClass::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type) {
bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type) {
Logger::Get().Log("Adding texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
HRESULT result;
@@ -680,7 +680,7 @@ bool ModelClass::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCon
return true;
}
bool ModelClass::AddTexture(ID3D11ShaderResourceView* texture, TextureType type) {
bool model_class::AddTexture(ID3D11ShaderResourceView* texture, TextureType type) {
if (!texture) {
Logger::Get().Log("Cannot add null texture", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;

View File

@@ -2,9 +2,9 @@
#include <comdef.h>
#include "d3dclass.h"
#include "d_3d_class.h"
Object::Object()// Initialize the reference here
object::object()// initialize the reference here
{
m_scaleMatrix = XMMatrixIdentity();
m_rotateMatrix = XMMatrixIdentity();
@@ -20,68 +20,68 @@ Object::Object()// Initialize the reference here
m_boundingRadius = 1.0f;
}
Object::~Object()
object::~object()
{
}
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
void object::SetScaleMatrix(XMMATRIX scaleMatrix)
{
m_scaleMatrix = scaleMatrix;
}
void Object::SetRotateMatrix(XMMATRIX rotateMatrix)
void object::SetRotateMatrix(XMMATRIX rotateMatrix)
{
m_rotateMatrix = rotateMatrix;
}
void Object::SetTranslateMatrix(XMMATRIX translateMatrix)
void object::SetTranslateMatrix(XMMATRIX translateMatrix)
{
m_translateMatrix = translateMatrix;
}
void Object::SetSRMatrix(XMMATRIX srMatrix)
void object::SetSRMatrix(XMMATRIX srMatrix)
{
m_srMatrix = srMatrix;
}
void Object::SetWorldMatrix(XMMATRIX worldMatrix)
void object::SetWorldMatrix(XMMATRIX worldMatrix)
{
m_worldMatrix = worldMatrix;
}
XMMATRIX Object::GetScaleMatrix() const
XMMATRIX object::GetScaleMatrix() const
{
return m_scaleMatrix;
}
XMMATRIX Object::GetRotateMatrix() const
XMMATRIX object::GetRotateMatrix() const
{
return m_rotateMatrix;
}
XMMATRIX Object::GetTranslateMatrix() const
XMMATRIX object::GetTranslateMatrix() const
{
return m_translateMatrix;
}
XMMATRIX Object::GetSRMatrix() const
XMMATRIX object::GetSRMatrix() const
{
return m_srMatrix;
}
XMMATRIX Object::GetWorldMatrix() const
XMMATRIX object::GetWorldMatrix() const
{
return m_worldMatrix;
}
XMVECTOR Object::GetPosition()
XMVECTOR object::GetPosition()
{
XMFLOAT4X4 matrix;
XMStoreFloat4x4(&matrix, m_translateMatrix);
return XMVectorSet(matrix._41, matrix._42, matrix._43, 0.0f);
}
XMVECTOR Object::GetRotation()
XMVECTOR object::GetRotation()
{
XMFLOAT4X4 matrix;
XMStoreFloat4x4(&matrix, m_rotateMatrix);
@@ -91,7 +91,7 @@ XMVECTOR Object::GetRotation()
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
}
XMVECTOR Object::GetScale()
XMVECTOR object::GetScale()
{
XMFLOAT4X4 matrix;
XMStoreFloat4x4(&matrix, m_scaleMatrix);
@@ -114,7 +114,7 @@ XMVECTOR Object::GetScale()
void Object::SetPosition(XMVECTOR position)
void object::SetPosition(XMVECTOR position)
{
XMFLOAT4X4 matrix;
XMStoreFloat4x4(&matrix, m_translateMatrix);
@@ -124,7 +124,7 @@ void Object::SetPosition(XMVECTOR position)
m_translateMatrix = XMLoadFloat4x4(&matrix);
}
void Object::SetRotation(XMVECTOR rotation)
void object::SetRotation(XMVECTOR rotation)
{
XMFLOAT4X4 matrix;
XMStoreFloat4x4(&matrix, m_rotateMatrix);
@@ -132,7 +132,7 @@ void Object::SetRotation(XMVECTOR rotation)
m_rotateMatrix = rotationMatrix;
}
void Object::SetScale(XMVECTOR scale)
void object::SetScale(XMVECTOR scale)
{
XMFLOAT4X4 matrix;
XMStoreFloat4x4(&matrix, m_scaleMatrix);
@@ -142,32 +142,32 @@ void Object::SetScale(XMVECTOR scale)
m_scaleMatrix = XMLoadFloat4x4(&matrix);
}
void Object::UpdateWorldMatrix()
void object::UpdateWorldMatrix()
{
m_worldMatrix = m_scaleMatrix * m_rotateMatrix * m_translateMatrix;
}
void Object::UpdateSRMatrix()
void object::UpdateSRMatrix()
{
m_srMatrix = m_scaleMatrix * m_rotateMatrix;
}
void Object::UpdateTranslateMatrix()
void object::UpdateTranslateMatrix()
{
m_translateMatrix = XMMatrixTranslationFromVector(GetPosition());
}
void Object::UpdateRotateMatrix()
void object::UpdateRotateMatrix()
{
m_rotateMatrix = XMMatrixRotationRollPitchYawFromVector(GetRotation());
}
void Object::UpdateScaleMatrix()
void object::UpdateScaleMatrix()
{
m_scaleMatrix = XMMatrixScalingFromVector(GetScale());
}
void Object::Update()
void object::Update()
{
UpdateWorldMatrix();
UpdateSRMatrix();
@@ -176,99 +176,99 @@ void Object::Update()
UpdateScaleMatrix();
}
std::string Object::GetName()
std::string object::GetName()
{
return m_name;
}
void Object::SetName(std::string name)
void object::SetName(std::string name)
{
m_name = name;
}
void Object::SetVelocity(XMVECTOR velocity)
void object::SetVelocity(XMVECTOR velocity)
{
m_velocity = velocity;
}
void Object::AddVelocity(float deltaTime)
void object::AddVelocity(float deltaTime)
{
m_velocity += m_acceleration * deltaTime;
}
XMVECTOR Object::GetVelocity() const
XMVECTOR object::GetVelocity() const
{
return m_velocity;
}
void Object::SetAcceleration(XMVECTOR acceleration)
void object::SetAcceleration(XMVECTOR acceleration)
{
m_acceleration = acceleration;
}
XMVECTOR Object::GetAcceleration() const
XMVECTOR object::GetAcceleration() const
{
return m_acceleration;
}
void Object::SetMass(float mass)
void object::SetMass(float mass)
{
m_mass = mass;
}
float Object::GetMass() const
float object::GetMass() const
{
return m_mass;
}
void Object::SetGrounded(bool isGrounded)
void object::SetGrounded(bool isGrounded)
{
m_isGrounded = isGrounded;
}
bool Object::IsGrounded() const
bool object::IsGrounded() const
{
return m_isGrounded;
}
int Object::SetId(int id)
int object::SetId(int id)
{
return m_id = id;
}
int Object::GetId() const
int object::GetId() const
{
return m_id;
}
bool Object::IsPhysicsEnabled() const
bool object::IsPhysicsEnabled() const
{
return m_isPhysicsEnabled;
}
void Object::SetPhysicsEnabled(bool state)
void object::SetPhysicsEnabled(bool state)
{
m_isPhysicsEnabled = state;
}
float Object::GetBoundingRadius() const
float object::GetBoundingRadius() const
{
return m_boundingRadius;
}
void Object::UpdatePosition(float deltaTime)
void object::UpdatePosition(float deltaTime)
{
XMVECTOR position = GetPosition();
position = position + GetVelocity() * deltaTime;
SetPosition(position);
}
void Object::SetType(ObjectType type)
void object::SetType(ObjectType type)
{
m_type = type;
}
std::string Object::ObjectTypeToString(ObjectType type) {
std::string object::ObjectTypeToString(ObjectType type) {
switch (type) {
case ObjectType::Cube: return "Cube";
case ObjectType::Sphere: return "Sphere";
@@ -277,14 +277,14 @@ std::string Object::ObjectTypeToString(ObjectType type) {
}
}
ObjectType Object::StringToObjectType(const std::string& str) {
ObjectType object::StringToObjectType(const std::string& str) {
if (str == "Cube") return ObjectType::Cube;
if (str == "Sphere") return ObjectType::Sphere;
// Add other cases as needed
return ObjectType::Unknown;
}
std::string Object::ShaderTypeToString(ShaderType type) {
std::string object::ShaderTypeToString(ShaderType type) {
switch (type) {
case ShaderType::ALPHA_MAPPING: return "ALPHA_MAPPING";
case ShaderType::CEL_SHADING: return "CEL_SHADING";
@@ -298,7 +298,7 @@ std::string Object::ShaderTypeToString(ShaderType type) {
}
}
ShaderType Object::StringToShaderType(const std::string& str) {
ShaderType object::StringToShaderType(const std::string& str) {
if (str == "ALPHA_MAPPING") return ShaderType::ALPHA_MAPPING;
if (str == "CEL_SHADING") return ShaderType::CEL_SHADING;
if (str == "NORMAL_MAPPING") return ShaderType::NORMAL_MAPPING;
@@ -310,7 +310,7 @@ ShaderType Object::StringToShaderType(const std::string& str) {
return ShaderType::TEXTURE;
}
void Object::LaunchObject()
void object::LaunchObject()
{
// Constants
const float gravity = -9.81f;
@@ -352,8 +352,8 @@ void Object::LaunchObject()
OutputDebugStringA(buffer);
}
bool Object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
D3DClass* m_Direct3D)
bool object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
d_3d_class* m_Direct3D)
{
HRESULT result;
@@ -363,7 +363,7 @@ bool Object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, Textu
for (const auto& texturePath : texturePaths)
{
ID3D11ShaderResourceView* texture = nullptr;
result = DirectX::CreateWICTextureFromFile(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), texturePath.c_str(), nullptr, &texture);
result = DirectX::CreateWICTextureFromFile(m_Direct3D->get_device(), m_Direct3D->get_device_context(), texturePath.c_str(), nullptr, &texture);
if (FAILED(result))
{

View File

@@ -1,34 +1,34 @@
#include "physics.h"
Physics::Physics()
physics::physics()
{
m_gravity = XMVectorSet(0.0f, -9.81f, 0.0f, 0.0f); // Initialize the gravity vector
m_gravity = XMVectorSet(0.0f, -9.81f, 0.0f, 0.0f); // initialize the gravity vector
}
Physics::Physics(const Physics& other)
physics::physics(const physics& other)
{
m_gravity = other.m_gravity; // Copy the gravity value
}
Physics::~Physics()
physics::~physics()
{
}
// Get the gravity value
XMVECTOR Physics::GetGravity() const
XMVECTOR physics::GetGravity() const
{
return m_gravity;
}
// Define the gravity value
void Physics::SetGravity(XMVECTOR gravity)
void physics::SetGravity(XMVECTOR gravity)
{
m_gravity = gravity;
}
// Apply gravity to an object
void Physics::ApplyGravity(Object* object, float dragValue)
void physics::ApplyGravity(object* object, float dragValue)
{
if (this == nullptr || object == nullptr) // Verify if 'this' and 'object' are not null
{
@@ -60,7 +60,7 @@ void Physics::ApplyGravity(Object* object, float dragValue)
}
}
void Physics::AddForce(Object* object, XMVECTOR force)
void physics::AddForce(object* object, XMVECTOR force)
{
if (object == nullptr) // Verify if the object is not null
{
@@ -77,7 +77,7 @@ void Physics::AddForce(Object* object, XMVECTOR force)
object->SetAcceleration(object->GetAcceleration() + acceleration);
}
bool Physics::IsColliding(Object* object1, Object* object2)
bool physics::IsColliding(object* object1, object* object2)
{
ObjectType type1 = object1->GetType();
ObjectType type2 = object2->GetType();
@@ -116,7 +116,7 @@ bool Physics::IsColliding(Object* object1, Object* object2)
// AABB method for collision detection //
/////////////////////////////////////////
bool Physics::CubesOverlap(Object* cube1, Object* cube2)
bool physics::CubesOverlap(object* cube1, object* cube2)
{
XMVECTOR position1 = cube1->GetPosition();
XMVECTOR position2 = cube2->GetPosition();
@@ -134,7 +134,7 @@ bool Physics::CubesOverlap(Object* cube1, Object* cube2)
min1.m128_f32[2] <= max2.m128_f32[2] && max1.m128_f32[2] >= min2.m128_f32[2]);
}
bool Physics::SpheresOverlap(Object* sphere1, Object* sphere2)
bool physics::SpheresOverlap(object* sphere1, object* sphere2)
{
XMVECTOR position1 = sphere1->GetPosition();
XMVECTOR position2 = sphere2->GetPosition();
@@ -154,7 +154,7 @@ bool Physics::SpheresOverlap(Object* sphere1, Object* sphere2)
return distance < radius1 + radius2;
}
bool Physics::SphereCubeOverlap(Object* cube, Object* sphere)
bool physics::SphereCubeOverlap(object* cube, object* sphere)
{
XMVECTOR position1 = cube->GetPosition();
XMVECTOR position2 = sphere->GetPosition();

View File

@@ -1,6 +1,6 @@
#include "positionclass.h"
#include "position_class.h"
PositionClass::PositionClass()
position_class::position_class()
{
m_frameTime = 0.0f;
m_rotationY = 0.0f;
@@ -17,29 +17,29 @@ PositionClass::PositionClass()
}
PositionClass::PositionClass(const PositionClass& other)
position_class::position_class(const position_class& other)
{
}
PositionClass::~PositionClass()
position_class::~position_class()
{
}
void PositionClass::SetFrameTime(float time)
void position_class::SetFrameTime(float time)
{
m_frameTime = time;
return;
}
void PositionClass::GetRotation(float& y, float& x) const
void position_class::GetRotation(float& y, float& x) const
{
y = m_rotationY;
x = m_rotationX;
return;
}
void PositionClass::GetPosition(float& x, float& y, float& z) const
void position_class::GetPosition(float& x, float& y, float& z) const
{
x = m_positionX;
y = m_positionY;
@@ -47,7 +47,7 @@ void PositionClass::GetPosition(float& x, float& y, float& z) const
return;
}
void PositionClass::TurnLeft(bool keydown)
void position_class::TurnLeft(bool keydown)
{
// If the key is pressed increase the speed at which the camera turns left. If not slow down the turn speed.
if (keydown)
@@ -80,7 +80,7 @@ void PositionClass::TurnLeft(bool keydown)
}
void PositionClass::TurnRight(bool keydown)
void position_class::TurnRight(bool keydown)
{
// If the key is pressed increase the speed at which the camera turns right. If not slow down the turn speed.
if (keydown)
@@ -112,7 +112,7 @@ void PositionClass::TurnRight(bool keydown)
return;
}
void PositionClass::TurnMouse(float deltaX, float deltaY, float sensitivity, bool rightMouseDown)
void position_class::TurnMouse(float deltaX, float deltaY, float sensitivity, bool rightMouseDown)
{
// The turning speed is proportional to the horizontal mouse movement
m_horizontalTurnSpeed = deltaX * sensitivity;
@@ -147,7 +147,7 @@ void PositionClass::TurnMouse(float deltaX, float deltaY, float sensitivity, boo
return;
}
void PositionClass::MoveCamera(bool forward, bool backward, bool left, bool right, bool up, bool down, bool scrollUp, bool scrollDown, bool rightClick)
void position_class::MoveCamera(bool forward, bool backward, bool left, bool right, bool up, bool down, bool scrollUp, bool scrollDown, bool rightClick)
{
float radiansY, radiansX, speed;

Some files were not shown because too many files have changed in this diff Show More