mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2025-02-21 11:21:32 +00:00
removed r_stencilbits r_depthbits r_colorbits r_texturebits r_ext_compressed_textures
This commit is contained in:
parent
9ea5d021d5
commit
eb4b1d8615
7 changed files with 39 additions and 262 deletions
|
@ -1,6 +1,8 @@
|
|||
|
||||
DD Mmm 17 - 1.49
|
||||
|
||||
chg: removed r_stencilbits, r_depthbits, r_colorbits, r_texturebits and r_ext_compressed_textures
|
||||
|
||||
chg: using stb_image to load png and tga images
|
||||
|
||||
fix: libjpeg errors no longer shut down the engine
|
||||
|
|
|
@ -347,31 +347,11 @@ static void Upload32( image_t* image, unsigned int* data )
|
|||
// validate and/or override the internal format
|
||||
switch (image->format) {
|
||||
case GL_RGB:
|
||||
/* if ( flags & IMG_NOIMANIP ) {
|
||||
;
|
||||
} else */
|
||||
if ( r_ext_compressed_textures->integer ) {
|
||||
image->format = GL_COMPRESSED_RGB_ARB;
|
||||
}
|
||||
else if ( r_texturebits->integer == 16 ) {
|
||||
image->format = GL_RGB5;
|
||||
}
|
||||
else if ( r_texturebits->integer == 32 ) {
|
||||
image->format = GL_RGB8;
|
||||
}
|
||||
image->format = GL_RGB8;
|
||||
break;
|
||||
|
||||
case GL_RGBA:
|
||||
/* compressed RGBA *still* somehow manages to suck ass, even with DXT5
|
||||
if ( r_ext_compressed_textures->integer ) {
|
||||
format = GL_COMPRESSED_RGBA_ARB;
|
||||
} else */
|
||||
if ( r_texturebits->integer == 16 ) {
|
||||
image->format = GL_RGBA4;
|
||||
}
|
||||
else if ( r_texturebits->integer == 32 ) {
|
||||
image->format = GL_RGBA8;
|
||||
}
|
||||
image->format = GL_RGBA8;
|
||||
break;
|
||||
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
|
|
|
@ -69,11 +69,6 @@ cvar_t *r_msaa;
|
|||
|
||||
cvar_t *r_ignoreGLErrors;
|
||||
|
||||
cvar_t *r_stencilbits;
|
||||
cvar_t *r_depthbits;
|
||||
cvar_t *r_colorbits;
|
||||
cvar_t *r_texturebits;
|
||||
|
||||
cvar_t *r_lightmap;
|
||||
cvar_t *r_vertexLight;
|
||||
cvar_t *r_uiFullScreen;
|
||||
|
@ -444,7 +439,6 @@ void GfxInfo_f( void )
|
|||
|
||||
ri.Printf( PRINT_DEVELOPER, "texturemode: %s\n", r_textureMode->string );
|
||||
ri.Printf( PRINT_DEVELOPER, "picmip: %d\n", r_picmip->integer );
|
||||
ri.Printf( PRINT_DEVELOPER, "texture bits: %d\n", r_texturebits->integer );
|
||||
ri.Printf( PRINT_DEVELOPER, "compressed textures: %s\n", enablestrings[r_ext_compressed_textures->integer] );
|
||||
ri.Printf( PRINT_DEVELOPER, "ambient pass: %s\n", r_vertexLight->integer ? "vertex" : "lightmap" );
|
||||
if ( r_finish->integer ) {
|
||||
|
@ -501,10 +495,6 @@ static void R_Register()
|
|||
r_roundImagesDown = ri.Cvar_Get ("r_roundImagesDown", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_colorMipLevels = ri.Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH );
|
||||
r_detailTextures = ri.Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_texturebits = ri.Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_colorbits = ri.Cvar_Get( "r_colorbits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_stencilbits = ri.Cvar_Get( "r_stencilbits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_depthbits = ri.Cvar_Get( "r_depthbits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_overBrightBits = ri.Cvar_Get( "r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_mode = ri.Cvar_Get( "r_mode", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
#if USE_SDL_VIDEO
|
||||
|
|
|
@ -934,15 +934,6 @@ extern glstate_t glState; // outside of TR since it shouldn't be cleared during
|
|||
//
|
||||
extern cvar_t *r_verbose; // used for verbose debug spew
|
||||
|
||||
extern cvar_t *r_stencilbits; // number of desired stencil bits
|
||||
extern cvar_t *r_depthbits; // number of desired depth bits
|
||||
extern cvar_t *r_colorbits; // number of desired color bits, only relevant for fullscreen
|
||||
extern cvar_t *r_texturebits; // number of desired texture bits
|
||||
// 0 = use framebuffer depth
|
||||
// 16 = use 16-bit textures
|
||||
// 32 = use 32-bit textures
|
||||
// all else = error
|
||||
|
||||
extern cvar_t *r_measureOverdraw; // enables stencil buffer overdraw measurement
|
||||
|
||||
extern cvar_t *r_lodbias; // push/pull LOD transitions
|
||||
|
@ -969,7 +960,6 @@ extern cvar_t *r_displayRefresh; // optional display refresh option
|
|||
extern cvar_t *r_intensity;
|
||||
extern cvar_t *r_gamma;
|
||||
|
||||
extern cvar_t *r_ext_compressed_textures;
|
||||
extern cvar_t *r_ext_max_anisotropy;
|
||||
extern cvar_t *r_msaa;
|
||||
|
||||
|
|
|
@ -828,27 +828,20 @@ void GLimp_Shutdown( void )
|
|||
static rserr_t GLW_SetMode( qboolean fullscreen )
|
||||
{
|
||||
int attrib[] = {
|
||||
GLX_RGBA, // 0
|
||||
GLX_RED_SIZE, 4, // 1, 2
|
||||
GLX_GREEN_SIZE, 4, // 3, 4
|
||||
GLX_BLUE_SIZE, 4, // 5, 6
|
||||
GLX_DOUBLEBUFFER, // 7
|
||||
GLX_DEPTH_SIZE, 1, // 8, 9
|
||||
GLX_STENCIL_SIZE, 1, // 10, 11
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 8,
|
||||
GLX_GREEN_SIZE, 8,
|
||||
GLX_BLUE_SIZE, 8,
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_DEPTH_SIZE, 24,
|
||||
GLX_STENCIL_SIZE, 8,
|
||||
None
|
||||
};
|
||||
// these match in the array
|
||||
#define ATTR_RED_IDX 2
|
||||
#define ATTR_GREEN_IDX 4
|
||||
#define ATTR_BLUE_IDX 6
|
||||
#define ATTR_DEPTH_IDX 9
|
||||
#define ATTR_STENCIL_IDX 11
|
||||
|
||||
XVisualInfo *visinfo;
|
||||
XSetWindowAttributes attr;
|
||||
XSizeHints sizehints;
|
||||
unsigned long mask;
|
||||
int colorbits, depthbits, stencilbits;
|
||||
int tcolorbits, tdepthbits, tstencilbits;
|
||||
int actualWidth, actualHeight;
|
||||
int i;
|
||||
|
||||
|
@ -871,115 +864,19 @@ static rserr_t GLW_SetMode( qboolean fullscreen )
|
|||
}
|
||||
ri.Printf( PRINT_DEVELOPER, "...setting mode %dx%d %s\n", glConfig.vidWidth, glConfig.vidHeight, fullscreen ? "FS" : "W" );
|
||||
|
||||
|
||||
|
||||
actualWidth = glConfig.vidWidth;
|
||||
actualHeight = glConfig.vidHeight;
|
||||
|
||||
if (!r_colorbits->value)
|
||||
colorbits = 24;
|
||||
else
|
||||
colorbits = r_colorbits->value;
|
||||
|
||||
if (!r_depthbits->value)
|
||||
depthbits = 24;
|
||||
else
|
||||
depthbits = r_depthbits->value;
|
||||
stencilbits = r_stencilbits->value;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
// 0 - default
|
||||
// 1 - minus colorbits
|
||||
// 2 - minus depthbits
|
||||
// 3 - minus stencil
|
||||
if ((i % 4) == 0 && i)
|
||||
{
|
||||
// one pass, reduce
|
||||
switch (i / 4)
|
||||
{
|
||||
case 2 :
|
||||
if (colorbits == 24)
|
||||
colorbits = 16;
|
||||
break;
|
||||
case 1 :
|
||||
if (depthbits == 24)
|
||||
depthbits = 16;
|
||||
else if (depthbits == 16)
|
||||
depthbits = 8;
|
||||
case 3 :
|
||||
if (stencilbits == 24)
|
||||
stencilbits = 16;
|
||||
else if (stencilbits == 16)
|
||||
stencilbits = 8;
|
||||
}
|
||||
}
|
||||
|
||||
tcolorbits = colorbits;
|
||||
tdepthbits = depthbits;
|
||||
tstencilbits = stencilbits;
|
||||
|
||||
if ((i % 4) == 3)
|
||||
{ // reduce colorbits
|
||||
if (tcolorbits == 24)
|
||||
tcolorbits = 16;
|
||||
}
|
||||
|
||||
if ((i % 4) == 2)
|
||||
{ // reduce depthbits
|
||||
if (tdepthbits == 24)
|
||||
tdepthbits = 16;
|
||||
else if (tdepthbits == 16)
|
||||
tdepthbits = 8;
|
||||
}
|
||||
|
||||
if ((i % 4) == 1)
|
||||
{ // reduce stencilbits
|
||||
if (tstencilbits == 24)
|
||||
tstencilbits = 16;
|
||||
else if (tstencilbits == 16)
|
||||
tstencilbits = 8;
|
||||
else
|
||||
tstencilbits = 0;
|
||||
}
|
||||
|
||||
if (tcolorbits == 24)
|
||||
{
|
||||
attrib[ATTR_RED_IDX] = 8;
|
||||
attrib[ATTR_GREEN_IDX] = 8;
|
||||
attrib[ATTR_BLUE_IDX] = 8;
|
||||
} else
|
||||
{
|
||||
// must be 16 bit
|
||||
attrib[ATTR_RED_IDX] = 4;
|
||||
attrib[ATTR_GREEN_IDX] = 4;
|
||||
attrib[ATTR_BLUE_IDX] = 4;
|
||||
}
|
||||
|
||||
attrib[ATTR_DEPTH_IDX] = tdepthbits; // default to 24 depth
|
||||
attrib[ATTR_STENCIL_IDX] = tstencilbits;
|
||||
|
||||
visinfo = qglXChooseVisual(dpy, scrnum, attrib);
|
||||
if (!visinfo)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ri.Printf( PRINT_ALL, "Using %d/%d/%d Color bits, %d depth, %d stencil display.\n",
|
||||
attrib[ATTR_RED_IDX], attrib[ATTR_GREEN_IDX], attrib[ATTR_BLUE_IDX],
|
||||
attrib[ATTR_DEPTH_IDX], attrib[ATTR_STENCIL_IDX]);
|
||||
|
||||
glConfig.colorBits = tcolorbits;
|
||||
glConfig.depthBits = tdepthbits;
|
||||
glConfig.stencilBits = tstencilbits;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
visinfo = qglXChooseVisual(dpy, scrnum, attrib);
|
||||
if (!visinfo)
|
||||
{
|
||||
ri.Printf( PRINT_ALL, "Couldn't get a visual\n" );
|
||||
return RSERR_INVALID_MODE;
|
||||
}
|
||||
|
||||
glConfig.colorBits = 32;
|
||||
glConfig.depthBits = 24;
|
||||
glConfig.stencilBits = 8;
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = BlackPixel(dpy, scrnum);
|
||||
|
|
|
@ -37,7 +37,6 @@ typedef struct
|
|||
HDC hDC;
|
||||
HGLRC hGLRC;
|
||||
HINSTANCE hinstOpenGL;
|
||||
int desktopBPP;
|
||||
qbool cdsDevModeValid;
|
||||
DEVMODE cdsDevMode; // Custom device mode for full-screen with r_mode 1.
|
||||
qbool pixelFormatSet;
|
||||
|
|
|
@ -209,35 +209,16 @@ static int GLW_ChoosePFD( HDC hDC, PIXELFORMATDESCRIPTOR *pPFD )
|
|||
**
|
||||
** Helper function zeros out then fills in a PFD
|
||||
*/
|
||||
static void GLW_CreatePFD( PIXELFORMATDESCRIPTOR *pPFD, int colorbits, int depthbits, int stencilbits )
|
||||
static void GLW_CreatePFD( PIXELFORMATDESCRIPTOR *pPFD )
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR src =
|
||||
{
|
||||
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
|
||||
1, // version number
|
||||
PFD_DRAW_TO_WINDOW | // support window
|
||||
PFD_SUPPORT_OPENGL | // support OpenGL
|
||||
PFD_DOUBLEBUFFER, // double buffered
|
||||
PFD_TYPE_RGBA, // RGBA type
|
||||
24, // 24-bit color depth
|
||||
0, 0, 0, 0, 0, 0, // color bits ignored
|
||||
0, // no alpha buffer
|
||||
0, // shift bit ignored
|
||||
0, // no accumulation buffer
|
||||
0, 0, 0, 0, // accum bits ignored
|
||||
24, // 24-bit z-buffer
|
||||
8, // 8-bit stencil buffer
|
||||
0, // no auxiliary buffer
|
||||
PFD_MAIN_PLANE, // main layer
|
||||
0, // reserved
|
||||
0, 0, 0 // layer masks ignored
|
||||
};
|
||||
|
||||
src.cColorBits = (BYTE)colorbits;
|
||||
src.cDepthBits = (BYTE)depthbits;
|
||||
src.cStencilBits = (BYTE)stencilbits;
|
||||
|
||||
*pPFD = src;
|
||||
ZeroMemory( pPFD, sizeof( *pPFD ) );
|
||||
pPFD->nSize = sizeof( *pPFD );
|
||||
pPFD->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pPFD->iPixelType = PFD_TYPE_RGBA;
|
||||
pPFD->iLayerType = PFD_MAIN_PLANE;
|
||||
pPFD->cColorBits = 32;
|
||||
pPFD->cDepthBits = 24;
|
||||
pPFD->cStencilBits = 8;
|
||||
}
|
||||
|
||||
static int GLW_MakeContext( PIXELFORMATDESCRIPTOR *pPFD )
|
||||
|
@ -306,10 +287,9 @@ static int GLW_MakeContext( PIXELFORMATDESCRIPTOR *pPFD )
|
|||
** - get a DC if one doesn't exist
|
||||
** - create an HGLRC if one doesn't exist
|
||||
*/
|
||||
static qbool GLW_InitDriver( int colorbits )
|
||||
static qbool GLW_InitDriver()
|
||||
{
|
||||
int tpfd;
|
||||
int depthbits, stencilbits;
|
||||
static PIXELFORMATDESCRIPTOR pfd; // save between frames since 'tr' gets cleared
|
||||
|
||||
ri.Printf( PRINT_DEVELOPER, "Initializing OpenGL driver\n" );
|
||||
|
@ -327,43 +307,12 @@ static qbool GLW_InitDriver( int colorbits )
|
|||
ri.Printf( PRINT_DEVELOPER, "...Get DC succeeded\n" );
|
||||
}
|
||||
|
||||
if ( colorbits == 0 )
|
||||
{
|
||||
colorbits = glw_state.desktopBPP;
|
||||
}
|
||||
|
||||
//
|
||||
// implicitly assume Z-buffer depth == desktop color depth
|
||||
//
|
||||
if ( r_depthbits->integer == 0 ) {
|
||||
if ( colorbits > 16 ) {
|
||||
depthbits = 24;
|
||||
} else {
|
||||
depthbits = 16;
|
||||
}
|
||||
} else {
|
||||
depthbits = r_depthbits->integer;
|
||||
}
|
||||
|
||||
//
|
||||
// do not allow stencil if Z-buffer depth likely won't contain it
|
||||
//
|
||||
stencilbits = r_stencilbits->integer;
|
||||
if ( depthbits < 24 )
|
||||
{
|
||||
stencilbits = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// make two attempts to set the PIXELFORMAT
|
||||
//
|
||||
|
||||
//
|
||||
// first attempt: r_colorbits, depthbits, and r_stencilbits
|
||||
// attempt to set the PIXELFORMAT
|
||||
//
|
||||
if ( !glw_state.pixelFormatSet )
|
||||
{
|
||||
GLW_CreatePFD( &pfd, colorbits, depthbits, stencilbits );
|
||||
GLW_CreatePFD( &pfd );
|
||||
if ( ( tpfd = GLW_MakeContext( &pfd ) ) != TRY_PFD_SUCCESS )
|
||||
{
|
||||
if ( tpfd == TRY_PFD_FAIL_HARD )
|
||||
|
@ -372,34 +321,10 @@ static qbool GLW_InitDriver( int colorbits )
|
|||
return qfalse;
|
||||
}
|
||||
|
||||
//
|
||||
// punt if we've already tried the desktop bit depth and no stencil bits
|
||||
//
|
||||
if ( ( r_colorbits->integer == glw_state.desktopBPP ) && !stencilbits )
|
||||
{
|
||||
ReleaseDC( g_wv.hWnd, glw_state.hDC );
|
||||
glw_state.hDC = NULL;
|
||||
ri.Printf( PRINT_ALL, "...failed to find an appropriate PIXELFORMAT\n" );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//
|
||||
// second attempt: desktop's color bits and no stencil
|
||||
//
|
||||
if ( colorbits > glw_state.desktopBPP )
|
||||
colorbits = glw_state.desktopBPP;
|
||||
|
||||
GLW_CreatePFD( &pfd, colorbits, depthbits, 0 );
|
||||
if ( GLW_MakeContext( &pfd ) != TRY_PFD_SUCCESS )
|
||||
{
|
||||
if ( glw_state.hDC )
|
||||
{
|
||||
ReleaseDC( g_wv.hWnd, glw_state.hDC );
|
||||
glw_state.hDC = NULL;
|
||||
}
|
||||
ri.Printf( PRINT_ALL, "...failed to find an appropriate PIXELFORMAT\n" );
|
||||
return qfalse;
|
||||
}
|
||||
ReleaseDC( g_wv.hWnd, glw_state.hDC );
|
||||
glw_state.hDC = NULL;
|
||||
ri.Printf( PRINT_ALL, "...failed to find an appropriate PIXELFORMAT\n" );
|
||||
return qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,7 +340,7 @@ static qbool GLW_InitDriver( int colorbits )
|
|||
|
||||
// responsible for creating the Win32 window and initializing the OpenGL driver.
|
||||
|
||||
static qbool GLW_CreateWindow( int width, int height, int colorbits )
|
||||
static qbool GLW_CreateWindow( int width, int height )
|
||||
{
|
||||
static qbool s_classRegistered = qfalse;
|
||||
|
||||
|
@ -501,7 +426,7 @@ static qbool GLW_CreateWindow( int width, int height, int colorbits )
|
|||
ri.Printf( PRINT_DEVELOPER, "...window already present, CreateWindowEx skipped\n" );
|
||||
}
|
||||
|
||||
if ( !GLW_InitDriver( colorbits ) )
|
||||
if ( !GLW_InitDriver() )
|
||||
{
|
||||
ShowWindow( g_wv.hWnd, SW_HIDE );
|
||||
DestroyWindow( g_wv.hWnd );
|
||||
|
@ -623,10 +548,6 @@ void WIN_SetDesktopDisplaySettings()
|
|||
|
||||
static qbool GLW_SetMode( qbool cdsFullscreen )
|
||||
{
|
||||
HDC hDC = GetDC( GetDesktopWindow() );
|
||||
glw_state.desktopBPP = GetDeviceCaps( hDC, BITSPIXEL );
|
||||
ReleaseDC( GetDesktopWindow(), hDC );
|
||||
|
||||
glInfo.isFullscreen = cdsFullscreen;
|
||||
WIN_UpdateMonitorIndexFromCvar();
|
||||
if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect ) ) {
|
||||
|
@ -653,10 +574,8 @@ static qbool GLW_SetMode( qbool cdsFullscreen )
|
|||
dm.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
}
|
||||
|
||||
if ( r_colorbits->integer ) {
|
||||
dm.dmBitsPerPel = r_colorbits->integer;
|
||||
dm.dmFields |= DM_BITSPERPEL;
|
||||
}
|
||||
dm.dmBitsPerPel = 32;
|
||||
dm.dmFields |= DM_BITSPERPEL;
|
||||
|
||||
const RECT& monRect = g_wv.monitorRects[g_wv.monitor];
|
||||
dm.dmPosition.x = monRect.left;
|
||||
|
@ -671,7 +590,7 @@ static qbool GLW_SetMode( qbool cdsFullscreen )
|
|||
}
|
||||
}
|
||||
|
||||
if (!GLW_CreateWindow( glConfig.vidWidth, glConfig.vidHeight, glConfig.colorBits ))
|
||||
if (!GLW_CreateWindow( glConfig.vidWidth, glConfig.vidHeight ))
|
||||
return qfalse;
|
||||
|
||||
if (EnumDisplaySettingsA( GLW_GetCurrentDisplayDeviceName(), ENUM_CURRENT_SETTINGS, &dm ))
|
||||
|
|
Loading…
Reference in a new issue