This tiny routine sets a new origin, rotates and scales any thing between the two new commands...

` Transform2DON( rotateAngle#, translateX#, translateY#, scaleX#, scaleY# ) // Angle, new origin X and new origin Y coords`

... Normal 2D code goes here

Transform2DOFF()

file 1, quick demo...

`// --------------------------------- //`

// Project: Transform2D

// Start: Monday, November 16, 2015

// IDE Version: 12.312

// SETCURRENTDIR("Media") // go to media files

GLOBAL angle#

WHILE 1

X_MAKE2D

angle# = FMOD( angle# + 0.5, 360 )

Transform2DON( MOD( -angle#, 360 ) , 320, 240 )

FOR x = 0 TO 9

FOR y = 0 TO 9

DRAWRECT -400 + x*80, -400 + y*80, 80, 80, RGB(y*25.6, x*25.6, SIN(angle/2)*255 )

NEXT

NEXT

Transform2DOFF()

Transform2DON( angle# * 2 , 320 + COS(angle*2)*200, 240 + SIN(angle)*200, SIN(angle)*4, SIN(angle)*4 )

DRAWRECT -120, -50, 240, 100, RGB(SIN(angle/2)*255, 55, 0)

PRINT "ROTATE + TRANSLATE + SCALE", -100 ,0

Transform2DOFF()

SHOWSCREEN

WEND

file 2, the actual lib to rotate, translate and scale the 2D stuff...

`// --------------------------------- //`

// Project: Transform2D

// Start: Monday, November 16, 2015

// IDE Version: 12.312

INLINE

};

extern "C" void __stdcall glPushMatrix();

extern "C" void __stdcall glPopMatrix();

extern "C" void __stdcall glTranslatef( float, float, float );

extern "C" void __stdcall glScalef( float, float, float );

extern "C" void __stdcall glRotatef( float, float, float, float );

namespace __GLBASIC__ {

ENDINLINE

FUNCTION Transform2DON: rotateAngle#, translateX#, translateY#, scaleX# = 1.0, scaleY# = 1.0

INLINE

glPushMatrix();

glTranslatef(translateX, translateY, 0.0);

glScalef(scaleX, scaleY, 1);

glRotatef( rotateAngle, 0, 0, 1.0);

ENDINLINE

ENDFUNCTION

FUNCTION Transform2DOFF:

INLINE

glPopMatrix();

ENDINLINE

ENDFUNCTION

// Same stuff, just a little more flexible

FUNCTION Push2DMatrix: // Transformation On (Preserve current transformation matrix)

INLINE

glPushMatrix();

ENDINLINE

ENDFUNCTION

FUNCTION Pop2DMatrix: // Transformation Off (restore the previous transformation matrix)

INLINE

glPopMatrix();

ENDINLINE

ENDFUNCTION

FUNCTION Translate2D: translateX#, translateY# // Translate 2D

INLINE

glTranslatef(translateX, translateY, 0.0);

ENDINLINE

ENDFUNCTION

FUNCTION Rotate2D: rotateAngle# // Rotate 2D

INLINE

glRotatef( rotateAngle, 0, 0, 1.0);

ENDINLINE

ENDFUNCTION

FUNCTION Scale2D: scaleX#, scaleY# // Scale 2D

INLINE

glScalef(scaleX, scaleY, 1);

ENDINLINE

ENDFUNCTION

It should be very fast are all the work is being done on the GPU.

Edit: Small bug in translate fixed, using these 2D function as a matrix stack should work now.