mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 14:51:46 +00:00
Merge pull request #701 from Doom2fan/DirectNativeShape2D
Added direct-native versions of the Shape2D API.
This commit is contained in:
commit
c64fafc490
1 changed files with 73 additions and 28 deletions
|
@ -37,54 +37,77 @@ EXTERN_CVAR(Float, transsouls)
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DShape2DTransform, false, false)
|
IMPLEMENT_CLASS(DShape2DTransform, false, false)
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2DTransform, Clear)
|
static void Shape2DTransform_Clear(DShape2DTransform* self)
|
||||||
|
{
|
||||||
|
self->transform.Identity();
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2DTransform, Clear, Shape2DTransform_Clear)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
||||||
self->transform.Identity();
|
Shape2DTransform_Clear(self);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2DTransform, Rotate)
|
static void Shape2DTransform_Rotate(DShape2DTransform* self, double angle)
|
||||||
|
{
|
||||||
|
self->transform = DMatrix3x3::Rotate2D(DEG2RAD(angle)) * self->transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2DTransform, Rotate, Shape2DTransform_Rotate)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
||||||
PARAM_FLOAT(angle);
|
PARAM_FLOAT(angle);
|
||||||
self->transform = DMatrix3x3::Rotate2D(DEG2RAD(angle)) * self->transform;
|
Shape2DTransform_Rotate(self, angle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2DTransform, Scale)
|
static void Shape2DTransform_Scale(DShape2DTransform* self, double x, double y)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
|
||||||
PARAM_FLOAT(x);
|
|
||||||
PARAM_FLOAT(y);
|
|
||||||
self->transform = DMatrix3x3::Scale2D(DVector2(x, y)) * self->transform;
|
self->transform = DMatrix3x3::Scale2D(DVector2(x, y)) * self->transform;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2DTransform, Translate)
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2DTransform, Scale, Shape2DTransform_Scale)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
||||||
PARAM_FLOAT(x);
|
PARAM_FLOAT(x);
|
||||||
PARAM_FLOAT(y);
|
PARAM_FLOAT(y);
|
||||||
|
Shape2DTransform_Scale(self, x, y);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Shape2DTransform_Translate(DShape2DTransform* self, double x, double y)
|
||||||
|
{
|
||||||
self->transform = DMatrix3x3::Translate2D(DVector2(x, y)) * self->transform;
|
self->transform = DMatrix3x3::Translate2D(DVector2(x, y)) * self->transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2DTransform, Translate, Shape2DTransform_Translate)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DShape2DTransform);
|
||||||
|
PARAM_FLOAT(x);
|
||||||
|
PARAM_FLOAT(y);
|
||||||
|
Shape2DTransform_Translate(self, x, y);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DShape2D, false, false)
|
IMPLEMENT_CLASS(DShape2D, false, false)
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2D, SetTransform)
|
static void Shape2D_SetTransform(DShape2D* self, DShape2DTransform *transform)
|
||||||
|
{
|
||||||
|
self->transform = transform->transform;
|
||||||
|
self->dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, SetTransform, Shape2D_SetTransform)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2D);
|
PARAM_SELF_PROLOGUE(DShape2D);
|
||||||
PARAM_OBJECT(transform, DShape2DTransform);
|
PARAM_OBJECT(transform, DShape2DTransform);
|
||||||
self->transform = transform->transform;
|
Shape2D_SetTransform(self, transform);
|
||||||
self->dirty = true;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2D, Clear)
|
static void Shape2D_Clear(DShape2D* self, int which)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2D);
|
|
||||||
PARAM_INT(which);
|
|
||||||
if (which & C_Verts)
|
if (which & C_Verts)
|
||||||
{
|
{
|
||||||
self->mVertices.Clear();
|
self->mVertices.Clear();
|
||||||
|
@ -92,37 +115,59 @@ DEFINE_ACTION_FUNCTION(DShape2D, Clear)
|
||||||
}
|
}
|
||||||
if (which & C_Coords) self->mCoords.Clear();
|
if (which & C_Coords) self->mCoords.Clear();
|
||||||
if (which & C_Indices) self->mIndices.Clear();
|
if (which & C_Indices) self->mIndices.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, Clear, Shape2D_Clear)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DShape2D);
|
||||||
|
PARAM_INT(which);
|
||||||
|
Shape2D_Clear(self, which);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2D, PushVertex)
|
static void Shape2D_PushVertex(DShape2D* self, double x, double y)
|
||||||
|
{
|
||||||
|
self->mVertices.Push(DVector2(x, y));
|
||||||
|
self->dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushVertex, Shape2D_PushVertex)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2D);
|
PARAM_SELF_PROLOGUE(DShape2D);
|
||||||
PARAM_FLOAT(x);
|
PARAM_FLOAT(x);
|
||||||
PARAM_FLOAT(y);
|
PARAM_FLOAT(y);
|
||||||
self->mVertices.Push(DVector2(x,y));
|
Shape2D_PushVertex(self, x, y);
|
||||||
self->dirty = true;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2D, PushCoord)
|
static void Shape2D_PushCoord(DShape2D* self, double u, double v)
|
||||||
|
{
|
||||||
|
self->mCoords.Push(DVector2(u, v));
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushCoord, Shape2D_PushCoord)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2D);
|
PARAM_SELF_PROLOGUE(DShape2D);
|
||||||
PARAM_FLOAT(u);
|
PARAM_FLOAT(u);
|
||||||
PARAM_FLOAT(v);
|
PARAM_FLOAT(v);
|
||||||
self->mCoords.Push(DVector2(u,v));
|
Shape2D_PushCoord(self, u, v);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DShape2D, PushTriangle)
|
static void Shape2D_PushTriangle(DShape2D* self, int a, int b, int c)
|
||||||
|
{
|
||||||
|
self->mIndices.Push(a);
|
||||||
|
self->mIndices.Push(b);
|
||||||
|
self->mIndices.Push(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushTriangle, Shape2D_PushTriangle)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DShape2D);
|
PARAM_SELF_PROLOGUE(DShape2D);
|
||||||
PARAM_INT(a);
|
PARAM_INT(a);
|
||||||
PARAM_INT(b);
|
PARAM_INT(b);
|
||||||
PARAM_INT(c);
|
PARAM_INT(c);
|
||||||
self->mIndices.Push(a);
|
Shape2D_PushTriangle(self, a, b, c);
|
||||||
self->mIndices.Push(b);
|
|
||||||
self->mIndices.Push(c);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue