Custom aspect ratio support for Polymer: r_pr_customaspect. Implements bug 2799107.

git-svn-id: https://svn.eduke32.com/eduke32@1507 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2009-09-30 14:32:11 +00:00
parent 13873b985c
commit dee579c030
3 changed files with 12 additions and 4 deletions

View file

@ -40,6 +40,7 @@ extern int32_t pr_shadowfiltering;
extern int32_t pr_maxlightpasses; extern int32_t pr_maxlightpasses;
extern int32_t pr_maxlightpriority; extern int32_t pr_maxlightpriority;
extern int32_t pr_fov; extern int32_t pr_fov;
extern float pr_customaspect;
extern int32_t pr_billboardingmode; extern int32_t pr_billboardingmode;
extern int32_t pr_verbosity; extern int32_t pr_verbosity;
extern int32_t pr_wireframe; extern int32_t pr_wireframe;

View file

@ -17,6 +17,7 @@ int32_t pr_shadowfiltering = 1;
int32_t pr_maxlightpasses = 10; int32_t pr_maxlightpasses = 10;
int32_t pr_maxlightpriority = PR_MAXLIGHTPRIORITY; int32_t pr_maxlightpriority = PR_MAXLIGHTPRIORITY;
int32_t pr_fov = 426; // appears to be the classic setting. int32_t pr_fov = 426; // appears to be the classic setting.
float pr_customaspect = 0.0f;
int32_t pr_billboardingmode = 1; int32_t pr_billboardingmode = 1;
int32_t pr_verbosity = 1; // 0: silent, 1: errors and one-times, 2: multiple-times, 3: flood int32_t pr_verbosity = 1; // 0: silent, 1: errors and one-times, 2: multiple-times, 3: flood
int32_t pr_wireframe = 0; int32_t pr_wireframe = 0;
@ -664,6 +665,8 @@ void polymer_uninit(void)
void polymer_glinit(void) void polymer_glinit(void)
{ {
float aspect;
bglClearColor(0.0f, 0.0f, 0.0f, 1.0f); bglClearColor(0.0f, 0.0f, 0.0f, 1.0f);
bglClearStencil(0); bglClearStencil(0);
bglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); bglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@ -685,12 +688,15 @@ void polymer_glinit(void)
else else
bglPolygonMode(GL_FRONT_AND_BACK, GL_FILL); bglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (pr_customaspect != 0.0f)
aspect = pr_customaspect;
else
aspect = (float)(windowx2-windowx1+1) /
(float)(windowy2-windowy1+1);
bglMatrixMode(GL_PROJECTION); bglMatrixMode(GL_PROJECTION);
bglLoadIdentity(); bglLoadIdentity();
bgluPerspective((float)(pr_fov) / (2048.0f / 360.0f), bgluPerspective((float)(pr_fov) / (2048.0f / 360.0f), aspect, 0.01f, 100.0f);
(float)(windowx2-windowx1+1) /
(float)(windowy2-windowy1+1),
0.01f, 100.0f);
bglMatrixMode(GL_MODELVIEW); bglMatrixMode(GL_MODELVIEW);
bglLoadIdentity(); bglLoadIdentity();

View file

@ -5965,6 +5965,7 @@ void polymost_initosdfuncs(void)
{ "r_pr_maxlightpasses", "r_pr_maxlightpasses: the maximal amount of lights a single object can by affected by", (void*)&r_pr_maxlightpasses, CVAR_INT|CVAR_FUNCPTR, 0, 0, PR_MAXLIGHTS }, { "r_pr_maxlightpasses", "r_pr_maxlightpasses: the maximal amount of lights a single object can by affected by", (void*)&r_pr_maxlightpasses, CVAR_INT|CVAR_FUNCPTR, 0, 0, PR_MAXLIGHTS },
{ "r_pr_maxlightpriority", "r_pr_maxlightpriority: lowering that value removes less meaningful lights from the scene", (void*)&pr_maxlightpriority, CVAR_INT, 0, 0, PR_MAXLIGHTPRIORITY }, { "r_pr_maxlightpriority", "r_pr_maxlightpriority: lowering that value removes less meaningful lights from the scene", (void*)&pr_maxlightpriority, CVAR_INT, 0, 0, PR_MAXLIGHTPRIORITY },
{ "r_pr_fov", "r_pr_fov: sets the field of vision in build angle", (void*)&pr_fov, CVAR_INT, 0, 0, 1023}, { "r_pr_fov", "r_pr_fov: sets the field of vision in build angle", (void*)&pr_fov, CVAR_INT, 0, 0, 1023},
{ "r_pr_customaspect", "r_pr_customaspect: if non-zero, forces the 3D view aspect ratio", (void*)&pr_customaspect, CVAR_FLOAT, 0, 0, 3 },
{ "r_pr_billboardingmode", "r_pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode", (void*)&pr_billboardingmode, CVAR_INT, 0, 0, 1 }, { "r_pr_billboardingmode", "r_pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode", (void*)&pr_billboardingmode, CVAR_INT, 0, 0, 1 },
{ "r_pr_verbosity", "r_pr_verbosity: verbosity level of the polymer renderer", (void*)&pr_verbosity, CVAR_INT, 0, 0, 3 }, { "r_pr_verbosity", "r_pr_verbosity: verbosity level of the polymer renderer", (void*)&pr_verbosity, CVAR_INT, 0, 0, 3 },
{ "r_pr_wireframe", "r_pr_wireframe: toggles wireframe mode", (void*)&pr_wireframe, CVAR_INT | CVAR_NOSAVE, 0, 0, 1 }, { "r_pr_wireframe", "r_pr_wireframe: toggles wireframe mode", (void*)&pr_wireframe, CVAR_INT | CVAR_NOSAVE, 0, 0, 1 },