mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 12:30:32 +00:00
- Extended fake Shape2D.
This commit is contained in:
parent
9df4683056
commit
4e3f294453
4 changed files with 95 additions and 0 deletions
|
@ -131,8 +131,51 @@ DEFINE_ACTION_FUNCTION(_Screen, PaletteColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dummy ZScript arbitrary textured shape drawing
|
// Dummy ZScript arbitrary textured shape drawing
|
||||||
|
IMPLEMENT_CLASS(DShape2DTransform, false, false)
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(DShape2DTransform, Clear)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(DShape2DTransform, Rotate)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
||||||
|
PARAM_FLOAT(angle);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(DShape2DTransform, Scale)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
||||||
|
PARAM_FLOAT(x);
|
||||||
|
PARAM_FLOAT(y);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(DShape2DTransform, Translate)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
||||||
|
PARAM_FLOAT(x);
|
||||||
|
PARAM_FLOAT(y);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DShape2D, false, false)
|
IMPLEMENT_CLASS(DShape2D, false, false)
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(DShape2D, SetTransform)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DShape2D);
|
||||||
|
PARAM_OBJECT(transform, DShape2DTransform);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2D, Clear)
|
DEFINE_ACTION_FUNCTION(DShape2D, Clear)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2D);
|
PARAM_SELF_PROLOGUE(DShape2D);
|
||||||
|
|
|
@ -209,6 +209,14 @@ struct VMVa_List
|
||||||
const uint8_t *reginfo;
|
const uint8_t *reginfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DShape2DTransform : public DObject
|
||||||
|
{
|
||||||
|
|
||||||
|
DECLARE_CLASS(DShape2DTransform, DObject)
|
||||||
|
public:
|
||||||
|
DMatrix3x3 transform;
|
||||||
|
};
|
||||||
|
|
||||||
// intermediate struct for fake shape drawing
|
// intermediate struct for fake shape drawing
|
||||||
|
|
||||||
enum EClearWhich
|
enum EClearWhich
|
||||||
|
@ -226,6 +234,11 @@ public:
|
||||||
TArray<int> mIndices;
|
TArray<int> mIndices;
|
||||||
TArray<DVector2> mVertices;
|
TArray<DVector2> mVertices;
|
||||||
TArray<DVector2> mCoords;
|
TArray<DVector2> mCoords;
|
||||||
|
|
||||||
|
DMatrix3x3 transform;
|
||||||
|
|
||||||
|
bool dirty = true;
|
||||||
|
TArray<DVector2> mTransformedVertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -979,6 +979,35 @@ Outside comments: A faster version with only 10 (not 24) multiplies.
|
||||||
|
|
||||||
TMatrix3x3(const Vector3 &axis, TAngle<vec_t> degrees);
|
TMatrix3x3(const Vector3 &axis, TAngle<vec_t> degrees);
|
||||||
|
|
||||||
|
static TMatrix3x3 Rotate2D(double radians)
|
||||||
|
{
|
||||||
|
double c = g_cos(radians);
|
||||||
|
double s = g_sin(radians);
|
||||||
|
TMatrix3x3 ret;
|
||||||
|
ret.Cells[0][0] = c; ret.Cells[0][1] = -s; ret.Cells[0][2] = 0;
|
||||||
|
ret.Cells[1][0] = s; ret.Cells[1][1] = c; ret.Cells[1][2] = 0;
|
||||||
|
ret.Cells[2][0] = 0; ret.Cells[2][1] = 0; ret.Cells[2][2] = 1;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static TMatrix3x3 Scale2D(TVector2<vec_t> scaleVec)
|
||||||
|
{
|
||||||
|
TMatrix3x3 ret;
|
||||||
|
ret.Cells[0][0] = scaleVec.X; ret.Cells[0][1] = 0; ret.Cells[0][2] = 0;
|
||||||
|
ret.Cells[1][0] = 0; ret.Cells[1][1] = scaleVec.Y; ret.Cells[1][2] = 0;
|
||||||
|
ret.Cells[2][0] = 0; ret.Cells[2][1] = 0; ret.Cells[2][2] = 1;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static TMatrix3x3 Translate2D(TVector2<vec_t> translateVec)
|
||||||
|
{
|
||||||
|
TMatrix3x3 ret;
|
||||||
|
ret.Cells[0][0] = 1; ret.Cells[0][1] = 0; ret.Cells[0][2] = translateVec.X;
|
||||||
|
ret.Cells[1][0] = 0; ret.Cells[1][1] = 1; ret.Cells[1][2] = translateVec.Y;
|
||||||
|
ret.Cells[2][0] = 0; ret.Cells[2][1] = 0; ret.Cells[2][2] = 1;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void Zero()
|
void Zero()
|
||||||
{
|
{
|
||||||
memset (this, 0, sizeof *this);
|
memset (this, 0, sizeof *this);
|
||||||
|
|
|
@ -172,6 +172,14 @@ enum DrawTextureTags
|
||||||
DTA_Monospace, // Strings only: Use a fixed distance between characters.
|
DTA_Monospace, // Strings only: Use a fixed distance between characters.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Shape2DTransform : Object native
|
||||||
|
{
|
||||||
|
native void Clear();
|
||||||
|
native void Rotate(double angle);
|
||||||
|
native void Scale(Vector2 scaleVec);
|
||||||
|
native void Translate(Vector2 translateVec);
|
||||||
|
}
|
||||||
|
|
||||||
class Shape2D : Object native
|
class Shape2D : Object native
|
||||||
{
|
{
|
||||||
enum EClearWhich
|
enum EClearWhich
|
||||||
|
@ -181,6 +189,8 @@ class Shape2D : Object native
|
||||||
C_Indices = 4,
|
C_Indices = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
native void SetTransform(Shape2DTransform transform);
|
||||||
|
|
||||||
native void Clear( int which = C_Verts|C_Coords|C_Indices );
|
native void Clear( int which = C_Verts|C_Coords|C_Indices );
|
||||||
native void PushVertex( Vector2 v );
|
native void PushVertex( Vector2 v );
|
||||||
native void PushCoord( Vector2 c );
|
native void PushCoord( Vector2 c );
|
||||||
|
|
Loading…
Reference in a new issue