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
12#include <raylib.h>
14#include "fsINative.h"
15class fsIImage;
16
17
19{
20 friend class fsITexture;
21
22public:
23
24 void initialiseScreenDo(fsPoint pDimensions);
25 void initialiseSolutionDo(const fsIImage* pSolution);
26
29
30protected:
31
32 void targetSetDo() override;
33 void targetClearDo() override;
34
35
36
37 void renderDo() override;
38
39private:
40
41 struct fsSMutableTexture
42 {
43 ~fsSMutableTexture();
44 fsSMutableTexture(fsS32 pW, fsS32 pH, const fsSColour4B& pCol = {0,0,0,0}, fsS32 pBpp = 32);
45 void paint(fsS32 x, fsS32 y)
46 {
47 mPixels[y * stride() + x * bytesPerPixel() + 0] = mPaintColour.mR;
48 mPixels[y * stride() + x * bytesPerPixel() + 1] = mPaintColour.mG;
49 mPixels[y * stride() + x * bytesPerPixel() + 2] = mPaintColour.mB;
50 mPixels[y * stride() + x * bytesPerPixel() + 3] = mPaintColour.mA;
51 }
52
53 fsSColour4B get(fsS32 x, fsS32 y) const
54 {
55 return fsSColour4B(
56 mPixels[y * stride() + x * bytesPerPixel() + 0],
57 mPixels[y * stride() + x * bytesPerPixel() + 1],
58 mPixels[y * stride() + x * bytesPerPixel() + 2],
59 mPixels[y * stride() + x * bytesPerPixel() + 3]);
60 }
61
62 fsU32 bytesPerPixel() const { return mBpp / 8; }
63 fsS32 stride() const { return mWidth * bytesPerPixel(); }
64 fsS32 len() const { return stride() * mHeight; }
65 fsS32 mWidth;
66 fsS32 mHeight;
67 fsU32 mBpp;
68 fsU8* mPixels;
69 fsSColour4B mPaintColour;
70 };
71
72 void updateDynamicTexturePixels() const;
73 void getDynamicTexturePixels();
74
75 static void pixelCallback(const unsigned char* pPixels, std::size_t pWidth, std::size_t pHeigth);
76
77 static fsSMutableTexture* mCurrMutableTexture;
78
79 RenderTexture2D mDynamicTexture;
80 Shader mShader;
81
82};
83
84#endif
Definition fsCNativeRenderTexture.h:31
void initialiseScreenDo(fsPoint pDimensions)
void renderDo() override
friend class fsITexture
Definition fsCNativeRenderTexture.h:32
void targetSetDo() override
void initialiseSolutionDo(const fsIImage *pSolution)
void targetClearDo() override
~fsCNativeRenderTexture() override
Definition fsIImage.h:21
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 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