Move to common (todo: merge with above)

This commit is contained in:
Henrik Rydgård committed 2022-08-03 14:12:55 +02:00
1 parent d55c4a3456
commit 1d3075566f
5 files changed
+58 -62

No files matched your search

+57 -2
View File
@@ -23,6 +23,9 @@
#include "Common/GPU/OpenGL/GLFeatures.h"
#include "Common/Data/Convert/ColorConv.h"
#include "Common/Data/Text/I18n.h"
#include "Common/Math/lin/matrix4x4.h"
#include "Common/Math/math_util.h"
#include "Common/System/Display.h"
#include "Common/CommonTypes.h"
#include "Core/Config.h"
#include "Core/ConfigValues.h"
@@ -44,8 +47,7 @@
#include "GPU/GPUState.h"
FramebufferManagerCommon::FramebufferManagerCommon(Draw::DrawContext *draw)
: draw_(draw),
displayFormat_(GE_FORMAT_565) {
: draw_(draw), displayFormat_(GE_FORMAT_565) {
presentation_ = new PresentationCommon(draw);
}
@@ -2504,3 +2506,56 @@ void FramebufferManagerCommon::DeviceRestore(Draw::DrawContext *draw) {
draw_ = draw;
presentation_->DeviceRestore(draw);
}
void FramebufferManagerCommon::DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags) {
// Will be drawn as a strip.
Draw2DVertex coord[4] = {
{x, y, u0, v0},
{x + w, y, u1, v0},
{x + w, y + h, u1, v1},
{x, y + h, u0, v1},
};
if (uvRotation != ROTATION_LOCKED_HORIZONTAL) {
float temp[8];
int rotation = 0;
switch (uvRotation) {
case ROTATION_LOCKED_HORIZONTAL180: rotation = 2; break;
case ROTATION_LOCKED_VERTICAL: rotation = 1; break;
case ROTATION_LOCKED_VERTICAL180: rotation = 3; break;
}
for (int i = 0; i < 4; i++) {
temp[i * 2] = coord[((i + rotation) & 3)].u;
temp[i * 2 + 1] = coord[((i + rotation) & 3)].v;
}
for (int i = 0; i < 4; i++) {
coord[i].u = temp[i * 2];
coord[i].v = temp[i * 2 + 1];
}
}
const float invDestW = 2.0f / destW;
const float invDestH = 2.0f / destH;
for (int i = 0; i < 4; i++) {
coord[i].x = coord[i].x * invDestW - 1.0f;
coord[i].y = coord[i].y * invDestH - 1.0f;
}
if ((flags & DRAWTEX_TO_BACKBUFFER) && g_display_rotation != DisplayRotation::ROTATE_0) {
for (int i = 0; i < 4; i++) {
// backwards notation, should fix that...
Lin::Vec3 pos = Lin::Vec3(coord[i].x, coord[i].y, 0.0);
pos = pos * g_display_rot_matrix;
coord[i].x = pos.x;
coord[i].y = pos.y;
}
}
// Rearrange to strip form.
std::swap(coord[2], coord[3]);
DrawStrip2D(nullptr, coord, 4);
gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
}