mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-10 15:17:52 +00:00
ref_soft: restore fallback gl1 blitter (force enable with -glblit)
This commit is contained in:
parent
c8eac04e9b
commit
86867dcbe3
23
r_context.c
23
r_context.c
@ -314,15 +314,6 @@ void GAME_EXPORT GL_SetTexCoordArrayMode( void )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GAME_EXPORT GL_InitExtensions( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void GAME_EXPORT GL_ClearExtensions( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GAME_EXPORT GL_BackendStartFrame( void )
|
void GAME_EXPORT GL_BackendStartFrame( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -432,20 +423,6 @@ byte *GAME_EXPORT Mod_GetCurrentVis( void )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GAME_EXPORT GL_SetupAttributes( int safegl )
|
|
||||||
{
|
|
||||||
gEngfuncs.Con_Reportf( "Creating an extended GL context for debug...\n" );
|
|
||||||
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_FLAGS, REF_GL_CONTEXT_DEBUG_FLAG );
|
|
||||||
|
|
||||||
// untill we have any blitter in ref api, setup GL
|
|
||||||
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_COMPATIBILITY );
|
|
||||||
gEngfuncs.GL_SetAttribute( REF_GL_DOUBLEBUFFER, 1 );
|
|
||||||
|
|
||||||
gEngfuncs.GL_SetAttribute( REF_GL_RED_SIZE, 5 );
|
|
||||||
gEngfuncs.GL_SetAttribute( REF_GL_GREEN_SIZE, 6 );
|
|
||||||
gEngfuncs.GL_SetAttribute( REF_GL_BLUE_SIZE, 5 );
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *R_GetConfigName( void )
|
const char *R_GetConfigName( void )
|
||||||
{
|
{
|
||||||
return "ref_soft"; // software specific cvars will go to ref_soft.cfg
|
return "ref_soft"; // software specific cvars will go to ref_soft.cfg
|
||||||
|
205
r_glblit.c
205
r_glblit.c
@ -6,6 +6,10 @@ struct swblit_s
|
|||||||
uint stride;
|
uint stride;
|
||||||
uint bpp;
|
uint bpp;
|
||||||
uint rmask, gmask, bmask;
|
uint rmask, gmask, bmask;
|
||||||
|
void *(*pLockBuffer)( void );
|
||||||
|
void (*pUnlockBuffer)( void );
|
||||||
|
void *(*pCreateBuffer)( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
|
||||||
|
|
||||||
} swblit;
|
} swblit;
|
||||||
|
|
||||||
|
|
||||||
@ -41,10 +45,122 @@ static void APIENTRY GL_DebugOutput( GLuint source, GLuint type, GLuint id, GLui
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned short *buffer;
|
|
||||||
|
|
||||||
|
static unsigned short *glbuf;
|
||||||
|
static int tex;
|
||||||
|
|
||||||
#define LOAD(x) p##x = gEngfuncs.GL_GetProcAddress(#x)
|
#define LOAD(x) p##x = gEngfuncs.GL_GetProcAddress(#x)
|
||||||
|
|
||||||
|
|
||||||
|
void GAME_EXPORT GL_SetupAttributes( int safegl )
|
||||||
|
{
|
||||||
|
gEngfuncs.Con_Reportf( "Creating an extended GL context for debug...\n" );
|
||||||
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_FLAGS, REF_GL_CONTEXT_DEBUG_FLAG );
|
||||||
|
|
||||||
|
// untill we have any blitter in ref api, setup GL
|
||||||
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_COMPATIBILITY );
|
||||||
|
gEngfuncs.GL_SetAttribute( REF_GL_DOUBLEBUFFER, 1 );
|
||||||
|
|
||||||
|
gEngfuncs.GL_SetAttribute( REF_GL_RED_SIZE, 5 );
|
||||||
|
gEngfuncs.GL_SetAttribute( REF_GL_GREEN_SIZE, 6 );
|
||||||
|
gEngfuncs.GL_SetAttribute( REF_GL_BLUE_SIZE, 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GAME_EXPORT GL_InitExtensions( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GAME_EXPORT GL_ClearExtensions( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *R_Lock_GL1( void )
|
||||||
|
{
|
||||||
|
return glbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_Unlock_GL1( void )
|
||||||
|
{
|
||||||
|
pglViewport( 0, 0, gpGlobals->width, gpGlobals->height );
|
||||||
|
pglMatrixMode( GL_PROJECTION );
|
||||||
|
pglLoadIdentity();
|
||||||
|
pglOrtho( 0, gpGlobals->width, gpGlobals->height, 0, -99999, 99999 );
|
||||||
|
pglMatrixMode( GL_MODELVIEW );
|
||||||
|
pglLoadIdentity();
|
||||||
|
|
||||||
|
pglEnable( GL_TEXTURE_2D );
|
||||||
|
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
|
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf );
|
||||||
|
//gEngfuncs.Con_Printf("%d\n",pglGetError());
|
||||||
|
pglBegin( GL_QUADS );
|
||||||
|
pglTexCoord2f( 0, 0 );
|
||||||
|
pglVertex2f( 0, 0 );
|
||||||
|
|
||||||
|
pglTexCoord2f( 1, 0 );
|
||||||
|
pglVertex2f( vid.width, 0 );
|
||||||
|
|
||||||
|
pglTexCoord2f( 1, 1 );
|
||||||
|
pglVertex2f( vid.width, vid.height );
|
||||||
|
|
||||||
|
pglTexCoord2f( 0, 1 );
|
||||||
|
pglVertex2f( 0, vid.height );
|
||||||
|
pglEnd();
|
||||||
|
pglDisable( GL_TEXTURE_2D );
|
||||||
|
gEngfuncs.GL_SwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *R_CreateBuffer_GL1( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b )
|
||||||
|
{
|
||||||
|
|
||||||
|
LOAD(glBegin);
|
||||||
|
LOAD(glEnd);
|
||||||
|
LOAD(glTexCoord2f);
|
||||||
|
LOAD(glVertex2f);
|
||||||
|
LOAD(glEnable);
|
||||||
|
LOAD(glDisable);
|
||||||
|
LOAD(glTexImage2D);
|
||||||
|
LOAD(glOrtho);
|
||||||
|
LOAD(glMatrixMode);
|
||||||
|
LOAD(glLoadIdentity);
|
||||||
|
LOAD(glViewport);
|
||||||
|
LOAD(glBindTexture);
|
||||||
|
LOAD(glDebugMessageCallbackARB);
|
||||||
|
LOAD(glDebugMessageControlARB);
|
||||||
|
LOAD(glGetError);
|
||||||
|
LOAD(glGenTextures);
|
||||||
|
LOAD(glTexParameteri);
|
||||||
|
#ifdef GLDEBUG
|
||||||
|
if( gpGlobals->developer )
|
||||||
|
{
|
||||||
|
gEngfuncs.Con_Reportf( "Installing GL_DebugOutput...\n");
|
||||||
|
pglDebugMessageCallbackARB( GL_DebugOutput, NULL );
|
||||||
|
|
||||||
|
// force everything to happen in the main thread instead of in a separate driver thread
|
||||||
|
pglEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB );
|
||||||
|
}
|
||||||
|
|
||||||
|
// enable all the low priority messages
|
||||||
|
pglDebugMessageControlARB( GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, true );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( glbuf )
|
||||||
|
Mem_Free(glbuf);
|
||||||
|
glbuf = Mem_Malloc( r_temppool, width*height*2 );
|
||||||
|
*stride = width;
|
||||||
|
*bpp = 2;
|
||||||
|
*r = MASK(5) << 6 + 5;
|
||||||
|
*g = MASK(6) << 5;
|
||||||
|
*b = MASK(5);
|
||||||
|
return glbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int FIRST_BIT( uint mask )
|
static int FIRST_BIT( uint mask )
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
@ -256,43 +372,22 @@ void R_BuildBlendMaps( void )
|
|||||||
|
|
||||||
void R_AllocScreen( void );
|
void R_AllocScreen( void );
|
||||||
|
|
||||||
void R_InitBlit(void)
|
void R_InitBlit( qboolean glblit )
|
||||||
{
|
{
|
||||||
|
|
||||||
/*LOAD(glBegin);
|
|
||||||
LOAD(glEnd);
|
|
||||||
LOAD(glTexCoord2f);
|
|
||||||
LOAD(glVertex2f);
|
|
||||||
LOAD(glEnable);
|
|
||||||
LOAD(glDisable);
|
|
||||||
LOAD(glTexImage2D);
|
|
||||||
LOAD(glOrtho);
|
|
||||||
LOAD(glMatrixMode);
|
|
||||||
LOAD(glLoadIdentity);
|
|
||||||
LOAD(glViewport);
|
|
||||||
LOAD(glBindTexture);
|
|
||||||
LOAD(glDebugMessageCallbackARB);
|
|
||||||
LOAD(glDebugMessageControlARB);
|
|
||||||
LOAD(glGetError);
|
|
||||||
LOAD(glGenTextures);
|
|
||||||
LOAD(glTexParameteri);*/
|
|
||||||
#ifdef GLDEBUG
|
|
||||||
if( gpGlobals->developer )
|
|
||||||
{
|
|
||||||
gEngfuncs.Con_Reportf( "Installing GL_DebugOutput...\n");
|
|
||||||
pglDebugMessageCallbackARB( GL_DebugOutput, NULL );
|
|
||||||
|
|
||||||
// force everything to happen in the main thread instead of in a separate driver thread
|
|
||||||
pglEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB );
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable all the low priority messages
|
|
||||||
pglDebugMessageControlARB( GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, true );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//buffer = Mem_Malloc( r_temppool, 1920*1080*2 );
|
|
||||||
|
|
||||||
R_BuildBlendMaps();
|
R_BuildBlendMaps();
|
||||||
|
|
||||||
|
if( glblit )
|
||||||
|
{
|
||||||
|
swblit.pLockBuffer = R_Lock_GL1;
|
||||||
|
swblit.pUnlockBuffer = R_Unlock_GL1;
|
||||||
|
swblit.pCreateBuffer = R_CreateBuffer_GL1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
swblit.pLockBuffer = gEngfuncs.SW_LockBuffer;
|
||||||
|
swblit.pUnlockBuffer = gEngfuncs.SW_UnlockBuffer;
|
||||||
|
swblit.pCreateBuffer = gEngfuncs.SW_CreateBuffer;
|
||||||
|
}
|
||||||
R_AllocScreen();
|
R_AllocScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +399,7 @@ void R_AllocScreen( void )
|
|||||||
gpGlobals->height = 200;
|
gpGlobals->height = 200;
|
||||||
|
|
||||||
R_InitCaches();
|
R_InitCaches();
|
||||||
gEngfuncs.SW_CreateBuffer( gpGlobals->width, gpGlobals->height, &swblit.stride, &swblit.bpp,
|
swblit.pCreateBuffer( gpGlobals->width, gpGlobals->height, &swblit.stride, &swblit.bpp,
|
||||||
&swblit.rmask, &swblit.gmask, &swblit.bmask);
|
&swblit.rmask, &swblit.gmask, &swblit.bmask);
|
||||||
R_BuildScreenMap();
|
R_BuildScreenMap();
|
||||||
vid.width = gpGlobals->width;
|
vid.width = gpGlobals->width;
|
||||||
@ -323,7 +418,7 @@ void R_BlitScreen( void )
|
|||||||
{
|
{
|
||||||
//memset( vid.buffer, 10, vid.width * vid.height );
|
//memset( vid.buffer, 10, vid.width * vid.height );
|
||||||
int u, v;
|
int u, v;
|
||||||
void *buffer = gEngfuncs.SW_LockBuffer();
|
void *buffer = swblit.pLockBuffer();
|
||||||
if( !buffer || gpGlobals->width != vid.width || gpGlobals->height != vid.height )
|
if( !buffer || gpGlobals->width != vid.width || gpGlobals->height != vid.height )
|
||||||
{
|
{
|
||||||
R_AllocScreen();
|
R_AllocScreen();
|
||||||
@ -383,37 +478,5 @@ void R_BlitScreen( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
swblit.pUnlockBuffer();
|
||||||
pglViewport( 0, 0, gpGlobals->width, gpGlobals->height );
|
|
||||||
pglMatrixMode( GL_PROJECTION );
|
|
||||||
pglLoadIdentity();
|
|
||||||
pglOrtho( 0, gpGlobals->width, gpGlobals->height, 0, -99999, 99999 );
|
|
||||||
pglMatrixMode( GL_MODELVIEW );
|
|
||||||
pglLoadIdentity();
|
|
||||||
|
|
||||||
pglEnable( GL_TEXTURE_2D );
|
|
||||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
|
|
||||||
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer );
|
|
||||||
//gEngfuncs.Con_Printf("%d\n",pglGetError());
|
|
||||||
pglBegin( GL_QUADS );
|
|
||||||
pglTexCoord2f( 0, 0 );
|
|
||||||
pglVertex2f( 0, 0 );
|
|
||||||
|
|
||||||
pglTexCoord2f( 1, 0 );
|
|
||||||
pglVertex2f( vid.width, 0 );
|
|
||||||
|
|
||||||
pglTexCoord2f( 1, 1 );
|
|
||||||
pglVertex2f( vid.width, vid.height );
|
|
||||||
|
|
||||||
pglTexCoord2f( 0, 1 );
|
|
||||||
pglVertex2f( 0, vid.height );
|
|
||||||
pglEnd();
|
|
||||||
pglDisable( GL_TEXTURE_2D );
|
|
||||||
gEngfuncs.GL_SwapBuffers();
|
|
||||||
// memset( vid.buffer, 0, vid.width * vid.height * 2 );
|
|
||||||
#else
|
|
||||||
gEngfuncs.SW_UnlockBuffer();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -1235,7 +1235,7 @@ void R_DrawBrushModel(cl_entity_t *pent);
|
|||||||
//
|
//
|
||||||
void R_InitCaches (void);
|
void R_InitCaches (void);
|
||||||
void R_BlitScreen( void );
|
void R_BlitScreen( void );
|
||||||
void R_InitBlit( void );
|
void R_InitBlit( qboolean gl );
|
||||||
|
|
||||||
//
|
//
|
||||||
// r_edge.c
|
// r_edge.c
|
||||||
|
21
r_main.c
21
r_main.c
@ -1788,7 +1788,7 @@ void GAME_EXPORT R_EndFrame( void )
|
|||||||
// flush any remaining 2D bits
|
// flush any remaining 2D bits
|
||||||
R_Set2DMode( false );
|
R_Set2DMode( false );
|
||||||
|
|
||||||
// blit pixels with GL until engine supports REF_SOFT context
|
// blit pixels
|
||||||
R_BlitScreen();
|
R_BlitScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1925,6 +1925,8 @@ void R_InitTurb (void)
|
|||||||
|
|
||||||
qboolean GAME_EXPORT R_Init( void )
|
qboolean GAME_EXPORT R_Init( void )
|
||||||
{
|
{
|
||||||
|
qboolean glblit = false;
|
||||||
|
|
||||||
gl_emboss_scale = gEngfuncs.Cvar_Get( "gl_emboss_scale", "0", FCVAR_ARCHIVE|FCVAR_LATCH, "fake bumpmapping scale" );
|
gl_emboss_scale = gEngfuncs.Cvar_Get( "gl_emboss_scale", "0", FCVAR_ARCHIVE|FCVAR_LATCH, "fake bumpmapping scale" );
|
||||||
vid_gamma = gEngfuncs.pfnGetCvarPointer( "gamma", 0 );
|
vid_gamma = gEngfuncs.pfnGetCvarPointer( "gamma", 0 );
|
||||||
r_norefresh = gEngfuncs.Cvar_Get( "r_norefresh", "0", 0, "disable 3D rendering (use with caution)" );
|
r_norefresh = gEngfuncs.Cvar_Get( "r_norefresh", "0", 0, "disable 3D rendering (use with caution)" );
|
||||||
@ -1969,18 +1971,25 @@ qboolean GAME_EXPORT R_Init( void )
|
|||||||
tracerblue = gEngfuncs.Cvar_Get( "tracerblue", "0.4", 0, "tracer blue component weight ( 0 - 1.0 )" );
|
tracerblue = gEngfuncs.Cvar_Get( "tracerblue", "0.4", 0, "tracer blue component weight ( 0 - 1.0 )" );
|
||||||
traceralpha = gEngfuncs.Cvar_Get( "traceralpha", "0.5", 0, "tracer alpha amount ( 0 - 1.0 )" );
|
traceralpha = gEngfuncs.Cvar_Get( "traceralpha", "0.5", 0, "tracer alpha amount ( 0 - 1.0 )" );
|
||||||
|
|
||||||
// create the window and set up the context
|
r_temppool = Mem_AllocPool( "ref_soft zone" );
|
||||||
r_temppool = Mem_AllocPool( "ref_sw zone" );
|
|
||||||
|
|
||||||
if( !gEngfuncs.R_Init_Video( REF_SOFTWARE )) // request GL context
|
glblit = !!gEngfuncs.Sys_CheckParm( "-glblit" );
|
||||||
|
|
||||||
|
// create the window and set up the context
|
||||||
|
if( !glblit && !gEngfuncs.R_Init_Video( REF_SOFTWARE )) // request software blitter
|
||||||
{
|
{
|
||||||
gEngfuncs.R_Free_Video();
|
gEngfuncs.R_Free_Video();
|
||||||
|
gEngfuncs.Con_Printf("failed to initialize software blitter, fallback to glblit\n");
|
||||||
|
glblit = true;
|
||||||
|
}
|
||||||
|
|
||||||
gEngfuncs.Host_Error( "Can't initialize video subsystem\nProbably driver was not installed" );
|
if( glblit && !gEngfuncs.R_Init_Video( REF_GL )) // request GL context
|
||||||
|
{
|
||||||
|
gEngfuncs.R_Free_Video();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_InitBlit();
|
R_InitBlit( glblit );
|
||||||
|
|
||||||
R_InitImages();
|
R_InitImages();
|
||||||
// init draw stack
|
// init draw stack
|
||||||
|
Loading…
Reference in New Issue
Block a user