Implemented Set2DWindow

This commit is contained in:
OM 2023-05-15 17:27:05 +02:00
parent 0e1b92a5eb
commit 2af3dee1d8
3 changed files with 31 additions and 8 deletions

View file

@ -443,7 +443,7 @@ void RB_BeginDrawingView (void) {
// we will need to change the projection matrix before drawing
// 2D images again
backEnd.projection2D = qfalse;
backEnd.in2D = qfalse;
//
// set the modelview matrix for the viewer
@ -751,7 +751,7 @@ RB_SetGL2D
================
*/
void RB_SetGL2D (void) {
backEnd.projection2D = qtrue;
backEnd.in2D = qtrue;
// set 2D virtual screen size
qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
@ -902,7 +902,7 @@ const void *RB_StretchPic ( const void *data ) {
cmd = (const stretchPicCommand_t *)data;
if ( !backEnd.projection2D ) {
if ( !backEnd.in2D ) {
RB_SetGL2D();
}
@ -1029,7 +1029,7 @@ void RB_ShowImages( void ) {
float x, y, w, h;
int start, end;
if ( !backEnd.projection2D ) {
if ( !backEnd.in2D ) {
RB_SetGL2D();
}
@ -1122,7 +1122,7 @@ const void *RB_SwapBuffers( const void *data ) {
GLimp_EndFrame();
backEnd.projection2D = qfalse;
backEnd.in2D = qfalse;
return (const void *)(cmd + 1);
}

View file

@ -364,7 +364,30 @@ Set2DWindow
================
*/
void Set2DWindow( int x, int y, int w, int h, float left, float right, float bottom, float top, float n, float f ) {
// FIXME: unimplemented
R_SyncRenderThread();
qglViewport(x, y, w, h);
qglScissor(x, y, w, h);
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity();
qglOrtho(left, right, bottom, top, n, f);
qglMatrixMode(GL_MODELVIEW);
qglLoadIdentity();
GL_State(GLS_SET2D | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA);
qglEnable(GL_BLEND);
qglDisable(GL_CULL_FACE);
qglDisable(GL_CLIP_PLANE0);
if (r_reset_tc_array->integer) {
qglDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (!backEnd.in2D)
{
backEnd.refdef.time = ri.Milliseconds();
backEnd.in2D = 1;
backEnd.refdef.floatTime = backEnd.refdef.time / 1000.0;
}
}
/*

View file

@ -1200,8 +1200,7 @@ typedef struct {
sphereor_t hudSphere;
cStaticModelUnpacked_t* currentStaticModel;
int dsStreamVert;
qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes
qboolean in2D; // if qtrue, drawstretchpic doesn't need to change modes
byte color2D[4];
qboolean vertexes2D; // shader needs to be finished
trRefEntity_t entity2D; // currentEntity will point at this when doing 2D rendering
@ -1609,6 +1608,7 @@ void GL_Cull( int cullType );
#define GLS_DSTBLEND_BITS 0x000000f0
#define GLS_DEPTHMASK_TRUE 0x00000100
#define GLS_SET2D 0x00000400
#define GLS_POLYMODE_LINE 0x00001000