35#define MARKER_SIZE 60.0
50void R_DrawFlatGeoscape (
const vec2_t nodePos,
const vec2_t nodeSize,
float p,
float cx,
float cy,
float iz,
const char* map,
bool overlayNation,
bool overlayXVI,
bool overlayRadar,
image_t*
r_dayandnightTexture,
image_t*
r_xviTexture,
image_t*
r_radarTexture)
53 float geoscape_texcoords[4 * 2];
54 short geoscape_verts[4 * 2];
57 const float nx = nodePos[0] *
viddef.rx;
58 const float ny = nodePos[1] *
viddef.ry;
59 const float nw = nodeSize[0] *
viddef.rx;
60 const float nh = nodeSize[1] *
viddef.ry;
68 glVertexPointer(2, GL_SHORT, 0, geoscape_verts);
69 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, geoscape_texcoords);
71 geoscape_texcoords[0] = cx - iz;
72 geoscape_texcoords[1] = cy - iz;
73 geoscape_texcoords[2] = cx + iz;
74 geoscape_texcoords[3] = cy - iz;
75 geoscape_texcoords[4] = cx + iz;
76 geoscape_texcoords[5] = cy + iz;
77 geoscape_texcoords[6] = cx - iz;
78 geoscape_texcoords[7] = cy + iz;
80 geoscape_verts[0] = nx;
81 geoscape_verts[1] = ny;
82 geoscape_verts[2] = nx + nw;
83 geoscape_verts[3] = ny;
84 geoscape_verts[4] = nx + nw;
85 geoscape_verts[5] = ny + nh;
86 geoscape_verts[6] = nx;
87 geoscape_verts[7] = ny + nh;
91 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
99 float geoscape_nighttexcoords[4 * 2];
105 geoscape_nighttexcoords[0] = geoscape_texcoords[0] + p;
106 geoscape_nighttexcoords[1] = geoscape_texcoords[1];
107 geoscape_nighttexcoords[2] = geoscape_texcoords[2] + p;
108 geoscape_nighttexcoords[3] = geoscape_texcoords[3];
109 geoscape_nighttexcoords[4] = geoscape_texcoords[4] + p;
110 geoscape_nighttexcoords[5] = geoscape_texcoords[5];
111 geoscape_nighttexcoords[6] = geoscape_texcoords[6] + p;
112 geoscape_nighttexcoords[7] = geoscape_texcoords[7];
114 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, geoscape_nighttexcoords);
119 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
124 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, geoscape_texcoords);
137 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
153 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
163 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
193 Com_Printf(
"Could not find model '%s'\n", model);
214 glTranslatef(screenPos[0]*
viddef.rx, screenPos[1]*
viddef.ry, 0);
218 glRotatef(-90.f + direction, 0, 0, 1);
240 const float nx = nodePos[0] *
viddef.rx;
241 const float ny = nodePos[1] *
viddef.ry;
242 const float nw = nodeSize[0] *
viddef.rx;
243 const float nh = nodeSize[1] *
viddef.ry;
247 const vec3_t earthPos = {nx + nw / 2.0f, ny + nh / 2.0f, 0.0f};
260 Com_Printf(
"Could not find model '%s'\n", model);
282 glTranslatef(earthPos[0], earthPos[1], 10.0f);
286 glRotatef(-rotate[1], 1, 0, 0);
287 glRotatef(rotate[2], 0, 1, 0);
288 glRotatef(rotate[0] - pos[0], 0, 0, 1);
289 glRotatef(90.0f - pos[1], 1, 0, 0);
290 glTranslatef(0, 0, earthRadius);
291 glRotatef(90.0f + direction, 0, 0, 1);
306#define SKYBOX_HALFSIZE 800.0f
347 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
348 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
349 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
350 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
351 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
352 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
379 VectorSet(angle, rotate[0] - timeOfDay *
todeg, rotate[1], rotate[2]);
380 glRotatef(angle[
YAW], 1, 0, 0);
381 glRotatef(angle[
ROLL], 0, 1, 0);
382 glRotatef(angle[
PITCH], 0, 0, 1);
391#ifdef GL_VERSION_ES_CM_1_0
392 for(
int ii = 0; ii < 6; ii++ )
393 glDrawArrays(GL_TRIANGLE_FAN, ii * 4, 4);
395 glDrawArrays(GL_QUADS, 0, 24);
419 Vector4Set(r, earthPos[0] + celestialDist * v2[1], earthPos[1] + celestialDist * v2[0], -celestialDist * v2[2], 0);
431 bool disableSolarRender,
float ambient,
bool overlayNation,
bool overlayXVI,
bool overlayRadar,
image_t*
r_xviTexture,
438 static const vec4_t diffuseLightColor = { 1.75f, 1.75f, 1.75f, 1.0f };
439 static const vec4_t specularLightColor = { 2.0f, 1.9f, 1.7f, 1.0f };
440 static const vec4_t darknessLightColor = { 0.0f, 0.0f, 0.0f, 1.0f };
441 static const vec4_t brightDiffuseLightColor = { 5.0f, 5.0f, 5.0f, 1.0f };
442 const vec4_t ambientLightColor = { ambient + 0.2f, ambient + 0.2f, ambient + 0.2f, ambient + 0.2f };
452 static const float moonSize = 0.025f;
459 const float nx = pos[0] *
viddef.rx;
460 const float ny = pos[1] *
viddef.ry;
466 const vec3_t earthPos = { nx + nw / 2.0f, ny + nh / 2.0f, 0.0f };
474 const float seasonProgress = season - (float) currSeason;
479 const float sqrta = sqrt(0.5f * (1 - a * a));
487 glMatrixMode(GL_TEXTURE);
489 glMatrixMode(GL_MODELVIEW);
490 glDisable(GL_LIGHTING);
499 Vector4Set(sunPos, cos(p) * sqrta, -sin(p) * sqrta, a, 0);
500 Vector4Set(antiSunPos, -cos(p) * sqrta, sin(p) * sqrta, -a, 0);
508 const int sunx = earthPos[0] +
viddef.rx * (-128.0f + celestialDist * (sunLoc[0] - earthPos[0]));
509 const int suny = earthPos[1] +
viddef.ry * (-128.0f + celestialDist * (sunLoc[1] - earthPos[1]));
520 VectorSet(moonLoc, cos(
m) * sqrta, -sin(
m) * sqrta, a);
551 glLightfv(GL_LIGHT1, GL_AMBIENT, darknessLightColor);
552 glLightfv(GL_LIGHT1, GL_DIFFUSE, brightDiffuseLightColor);
553 glLightfv(GL_LIGHT1, GL_SPECULAR, darknessLightColor);
562 glMatrixMode(GL_TEXTURE);
564 glScalef(2.0f, 1.0f, 1.0f);
565 glMatrixMode(GL_MODELVIEW);
568 glEnable(GL_LIGHTING);
570 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLightColor);
571 glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLightColor);
572 glLightfv(GL_LIGHT0, GL_SPECULAR, specularLightColor);
579 glEnable(GL_DEPTH_TEST);
585 glBlendFunc(GL_ONE, GL_ZERO);
590 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
595 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
601 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
603 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_ALPHA);
605 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
606 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
608 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
610 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
617 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
635 const float earthSizeX = fullscale * 20500.0f *
viddef.rx;
636 const float earthSizeY = fullscale * 20500.0f *
viddef.ry;
637 glMatrixMode(GL_TEXTURE);
640 glDisable(GL_LIGHTING);
642 R_DrawTexture(halo->
texnum, earthPos[0] - earthSizeX * 0.5f, earthPos[1] - earthSizeY * 0.5f, earthSizeX, earthSizeY);
643 glEnable(GL_LIGHTING);
645 glMatrixMode(GL_MODELVIEW);
650 glDisable(GL_DEPTH_TEST);
660 if (renderNationGlow) {
667 glDisable(GL_LIGHTING);
669 glEnable(GL_LIGHTING);
693 glDisable(GL_LIGHTING);
696 glMatrixMode(GL_TEXTURE);
698 glMatrixMode(GL_MODELVIEW);
707 const vec2_t texcoord[] = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } };
710 glVertexPointer(2, GL_FLOAT, 0, verts);
711 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, texcoord);
713 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
742 for (
int i = 0;
i < levels;
i++) {
743 const int l = levels -
i - 1;
765 bool renderBufferState;
772 glMatrixMode(GL_MODELVIEW);
775 glMatrixMode(GL_TEXTURE);
778 glMatrixMode(GL_PROJECTION);
781#ifndef GL_VERSION_ES_CM_1_0
782 glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT);
786 glDisable(GL_LIGHTING);
787 glDisable(GL_DEPTH_TEST);
792 qglGenerateMipmapEXT(GL_TEXTURE_2D);
799 qglGenerateMipmapEXT(GL_TEXTURE_2D);
837#ifndef GL_VERSION_ES_CM_1_0
840 glMatrixMode(GL_PROJECTION);
842 glMatrixMode(GL_TEXTURE);
844 glMatrixMode(GL_MODELVIEW);
DateTime class definition.
static const short SEASONS_PER_YEAR
static const int SECONDS_PER_DAY
static const int DAYS_PER_YEAR
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
Rotate a point around a given vector.
void R_DrawTexture(int texnum, int x, int y, int w, int h)
Bind and draw a texture.
void R_UseFramebuffer(const r_framebuffer_t *buf)
bind specified framebuffer object so we render to it
bool R_EnableRenderbuffer(bool enable)
Enable the render to the framebuffer.
void R_UseViewport(const r_framebuffer_t *buf)
Set the viewport to the dimensions of the given framebuffer.
void R_DrawBuffers(unsigned int drawBufferNum)
Activate draw buffer(s).
void R_ResolveMSAA(const r_framebuffer_t *buf)
Forces multisample antialiasing resolve on given framebuffer, if needed.
bool R_RenderbufferEnabled(void)
static void R_DrawQuad(void)
Draw the current texture on a quad the size of the renderbuffer.
void R_DrawFlatGeoscape(const vec2_t nodePos, const vec2_t nodeSize, float p, float cx, float cy, float iz, const char *map, bool overlayNation, bool overlayXVI, bool overlayRadar, image_t *r_dayandnightTexture, image_t *r_xviTexture, image_t *r_radarTexture)
Draw the day and night images of a flat geoscape multitexture feature is used to blend the images.
void R_Draw3DMapMarkers(const vec2_t nodePos, const vec2_t nodeSize, const vec3_t rotate, const vec2_t pos, float direction, float earthRadius, const char *model, int skin)
Draw 3D Marker on the 3D geoscape.
static void R_RotateCelestialBody(const vec4_t v, vec4_t r, const vec3_t rotate, const vec3_t earthPos, const float celestialDist)
rotate a planet (sun or moon) with respect to the earth
void R_Draw2DMapMarkers(const vec2_t screenPos, float direction, const char *model, int skin)
Draw 3D Marker on the 2D geoscape.
void R_DrawBloom(void)
handle post-processing bloom
void R_Draw3DGlobe(const vec2_t pos, const vec2_t size, int day, int second, const vec3_t rotate, float zoom, const char *map, bool disableSolarRender, float ambient, bool overlayNation, bool overlayXVI, bool overlayRadar, image_t *r_xviTexture, image_t *r_radarTexture, bool renderNationGlow)
responsible for drawing the 3d globe on geoscape param[in] rotate the rotate angle of the globe param...
static void R_BlurStack(int levels, r_framebuffer_t **sources, r_framebuffer_t **dests)
blur from the source image pyramid into the dest image pyramid
static void R_DrawStarfield(int texnum, const vec3_t pos, const vec3_t rotate, float timeOfDay)
Bind and draw starfield.
#define SKYBOX_HALFSIZE
Half size of Skybox.
static const float starFieldVerts[]
static void R_Blur(r_framebuffer_t *source, r_framebuffer_t *dest, int tex, int dir)
does 1D filter convolution to blur a framebuffer texture. dir=0 for horizontal, dir=1 for vertical
static const float starFieldTexCoords[]
#define STANDARD_3D_ZOOM
Typical zoom to use on the 3D geoscape to use same zoom values for both 2D and 3D geoscape.
QGL_EXTERN GLuint GLchar ** sources
QGL_EXTERN GLenum GLuint * dest
QGL_EXTERN int GLboolean GLfloat * v
void R_FreeImage(image_t *image)
Free the image and its assigned maps (roughness, normal, specular, glow - if there are any).
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
local graphics definitions
void R_DrawModelDirect(modelInfo_t *mi, modelInfo_t *pmi, const char *tagname)
Draws a model in 2d mode (for rendering model data from the ui).
void R_ModelAutoScale(const vec2_t boxSize, modelInfo_t *mi, vec3_t scale, vec3_t center)
Compute scale and center for a model info data structure.
model_t * R_FindModel(const char *name)
Tries to load a model.
void R_UseProgram(r_program_t *prog)
sphere_t r_globeEarthAtmosphere
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.
Functions to generate and render spheres.
void R_EnableTexture(gltexunit_t *texunit, bool enable)
void R_BindDefaultArray(GLenum target)
Binds the appropriate shared vertex array to the specified target.
void R_EnableBlur(r_program_t *program, bool enable, r_framebuffer_t *source, r_framebuffer_t *dest, int dir)
bool R_SelectTexture(gltexunit_t *texunit)
Returns false if the texunit is not supported.
void R_BindLightmapTexture(GLuint texnum)
void R_BindTextureForTexUnit(GLuint texnum, gltexunit_t *texunit)
void R_BindArray(GLenum target, GLenum type, const void *array)
#define DOWNSAMPLE_PASSES
#define SKYBOX_DEPTH
Center position of skybox along z-axis. This is used to make sure we see only the inside of Skybox.
#define R_BindTexture(tn)
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
static const vec3_t scale
image_t * r_dayandnightTexture
#define Vector2FromInt(x, y)
#define Vector4Set(v, r, g, b, a)
#define VectorCopy(src, dest)
#define VectorSet(v, x, y, z)