#include "plugin_vc.h"
#include "game_vc\CSprite2d.h"
#include "game_vc\CFont.h"
using namespace plugin;
class ImageDraw {
public:
static RwRaster *LoadRasterFromBMP(char *filepath) {
RwImage *image = RtBMPImageRead(filepath);
if (image) {
int width, height, depth, format;
RwImageFindRasterFormat(image, rwRASTERTYPETEXTURE, &width, &height, &depth, &format);
RwRaster *raster = RwRasterCreate(width, height, depth, format);
RwRasterSetFromImage(raster, image);
RwImageDestroy(image);
return raster;
}
return nullptr;
}
ImageDraw() {
static RwRaster *gRaster = nullptr;
static int savedState;
Events::initRwEvent += [] {
gRaster = LoadRasterFromBMP(PLUGIN_PATH("image.bmp"));
};
Events::drawingEvent += [] {
if (gRaster) {
CSprite2d::DrawRect(CRect(0, 0, SCREEN_COORD_MAX_X, SCREEN_COORD_MAX_Y), CRGBA(0, 0, 0, 240));
static wchar_t tmpText[64];
CFont::SetColor(CRGBA(255, 255, 255, 255));
CFont::SetDropShadowPosition(0);
CFont::SetBackgroundOff();
CFont::SetFontStyle(1);
CFont::SetCentreOn();
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_COORD_MAX_X);
CFont::SetScale(SCREEN_MULTIPLIER(1.2f), SCREEN_MULTIPLIER(2.4f));
swprintf(tmpText, L"Raster: %dx%dx%d", gRaster->width, gRaster->height, gRaster->depth);
CFont::PrintString(SCREEN_COORD_LEFT(350.0f), SCREEN_COORD_TOP(620.0f), tmpText);
CFont::PrintString(SCREEN_COORD_LEFT(350.0f), SCREEN_COORD_TOP(670.0f), L"Filtering: NEAREST POINT");
swprintf(tmpText, L"Raster: %dx%dx%d", gRaster->width, gRaster->height, gRaster->depth);
CFont::PrintString(SCREEN_COORD_LEFT(900.0f), SCREEN_COORD_TOP(620.0f), tmpText);
CFont::PrintString(SCREEN_COORD_LEFT(900.0f), SCREEN_COORD_TOP(670.0f), L"Filtering: LINEAR");
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, gRaster);
RwRenderStateGet(rwRENDERSTATETEXTUREFILTER, &savedState);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, RWRSTATE(rwFILTERNEAREST));
CSprite2d::SetVertices(CRect(SCREEN_COORD_LEFT(100.0f), SCREEN_COORD_TOP(100.0f), SCREEN_COORD_LEFT(600.0f), SCREEN_COORD_TOP(600.0f)),
CRGBA(255, 255, 255, 255), CRGBA(255, 255, 255, 255), CRGBA(255, 255, 255, 255), CRGBA(255, 255, 255, 255));
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, RWRSTATE(rwFILTERLINEAR));
CSprite2d::SetVertices(CRect(SCREEN_COORD_LEFT(650.0f), SCREEN_COORD_TOP(100.0f), SCREEN_COORD_LEFT(1150.0f), SCREEN_COORD_TOP(600.0f)),
CRGBA(255, 255, 255, 255), CRGBA(255, 255, 255, 255), CRGBA(255, 255, 255, 255), CRGBA(255, 255, 255, 255));
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, RWRSTATE(savedState));
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nullptr);
}
};
Events::shutdownRwEvent += [] {
if (gRaster)
RwRasterDestroy(gRaster);
};
}
} plg;