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
28
29
30 void renderDo() override;
31 void matrixApplyDo(fsAffineMtx2d const& pTransform) override;
32
33private:
34
35 struct fsSMutableTexture
36 {
37 ~fsSMutableTexture();
38 fsSMutableTexture(fsS32 pW, fsS32 pH, const fsSColour4B& pCol = {0,0,0,0}, fsS32 pBpp = 32);
39 void paint(fsS32 x, fsS32 y)
40 {
41 mPixels[y * stride() + x * bytesPerPixel() + 0] = mPaintColour.mR;
42 mPixels[y * stride() + x * bytesPerPixel() + 1] = mPaintColour.mG;
43 mPixels[y * stride() + x * bytesPerPixel() + 2] = mPaintColour.mB;
44 mPixels[y * stride() + x * bytesPerPixel() + 3] = mPaintColour.mA;
45 }
46
47 fsSColour4B get(fsS32 x, fsS32 y) const
48 {
49 return fsSColour4B(
50 mPixels[y * stride() + x * bytesPerPixel() + 0],
51 mPixels[y * stride() + x * bytesPerPixel() + 1],
52 mPixels[y * stride() + x * bytesPerPixel() + 2],
53 mPixels[y * stride() + x * bytesPerPixel() + 3]);
54 }
55
56 fsU32 bytesPerPixel() const { return mBpp / 8; }
57 fsS32 stride() const { return mWidth * bytesPerPixel(); }
58 fsS32 len() const { return stride() * mHeight; }
59 fsS32 mWidth;
60 fsS32 mHeight;
61 fsU32 mBpp;
62 fsU8* mPixels;
63 fsSColour4B mPaintColour;
64 };
65
66 void updateDynamicTexturePixels() const;
67 void getDynamicTexturePixels();
68
69 static void pixelCallback(const unsigned char* pPixels, std::size_t pWidth, std::size_t pHeigth);
70
71 static fsSMutableTexture* mCurrMutableTexture;
72};
73
74#endif
Definition fsAffineMtx2d.h:27
Definition fsCNativeRenderTexture.h:31
void matrixApplyDo(fsAffineMtx2d const &pTransform) override
void renderDo() override
friend class fsITexture
Definition fsCNativeRenderTexture.h:32
~fsCNativeRenderTexture() override
Definition fsIRenderableTexture.h:39
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 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