37 static inline float rhoSpiral (
const int index,
const float deltaRho,
const float thetaAngle)
39 const float rhoAngle = (index == 0) ? 0.0
f : (
float) ((index - 1) * deltaRho + thetaAngle * deltaRho / (2.0
f *
M_PI));
40 return rhoAngle > M_PI ? M_PI : rhoAngle;
53 const float drho =
M_PI / tris;
56 const float dtheta = 2.0f *
M_PI / tris;
68 for (
int i = 0;
i <= tris;
i++) {
70 for (
int j = 0; j <= tris ; j++) {
71 const float theta = j * dtheta;
72 const float stheta = (float) (-sin(theta));
73 const float ctheta = (float) (cos(theta));
77 const float rhodrho =
rhoSpiral(
i + 1, drho, theta);
78 const float srho = (float) (sin(rho));
79 const float crho = (float) (cos(rho));
80 const float srhodrho = (float) (sin(rhodrho));
81 const float crhodrho = (float) (cos(rhodrho));
83 const float st = 1 - rho /
M_PI;
84 const float stdt = 1 - rhodrho /
M_PI;
86 const float s = theta / (4.0f *
M_PI);
92 stheta * srhodrho * radius,
93 ctheta * srhodrho * radius,
102 stheta * srho * radius,
103 ctheta * srho * radius,
109 sphere->
num_tris = (tris + 1) * (tris + 2) * 2;
121 r_sphereDetails =
Cvar_Get(
"r_sphereDetails",
"1.0",
CVAR_ARCHIVE,
"Factor to increase or decrease the sphere tris");
122 if (r_sphereDetails->
integer <= 0)
134 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, texCoordBuffer);
135 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
142 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
147 glEnable(GL_CULL_FACE);
148 glEnable(GL_NORMALIZE);
150 glDrawArrays(GL_TRIANGLE_STRIP, 0, sphere->
num_tris);
154 glDisable(GL_NORMALIZE);
155 glDisable(GL_CULL_FACE);
188 glEnableClientState(GL_NORMAL_ARRAY);
192 glDisableClientState(GL_NORMAL_ARRAY);
252 glMatrixMode(GL_MODELVIEW);
253 glTranslatef(pos[0], pos[1], pos[2]);
260 glRotatef(rotate[
YAW], 1, 0, 0);
261 glRotatef(rotate[
ROLL], 0, 1, 0);
262 glRotatef(rotate[
PITCH], 0, 0, 1);
265 glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
#define Vector4NotEmpty(a)
void R_EnableTexture(gltexunit_t *texunit, bool enable)
#define VectorSet(v, x, y, z)
static void R_SphereActivateTextureUnit(gltexunit_t *texunit, void *texCoordBuffer)
static const vec3_t scale
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
void R_BindLightmapTexture(GLuint texnum)
static void R_SphereShadeGLSL(const sphere_t *sphere)
render sphere using GLSL (bump mapping, specularity, and season-blending)
static cvar_t * r_sphereDetails
memPool_t * vid_genericPool
local graphics definitions
static bool R_SphereCheckGLSL(const sphere_t *sphere)
vec_t VectorNormalize2(const vec3_t v, vec3_t out)
Calculated the normal vector for a given vec3_t.
void R_SphereInit(void)
Creates the spheres we need for rendering the 3d globe.
static float rhoSpiral(const int index, const float deltaRho, const float thetaAngle)
sphere_t r_globeEarthAtmosphere
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
#define Vector2Set(v, x, y)
texunits maintain multitexture state
void R_BindDefaultArray(GLenum target)
Binds the appropriate shared vertex array to the specified target.
#define VectorNotEmpty(a)
#define Mem_PoolAllocTypeN(type, n, pool)
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.
void R_SphereGenerate(sphere_t *sphere, const int tris, const float radius)
Initialize the globe chain arrays.
static void R_SphereDeactivateTextureUnit(gltexunit_t *texunit)
bool R_EnableLighting(r_program_t *program, bool enable)
Enables hardware-accelerated lighting with the specified program. This should be called after any tex...
image_t * overlayAlphaMask
Functions to generate and render spheres.
static void R_SphereRenderTris(const sphere_t *sphere)
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
void R_ProgramParameter1f(const char *name, GLfloat value)
static void R_SphereShade(const sphere_t *sphere)
render sphere using standard OpenGL lighting
void R_BindTextureForTexUnit(GLuint texnum, gltexunit_t *texunit)
#define R_BindTexture(tn)
r_program_t * glslProgram
bool R_SelectTexture(gltexunit_t *texunit)
Returns false if the texunit is not supported.
void R_BindArray(GLenum target, GLenum type, const void *array)