1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/********************************************************************
*
*	File:		fsCNativeSprite.h
*
*	Purpose:	Sprite that is added to and retained by a scene. All
*				positioning / parenting is handled in the scene
*
*********************************************************************/

#ifndef fsCNativeSpritehdr
#define fsCNativeSpritehdr

#include <Magnum/Math/Matrix4.h>
#include <Magnum/GL/GL.h>
#include <Magnum/GL/Mesh.h>
#include <Magnum/Shaders/FlatGL.h>

#include <fsCore/fsBaseTypes.h>
#include <fsCore/fsAffineMtx2d.h>

#include "fsINative.h"

class fsSColour;
class fsAffineMtx2d;
class fsCBrush;
struct fsPoint;


class fsCNativeSprite : public fsINative
{
	friend class fsCNativeSpriteRenderData;

public:

	static Magnum::Shaders::FlatGL3D  *mShader;
	static Magnum::Matrix4 projectionMatrix;

	fsBool hitTest(const fsPoint& pLocalPos, fsBool pRequireHitMap) const;

	fsS32 widthGet() const;
	fsS32 heightGet() const;

	std::shared_ptr<fsCBrush> brushGet() const;

	virtual ~fsCNativeSprite();<--- Destructor in derived class

protected:

	void polygonInfoSetDo(fsIRenderData::fsSPolyInfo const& pPolyInfo) override;<--- Function in derived class

	void textureWrapSetDo() override;<--- Function in derived class
	void renderDo() override;
	void matrixApplyDo(const fsAffineMtx2d& pRenderMatrix) override;
	void colourSetDo(const fsSColour4B& pColour) override;<--- Function in derived class

	void uvSetDo(const fsRect& pOffest) override;<--- Function in derived class
	void vertsSetDo(std::vector<fsVec2d> const& pVerts) override;<--- Function in derived class
	void widthSetDo(fsS32 pWidth) override;<--- Function in derived class
	void heightSetDo(fsS32 pHeight) override;<--- Function in derived class
	void brushSetDo(std::shared_ptr<fsCBrush> pBrush) override;
	void alphaBlendModeSetDo(fsS32 pAlphaBlendMode) override;<--- Function in derived class

	fsCNativeSprite();

private:

	fsS32 mWidth;
	fsS32 mHeight;

	fsS32 mScreenWidth;
	fsS32 mScreenHeight;

	struct TriangleVertex {
		Magnum::Vector2 position;
		Magnum::Vector2 textureCoordinates;
	};
	
	std::shared_ptr<fsCBrush> mBrush;

	Magnum::Math::Matrix4<fsF32> mRenderMatrix;
	Magnum::GL::Texture2D* mTexture;
	Magnum::GL::Mesh mMesh;

};


#endif