33 #define MARKER_SIZE 60.0
48 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)
51 float geoscape_texcoords[4 * 2];
52 short geoscape_verts[4 * 2];
55 const float nx = nodePos[0] *
viddef.
rx;
56 const float ny = nodePos[1] *
viddef.
ry;
57 const float nw = nodeSize[0] *
viddef.
rx;
58 const float nh = nodeSize[1] *
viddef.
ry;
66 glVertexPointer(2, GL_SHORT, 0, geoscape_verts);
67 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, geoscape_texcoords);
69 geoscape_texcoords[0] = cx - iz;
70 geoscape_texcoords[1] = cy - iz;
71 geoscape_texcoords[2] = cx + iz;
72 geoscape_texcoords[3] = cy - iz;
73 geoscape_texcoords[4] = cx + iz;
74 geoscape_texcoords[5] = cy + iz;
75 geoscape_texcoords[6] = cx - iz;
76 geoscape_texcoords[7] = cy + iz;
78 geoscape_verts[0] = nx;
79 geoscape_verts[1] = ny;
80 geoscape_verts[2] = nx + nw;
81 geoscape_verts[3] = ny;
82 geoscape_verts[4] = nx + nw;
83 geoscape_verts[5] = ny + nh;
84 geoscape_verts[6] = nx;
85 geoscape_verts[7] = ny + nh;
89 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
97 float geoscape_nighttexcoords[4 * 2];
103 geoscape_nighttexcoords[0] = geoscape_texcoords[0] + p;
104 geoscape_nighttexcoords[1] = geoscape_texcoords[1];
105 geoscape_nighttexcoords[2] = geoscape_texcoords[2] + p;
106 geoscape_nighttexcoords[3] = geoscape_texcoords[3];
107 geoscape_nighttexcoords[4] = geoscape_texcoords[4] + p;
108 geoscape_nighttexcoords[5] = geoscape_texcoords[5];
109 geoscape_nighttexcoords[6] = geoscape_texcoords[6] + p;
110 geoscape_nighttexcoords[7] = geoscape_texcoords[7];
112 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, geoscape_nighttexcoords);
117 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
122 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, geoscape_texcoords);
135 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
151 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
161 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
191 Com_Printf(
"Could not find model '%s'\n", model);
216 glRotatef(-90.
f + direction, 0, 0, 1);
238 const float nx = nodePos[0] *
viddef.
rx;
239 const float ny = nodePos[1] *
viddef.
ry;
240 const float nw = nodeSize[0] *
viddef.
rx;
241 const float nh = nodeSize[1] *
viddef.
ry;
245 const vec3_t earthPos = {nx + nw / 2.0f, ny + nh / 2.0f, 0.0f};
258 Com_Printf(
"Could not find model '%s'\n", model);
280 glTranslatef(earthPos[0], earthPos[1], 10.0
f);
284 glRotatef(-rotate[1], 1, 0, 0);
285 glRotatef(rotate[2], 0, 1, 0);
286 glRotatef(rotate[0] - pos[0], 0, 0, 1);
287 glRotatef(90.0
f - pos[1], 1, 0, 0);
288 glTranslatef(0, 0, earthRadius);
289 glRotatef(90.0
f + direction, 0, 0, 1);
304 #define SKYBOX_HALFSIZE 800.0f
345 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
346 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
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,
377 VectorSet(angle, rotate[0] - timeOfDay *
todeg, rotate[1], rotate[2]);
378 glRotatef(angle[
YAW], 1, 0, 0);
379 glRotatef(angle[
ROLL], 0, 1, 0);
380 glRotatef(angle[
PITCH], 0, 0, 1);
389 #ifdef GL_VERSION_ES_CM_1_0
390 for(
int ii = 0; ii < 6; ii++ )
391 glDrawArrays(GL_TRIANGLE_FAN, ii * 4, 4);
393 glDrawArrays(GL_QUADS, 0, 24);
417 Vector4Set(r, earthPos[0] + celestialDist * v2[1], earthPos[1] + celestialDist * v2[0], -celestialDist * v2[2], 0);
429 bool disableSolarRender,
float ambient,
bool overlayNation,
bool overlayXVI,
bool overlayRadar,
image_t*
r_xviTexture,
436 static const vec4_t diffuseLightColor = { 1.75f, 1.75f, 1.75f, 1.0f };
437 static const vec4_t specularLightColor = { 2.0f, 1.9f, 1.7f, 1.0f };
438 static const vec4_t darknessLightColor = { 0.0f, 0.0f, 0.0f, 1.0f };
439 static const vec4_t brightDiffuseLightColor = { 5.0f, 5.0f, 5.0f, 1.0f };
440 const vec4_t ambientLightColor = { ambient + 0.2f, ambient + 0.2f, ambient + 0.2f, ambient + 0.2f };
450 static const float moonSize = 0.025f;
457 const float nx = pos[0] *
viddef.
rx;
458 const float ny = pos[1] *
viddef.
ry;
459 const float nw = size[0] *
viddef.
rx;
460 const float nh = size[1] *
viddef.
ry;
464 const vec3_t earthPos = { nx + nw / 2.0f, ny + nh / 2.0f, 0.0f };
472 const float seasonProgress = season - (float) currSeason;
477 const float sqrta = sqrt(0.5
f * (1 - a * a));
482 const float m = p + (((double)((10 * day % 249) / 10.0f) + ((
double)second / (double)
SECONDS_PER_DAY)) / 24.9
f) * (2.0f *
M_PI);
485 glMatrixMode(GL_TEXTURE);
487 glMatrixMode(GL_MODELVIEW);
488 glDisable(GL_LIGHTING);
497 Vector4Set(sunPos, cos(p) * sqrta, -sin(p) * sqrta, a, 0);
498 Vector4Set(antiSunPos, -cos(p) * sqrta, sin(p) * sqrta, -a, 0);
506 const int sunx = earthPos[0] +
viddef.
rx * (-128.0f + celestialDist * (sunLoc[0] - earthPos[0]));
507 const int suny = earthPos[1] +
viddef.
ry * (-128.0f + celestialDist * (sunLoc[1] - earthPos[1]));
518 VectorSet(moonLoc, cos(m) * sqrta, -sin(m) * sqrta, a);
549 glLightfv(GL_LIGHT1, GL_AMBIENT, darknessLightColor);
550 glLightfv(GL_LIGHT1, GL_DIFFUSE, brightDiffuseLightColor);
551 glLightfv(GL_LIGHT1, GL_SPECULAR, darknessLightColor);
560 glMatrixMode(GL_TEXTURE);
562 glScalef(2.0
f, 1.0
f, 1.0
f);
563 glMatrixMode(GL_MODELVIEW);
566 glEnable(GL_LIGHTING);
568 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLightColor);
569 glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLightColor);
570 glLightfv(GL_LIGHT0, GL_SPECULAR, specularLightColor);
577 glEnable(GL_DEPTH_TEST);
583 glBlendFunc(GL_ONE, GL_ZERO);
588 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
593 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
599 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
601 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_ALPHA);
603 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
604 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
606 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
608 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
615 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
633 const float earthSizeX = fullscale * 20500.0f *
viddef.
rx;
634 const float earthSizeY = fullscale * 20500.0f *
viddef.
ry;
635 glMatrixMode(GL_TEXTURE);
638 glDisable(GL_LIGHTING);
640 R_DrawTexture(halo->
texnum, earthPos[0] - earthSizeX * 0.5f, earthPos[1] - earthSizeY * 0.5f, earthSizeX, earthSizeY);
641 glEnable(GL_LIGHTING);
643 glMatrixMode(GL_MODELVIEW);
648 glDisable(GL_DEPTH_TEST);
658 if (renderNationGlow) {
665 glDisable(GL_LIGHTING);
667 glEnable(GL_LIGHTING);
691 glDisable(GL_LIGHTING);
694 glMatrixMode(GL_TEXTURE);
696 glMatrixMode(GL_MODELVIEW);
705 const vec2_t texcoord[] = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } };
708 glVertexPointer(2, GL_FLOAT, 0, verts);
709 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, texcoord);
711 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
740 for (
int i = 0;
i < levels;
i++) {
741 const int l = levels -
i - 1;
752 R_Blur(dests[l], sources[l], 0, 1);
753 R_Blur(sources[l], dests[l], 0, 0);
763 bool renderBufferState;
770 glMatrixMode(GL_MODELVIEW);
773 glMatrixMode(GL_TEXTURE);
776 glMatrixMode(GL_PROJECTION);
779 #ifndef GL_VERSION_ES_CM_1_0
780 glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT);
784 glDisable(GL_LIGHTING);
785 glDisable(GL_DEPTH_TEST);
790 qglGenerateMipmapEXT(GL_TEXTURE_2D);
797 qglGenerateMipmapEXT(GL_TEXTURE_2D);
835 #ifndef GL_VERSION_ES_CM_1_0
838 glMatrixMode(GL_PROJECTION);
840 glMatrixMode(GL_TEXTURE);
842 glMatrixMode(GL_MODELVIEW);
bool R_EnableRenderbuffer(bool enable)
Enable the render to the framebuffer.
void R_UseProgram(r_program_t *prog)
#define VectorCopy(src, dest)
void R_UseFramebuffer(const r_framebuffer_t *buf)
bind specified framebuffer object so we render to it
void R_EnableTexture(gltexunit_t *texunit, bool enable)
#define VectorSet(v, x, y, z)
r_framebuffer_t * buffers2[DOWNSAMPLE_PASSES]
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...
QGL_EXTERN GLuint GLchar ** sources
static const vec3_t scale
r_program_t * atmosphere_program
void R_BindLightmapTexture(GLuint texnum)
static const float starFieldVerts[]
r_program_t * combine2_program
local graphics definitions
static void R_DrawQuad(void)
Draw the current texture on a quad the size of the renderbuffer.
static void R_DrawStarfield(int texnum, const vec3_t pos, const vec3_t rotate, float timeOfDay)
Bind and draw starfield.
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
Rotate a point around a given vector.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void Com_Printf(const char *const fmt,...)
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 Com_Error(int code, const char *fmt,...)
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
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.
void R_Draw2DMapMarkers(const vec2_t screenPos, float direction, const char *model, int skin)
Draw 3D Marker on the 2D geoscape.
bool R_RenderbufferEnabled(void)
sphere_t r_globeEarthAtmosphere
void R_DrawTexture(int texnum, int x, int y, int w, int h)
Bind and draw a texture.
#define STANDARD_3D_ZOOM
Typical zoom to use on the 3D geoscape to use same zoom values for both 2D and 3D geoscape...
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 ...
#define DOWNSAMPLE_PASSES
#define Vector4Set(v, r, g, b, a)
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
#define SKYBOX_HALFSIZE
Half size of Skybox.
r_program_t * geoscape_program
void R_BindDefaultArray(GLenum target)
Binds the appropriate shared vertex array to the specified target.
model_t * R_FindModel(const char *name)
Tries to load a model.
QGL_EXTERN GLenum GLuint * dest
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.
void R_DrawBuffers(unsigned int drawBufferNum)
Activate draw buffer(s)
#define Vector2FromInt(x, y)
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.
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
r_framebuffer_t * buffers0[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...
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...
image_t * r_dayandnightTexture
void R_EnableBlur(r_program_t *program, bool enable, r_framebuffer_t *source, r_framebuffer_t *dest, int dir)
void R_FreeImage(image_t *image)
Free the image and its assigned maps (roughness, normal, specular, glow - if there are any) ...
static const float starFieldTexCoords[]
void R_DrawBloom(void)
handle post-processing bloom
r_framebuffer_t * buffers1[DOWNSAMPLE_PASSES]
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...
r_program_t * convolve_program
void R_ResolveMSAA(const r_framebuffer_t *buf)
Forces multisample antialiasing resolve on given framebuffer, if needed.
image_t * overlayAlphaMask
Functions to generate and render spheres.
void R_UseViewport(const r_framebuffer_t *buf)
Set the viewport to the dimensions of the given framebuffer.
QGL_EXTERN int GLboolean GLfloat * v
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)