Added GL_PrintError() for more detailed OpenGL error output.

Added R_EndFrame() to remove direct calls to GLimp_EndFrame() from client and UI.
Removed GL_LockArrays()/GL_UnlockArrays() calls in shadow volume rendering.
Changed parameters to UI_DrawMenuString(), UI_DrawString(), and variants.
Added UI_DrawPopupMessage() to simplify popup text drawing.
This commit is contained in:
Knightmare66 2021-11-19 07:25:37 -05:00
parent 4cb3614976
commit befa8db495
15 changed files with 183 additions and 166 deletions

View file

@ -2368,13 +2368,13 @@ void SCR_TimeRefresh_f (void)
if (Cmd_Argc() == 2) if (Cmd_Argc() == 2)
{ // run without page flipping { // run without page flipping
R_BeginFrame( 0 ); R_BeginFrame (0);
for (i=0 ; i<128 ; i++) for (i=0 ; i<128 ; i++)
{ {
cl.refdef.viewangles[1] = i/128.0*360.0; cl.refdef.viewangles[1] = i/128.0*360.0;
R_RenderFrame (&cl.refdef); R_RenderFrame (&cl.refdef);
} }
GLimp_EndFrame(); R_EndFrame ();
} }
else else
{ {
@ -2382,9 +2382,9 @@ void SCR_TimeRefresh_f (void)
{ {
cl.refdef.viewangles[1] = i/128.0*360.0; cl.refdef.viewangles[1] = i/128.0*360.0;
R_BeginFrame( 0 ); R_BeginFrame (0);
R_RenderFrame (&cl.refdef); R_RenderFrame (&cl.refdef);
GLimp_EndFrame(); R_EndFrame ();
} }
} }
@ -2559,7 +2559,7 @@ void SCR_UpdateScreen (void)
for ( i = 0; i < numframes; i++ ) for ( i = 0; i < numframes; i++ )
{ {
R_BeginFrame( separation[i] ); R_BeginFrame (separation[i]);
if (scr_draw_loading == 2) if (scr_draw_loading == 2)
{ // loading plaque over black screen { // loading plaque over black screen
@ -2659,5 +2659,5 @@ void SCR_UpdateScreen (void)
} }
SCR_DrawConsole (); SCR_DrawConsole ();
} }
GLimp_EndFrame(); R_EndFrame ();
} }

View file

