mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Format renderergl1 source files
This commit is contained in:
parent
f86b495cc6
commit
49b5c29c11
7 changed files with 1448 additions and 1451 deletions
|
@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.12)
|
|||
project(omohrenderergl1)
|
||||
|
||||
file(GLOB_RECURSE SOURCES_RENDERER "./*.c" "./*.cpp")
|
||||
list(REMOVE_ITEM SOURCES_RENDERER "./tr_subs.c")
|
||||
|
||||
set(SOURCES_RENDERER ${SOURCES_RENDERER}
|
||||
"../tiki/tiki_mesh.cpp"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2023 the OpenMoHAA team
|
||||
Copyright (C) 2024 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
|
|
|
@ -1651,8 +1651,6 @@ extern cvar_t* r_fps;
|
|||
|
||||
void R_NoiseInit( void );
|
||||
|
||||
void R_DebugCircle(const vec3_t org, float radius, float r, float g, float b, float alpha, qboolean horizontal);
|
||||
void R_DebugLine(const vec3_t start, const vec3_t end, float r, float g, float b, float alpha);
|
||||
void R_RenderView( viewParms_t *parms );
|
||||
|
||||
qboolean SurfIsOffscreen(const srfSurfaceFace_t* surface, shader_t* shader, int entityNum);
|
||||
|
@ -2106,6 +2104,18 @@ float R_GetFontStringWidth(const fontheader_t* font, const char* s);
|
|||
/*
|
||||
=============================================================
|
||||
|
||||
GHOST
|
||||
|
||||
=============================================================
|
||||
*/
|
||||
|
||||
void R_UpdateGhostTextures();
|
||||
void R_SetGhostImage(const char* name, image_t* image);
|
||||
void LoadGHOST(const char* name, byte** pic, int* width, int* height);
|
||||
|
||||
/*
|
||||
=============================================================
|
||||
|
||||
MARKS
|
||||
|
||||
=============================================================
|
||||
|
@ -2230,6 +2240,7 @@ UTIL
|
|||
|
||||
=============================================================
|
||||
*/
|
||||
|
||||
void RB_StreamBegin(shader_t* shader);
|
||||
void RB_StreamEnd(void);
|
||||
void RB_StreamBeginDrawSurf(void);
|
||||
|
@ -2246,23 +2257,13 @@ void RB_Texcoord2f(float s, float t);
|
|||
void RB_Texcoord2fv(vec2_t st);
|
||||
void R_DrawDebugNumber(const vec3_t org, float number, float scale, float r, float g, float b, int precision);
|
||||
void R_DebugRotatedBBox(const vec3_t org, const vec3_t ang, const vec3_t mins, const vec3_t maxs, float r, float g, float b, float alpha);
|
||||
void R_DebugCircle(const vec3_t org, float radius, float r, float g, float b, float alpha, qboolean horizontal);
|
||||
void R_DebugLine(const vec3_t start, const vec3_t end, float r, float g, float b, float alpha);
|
||||
int RE_GetShaderWidth(qhandle_t hShader);
|
||||
int RE_GetShaderHeight(qhandle_t hShader);
|
||||
const char* RE_GetShaderName(qhandle_t hShader);
|
||||
const char* RE_GetModelName(qhandle_t hModel);
|
||||
|
||||
/*
|
||||
=============================================================
|
||||
|
||||
GHOST
|
||||
|
||||
=============================================================
|
||||
*/
|
||||
|
||||
void R_UpdateGhostTextures();
|
||||
void R_SetGhostImage(const char* name, image_t* image);
|
||||
void LoadGHOST(const char* name, byte** pic, int* width, int* height);
|
||||
|
||||
/*
|
||||
=============================================================
|
||||
=============================================================
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -32,8 +32,8 @@ R_Sky_Init
|
|||
*/
|
||||
void R_Sky_Init()
|
||||
{
|
||||
tr.viewParms.isPortalSky = qfalse;
|
||||
tr.portalsky.numSurfs = 0;
|
||||
tr.viewParms.isPortalSky = qfalse;
|
||||
tr.portalsky.numSurfs = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -48,14 +48,14 @@ void R_Sky_Reset()
|
|||
return;
|
||||
}
|
||||
|
||||
tr.portalsky.mins[0] = 8192.0;
|
||||
tr.portalsky.mins[1] = 8192.0;
|
||||
tr.portalsky.mins[2] = 8192.0;
|
||||
tr.portalsky.maxs[0] = -8192.0;
|
||||
tr.portalsky.maxs[1] = -8192.0;
|
||||
tr.portalsky.maxs[2] = -8192.0;
|
||||
tr.portalsky.cntNode = 0;
|
||||
tr.portalsky.numSurfs = 0;
|
||||
tr.portalsky.mins[0] = 8192.0;
|
||||
tr.portalsky.mins[1] = 8192.0;
|
||||
tr.portalsky.mins[2] = 8192.0;
|
||||
tr.portalsky.maxs[0] = -8192.0;
|
||||
tr.portalsky.maxs[1] = -8192.0;
|
||||
tr.portalsky.maxs[2] = -8192.0;
|
||||
tr.portalsky.cntNode = 0;
|
||||
tr.portalsky.numSurfs = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -64,39 +64,36 @@ R_Sky_AddSurf
|
|||
|
||||
=================
|
||||
*/
|
||||
void R_Sky_AddSurf(msurface_t* surf)
|
||||
void R_Sky_AddSurf(msurface_t *surf)
|
||||
{
|
||||
if (tr.viewParms.isPortalSky)
|
||||
{
|
||||
static int last_sky_warning = 0;
|
||||
if (tr.viewParms.isPortalSky) {
|
||||
static int last_sky_warning = 0;
|
||||
|
||||
if (tr.refdef.time - 1000 > last_sky_warning)
|
||||
{
|
||||
ri.Printf(3, "WARNING: sky being drawn in a sky portal! Bad! Bad!\n");
|
||||
last_sky_warning = tr.refdef.time;
|
||||
}
|
||||
if (tr.refdef.time - 1000 > last_sky_warning) {
|
||||
ri.Printf(3, "WARNING: sky being drawn in a sky portal! Bad! Bad!\n");
|
||||
last_sky_warning = tr.refdef.time;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (tr.portalsky.numSurfs < 32) {
|
||||
tr.portalsky.skySurfs[tr.portalsky.numSurfs++] = surf;
|
||||
}
|
||||
if (tr.portalsky.numSurfs < 32) {
|
||||
tr.portalsky.skySurfs[tr.portalsky.numSurfs++] = surf;
|
||||
}
|
||||
|
||||
if (tr.portalsky.cntNode)
|
||||
{
|
||||
int i;
|
||||
if (tr.portalsky.cntNode) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (tr.portalsky.mins[i] >= tr.portalsky.cntNode->mins[i]) {
|
||||
tr.portalsky.mins[i] = tr.portalsky.cntNode->mins[i];
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (tr.portalsky.mins[i] >= tr.portalsky.cntNode->mins[i]) {
|
||||
tr.portalsky.mins[i] = tr.portalsky.cntNode->mins[i];
|
||||
}
|
||||
|
||||
if (tr.portalsky.maxs[i] >= tr.portalsky.cntNode->maxs[i]) {
|
||||
tr.portalsky.maxs[i] = tr.portalsky.cntNode->maxs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tr.portalsky.maxs[i] >= tr.portalsky.cntNode->maxs[i]) {
|
||||
tr.portalsky.maxs[i] = tr.portalsky.cntNode->maxs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -105,10 +102,11 @@ R_Sky_Render
|
|||
|
||||
=================
|
||||
*/
|
||||
void R_Sky_Render() {
|
||||
int i;
|
||||
void R_Sky_Render()
|
||||
{
|
||||
int i;
|
||||
viewParms_t newParms, oldParms;
|
||||
mnode_t* leaf;
|
||||
mnode_t *leaf;
|
||||
|
||||
if (!tr.portalsky.numSurfs) {
|
||||
return;
|
||||
|
@ -123,12 +121,16 @@ void R_Sky_Render() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (tr.viewParms.isPortalSky) {
|
||||
return;
|
||||
}
|
||||
if (tr.viewParms.isPortalSky) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < tr.portalsky.numSurfs; i++) {
|
||||
if (!SurfIsOffscreen((const srfSurfaceFace_t*)tr.portalsky.skySurfs[i]->data, tr.portalsky.skySurfs[i]->shader, ENTITYNUM_WORLD)) {
|
||||
if (!SurfIsOffscreen(
|
||||
(const srfSurfaceFace_t *)tr.portalsky.skySurfs[i]->data,
|
||||
tr.portalsky.skySurfs[i]->shader,
|
||||
ENTITYNUM_WORLD
|
||||
)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -140,30 +142,33 @@ void R_Sky_Render() {
|
|||
oldParms = tr.viewParms;
|
||||
newParms = tr.viewParms;
|
||||
|
||||
if (r_skyportal->integer)
|
||||
{
|
||||
if (sscanf(r_skyportal_origin->string, "%f %f %f", &newParms.ori.origin[0], &newParms.ori.origin[1], &newParms.ori.origin[2]) != 3)
|
||||
{
|
||||
ri.Printf(PRINT_WARNING, "WARNING: Invalid sky portal origin: %s\n", r_skyportal_origin->string);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (r_skyportal->integer) {
|
||||
if (sscanf(
|
||||
r_skyportal_origin->string,
|
||||
"%f %f %f",
|
||||
&newParms.ori.origin[0],
|
||||
&newParms.ori.origin[1],
|
||||
&newParms.ori.origin[2]
|
||||
)
|
||||
!= 3) {
|
||||
ri.Printf(PRINT_WARNING, "WARNING: Invalid sky portal origin: %s\n", r_skyportal_origin->string);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
VectorCopy(tr.refdef.sky_origin, newParms.ori.origin);
|
||||
MatrixMultiply(newParms.ori.axis, tr.refdef.sky_axis, newParms.ori.axis);
|
||||
}
|
||||
MatrixMultiply(newParms.ori.axis, tr.refdef.sky_axis, newParms.ori.axis);
|
||||
}
|
||||
|
||||
VectorCopy(newParms.ori.origin, newParms.pvsOrigin);
|
||||
newParms.isPortalSky = qtrue;
|
||||
newParms.farplane_distance = tr.refdef.skybox_farplane;
|
||||
newParms.renderTerrain = tr.refdef.render_terrain;
|
||||
newParms.isPortalSky = qtrue;
|
||||
newParms.farplane_distance = tr.refdef.skybox_farplane;
|
||||
newParms.renderTerrain = tr.refdef.render_terrain;
|
||||
|
||||
if (oldParms.farplane_bias == 0.0 || oldParms.farplane_distance == 0.0) {
|
||||
newParms.farplane_bias = 0.0;
|
||||
} else {
|
||||
newParms.farplane_bias = newParms.farplane_distance / oldParms.farplane_distance * oldParms.farplane_bias;
|
||||
}
|
||||
if (oldParms.farplane_bias == 0.0 || oldParms.farplane_distance == 0.0) {
|
||||
newParms.farplane_bias = 0.0;
|
||||
} else {
|
||||
newParms.farplane_bias = newParms.farplane_distance / oldParms.farplane_distance * oldParms.farplane_bias;
|
||||
}
|
||||
|
||||
leaf = R_PointInLeaf(newParms.pvsOrigin);
|
||||
if (leaf) {
|
||||
|
@ -172,11 +177,11 @@ void R_Sky_Render() {
|
|||
|
||||
tr.viewParms = oldParms;
|
||||
|
||||
tr.portalsky.numSurfs = 0;
|
||||
tr.skyRendered = qtrue;
|
||||
tr.portalsky.numSurfs = 0;
|
||||
tr.skyRendered = qtrue;
|
||||
|
||||
R_RotateForViewer();
|
||||
R_SetupFrustum();
|
||||
R_RotateForViewer();
|
||||
R_SetupFrustum();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -185,12 +190,13 @@ R_Sky_ChangeFrustum
|
|||
|
||||
=================
|
||||
*/
|
||||
void R_Sky_ChangeFrustum() {
|
||||
cplane_t* frust;
|
||||
int i;
|
||||
vec3_t bounds[2];
|
||||
vec3_t origin;
|
||||
cplane_t abouts[4];
|
||||
void R_Sky_ChangeFrustum()
|
||||
{
|
||||
cplane_t *frust;
|
||||
int i;
|
||||
vec3_t bounds[2];
|
||||
vec3_t origin;
|
||||
cplane_t abouts[4];
|
||||
|
||||
VectorCopy(tr.portalsky.mins, bounds[0]);
|
||||
VectorCopy(tr.portalsky.maxs, bounds[1]);
|
||||
|
@ -203,8 +209,8 @@ void R_Sky_ChangeFrustum() {
|
|||
|
||||
for (i = 0; i < 4; i++) {
|
||||
cplane_t out;
|
||||
int i1;
|
||||
float leastfov = 99999;
|
||||
int i1;
|
||||
float leastfov = 99999;
|
||||
|
||||
frust = &tr.viewParms.frustum[i];
|
||||
|
||||
|
@ -213,9 +219,9 @@ void R_Sky_ChangeFrustum() {
|
|||
|
||||
for (i1 = 0; i1 < 8; i1++) {
|
||||
vec3_t point;
|
||||
vec_t distFromFrustum;
|
||||
float angle;
|
||||
int i2;
|
||||
vec_t distFromFrustum;
|
||||
float angle;
|
||||
int i2;
|
||||
|
||||
for (i2 = 0; i2 < 3; i2++) {
|
||||
point[i2] = bounds[i1 % 3][i2];
|
||||
|
|
|
@ -143,7 +143,7 @@ static void R_InterpolateVert(terraTri_t *pTri, terrainVert_t *pVert)
|
|||
pVert->pHgt = (byte *)(pMinHeight + ((pMaxHeight - pMinHeight) >> 1));
|
||||
assert(pVert->pHgt >= pMinHeight && pVert->pHgt < pMaxHeight);
|
||||
|
||||
// Calculate the average Z
|
||||
// Calculate the average Z
|
||||
pVert->fHgtAvg = (float)(*pVert0->pHgt + *pVert1->pHgt);
|
||||
pVert->fHgtAdd = (float)(*pVert->pHgt * 2) - pVert->fHgtAvg;
|
||||
pVert->fHgtAvg += pPatch->z0;
|
||||
|
|
|
@ -1,61 +1,62 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2024 the OpenMoHAA team
|
||||
|
||||
This file is part of Quake III Arena source code.
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
Quake III Arena source code is free software; you can redistribute it
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Quake III Arena source code is distributed in the hope that it will be
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Quake III Arena source code; if not, write to the Free Software
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// tr_util.c -- renderer utility
|
||||
|
||||
#include "tr_local.h"
|
||||
#include "../qcommon/str.h"
|
||||
|
||||
static byte cntColor[4];
|
||||
static float cntSt[ 2 ];
|
||||
static byte cntColor[4];
|
||||
static float cntSt[2];
|
||||
|
||||
static int Numbers[12][8] = {
|
||||
{ 1, 3, 4, 5, 6, 7, 0, 0 },
|
||||
{ 4, 5, 0, 0, 0, 0, 0, 0 },
|
||||
{ 1, 4, 2, 7, 3, 0, 0, 0 },
|
||||
{ 1, 4, 2, 5, 3, 0, 0, 0 },
|
||||
{ 6, 4, 2, 5, 0, 0, 0, 0 },
|
||||
{ 1, 6, 2, 5, 3, 0, 0, 0 },
|
||||
{ 1, 6, 2, 5, 7, 3, 0, 0 },
|
||||
{ 1, 8, 0, 0, 0, 0, 0, 0 },
|
||||
{ 1, 2, 3, 4, 5, 6, 7, 0 },
|
||||
{ 1, 6, 4, 2, 5, 3, 0, 0 },
|
||||
{ 9, 10, 11, 12, 0, 0, 0, 0 },
|
||||
{ 2, 0, 0, 0, 0, 0, 0, 0 }
|
||||
{1, 3, 4, 5, 6, 7, 0, 0},
|
||||
{4, 5, 0, 0, 0, 0, 0, 0},
|
||||
{1, 4, 2, 7, 3, 0, 0, 0},
|
||||
{1, 4, 2, 5, 3, 0, 0, 0},
|
||||
{6, 4, 2, 5, 0, 0, 0, 0},
|
||||
{1, 6, 2, 5, 3, 0, 0, 0},
|
||||
{1, 6, 2, 5, 7, 3, 0, 0},
|
||||
{1, 8, 0, 0, 0, 0, 0, 0},
|
||||
{1, 2, 3, 4, 5, 6, 7, 0},
|
||||
{1, 6, 4, 2, 5, 3, 0, 0},
|
||||
{9, 10, 11, 12, 0, 0, 0, 0},
|
||||
{2, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static float Lines[13][4] = {
|
||||
{ 0.0, 0.0, 0.0, 0.0 },
|
||||
{ -4.0, 8.0, 4.0, 8.0 },
|
||||
{ -4.0, 4.0, 4.0, 4.0 },
|
||||
{ -4.0, 0.0, 4.0, 0.0 },
|
||||
{ 4.0, 8.0, 4.0, 4.0 },
|
||||
{ 4.0, 4.0, 4.0, 0.0 },
|
||||
{ -4.0, 8.0, -4.0, 4.0 },
|
||||
{ -4.0, 4.0, -4.0, 0.0 },
|
||||
{ 4.0, 8.0, -4.0, 0.0 },
|
||||
{ -1.0, 2.0, 1.0, 2.0 },
|
||||
{ 1.0, 2.0, 1.0, 0.0 },
|
||||
{ -1.0, 0.0, 1.0, 0.0 },
|
||||
{ -1.0, 0.0, -1.0, 2.0 }
|
||||
{0.0, 0.0, 0.0, 0.0},
|
||||
{-4.0, 8.0, 4.0, 8.0},
|
||||
{-4.0, 4.0, 4.0, 4.0},
|
||||
{-4.0, 0.0, 4.0, 0.0},
|
||||
{4.0, 8.0, 4.0, 4.0},
|
||||
{4.0, 4.0, 4.0, 0.0},
|
||||
{-4.0, 8.0, -4.0, 4.0},
|
||||
{-4.0, 4.0, -4.0, 0.0},
|
||||
{4.0, 8.0, -4.0, 0.0},
|
||||
{-1.0, 2.0, 1.0, 2.0},
|
||||
{1.0, 2.0, 1.0, 0.0},
|
||||
{-1.0, 0.0, 1.0, 0.0},
|
||||
{-1.0, 0.0, -1.0, 2.0}
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -63,8 +64,9 @@ static float Lines[13][4] = {
|
|||
RB_StreamBegin
|
||||
===============
|
||||
*/
|
||||
void RB_StreamBegin( shader_t *shader ) {
|
||||
RB_BeginSurface( shader );
|
||||
void RB_StreamBegin(shader_t *shader)
|
||||
{
|
||||
RB_BeginSurface(shader);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -72,26 +74,27 @@ void RB_StreamBegin( shader_t *shader ) {
|
|||
RB_StreamEnd
|
||||
===============
|
||||
*/
|
||||
void RB_StreamEnd( void ) {
|
||||
int i;
|
||||
void RB_StreamEnd(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( tess.numVertexes <= 2 ) {
|
||||
RB_EndSurface();
|
||||
return;
|
||||
}
|
||||
if (tess.numVertexes <= 2) {
|
||||
RB_EndSurface();
|
||||
return;
|
||||
}
|
||||
|
||||
tess.indexes[ 0 ] = 0;
|
||||
tess.indexes[ 1 ] = 1;
|
||||
tess.indexes[ 2 ] = 2;
|
||||
tess.indexes[0] = 0;
|
||||
tess.indexes[1] = 1;
|
||||
tess.indexes[2] = 2;
|
||||
|
||||
for( i = 0; i < tess.numVertexes - 2; i++ ) {
|
||||
tess.indexes[ i * 3 + 0 ] = ( i & 1 ) + i;
|
||||
tess.indexes[ i * 3 + 1 ] = i - ( ( i & 1 ) - 1 );
|
||||
tess.indexes[ i * 3 + 2 ] = i + 2;
|
||||
tess.numIndexes += 3;
|
||||
}
|
||||
for (i = 0; i < tess.numVertexes - 2; i++) {
|
||||
tess.indexes[i * 3 + 0] = (i & 1) + i;
|
||||
tess.indexes[i * 3 + 1] = i - ((i & 1) - 1);
|
||||
tess.indexes[i * 3 + 2] = i + 2;
|
||||
tess.numIndexes += 3;
|
||||
}
|
||||
|
||||
RB_EndSurface();
|
||||
RB_EndSurface();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -99,8 +102,9 @@ void RB_StreamEnd( void ) {
|
|||
RB_StreamBeginDrawSurf
|
||||
===============
|
||||
*/
|
||||
void RB_StreamBeginDrawSurf( void ) {
|
||||
backEnd.dsStreamVert = tess.numVertexes;
|
||||
void RB_StreamBeginDrawSurf(void)
|
||||
{
|
||||
backEnd.dsStreamVert = tess.numVertexes;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -108,22 +112,23 @@ void RB_StreamBeginDrawSurf( void ) {
|
|||
RB_StreamEndDrawSurf
|
||||
===============
|
||||
*/
|
||||
void RB_StreamEndDrawSurf( void ) {
|
||||
int numverts;
|
||||
int i;
|
||||
void RB_StreamEndDrawSurf(void)
|
||||
{
|
||||
int numverts;
|
||||
int i;
|
||||
|
||||
if( tess.numVertexes - backEnd.dsStreamVert <= 2 ) {
|
||||
tess.numVertexes = backEnd.dsStreamVert;
|
||||
return;
|
||||
}
|
||||
if (tess.numVertexes - backEnd.dsStreamVert <= 2) {
|
||||
tess.numVertexes = backEnd.dsStreamVert;
|
||||
return;
|
||||
}
|
||||
|
||||
numverts = tess.numVertexes - backEnd.dsStreamVert - 2;
|
||||
for( i = 0; i < numverts; i++ ) {
|
||||
tess.indexes[ i + tess.numIndexes ] = ( i & 1 ) + i + backEnd.dsStreamVert;
|
||||
tess.indexes[ i + tess.numIndexes + 1 ] = i + backEnd.dsStreamVert - ( ( i & 1 ) - 1 );
|
||||
tess.indexes[ i + tess.numIndexes + 2 ] = i + backEnd.dsStreamVert + 2;
|
||||
tess.numIndexes += 3;
|
||||
}
|
||||
numverts = tess.numVertexes - backEnd.dsStreamVert - 2;
|
||||
for (i = 0; i < numverts; i++) {
|
||||
tess.indexes[i + tess.numIndexes] = (i & 1) + i + backEnd.dsStreamVert;
|
||||
tess.indexes[i + tess.numIndexes + 1] = i + backEnd.dsStreamVert - ((i & 1) - 1);
|
||||
tess.indexes[i + tess.numIndexes + 2] = i + backEnd.dsStreamVert + 2;
|
||||
tess.numIndexes += 3;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -131,15 +136,16 @@ void RB_StreamEndDrawSurf( void ) {
|
|||
addTriangle
|
||||
===============
|
||||
*/
|
||||
static void addTriangle( void ) {
|
||||
tess.texCoords[ tess.numVertexes ][ 0 ][ 0 ] = cntSt[ 0 ];
|
||||
tess.texCoords[ tess.numVertexes ][ 0 ][ 1 ] = cntSt[ 1 ];
|
||||
tess.vertexColors[ tess.numVertexes ][ 0 ] = cntColor[ 0 ];
|
||||
tess.vertexColors[ tess.numVertexes ][ 1 ] = cntColor[ 1 ];
|
||||
tess.vertexColors[ tess.numVertexes ][ 2 ] = cntColor[ 2 ];
|
||||
tess.vertexColors[ tess.numVertexes ][ 3 ] = cntColor[ 3 ];
|
||||
tess.vertexColorValid = qtrue;
|
||||
tess.numVertexes++;
|
||||
static void addTriangle(void)
|
||||
{
|
||||
tess.texCoords[tess.numVertexes][0][0] = cntSt[0];
|
||||
tess.texCoords[tess.numVertexes][0][1] = cntSt[1];
|
||||
tess.vertexColors[tess.numVertexes][0] = cntColor[0];
|
||||
tess.vertexColors[tess.numVertexes][1] = cntColor[1];
|
||||
tess.vertexColors[tess.numVertexes][2] = cntColor[2];
|
||||
tess.vertexColors[tess.numVertexes][3] = cntColor[3];
|
||||
tess.vertexColorValid = qtrue;
|
||||
tess.numVertexes++;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -147,9 +153,10 @@ static void addTriangle( void ) {
|
|||
RB_Vertex3fv
|
||||
===============
|
||||
*/
|
||||
void RB_Vertex3fv( vec3_t v ) {
|
||||
VectorCopy( v, tess.xyz[ tess.numVertexes ] );
|
||||
addTriangle();
|
||||
void RB_Vertex3fv(vec3_t v)
|
||||
{
|
||||
VectorCopy(v, tess.xyz[tess.numVertexes]);
|
||||
addTriangle();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -157,11 +164,12 @@ void RB_Vertex3fv( vec3_t v ) {
|
|||
RB_Vertex3f
|
||||
===============
|
||||
*/
|
||||
void RB_Vertex3f( vec_t x, vec_t y, vec_t z ) {
|
||||
tess.xyz[ tess.numVertexes ][ 0 ] = x;
|
||||
tess.xyz[ tess.numVertexes ][ 1 ] = y;
|
||||
tess.xyz[ tess.numVertexes ][ 2 ] = z;
|
||||
addTriangle();
|
||||
void RB_Vertex3f(vec_t x, vec_t y, vec_t z)
|
||||
{
|
||||
tess.xyz[tess.numVertexes][0] = x;
|
||||
tess.xyz[tess.numVertexes][1] = y;
|
||||
tess.xyz[tess.numVertexes][2] = z;
|
||||
addTriangle();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -169,8 +177,9 @@ void RB_Vertex3f( vec_t x, vec_t y, vec_t z ) {
|
|||
RB_Vertex2f
|
||||
===============
|
||||
*/
|
||||
void RB_Vertex2f( vec_t x, vec_t y ) {
|
||||
RB_Vertex3f( x, y, 0 );
|
||||
void RB_Vertex2f(vec_t x, vec_t y)
|
||||
{
|
||||
RB_Vertex3f(x, y, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -178,11 +187,12 @@ void RB_Vertex2f( vec_t x, vec_t y ) {
|
|||
RB_Color4f
|
||||
===============
|
||||
*/
|
||||
void RB_Color4f( vec_t r, vec_t g, vec_t b, vec_t a ) {
|
||||
cntColor[ 0 ] = r * tr.identityLightByte;
|
||||
cntColor[ 1 ] = g * tr.identityLightByte;
|
||||
cntColor[ 2 ] = b * tr.identityLightByte;
|
||||
cntColor[ 3 ] = a * 255.0;
|
||||
void RB_Color4f(vec_t r, vec_t g, vec_t b, vec_t a)
|
||||
{
|
||||
cntColor[0] = r * tr.identityLightByte;
|
||||
cntColor[1] = g * tr.identityLightByte;
|
||||
cntColor[2] = b * tr.identityLightByte;
|
||||
cntColor[3] = a * 255.0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -190,8 +200,9 @@ void RB_Color4f( vec_t r, vec_t g, vec_t b, vec_t a ) {
|
|||
RB_Color3f
|
||||
===============
|
||||
*/
|
||||
void RB_Color3f( vec_t r, vec_t g, vec_t b ) {
|
||||
RB_Color4f( r, g, b, 1.0 );
|
||||
void RB_Color3f(vec_t r, vec_t g, vec_t b)
|
||||
{
|
||||
RB_Color4f(r, g, b, 1.0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -199,8 +210,9 @@ void RB_Color3f( vec_t r, vec_t g, vec_t b ) {
|
|||
RB_Color3fv
|
||||
===============
|
||||
*/
|
||||
void RB_Color3fv( vec3_t col ) {
|
||||
RB_Color3f( col[ 0 ], col[ 1 ], col[ 2 ] );
|
||||
void RB_Color3fv(vec3_t col)
|
||||
{
|
||||
RB_Color3f(col[0], col[1], col[2]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -208,11 +220,12 @@ void RB_Color3fv( vec3_t col ) {
|
|||
RB_Color4bv
|
||||
===============
|
||||
*/
|
||||
void RB_Color4bv( unsigned char *colors ) {
|
||||
cntColor[ 0 ] = colors[ 0 ];
|
||||
cntColor[ 1 ] = colors[ 1 ];
|
||||
cntColor[ 2 ] = colors[ 2 ];
|
||||
cntColor[ 3 ] = colors[ 3 ];
|
||||
void RB_Color4bv(unsigned char *colors)
|
||||
{
|
||||
cntColor[0] = colors[0];
|
||||
cntColor[1] = colors[1];
|
||||
cntColor[2] = colors[2];
|
||||
cntColor[3] = colors[3];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -220,9 +233,10 @@ void RB_Color4bv( unsigned char *colors ) {
|
|||
RB_Texcoord2f
|
||||
===============
|
||||
*/
|
||||
void RB_Texcoord2f( float s, float t ) {
|
||||
cntSt[ 0 ] = s;
|
||||
cntSt[ 1 ] = t;
|
||||
void RB_Texcoord2f(float s, float t)
|
||||
{
|
||||
cntSt[0] = s;
|
||||
cntSt[1] = t;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -230,9 +244,10 @@ void RB_Texcoord2f( float s, float t ) {
|
|||
RB_Texcoord2fv
|
||||
===============
|
||||
*/
|
||||
void RB_Texcoord2fv( vec2_t st ) {
|
||||
cntSt[ 0 ] = st[ 0 ];
|
||||
cntSt[ 1 ] = st[ 1 ];
|
||||
void RB_Texcoord2fv(vec2_t st)
|
||||
{
|
||||
cntSt[0] = st[0];
|
||||
cntSt[1] = st[1];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -240,70 +255,69 @@ void RB_Texcoord2fv( vec2_t st ) {
|
|||
R_DrawDebugNumber
|
||||
===============
|
||||
*/
|
||||
void R_DrawDebugNumber( const vec3_t org, float number, float scale, float r, float g, float b, int precision ) {
|
||||
vec3_t up, right;
|
||||
vec3_t pos1, pos2;
|
||||
vec3_t start;
|
||||
str text;
|
||||
char format[20];
|
||||
int i;
|
||||
int j;
|
||||
int l;
|
||||
int num;
|
||||
|
||||
VectorCopy(tr.viewParms.ori.axis[2], up);
|
||||
VectorCopy(tr.viewParms.ori.axis[1], right);
|
||||
VectorNegate(right, right);
|
||||
void R_DrawDebugNumber(const vec3_t org, float number, float scale, float r, float g, float b, int precision)
|
||||
{
|
||||
vec3_t up, right;
|
||||
vec3_t pos1, pos2;
|
||||
vec3_t start;
|
||||
str text;
|
||||
char format[20];
|
||||
int i;
|
||||
int j;
|
||||
int l;
|
||||
int num;
|
||||
|
||||
VectorNormalize(up);
|
||||
VectorNormalize(right);
|
||||
VectorCopy(tr.viewParms.ori.axis[2], up);
|
||||
VectorCopy(tr.viewParms.ori.axis[1], right);
|
||||
VectorNegate(right, right);
|
||||
|
||||
VectorScale(up, scale, up);
|
||||
VectorScale(right, scale, right);
|
||||
VectorNormalize(up);
|
||||
VectorNormalize(right);
|
||||
|
||||
VectorScale(up, scale, up);
|
||||
VectorScale(right, scale, right);
|
||||
|
||||
if (precision > 0) {
|
||||
Com_sprintf(format, sizeof(format), "%%.%df", precision);
|
||||
Com_sprintf(format, sizeof(format), "%%.%df", precision);
|
||||
text = va(format, number);
|
||||
} else {
|
||||
text = va("%d", (int)number);
|
||||
}
|
||||
} else {
|
||||
text = va("%d", (int)number);
|
||||
}
|
||||
|
||||
// NOTE: this cast here is needed!
|
||||
// Otherwise the compiler will do very nasty implicit casting of negative
|
||||
// numbers to unsigned numbers, resulting in incorrect values.
|
||||
// -------------------v
|
||||
VectorMA(org, 5 - 5 * (int)text.length(), right, start);
|
||||
// NOTE: this cast here is needed!
|
||||
// Otherwise the compiler will do very nasty implicit casting of negative
|
||||
// numbers to unsigned numbers, resulting in incorrect values.
|
||||
// -------------------v
|
||||
VectorMA(org, 5 - 5 * (int)text.length(), right, start);
|
||||
|
||||
// Draw each character/digit of the text
|
||||
for (i = 0; i < text.length(); i++) {
|
||||
if (text[i] == '.') {
|
||||
num = 10;
|
||||
}
|
||||
else if (text[i] == '-') {
|
||||
num = 11;
|
||||
}
|
||||
else {
|
||||
num = text[i] - '0';
|
||||
}
|
||||
// Draw each character/digit of the text
|
||||
for (i = 0; i < text.length(); i++) {
|
||||
if (text[i] == '.') {
|
||||
num = 10;
|
||||
} else if (text[i] == '-') {
|
||||
num = 11;
|
||||
} else {
|
||||
num = text[i] - '0';
|
||||
}
|
||||
|
||||
// Get the first line index for the number to be drawn
|
||||
l = Numbers[num][0];
|
||||
// Get the first line index for the number to be drawn
|
||||
l = Numbers[num][0];
|
||||
|
||||
// Draw each line of the character/digit
|
||||
for (j = 0; j < 8 && l; ++j, l = Numbers[num][j]) {
|
||||
// Draw each line of the character/digit
|
||||
for (j = 0; j < 8 && l; ++j, l = Numbers[num][j]) {
|
||||
pos1[0] = start[0] + Lines[l][0] * right[0] + Lines[l][1] * up[0];
|
||||
pos1[1] = start[1] + Lines[l][0] * right[1] + Lines[l][1] * up[1];
|
||||
pos1[2] = start[2] + Lines[l][0] * right[2] + Lines[l][1] * up[2];
|
||||
|
||||
pos2[0] = start[0] + Lines[l][2] * right[0] + Lines[l][3] * up[0];
|
||||
pos2[1] = start[1] + Lines[l][2] * right[1] + Lines[l][3] * up[1];
|
||||
pos2[2] = start[2] + Lines[l][2] * right[2] + Lines[l][3] * up[2];
|
||||
pos2[0] = start[0] + Lines[l][2] * right[0] + Lines[l][3] * up[0];
|
||||
pos2[1] = start[1] + Lines[l][2] * right[1] + Lines[l][3] * up[1];
|
||||
pos2[2] = start[2] + Lines[l][2] * right[2] + Lines[l][3] * up[2];
|
||||
|
||||
R_DebugLine(pos1, pos2, r, g, b, 1.0);
|
||||
R_DebugLine(pos1, pos2, r, g, b, 1.0);
|
||||
}
|
||||
|
||||
VectorMA(start, 10.0, right, start);
|
||||
}
|
||||
VectorMA(start, 10.0, right, start);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -311,36 +325,38 @@ void R_DrawDebugNumber( const vec3_t org, float number, float scale, float r, fl
|
|||
R_DebugRotatedBBox
|
||||
===============
|
||||
*/
|
||||
void R_DebugRotatedBBox( const vec3_t org, const vec3_t ang, const vec3_t mins, const vec3_t maxs, float r, float g, float b, float alpha ) {
|
||||
int i;
|
||||
vec3_t tmp;
|
||||
vec3_t points[8];
|
||||
vec3_t axis[3];
|
||||
void R_DebugRotatedBBox(
|
||||
const vec3_t org, const vec3_t ang, const vec3_t mins, const vec3_t maxs, float r, float g, float b, float alpha
|
||||
)
|
||||
{
|
||||
int i;
|
||||
vec3_t tmp;
|
||||
vec3_t points[8];
|
||||
vec3_t axis[3];
|
||||
|
||||
AnglesToAxis(ang, axis);
|
||||
AnglesToAxis(ang, axis);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (i & 1) {
|
||||
tmp[0] = mins[0];
|
||||
} else {
|
||||
tmp[0] = maxs[0];
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (i & 1) {
|
||||
tmp[0] = mins[0];
|
||||
} else {
|
||||
tmp[0] = maxs[0];
|
||||
}
|
||||
|
||||
if (i & 2) {
|
||||
tmp[1] = mins[1];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tmp[1] = maxs[1];
|
||||
}
|
||||
|
||||
if (i & 4) {
|
||||
tmp[2] = mins[2];
|
||||
} else {
|
||||
tmp[2] = maxs[2];
|
||||
}
|
||||
if (i & 4) {
|
||||
tmp[2] = mins[2];
|
||||
} else {
|
||||
tmp[2] = maxs[2];
|
||||
}
|
||||
|
||||
points[i][0] = tmp[0] * axis[0][0];
|
||||
points[i][1] = tmp[0] * axis[0][1];
|
||||
points[i][0] = tmp[0] * axis[0][0];
|
||||
points[i][1] = tmp[0] * axis[0][1];
|
||||
points[i][2] = tmp[0] * axis[0][2];
|
||||
|
||||
points[i][0] += tmp[1] * axis[1][0];
|
||||
|
@ -351,10 +367,10 @@ void R_DebugRotatedBBox( const vec3_t org, const vec3_t ang, const vec3_t mins,
|
|||
points[i][1] += tmp[2] * axis[2][1];
|
||||
points[i][2] += tmp[2] * axis[2][2];
|
||||
|
||||
points[i][0] += org[0];
|
||||
points[i][1] += org[1];
|
||||
points[i][2] += org[2];
|
||||
}
|
||||
points[i][0] += org[0];
|
||||
points[i][1] += org[1];
|
||||
points[i][2] += org[2];
|
||||
}
|
||||
|
||||
R_DebugLine(points[0], points[1], r, g, b, alpha);
|
||||
R_DebugLine(points[1], points[3], r, g, b, alpha);
|
||||
|
@ -365,9 +381,9 @@ void R_DebugRotatedBBox( const vec3_t org, const vec3_t ang, const vec3_t mins,
|
|||
R_DebugLine(points[7], points[6], r, g, b, alpha);
|
||||
R_DebugLine(points[6], points[4], r, g, b, alpha);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
R_DebugLine(points[i], points[i + 4], r, g, b, alpha);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
R_DebugLine(points[i], points[i + 4], r, g, b, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -375,43 +391,9 @@ void R_DebugRotatedBBox( const vec3_t org, const vec3_t ang, const vec3_t mins,
|
|||
RE_GetShaderWidth
|
||||
===============
|
||||
*/
|
||||
int RE_GetShaderWidth( qhandle_t hShader ) {
|
||||
shader_t *shader;
|
||||
|
||||
if( hShader ) {
|
||||
shader = R_GetShaderByHandle( hShader );
|
||||
} else {
|
||||
shader = tr.defaultShader;
|
||||
}
|
||||
|
||||
return shader->unfoggedStages[ 0 ]->bundle[ 0 ].image[ 0 ]->uploadWidth;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
RE_GetShaderHeight
|
||||
===============
|
||||
*/
|
||||
int RE_GetShaderHeight( qhandle_t hShader ) {
|
||||
shader_t *shader;
|
||||
|
||||
if( hShader ) {
|
||||
shader = R_GetShaderByHandle( hShader );
|
||||
}
|
||||
else {
|
||||
shader = tr.defaultShader;
|
||||
}
|
||||
|
||||
return shader->unfoggedStages[ 0 ]->bundle[ 0 ].image[ 0 ]->uploadHeight;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
RE_GetShaderName
|
||||
===============
|
||||
*/
|
||||
const char* RE_GetShaderName(qhandle_t hShader) {
|
||||
shader_t* shader;
|
||||
int RE_GetShaderWidth(qhandle_t hShader)
|
||||
{
|
||||
shader_t *shader;
|
||||
|
||||
if (hShader) {
|
||||
shader = R_GetShaderByHandle(hShader);
|
||||
|
@ -419,7 +401,43 @@ const char* RE_GetShaderName(qhandle_t hShader) {
|
|||
shader = tr.defaultShader;
|
||||
}
|
||||
|
||||
return shader->name;
|
||||
return shader->unfoggedStages[0]->bundle[0].image[0]->uploadWidth;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
RE_GetShaderHeight
|
||||
===============
|
||||
*/
|
||||
int RE_GetShaderHeight(qhandle_t hShader)
|
||||
{
|
||||
shader_t *shader;
|
||||
|
||||
if (hShader) {
|
||||
shader = R_GetShaderByHandle(hShader);
|
||||
} else {
|
||||
shader = tr.defaultShader;
|
||||
}
|
||||
|
||||
return shader->unfoggedStages[0]->bundle[0].image[0]->uploadHeight;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
RE_GetShaderName
|
||||
===============
|
||||
*/
|
||||
const char *RE_GetShaderName(qhandle_t hShader)
|
||||
{
|
||||
shader_t *shader;
|
||||
|
||||
if (hShader) {
|
||||
shader = R_GetShaderByHandle(hShader);
|
||||
} else {
|
||||
shader = tr.defaultShader;
|
||||
}
|
||||
|
||||
return shader->name;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -427,14 +445,15 @@ const char* RE_GetShaderName(qhandle_t hShader) {
|
|||
RE_GetModelName
|
||||
===============
|
||||
*/
|
||||
const char* RE_GetModelName(qhandle_t hModel) {
|
||||
const char *RE_GetModelName(qhandle_t hModel)
|
||||
{
|
||||
model_t *model;
|
||||
|
||||
if (!hModel) {
|
||||
return "";
|
||||
}
|
||||
if (!hModel) {
|
||||
return "";
|
||||
}
|
||||
|
||||
model = R_GetModelByHandle(hModel);
|
||||
model = R_GetModelByHandle(hModel);
|
||||
|
||||
return model->name;
|
||||
return model->name;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue