UFO: Alien Invasion
Loading...
Searching...
No Matches
r_sphere.cpp File Reference

Functions to generate and render spheres. More...

#include "r_local.h"
#include "r_sphere.h"
#include "r_error.h"
#include "r_geoscape.h"
Include dependency graph for r_sphere.cpp:

Go to the source code of this file.

Functions

static float rhoSpiral (const int index, const float deltaRho, const float thetaAngle)
void R_SphereGenerate (sphere_t *sphere, const int tris, const float radius)
 Initialize the globe chain arrays.
void R_SphereInit (void)
 Creates the spheres we need for rendering the 3d globe.
static void R_SphereActivateTextureUnit (gltexunit_t *texunit, void *texCoordBuffer)
static void R_SphereDeactivateTextureUnit (gltexunit_t *texunit)
static void R_SphereRenderTris (const sphere_t *sphere)
static bool R_SphereCheckGLSL (const sphere_t *sphere)
static void R_SphereShade (const sphere_t *sphere)
 render sphere using standard OpenGL lighting
static void R_SphereShadeGLSL (const sphere_t *sphere)
 render sphere using GLSL (bump mapping, specularity, and season-blending)
void R_SphereRender (const sphere_t *sphere, const vec3_t pos, const vec3_t rotate, const float scale, const vec4_t lightPos)
 Draw the sphere.

Variables

static cvar_tr_sphereDetails
sphere_t r_globeEarth
sphere_t r_globeMoon
sphere_t r_globeEarthAtmosphere

Detailed Description

Functions to generate and render spheres.

Definition in file r_sphere.cpp.

Function Documentation

◆ R_SphereActivateTextureUnit()

void R_SphereActivateTextureUnit ( gltexunit_t * texunit,
void * texCoordBuffer )
inlinestatic

Definition at line 131 of file r_sphere.cpp.

References R_BindArray(), and R_SelectTexture().

Referenced by R_SphereShadeGLSL().

◆ R_SphereCheckGLSL()

bool R_SphereCheckGLSL ( const sphere_t * sphere)
inlinestatic
Parameters
sphereThe sphere to check
Returns
true if all needed data is loaded to use the geoscape glsl shaders, false otherwise

Definition at line 162 of file r_sphere.cpp.

References sphere_t::glslProgram, and r_programs.

Referenced by R_SphereRender().

◆ R_SphereDeactivateTextureUnit()

void R_SphereDeactivateTextureUnit ( gltexunit_t * texunit)
inlinestatic

Definition at line 138 of file r_sphere.cpp.

References R_BindDefaultArray(), and R_SelectTexture().

Referenced by R_SphereShadeGLSL().

◆ R_SphereGenerate()

void R_SphereGenerate ( sphere_t * sphere,
const int tris,
const float radius )

Initialize the globe chain arrays.

Parameters
[out]sphereThe sphere you want to create
[in]trisThe amount of tris the globe should have - the higher the number the higher the details. tris*tris triangles are obtained.
[in]radiusThe radius of the sphere
See also
R_Draw3DGlobe

< angle from the pole (z-axis)

< angle around the equator, from y-axis

Definition at line 51 of file r_sphere.cpp.

References sphere_t::glslProgram, i, M_PI, Mem_PoolAllocTypeN, sphere_t::normals, sphere_t::num_tris, rhoSpiral(), sphere_t::texes, Vector2Set, VectorNormalize2(), VectorSet, sphere_t::verts, and vid_genericPool.

Referenced by R_SphereInit().

◆ R_SphereInit()

void R_SphereInit ( void )

Creates the spheres we need for rendering the 3d globe.

Note
The moon sphere has less detail because it's smaller in the scene
The sizes are arbitrary, becasue we use orthographic projection. The real sizes are: lunarRadius = 0.273 * earthRadius, solarRadius = 110.0 * earthRadius
See also
R_Init

Definition at line 119 of file r_sphere.cpp.

References CVAR_ARCHIVE, Cvar_Get(), Cvar_SetValue(), EARTH_RADIUS, MOON_RADIUS, r_globeEarth, r_globeEarthAtmosphere, r_globeMoon, r_sphereDetails, and R_SphereGenerate().

Referenced by R_Init().

◆ R_SphereRender()

void R_SphereRender ( const sphere_t * sphere,
const vec3_t pos,
const vec3_t rotate,
const float scale,
const vec4_t lightPos )

Draw the sphere.

Parameters
[in]sphereThe sphere that should be rendered
[in]posThe position (translation) of the matrix
[in]rotateThe rotation of the matrix
[in]scaleThe scale of the matrix
[in]lightPosSet this to nullptr if you don't want to change the light position

Definition at line 247 of file r_sphere.cpp.

References sphere_t::num_tris, sphere_t::overlay, PITCH, R_BindDefaultArray(), R_CheckError, R_SphereCheckGLSL(), R_SphereShade(), R_SphereShadeGLSL(), refdef, ROLL, scale, VectorNotEmpty, viddef, and YAW.

Referenced by R_Draw3DGlobe().

◆ R_SphereRenderTris()

void R_SphereRenderTris ( const sphere_t * sphere)
static

Definition at line 145 of file r_sphere.cpp.

References sphere_t::num_tris, and refdef.

Referenced by R_SphereShade(), and R_SphereShadeGLSL().

◆ R_SphereShade()

◆ R_SphereShadeGLSL()

◆ rhoSpiral()

float rhoSpiral ( const int index,
const float deltaRho,
const float thetaAngle )
inlinestatic

Definition at line 37 of file r_sphere.cpp.

References index, and M_PI.

Referenced by R_SphereGenerate().

Variable Documentation

◆ r_globeEarth

sphere_t r_globeEarth

Definition at line 33 of file r_sphere.cpp.

Referenced by R_Draw3DGlobe(), and R_SphereInit().

◆ r_globeEarthAtmosphere

sphere_t r_globeEarthAtmosphere

Definition at line 35 of file r_sphere.cpp.

Referenced by R_Draw3DGlobe(), and R_SphereInit().

◆ r_globeMoon

sphere_t r_globeMoon

Definition at line 34 of file r_sphere.cpp.

Referenced by R_Draw3DGlobe(), and R_SphereInit().

◆ r_sphereDetails

cvar_t* r_sphereDetails
static

Definition at line 31 of file r_sphere.cpp.

Referenced by R_SphereInit().