Jedi Outcast/Academy source code releases
Posted: Thu Apr 04, 2013 6:01 pm

Throwing my hat in the ring here, native widescreen/surround/triplehead/eyefinity support would be absolutely incredible. I've submitted a feature request here: https://github.com/Razish/OpenJK/issues/36Knightmare wrote:It also contains what appears to be the source for the random map generator used in SOF2 (under code/rmg). Maybe that could be gotten working- its implementation did use a lot of scripts in SOF2.
More ideas:
- (OpenJK) Implement native widescreen/surround support with properly scaled FOV and anamorphic screen coord scaling (avoid stretched menus/HUD).
- Implement its BSP format in Q3 and/or Q2 (it has the lightstyles from Q1 and Q2 that were removed for Q3).
Code: Select all
vidmode_t r_vidModes[] =
{
{ "Mode 0: 320x240", 320, 240, 1 },
{ "Mode 1: 400x300", 400, 300, 1 },
{ "Mode 2: 512x384", 512, 384, 1 },
{ "Mode 3: 640x480", 640, 480, 1 },
{ "Mode 4: 800x600", 800, 600, 1 },
{ "Mode 5: 960x720", 960, 720, 1 },
{ "Mode 6: 1024x768", 1024, 768, 1 },
{ "Mode 7: 1152x864", 1152, 864, 1 },
{ "Mode 8: 1280x960", 1280, 960, 1 }, // Knightmare added
{ "Mode 9: 1280x1024", 1280, 1024, 1 },
{ "Mode 10: 1400x1050", 1400, 1050, 1 }, // Knightmare added
{ "Mode 11: 1600x1200", 1600, 1200, 1 },
{ "Mode 12: 1920x1440", 1920, 1440, 1 }, // Knightmare added
{ "Mode 13: 2048x1536", 2048, 1536, 1 },
{ "Mode 14: 800x480 (wide)", 800, 480, 1 }, // Knightmare added
{ "Mode 15: 856x480 (wide)", 856, 480, 1 },
{ "Mode 16: 1024x600 (wide)", 1024, 600, 1 }, // Knightmare added
{ "Mode 17: 1280x720 (wide)", 1280, 720, 1 }, // Knightmare added
{ "Mode 18: 1280x768 (wide)", 1280, 768, 1 }, // Knightmare added
{ "Mode 19: 1280x800 (wide)", 1280, 800, 1 }, // Knightmare added
{ "Mode 20: 1360x768 (wide)", 1360, 768, 1 }, // Knightmare added
{ "Mode 21: 1366x768 (wide)", 1366, 768, 1 }, // Knightmare added
{ "Mode 22: 1440x900 (wide)", 1440, 900, 1 }, // Knightmare added
{ "Mode 23: 1600x900 (wide)", 1600, 900, 1 }, // Knightmare added
{ "Mode 24: 1600x1024 (wide)", 1600, 1024, 1 }, // Knightmare added
{ "Mode 25: 1680x1050 (wide)", 1680, 1050, 1 }, // Knightmare added
{ "Mode 26: 1920x1080 (wide)", 1920, 1080, 1 }, // Knightmare added
{ "Mode 27: 1920x1200 (wide)", 1920, 1200, 1 }, //----(SA) added
{ "Mode 28: 2560x1080 (ultra-wide)", 2560, 1080, 1 }, // Knightmare added
{ "Mode 29: 2560x1440 (wide)", 2560, 1440, 1 }, // Knightmare added
{ "Mode 30: 2560x1600 (wide)", 2560, 1600, 1 } // Knightmare added
};
Code: Select all
// Knightmare- screen item alignment types
typedef enum
{
ALIGN_STRETCH,
ALIGN_CENTER,
ALIGN_LETTERBOX,
ALIGN_TOP,
ALIGN_BOTTOM,
ALIGN_RIGHT,
ALIGN_LEFT,
ALIGN_TOPRIGHT,
ALIGN_TOPLEFT,
ALIGN_BOTTOMRIGHT,
ALIGN_BOTTOMLEFT,
ALIGN_TOP_STRETCH,
ALIGN_BOTTOM_STRETCH
} scralign_t;
Code: Select all
void SCR_AdjustFrom640( float *x, float *y, float *w, float *h, scralign_t align ) {
float xscale, yscale, avgscale, vertscale; // Knightmare added
float tmp_x, tmp_y, tmp_w, tmp_h; // Knightmare added
// scale for screen sizes
xscale = cls.glconfig.vidWidth / 640.0;
yscale = cls.glconfig.vidHeight / 480.0;
avgscale = min (xscale, yscale);
// hack for 4:3 modes
if ( !(xscale > yscale) && align != ALIGN_LETTERBOX)
align = ALIGN_STRETCH;
// Knightmare- added anamorphic code
switch (align)
{
case ALIGN_CENTER:
if (x) {
tmp_x = *x;
*x = (tmp_x - (0.5 * SCREEN_WIDTH)) * avgscale + (0.5 * cls.glconfig.vidWidth);
}
if (y) {
tmp_y = *y;
*y = (tmp_y - (0.5 * SCREEN_HEIGHT)) * avgscale + (0.5 * cls.glconfig.vidHeight);
}
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
break;
case ALIGN_LETTERBOX:
// special case: video mode (eyefinity?) is wider than object
if ( w != NULL && h != NULL && ((float)cls.glconfig.vidWidth / (float)cls.glconfig.vidHeight > *w / *h) ) {
tmp_h = *h;
vertscale = cls.glconfig.vidHeight / tmp_h;
if (x != NULL && w != NULL) {
tmp_x = *x;
tmp_w = *w;
*x = tmp_x * xscale - (0.5 * (tmp_w * vertscale - tmp_w * xscale));
}
if (y)
*y = 0;
if (w)
*w *= vertscale;
if (h)
*h *= vertscale;
}
else {
if (x)
*x *= xscale;
if (y != NULL && h != NULL) {
tmp_y = *y;
tmp_h = *h;
*y = tmp_y * yscale - (0.5 * (tmp_h * xscale - tmp_h * yscale));
}
if (w)
*w *= xscale;
if (h)
*h *= xscale;
}
break;
case ALIGN_TOP:
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
if (x) {
tmp_x = *x;
*x = (tmp_x - (0.5 * SCREEN_WIDTH)) * avgscale + (0.5 * cls.glconfig.vidWidth);
}
if (y)
*y *= avgscale;
break;
case ALIGN_BOTTOM:
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
if (x) {
tmp_x = *x;
*x = (tmp_x - (0.5 * SCREEN_WIDTH)) * avgscale + (0.5 * cls.glconfig.vidWidth);
}
if (y) {
tmp_y = *y;
*y = (tmp_y - SCREEN_HEIGHT) * avgscale + cls.glconfig.vidHeight;
}
break;
case ALIGN_RIGHT:
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
if (x) {
tmp_x = *x;
*x = (tmp_x - SCREEN_WIDTH) * avgscale + cls.glconfig.vidWidth;
}
if (y) {
tmp_y = *y;
*y = (tmp_y - (0.5 * SCREEN_HEIGHT)) * avgscale + (0.5 * cls.glconfig.vidHeight);
}
break;
case ALIGN_LEFT:
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
if (x)
*x *= avgscale;
if (y) {
tmp_y = *y;
*y = (tmp_y - (0.5 * SCREEN_HEIGHT)) * avgscale + (0.5 * cls.glconfig.vidHeight);
}
break;
case ALIGN_TOPRIGHT:
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
if (x) {
tmp_x = *x;
*x = (tmp_x - SCREEN_WIDTH) * avgscale + cls.glconfig.vidWidth;
}
if (y)
*y *= avgscale;
break;
case ALIGN_TOPLEFT:
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
if (x)
*x *= avgscale;
if (y)
*y *= avgscale;
break;
case ALIGN_BOTTOMRIGHT:
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
if (x) {
tmp_x = *x;
*x = (tmp_x - SCREEN_WIDTH) * avgscale + cls.glconfig.vidWidth;
}
if (y) {
tmp_y = *y;
*y = (tmp_y - SCREEN_HEIGHT) * avgscale + cls.glconfig.vidHeight;
}
break;
case ALIGN_BOTTOMLEFT:
if (w)
*w *= avgscale;
if (h)
*h *= avgscale;
if (x)
*x *= avgscale;
if (y) {
tmp_y = *y;
*y = (tmp_y - SCREEN_HEIGHT) * avgscale + cls.glconfig.vidHeight;
}
break;
case ALIGN_TOP_STRETCH:
if (w)
*w *= xscale;
if (h)
*h *= avgscale;
if (x)
*x *= xscale;
if (y)
*y *= avgscale;
break;
case ALIGN_BOTTOM_STRETCH:
if (w)
*w *= xscale;
if (h)
*h *= avgscale;
if (x)
*x *= xscale;
if (y) {
tmp_y = *y;
*y = (tmp_y - SCREEN_HEIGHT) * avgscale + cls.glconfig.vidHeight;
}
break;
case ALIGN_STRETCH:
default:
if (x)
*x *= xscale;
if (y)
*y *= yscale;
if (w)
*w *= xscale;
if (h)
*h *= yscale;
break;
}
}Code: Select all
#define STANDARD_ASPECT_RATIO ((float)640/(float)480) // Knightmare added
Code: Select all
// Knightmare- adjust fov_x for wide screen aspect
if (cg_widescreen_fov.value)
{
float aspectRatio = (float)cg.refdef.width/(float)cg.refdef.height;
if (aspectRatio > STANDARD_ASPECT_RATIO)
fov_x = RAD2DEG( 2 * atan( (aspectRatio / STANDARD_ASPECT_RATIO) * tan(DEG2RAD(fov_x) * 0.5) ) );
fov_x = min(fov_x, 160);
}
// end Knightmare
x = cg.refdef.width / tan( fov_x / 360 * M_PI );
fov_y = atan2( cg.refdef.height, x );
fov_y = fov_y * 360 / M_PI;
Code: Select all
// wide aspect ratio screens need to have the sides cleared
// unless they are displaying game renderings
#ifndef _XBOX
// Xbox no want this
if ( cls.state != CA_ACTIVE ) {
if ( cls.glconfig.vidWidth * 480 > cls.glconfig.vidHeight * 640 ) {
re.SetColor( g_color_table[0] );
re.DrawStretchPic( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, 0, 0, 0, 0 );
re.SetColor( NULL );
}
}
#endif
Code: Select all
void CIN_DrawCinematic( int handle ) {
float barheight, barwidth, vw, vh; // Knightmare added
.
.
.
x = cinTable[handle].xpos;
y = cinTable[handle].ypos;
w = cinTable[handle].width;
h = cinTable[handle].height;
// Knightmare- use letterbox scaling if specified
if ( cinTable[handle].letterBox )
SCR_AdjustFrom640( &x, &y, &w, &h, ALIGN_LETTERBOX );
else
SCR_AdjustFrom640( &x, &y, &w, &h, ALIGN_CENTER );
vw = (float)cls.glconfig.vidWidth;
vh = (float)cls.glconfig.vidHeight;
.
.
.
// Knightmare- add pillarbox bars when needed
barwidth = 0.5 * (vw - w);
barheight = vh;
if (barwidth > 0) {
re.SetColor( &colorBlack[0] );
re.DrawStretchPic( 0, 0, barwidth, barheight, 0, 0, 0, 0, cls.whiteShader );
re.DrawStretchPic( vw - barwidth - 1, 0, barwidth + 1, barheight, 0, 0, 0, 0, cls.whiteShader );
}
// end Knightmare
if ( cinTable[handle].dirty && ( cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY ) ) {
.
.
.
.
}
.
.
}
The menu scripts are not included for me.Knightmare wrote:(good thing the menu files are included with the GPLed source)