ref: gl: implement rotation for 2D

This commit is contained in:
Alibek Omarov
2025-10-19 03:17:08 +05:00
parent ea2c864265
commit 4dabb5d1f9
3 changed files with 23 additions and 7 deletions

View File

@@ -365,11 +365,8 @@ static void GAME_EXPORT R_SetupSky( int *skyboxTextures )
static qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int offset_y, float scale_x, float scale_y )
{
qboolean ret = true;
if( rotate > 0 )
{
gEngfuncs.Con_Printf("rotation transform not supported\n");
ret = false;
}
tr.rotation = rotate;
if( offset_x || offset_y )
{

View File

@@ -215,10 +215,27 @@ void R_Set2DMode( qboolean enable )
return;
// set 2D virtual screen size
pglViewport( 0, 0, gpGlobals->width, gpGlobals->height );
switch( tr.rotation )
{
case REF_ROTATE_CW:
pglViewport( 0, 0, gpGlobals->height, gpGlobals->width );
Matrix4x4_CreateOrtho( projection_matrix, 0, gpGlobals->height, gpGlobals->width, 0, -99999, 99999 );
Matrix4x4_ConcatRotate( projection_matrix, 90, 0, 0, 1 );
Matrix4x4_ConcatTranslate( projection_matrix, 0, -gpGlobals->height, 0 );
break;
case REF_ROTATE_CCW:
pglViewport( 0, 0, gpGlobals->height, gpGlobals->width );
Matrix4x4_CreateOrtho( projection_matrix, 0, gpGlobals->height, gpGlobals->width, 0, -99999, 99999 );
Matrix4x4_ConcatRotate( projection_matrix, -90, 0, 0, 1 );
Matrix4x4_ConcatTranslate( projection_matrix, -gpGlobals->width, 0, 0 );
break;
default:
pglViewport( 0, 0, gpGlobals->width, gpGlobals->height );
Matrix4x4_CreateOrtho( projection_matrix, 0, gpGlobals->width, gpGlobals->height, 0, -99999, 99999 );
break;
}
pglMatrixMode( GL_PROJECTION );
Matrix4x4_CreateOrtho( projection_matrix, 0, gpGlobals->width, gpGlobals->height, 0, -99999, 99999 );
GL_LoadMatrix( projection_matrix );
pglMatrixMode( GL_MODELVIEW );

View File

@@ -263,6 +263,8 @@ typedef struct
uint *screengammatable;
uint max_entities;
ref_screen_rotation_t rotation;
} gl_globals_t;
typedef struct