2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
23 #include "Audio/openal_wrapper.hpp"
24 #include "Level/Awards.hpp"
25 #include "Level/Dialog.hpp"
26 #include "Level/Hotspot.hpp"
27 #include "Menu/Menu.hpp"
28 #include "Tutorial.hpp"
29 #include "Utils/Input.hpp"
32 extern int environment;
33 extern float texscale;
35 extern Terrain terrain;
36 extern float multiplier;
37 extern float viewdistance;
38 extern float fadestart;
39 extern float screenwidth, screenheight;
40 extern int kTextureSize;
41 extern FRUSTUM frustum;
44 extern float usermousesensitivity;
45 extern float camerashake;
47 extern float slomodelay;
48 extern bool ismotionblur;
50 extern float blackout;
51 extern bool damageeffects;
53 extern bool texttoggle;
54 extern float blurness;
55 extern float targetblurness;
56 extern float playerdist;
57 extern bool cellophane;
59 extern float flashamount, flashr, flashg, flashb;
60 extern int flashdelay;
62 extern float motionbluramount;
64 extern bool alwaysblur;
65 extern bool velocityblur;
68 extern int bloodtoggle;
69 extern int difficulty;
70 extern bool decalstoggle;
71 extern float texdetail;
72 extern bool musictoggle;
73 extern float smoketex;
74 extern bool againbonus;
75 extern float damagedealt;
76 extern bool invertmouse;
79 extern bool winfreeze;
81 extern bool gamestart;
83 extern bool gamestarted;
85 extern bool showdamagebar;
88 int numboundaries = 0;
102 void Game::flash(float amount, int delay) // shouldn't be that way, these should be attributes and Person class should not change rendering.
107 flashamount = amount;
113 /*********************> DrawGLScene() <*****/
114 int Game::DrawGLScene(StereoSide side)
116 static float texcoordwidth, texcoordheight;
117 static float texviewwidth, texviewheight;
118 static XYZ checkpoint;
119 static float tempmult;
122 static int drawmode = 0;
124 if (stereomode == stereoAnaglyph) {
127 glColorMask(0.0, 1.0, 1.0, 1.0);
130 glColorMask(1.0, 0.0, 0.0, 1.0);
136 glColorMask(1.0, 1.0, 1.0, 1.0);
138 if (stereomode == stereoHorizontalInterlaced ||
139 stereomode == stereoVerticalInterlaced) {
140 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
144 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
145 tempmult = multiplier;
151 numboundaries = mapradius * 2;
152 if (numboundaries > 360) {
155 for (int i = 0; i < numboundaries; i++) {
158 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
167 int olddrawmode = drawmode;
168 if (ismotionblur && !loading) {
169 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
170 drawmode = motionblurmode;
171 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
174 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
175 drawmode = doublevisionmode;
180 if (slomo && !loading) {
182 drawmode = motionblurmode;
184 motionbluramount = .2;
185 slomodelay -= multiplier;
186 if (slomodelay < 0) {
192 if ((!changed && !slomo) || loading) {
193 drawmode = normalmode;
194 if (ismotionblur && (/*fps>100||*/ alwaysblur)) {
195 if (olddrawmode != realmotionblurmode) {
200 drawmode = realmotionblurmode;
201 } else if (olddrawmode == realmotionblurmode) {
208 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
209 drawmode = normalmode;
211 if ((freeze || winfreeze) && ismotionblur && !mainmenu) {
212 drawmode = radialzoommode;
215 if (winfreeze || mainmenu) {
216 drawmode = normalmode;
219 if (drawtoggle != 2) {
220 drawtoggle = 1 - drawtoggle;
223 if (!texcoordwidth) {
224 texviewwidth = kTextureSize;
225 if (texviewwidth > screenwidth) {
226 texviewwidth = screenwidth;
228 texviewheight = kTextureSize;
229 if (texviewheight > screenheight) {
230 texviewheight = screenheight;
233 texcoordwidth = screenwidth / kTextureSize;
234 texcoordheight = screenheight / kTextureSize;
235 if (texcoordwidth > 1) {
238 if (texcoordheight > 1) {
243 glDrawBuffer(GL_BACK);
244 glReadBuffer(GL_BACK);
246 static XYZ terrainlight;
247 static float distance;
248 if (drawmode == normalmode) {
249 Game::ReSizeGLScene(90, .1f);
251 glViewport(0, 0, texviewwidth, texviewheight);
253 glDepthFunc(GL_LEQUAL);
255 glAlphaFunc(GL_GREATER, 0.0001f);
256 glEnable(GL_ALPHA_TEST);
257 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
258 glClear(GL_DEPTH_BUFFER_BIT);
260 glMatrixMode(GL_MODELVIEW);
261 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
264 // Move the camera for the current eye's point of view.
265 // Reverse the movement if we're reversing stereo
266 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
269 if (!cameramode && !freeze && !winfreeze) {
271 glRotatef(float(Random() % 100) / 10 * camerashake /*+(woozy*woozy)/10*/, 0, 0, 1);
273 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
274 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
276 if (cameramode || freeze || winfreeze) {
277 glRotatef(pitch, 1, 0, 0);
278 glRotatef(yaw, 0, 1, 0);
281 if (environment == desertenvironment) {
282 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
283 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
285 SetUpLight(&light, 0);
288 //heat blur effect in desert
289 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
290 blurness = targetblurness;
291 targetblurness = (float)(abs(Random() % 100)) / 40;
293 if (blurness < targetblurness) {
294 blurness += multiplier * 5;
296 blurness -= multiplier * 5;
299 if (environment == desertenvironment) {
301 glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, blurness + .4);
303 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
304 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
307 glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0);
309 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
310 frustum.GetFrustum();
312 //make shadow decals on terrain and Object::objects
314 static float size, opacity, rotation;
316 for (unsigned int k = 0; k < Person::players.size(); k++) {
317 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping) {
318 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y + Person::players[k]->scale * 3, Person::players[k]->coords.z, Person::players[k]->scale * 7) && Person::players[k]->occluded < 25) {
319 for (unsigned int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
320 if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin) {
321 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
323 opacity = .4 - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10;
324 if (k != 0 && Tutorial::active) {
325 opacity = .2 + .2 * sin(smoketex * 6 + i) - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10;
327 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
328 for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
329 unsigned int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
330 if (Object::objects[j]->position.y < Person::players[k]->coords.y || Object::objects[j]->type == tunneltype || Object::objects[j]->type == weirdtype) {
331 point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
334 if (k != 0 && Tutorial::active) {
335 opacity = .2 + .2 * sin(smoketex * 6 + i);
337 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
344 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail) {
345 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5) && Person::players[k]->occluded < 25) {
346 for (unsigned i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
347 if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin || Person::players[k]->skeleton.joints[i].label == leftelbow || Person::players[k]->skeleton.joints[i].label == rightelbow || Person::players[k]->skeleton.joints[i].label == neck) {
348 if (Person::players[k]->skeleton.free) {
349 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
351 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
354 opacity = .4 - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
355 if (k != 0 && Tutorial::active) {
356 opacity = .2 + .2 * sin(smoketex * 6 + i) - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10;
358 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
359 for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
360 unsigned int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
361 if (Object::objects[j]->position.y < Person::players[k]->coords.y || Object::objects[j]->type == tunneltype || Object::objects[j]->type == weirdtype) {
362 if (Person::players[k]->skeleton.free) {
363 point = DoRotation(Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
365 point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
369 if (k != 0 && Tutorial::active) {
370 opacity = .2 + .2 * sin(smoketex * 6 + i);
372 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
380 if (!Person::players[k]->playerdetail) {
381 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
382 point = Person::players[k]->coords;
384 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
385 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
386 for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
387 unsigned int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
388 point = DoRotation(Person::players[k]->coords - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
391 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
398 glEnable(GL_TEXTURE_2D);
400 glEnable(GL_DEPTH_TEST);
401 glEnable(GL_CULL_FACE);
403 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
404 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
405 terraintexture.bind();
407 terraintexture2.bind();
410 terrain.drawdecals();
413 glEnable(GL_CULL_FACE);
414 glEnable(GL_LIGHTING);
416 glEnable(GL_TEXTURE_2D);
419 glEnable(GL_COLOR_MATERIAL);
422 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
423 glEnable(GL_CULL_FACE);
424 glCullFace(GL_FRONT);
426 for (unsigned k = 0; k < Person::players.size(); k++) {
427 if (k == 0 || !Tutorial::active) {
429 glEnable(GL_LIGHTING);
430 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
431 distance = distsq(&viewer, &Person::players[k]->coords);
432 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
433 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
437 if (distance >= .5) {
438 checkpoint = DoRotation(Person::players[k]->skeleton.joints[fabs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
441 if (Person::players[k]->occluded != 0) {
442 i = Object::checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
445 i = Object::checkcollide(viewer, checkpoint);
448 Person::players[k]->occluded += 1;
449 Person::players[k]->lastoccluded = i;
451 Person::players[k]->occluded = 0;
453 if (Person::players[k]->occluded < 25) {
454 Person::players[k]->DrawSkeleton();
461 if (!cameramode && musictype == stream_fighttheme) {
462 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
468 glEnable(GL_TEXTURE_2D);
474 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
475 glAlphaFunc(GL_GREATER, 0.0001f);
477 glDisable(GL_CULL_FACE);
478 glDisable(GL_LIGHTING);
480 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
481 glRotatef(hawkyaw, 0, 1, 0);
482 glTranslatef(25, 0, 0);
483 distance = distsq(&viewer, &realhawkcoords) * 1.2;
484 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
485 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1) {
486 glColor4f(light.color[0], light.color[1], light.color[2], 1);
488 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0) {
489 hawk.drawdifftex(hawktexture);
494 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
495 glEnable(GL_CULL_FACE);
496 glCullFace(GL_FRONT);
498 for (unsigned k = 0; k < Person::players.size(); k++) {
499 if (!(k == 0 || !Tutorial::active)) {
501 glEnable(GL_LIGHTING);
502 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
503 distance = distsq(&viewer, &Person::players[k]->coords);
504 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
505 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
509 if (distance >= .5) {
510 checkpoint = DoRotation(Person::players[k]->skeleton.joints[fabs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
513 if (Person::players[k]->occluded != 0) {
514 i = Object::checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
517 i = Object::checkcollide(viewer, checkpoint);
520 Person::players[k]->occluded += 1;
521 Person::players[k]->lastoccluded = i;
523 Person::players[k]->occluded = 0;
525 if (Person::players[k]->occluded < 25) {
526 Person::players[k]->DrawSkeleton();
533 glEnable(GL_TEXTURE_2D);
538 glDisable(GL_COLOR_MATERIAL);
540 glDisable(GL_LIGHTING);
541 glDisable(GL_TEXTURE_2D);
547 //waypoints, pathpoints in editor
550 glDisable(GL_LIGHTING);
551 glDisable(GL_TEXTURE_2D);
552 glDisable(GL_COLOR_MATERIAL);
553 glColor4f(1, 1, 0, 1);
555 for (unsigned k = 0; k < Person::players.size(); k++) {
556 if (Person::players[k]->numwaypoints > 1) {
557 glBegin(GL_LINE_LOOP);
558 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
559 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
565 if (numpathpoints > 1) {
566 glColor4f(0, 1, 0, 1);
567 for (unsigned k = 0; int(k) < numpathpoints; k++) {
568 if (numpathpointconnect[k]) {
569 for (int i = 0; i < numpathpointconnect[k]; i++) {
570 glBegin(GL_LINE_LOOP);
571 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
572 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
577 glColor4f(1, 1, 1, 1);
580 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
587 glEnable(GL_TEXTURE_2D);
588 glColor4f(.5, .5, .5, 1);
590 if (!Tutorial::active) {
591 if (bonus > 0 && bonustime < 1 && !winfreeze && !Dialog::inDialog()) {
592 const char* bonus_name;
593 if (bonus < bonus_count) {
594 bonus_name = bonus_names[bonus];
596 bonus_name = "Excellent!"; // When does this happen?
598 text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
600 string = to_string((int)bonusvalue);
601 text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * string.size(), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
603 glColor4f(.5, .5, .5, 1);
607 if (Tutorial::active) {
608 Tutorial::DrawTextInfo();
612 if (Hotspot::hotspots.size() && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !Tutorial::active) {
613 float closestdist = -1;
614 int closest = Hotspot::current;
615 for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
616 float distance = distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position);
617 if (closestdist == -1 || distance < closestdist) {
618 if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position) < Hotspot::hotspots[i].size && ((Hotspot::hotspots[i].type <= 10 && Hotspot::hotspots[i].type >= 0) || (Hotspot::hotspots[i].type <= 40 && Hotspot::hotspots[i].type >= 20))) {
619 closestdist = distance;
625 Hotspot::current = closest;
626 if (Hotspot::hotspots[closest].type <= 10) {
627 if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[closest].position) < Hotspot::hotspots[closest].size) {
628 Tutorial::stagetime = 0;
630 Tutorial::maxtime = 1;
631 tutorialopac = Tutorial::maxtime - Tutorial::stagetime;
632 if (tutorialopac > 1) {
635 if (tutorialopac < 0) {
639 string = Hotspot::hotspots[closest].text;
646 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
647 text->glPrintOutlined(1, 1, 1, tutorialopac, screenwidth / 2 - 7.6 * (i - lastline) * screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
650 if (string[i] == '\0') {
659 } else if ((Hotspot::hotspots[closest].type >= 20) && (Dialog::dialogs[Hotspot::hotspots[closest].type - 20].gonethrough == 0)) {
660 Dialog::whichdialogue = Hotspot::hotspots[closest].type - 20;
661 Dialog::currentDialog().play();
662 Dialog::currentDialog().gonethrough++;
667 if (Dialog::inDialog() && !mainmenu) {
668 glDisable(GL_DEPTH_TEST);
669 glDisable(GL_CULL_FACE);
670 glDisable(GL_LIGHTING);
671 glDisable(GL_TEXTURE_2D);
673 glMatrixMode(GL_PROJECTION);
676 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
677 glMatrixMode(GL_MODELVIEW);
680 if (Dialog::currentScene().location == 1) {
681 glTranslatef(0, screenheight * 3 / 4, 0);
683 glScalef(screenwidth, screenheight / 4, 1);
684 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
687 glColor4f(Dialog::currentScene().color[0], Dialog::currentScene().color[1], Dialog::currentScene().color[2], 0.7);
689 glVertex3f(0, 0, 0.0f);
690 glVertex3f(1, 0, 0.0f);
691 glVertex3f(1, 1, 0.0f);
692 glVertex3f(0, 1, 0.0f);
694 glMatrixMode(GL_PROJECTION);
696 glMatrixMode(GL_MODELVIEW);
698 glEnable(GL_DEPTH_TEST);
699 glEnable(GL_CULL_FACE);
702 glEnable(GL_TEXTURE_2D);
709 startx = screenwidth * 1 / 5;
710 if (Dialog::currentScene().location == 1) {
711 starty = screenheight / 16 + screenheight * 4 / 5;
713 starty = screenheight * 1 / 5 - screenheight / 16;
716 // FIXME - What is that char[] building for?
719 for (int i = 0; i < 264; i++) {
723 for (unsigned i = 0; i < Dialog::currentScene().name.size(); i++) {
724 tempname[tempnum] = Dialog::currentScene().name[i];
725 if (tempname[tempnum] == '#' || tempname[tempnum] == '\0') {
726 tempname[tempnum] = '\0';
732 string = std::string(tempname) + ": ";
734 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
735 text->glPrintOutlined(0.7, 0.7, 0.7, tutorialopac, startx - 2 * 7.6 * string.size() * screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
737 glColor4f(0, 0, 0, tutorialopac);
738 text->glPrintOutline(startx - 2 * 7.6 * string.size() * screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
742 for (unsigned i = 0; i < Dialog::currentScene().text.size() + 1; i++) {
743 tempname[tempnum] = Dialog::currentScene().text[i];
744 if (Dialog::currentScene().text[i] != '#') {
756 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
757 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
758 text->glPrintOutlined(1, 1, 1, tutorialopac, startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
760 glColor4f(0, 0, 0, tutorialopac);
761 text->glPrint(startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
765 if (string[i] == '\0') {
776 if (!Tutorial::active && !winfreeze && !Dialog::inDialog() && !mainmenu) {
779 string = "Score: " + to_string(int(Account::active().getCampaignScore()));
781 string = "Score: " + to_string(int(Account::active().getCampaignScore() + bonustotal));
784 string = "Score: " + to_string(int(bonustotal));
786 text->glPrintOutlined(1, 0, 0, 1, 1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
788 glDisable(GL_DEPTH_TEST);
789 glDisable(GL_CULL_FACE);
790 glDisable(GL_LIGHTING);
791 glDisable(GL_TEXTURE_2D);
793 glMatrixMode(GL_PROJECTION);
796 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
797 glMatrixMode(GL_MODELVIEW);
800 glTranslatef(15, screenheight * 17.5 / 20, 0);
801 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
802 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
804 glColor4f(0.0, 0.4, 0.0, 0.7);
805 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
807 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
808 glVertex3f(1, 0, 0.0f);
809 glVertex3f(1, 1, 0.0f);
810 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
812 glColor4f(0.1, 0.0, 0.0, 1);
813 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
815 glVertex3f(0, 0, 0.0f);
816 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
817 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
818 glVertex3f(0, 1, 0.0f);
820 glColor4f(0.4, 0.0, 0.0, 0.7);
821 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
823 glVertex3f(0, 0, 0.0f);
824 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
825 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
826 glVertex3f(0, 1, 0.0f);
828 glColor4f(0.4, 0.0, 0.0, 0.7);
829 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
831 glVertex3f(0, 0, 0.0f);
832 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
833 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
834 glVertex3f(0, 1, 0.0f);
836 glColor4f(0.4, 0.0, 0.0, 0.7);
837 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
839 glVertex3f(0, 0, 0.0f);
840 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
841 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
842 glVertex3f(0, 1, 0.0f);
844 glColor4f(0.0, 0.0, 0.0, 0.7);
846 glBegin(GL_LINE_STRIP);
847 glVertex3f(0, 0, 0.0f);
848 glVertex3f(1, 0, 0.0f);
849 glVertex3f(1, 1, 0.0f);
850 glVertex3f(0, 1, 0.0f);
851 glVertex3f(0, 0, 0.0f);
854 glMatrixMode(GL_PROJECTION);
856 glMatrixMode(GL_MODELVIEW);
858 glEnable(GL_DEPTH_TEST);
859 glEnable(GL_CULL_FACE);
862 glEnable(GL_TEXTURE_2D);
864 // writing the numbers :
865 string = "Damages : " + to_string(int(Person::players[0]->damage)) + "/" + to_string(int(Person::players[0]->damagetolerance)) + " (" + to_string(int(Person::players[0]->bloodloss)) + ")";
866 text->glPrintOutlined(1, 0, 0, 1, 1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
870 glColor4f(.5, .5, .5, 1);
872 if ((texttoggle || editorenabled) && devtools && !mainmenu) {
873 string = "The framespersecond is " + to_string(int(fps));
874 text->glPrint(10, 30, string, 0, .8, 1024, 768);
877 string = "Map editor enabled.";
879 string = "Map editor disabled.";
881 text->glPrint(10, 60, string, 0, .8, 1024, 768);
883 string = "Object size: " + to_string(editorsize);
884 text->glPrint(10, 75, string, 0, .8, 1024, 768);
885 if (editoryaw >= 0) {
886 string = "Object yaw: " + to_string(editoryaw);
888 string = "Object yaw: Random";
890 text->glPrint(10, 90, string, 0, .8, 1024, 768);
891 if (editorpitch >= 0) {
892 string = "Object pitch: " + to_string(editorpitch);
894 string = "Object pitch: Random";
896 text->glPrint(10, 105, string, 0, .8, 1024, 768);
897 string = "Object type: " + to_string(editortype);
898 text->glPrint(10, 120, string, 0, .8, 1024, 768);
899 switch (editortype) {
925 string = "(chimney)";
928 string = "(platform)";
937 text->glPrint(130, 120, string, 0, .8, 1024, 768);
939 string = "Numplayers: " + to_string(Person::players.size());
940 text->glPrint(10, 155, string, 0, .8, 1024, 768);
941 string = "Player " + to_string(int(Person::players.size()) - 1) + ": numwaypoints: " + to_string(Person::players.back()->numwaypoints);
942 text->glPrint(10, 140, string, 0, .8, 1024, 768);
944 string = "Difficulty: " + to_string(difficulty);
945 text->glPrint(10, 240, string, 0, .8, 1024, 768);
949 if (drawmode == glowmode) {
950 glDisable(GL_DEPTH_TEST);
951 glDisable(GL_CULL_FACE);
952 glDisable(GL_LIGHTING);
953 glDisable(GL_TEXTURE_2D);
955 glMatrixMode(GL_PROJECTION);
958 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
959 glMatrixMode(GL_MODELVIEW);
962 glScalef(screenwidth, screenheight, 1);
963 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
965 glColor4f(0, 0, 0, .5);
967 glVertex3f(0, 0, 0.0f);
968 glVertex3f(256, 0, 0.0f);
969 glVertex3f(256, 256, 0.0f);
970 glVertex3f(0, 256, 0.0f);
972 glMatrixMode(GL_PROJECTION);
974 glMatrixMode(GL_MODELVIEW);
976 glEnable(GL_DEPTH_TEST);
977 glEnable(GL_CULL_FACE);
982 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
983 glDisable(GL_DEPTH_TEST);
984 glDisable(GL_CULL_FACE);
985 glDisable(GL_LIGHTING);
986 glDisable(GL_TEXTURE_2D);
988 glMatrixMode(GL_PROJECTION);
991 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
992 glMatrixMode(GL_MODELVIEW);
995 glScalef(screenwidth, screenheight, 1);
996 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
998 if (Person::players[0]->dead) {
999 blackout += multiplier * 3;
1001 if (Person::players[0]->dead == 1) {
1004 if (Person::players[0]->dead == 2 && blackout > .6) {
1007 glColor4f(0, 0, 0, blackout);
1008 if (!Person::players[0]->dead) {
1009 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)) * .3 < .3) {
1010 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3);
1011 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1013 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1014 blackout = Person::players[0]->blooddimamount * .3;
1018 glColor4f(.7, 0, 0, .2);
1021 glVertex3f(0, 0, 0.0f);
1022 glVertex3f(256, 0, 0.0f);
1023 glVertex3f(256, 256, 0.0f);
1024 glVertex3f(0, 256, 0.0f);
1026 glMatrixMode(GL_PROJECTION);
1028 glMatrixMode(GL_MODELVIEW);
1030 glEnable(GL_DEPTH_TEST);
1031 glEnable(GL_CULL_FACE);
1032 glDisable(GL_BLEND);
1036 if (flashamount > 0 && damageeffects) {
1037 if (flashamount > 1) {
1040 if (flashdelay <= 0) {
1041 flashamount -= multiplier;
1044 if (flashamount < 0) {
1047 glDisable(GL_DEPTH_TEST);
1048 glDisable(GL_CULL_FACE);
1049 glDisable(GL_LIGHTING);
1051 glMatrixMode(GL_PROJECTION);
1054 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1055 glMatrixMode(GL_MODELVIEW);
1058 glScalef(screenwidth, screenheight, 1);
1059 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1061 glColor4f(flashr, flashg, flashb, flashamount);
1063 glVertex3f(0, 0, 0.0f);
1064 glVertex3f(256, 0, 0.0f);
1065 glVertex3f(256, 256, 0.0f);
1066 glVertex3f(0, 256, 0.0f);
1068 glMatrixMode(GL_PROJECTION);
1070 glMatrixMode(GL_MODELVIEW);
1072 glEnable(GL_DEPTH_TEST);
1073 glEnable(GL_CULL_FACE);
1074 glDisable(GL_BLEND);
1078 if (difficulty < 2 && !Dialog::inDialog()) { // minimap
1079 float mapviewdist = 20000;
1081 glDisable(GL_DEPTH_TEST);
1082 glColor3f(1.0, 1.0, 1.0); // no coloring
1084 glEnable(GL_TEXTURE_2D);
1085 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1086 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1087 glDisable(GL_DEPTH_TEST);
1088 glDisable(GL_CULL_FACE);
1089 glDisable(GL_LIGHTING);
1091 glMatrixMode(GL_PROJECTION);
1094 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1095 glMatrixMode(GL_MODELVIEW);
1098 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1099 glTranslatef(1.75, .25, 0);
1100 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1102 glColor4f(1, 1, 1, 1);
1109 center = Person::players[0]->coords;
1113 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1115 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1117 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1118 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1119 for (unsigned int i = 0; i < Object::objects.size(); i++) {
1120 if (Object::objects[i]->type == treetrunktype) {
1121 distcheck = distsq(&Person::players[0]->coords, &Object::objects[i]->position);
1122 if (distcheck < mapviewdist) {
1123 Mapcircletexture.bind();
1124 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1126 glTranslatef(Object::objects[i]->position.x / terrain.scale / 256 * -2 + 1, Object::objects[i]->position.z / terrain.scale / 256 * 2 - 1, 0);
1127 glRotatef(Object::objects[i]->yaw, 0, 0, 1);
1128 glScalef(.003, .003, .003);
1131 glVertex3f(-1, -1, 0.0f);
1133 glVertex3f(1, -1, 0.0f);
1135 glVertex3f(1, 1, 0.0f);
1137 glVertex3f(-1, 1, 0.0f);
1142 if (Object::objects[i]->type == boxtype) {
1143 distcheck = distsq(&Person::players[0]->coords, &Object::objects[i]->position);
1144 if (distcheck < mapviewdist) {
1145 Mapboxtexture.bind();
1146 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1148 glTranslatef(Object::objects[i]->position.x / terrain.scale / 256 * -2 + 1, Object::objects[i]->position.z / terrain.scale / 256 * 2 - 1, 0);
1149 glRotatef(Object::objects[i]->yaw, 0, 0, 1);
1150 glScalef(.01 * Object::objects[i]->scale, .01 * Object::objects[i]->scale, .01 * Object::objects[i]->scale);
1153 glVertex3f(-1, -1, 0.0f);
1155 glVertex3f(1, -1, 0.0f);
1157 glVertex3f(1, 1, 0.0f);
1159 glVertex3f(-1, 1, 0.0f);
1165 if (editorenabled) {
1166 Mapcircletexture.bind();
1167 for (int i = 0; i < numboundaries; i++) {
1168 glColor4f(0, 0, 0, opac / 3);
1170 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1171 glScalef(.002, .002, .002);
1174 glVertex3f(-1, -1, 0.0f);
1176 glVertex3f(1, -1, 0.0f);
1178 glVertex3f(1, 1, 0.0f);
1180 glVertex3f(-1, 1, 0.0f);
1185 for (unsigned i = 0; i < Person::players.size(); i++) {
1186 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1187 if (distcheck < mapviewdist) {
1189 Maparrowtexture.bind();
1191 glColor4f(1, 1, 1, opac);
1192 } else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping) {
1193 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1194 } else if (Person::players[i]->dead) {
1195 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1196 } else if (Person::players[i]->aitype == attacktypecutoff) {
1197 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1198 } else if (Person::players[i]->aitype == passivetype) {
1199 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1201 glColor4f(1, 1, 0, 1);
1203 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1204 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1205 glScalef(.005, .005, .005);
1208 glVertex3f(-1, -1, 0.0f);
1210 glVertex3f(1, -1, 0.0f);
1212 glVertex3f(1, 1, 0.0f);
1214 glVertex3f(-1, 1, 0.0f);
1220 glDisable(GL_TEXTURE_2D);
1221 glMatrixMode(GL_PROJECTION);
1223 glMatrixMode(GL_MODELVIEW);
1225 glEnable(GL_DEPTH_TEST);
1226 glEnable(GL_CULL_FACE);
1227 glDisable(GL_BLEND);
1231 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1232 glDisable(GL_DEPTH_TEST);
1233 glDisable(GL_CULL_FACE);
1234 glDisable(GL_LIGHTING);
1235 glDisable(GL_TEXTURE_2D);
1237 glMatrixMode(GL_PROJECTION);
1240 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1241 glMatrixMode(GL_MODELVIEW);
1244 glScalef(screenwidth, screenheight, 1);
1245 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1247 glColor4f(0, 0, 0, .7);
1249 glVertex3f(0, 0, 0.0f);
1250 glVertex3f(256, 0, 0.0f);
1251 glVertex3f(256, 256, 0.0f);
1252 glVertex3f(0, 256, 0.0f);
1254 glMatrixMode(GL_PROJECTION);
1256 glMatrixMode(GL_MODELVIEW);
1258 glEnable(GL_DEPTH_TEST);
1259 glEnable(GL_CULL_FACE);
1260 glDisable(GL_BLEND);
1264 glDisable(GL_DEPTH_TEST);
1265 glColor3f(1.0, 1.0, 1.0); // no coloring
1267 glEnable(GL_TEXTURE_2D);
1272 glEnable(GL_TEXTURE_2D);
1273 glColor4f(1, 1, 1, 1);
1274 string = "Loading...";
1275 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1278 drawmode = normalmode;
1281 if (winfreeze && !campaign) {
1282 glDisable(GL_DEPTH_TEST);
1283 glDisable(GL_CULL_FACE);
1284 glDisable(GL_LIGHTING);
1285 glDisable(GL_TEXTURE_2D);
1287 glMatrixMode(GL_PROJECTION);
1290 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1291 glMatrixMode(GL_MODELVIEW);
1294 glScalef(screenwidth, screenheight, 1);
1295 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1297 glColor4f(0, 0, 0, .4);
1299 glVertex3f(0, 0, 0.0f);
1300 glVertex3f(256, 0, 0.0f);
1301 glVertex3f(256, 256, 0.0f);
1302 glVertex3f(0, 256, 0.0f);
1304 glMatrixMode(GL_PROJECTION);
1306 glMatrixMode(GL_MODELVIEW);
1308 glEnable(GL_DEPTH_TEST);
1309 glEnable(GL_CULL_FACE);
1310 glDisable(GL_BLEND);
1314 glDisable(GL_DEPTH_TEST);
1315 glColor3f(1.0, 1.0, 1.0); // no coloring
1317 glEnable(GL_TEXTURE_2D);
1319 //Win Screen Won Victory
1321 glEnable(GL_TEXTURE_2D);
1322 glColor4f(1, 1, 1, 1);
1323 string = "Level Cleared!";
1324 text->glPrintOutlined(1024 / 2 - string.size() * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1326 string = "Score: " + to_string(int(bonustotal - startbonustotal));
1327 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1329 string = "Press Escape to return to menu or Space to continue";
1330 text->glPrintOutlined(640 / 2 - string.size() * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1332 int wontime = (int)round(wonleveltime);
1333 string = "Time: " + to_string(int((wontime - wontime % 60) / 60));
1334 if (wontime % 60 < 10) {
1337 string += to_string(int(wontime % 60));
1338 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1341 int awards[award_count];
1342 int numawards = award_awards(awards);
1344 for (int i = 0; i < numawards && i < 6; i++) {
1345 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1349 if (drawmode != normalmode) {
1350 glEnable(GL_TEXTURE_2D);
1352 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1353 if (screentexture) {
1355 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
1356 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1357 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1358 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
1359 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
1360 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
1362 glBindTexture(GL_TEXTURE_2D, screentexture);
1363 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1366 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1367 if (screentexture2) {
1368 glBindTexture(GL_TEXTURE_2D, screentexture2);
1369 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1371 if (!screentexture2) {
1372 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1374 glGenTextures(1, &screentexture2);
1375 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1377 glEnable(GL_TEXTURE_2D);
1378 glBindTexture(GL_TEXTURE_2D, screentexture2);
1379 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1380 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1382 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1387 glClear(GL_DEPTH_BUFFER_BIT);
1388 Game::ReSizeGLScene(90, .1f);
1389 glViewport(0, 0, screenwidth, screenheight);
1391 if (drawmode != normalmode) {
1392 glDisable(GL_DEPTH_TEST);
1393 if (drawmode == motionblurmode) {
1394 glDrawBuffer(GL_FRONT);
1395 glReadBuffer(GL_BACK);
1397 glColor3f(1.0, 1.0, 1.0); // no coloring
1399 glEnable(GL_TEXTURE_2D);
1400 glBindTexture(GL_TEXTURE_2D, screentexture);
1401 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1402 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1403 glDisable(GL_DEPTH_TEST);
1404 glDisable(GL_CULL_FACE);
1405 glDisable(GL_LIGHTING);
1407 glMatrixMode(GL_PROJECTION);
1410 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1411 glMatrixMode(GL_MODELVIEW);
1414 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1415 glTranslatef(1, 1, 0);
1416 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1418 if (drawmode == motionblurmode) {
1419 if (motionbluramount < .2) {
1420 motionbluramount = .2;
1422 glColor4f(1, 1, 1, motionbluramount);
1426 glVertex3f(-1, -1, 0.0f);
1427 glTexCoord2f(texcoordwidth, 0);
1428 glVertex3f(1, -1, 0.0f);
1429 glTexCoord2f(texcoordwidth, texcoordheight);
1430 glVertex3f(1, 1, 0.0f);
1431 glTexCoord2f(0, texcoordheight);
1432 glVertex3f(-1, 1, 0.0f);
1436 if (drawmode == realmotionblurmode) {
1437 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1438 glClear(GL_COLOR_BUFFER_BIT);
1439 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1440 glBindTexture(GL_TEXTURE_2D, screentexture);
1441 glColor4f(1, 1, 1, .5);
1445 glVertex3f(-1, -1, 0.0f);
1446 glTexCoord2f(texcoordwidth, 0);
1447 glVertex3f(1, -1, 0.0f);
1448 glTexCoord2f(texcoordwidth, texcoordheight);
1449 glVertex3f(1, 1, 0.0f);
1450 glTexCoord2f(0, texcoordheight);
1451 glVertex3f(-1, 1, 0.0f);
1454 glBindTexture(GL_TEXTURE_2D, screentexture2);
1455 glColor4f(1, 1, 1, .5);
1459 glVertex3f(-1, -1, 0.0f);
1460 glTexCoord2f(texcoordwidth, 0);
1461 glVertex3f(1, -1, 0.0f);
1462 glTexCoord2f(texcoordwidth, texcoordheight);
1463 glVertex3f(1, 1, 0.0f);
1464 glTexCoord2f(0, texcoordheight);
1465 glVertex3f(-1, 1, 0.0f);
1468 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1470 if (drawmode == doublevisionmode) {
1471 static float crosseyedness;
1472 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1473 if (crosseyedness > 1) {
1476 if (crosseyedness < 0) {
1479 glColor4f(1, 1, 1, 1);
1480 glDisable(GL_BLEND);
1485 glVertex3f(-1, -1, 0.0f);
1486 glTexCoord2f(texcoordwidth, 0);
1487 glVertex3f(1, -1, 0.0f);
1488 glTexCoord2f(texcoordwidth, texcoordheight);
1489 glVertex3f(1, 1, 0.0f);
1490 glTexCoord2f(0, texcoordheight);
1491 glVertex3f(-1, 1, 0.0f);
1494 if (crosseyedness) {
1495 glColor4f(1, 1, 1, .5);
1498 glTranslatef(.015 * crosseyedness, 0, 0);
1502 glVertex3f(-1, -1, 0.0f);
1503 glTexCoord2f(texcoordwidth, 0);
1504 glVertex3f(1, -1, 0.0f);
1505 glTexCoord2f(texcoordwidth, texcoordheight);
1506 glVertex3f(1, 1, 0.0f);
1507 glTexCoord2f(0, texcoordheight);
1508 glVertex3f(-1, 1, 0.0f);
1513 if (drawmode == glowmode) {
1514 glColor4f(.5, .5, .5, .5);
1516 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1518 glTranslatef(.01, 0, 0);
1521 glVertex3f(-1, -1, 0.0f);
1522 glTexCoord2f(texcoordwidth, 0);
1523 glVertex3f(1, -1, 0.0f);
1524 glTexCoord2f(texcoordwidth, texcoordheight);
1525 glVertex3f(1, 1, 0.0f);
1526 glTexCoord2f(0, texcoordheight);
1527 glVertex3f(-1, 1, 0.0f);
1531 glTranslatef(-.01, 0, 0);
1534 glVertex3f(-1, -1, 0.0f);
1535 glTexCoord2f(texcoordwidth, 0);
1536 glVertex3f(1, -1, 0.0f);
1537 glTexCoord2f(texcoordwidth, texcoordheight);
1538 glVertex3f(1, 1, 0.0f);
1539 glTexCoord2f(0, texcoordheight);
1540 glVertex3f(-1, 1, 0.0f);
1544 glTranslatef(.0, .01, 0);
1547 glVertex3f(-1, -1, 0.0f);
1548 glTexCoord2f(texcoordwidth, 0);
1549 glVertex3f(1, -1, 0.0f);
1550 glTexCoord2f(texcoordwidth, texcoordheight);
1551 glVertex3f(1, 1, 0.0f);
1552 glTexCoord2f(0, texcoordheight);
1553 glVertex3f(-1, 1, 0.0f);
1557 glTranslatef(0, -.01, 0);
1560 glVertex3f(-1, -1, 0.0f);
1561 glTexCoord2f(texcoordwidth, 0);
1562 glVertex3f(1, -1, 0.0f);
1563 glTexCoord2f(texcoordwidth, texcoordheight);
1564 glVertex3f(1, 1, 0.0f);
1565 glTexCoord2f(0, texcoordheight);
1566 glVertex3f(-1, 1, 0.0f);
1570 if (drawmode == radialzoommode) {
1571 for (int i = 0; i < 3; i++) {
1572 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1574 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1577 glVertex3f(-1, -1, 0.0f);
1578 glTexCoord2f(texcoordwidth, 0);
1579 glVertex3f(1, -1, 0.0f);
1580 glTexCoord2f(texcoordwidth, texcoordheight);
1581 glVertex3f(1, 1, 0.0f);
1582 glTexCoord2f(0, texcoordheight);
1583 glVertex3f(-1, 1, 0.0f);
1588 glDisable(GL_TEXTURE_2D);
1589 glMatrixMode(GL_PROJECTION);
1591 glMatrixMode(GL_MODELVIEW);
1593 glEnable(GL_DEPTH_TEST);
1594 glEnable(GL_CULL_FACE);
1595 glDisable(GL_BLEND);
1600 glEnable(GL_TEXTURE_2D);
1601 glColor4f(1, 1, 1, 1);
1603 if (consoleselected >= 60) {
1604 offset = consoleselected - 60;
1606 textmono->glPrint(10, 30, " ]", 0, 1, 1024, 768);
1608 textmono->glPrint(30 + (float)consoleselected * 10 - offset * 10, 30, "_", 0, 1, 1024, 768);
1610 for (unsigned i = 0; i < 15; i++) {
1611 textmono->glPrint(30 - offset * 10, 30 + i * 20, consoletext[i], 0, 1, 1024, 768);
1616 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1617 multiplier = tempmult;
1624 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1625 tempmult = multiplier;
1629 if (side == stereoRight || side == stereoCenter) {
1630 if (drawmode != motionblurmode || mainmenu) {
1635 glDrawBuffer(GL_BACK);
1636 glReadBuffer(GL_BACK);
1640 if (drawtoggle == 2) {
1644 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1645 multiplier = tempmult;
1647 //Jordan fixed your warning!
1653 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1656 glDrawBuffer(GL_BACK);
1657 glReadBuffer(GL_BACK);
1658 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1659 Game::ReSizeGLScene(90, .1f);
1661 //draw menu background
1662 glClear(GL_DEPTH_BUFFER_BIT);
1663 glEnable(GL_ALPHA_TEST);
1664 glAlphaFunc(GL_GREATER, 0.001f);
1665 glEnable(GL_TEXTURE_2D);
1666 glDisable(GL_DEPTH_TEST);
1667 glDisable(GL_CULL_FACE);
1668 glDisable(GL_LIGHTING);
1670 glMatrixMode(GL_PROJECTION);
1673 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1674 glMatrixMode(GL_MODELVIEW);
1677 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1679 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1680 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1681 glDisable(GL_BLEND);
1682 glColor4f(0, 0, 0, 1.0);
1683 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1684 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1685 glDisable(GL_TEXTURE_2D);
1687 glVertex3f(-1, -1, 0);
1688 glVertex3f(+1, -1, 0);
1689 glVertex3f(+1, +1, 0);
1690 glVertex3f(-1, +1, 0);
1693 glColor4f(0.4, 0.4, 0.4, 1.0);
1694 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1695 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1696 glEnable(GL_TEXTURE_2D);
1697 Game::Mainmenuitems[4].bind();
1700 glVertex3f(-1, -1, 0);
1702 glVertex3f(+1, -1, 0);
1704 glVertex3f(+1, +1, 0);
1706 glVertex3f(-1, +1, 0);
1710 glMatrixMode(GL_PROJECTION);
1712 glMatrixMode(GL_MODELVIEW);
1714 glMatrixMode(GL_PROJECTION);
1717 glOrtho(0, 640, 0, 480, -100, 100);
1718 glMatrixMode(GL_MODELVIEW);
1721 glEnable(GL_TEXTURE_2D);
1726 glMatrixMode(GL_PROJECTION);
1728 glMatrixMode(GL_MODELVIEW);
1731 glMatrixMode(GL_PROJECTION);
1734 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1735 glMatrixMode(GL_MODELVIEW);
1738 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1740 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1741 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1743 glEnable(GL_TEXTURE_2D);
1744 glColor4f(1, 1, 1, 1);
1745 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1746 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1748 if (!Game::waiting) { // hide the cursor while waiting for a key
1750 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
1751 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
1752 glTranslatef(1, -1, 0);
1753 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1754 glColor4f(1, 1, 1, 1);
1755 Game::cursortexture.bind();
1759 glVertex3f(-1, -1, 0.0f);
1761 glVertex3f(1, -1, 0.0f);
1763 glVertex3f(1, 1, 0.0f);
1765 glVertex3f(-1, 1, 0.0f);
1771 glMatrixMode(GL_PROJECTION);
1775 if (flashamount > 0) {
1776 if (flashamount > 1) {
1779 if (flashdelay <= 0) {
1780 flashamount -= multiplier;
1783 if (flashamount < 0) {
1786 glDisable(GL_DEPTH_TEST);
1787 glDisable(GL_CULL_FACE);
1788 glDisable(GL_LIGHTING);
1789 glDisable(GL_TEXTURE_2D);
1791 glMatrixMode(GL_PROJECTION);
1794 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1795 glMatrixMode(GL_MODELVIEW);
1798 glScalef(screenwidth, screenheight, 1);
1799 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1801 glColor4f(flashr, flashg, flashb, flashamount);
1803 glVertex3f(0, 0, 0.0f);
1804 glVertex3f(256, 0, 0.0f);
1805 glVertex3f(256, 256, 0.0f);
1806 glVertex3f(0, 256, 0.0f);
1808 glMatrixMode(GL_PROJECTION);
1810 glMatrixMode(GL_MODELVIEW);
1812 glEnable(GL_DEPTH_TEST);
1813 glEnable(GL_CULL_FACE);
1814 glDisable(GL_BLEND);