C++ Game Framework  2013-06-04
CGF is a DirectX 11 game framework, built in C++ and DirectX 11. This is used to contain many to the DirectX functionality and wrap them into a framework to make game development easier.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ColorLine.h
Go to the documentation of this file.
1 // Filename: ColorLine.h
4 
5 //Preprocessor directive designed to cause the current source file to be included only once in a single compilation
6 #pragma once
7 
8 //Includes
9 #include <d3d11.h>
10 #include <DirectXMath.h>
11 #include "CGFInclude.h"
12 #include "CGFException.h"
13 #include "CGFMath.h"
14 #include "IGraphicsObject.h"
15 #include "Vector2f.h"
16 #include "Color4f.h"
17 #include "GameContainer.h"
18 
19 namespace CGF
20 {
21  typedef std::pair<Vector2f, Vector2f> LinePosition;
22 
24  {
25  friend class GraphicsDevice;
26 
27  private:
28  struct VertexType
29  {
30  XMFLOAT3 position;
31  XMFLOAT4 color;
32  };
33 
34  public:
35  ColorLine(const Vector2f position1, const Vector2f position2, GameContainer* game);
36  ColorLine(const Vector2f position1, const Vector2f position2, const Color4f color, GameContainer* game);
37  ~ColorLine();
38 
39  LinePosition GetPosition();
40  void SetPosition(Vector2f position1, Vector2f position2);
41 
42  private:
43  void Render(ID3D11DeviceContext* deviceContext);
44  XMMATRIX GetTransformMatrix();
45 
46  private:
47  bool InitializeBuffers(ID3D11Device*);
48  void ShutdownBuffers();
49  void RenderBuffers(ID3D11DeviceContext* deviceContext);
50  bool UpdateBuffers(ID3D11DeviceContext* deviceContext);
51 
52  private:
53  ID3D11Buffer* m_vertexBuffer;
54  ID3D11Buffer* m_indexBuffer;
55  int m_vertexCount;
56  VertexType* m_vertices;
58  Vector2f m_position1;
59  Vector2f m_position2;
60  bool m_isUpdated;
61  };
62 }