Fission FSN
Loading...
Searching...
No Matches
fsCNativeRenderTexture.h
Go to the documentation of this file.
1/********************************************************************
2*
3* File: fsCRenderTexture.h
4*
5* Purpose: Cocos2d-x implementation of a render texture.
6*
7*********************************************************************/
8
9#ifndef fsCNativeRenderTexturehdr
10#define fsCNativeRenderTexturehdr
11
13#include "fsINative.h"
14
15
17{
18 friend class fsITexture;
19
20public:
21
24
25protected:
26
27 void brushSetDo(fsCResourceName const& pBrushFilename) override;
28 void saveDo(fsCResourceName const& pFilename) override;
29
30
31 void recolourDo(fsSColour4B const& pOld, fsSColour4B const& pNew) override;
32 void paintWithSpriteBrushDo(fsPoint const& pPos) override;
33 void paintDo(std::vector<fsPoint> const& pPos, fsSColour4B const& pColour) override;
34
35 void renderDo() override;
36 void matrixApplyDo(fsAffineMtx2d const& pTransform) override;
37
38private:
39
40 struct fsSMutableTexture
41 {
42 ~fsSMutableTexture();
43 fsSMutableTexture(fsS32 pW, fsS32 pH, const fsSColour4B& pCol = {0,0,0,0}, fsS32 pBpp = 32);
44 void paint(fsS32 x, fsS32 y)
45 {
46 mPixels[y * stride() + x * bytesPerPixel() + 0] = mPaintColour.mR;
47 mPixels[y * stride() + x * bytesPerPixel() + 1] = mPaintColour.mG;
48 mPixels[y * stride() + x * bytesPerPixel() + 2] = mPaintColour.mB;
49 mPixels[y * stride() + x * bytesPerPixel() + 3] = mPaintColour.mA;
50 }
51
52 fsSColour4B get(fsS32 x, fsS32 y) const
53 {
54 return fsSColour4B(
55 mPixels[y * stride() + x * bytesPerPixel() + 0],
56 mPixels[y * stride() + x * bytesPerPixel() + 1],
57 mPixels[y * stride() + x * bytesPerPixel() + 2],
58 mPixels[y * stride() + x * bytesPerPixel() + 3]);
59 }
60
61 fsU32 bytesPerPixel() const { return mBpp / 8; }
62 fsS32 stride() const { return mWidth * bytesPerPixel(); }
63 fsS32 len() const { return stride() * mHeight; }
64 fsS32 mWidth;
65 fsS32 mHeight;
66 fsU32 mBpp;
67 fsU8* mPixels;
68 fsSColour4B mPaintColour;
69 };
70
71 void updateDynamicTexturePixels() const;
72 void getDynamicTexturePixels();
73
74 static void pixelCallback(const unsigned char* pPixels, std::size_t pWidth, std::size_t pHeigth);
75
76 static fsSMutableTexture* mCurrMutableTexture;
77};
78
79#endif
Definition fsAffineMtx2d.h:27
Definition fsCNativeRenderTexture.h:31
void paintWithSpriteBrushDo(fsPoint const &pPos) override
void matrixApplyDo(fsAffineMtx2d const &pTransform) override
void saveDo(fsCResourceName const &pFilename) override
void renderDo() override
void paintDo(std::vector< fsPoint > const &pPos, fsSColour4B const &pColour) override
friend class fsITexture
Definition fsCNativeRenderTexture.h:32
void recolourDo(fsSColour4B const &pOld, fsSColour4B const &pNew) override
virtual ~fsCNativeRenderTexture()
void brushSetDo(fsCResourceName const &pBrushFilename) override
Definition fsCResourceName.h:32
Definition fsIRenderableTexture.h:38
unsigned int fsU32
Definition fsBaseTypes.h:21
unsigned char fsU8
Definition fsBaseTypes.h:15
int fsS32
Definition fsBaseTypes.h:20
decltype(sizeof(void *)) size_t
Definition doctest.h:524
Definition fsPoint.h:17
Definition fsSColour.h:54
fsU8 mG
Definition fsSColour.h:82
fsU8 mR
Definition fsSColour.h:81
fsU8 mB
Definition fsSColour.h:83
fsU8 mA
Definition fsSColour.h:84