mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Implement GraphicsDrawer::copyTexturedRect
This commit is contained in:
parent
5ce4a4328e
commit
704378777d
|
@ -1389,3 +1389,86 @@ void GraphicsDrawer::clearColorBuffer(float *_pColor)
|
||||||
else
|
else
|
||||||
gfxContext.clearColorBuffer(0.0f, 0.0f, 0.0f, 0.0f);
|
gfxContext.clearColorBuffer(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsDrawer::copyTexturedRect(const CopyRectParams & _params)
|
||||||
|
{
|
||||||
|
m_drawingState = DrawingState::TexRect;
|
||||||
|
|
||||||
|
const float scaleX = 1.0f / _params.dstWidth;
|
||||||
|
const float scaleY = 1.0f / _params.dstHeight;
|
||||||
|
const float X0 = _params.dstX0 * (2.0f * scaleX) - 1.0f;
|
||||||
|
const float Y0 = _params.dstY0 * (2.0f * scaleY) - 1.0f;
|
||||||
|
const float X1 = _params.dstX1 * (2.0f * scaleX) - 1.0f;
|
||||||
|
const float Y1 = _params.dstY1 * (2.0f * scaleY) - 1.0f;
|
||||||
|
const float Z = 1.0f;
|
||||||
|
const float W = 1.0f;
|
||||||
|
|
||||||
|
m_rect[0].x = X0;
|
||||||
|
m_rect[0].y = Y0;
|
||||||
|
m_rect[0].z = Z;
|
||||||
|
m_rect[0].w = W;
|
||||||
|
m_rect[1].x = X1;
|
||||||
|
m_rect[1].y = Y0;
|
||||||
|
m_rect[1].z = Z;
|
||||||
|
m_rect[1].w = W;
|
||||||
|
m_rect[2].x = X0;
|
||||||
|
m_rect[2].y = Y1;
|
||||||
|
m_rect[2].z = Z;
|
||||||
|
m_rect[2].w = W;
|
||||||
|
m_rect[3].x = X1;
|
||||||
|
m_rect[3].y = Y1;
|
||||||
|
m_rect[3].z = Z;
|
||||||
|
m_rect[3].w = W;
|
||||||
|
|
||||||
|
const float scaleS = 1.0f / _params.srcWidth;
|
||||||
|
const float scaleT = 1.0f / _params.srcHeight;
|
||||||
|
|
||||||
|
const float S0 = _params.srcX0 * scaleS;
|
||||||
|
const float S1 = _params.srcX1 * scaleS;
|
||||||
|
const float T0 = _params.srcY0 * scaleT;
|
||||||
|
const float T1 = _params.srcY1 * scaleT;
|
||||||
|
|
||||||
|
m_rect[0].s0 = S0;
|
||||||
|
m_rect[0].t0 = T0;
|
||||||
|
m_rect[1].s0 = S1;
|
||||||
|
m_rect[1].t0 = T0;
|
||||||
|
m_rect[2].s0 = S0;
|
||||||
|
m_rect[2].t0 = T1;
|
||||||
|
m_rect[3].s0 = S1;
|
||||||
|
m_rect[3].t0 = T1;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < 2; ++i) {
|
||||||
|
CachedTexture * tex = _params.tex[i];
|
||||||
|
if (tex == nullptr)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Context::TexParameters texParams;
|
||||||
|
texParams.handle = graphics::ObjectHandle(tex->glName);
|
||||||
|
texParams.textureUnitIndex = graphics::textureIndices::Tex[i];
|
||||||
|
texParams.target = tex->frameBufferTexture == CachedTexture::fbMultiSample ?
|
||||||
|
graphics::target::TEXTURE_2D_MULTISAMPLE : graphics::target::TEXTURE_2D;
|
||||||
|
texParams.minFilter = _params.filter;
|
||||||
|
texParams.magFilter = _params.filter;
|
||||||
|
texParams.wrapS = graphics::textureParameters::WRAP_CLAMP_TO_EDGE;
|
||||||
|
texParams.wrapT = graphics::textureParameters::WRAP_CLAMP_TO_EDGE;
|
||||||
|
gfxContext.setTextureParameters(texParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
gfxContext.setViewport(0, 0, _params.dstWidth, _params.dstHeight);
|
||||||
|
gfxContext.enable(graphics::enable::CULL_FACE, false);
|
||||||
|
gfxContext.enable(graphics::enable::BLEND, false);
|
||||||
|
gfxContext.enable(graphics::enable::DEPTH_TEST, false);
|
||||||
|
gfxContext.enable(graphics::enable::SCISSOR_TEST, false);
|
||||||
|
gfxContext.enableDepthWrite(false);
|
||||||
|
|
||||||
|
Context::DrawRectParameters rectParams;
|
||||||
|
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
||||||
|
rectParams.rectColor.fill(0.0f);
|
||||||
|
rectParams.verticesCount = 4;
|
||||||
|
rectParams.vertices = m_rect;
|
||||||
|
rectParams.combiner = _params.combiner;
|
||||||
|
gfxContext.drawRects(rectParams);
|
||||||
|
|
||||||
|
gSP.changed |= CHANGED_GEOMETRYMODE | CHANGED_VIEWPORT;
|
||||||
|
gDP.changed |= CHANGED_RENDERMODE | CHANGED_TILE | CHANGED_COMBINE | CHANGED_SCISSOR;
|
||||||
|
}
|
|
@ -78,10 +78,26 @@ public:
|
||||||
|
|
||||||
void drawTexturedRect(const TexturedRectParams & _params);
|
void drawTexturedRect(const TexturedRectParams & _params);
|
||||||
|
|
||||||
void copyTexturedRect(u32 _srcX0, u32 _srcY0, u32 _srcX1, u32 _srcY1,
|
struct CopyRectParams
|
||||||
u32 _srcWidth, u32 _srcHeight, u32 _srcTex,
|
{
|
||||||
s32 _dstX0, s32 _dstY0, s32 _dstX1, s32 _dstY1,
|
s32 srcX0 = 0;
|
||||||
u32 _dstWidth, u32 _dstHeight, graphics::Parameter _filter);
|
s32 srcY0 = 0;
|
||||||
|
s32 srcX1;
|
||||||
|
s32 srcY1;
|
||||||
|
u32 srcWidth;
|
||||||
|
u32 srcHeight;
|
||||||
|
s32 dstX0 = 0;
|
||||||
|
s32 dstY0 = 0;
|
||||||
|
s32 dstX1;
|
||||||
|
s32 dstY1;
|
||||||
|
u32 dstWidth;
|
||||||
|
u32 dstHeight;
|
||||||
|
std::array<CachedTexture *, 2> tex{ { nullptr, nullptr } };
|
||||||
|
graphics::CombinerProgram * combiner = nullptr;
|
||||||
|
graphics::Parameter filter;
|
||||||
|
};
|
||||||
|
|
||||||
|
void copyTexturedRect(const CopyRectParams & _params);
|
||||||
|
|
||||||
void drawText(const char *_pText, float x, float y);
|
void drawText(const char *_pText, float x, float y);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user