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
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

#include "fsCNativeRenderTexture.h"

#include "rlgl.h"

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

#include <fsAppCore/fsIDisplay.h>
#include <fsAppCore/fsIInputManager.h>

fsCNativeRenderTexture::fsSMutableTexture* fsCNativeRenderTexture::mCurrMutableTexture;

#if defined(PLATFORM_DESKTOP)
    #define GLSL_VERSION            330
#else   // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
    #define GLSL_VERSION            100
#endif

void fsCNativeRenderTexture::initialiseScreenDo(fsPoint pDimensions){<--- The member function 'fsCNativeRenderTexture::initialiseScreenDo' can be static.
    // TODO
}

void fsCNativeRenderTexture::initialiseSolutionDo(fsIImage* pSolution){<--- The member function 'fsCNativeRenderTexture::initialiseSolutionDo' can be static.<--- Parameter 'pSolution' can be declared as pointer to const
    // TODO
}

void fsCNativeRenderTexture::targetSetDo()
{
    Vector2 mousePos {
            static_cast<fsF32>(fsIInputManager::instanceGet()->mousePosGet().x),
            -static_cast<fsF32>(fsIInputManager::instanceGet()->mousePosGet().y)
                    + fsIDisplay::instanceGet()->designCanvasHeightGet()
    };
    SetShaderValue(mShader,
            GetShaderLocation(mShader, "u_mousePos"),
            &mousePos,
            SHADER_UNIFORM_VEC2);
    BeginTextureMode(mDynamicTexture);
}

void fsCNativeRenderTexture::targetClearDo()
{
    fsIRenderer::instanceGet()->flush();
    EndTextureMode();

    BeginShaderMode(mShader);

    rlPushMatrix();
    rlMultMatrixf(&mRenderMatrix[0]);

    DrawTextureRec(mDynamicTexture.texture, 
        { 0, 0,
            static_cast<float>(mDynamicTexture.texture.width),
            static_cast<float>(-mDynamicTexture.texture.height) },
            { 0, 0 }, RED);
    
    rlPopMatrix();

    EndShaderMode();
}

void fsCNativeRenderTexture::saveDo(fsCResourceName const& pFilename)
{
}

void fsCNativeRenderTexture::pixelCallback(const unsigned char* pPixels, std::size_t pWidth, std::size_t pHeigth)
{
}

void fsCNativeRenderTexture::getDynamicTexturePixels()<--- The member function 'fsCNativeRenderTexture::getDynamicTexturePixels' can be static.
{
}

void fsCNativeRenderTexture::updateDynamicTexturePixels() const<--- The member function 'fsCNativeRenderTexture::updateDynamicTexturePixels' can be static.
{
}

void fsCNativeRenderTexture::recolourDo(fsSColour4B const& pOld, fsSColour4B const& pNew)
{
}

void fsCNativeRenderTexture::paintDo(std::vector<fsPoint> const& pPos, fsSColour4B const& pColour)
{
}

void fsCNativeRenderTexture::paintWithSpriteBrushDo(fsPoint const& pPos)
{
}

void fsCNativeRenderTexture::renderDo()
{
}

void fsCNativeRenderTexture::brushSetDo(fsCResourceName const& pBrushFilename)
{
}

fsCNativeRenderTexture::fsCNativeRenderTexture():
fsIRenderableTexture()
{
    const auto size = fsPoint{
        fsIDisplay::instanceGet()->visibleCanvasWidthGet(),
        fsIDisplay::instanceGet()->visibleCanvasHeightGet()};

    mDynamicTexture = LoadRenderTexture(size.x, size.y);
    mShader = LoadShader(0, TextFormat("resources/shaders/zoomtorch_cx.fsh", GLSL_VERSION));
    auto canvasSize = Vector2{
        static_cast<fsF32>(fsIDisplay::instanceGet()->designCanvasWidthGet()),
        static_cast<fsF32>(fsIDisplay::instanceGet()->designCanvasHeightGet())};
    SetShaderValue(mShader,
        GetShaderLocation(mShader, "u_resolution"),
        &canvasSize,
        SHADER_UNIFORM_VEC2);
}

fsCNativeRenderTexture::~fsCNativeRenderTexture()
{
}

fsCNativeRenderTexture::fsSMutableTexture::fsSMutableTexture(fsS32 pW, fsS32 pH, const fsSColour4B& pCol, fsS32 pBpp)
{
}

fsCNativeRenderTexture::fsSMutableTexture::~fsSMutableTexture()
{
}