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)
154 for (int i = 0; i < numboundaries; i++) {
157 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
166 int olddrawmode = drawmode;
167 if (ismotionblur && !loading) {
168 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
169 drawmode = motionblurmode;
170 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
173 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
174 drawmode = doublevisionmode;
179 if (slomo && !loading) {
181 drawmode = motionblurmode;
182 motionbluramount = .2;
183 slomodelay -= multiplier;
189 if ((!changed && !slomo) || loading) {
190 drawmode = normalmode;
191 if (ismotionblur && (/*fps>100||*/ alwaysblur)) {
192 if (olddrawmode != realmotionblurmode)
196 drawmode = realmotionblurmode;
197 } else if (olddrawmode == realmotionblurmode)
203 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
204 drawmode = normalmode;
205 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
206 drawmode = radialzoommode;
208 if (winfreeze || mainmenu)
209 drawmode = normalmode;
212 drawtoggle = 1 - drawtoggle;
214 if (!texcoordwidth) {
215 texviewwidth = kTextureSize;
216 if (texviewwidth > screenwidth)
217 texviewwidth = screenwidth;
218 texviewheight = kTextureSize;
219 if (texviewheight > screenheight)
220 texviewheight = screenheight;
222 texcoordwidth = screenwidth / kTextureSize;
223 texcoordheight = screenheight / kTextureSize;
224 if (texcoordwidth > 1)
226 if (texcoordheight > 1)
230 glDrawBuffer(GL_BACK);
231 glReadBuffer(GL_BACK);
233 static XYZ terrainlight;
234 static float distance;
235 if (drawmode == normalmode) {
236 Game::ReSizeGLScene(90, .1f);
238 glViewport(0, 0, texviewwidth, texviewheight);
240 glDepthFunc(GL_LEQUAL);
242 glAlphaFunc(GL_GREATER, 0.0001f);
243 glEnable(GL_ALPHA_TEST);
244 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
245 glClear(GL_DEPTH_BUFFER_BIT);
247 glMatrixMode(GL_MODELVIEW);
248 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
251 // Move the camera for the current eye's point of view.
252 // Reverse the movement if we're reversing stereo
253 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
256 if (!cameramode && !freeze && !winfreeze) {
258 glRotatef(float(Random() % 100) / 10 * camerashake /*+(woozy*woozy)/10*/, 0, 0, 1);
260 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
261 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
263 if (cameramode || freeze || winfreeze) {
264 glRotatef(pitch, 1, 0, 0);
265 glRotatef(yaw, 0, 1, 0);
268 if (environment == desertenvironment) {
269 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
270 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
272 SetUpLight(&light, 0);
275 //heat blur effect in desert
276 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
277 blurness = targetblurness;
278 targetblurness = (float)(abs(Random() % 100)) / 40;
280 if (blurness < targetblurness)
281 blurness += multiplier * 5;
283 blurness -= multiplier * 5;
285 if (environment == desertenvironment) {
287 glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, blurness + .4);
289 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
290 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
293 glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0);
295 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
296 frustum.GetFrustum();
298 //make shadow decals on terrain and Object::objects
300 static float size, opacity, rotation;
302 for (unsigned int k = 0; k < Person::players.size(); k++) {
303 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
304 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)
305 for (unsigned int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
306 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) {
307 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
309 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;
310 if (k != 0 && Tutorial::active) {
311 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;
313 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
314 for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
315 unsigned int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
316 if (Object::objects[j]->position.y < Person::players[k]->coords.y || Object::objects[j]->type == tunneltype || Object::objects[j]->type == weirdtype) {
317 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);
320 if (k != 0 && Tutorial::active) {
321 opacity = .2 + .2 * sin(smoketex * 6 + i);
323 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
328 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
329 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)
330 for (unsigned i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
331 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) {
332 if (Person::players[k]->skeleton.free)
333 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
335 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
337 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;
338 if (k != 0 && Tutorial::active) {
339 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;
341 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
342 for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
343 unsigned int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
344 if (Object::objects[j]->position.y < Person::players[k]->coords.y || Object::objects[j]->type == tunneltype || Object::objects[j]->type == weirdtype) {
345 if (Person::players[k]->skeleton.free)
346 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);
348 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);
351 if (k != 0 && Tutorial::active) {
352 opacity = .2 + .2 * sin(smoketex * 6 + i);
354 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
360 if (!Person::players[k]->playerdetail)
361 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
362 point = Person::players[k]->coords;
364 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
365 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
366 for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
367 unsigned int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
368 point = DoRotation(Person::players[k]->coords - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
371 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
377 glEnable(GL_TEXTURE_2D);
379 glEnable(GL_DEPTH_TEST);
380 glEnable(GL_CULL_FACE);
382 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
383 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
384 terraintexture.bind();
386 terraintexture2.bind();
389 terrain.drawdecals();
392 glEnable(GL_CULL_FACE);
393 glEnable(GL_LIGHTING);
395 glEnable(GL_TEXTURE_2D);
398 glEnable(GL_COLOR_MATERIAL);
401 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
402 glEnable(GL_CULL_FACE);
403 glCullFace(GL_FRONT);
405 for (unsigned k = 0; k < Person::players.size(); k++) {
406 if (k == 0 || !Tutorial::active) {
408 glEnable(GL_LIGHTING);
409 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
410 distance = distsq(&viewer, &Person::players[k]->coords);
411 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
412 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
415 if (distance >= .5) {
416 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;
419 if (Person::players[k]->occluded != 0)
420 i = Object::checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
422 i = Object::checkcollide(viewer, checkpoint);
424 Person::players[k]->occluded += 1;
425 Person::players[k]->lastoccluded = i;
427 Person::players[k]->occluded = 0;
429 if (Person::players[k]->occluded < 25)
430 Person::players[k]->DrawSkeleton();
436 if (!cameramode && musictype == stream_fighttheme)
437 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
442 glEnable(GL_TEXTURE_2D);
448 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
449 glAlphaFunc(GL_GREATER, 0.0001f);
451 glDisable(GL_CULL_FACE);
452 glDisable(GL_LIGHTING);
454 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
455 glRotatef(hawkyaw, 0, 1, 0);
456 glTranslatef(25, 0, 0);
457 distance = distsq(&viewer, &realhawkcoords) * 1.2;
458 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
459 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
460 glColor4f(light.color[0], light.color[1], light.color[2], 1);
461 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
462 hawk.drawdifftex(hawktexture);
466 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
467 glEnable(GL_CULL_FACE);
468 glCullFace(GL_FRONT);
470 for (unsigned k = 0; k < Person::players.size(); k++) {
471 if (!(k == 0 || !Tutorial::active)) {
473 glEnable(GL_LIGHTING);
474 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
475 distance = distsq(&viewer, &Person::players[k]->coords);
476 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
477 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
480 if (distance >= .5) {
481 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;
484 if (Person::players[k]->occluded != 0) {
485 i = Object::checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
488 i = Object::checkcollide(viewer, checkpoint);
491 Person::players[k]->occluded += 1;
492 Person::players[k]->lastoccluded = i;
494 Person::players[k]->occluded = 0;
496 if (Person::players[k]->occluded < 25) {
497 Person::players[k]->DrawSkeleton();
504 glEnable(GL_TEXTURE_2D);
509 glDisable(GL_COLOR_MATERIAL);
511 glDisable(GL_LIGHTING);
512 glDisable(GL_TEXTURE_2D);
518 //waypoints, pathpoints in editor
521 glDisable(GL_LIGHTING);
522 glDisable(GL_TEXTURE_2D);
523 glDisable(GL_COLOR_MATERIAL);
524 glColor4f(1, 1, 0, 1);
526 for (unsigned k = 0; k < Person::players.size(); k++) {
527 if (Person::players[k]->numwaypoints > 1) {
528 glBegin(GL_LINE_LOOP);
529 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
530 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
536 if (numpathpoints > 1) {
537 glColor4f(0, 1, 0, 1);
538 for (unsigned k = 0; int(k) < numpathpoints; k++) {
539 if (numpathpointconnect[k]) {
540 for (int i = 0; i < numpathpointconnect[k]; i++) {
541 glBegin(GL_LINE_LOOP);
542 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
543 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
548 glColor4f(1, 1, 1, 1);
551 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
558 glEnable(GL_TEXTURE_2D);
559 glColor4f(.5, .5, .5, 1);
561 if (!Tutorial::active)
562 if (bonus > 0 && bonustime < 1 && !winfreeze && !Dialog::inDialog()) {
563 const char* bonus_name;
564 if (bonus < bonus_count)
565 bonus_name = bonus_names[bonus];
567 bonus_name = "Excellent!"; // When does this happen?
569 text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
571 string = to_string((int)bonusvalue);
572 text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * string.size(), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
574 glColor4f(.5, .5, .5, 1);
577 if (Tutorial::active) {
578 Tutorial::DrawTextInfo();
582 if (Hotspot::hotspots.size() && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !Tutorial::active) {
583 float closestdist = -1;
584 int closest = Hotspot::current;
585 for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
586 float distance = distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position);
587 if (closestdist == -1 || distance < closestdist) {
588 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))) {
589 closestdist = distance;
595 Hotspot::current = closest;
596 if (Hotspot::hotspots[closest].type <= 10) {
597 if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[closest].position) < Hotspot::hotspots[closest].size)
598 Tutorial::stagetime = 0;
599 Tutorial::maxtime = 1;
600 tutorialopac = Tutorial::maxtime - Tutorial::stagetime;
601 if (tutorialopac > 1)
603 if (tutorialopac < 0)
606 string = Hotspot::hotspots[closest].text;
613 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
614 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);
617 if (string[i] == '\0')
624 } else if ((Hotspot::hotspots[closest].type >= 20) && (Dialog::dialogs[Hotspot::hotspots[closest].type - 20].gonethrough == 0)) {
625 Dialog::whichdialogue = Hotspot::hotspots[closest].type - 20;
626 Dialog::currentDialog().play();
627 Dialog::currentDialog().gonethrough++;
632 if (Dialog::inDialog() && !mainmenu) {
633 glDisable(GL_DEPTH_TEST);
634 glDisable(GL_CULL_FACE);
635 glDisable(GL_LIGHTING);
636 glDisable(GL_TEXTURE_2D);
638 glMatrixMode(GL_PROJECTION);
641 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
642 glMatrixMode(GL_MODELVIEW);
645 if (Dialog::currentScene().location == 1)
646 glTranslatef(0, screenheight * 3 / 4, 0);
647 glScalef(screenwidth, screenheight / 4, 1);
648 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
651 glColor4f(Dialog::currentScene().color[0], Dialog::currentScene().color[1], Dialog::currentScene().color[2], 0.7);
653 glVertex3f(0, 0, 0.0f);
654 glVertex3f(1, 0, 0.0f);
655 glVertex3f(1, 1, 0.0f);
656 glVertex3f(0, 1, 0.0f);
658 glMatrixMode(GL_PROJECTION);
660 glMatrixMode(GL_MODELVIEW);
662 glEnable(GL_DEPTH_TEST);
663 glEnable(GL_CULL_FACE);
666 glEnable(GL_TEXTURE_2D);
673 startx = screenwidth * 1 / 5;
674 if (Dialog::currentScene().location == 1) {
675 starty = screenheight / 16 + screenheight * 4 / 5;
677 starty = screenheight * 1 / 5 - screenheight / 16;
680 // FIXME - What is that char[] building for?
683 for (int i = 0; i < 264; i++) {
687 for (unsigned i = 0; i < Dialog::currentScene().name.size(); i++) {
688 tempname[tempnum] = Dialog::currentScene().name[i];
689 if (tempname[tempnum] == '#' || tempname[tempnum] == '\0')
690 tempname[tempnum] = '\0';
695 string = std::string(tempname) + ": ";
697 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
698 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);
700 glColor4f(0, 0, 0, tutorialopac);
701 text->glPrintOutline(startx - 2 * 7.6 * string.size() * screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
705 for (unsigned i = 0; i < Dialog::currentScene().text.size() + 1; i++) {
706 tempname[tempnum] = Dialog::currentScene().text[i];
707 if (Dialog::currentScene().text[i] != '#')
718 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
719 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
720 text->glPrintOutlined(1, 1, 1, tutorialopac, startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
722 glColor4f(0, 0, 0, tutorialopac);
723 text->glPrint(startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
727 if (string[i] == '\0')
736 if (!Tutorial::active && !winfreeze && !Dialog::inDialog() && !mainmenu) {
739 string = "Score: " + to_string(int(Account::active().getCampaignScore()));
741 string = "Score: " + to_string(int(Account::active().getCampaignScore() + bonustotal));
744 string = "Score: " + to_string(int(bonustotal));
746 text->glPrintOutlined(1, 0, 0, 1, 1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
748 glDisable(GL_DEPTH_TEST);
749 glDisable(GL_CULL_FACE);
750 glDisable(GL_LIGHTING);
751 glDisable(GL_TEXTURE_2D);
753 glMatrixMode(GL_PROJECTION);
756 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
757 glMatrixMode(GL_MODELVIEW);
760 glTranslatef(15, screenheight * 17.5 / 20, 0);
761 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
762 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
764 glColor4f(0.0, 0.4, 0.0, 0.7);
765 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
767 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
768 glVertex3f(1, 0, 0.0f);
769 glVertex3f(1, 1, 0.0f);
770 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
772 glColor4f(0.1, 0.0, 0.0, 1);
773 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
775 glVertex3f(0, 0, 0.0f);
776 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
777 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
778 glVertex3f(0, 1, 0.0f);
780 glColor4f(0.4, 0.0, 0.0, 0.7);
781 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
783 glVertex3f(0, 0, 0.0f);
784 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
785 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
786 glVertex3f(0, 1, 0.0f);
788 glColor4f(0.4, 0.0, 0.0, 0.7);
789 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
791 glVertex3f(0, 0, 0.0f);
792 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
793 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
794 glVertex3f(0, 1, 0.0f);
796 glColor4f(0.4, 0.0, 0.0, 0.7);
797 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
799 glVertex3f(0, 0, 0.0f);
800 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
801 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
802 glVertex3f(0, 1, 0.0f);
804 glColor4f(0.0, 0.0, 0.0, 0.7);
806 glBegin(GL_LINE_STRIP);
807 glVertex3f(0, 0, 0.0f);
808 glVertex3f(1, 0, 0.0f);
809 glVertex3f(1, 1, 0.0f);
810 glVertex3f(0, 1, 0.0f);
811 glVertex3f(0, 0, 0.0f);
814 glMatrixMode(GL_PROJECTION);
816 glMatrixMode(GL_MODELVIEW);
818 glEnable(GL_DEPTH_TEST);
819 glEnable(GL_CULL_FACE);
822 glEnable(GL_TEXTURE_2D);
824 // writing the numbers :
825 string = "Damages : " + to_string(int(Person::players[0]->damage)) + "/" + to_string(int(Person::players[0]->damagetolerance)) + " (" + to_string(int(Person::players[0]->bloodloss)) + ")";
826 text->glPrintOutlined(1, 0, 0, 1, 1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
830 glColor4f(.5, .5, .5, 1);
832 if ((texttoggle || editorenabled) && devtools && !mainmenu) {
833 string = "The framespersecond is " + to_string(int(fps));
834 text->glPrint(10, 30, string, 0, .8, 1024, 768);
837 string = "Map editor enabled.";
839 string = "Map editor disabled.";
841 text->glPrint(10, 60, string, 0, .8, 1024, 768);
843 string = "Object size: " + to_string(editorsize);
844 text->glPrint(10, 75, string, 0, .8, 1024, 768);
845 if (editoryaw >= 0) {
846 string = "Object yaw: " + to_string(editoryaw);
848 string = "Object yaw: Random";
850 text->glPrint(10, 90, string, 0, .8, 1024, 768);
851 if (editorpitch >= 0) {
852 string = "Object pitch: " + to_string(editorpitch);
854 string = "Object pitch: Random";
856 text->glPrint(10, 105, string, 0, .8, 1024, 768);
857 string = "Object type: " + to_string(editortype);
858 text->glPrint(10, 120, string, 0, .8, 1024, 768);
859 switch (editortype) {
885 string = "(chimney)";
888 string = "(platform)";
897 text->glPrint(130, 120, string, 0, .8, 1024, 768);
899 string = "Numplayers: " + to_string(Person::players.size());
900 text->glPrint(10, 155, string, 0, .8, 1024, 768);
901 string = "Player " + to_string(int(Person::players.size()) - 1) + ": numwaypoints: " + to_string(Person::players.back()->numwaypoints);
902 text->glPrint(10, 140, string, 0, .8, 1024, 768);
904 string = "Difficulty: " + to_string(difficulty);
905 text->glPrint(10, 240, string, 0, .8, 1024, 768);
909 if (drawmode == glowmode) {
910 glDisable(GL_DEPTH_TEST);
911 glDisable(GL_CULL_FACE);
912 glDisable(GL_LIGHTING);
913 glDisable(GL_TEXTURE_2D);
915 glMatrixMode(GL_PROJECTION);
918 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
919 glMatrixMode(GL_MODELVIEW);
922 glScalef(screenwidth, screenheight, 1);
923 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
925 glColor4f(0, 0, 0, .5);
927 glVertex3f(0, 0, 0.0f);
928 glVertex3f(256, 0, 0.0f);
929 glVertex3f(256, 256, 0.0f);
930 glVertex3f(0, 256, 0.0f);
932 glMatrixMode(GL_PROJECTION);
934 glMatrixMode(GL_MODELVIEW);
936 glEnable(GL_DEPTH_TEST);
937 glEnable(GL_CULL_FACE);
942 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
943 glDisable(GL_DEPTH_TEST);
944 glDisable(GL_CULL_FACE);
945 glDisable(GL_LIGHTING);
946 glDisable(GL_TEXTURE_2D);
948 glMatrixMode(GL_PROJECTION);
951 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
952 glMatrixMode(GL_MODELVIEW);
955 glScalef(screenwidth, screenheight, 1);
956 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
958 if (Person::players[0]->dead)
959 blackout += multiplier * 3;
960 if (Person::players[0]->dead == 1)
962 if (Person::players[0]->dead == 2 && blackout > .6)
964 glColor4f(0, 0, 0, blackout);
965 if (!Person::players[0]->dead) {
966 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)) * .3 < .3) {
967 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3);
968 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
970 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
971 blackout = Person::players[0]->blooddimamount * .3;
975 glColor4f(.7, 0, 0, .2);
977 glVertex3f(0, 0, 0.0f);
978 glVertex3f(256, 0, 0.0f);
979 glVertex3f(256, 256, 0.0f);
980 glVertex3f(0, 256, 0.0f);
982 glMatrixMode(GL_PROJECTION);
984 glMatrixMode(GL_MODELVIEW);
986 glEnable(GL_DEPTH_TEST);
987 glEnable(GL_CULL_FACE);
992 if (flashamount > 0 && damageeffects) {
996 flashamount -= multiplier;
1000 glDisable(GL_DEPTH_TEST);
1001 glDisable(GL_CULL_FACE);
1002 glDisable(GL_LIGHTING);
1004 glMatrixMode(GL_PROJECTION);
1007 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1008 glMatrixMode(GL_MODELVIEW);
1011 glScalef(screenwidth, screenheight, 1);
1012 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1014 glColor4f(flashr, flashg, flashb, flashamount);
1016 glVertex3f(0, 0, 0.0f);
1017 glVertex3f(256, 0, 0.0f);
1018 glVertex3f(256, 256, 0.0f);
1019 glVertex3f(0, 256, 0.0f);
1021 glMatrixMode(GL_PROJECTION);
1023 glMatrixMode(GL_MODELVIEW);
1025 glEnable(GL_DEPTH_TEST);
1026 glEnable(GL_CULL_FACE);
1027 glDisable(GL_BLEND);
1031 if (difficulty < 2 && !Dialog::inDialog()) { // minimap
1032 float mapviewdist = 20000;
1034 glDisable(GL_DEPTH_TEST);
1035 glColor3f(1.0, 1.0, 1.0); // no coloring
1037 glEnable(GL_TEXTURE_2D);
1038 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1039 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1040 glDisable(GL_DEPTH_TEST);
1041 glDisable(GL_CULL_FACE);
1042 glDisable(GL_LIGHTING);
1044 glMatrixMode(GL_PROJECTION);
1047 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1048 glMatrixMode(GL_MODELVIEW);
1051 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1052 glTranslatef(1.75, .25, 0);
1053 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1055 glColor4f(1, 1, 1, 1);
1062 center = Person::players[0]->coords;
1066 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1068 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1070 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1071 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1072 for (unsigned int i = 0; i < Object::objects.size(); i++) {
1073 if (Object::objects[i]->type == treetrunktype) {
1074 distcheck = distsq(&Person::players[0]->coords, &Object::objects[i]->position);
1075 if (distcheck < mapviewdist) {
1076 Mapcircletexture.bind();
1077 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1079 glTranslatef(Object::objects[i]->position.x / terrain.scale / 256 * -2 + 1, Object::objects[i]->position.z / terrain.scale / 256 * 2 - 1, 0);
1080 glRotatef(Object::objects[i]->yaw, 0, 0, 1);
1081 glScalef(.003, .003, .003);
1084 glVertex3f(-1, -1, 0.0f);
1086 glVertex3f(1, -1, 0.0f);
1088 glVertex3f(1, 1, 0.0f);
1090 glVertex3f(-1, 1, 0.0f);
1095 if (Object::objects[i]->type == boxtype) {
1096 distcheck = distsq(&Person::players[0]->coords, &Object::objects[i]->position);
1097 if (distcheck < mapviewdist) {
1098 Mapboxtexture.bind();
1099 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1101 glTranslatef(Object::objects[i]->position.x / terrain.scale / 256 * -2 + 1, Object::objects[i]->position.z / terrain.scale / 256 * 2 - 1, 0);
1102 glRotatef(Object::objects[i]->yaw, 0, 0, 1);
1103 glScalef(.01 * Object::objects[i]->scale, .01 * Object::objects[i]->scale, .01 * Object::objects[i]->scale);
1106 glVertex3f(-1, -1, 0.0f);
1108 glVertex3f(1, -1, 0.0f);
1110 glVertex3f(1, 1, 0.0f);
1112 glVertex3f(-1, 1, 0.0f);
1118 if (editorenabled) {
1119 Mapcircletexture.bind();
1120 for (int i = 0; i < numboundaries; i++) {
1121 glColor4f(0, 0, 0, opac / 3);
1123 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1124 glScalef(.002, .002, .002);
1127 glVertex3f(-1, -1, 0.0f);
1129 glVertex3f(1, -1, 0.0f);
1131 glVertex3f(1, 1, 0.0f);
1133 glVertex3f(-1, 1, 0.0f);
1138 for (unsigned i = 0; i < Person::players.size(); i++) {
1139 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1140 if (distcheck < mapviewdist) {
1142 Maparrowtexture.bind();
1144 glColor4f(1, 1, 1, opac);
1145 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1146 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1147 else if (Person::players[i]->dead)
1148 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1149 else if (Person::players[i]->aitype == attacktypecutoff)
1150 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1151 else if (Person::players[i]->aitype == passivetype)
1152 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1154 glColor4f(1, 1, 0, 1);
1155 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1156 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1157 glScalef(.005, .005, .005);
1160 glVertex3f(-1, -1, 0.0f);
1162 glVertex3f(1, -1, 0.0f);
1164 glVertex3f(1, 1, 0.0f);
1166 glVertex3f(-1, 1, 0.0f);
1172 glDisable(GL_TEXTURE_2D);
1173 glMatrixMode(GL_PROJECTION);
1175 glMatrixMode(GL_MODELVIEW);
1177 glEnable(GL_DEPTH_TEST);
1178 glEnable(GL_CULL_FACE);
1179 glDisable(GL_BLEND);
1183 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1184 glDisable(GL_DEPTH_TEST);
1185 glDisable(GL_CULL_FACE);
1186 glDisable(GL_LIGHTING);
1187 glDisable(GL_TEXTURE_2D);
1189 glMatrixMode(GL_PROJECTION);
1192 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1193 glMatrixMode(GL_MODELVIEW);
1196 glScalef(screenwidth, screenheight, 1);
1197 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1199 glColor4f(0, 0, 0, .7);
1201 glVertex3f(0, 0, 0.0f);
1202 glVertex3f(256, 0, 0.0f);
1203 glVertex3f(256, 256, 0.0f);
1204 glVertex3f(0, 256, 0.0f);
1206 glMatrixMode(GL_PROJECTION);
1208 glMatrixMode(GL_MODELVIEW);
1210 glEnable(GL_DEPTH_TEST);
1211 glEnable(GL_CULL_FACE);
1212 glDisable(GL_BLEND);
1216 glDisable(GL_DEPTH_TEST);
1217 glColor3f(1.0, 1.0, 1.0); // no coloring
1219 glEnable(GL_TEXTURE_2D);
1224 glEnable(GL_TEXTURE_2D);
1225 glColor4f(1, 1, 1, 1);
1226 string = "Loading...";
1227 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1230 drawmode = normalmode;
1233 if (winfreeze && !campaign) {
1234 glDisable(GL_DEPTH_TEST);
1235 glDisable(GL_CULL_FACE);
1236 glDisable(GL_LIGHTING);
1237 glDisable(GL_TEXTURE_2D);
1239 glMatrixMode(GL_PROJECTION);
1242 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1243 glMatrixMode(GL_MODELVIEW);
1246 glScalef(screenwidth, screenheight, 1);
1247 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1249 glColor4f(0, 0, 0, .4);
1251 glVertex3f(0, 0, 0.0f);
1252 glVertex3f(256, 0, 0.0f);
1253 glVertex3f(256, 256, 0.0f);
1254 glVertex3f(0, 256, 0.0f);
1256 glMatrixMode(GL_PROJECTION);
1258 glMatrixMode(GL_MODELVIEW);
1260 glEnable(GL_DEPTH_TEST);
1261 glEnable(GL_CULL_FACE);
1262 glDisable(GL_BLEND);
1266 glDisable(GL_DEPTH_TEST);
1267 glColor3f(1.0, 1.0, 1.0); // no coloring
1269 glEnable(GL_TEXTURE_2D);
1271 //Win Screen Won Victory
1273 glEnable(GL_TEXTURE_2D);
1274 glColor4f(1, 1, 1, 1);
1275 string = "Level Cleared!";
1276 text->glPrintOutlined(1024 / 2 - string.size() * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1278 string = "Score: " + to_string(int(bonustotal - startbonustotal));
1279 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1281 string = "Press Escape to return to menu or Space to continue";
1282 text->glPrintOutlined(640 / 2 - string.size() * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1284 int wontime = (int)round(wonleveltime);
1285 string = "Time: " + to_string(int((wontime - wontime % 60) / 60));
1286 if (wontime % 60 < 10) {
1289 string += to_string(int(wontime % 60));
1290 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1293 int awards[award_count];
1294 int numawards = award_awards(awards);
1296 for (int i = 0; i < numawards && i < 6; i++)
1297 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1300 if (drawmode != normalmode) {
1301 glEnable(GL_TEXTURE_2D);
1303 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1304 if (screentexture) {
1306 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
1307 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1308 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1309 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
1310 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
1311 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
1313 glBindTexture(GL_TEXTURE_2D, screentexture);
1314 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1317 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1318 if (screentexture2) {
1319 glBindTexture(GL_TEXTURE_2D, screentexture2);
1320 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1322 if (!screentexture2) {
1323 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1325 glGenTextures(1, &screentexture2);
1326 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1328 glEnable(GL_TEXTURE_2D);
1329 glBindTexture(GL_TEXTURE_2D, screentexture2);
1330 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1331 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1333 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1338 glClear(GL_DEPTH_BUFFER_BIT);
1339 Game::ReSizeGLScene(90, .1f);
1340 glViewport(0, 0, screenwidth, screenheight);
1342 if (drawmode != normalmode) {
1343 glDisable(GL_DEPTH_TEST);
1344 if (drawmode == motionblurmode) {
1345 glDrawBuffer(GL_FRONT);
1346 glReadBuffer(GL_BACK);
1348 glColor3f(1.0, 1.0, 1.0); // no coloring
1350 glEnable(GL_TEXTURE_2D);
1351 glBindTexture(GL_TEXTURE_2D, screentexture);
1352 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1353 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1354 glDisable(GL_DEPTH_TEST);
1355 glDisable(GL_CULL_FACE);
1356 glDisable(GL_LIGHTING);
1358 glMatrixMode(GL_PROJECTION);
1361 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1362 glMatrixMode(GL_MODELVIEW);
1365 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1366 glTranslatef(1, 1, 0);
1367 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1369 if (drawmode == motionblurmode) {
1370 if (motionbluramount < .2)
1371 motionbluramount = .2;
1372 glColor4f(1, 1, 1, motionbluramount);
1376 glVertex3f(-1, -1, 0.0f);
1377 glTexCoord2f(texcoordwidth, 0);
1378 glVertex3f(1, -1, 0.0f);
1379 glTexCoord2f(texcoordwidth, texcoordheight);
1380 glVertex3f(1, 1, 0.0f);
1381 glTexCoord2f(0, texcoordheight);
1382 glVertex3f(-1, 1, 0.0f);
1386 if (drawmode == realmotionblurmode) {
1387 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1388 glClear(GL_COLOR_BUFFER_BIT);
1389 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1390 glBindTexture(GL_TEXTURE_2D, screentexture);
1391 glColor4f(1, 1, 1, .5);
1395 glVertex3f(-1, -1, 0.0f);
1396 glTexCoord2f(texcoordwidth, 0);
1397 glVertex3f(1, -1, 0.0f);
1398 glTexCoord2f(texcoordwidth, texcoordheight);
1399 glVertex3f(1, 1, 0.0f);
1400 glTexCoord2f(0, texcoordheight);
1401 glVertex3f(-1, 1, 0.0f);
1404 glBindTexture(GL_TEXTURE_2D, screentexture2);
1405 glColor4f(1, 1, 1, .5);
1409 glVertex3f(-1, -1, 0.0f);
1410 glTexCoord2f(texcoordwidth, 0);
1411 glVertex3f(1, -1, 0.0f);
1412 glTexCoord2f(texcoordwidth, texcoordheight);
1413 glVertex3f(1, 1, 0.0f);
1414 glTexCoord2f(0, texcoordheight);
1415 glVertex3f(-1, 1, 0.0f);
1418 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1420 if (drawmode == doublevisionmode) {
1421 static float crosseyedness;
1422 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1423 if (crosseyedness > 1)
1425 if (crosseyedness < 0)
1427 glColor4f(1, 1, 1, 1);
1428 glDisable(GL_BLEND);
1433 glVertex3f(-1, -1, 0.0f);
1434 glTexCoord2f(texcoordwidth, 0);
1435 glVertex3f(1, -1, 0.0f);
1436 glTexCoord2f(texcoordwidth, texcoordheight);
1437 glVertex3f(1, 1, 0.0f);
1438 glTexCoord2f(0, texcoordheight);
1439 glVertex3f(-1, 1, 0.0f);
1442 if (crosseyedness) {
1443 glColor4f(1, 1, 1, .5);
1446 glTranslatef(.015 * crosseyedness, 0, 0);
1450 glVertex3f(-1, -1, 0.0f);
1451 glTexCoord2f(texcoordwidth, 0);
1452 glVertex3f(1, -1, 0.0f);
1453 glTexCoord2f(texcoordwidth, texcoordheight);
1454 glVertex3f(1, 1, 0.0f);
1455 glTexCoord2f(0, texcoordheight);
1456 glVertex3f(-1, 1, 0.0f);
1461 if (drawmode == glowmode) {
1462 glColor4f(.5, .5, .5, .5);
1464 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1466 glTranslatef(.01, 0, 0);
1469 glVertex3f(-1, -1, 0.0f);
1470 glTexCoord2f(texcoordwidth, 0);
1471 glVertex3f(1, -1, 0.0f);
1472 glTexCoord2f(texcoordwidth, texcoordheight);
1473 glVertex3f(1, 1, 0.0f);
1474 glTexCoord2f(0, texcoordheight);
1475 glVertex3f(-1, 1, 0.0f);
1479 glTranslatef(-.01, 0, 0);
1482 glVertex3f(-1, -1, 0.0f);
1483 glTexCoord2f(texcoordwidth, 0);
1484 glVertex3f(1, -1, 0.0f);
1485 glTexCoord2f(texcoordwidth, texcoordheight);
1486 glVertex3f(1, 1, 0.0f);
1487 glTexCoord2f(0, texcoordheight);
1488 glVertex3f(-1, 1, 0.0f);
1492 glTranslatef(.0, .01, 0);
1495 glVertex3f(-1, -1, 0.0f);
1496 glTexCoord2f(texcoordwidth, 0);
1497 glVertex3f(1, -1, 0.0f);
1498 glTexCoord2f(texcoordwidth, texcoordheight);
1499 glVertex3f(1, 1, 0.0f);
1500 glTexCoord2f(0, texcoordheight);
1501 glVertex3f(-1, 1, 0.0f);
1505 glTranslatef(0, -.01, 0);
1508 glVertex3f(-1, -1, 0.0f);
1509 glTexCoord2f(texcoordwidth, 0);
1510 glVertex3f(1, -1, 0.0f);
1511 glTexCoord2f(texcoordwidth, texcoordheight);
1512 glVertex3f(1, 1, 0.0f);
1513 glTexCoord2f(0, texcoordheight);
1514 glVertex3f(-1, 1, 0.0f);
1518 if (drawmode == radialzoommode) {
1519 for (int i = 0; i < 3; i++) {
1520 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1522 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1525 glVertex3f(-1, -1, 0.0f);
1526 glTexCoord2f(texcoordwidth, 0);
1527 glVertex3f(1, -1, 0.0f);
1528 glTexCoord2f(texcoordwidth, texcoordheight);
1529 glVertex3f(1, 1, 0.0f);
1530 glTexCoord2f(0, texcoordheight);
1531 glVertex3f(-1, 1, 0.0f);
1536 glDisable(GL_TEXTURE_2D);
1537 glMatrixMode(GL_PROJECTION);
1539 glMatrixMode(GL_MODELVIEW);
1541 glEnable(GL_DEPTH_TEST);
1542 glEnable(GL_CULL_FACE);
1543 glDisable(GL_BLEND);
1548 glEnable(GL_TEXTURE_2D);
1549 glColor4f(1, 1, 1, 1);
1551 if (consoleselected >= 60)
1552 offset = consoleselected - 60;
1553 textmono->glPrint(10, 30, " ]", 0, 1, 1024, 768);
1555 textmono->glPrint(30 + (float)consoleselected * 10 - offset * 10, 30, "_", 0, 1, 1024, 768);
1557 for (unsigned i = 0; i < 15; i++) {
1558 textmono->glPrint(30 - offset * 10, 30 + i * 20, consoletext[i], 0, 1, 1024, 768);
1563 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1564 multiplier = tempmult;
1571 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1572 tempmult = multiplier;
1576 if (side == stereoRight || side == stereoCenter) {
1577 if (drawmode != motionblurmode || mainmenu) {
1582 glDrawBuffer(GL_BACK);
1583 glReadBuffer(GL_BACK);
1587 if (drawtoggle == 2)
1590 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1591 multiplier = tempmult;
1593 //Jordan fixed your warning!
1599 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1602 glDrawBuffer(GL_BACK);
1603 glReadBuffer(GL_BACK);
1604 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1605 Game::ReSizeGLScene(90, .1f);
1607 //draw menu background
1608 glClear(GL_DEPTH_BUFFER_BIT);
1609 glEnable(GL_ALPHA_TEST);
1610 glAlphaFunc(GL_GREATER, 0.001f);
1611 glEnable(GL_TEXTURE_2D);
1612 glDisable(GL_DEPTH_TEST);
1613 glDisable(GL_CULL_FACE);
1614 glDisable(GL_LIGHTING);
1616 glMatrixMode(GL_PROJECTION);
1619 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1620 glMatrixMode(GL_MODELVIEW);
1623 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1625 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1626 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1627 glDisable(GL_BLEND);
1628 glColor4f(0, 0, 0, 1.0);
1629 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1630 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1631 glDisable(GL_TEXTURE_2D);
1633 glVertex3f(-1, -1, 0);
1634 glVertex3f(+1, -1, 0);
1635 glVertex3f(+1, +1, 0);
1636 glVertex3f(-1, +1, 0);
1639 glColor4f(0.4, 0.4, 0.4, 1.0);
1640 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1641 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1642 glEnable(GL_TEXTURE_2D);
1643 Game::Mainmenuitems[4].bind();
1646 glVertex3f(-1, -1, 0);
1648 glVertex3f(+1, -1, 0);
1650 glVertex3f(+1, +1, 0);
1652 glVertex3f(-1, +1, 0);
1656 glMatrixMode(GL_PROJECTION);
1658 glMatrixMode(GL_MODELVIEW);
1660 glMatrixMode(GL_PROJECTION);
1663 glOrtho(0, 640, 0, 480, -100, 100);
1664 glMatrixMode(GL_MODELVIEW);
1667 glEnable(GL_TEXTURE_2D);
1672 glMatrixMode(GL_PROJECTION);
1674 glMatrixMode(GL_MODELVIEW);
1677 glMatrixMode(GL_PROJECTION);
1680 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1681 glMatrixMode(GL_MODELVIEW);
1684 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1686 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1687 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1689 glEnable(GL_TEXTURE_2D);
1690 glColor4f(1, 1, 1, 1);
1691 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1692 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1694 if (!Game::waiting) { // hide the cursor while waiting for a key
1696 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
1697 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
1698 glTranslatef(1, -1, 0);
1699 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1700 glColor4f(1, 1, 1, 1);
1701 Game::cursortexture.bind();
1705 glVertex3f(-1, -1, 0.0f);
1707 glVertex3f(1, -1, 0.0f);
1709 glVertex3f(1, 1, 0.0f);
1711 glVertex3f(-1, 1, 0.0f);
1717 glMatrixMode(GL_PROJECTION);
1721 if (flashamount > 0) {
1722 if (flashamount > 1)
1724 if (flashdelay <= 0)
1725 flashamount -= multiplier;
1727 if (flashamount < 0)
1729 glDisable(GL_DEPTH_TEST);
1730 glDisable(GL_CULL_FACE);
1731 glDisable(GL_LIGHTING);
1732 glDisable(GL_TEXTURE_2D);
1734 glMatrixMode(GL_PROJECTION);
1737 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1738 glMatrixMode(GL_MODELVIEW);
1741 glScalef(screenwidth, screenheight, 1);
1742 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1744 glColor4f(flashr, flashg, flashb, flashamount);
1746 glVertex3f(0, 0, 0.0f);
1747 glVertex3f(256, 0, 0.0f);
1748 glVertex3f(256, 256, 0.0f);
1749 glVertex3f(0, 256, 0.0f);
1751 glMatrixMode(GL_PROJECTION);
1753 glMatrixMode(GL_MODELVIEW);
1755 glEnable(GL_DEPTH_TEST);
1756 glEnable(GL_CULL_FACE);
1757 glDisable(GL_BLEND);