Wide screen support.

This commit is contained in:
Andrei Drexler 2009-06-30 02:34:25 +00:00
parent bb4b71d09d
commit 3c08e99162
5 changed files with 56 additions and 54 deletions

View File

@ -494,7 +494,7 @@ static void CG_DrawStatusBar(void)
qhandle_t hicon; qhandle_t hicon;
qhandle_t icon; qhandle_t icon;
//Makro - added x and y for weapon drawing //Makro - added x and y for weapon drawing
int i, x = 640 - SMICON_SIZE, y = 400; int i, x = cgs.screenXMax - SMICON_SIZE - 8, y = 400;
//Makro - old values //Makro - old values
/* /*
@ -573,10 +573,10 @@ static void CG_DrawStatusBar(void)
} }
} */ } */
CG_DrawPic(8, 440, SMICON_SIZE, SMICON_SIZE, hicon); CG_DrawPic(cgs.screenXMin + 8, 440, SMICON_SIZE, SMICON_SIZE, hicon);
//CG_DrawStringExt(44, 444, va("%d", value), hcolor, qtrue, qtrue, 24, 24, 3); //CG_DrawStringExt(44, 444, va("%d", value), hcolor, qtrue, qtrue, 24, 24, 3);
//UI_DrawProportionalString(44, 444, va("%d", value), style, hcolor); //UI_DrawProportionalString(44, 444, va("%d", value), style, hcolor);
UI_DrawProportionalString(40, 444, va("%d", value), style, hcolor); UI_DrawProportionalString(cgs.screenXMin + 40, 444, va("%d", value), style, hcolor);
//Elder: Draw weapon ammo and clips //Elder: Draw weapon ammo and clips
style = UI_LEFT | UI_DROPSHADOW; style = UI_LEFT | UI_DROPSHADOW;
@ -596,7 +596,7 @@ static void CG_DrawStatusBar(void)
//if (icon && cg.predictedPlayerState.weapon != WP_KNIFE && cg.predictedPlayerState.weapon != WP_GRENADE) //if (icon && cg.predictedPlayerState.weapon != WP_KNIFE && cg.predictedPlayerState.weapon != WP_GRENADE)
if (icon) if (icon)
//CG_DrawPic(252, 440, SMICON_SIZE, SMICON_SIZE, icon); //CG_DrawPic(252, 440, SMICON_SIZE, SMICON_SIZE, icon);
CG_DrawPic(288, 440, SMICON_SIZE, SMICON_SIZE, icon); CG_DrawPic(cgs.screenXMin + 288, 440, SMICON_SIZE, SMICON_SIZE, icon);
if (cent->currentState.weapon) { if (cent->currentState.weapon) {
value = ps->ammo[cent->currentState.weapon]; value = ps->ammo[cent->currentState.weapon];
@ -637,7 +637,7 @@ static void CG_DrawStatusBar(void)
} }
if (value >= 0) if (value >= 0)
UI_DrawProportionalString(200, 444, va("%d", value), style, hcolor); UI_DrawProportionalString(cgs.screenXMin + 200, 444, va("%d", value), style, hcolor);
#endif #endif
//UI_DrawProportionalString(188, 444, "/"), style, colors[0]); //UI_DrawProportionalString(188, 444, "/"), style, colors[0]);
@ -646,7 +646,7 @@ static void CG_DrawStatusBar(void)
if (value > -1 && if (value > -1 &&
cg.predictedPlayerState.weapon != WP_KNIFE && cg.predictedPlayerState.weapon != WP_GRENADE) cg.predictedPlayerState.weapon != WP_KNIFE && cg.predictedPlayerState.weapon != WP_GRENADE)
//Makro - pretty colours ! //Makro - pretty colours !
UI_DrawProportionalString(320, 444, va("%d", value), style, (value != 0) ? colors[0] : colors[3]); UI_DrawProportionalString(cgs.screenXMin + 320, 444, va("%d", value), style, (value != 0) ? colors[0] : colors[3]);
} }
// Elder: temporary // Elder: temporary
//if (cg.snap->ps.stats[STAT_RELOADTIME] > 0) //if (cg.snap->ps.stats[STAT_RELOADTIME] > 0)
@ -828,9 +828,9 @@ static float CG_DrawScore(float y)
w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH; w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH;
x = w; x = w;
CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, BColor); CG_FillRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, BColor);
CG_DrawCleanRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, FColor); CG_DrawCleanRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, FColor);
CG_DrawSmallString(631 - x, y + 2, s, 1.0f); CG_DrawSmallString(cgs.screenXMax - x - 9, y + 2, s, 1.0f);
// Your team: // Your team:
if (team == TEAM_RED) { if (team == TEAM_RED) {
@ -846,9 +846,9 @@ static float CG_DrawScore(float y)
w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH; w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH;
x += w + 9; x += w + 9;
CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, BColor); CG_FillRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, BColor);
CG_DrawCleanRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, FColor); CG_DrawCleanRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, FColor);
CG_DrawSmallString(631 - x, y + 2, s, 1.0f); CG_DrawSmallString(cgs.screenXMax - x - 9, y + 2, s, 1.0f);
} }
s = va("%i", cg.snap->ps.persistant[PERS_SCORE]); s = va("%i", cg.snap->ps.persistant[PERS_SCORE]);
@ -865,10 +865,10 @@ static float CG_DrawScore(float y)
//MAKERGBA(BColor, 1.0f, 1.0f, 1.0f, 1.0f); //MAKERGBA(BColor, 1.0f, 1.0f, 1.0f, 1.0f);
//CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, BColor); //CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, BColor);
CG_DrawCleanRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, FColor); CG_DrawCleanRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, FColor);
MAKERGBA(FColor, 0.75f, 0.75f, 0.75f, 1.0f); MAKERGBA(FColor, 0.75f, 0.75f, 0.75f, 1.0f);
CG_DrawStringExt(631 - x, y + 2, s, FColor, qfalse, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0); CG_DrawStringExt(cgs.screenXMax - x - 9, y + 2, s, FColor, qfalse, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0);
//CG_DrawSmallString(631 - x, y + 2, s, 1.0F); //CG_DrawSmallString(631 - x, y + 2, s, 1.0F);
@ -936,12 +936,12 @@ static float CG_DrawFPSandPing(float y)
x = w; x = w;
MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 0.4f); MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 0.4f);
CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, Color); CG_FillRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, Color);
MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 1.0f); MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 1.0f);
CG_DrawCleanRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, Color); CG_DrawCleanRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, Color);
CG_DrawSmallString(631 - x, y + 2, s, 1.0F); CG_DrawSmallString(cgs.screenXMax - x - 9, y + 2, s, 1.0F);
x += 9; x += 9;
} }
@ -973,10 +973,10 @@ static float CG_DrawFPSandPing(float y)
if (l < 0) l += LAG_SAMPLES; if (l < 0) l += LAG_SAMPLES;
MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 0.4f); MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 0.4f);
CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, Color); CG_FillRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, Color);
MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 1.0f); MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 1.0f);
CG_DrawCleanRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, Color); CG_DrawCleanRect(cgs.screenXMax - x - 12, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, Color);
MAKERGBA(Color, 0.0f, 1.0f, 0.0f, 1.0f); // Green, All good MAKERGBA(Color, 0.0f, 1.0f, 0.0f, 1.0f); // Green, All good
@ -987,7 +987,7 @@ static float CG_DrawFPSandPing(float y)
if (lagometer.snapshotFlags[l] & SNAPFLAG_RATE_DELAYED) // Yellow. Delayed packet if (lagometer.snapshotFlags[l] & SNAPFLAG_RATE_DELAYED) // Yellow. Delayed packet
MAKERGBA(Color, 1.0f, 1.0f, 0.0f, 1.0f); MAKERGBA(Color, 1.0f, 1.0f, 0.0f, 1.0f);
CG_DrawStringExt(631 - x, y + 2, s, Color, qfalse, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0); CG_DrawStringExt(cgs.screenXMax - x - 9, y + 2, s, Color, qfalse, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0);
} }
if (!cg_drawFPS.integer && (!cg_drawPing.integer || cg.demoPlayback)) if (!cg_drawFPS.integer && (!cg_drawPing.integer || cg.demoPlayback))
@ -1375,8 +1375,8 @@ static int CG_DrawPickupItem(int y)
if (fadeColor) { if (fadeColor) {
CG_RegisterItemVisuals(value); CG_RegisterItemVisuals(value);
trap_R_SetColor(fadeColor); trap_R_SetColor(fadeColor);
CG_DrawPic(8, y, ICON_SIZE, ICON_SIZE, cg_items[value].icon); CG_DrawPic(cgs.screenXMin + 8, y, ICON_SIZE, ICON_SIZE, cg_items[value].icon);
CG_DrawBigString(ICON_SIZE + 16, y + (ICON_SIZE / 2 - BIGCHAR_HEIGHT / 2), CG_DrawBigString(cgs.screenXMin + ICON_SIZE + 16, y + (ICON_SIZE / 2 - BIGCHAR_HEIGHT / 2),
bg_itemlist[value].pickup_name, fadeColor[0]); bg_itemlist[value].pickup_name, fadeColor[0]);
trap_R_SetColor(NULL); trap_R_SetColor(NULL);
} }
@ -1502,7 +1502,7 @@ static void CG_DrawHoldableItem(void)
if (item) { if (item) {
value = BG_FindItemForHoldable(item) - bg_itemlist; value = BG_FindItemForHoldable(item) - bg_itemlist;
CG_RegisterItemVisuals(value); CG_RegisterItemVisuals(value);
CG_DrawPic(640 - SMICON_SIZE, 440, SMICON_SIZE, SMICON_SIZE, cg_items[value].icon); CG_DrawPic(cgs.screenXMax - SMICON_SIZE - 8, 440, SMICON_SIZE, SMICON_SIZE, cg_items[value].icon);
} }
} }
@ -1662,7 +1662,7 @@ static void CG_DrawDisconnect(void)
//x = 640 - 48; //x = 640 - 48;
//y = 480 - 48; //y = 480 - 48;
CG_DrawPic(x, y, 48, 48, trap_R_RegisterShader("gfx/2d/net.tga")); CG_DrawPic(cgs.screenXMin + x, y, 48, 48, trap_R_RegisterShader("gfx/2d/net.tga"));
} }
#define MAX_LAGOMETER_PING 900 #define MAX_LAGOMETER_PING 900
@ -1694,9 +1694,9 @@ static void CG_DrawLagometer(void)
y = 0; y = 0;
trap_R_SetColor(NULL); trap_R_SetColor(NULL);
CG_DrawPic(x, y, 48, 48, cgs.media.lagometerShader); CG_DrawPic(cgs.screenXMin + x, y, 48, 48, cgs.media.lagometerShader);
ax = x; ax = cgs.screenXMin + x;
ay = y; ay = y;
aw = 48; aw = 48;
ah = 48; ah = 48;
@ -2031,9 +2031,9 @@ static void CG_DrawCrosshair(void)
} }
if (drawSSG == 0 || (drawSSG == 1 && cg_RQ3_overlaycrosshair.integer == 1)) { if (drawSSG == 0 || (drawSSG == 1 && cg_RQ3_overlaycrosshair.integer == 1)) {
x = cg_crosshairX.integer; float half = w * 0.5f;
y = cg_crosshairY.integer; x = cg_crosshairX.integer + SCREEN_WIDTH / 2;
CG_AdjustFrom640(&x, &y, &w, &h); y = cg_crosshairY.integer + SCREEN_HEIGHT / 2;
ca = cg_drawCrosshair.integer; ca = cg_drawCrosshair.integer;
if (ca < 0) { if (ca < 0) {
@ -2053,8 +2053,7 @@ static void CG_DrawCrosshair(void)
} }
trap_R_SetColor(crosshairColor); trap_R_SetColor(crosshairColor);
trap_R_DrawStretchPic(x + cg.refdef.x + 0.5 * (cg.refdef.width - w), CG_DrawPic(x - half, y - half, w, h, hShader);
y + cg.refdef.y + 0.5 * (cg.refdef.height - h), w, h, 0, 0, 1, 1, hShader);
trap_R_SetColor(NULL); trap_R_SetColor(NULL);
} }
} }
@ -2208,19 +2207,19 @@ static void CG_DrawVote(void)
MAKERGBA(Color1, 0.0f, 0.0f, 0.0f, 0.4f); MAKERGBA(Color1, 0.0f, 0.0f, 0.0f, 0.4f);
CG_FillRect(1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4, CG_FillRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, Color1); SMALLCHAR_HEIGHT + 4, Color1);
CG_DrawCleanRect(1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4, CG_DrawCleanRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, 1, colorBlack); SMALLCHAR_HEIGHT + 4, 1, colorBlack);
CG_DrawStringExt(3, y+2, s, colorWhite, qtrue, qfalse, CG_DrawStringExt(cgs.screenXMin + 3, y+2, s, colorWhite, qtrue, qfalse,
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100); SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100);
y += SMALLCHAR_HEIGHT + 3; y += SMALLCHAR_HEIGHT + 3;
CG_FillRect(1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4, CG_FillRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, Color1); SMALLCHAR_HEIGHT + 4, Color1);
CG_DrawCleanRect(1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4, CG_DrawCleanRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, 1, colorBlack); SMALLCHAR_HEIGHT + 4, 1, colorBlack);
CG_DrawStringExt(3, y + 2, s2, colorWhite, qtrue, qfalse, CG_DrawStringExt(cgs.screenXMin + 3, y + 2, s2, colorWhite, qtrue, qfalse,
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100); SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100);
} }
@ -2265,19 +2264,19 @@ static void CG_DrawTeamVote(void)
MAKERGBA(Color1, 0.0f, 0.0f, 0.0f, 0.4f); MAKERGBA(Color1, 0.0f, 0.0f, 0.0f, 0.4f);
CG_FillRect(1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4, CG_FillRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, Color1); SMALLCHAR_HEIGHT + 4, Color1);
CG_DrawCleanRect(1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4, CG_DrawCleanRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, 1, colorBlack); SMALLCHAR_HEIGHT + 4, 1, colorBlack);
CG_DrawStringExt(3, y+2, s, colorWhite, qtrue, qfalse, CG_DrawStringExt(cgs.screenXMin + 3, y+2, s, colorWhite, qtrue, qfalse,
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100); SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100);
y += SMALLCHAR_HEIGHT + 3; y += SMALLCHAR_HEIGHT + 3;
CG_FillRect(1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4, CG_FillRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, Color1); SMALLCHAR_HEIGHT + 4, Color1);
CG_DrawCleanRect(1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4, CG_DrawCleanRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, 1, colorBlack); SMALLCHAR_HEIGHT + 4, 1, colorBlack);
CG_DrawStringExt(3, y + 2, s2, colorWhite, qtrue, qfalse, CG_DrawStringExt(cgs.screenXMin + 3, y + 2, s2, colorWhite, qtrue, qfalse,
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100); SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100);
} }
@ -2662,7 +2661,7 @@ static void CG_DrawDamageBlend()
else if (damageColor[3] < 0) else if (damageColor[3] < 0)
damageColor[3] = 0; damageColor[3] = 0;
CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, damageColor); CG_FillRect(cgs.screenXMin, 0, cgs.screenWidth, SCREEN_HEIGHT, damageColor);
} }
/* /*

View File

@ -45,14 +45,8 @@ Adjusted for resolution and screen aspect ratio
*/ */
void CG_AdjustFrom640(float *x, float *y, float *w, float *h) void CG_AdjustFrom640(float *x, float *y, float *w, float *h)
{ {
#if 0
// adjust for wide screens
if (cgs.glconfig.vidWidth * 480 > cgs.glconfig.vidHeight * 640) {
*x += 0.5 * (cgs.glconfig.vidWidth - (cgs.glconfig.vidHeight * 640 / 480));
}
#endif
// scale for screen sizes // scale for screen sizes
*x *= cgs.screenXScale; *x = *x * cgs.screenXScale + cgs.screenXBias;
*y *= cgs.screenYScale; *y *= cgs.screenYScale;
*w *= cgs.screenXScale; *w *= cgs.screenXScale;
*h *= cgs.screenYScale; *h *= cgs.screenYScale;

View File

@ -1672,6 +1672,10 @@ typedef struct {
float screenYScale; float screenYScale;
float screenXBias; float screenXBias;
float screenXMin; // Makro - derived from glconfig, used for wide-screens
float screenXMax;
float screenWidth;
int serverCommandSequence; // reliable command stream counter int serverCommandSequence; // reliable command stream counter
int processedSnapshotNum; // the number of snapshots cgame has requested int processedSnapshotNum; // the number of snapshots cgame has requested

View File

@ -2963,8 +2963,13 @@ void CG_Init(int serverMessageNum, int serverCommandSequence, int clientNum)
// get the rendering configuration from the client system // get the rendering configuration from the client system
trap_GetGlconfig(&cgs.glconfig); trap_GetGlconfig(&cgs.glconfig);
cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight * (1.f / SCREEN_HEIGHT);
cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; cgs.screenXScale = cgs.screenYScale;
cgs.screenXBias = 0.5f * (cgs.glconfig.vidWidth - (cgs.glconfig.vidHeight * SCREEN_WIDTH / (float)SCREEN_HEIGHT));
cgs.screenXMin = 0.5f * (SCREEN_WIDTH - SCREEN_HEIGHT * cgs.glconfig.vidWidth / (float)cgs.glconfig.vidHeight);
cgs.screenXMax = SCREEN_WIDTH - cgs.screenXMin;
cgs.screenWidth = cgs.screenXMax - cgs.screenXMin;
// get the gamestate from the client system // get the gamestate from the client system
trap_GetGameState(&cgs.gameState); trap_GetGameState(&cgs.gameState);

View File

@ -1231,7 +1231,7 @@ void CG_AddLensFlare(qboolean sun)
color[3] = (cgs.flareForwardFactor - ffov) / (1 - ffov) * cgs.flareFadeFactor * FLARE_BLIND_ALPHA; color[3] = (cgs.flareForwardFactor - ffov) / (1 - ffov) * cgs.flareFadeFactor * FLARE_BLIND_ALPHA;
//Makro - too expensive //Makro - too expensive
//color[3] = cgs.sunAlpha * cgs.flareFadeFactor * FLARE_BLIND_ALPHA * (1.0f - abs(320 - cgs.lastSunX) / 320.0f) * (1.0f - abs(240 - cgs.lastSunY) / 240.0f); //color[3] = cgs.sunAlpha * cgs.flareFadeFactor * FLARE_BLIND_ALPHA * (1.0f - abs(320 - cgs.lastSunX) / 320.0f) * (1.0f - abs(240 - cgs.lastSunY) / 240.0f);
CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, color); CG_FillRect(cgs.screenXMin, 0, cgs.screenWidth, SCREEN_HEIGHT, color);
} }
} }
} }