@ -815,7 +815,7 @@ void R_DrawStretchRaw (int x, int y, int w, int h, int cols, int rows, byte *dat
*/ */
void R_SetPalette (const unsigned char *palette); // NULL = game palette void R_SetPalette (const unsigned char *palette); // NULL = game palette
void R_BeginFrame (float camera_separation); void R_BeginFrame (float camera_separation);
void GLimp_EndFrame (void); void R_EndFrame (void);
void GLimp_AppActivate (qboolean activate); void GLimp_AppActivate (qboolean activate);

View file

@ -865,74 +865,13 @@ based on code from BeefQuake R6
*/ */
void R_DrawAliasVolumeShadow (maliasmodel_t *paliashdr, vec3_t bbox[8]) void R_DrawAliasVolumeShadow (maliasmodel_t *paliashdr, vec3_t bbox[8])
{ {
vec3_t light, vecAdd; // temp vec3_t light, vecAdd;
vec3_t shadowVec, endBBox[8], volumeMins, volumeMaxs; vec3_t shadowVec, endBBox[8], volumeMins, volumeMaxs;
float projected_distance; float projected_distance;
int i, j, skinnum; // lnum int i, j, skinnum;
qboolean zFail = (r_shadow_zfail->integer != 0); qboolean zFail = (r_shadow_zfail->integer != 0);
qboolean inVolume = false; qboolean inVolume = false;
// GLenum incr, decr; // GLenum incr, decr;
// float dist, highest, lowest;
// float angle, cosp, sinp, cosy, siny, cosr, sinr, ix, iy, iz;
// dlight_t *dl;
#if 0
dl = r_newrefdef.dlights;
VectorSet(vecAdd, 680,0,1024); // set base vector, was 576,0,1024
// compute average light vector from dlights
for (i=0, lnum=0; i<r_newrefdef.num_dlights; i++, dl++)
{
if (VectorCompare(dl->origin, currententity->origin))
continue;
VectorSubtract(dl->origin, currententity->origin, temp);
dist = dl->intensity - VectorLength(temp);
if (dist <= 0)
continue;
lnum++;
// Factor in the intensity of a dlight
VectorScale (temp, dist*0.25, temp);
VectorAdd (vecAdd, temp, vecAdd);
}
VectorNormalize(vecAdd);
VectorScale(vecAdd, 1024, vecAdd);
// get projection distance from lightspot height
highest = lowest = bbox[0][2];
for (i=0; i<8; i++) {
if (bbox[i][2] > highest) highest = bbox[i][2];
if (bbox[i][2] < lowest) lowest = bbox[i][2];
}
projected_distance = (fabs(highest - lightspot[2]) + (highest-lowest)) / vecAdd[2];
VectorCopy(vecAdd, light);
// reverse-rotate light vector based on angles
angle = -currententity->angles[PITCH] / 180 * M_PI;
cosp = cos(angle), sinp = sin(angle);
angle = -currententity->angles[YAW] / 180 * M_PI;
cosy = cos(angle), siny = sin(angle);
angle = -currententity->angles[ROLL] / 180 * M_PI * R_RollMult(); // roll is backwards
cosr = cos(angle), sinr = sin(angle);
// rotate for yaw (z axis)
ix = light[0], iy = light[1];
light[0] = cosy * ix - siny * iy + 0;
light[1] = siny * ix + cosy * iy + 0;
// rotate for pitch (y axis)
ix = light[0], iz = light[2];
light[0] = cosp * ix + 0 + sinp * iz;
light[2] = -sinp * ix + 0 + cosp * iz;
// rotate for roll (x axis)
iy = light[1], iz = light[2];
light[1] = 0 + cosr * iy - sinr * iz;
light[2] = 0 + sinr * iy + cosr * iz;
#endif
projected_distance = R_CalcAliasVolumeShadowLightVector (bbox, light); projected_distance = R_CalcAliasVolumeShadowLightVector (bbox, light);
@ -994,11 +933,11 @@ void R_DrawAliasVolumeShadow (maliasmodel_t *paliashdr, vec3_t bbox[8])
for (i=0; i<paliashdr->num_meshes; i++) for (i=0; i<paliashdr->num_meshes; i++)
{ {
skinnum = (currententity->skinnum<paliashdr->meshes[i].num_skins)?currententity->skinnum:0; skinnum = (currententity->skinnum<paliashdr->meshes[i].num_skins)?currententity->skinnum:0;
if (paliashdr->meshes[i].skins[skinnum].renderparms.noshadow) if (paliashdr->meshes[i].skins[skinnum].renderparms.nodraw || paliashdr->meshes[i].skins[skinnum].renderparms.noshadow)
continue; continue;
R_BuildShadowVolume (paliashdr, i, light, projected_distance, r_shadowvolumes->integer); R_BuildShadowVolume (paliashdr, i, light, projected_distance, r_shadowvolumes->integer);
GL_LockArrays (shadow_va); // GL_LockArrays (shadow_va);
if (!r_shadowvolumes->integer) if (!r_shadowvolumes->integer)
{ {
@ -1070,7 +1009,7 @@ void R_DrawAliasVolumeShadow (maliasmodel_t *paliashdr, vec3_t bbox[8])
else else
R_DrawShadowVolume (); R_DrawShadowVolume ();
GL_UnlockArrays (); // GL_UnlockArrays ();
} }
// end stenciling and draw stenciled volume // end stenciling and draw stenciled volume

View file

@ -533,7 +533,7 @@ void R_DrawAliasMD2VolumeShadow (dmd2_t *paliashdr, vec3_t bbox[8])
} }
R_BuildMD2ShadowVolume(paliashdr, light, projected_distance, r_shadowvolumes->integer||!zfail); R_BuildMD2ShadowVolume(paliashdr, light, projected_distance, r_shadowvolumes->integer||!zfail);
GL_LockArrays(md2shadow_va); // GL_LockArrays(md2shadow_va);
if (!r_shadowvolumes->integer) if (!r_shadowvolumes->integer)
{ // increment stencil if backface is behind depthbuffer { // increment stencil if backface is behind depthbuffer
@ -565,7 +565,7 @@ void R_DrawAliasMD2VolumeShadow (dmd2_t *paliashdr, vec3_t bbox[8])
qglDrawRangeElements(GL_TRIANGLES, 0, md2shadow_va, md2shadow_index, GL_UNSIGNED_INT, indexArray); qglDrawRangeElements(GL_TRIANGLES, 0, md2shadow_va, md2shadow_index, GL_UNSIGNED_INT, indexArray);
else else
qglDrawElements(GL_TRIANGLES, md2shadow_index, GL_UNSIGNED_INT, indexArray); qglDrawElements(GL_TRIANGLES, md2shadow_index, GL_UNSIGNED_INT, indexArray);
GL_UnlockArrays(); // GL_UnlockArrays();
/*for (i=-1; i<r_newrefdef.num_dlights; i++) //, dl++) /*for (i=-1; i<r_newrefdef.num_dlights; i++) //, dl++)
{ {

View file

@ -624,3 +624,44 @@ void GL_SetDefaultState (void)
GL_UpdateSwapInterval(); GL_UpdateSwapInterval();
} }
/*
=================
GL_PrintError
=================
*/
void GL_PrintError (int errorCode, char *funcName)
{
switch (errorCode)
{
case GL_INVALID_ENUM:
VID_Printf (PRINT_DEVELOPER, "%s: GL_INVALID_ENUM\n", funcName);
break;
case GL_INVALID_VALUE:
VID_Printf (PRINT_DEVELOPER, "%s: GL_INVALID_VALUE\n", funcName);
break;
case GL_INVALID_OPERATION:
VID_Printf (PRINT_DEVELOPER, "%s: GL_INVALID_OPERATION\n", funcName);
break;
case GL_STACK_OVERFLOW:
VID_Printf (PRINT_DEVELOPER, "%s: GL_STACK_OVERFLOW\n", funcName);
break;
case GL_STACK_UNDERFLOW:
VID_Printf (PRINT_DEVELOPER, "%s: GL_STACK_UNDERFLOW\n", funcName);
break;
case GL_OUT_OF_MEMORY:
VID_Printf (PRINT_DEVELOPER, "%s: GL_OUT_OF_MEMORY\n", funcName);
break;
case GL_TABLE_TOO_LARGE:
VID_Printf (PRINT_DEVELOPER, "%s: GL_TABLE_TOO_LARGE\n", funcName);
break;
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
VID_Printf (PRINT_DEVELOPER, "GL_INVALID_FRAMEBUFFER_OPERATION_EXT\n", funcName);
break;
#endif
default:
VID_Printf (PRINT_DEVELOPER, "%s: GL ERROR UNKNOWN (%i)\n", funcName, errorCode);
break;
}
}

View file

@ -58,19 +58,13 @@ static unsigned char gammatable[256];
cvar_t *r_intensity; cvar_t *r_intensity;
unsigned d_8to24table[256]; unsigned d_8to24table[256];
float d_8to24tablef[256][3]; //Knightmare- MrG's Vertex array stuff float d_8to24tablef[256][3]; // Knightmare- MrG's Vertex array stuff
qboolean GL_Upload8 (byte *data, int width, int height, imagetype_t type); qboolean GL_Upload8 (byte *data, int width, int height, imagetype_t type);
qboolean GL_Upload32 (unsigned *data, int width, int height, imagetype_t type); qboolean GL_Upload32 (unsigned *data, int width, int height, imagetype_t type);
/* int gl_filter_min;
int gl_solid_format = 3; int gl_filter_max;
int gl_alpha_format = 4;
int gl_tex_solid_format = 3;
int gl_tex_alpha_format = 4;
*/
int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
int gl_filter_max = GL_LINEAR;
#if 0 #if 0
void GL_SetTexturePalette (unsigned palette[256]) void GL_SetTexturePalette (unsigned palette[256])
@ -115,6 +109,7 @@ glmode_t gl_modes[] = {
#define NUM_GL_MODES (sizeof(gl_modes) / sizeof (glmode_t)) #define NUM_GL_MODES (sizeof(gl_modes) / sizeof (glmode_t))
#if 0 // removed
typedef struct typedef struct
{ {
char *name; char *name;
@ -145,7 +140,7 @@ gltmode_t gl_solid_modes[] = {
}; };
#define NUM_GL_SOLID_MODES (sizeof(gl_solid_modes) / sizeof (gltmode_t)) #define NUM_GL_SOLID_MODES (sizeof(gl_solid_modes) / sizeof (gltmode_t))
#endif
/* /*
=============== ===============
@ -2664,12 +2659,6 @@ void R_InitImages (void)
// Knightmare- reinitialize these after a vid_restart // Knightmare- reinitialize these after a vid_restart
// this is needed because the renderer is no longer a DLL // this is needed because the renderer is no longer a DLL
/*
gl_solid_format = 3;
gl_alpha_format = 4;
gl_tex_solid_format = 3;
gl_tex_alpha_format = 4;
*/
gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
gl_filter_max = GL_LINEAR; gl_filter_max = GL_LINEAR;

View file

@ -1021,6 +1021,7 @@ void GL_SelectTexture (unsigned tmu);
void GL_Bind (int texnum); void GL_Bind (int texnum);
void GL_MBind (unsigned tmu, int texnum); void GL_MBind (unsigned tmu, int texnum);
void GL_SetDefaultState (void); void GL_SetDefaultState (void);
void GL_PrintError (int errorCode, char *funcName);
/* /*
==================================================================== ====================================================================

View file

@ -2183,8 +2183,7 @@ void R_Shutdown (void)
R_BeginFrame R_BeginFrame
@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@
*/ */
void UpdateGammaRamp (void); //Knightmare added void UpdateGammaRamp (void); // hardware gamma
void RefreshFont (void);
void R_BeginFrame( float camera_separation ) void R_BeginFrame( float camera_separation )
{ {
qboolean clearColor_modified = false; qboolean clearColor_modified = false;
@ -2375,6 +2374,18 @@ void R_BeginFrame( float camera_separation )
R_Clear (); R_Clear ();
} }
/*
@@@@@@@@@@@@@@@@@@@@@
R_EndFrame
@@@@@@@@@@@@@@@@@@@@@
*/
void R_EndFrame (void)
{
GLimp_EndFrame ();
}
/* /*
============= =============
R_SetPalette R_SetPalette

View file

@ -130,7 +130,7 @@ void Menu_Credits_Draw (void)
x = ( SCREEN_WIDTH - len * MENU_FONT_SIZE - stringoffset * MENU_FONT_SIZE ) / 2 x = ( SCREEN_WIDTH - len * MENU_FONT_SIZE - stringoffset * MENU_FONT_SIZE ) / 2
+ stringoffset * MENU_FONT_SIZE; + stringoffset * MENU_FONT_SIZE;
UI_DrawString (x, y, MENU_FONT_SIZE, credits[i], alpha*255); UI_DrawString (x, y, MENU_FONT_SIZE, ALIGN_CENTER, credits[i], FONT_UI, alpha*255);
} }
} }

View file

@ -72,6 +72,11 @@ static void CDVolumeFunc (void *unused)
//======================================================================= //=======================================================================
void M_Sound_DrawUpdateMessage (void)
{
UI_DrawPopupMessage ("Restarting the sound system.\nThis could take up to a minute,\nso please be patient.");
}
static void M_UpdateSoundQualityFunc (void *unused) static void M_UpdateSoundQualityFunc (void *unused)
{ {
UI_MenuSpinControl_SaveValue (&s_options_sound_quality_list, "s_khz"); UI_MenuSpinControl_SaveValue (&s_options_sound_quality_list, "s_khz");
@ -79,15 +84,9 @@ static void M_UpdateSoundQualityFunc (void *unused)
UI_MenuSpinControl_SaveValue (&s_options_sound_compatibility_list, "s_primary"); UI_MenuSpinControl_SaveValue (&s_options_sound_compatibility_list, "s_primary");
UI_DrawTextBox (168, 192, 36, 3); // show update wait message
UI_DrawString (188, 192+MENU_FONT_SIZE, MENU_FONT_SIZE, S_COLOR_ALT"Restarting the sound system. This", 255); M_Sound_DrawUpdateMessage ();
UI_DrawString (188, 192+MENU_FONT_SIZE*2, MENU_FONT_SIZE, S_COLOR_ALT"could take up to a minute, so", 255); CL_Snd_Restart_f ();
UI_DrawString (188, 192+MENU_FONT_SIZE*3, MENU_FONT_SIZE, S_COLOR_ALT"please be patient.", 255);
// the text box won't show up unless we do a buffer swap
GLimp_EndFrame();
CL_Snd_Restart_f();
} }
static void M_SoundSetMenuItemValues (void) static void M_SoundSetMenuItemValues (void)
@ -109,17 +108,10 @@ static void M_SoundResetDefaultsFunc (void *unused)
Cvar_SetToDefault ("s_loadas8bit"); Cvar_SetToDefault ("s_loadas8bit");
Cvar_SetToDefault ("s_primary"); Cvar_SetToDefault ("s_primary");
UI_DrawTextBox (168, 192, 36, 3); // show update wait message
UI_DrawString (188, 192+MENU_FONT_SIZE, MENU_FONT_SIZE, S_COLOR_ALT"Restarting the sound system. This", 255); M_Sound_DrawUpdateMessage ();
UI_DrawString (188, 192+MENU_FONT_SIZE*2, MENU_FONT_SIZE, S_COLOR_ALT"could take up to a minute, so", 255); CL_Snd_Restart_f ();
UI_DrawString (188, 192+MENU_FONT_SIZE*3, MENU_FONT_SIZE, S_COLOR_ALT"please be patient.", 255); M_SoundSetMenuItemValues ();
// the text box won't show up unless we do a buffer swap
GLimp_EndFrame();
CL_Snd_Restart_f();
M_SoundSetMenuItemValues();
} }
//======================================================================= //=======================================================================

View file

@ -41,7 +41,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
UI_DrawMenuString UI_DrawMenuString
========================== ==========================
*/ */
void UI_DrawMenuString (int x, int y, int size, const char *string, int alpha, qboolean R2L, qboolean altColor) void UI_DrawMenuString (int x, int y, int size, scralign_t align, const char *string, int alpha, qboolean R2L, qboolean altColor)
{ {
char newstring[1024]; char newstring[1024];
@ -52,7 +52,7 @@ void UI_DrawMenuString (int x, int y, int size, const char *string, int alpha, q
if (R2L) if (R2L)
x -= stringLen(string)*size; x -= stringLen(string)*size;
UI_DrawString (x, y, size, newstring, alpha); UI_DrawString (x, y, size, align, newstring, FONT_UI, alpha);
} }
@ -61,9 +61,9 @@ void UI_DrawMenuString (int x, int y, int size, const char *string, int alpha, q
UI_DrawString UI_DrawString
============= =============
*/ */
void UI_DrawString (int x, int y, int size, const char *string, int alpha) void UI_DrawString (int x, int y, int size, scralign_t align, const char *string, fontslot_t font, int alpha)
{ {
SCR_DrawString (x, y, size, ALIGN_CENTER, string, FONT_UI, alpha); SCR_DrawString (x, y, size, align, string, font, alpha);
} }
@ -72,12 +72,12 @@ void UI_DrawString (int x, int y, int size, const char *string, int alpha)
UI_DrawStringDark UI_DrawStringDark
============= =============
*/ */
void UI_DrawStringDark (int x, int y, int size, const char *string, int alpha) void UI_DrawStringDark (int x, int y, int size, scralign_t align, const char *string, fontslot_t font, int alpha)
{ {
char newstring[1024]; char newstring[1024];
Com_sprintf (newstring, sizeof(newstring), S_COLOR_ALT"%s", string); Com_sprintf (newstring, sizeof(newstring), S_COLOR_ALT"%s", string);
SCR_DrawString (x, y, size, ALIGN_CENTER, newstring, FONT_UI, alpha); SCR_DrawString (x, y, size, align, newstring, font, alpha);
} }
@ -86,10 +86,10 @@ void UI_DrawStringDark (int x, int y, int size, const char *string, int alpha)
UI_DrawStringR2L UI_DrawStringR2L
============= =============
*/ */
void UI_DrawStringR2L (int x, int y, int size, const char *string, int alpha) void UI_DrawStringR2L (int x, int y, int size, scralign_t align, const char *string, fontslot_t font, int alpha)
{ {
x -= stringLen(string)*size; // MENU_FONT_SIZE x -= stringLen(string)*size; // MENU_FONT_SIZE
SCR_DrawString (x, y, size, ALIGN_CENTER, string, FONT_UI, alpha); SCR_DrawString (x, y, size, align, string, font, alpha);
} }
@ -98,13 +98,13 @@ void UI_DrawStringR2L (int x, int y, int size, const char *string, int alpha)
UI_DrawStringR2LDark UI_DrawStringR2LDark
============= =============
*/ */
void UI_DrawStringR2LDark (int x, int y, int size, const char *string, int alpha) void UI_DrawStringR2LDark (int x, int y, int size, scralign_t align, const char *string, fontslot_t font, int alpha)
{ {
char newstring[1024]; char newstring[1024];
Com_sprintf (newstring, sizeof(newstring), S_COLOR_ALT"%s", string); Com_sprintf (newstring, sizeof(newstring), S_COLOR_ALT"%s", string);
x -= stringLen(string)*size; // MENU_FONT_SIZE x -= stringLen(string)*size; // MENU_FONT_SIZE
SCR_DrawString (x, y, size, ALIGN_CENTER, newstring, FONT_UI, alpha); SCR_DrawString (x, y, size, align, newstring, font, alpha);
} }
@ -121,7 +121,7 @@ void UI_DrawMenuStatusBar (const char *string)
UI_DrawFill (0, SCREEN_HEIGHT-(MENU_FONT_SIZE+3), SCREEN_WIDTH, MENU_FONT_SIZE+4, ALIGN_BOTTOM_STRETCH, false, 60,60,60,255 ); // go 1 pixel past screen bottom to prevent gap from scaling UI_DrawFill (0, SCREEN_HEIGHT-(MENU_FONT_SIZE+3), SCREEN_WIDTH, MENU_FONT_SIZE+4, ALIGN_BOTTOM_STRETCH, false, 60,60,60,255 ); // go 1 pixel past screen bottom to prevent gap from scaling
UI_DrawFill (0, SCREEN_HEIGHT-(MENU_FONT_SIZE+3), SCREEN_WIDTH, 1, ALIGN_BOTTOM_STRETCH, false, 0,0,0,255 ); UI_DrawFill (0, SCREEN_HEIGHT-(MENU_FONT_SIZE+3), SCREEN_WIDTH, 1, ALIGN_BOTTOM_STRETCH, false, 0,0,0,255 );
SCR_DrawString (SCREEN_WIDTH/2-(l/2)*MENU_FONT_SIZE, SCREEN_HEIGHT-(MENU_FONT_SIZE+1), MENU_FONT_SIZE, ALIGN_BOTTOM, string, FONT_UI, 255 ); UI_DrawString (SCREEN_WIDTH/2-(l/2)*MENU_FONT_SIZE, SCREEN_HEIGHT-(MENU_FONT_SIZE+1), MENU_FONT_SIZE, ALIGN_BOTTOM, string, FONT_UI, 255 );
} }
else else
UI_DrawFill (0, SCREEN_HEIGHT-(MENU_FONT_SIZE+3), SCREEN_WIDTH, MENU_FONT_SIZE+4, ALIGN_BOTTOM_STRETCH, false, 0,0,0,255 ); // go 1 pixel past screen bottom to prevent gap from scaling UI_DrawFill (0, SCREEN_HEIGHT-(MENU_FONT_SIZE+3), SCREEN_WIDTH, MENU_FONT_SIZE+4, ALIGN_BOTTOM_STRETCH, false, 0,0,0,255 ); // go 1 pixel past screen bottom to prevent gap from scaling
@ -130,10 +130,10 @@ void UI_DrawMenuStatusBar (const char *string)
/* /*
============= =============
UI_DrawTextBox UI_DrawMenuTextBox
============= =============
*/ */
void UI_DrawTextBox (int x, int y, int width, int lines) void UI_DrawMenuTextBox (int x, int y, int width, int lines)
{ {
int cx, cy; int cx, cy;
int n; int n;
@ -215,6 +215,55 @@ void UI_DrawTextBox (int x, int y, int width, int lines)
} }
/*
==========================
UI_DrawPopupMessage
==========================
*/
void UI_DrawPopupMessage (char *message)
{
int i, x, y, numlines=0, width, widest=0, padding, boxwidth;
char buffer[1024], *parse, *tok;
if (!message) return;
memset (&buffer, 0, sizeof(buffer));
Com_sprintf(buffer, sizeof(buffer), message);
// get max width and num of lines
parse = buffer;
while (*parse)
{
width = 0;
while (*parse && *parse != '\n') {
width++; parse++;
}
numlines++;
widest = max(widest, width);
if (*parse)
parse++; // skip the \n
}
padding = (widest % 2 == 0) ? 2 : 3;
boxwidth = min(widest + padding, SCREEN_WIDTH/MENU_FONT_SIZE-2);
numlines = min(numlines, SCREEN_HEIGHT/MENU_FONT_SIZE-2);
// draw the box
x = SCREEN_WIDTH/2 - ((boxwidth+2)*MENU_FONT_SIZE/2);
y = SCREEN_HEIGHT/2 -((numlines+2)*MENU_FONT_SIZE/2);
UI_DrawMenuTextBox (x, y, boxwidth, numlines);
// draw the text
parse = buffer;
for (i=0, tok = strtok (parse, "\n"); i<numlines, tok != NULL; i++, tok = strtok (NULL, "\n"))
UI_DrawMenuString (x+((padding+2)*MENU_FONT_SIZE/2), y+MENU_FONT_SIZE*(i+1), MENU_FONT_SIZE,
ALIGN_CENTER, va("%s%s",S_COLOR_ALT,tok), 255, false, false);
// the text box won't show up unless we do a buffer swap
R_EndFrame ();
}
/* /*
================= =================
UI_DrawBanner UI_DrawBanner

View file

@ -498,13 +498,14 @@ void UI_RefreshData (void);
#define UI_DrawTiledPic SCR_DrawTiledPic #define UI_DrawTiledPic SCR_DrawTiledPic
#define UI_DrawChar(x, y, s, t, n, r, g, b, a, i, l) SCR_DrawChar(x, y, s, t, n, FONT_UI, r, g, b, a, i, l) #define UI_DrawChar(x, y, s, t, n, r, g, b, a, i, l) SCR_DrawChar(x, y, s, t, n, FONT_UI, r, g, b, a, i, l)
void UI_DrawMenuString (int x, int y, int size, const char *string, int alpha, qboolean R2L, qboolean altColor); void UI_DrawMenuString (int x, int y, int size, scralign_t align, const char *string, int alpha, qboolean R2L, qboolean altColor);
void UI_DrawString (int x, int y, int size, const char *string, int alpha); void UI_DrawString (int x, int y, int size, scralign_t align, const char *string, fontslot_t font, int alpha);
void UI_DrawStringDark (int x, int y, int size, const char *string, int alpha); void UI_DrawStringDark (int x, int y, int size, scralign_t align, const char *string, fontslot_t font, int alpha);
void UI_DrawStringR2L (int x, int y, int size, const char *string, int alpha); void UI_DrawStringR2L (int x, int y, int size, scralign_t align, const char *string, fontslot_t font, int alpha);
void UI_DrawStringR2LDark (int x, int y, int size, const char *string, int alpha); void UI_DrawStringR2LDark (int x, int y, int size, scralign_t align, const char *string, fontslot_t font, int alpha);
void UI_DrawMenuStatusBar (const char *string); void UI_DrawMenuStatusBar (const char *string);
void UI_DrawTextBox (int x, int y, int width, int lines); void UI_DrawMenuTextBox (int x, int y, int width, int lines);
void UI_DrawPopupMessage (char *message);
void UI_DrawBanner (char *name); void UI_DrawBanner (char *name);
void UI_Draw_Cursor (void); void UI_Draw_Cursor (void);

View file

@ -1561,16 +1561,10 @@ void UI_SearchLocalGames (void)
// strncpy (ui_local_server_names[i], NO_SERVER_STRING); // strncpy (ui_local_server_names[i], NO_SERVER_STRING);
Q_strncpyz (ui_local_server_names[i], sizeof(ui_local_server_names[i]), NO_SERVER_STRING); Q_strncpyz (ui_local_server_names[i], sizeof(ui_local_server_names[i]), NO_SERVER_STRING);
UI_DrawTextBox (168, 192, 36, 3); UI_DrawPopupMessage ("Searching for local servers.\nThis could take up to a minute,\nso please be patient.");
UI_DrawString (188, 192+MENU_FONT_SIZE, MENU_FONT_SIZE, S_COLOR_ALT"Searching for local servers, this", 255);
UI_DrawString (188, 192+MENU_FONT_SIZE*2, MENU_FONT_SIZE, S_COLOR_ALT"could take up to a minute, so", 255);
UI_DrawString (188, 192+MENU_FONT_SIZE*3, MENU_FONT_SIZE, S_COLOR_ALT"please be patient.", 255);
// the text box won't show up unless we do a buffer swap
GLimp_EndFrame();
// send out info packets // send out info packets
CL_PingServers_f(); CL_PingServers_f ();
} }

View file

@ -84,19 +84,19 @@ void MenuAction_Draw (menuaction_s *a)
{ {
if (a->generic.flags & QMF_GRAYED) if (a->generic.flags & QMF_GRAYED)
UI_DrawStringDark (a->generic.x + a->generic.parent->x + LCOLUMN_OFFSET, UI_DrawStringDark (a->generic.x + a->generic.parent->x + LCOLUMN_OFFSET,
a->generic.y + a->generic.parent->y, a->generic.textSize, a->generic.name, alpha); a->generic.y + a->generic.parent->y, a->generic.textSize, ALIGN_CENTER, a->generic.name, FONT_UI, alpha);
else else
UI_DrawString (a->generic.x + a->generic.parent->x + LCOLUMN_OFFSET, UI_DrawString (a->generic.x + a->generic.parent->x + LCOLUMN_OFFSET,
a->generic.y + a->generic.parent->y, a->generic.textSize, a->generic.name, alpha); a->generic.y + a->generic.parent->y, a->generic.textSize, ALIGN_CENTER, a->generic.name, FONT_UI, alpha);
} }
else else
{ {
if (a->generic.flags & QMF_GRAYED) if (a->generic.flags & QMF_GRAYED)
UI_DrawStringR2LDark (a->generic.x + a->generic.parent->x + LCOLUMN_OFFSET, UI_DrawStringR2LDark (a->generic.x + a->generic.parent->x + LCOLUMN_OFFSET,
a->generic.y + a->generic.parent->y, a->generic.textSize, a->generic.name, alpha); a->generic.y + a->generic.parent->y, a->generic.textSize, ALIGN_CENTER, a->generic.name, FONT_UI, alpha);
else else
UI_DrawStringR2L (a->generic.x + a->generic.parent->x + LCOLUMN_OFFSET, UI_DrawStringR2L (a->generic.x + a->generic.parent->x + LCOLUMN_OFFSET,
a->generic.y + a->generic.parent->y, a->generic.textSize, a->generic.name, alpha); a->generic.y + a->generic.parent->y, a->generic.textSize, ALIGN_CENTER, a->generic.name, FONT_UI, alpha);
} }
if (a->generic.ownerdraw) if (a->generic.ownerdraw)
a->generic.ownerdraw(a); a->generic.ownerdraw(a);
@ -128,7 +128,7 @@ void MenuField_Draw (menufield_s *f)
if (f->generic.name) if (f->generic.name)
UI_DrawStringR2LDark (f->generic.x + f->generic.parent->x + LCOLUMN_OFFSET, UI_DrawStringR2LDark (f->generic.x + f->generic.parent->x + LCOLUMN_OFFSET,
f->generic.y + f->generic.parent->y, f->generic.textSize, f->generic.name, 255); f->generic.y + f->generic.parent->y, f->generic.textSize, ALIGN_CENTER, f->generic.name, FONT_UI, 255);
if (xtra = stringLengthExtra(f->buffer)) if (xtra = stringLengthExtra(f->buffer))
{ {
@ -189,7 +189,7 @@ void MenuField_Draw (menufield_s *f)
Com_sprintf (tempbuffer, sizeof(tempbuffer), "%s%c", tempbuffer, 11); Com_sprintf (tempbuffer, sizeof(tempbuffer), "%s%c", tempbuffer, 11);
UI_DrawString (f->generic.x + f->generic.parent->x + f->generic.textSize*3, UI_DrawString (f->generic.x + f->generic.parent->x + f->generic.textSize*3,
f->generic.y + f->generic.parent->y, f->generic.textSize, tempbuffer, alpha); f->generic.y + f->generic.parent->y, f->generic.textSize, ALIGN_CENTER, tempbuffer, FONT_UI, alpha);
} }
qboolean UI_MenuField_Key (menufield_s *f, int key) qboolean UI_MenuField_Key (menufield_s *f, int key)
@ -345,15 +345,15 @@ void Menulist_DoEnter (menulist_s *l)
void MenuList_Draw (menulist_s *l) void MenuList_Draw (menulist_s *l)
{ {
const char **n; const char **n;
int y = 0, alpha; int y = 0, alpha;
if (!l) return; if (!l) return;
alpha = UI_MouseOverAlpha(&l->generic); alpha = UI_MouseOverAlpha(&l->generic);
UI_DrawStringR2LDark (l->generic.x + l->generic.parent->x + LCOLUMN_OFFSET, // - 2*MENU_FONT_SIZE, UI_DrawStringR2LDark (l->generic.x + l->generic.parent->x + LCOLUMN_OFFSET, // - 2*MENU_FONT_SIZE,
l->generic.y + l->generic.parent->y, l->generic.textSize, l->generic.name, alpha); l->generic.y + l->generic.parent->y, l->generic.textSize, ALIGN_CENTER, l->generic.name, FONT_UI, alpha);
n = l->itemNames; n = l->itemNames;
@ -365,7 +365,7 @@ void MenuList_Draw (menulist_s *l)
while (*n) while (*n)
{ {
UI_DrawStringR2LDark (l->generic.x + l->generic.parent->x + LCOLUMN_OFFSET, UI_DrawStringR2LDark (l->generic.x + l->generic.parent->x + LCOLUMN_OFFSET,
l->generic.y + l->generic.parent->y + y + MENU_LINE_SIZE, l->generic.textSize, *n, alpha); l->generic.y + l->generic.parent->y + y + MENU_LINE_SIZE, l->generic.textSize, ALIGN_CENTER, *n, FONT_UI, alpha);
n++; n++;
y += MENU_LINE_SIZE; y += MENU_LINE_SIZE;
} }
@ -383,7 +383,7 @@ void MenuSeparator_Draw (menuseparator_s *s)
if (s->generic.name) if (s->generic.name)
UI_DrawStringR2LDark (s->generic.x + s->generic.parent->x, UI_DrawStringR2LDark (s->generic.x + s->generic.parent->x,
s->generic.y + s->generic.parent->y, s->generic.textSize, s->generic.name, alpha); s->generic.y + s->generic.parent->y, s->generic.textSize, ALIGN_CENTER, s->generic.name, FONT_UI, alpha);
} }
//========================================================= //=========================================================
@ -445,7 +445,7 @@ void MenuSlider_Draw (menuslider_s *s)
alpha = UI_MouseOverAlpha(&s->generic); alpha = UI_MouseOverAlpha(&s->generic);
UI_DrawStringR2LDark (s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET, UI_DrawStringR2LDark (s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
s->generic.y + s->generic.parent->y, s->generic.textSize, s->generic.name, alpha); s->generic.y + s->generic.parent->y, s->generic.textSize, ALIGN_CENTER, s->generic.name, FONT_UI, alpha);
if (!s->maxPos) if (!s->maxPos)
s->maxPos = 1; s->maxPos = 1;
@ -502,9 +502,9 @@ void MenuSlider_Draw (menuslider_s *s)
Com_sprintf (valueText, sizeof(valueText), "%4.2f", tmpValue); Com_sprintf (valueText, sizeof(valueText), "%4.2f", tmpValue);
} }
UI_DrawString (s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET + 2*SLIDER_ENDCAP_WIDTH + i*SLIDER_SECTION_WIDTH + MENU_FONT_SIZE/2, UI_DrawString (s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET + 2*SLIDER_ENDCAP_WIDTH + i*SLIDER_SECTION_WIDTH + MENU_FONT_SIZE/2,
s->generic.y + s->generic.parent->y + 1, MENU_FONT_SIZE-2, valueText, alpha); s->generic.y + s->generic.parent->y + 1, MENU_FONT_SIZE-2, ALIGN_CENTER, valueText, FONT_UI, alpha);
// UI_DrawString (s->generic.x + s->generic.parent->x + s->generic.textSize*SLIDER_RANGE + RCOLUMN_OFFSET + 2.5*MENU_FONT_SIZE, // UI_DrawString (s->generic.x + s->generic.parent->x + s->generic.textSize*SLIDER_RANGE + RCOLUMN_OFFSET + 2.5*MENU_FONT_SIZE,
// s->generic.y + s->generic.parent->y + 1, MENU_FONT_SIZE-2, valueText, alpha); // s->generic.y + s->generic.parent->y + 1, MENU_FONT_SIZE-2, ALIGN_CENTER, valueText, FONT_UI, alpha);
} }
//========================================================= //=========================================================
@ -636,12 +636,12 @@ void MenuSpinControl_Draw (menulist_s *s)
if (s->generic.name) if (s->generic.name)
{ {
UI_DrawStringR2LDark (s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET, UI_DrawStringR2LDark (s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
s->generic.y + s->generic.parent->y, s->generic.textSize, s->generic.name, alpha); s->generic.y + s->generic.parent->y, s->generic.textSize, ALIGN_CENTER, s->generic.name, FONT_UI, alpha);
} }
if (!strchr(s->itemNames[s->curValue], '\n')) if (!strchr(s->itemNames[s->curValue], '\n'))
{ {
UI_DrawString (s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET, UI_DrawString (s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET,
s->generic.y + s->generic.parent->y, s->generic.textSize, s->itemNames[s->curValue], alpha); s->generic.y + s->generic.parent->y, s->generic.textSize, ALIGN_CENTER, s->itemNames[s->curValue], FONT_UI, alpha);
} }
else else
{ {
@ -649,11 +649,11 @@ void MenuSpinControl_Draw (menulist_s *s)
Q_strncpyz (buffer, sizeof(buffer), s->itemNames[s->curValue]); Q_strncpyz (buffer, sizeof(buffer), s->itemNames[s->curValue]);
*strchr(buffer, '\n') = 0; *strchr(buffer, '\n') = 0;
UI_DrawString (s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET, UI_DrawString (s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET,
s->generic.y + s->generic.parent->y, s->generic.textSize, buffer, alpha); s->generic.y + s->generic.parent->y, s->generic.textSize, ALIGN_CENTER, buffer, FONT_UI, alpha);
// strncpy(buffer, strchr( s->itemnames[s->curvalue], '\n' ) + 1 ); // strncpy(buffer, strchr( s->itemnames[s->curvalue], '\n' ) + 1 );
Q_strncpyz (buffer, sizeof(buffer), strchr( s->itemNames[s->curValue], '\n' ) + 1); Q_strncpyz (buffer, sizeof(buffer), strchr( s->itemNames[s->curValue], '\n' ) + 1);
UI_DrawString (s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET, UI_DrawString (s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET,
s->generic.y + s->generic.parent->y + MENU_LINE_SIZE, s->generic.textSize, buffer, alpha); s->generic.y + s->generic.parent->y + MENU_LINE_SIZE, s->generic.textSize, ALIGN_CENTER, buffer, FONT_UI, alpha);
} }
} }
@ -683,7 +683,7 @@ void MenuKeyBind_Draw (menukeybind_s *k)
const char *keyName1, *keyName2; const char *keyName1, *keyName2;
UI_DrawMenuString (menu->x + k->generic.x + LCOLUMN_OFFSET, UI_DrawMenuString (menu->x + k->generic.x + LCOLUMN_OFFSET,
menu->y + k->generic.y, MENU_FONT_SIZE, k->generic.name, alpha, menu->y + k->generic.y, MENU_FONT_SIZE, ALIGN_CENTER, k->generic.name, alpha,
!(k->generic.flags & QMF_LEFT_JUSTIFY), (k->generic.flags & QMF_ALTCOLOR)); !(k->generic.flags & QMF_LEFT_JUSTIFY), (k->generic.flags & QMF_ALTCOLOR));
if (k->commandName) if (k->commandName)
@ -693,21 +693,21 @@ void MenuKeyBind_Draw (menukeybind_s *k)
if (k->keys[0] == -1) if (k->keys[0] == -1)
{ {
UI_DrawMenuString (menu->x + k->generic.x + RCOLUMN_OFFSET, UI_DrawMenuString (menu->x + k->generic.x + RCOLUMN_OFFSET,
menu->y + k->generic.y, MENU_FONT_SIZE, "???", alpha, false, false); menu->y + k->generic.y, MENU_FONT_SIZE, ALIGN_CENTER, "???", alpha, false, false);
} }
else else
{ {
keyName1 = Key_KeynumToString (k->keys[0]); keyName1 = Key_KeynumToString (k->keys[0]);
UI_DrawMenuString (menu->x + k->generic.x + RCOLUMN_OFFSET, UI_DrawMenuString (menu->x + k->generic.x + RCOLUMN_OFFSET,
menu->y + k->generic.y, MENU_FONT_SIZE, keyName1, alpha, false, false); menu->y + k->generic.y, MENU_FONT_SIZE, ALIGN_CENTER, keyName1, alpha, false, false);
if (k->keys[1] != -1) if (k->keys[1] != -1)
{ {
x = (int)strlen(keyName1) * MENU_FONT_SIZE; x = (int)strlen(keyName1) * MENU_FONT_SIZE;
keyName2 = Key_KeynumToString (k->keys[1]); keyName2 = Key_KeynumToString (k->keys[1]);
UI_DrawMenuString (menu->x + k->generic.x + MENU_FONT_SIZE*3 + x, UI_DrawMenuString (menu->x + k->generic.x + MENU_FONT_SIZE*3 + x,
menu->y + k->generic.y, MENU_FONT_SIZE, "or", alpha, false, false); menu->y + k->generic.y, MENU_FONT_SIZE, ALIGN_CENTER, "or", alpha, false, false);
UI_DrawMenuString (menu->x + k->generic.x + MENU_FONT_SIZE*6 + x, UI_DrawMenuString (menu->x + k->generic.x + MENU_FONT_SIZE*6 + x,
menu->y + k->generic.y, MENU_FONT_SIZE, keyName2, alpha, false, false); menu->y + k->generic.y, MENU_FONT_SIZE, ALIGN_CENTER, keyName2, alpha, false, false);
} }
} }
} }

View file

@ -843,9 +843,9 @@ void GLimp_EndFrame (void)
int err; int err;
err = qglGetError(); err = qglGetError();
// assert( err == GL_NO_ERROR );
if (err != GL_NO_ERROR) // Output error code instead if (err != GL_NO_ERROR) // Output error code instead
VID_Printf (PRINT_DEVELOPER, "OpenGL Error %i\n", err); // VID_Printf (PRINT_DEVELOPER, "OpenGL Error %i\n", err);
GL_PrintError (err, "GLimp_EndFrame");
if ( stricmp( r_drawbuffer->string, "GL_BACK" ) == 0 ) if ( stricmp( r_drawbuffer->string, "GL_BACK" ) == 0 )
{ {