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 "Utils/Input.hpp"
31 extern int environment;
32 extern float texscale;
34 extern Terrain terrain;
35 extern float multiplier;
36 extern float viewdistance;
37 extern float fadestart;
38 extern float screenwidth, screenheight;
39 extern int kTextureSize;
40 extern FRUSTUM frustum;
43 extern float usermousesensitivity;
44 extern float camerashake;
46 extern float slomodelay;
47 extern bool ismotionblur;
49 extern float blackout;
50 extern bool damageeffects;
52 extern bool texttoggle;
53 extern float blurness;
54 extern float targetblurness;
55 extern float playerdist;
56 extern bool cellophane;
58 extern float flashamount, flashr, flashg, flashb;
59 extern int flashdelay;
61 extern float motionbluramount;
63 extern bool alwaysblur;
64 extern bool velocityblur;
67 extern int bloodtoggle;
68 extern int difficulty;
70 extern float texdetail;
71 extern bool musictoggle;
72 extern int tutoriallevel;
73 extern float smoketex;
74 extern float tutorialstagetime;
75 extern float tutorialmaxtime;
76 extern int tutorialstage;
77 extern bool againbonus;
78 extern float damagedealt;
79 extern bool invertmouse;
82 extern bool winfreeze;
84 extern bool gamestart;
86 extern bool gamestarted;
88 extern bool showdamagebar;
93 int numboundaries = 0;
100 normalmode, motionblurmode, radialzoommode,
101 realmotionblurmode, doublevisionmode, glowmode,
104 void Game::flash(float amount, int delay) // shouldn't be that way, these should be attributes and Person class should not change rendering.
109 flashamount = amount;
115 /*********************> DrawGLScene() <*****/
116 int Game::DrawGLScene(StereoSide side)
118 static float texcoordwidth, texcoordheight;
119 static float texviewwidth, texviewheight;
121 static XYZ checkpoint;
122 static float tempmult;
127 static int drawmode = 0;
129 if ( stereomode == stereoAnaglyph ) {
132 glColorMask( 0.0, 1.0, 1.0, 1.0 );
135 glColorMask( 1.0, 0.0, 0.0, 1.0 );
141 glColorMask( 1.0, 1.0, 1.0, 1.0 );
143 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
144 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
148 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
149 tempmult = multiplier;
155 numboundaries = mapradius * 2;
156 if (numboundaries > 360)
158 for (int i = 0; i < numboundaries; i++) {
161 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
170 int olddrawmode = drawmode;
171 if (ismotionblur && !loading) {
172 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
173 drawmode = motionblurmode;
174 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
177 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
178 drawmode = doublevisionmode;
183 if (slomo && !loading) {
185 drawmode = motionblurmode;
186 motionbluramount = .2;
187 slomodelay -= multiplier;
193 if ((!changed && !slomo) || loading) {
194 drawmode = normalmode;
195 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
196 if (olddrawmode != realmotionblurmode)
200 drawmode = realmotionblurmode;
201 } else if (olddrawmode == realmotionblurmode)
207 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
208 drawmode = normalmode;
209 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
210 drawmode = radialzoommode;
212 if (winfreeze || mainmenu)
213 drawmode = normalmode;
216 drawtoggle = 1 - drawtoggle;
218 if (!texcoordwidth) {
219 texviewwidth = kTextureSize;
220 if (texviewwidth > screenwidth)
221 texviewwidth = screenwidth;
222 texviewheight = kTextureSize;
223 if (texviewheight > screenheight)
224 texviewheight = screenheight;
226 texcoordwidth = screenwidth / kTextureSize;
227 texcoordheight = screenheight / kTextureSize;
228 if (texcoordwidth > 1)
230 if (texcoordheight > 1)
234 glDrawBuffer(GL_BACK);
235 glReadBuffer(GL_BACK);
237 static XYZ terrainlight;
238 static float distance;
239 if (drawmode == normalmode) {
240 Game::ReSizeGLScene(90, .1f);
242 glViewport(0, 0, texviewwidth, texviewheight);
244 glDepthFunc(GL_LEQUAL);
246 glAlphaFunc(GL_GREATER, 0.0001f);
247 glEnable(GL_ALPHA_TEST);
248 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
249 glClear(GL_DEPTH_BUFFER_BIT);
251 glMatrixMode (GL_MODELVIEW);
252 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
255 // Move the camera for the current eye's point of view.
256 // Reverse the movement if we're reversing stereo
257 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
260 if (!cameramode && !freeze && !winfreeze) {
262 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
264 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
265 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
267 if (cameramode || freeze || winfreeze) {
268 glRotatef(pitch, 1, 0, 0);
269 glRotatef(yaw, 0, 1, 0);
272 if (environment == desertenvironment) {
273 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
274 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
276 SetUpLight(&light, 0);
279 //heat blur effect in desert
280 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
281 blurness = targetblurness;
282 targetblurness = (float)(abs(Random() % 100)) / 40;
284 if (blurness < targetblurness)
285 blurness += multiplier * 5;
287 blurness -= multiplier * 5;
289 if (environment == desertenvironment) {
291 glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, blurness + .4 );
293 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
294 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
297 glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0);
299 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
300 frustum.GetFrustum();
302 //make shadow decals on terrain and Object::objects
304 static float size, opacity, rotation;
306 for (unsigned k = 0; k < Person::players.size(); k++) {
307 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
308 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)
309 for (unsigned i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
310 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) {
311 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
313 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;
314 if (k != 0 && tutoriallevel == 1) {
315 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;
317 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
318 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
319 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
320 if (Object::objects[j]->position.y < Person::players[k]->coords.y || Object::objects[j]->type == tunneltype || Object::objects[j]->type == weirdtype) {
321 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);
324 if (k != 0 && tutoriallevel == 1) {
325 opacity = .2 + .2 * sin(smoketex * 6 + i);
327 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
332 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
333 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)
334 for (unsigned i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
335 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) {
336 if (Person::players[k]->skeleton.free)
337 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
339 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
341 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;
342 if (k != 0 && tutoriallevel == 1) {
343 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;
345 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
346 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
347 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
348 if (Object::objects[j]->position.y < Person::players[k]->coords.y || Object::objects[j]->type == tunneltype || Object::objects[j]->type == weirdtype) {
349 if (Person::players[k]->skeleton.free)
350 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);
352 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);
355 if (k != 0 && tutoriallevel == 1) {
356 opacity = .2 + .2 * sin(smoketex * 6 + i);
358 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
364 if (!Person::players[k]->playerdetail)
365 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
366 point = Person::players[k]->coords;
368 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
369 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
370 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
371 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
372 point = DoRotation(Person::players[k]->coords - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
375 Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
381 glEnable(GL_TEXTURE_2D);
383 glEnable(GL_DEPTH_TEST);
384 glEnable(GL_CULL_FACE);
386 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
387 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
388 terraintexture.bind();
390 terraintexture2.bind();
393 terrain.drawdecals();
396 glEnable(GL_CULL_FACE);
397 glEnable(GL_LIGHTING);
399 glEnable(GL_TEXTURE_2D);
402 glEnable(GL_COLOR_MATERIAL);
405 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
406 glEnable(GL_CULL_FACE);
407 glCullFace(GL_FRONT);
409 for (unsigned k = 0; k < Person::players.size(); k++) {
410 if (k == 0 || tutoriallevel != 1) {
412 glEnable(GL_LIGHTING);
413 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
414 distance = distsq(&viewer, &Person::players[k]->coords);
415 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
416 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
419 if (distance >= .5) {
420 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;
423 if (Person::players[k]->occluded != 0)
424 i = Object::checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
426 i = Object::checkcollide(viewer, checkpoint);
428 Person::players[k]->occluded += 1;
429 Person::players[k]->lastoccluded = i;
431 Person::players[k]->occluded = 0;
433 if (Person::players[k]->occluded < 25)
434 Person::players[k]->DrawSkeleton();
440 if (!cameramode && musictype == stream_fighttheme)
441 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
446 glEnable(GL_TEXTURE_2D);
452 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
453 glAlphaFunc(GL_GREATER, 0.0001f);
455 glDisable(GL_CULL_FACE);
456 glDisable(GL_LIGHTING);
458 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
459 glRotatef(hawkyaw, 0, 1, 0);
460 glTranslatef(25, 0, 0);
461 distance = distsq(&viewer, &realhawkcoords) * 1.2;
462 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
463 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
464 glColor4f(light.color[0], light.color[1], light.color[2], 1);
465 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
466 hawk.drawdifftex(hawktexture);
470 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
471 glEnable(GL_CULL_FACE);
472 glCullFace(GL_FRONT);
474 for (unsigned k = 0; k < Person::players.size(); k++) {
475 if (!(k == 0 || tutoriallevel != 1)) {
477 glEnable(GL_LIGHTING);
478 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
479 distance = distsq(&viewer, &Person::players[k]->coords);
480 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
481 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
484 if (distance >= .5) {
485 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;
488 if (Person::players[k]->occluded != 0) {
489 i = Object::checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
492 i = Object::checkcollide(viewer, checkpoint);
495 Person::players[k]->occluded += 1;
496 Person::players[k]->lastoccluded = i;
498 Person::players[k]->occluded = 0;
500 if (Person::players[k]->occluded < 25) {
501 Person::players[k]->DrawSkeleton();
508 glEnable(GL_TEXTURE_2D);
513 glDisable(GL_COLOR_MATERIAL);
515 glDisable(GL_LIGHTING);
516 glDisable(GL_TEXTURE_2D);
522 //waypoints, pathpoints in editor
525 glDisable(GL_LIGHTING);
526 glDisable(GL_TEXTURE_2D);
527 glDisable(GL_COLOR_MATERIAL);
528 glColor4f(1, 1, 0, 1);
530 for (unsigned k = 0; k < Person::players.size(); k++) {
531 if (Person::players[k]->numwaypoints > 1) {
532 glBegin(GL_LINE_LOOP);
533 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
534 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
541 if (numpathpoints > 1) {
542 glColor4f(0, 1, 0, 1);
543 for (unsigned k = 0; int(k) < numpathpoints; k++) {
544 if (numpathpointconnect[k]) {
545 for (int i = 0; i < numpathpointconnect[k]; i++) {
546 glBegin(GL_LINE_LOOP);
547 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
548 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
553 glColor4f(1, 1, 1, 1);
556 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
563 glEnable(GL_TEXTURE_2D);
564 glColor4f(.5, .5, .5, 1);
567 if (bonus > 0 && bonustime < 1 && !winfreeze && !Dialog::inDialog()) {
568 const char *bonus_name;
569 if (bonus < bonus_count)
570 bonus_name = bonus_names[bonus];
572 bonus_name = "Excellent!"; // When does this happen?
574 text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
576 string = to_string((int)bonusvalue);
577 text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * string.size(), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
579 glColor4f(.5, .5, .5, 1);
582 if (tutoriallevel == 1) {
583 tutorialopac = tutorialmaxtime - tutorialstagetime;
584 if (tutorialopac > 1)
586 if (tutorialopac < 0)
592 if (tutorialstage == 0) {
597 if (tutorialstage == 1) {
598 string = "Welcome to the Lugaru training level!";
602 if (tutorialstage == 2) {
603 string = "BASIC MOVEMENT:";
607 if (tutorialstage == 3) {
608 string = "You can move the mouse to rotate the camera.";
612 if (tutorialstage == 4) {
613 string = std::string("Try using the ") +
614 Input::keyToChar(forwardkey) + ", " +
615 Input::keyToChar(leftkey) + ", " +
616 Input::keyToChar(backkey) + " and " +
617 Input::keyToChar(rightkey) + " keys to move around.";
618 string2 = "All movement is relative to the camera.";
621 if (tutorialstage == 5) {
622 string = std::string("Please press ") + Input::keyToChar(jumpkey) + " to jump.";
623 string2 = "You can hold it longer to jump higher.";
626 if (tutorialstage == 6) {
627 string = std::string("You can press ") + Input::keyToChar(crouchkey) + " to crouch.";
628 string2 = "You can jump higher from a crouching position.";
631 if (tutorialstage == 7) {
632 string = std::string("While running, you can press ") + Input::keyToChar(crouchkey) + " to roll.";
636 if (tutorialstage == 8) {
637 string = "While crouching, you can sneak around silently";
638 string2 = "using the movement keys.";
641 if (tutorialstage == 9) {
642 string = "Release the crouch key while sneaking and hold the movement keys";
643 string2 = "to run animal-style.";
646 if (tutorialstage == 10) {
647 string = "ADVANCED MOVEMENT:";
651 if (tutorialstage == 11) {
652 string = std::string("When you jump at a wall, you can hold ") + Input::keyToChar(jumpkey) + " again";
653 string2 = "during impact to perform a walljump.";
654 string3 = "Be sure to use the movement keys to press against the wall";
656 if (tutorialstage == 12) {
657 string = "While in the air, you can press crouch to flip.";
658 string2 = "Walljumps and flips confuse enemies and give you more control.";
661 if (tutorialstage == 13) {
662 string = "BASIC COMBAT:";
666 if (tutorialstage == 14) {
667 string = "There is now an imaginary enemy";
668 string2 = "in the middle of the training area.";
671 if (tutorialstage == 15) {
672 if (attackkey == MOUSEBUTTON1) {
673 string = "Click to attack when you are near an enemy.";
675 string = std::string("Press ") + Input::keyToChar(attackkey) + " to attack when you are near an enemy.";
677 string2 = "You can punch by standing still near an enemy and attacking.";
680 if (tutorialstage == 16) {
681 string = "If you are close, you will perform a weak punch.";
682 string2 = "The weak punch is excellent for starting attack combinations.";
685 if (tutorialstage == 17) {
686 string = "Attacking while running results in a spin kick.";
687 string2 = "This is one of your most powerful ground attacks.";
690 if (tutorialstage == 18) {
691 string = "Sweep the enemy's legs out by attacking while crouched.";
692 string2 = "This is a very fast attack, and easy to follow up.";
695 if (tutorialstage == 19) {
696 string = "When an enemy is on the ground, you can deal some extra";
697 string2 = "damage by running up and drop-kicking him.";
698 string3 = "(Try knocking them down with a sweep first)";
700 if (tutorialstage == 20) {
701 string = "Your most powerful individual attack is the rabbit kick.";
702 if (attackkey == MOUSEBUTTON1) {
703 string2 = "Run at the enemy while holding the mouse button, and press";
705 string2 = std::string("Run at the enemy while holding ") + Input::keyToChar(attackkey) + ", and press";
707 string3 = std::string("the jump key (") + Input::keyToChar(jumpkey) + ") to attack.";
709 if (tutorialstage == 21) {
710 string = "This attack is devastating if timed correctly.";
711 string2 = "Even if timed incorrectly, it will knock the enemy over.";
713 string3 = "Try rabbit-kicking the imaginary enemy again.";
715 string3 = "Try rabbit-kicking the imaginary enemy.";
717 if (tutorialstage == 22) {
718 string = "If you sneak behind an enemy unnoticed, you can kill";
719 string2 = "him instantly. Move close behind this enemy";
720 string3 = "and attack.";
722 if (tutorialstage == 23) {
723 string = "Another important attack is the wall kick. When an enemy";
724 string2 = "is near a wall, perform a walljump nearby and hold";
725 string3 = "the attack key during impact with the wall.";
727 if (tutorialstage == 24) {
728 string = "You can tackle enemies by running at them animal-style";
729 if (attackkey == MOUSEBUTTON1) {
730 string2 = std::string("and pressing jump (") + Input::keyToChar(jumpkey) + ") or attack(mouse button).";
732 string2 = std::string("and pressing jump (") + Input::keyToChar(jumpkey) + ") or attack(" + Input::keyToChar(attackkey) + ").";
734 string3 = "This is especially useful when they are running away.";
736 if (tutorialstage == 25) {
737 string = "Dodge by pressing back and attack. Dodging is essential";
738 string2 = "against enemies with swords or other long weapons.";
741 if (tutorialstage == 26) {
742 string = "REVERSALS AND COUNTER-REVERSALS";
746 if (tutorialstage == 27) {
747 string = "The enemy can now reverse your attacks.";
751 if (tutorialstage == 28) {
752 string = "If you attack, you will notice that the enemy now sometimes";
753 string2 = "catches your attack and uses it against you. Hold";
754 string3 = std::string("crouch (") + Input::keyToChar(crouchkey) + ") after attacking to escape from reversals.";
756 if (tutorialstage == 29) {
757 string = "Try escaping from two more reversals in a row.";
761 if (tutorialstage == 30) {
766 if (tutorialstage == 31) {
767 string = std::string("To reverse an attack, you must tap crouch (") + Input::keyToChar(crouchkey) + ") during the";
768 string2 = "enemy's attack. You must also be close to the enemy;";
769 string3 = "this is especially important against armed opponents.";
771 if (tutorialstage == 32) {
772 string = "The enemy can attack in " + to_string(int(tutorialmaxtime - tutorialstagetime)) + " seconds.";
773 string2 = "This imaginary opponents attacks will be highlighted";
774 string3 = "to make this easier.";
776 if (tutorialstage == 33) {
777 string = "Reverse three enemy attacks!";
781 if (tutorialstage == 34) {
782 string = "Reverse two more enemy attacks!";
786 if (tutorialstage == 35) {
787 string = "Reverse one more enemy attack!";
791 if (tutorialstage == 36) {
792 string = "Excellent!";
796 if (tutorialstage == 37) {
797 string = "Now spar with the enemy for " + to_string(int(tutorialmaxtime - tutorialstagetime)) + " more seconds.";
798 string2 = "Damage dealt: " + to_string(int(damagedealt));
799 string3 = "Damage taken: " + to_string(int(damagetaken));
801 if (tutorialstage == 38) {
806 if (tutorialstage == 39) {
807 string = "There is now an imaginary knife";
808 string2 = "in the center of the training area.";
811 if (tutorialstage == 40) {
812 string = "Stand, roll or handspring over the knife";
813 string2 = std::string("while pressing ") + Input::keyToChar(throwkey) + " to pick it up.";
814 string3 = "You can crouch and press the same key to drop it again.";
816 if (tutorialstage == 41) {
817 string = std::string("You can equip and unequip weapons using the ") + Input::keyToChar(drawkey) + " key.";
818 string2 = "Sometimes it is best to keep them unequipped to";
819 string3 = "prevent enemies from taking them. ";
821 if (tutorialstage == 42) {
822 string = "The knife is the smallest weapon and the least encumbering.";
823 string2 = "You can equip or unequip it while standing, crouching,";
824 string3 = "running or flipping.";
826 if (tutorialstage == 43) {
827 string = "You perform weapon attacks the same way as unarmed attacks,";
828 string2 = "but sharp weapons cause permanent damage, instead of the";
829 string3 = "temporary trauma from blunt weapons, fists and feet.";
831 if (tutorialstage == 44) {
832 string = "The enemy now has your knife!";
833 string2 = "Please reverse two of his knife attacks.";
836 if (tutorialstage == 45) {
837 string = "Please reverse one more of his knife attacks.";
841 if (tutorialstage == 46) {
842 string = "Now he has a sword!";
843 string2 = "The sword has longer reach than your arms, so you";
844 string3 = "must move close to reverse the sword slash.";
846 if (tutorialstage == 47) {
847 string = "Long weapons like the sword and staff are also useful for defense;";
848 string2 = "you can parry enemy weapon attacks by pressing the attack key";
849 string3 = "at the right time. Please try parrying the enemy's attacks!";
851 if (tutorialstage == 48) {
852 string = "The staff is like the sword, but has two main attacks.";
853 string2 = "The standing smash is fast and effective, and the running";
854 string3 = "spin smash is slower and more powerful.";
856 if (tutorialstage == 49) {
857 string = std::string("When facing an enemy, you can throw the knife with ") + Input::keyToChar(throwkey) + ".";
858 string2 = "It is possible to throw the knife while flipping,";
859 string3 = "but it is very inaccurate.";
861 if (tutorialstage == 50) {
862 string = "You now know everything you can learn from training.";
863 string2 = "Everything else you must learn from experience!";
866 if (tutorialstage == 51) {
867 string = "Walk out of the training area to return to the main menu.";
872 text->glPrintOutlined(1, 1, 1, tutorialopac, screenwidth / 2 - 7.6 * string.size()*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
873 text->glPrintOutlined(1, 1, 1, tutorialopac, screenwidth / 2 - 7.6 * string2.size()*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024, string2, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
874 text->glPrintOutlined(1, 1, 1, tutorialopac, screenwidth / 2 - 7.6 * string3.size()*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 40 * screenwidth / 1024, string3, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
876 string = "Press 'tab' to skip to the next item.";
877 string2 = "Press escape at any time to";
878 string3 = "pause or exit the tutorial.";
880 text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string.size()*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
881 text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string2.size()*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10 - 20 * .8 * screenwidth / 1024, string2, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
882 text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string3.size()*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10 - 40 * .8 * screenwidth / 1024, string3, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
886 if (Hotspot::hotspots.size() && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
887 float closestdist = -1;
889 int closest = Hotspot::current;
890 for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
891 distance = distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position);
892 if (closestdist == -1 || distance < closestdist) {
893 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))) {
894 closestdist = distance;
900 Hotspot::current = closest;
901 if (Hotspot::hotspots[closest].type <= 10) {
902 if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[closest].position) < Hotspot::hotspots[closest].size)
903 tutorialstagetime = 0;
905 tutorialopac = tutorialmaxtime - tutorialstagetime;
906 if (tutorialopac > 1)
908 if (tutorialopac < 0)
911 string = Hotspot::hotspots[closest].text;
918 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
919 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);
922 if (string[i] == '\0')
929 } else if ((Hotspot::hotspots[closest].type >= 20) && (Dialog::dialogs[Hotspot::hotspots[closest].type - 20].gonethrough == 0)) {
930 Dialog::whichdialogue = Hotspot::hotspots[closest].type - 20;
931 Dialog::currentDialog().play();
932 Dialog::currentDialog().gonethrough++;
937 if (Dialog::inDialog() && !mainmenu) {
938 glDisable(GL_DEPTH_TEST);
939 glDisable(GL_CULL_FACE);
940 glDisable(GL_LIGHTING);
941 glDisable(GL_TEXTURE_2D);
943 glMatrixMode(GL_PROJECTION);
946 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
947 glMatrixMode(GL_MODELVIEW);
950 if (Dialog::currentScene().location == 1)
951 glTranslatef(0, screenheight * 3 / 4, 0);
952 glScalef(screenwidth, screenheight / 4, 1);
953 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
956 glColor4f(Dialog::currentScene().color[0], Dialog::currentScene().color[1], Dialog::currentScene().color[2], 0.7);
958 glVertex3f(0, 0, 0.0f);
959 glVertex3f(1, 0, 0.0f);
960 glVertex3f(1, 1, 0.0f);
961 glVertex3f(0, 1, 0.0f);
963 glMatrixMode(GL_PROJECTION);
965 glMatrixMode(GL_MODELVIEW);
967 glEnable(GL_DEPTH_TEST);
968 glEnable(GL_CULL_FACE);
971 glEnable(GL_TEXTURE_2D);
978 startx = screenwidth * 1 / 5;
979 if (Dialog::currentScene().location == 1) {
980 starty = screenheight / 16 + screenheight * 4 / 5;
982 starty = screenheight * 1 / 5 - screenheight / 16;
985 // FIXME - What is that char[] building for?
988 for (int i = 0; i < 264; i++) {
992 for (unsigned i = 0; i < Dialog::currentScene().name.size(); i++) {
993 tempname[tempnum] = Dialog::currentScene().name[i];
994 if (tempname[tempnum] == '#' || tempname[tempnum] == '\0')
995 tempname[tempnum] = '\0';
1000 string = std::string(tempname) + ": ";
1002 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
1003 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);
1005 glColor4f(0, 0, 0, tutorialopac);
1006 text->glPrintOutline(startx - 2 * 7.6 * string.size()*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1010 for (unsigned i = 0; i < Dialog::currentScene().text.size() + 1; i++) {
1011 tempname[tempnum] = Dialog::currentScene().text[i];
1012 if (Dialog::currentScene().text[i] != '#')
1023 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1024 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
1025 text->glPrintOutlined(1, 1, 1, tutorialopac, startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1027 glColor4f(0, 0, 0, tutorialopac);
1028 text->glPrint(startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1032 if (string[i] == '\0')
1041 if (!tutoriallevel && !winfreeze && !Dialog::inDialog() && !mainmenu) {
1044 string = "Score: " + to_string(int(Account::active().getCampaignScore()));
1046 string = "Score: " + to_string(int(Account::active().getCampaignScore() + bonustotal));
1049 string = "Score: " + to_string(int(bonustotal));
1051 text->glPrintOutlined(1, 0, 0, 1, 1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1052 if (showdamagebar) {
1053 glDisable(GL_DEPTH_TEST);
1054 glDisable(GL_CULL_FACE);
1055 glDisable(GL_LIGHTING);
1056 glDisable(GL_TEXTURE_2D);
1058 glMatrixMode(GL_PROJECTION);
1061 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1062 glMatrixMode(GL_MODELVIEW);
1065 glTranslatef(15, screenheight * 17.5 / 20, 0);
1066 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1067 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1069 glColor4f(0.0, 0.4, 0.0, 0.7);
1070 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1072 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1073 glVertex3f(1, 0, 0.0f);
1074 glVertex3f(1, 1, 0.0f);
1075 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1077 glColor4f(0.1, 0.0, 0.0, 1);
1078 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1080 glVertex3f(0, 0, 0.0f);
1081 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1082 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1083 glVertex3f(0, 1, 0.0f);
1085 glColor4f(0.4, 0.0, 0.0, 0.7);
1086 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1088 glVertex3f(0, 0, 0.0f);
1089 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1090 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1091 glVertex3f(0, 1, 0.0f);
1093 glColor4f(0.4, 0.0, 0.0, 0.7);
1094 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1096 glVertex3f(0, 0, 0.0f);
1097 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1098 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1099 glVertex3f(0, 1, 0.0f);
1101 glColor4f(0.4, 0.0, 0.0, 0.7);
1102 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1104 glVertex3f(0, 0, 0.0f);
1105 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1106 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1107 glVertex3f(0, 1, 0.0f);
1109 glColor4f(0.0, 0.0, 0.0, 0.7);
1111 glBegin(GL_LINE_STRIP);
1112 glVertex3f(0, 0, 0.0f);
1113 glVertex3f(1, 0, 0.0f);
1114 glVertex3f(1, 1, 0.0f);
1115 glVertex3f(0, 1, 0.0f);
1116 glVertex3f(0, 0, 0.0f);
1119 glMatrixMode(GL_PROJECTION);
1121 glMatrixMode(GL_MODELVIEW);
1123 glEnable(GL_DEPTH_TEST);
1124 glEnable(GL_CULL_FACE);
1125 glDisable(GL_BLEND);
1127 glEnable(GL_TEXTURE_2D);
1129 // writing the numbers :
1130 string = "Damages : " + to_string(int(Person::players[0]->damage)) + "/" + to_string(int(Person::players[0]->damagetolerance)) + " (" + to_string(int(Person::players[0]->bloodloss)) + ")";
1131 text->glPrintOutlined(1, 0, 0, 1, 1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1135 glColor4f(.5, .5, .5, 1);
1138 if ((texttoggle || editorenabled) && devtools && !mainmenu) {
1139 string = "The framespersecond is " + to_string(int(fps));
1140 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1142 if (editorenabled) {
1143 string = "Map editor enabled.";
1145 string = "Map editor disabled.";
1147 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1148 if (editorenabled) {
1149 string = "Object size: " + to_string(editorsize);
1150 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1151 if (editoryaw >= 0) {
1152 string = "Object yaw: " + to_string(editoryaw);
1154 string = "Object yaw: Random";
1156 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1157 if (editorpitch >= 0) {
1158 string = "Object pitch: " + to_string(editorpitch);
1160 string = "Object pitch: Random";
1162 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1163 string = "Object type: " + to_string(editortype);
1164 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1165 switch (editortype) {
1188 string = "(tunnel)";
1191 string = "(chimney)";
1194 string = "(platform)";
1203 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1205 string = "Numplayers: " + to_string(Person::players.size());
1206 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1207 string = "Player " + to_string(int(Person::players.size()) - 1) + ": numwaypoints: " + to_string(Person::players.back()->numwaypoints);
1208 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1210 string = "Difficulty: " + to_string(difficulty);
1211 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1216 if (drawmode == glowmode) {
1217 glDisable(GL_DEPTH_TEST);
1218 glDisable(GL_CULL_FACE);
1219 glDisable(GL_LIGHTING);
1220 glDisable(GL_TEXTURE_2D);
1222 glMatrixMode(GL_PROJECTION);
1225 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1226 glMatrixMode(GL_MODELVIEW);
1229 glScalef(screenwidth, screenheight, 1);
1230 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1232 glColor4f(0, 0, 0, .5);
1234 glVertex3f(0, 0, 0.0f);
1235 glVertex3f(256, 0, 0.0f);
1236 glVertex3f(256, 256, 0.0f);
1237 glVertex3f(0, 256, 0.0f);
1239 glMatrixMode(GL_PROJECTION);
1241 glMatrixMode(GL_MODELVIEW);
1243 glEnable(GL_DEPTH_TEST);
1244 glEnable(GL_CULL_FACE);
1245 glDisable(GL_BLEND);
1249 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1250 glDisable(GL_DEPTH_TEST);
1251 glDisable(GL_CULL_FACE);
1252 glDisable(GL_LIGHTING);
1253 glDisable(GL_TEXTURE_2D);
1255 glMatrixMode(GL_PROJECTION);
1258 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1259 glMatrixMode(GL_MODELVIEW);
1262 glScalef(screenwidth, screenheight, 1);
1263 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1265 if (Person::players[0]->dead)
1266 blackout += multiplier * 3;
1267 if (Person::players[0]->dead == 1)
1269 if (Person::players[0]->dead == 2 && blackout > .6)
1271 glColor4f(0, 0, 0, blackout);
1272 if (!Person::players[0]->dead) {
1273 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1274 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1275 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1277 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1278 blackout = Person::players[0]->blooddimamount * .3;
1282 glColor4f(.7, 0, 0, .2);
1284 glVertex3f(0, 0, 0.0f);
1285 glVertex3f(256, 0, 0.0f);
1286 glVertex3f(256, 256, 0.0f);
1287 glVertex3f(0, 256, 0.0f);
1289 glMatrixMode(GL_PROJECTION);
1291 glMatrixMode(GL_MODELVIEW);
1293 glEnable(GL_DEPTH_TEST);
1294 glEnable(GL_CULL_FACE);
1295 glDisable(GL_BLEND);
1299 if (flashamount > 0 && damageeffects) {
1300 if (flashamount > 1)
1302 if (flashdelay <= 0)
1303 flashamount -= multiplier;
1305 if (flashamount < 0)
1307 glDisable(GL_DEPTH_TEST);
1308 glDisable(GL_CULL_FACE);
1309 glDisable(GL_LIGHTING);
1311 glMatrixMode(GL_PROJECTION);
1314 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1315 glMatrixMode(GL_MODELVIEW);
1318 glScalef(screenwidth, screenheight, 1);
1319 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1321 glColor4f(flashr, flashg, flashb, flashamount);
1323 glVertex3f(0, 0, 0.0f);
1324 glVertex3f(256, 0, 0.0f);
1325 glVertex3f(256, 256, 0.0f);
1326 glVertex3f(0, 256, 0.0f);
1328 glMatrixMode(GL_PROJECTION);
1330 glMatrixMode(GL_MODELVIEW);
1332 glEnable(GL_DEPTH_TEST);
1333 glEnable(GL_CULL_FACE);
1334 glDisable(GL_BLEND);
1338 if (difficulty < 2 && !Dialog::inDialog()) { // minimap
1339 float mapviewdist = 20000;
1341 glDisable(GL_DEPTH_TEST);
1342 glColor3f (1.0, 1.0, 1.0); // no coloring
1344 glEnable(GL_TEXTURE_2D);
1345 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1346 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1347 glDisable(GL_DEPTH_TEST);
1348 glDisable(GL_CULL_FACE);
1349 glDisable(GL_LIGHTING);
1351 glMatrixMode(GL_PROJECTION);
1354 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1355 glMatrixMode(GL_MODELVIEW);
1358 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1359 glTranslatef(1.75, .25, 0);
1360 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1362 glColor4f(1, 1, 1, 1);
1369 center = Person::players[0]->coords;
1373 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1375 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1377 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1378 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1379 for (int i = 0; i < Object::objects.size(); i++) {
1380 if (Object::objects[i]->type == treetrunktype) {
1381 distcheck = distsq(&Person::players[0]->coords, &Object::objects[i]->position);
1382 if (distcheck < mapviewdist) {
1383 Mapcircletexture.bind();
1384 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1386 glTranslatef(Object::objects[i]->position.x / terrain.scale / 256 * -2 + 1, Object::objects[i]->position.z / terrain.scale / 256 * 2 - 1, 0);
1387 glRotatef(Object::objects[i]->yaw, 0, 0, 1);
1388 glScalef(.003, .003, .003);
1391 glVertex3f(-1, -1, 0.0f);
1393 glVertex3f(1, -1, 0.0f);
1395 glVertex3f(1, 1, 0.0f);
1397 glVertex3f(-1, 1, 0.0f);
1402 if (Object::objects[i]->type == boxtype) {
1403 distcheck = distsq(&Person::players[0]->coords, &Object::objects[i]->position);
1404 if (distcheck < mapviewdist) {
1405 Mapboxtexture.bind();
1406 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1408 glTranslatef(Object::objects[i]->position.x / terrain.scale / 256 * -2 + 1, Object::objects[i]->position.z / terrain.scale / 256 * 2 - 1, 0);
1409 glRotatef(Object::objects[i]->yaw, 0, 0, 1);
1410 glScalef(.01 * Object::objects[i]->scale, .01 * Object::objects[i]->scale, .01 * Object::objects[i]->scale);
1413 glVertex3f(-1, -1, 0.0f);
1415 glVertex3f(1, -1, 0.0f);
1417 glVertex3f(1, 1, 0.0f);
1419 glVertex3f(-1, 1, 0.0f);
1425 if (editorenabled) {
1426 Mapcircletexture.bind();
1427 for (int i = 0; i < numboundaries; i++) {
1428 glColor4f(0, 0, 0, opac / 3);
1430 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1431 glScalef(.002, .002, .002);
1434 glVertex3f(-1, -1, 0.0f);
1436 glVertex3f(1, -1, 0.0f);
1438 glVertex3f(1, 1, 0.0f);
1440 glVertex3f(-1, 1, 0.0f);
1445 for (unsigned i = 0; i < Person::players.size(); i++) {
1446 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1447 if (distcheck < mapviewdist) {
1449 Maparrowtexture.bind();
1451 glColor4f(1, 1, 1, opac);
1452 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1453 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1454 else if (Person::players[i]->dead)
1455 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1456 else if (Person::players[i]->aitype == attacktypecutoff)
1457 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1458 else if (Person::players[i]->aitype == passivetype)
1459 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1461 glColor4f(1, 1, 0, 1);
1462 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1463 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1464 glScalef(.005, .005, .005);
1467 glVertex3f(-1, -1, 0.0f);
1469 glVertex3f(1, -1, 0.0f);
1471 glVertex3f(1, 1, 0.0f);
1473 glVertex3f(-1, 1, 0.0f);
1479 glDisable(GL_TEXTURE_2D);
1480 glMatrixMode(GL_PROJECTION);
1482 glMatrixMode(GL_MODELVIEW);
1484 glEnable(GL_DEPTH_TEST);
1485 glEnable(GL_CULL_FACE);
1486 glDisable(GL_BLEND);
1490 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1491 glDisable(GL_DEPTH_TEST);
1492 glDisable(GL_CULL_FACE);
1493 glDisable(GL_LIGHTING);
1494 glDisable(GL_TEXTURE_2D);
1496 glMatrixMode(GL_PROJECTION);
1499 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1500 glMatrixMode(GL_MODELVIEW);
1503 glScalef(screenwidth, screenheight, 1);
1504 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1506 glColor4f(0, 0, 0, .7);
1508 glVertex3f(0, 0, 0.0f);
1509 glVertex3f(256, 0, 0.0f);
1510 glVertex3f(256, 256, 0.0f);
1511 glVertex3f(0, 256, 0.0f);
1513 glMatrixMode(GL_PROJECTION);
1515 glMatrixMode(GL_MODELVIEW);
1517 glEnable(GL_DEPTH_TEST);
1518 glEnable(GL_CULL_FACE);
1519 glDisable(GL_BLEND);
1523 glDisable(GL_DEPTH_TEST);
1524 glColor3f (1.0, 1.0, 1.0); // no coloring
1526 glEnable(GL_TEXTURE_2D);
1531 glEnable(GL_TEXTURE_2D);
1532 glColor4f(1, 1, 1, 1);
1533 string = "Loading...";
1534 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1537 drawmode = normalmode;
1540 if (winfreeze && !campaign) {
1541 glDisable(GL_DEPTH_TEST);
1542 glDisable(GL_CULL_FACE);
1543 glDisable(GL_LIGHTING);
1544 glDisable(GL_TEXTURE_2D);
1546 glMatrixMode(GL_PROJECTION);
1549 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1550 glMatrixMode(GL_MODELVIEW);
1553 glScalef(screenwidth, screenheight, 1);
1554 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1556 glColor4f(0, 0, 0, .4);
1558 glVertex3f(0, 0, 0.0f);
1559 glVertex3f(256, 0, 0.0f);
1560 glVertex3f(256, 256, 0.0f);
1561 glVertex3f(0, 256, 0.0f);
1563 glMatrixMode(GL_PROJECTION);
1565 glMatrixMode(GL_MODELVIEW);
1567 glEnable(GL_DEPTH_TEST);
1568 glEnable(GL_CULL_FACE);
1569 glDisable(GL_BLEND);
1573 glDisable(GL_DEPTH_TEST);
1574 glColor3f (1.0, 1.0, 1.0); // no coloring
1576 glEnable(GL_TEXTURE_2D);
1578 //Win Screen Won Victory
1580 glEnable(GL_TEXTURE_2D);
1581 glColor4f(1, 1, 1, 1);
1582 string = "Level Cleared!";
1583 text->glPrintOutlined(1024 / 2 - string.size() * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1585 string = "Score: " + to_string(int(bonustotal - startbonustotal));
1586 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1588 string = "Press Escape to return to menu or Space to continue";
1589 text->glPrintOutlined(640 / 2 - string.size() * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1591 int wontime = (int)round(wonleveltime);
1592 string = "Time: " + to_string(int((wontime - wontime % 60) / 60));
1593 if (wontime % 60 < 10) {
1596 string += to_string(int(wontime % 60));
1597 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1600 int awards[award_count];
1601 int numawards = award_awards(awards);
1603 for (int i = 0; i < numawards && i < 6; i++)
1604 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1607 if (drawmode != normalmode) {
1608 glEnable(GL_TEXTURE_2D);
1610 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1611 if (screentexture) {
1613 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
1614 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1615 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1616 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
1617 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
1618 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
1620 glBindTexture( GL_TEXTURE_2D, screentexture);
1621 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1624 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1625 if (screentexture2) {
1626 glBindTexture( GL_TEXTURE_2D, screentexture2);
1627 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1629 if (!screentexture2) {
1630 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1632 glGenTextures( 1, &screentexture2 );
1633 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1635 glEnable(GL_TEXTURE_2D);
1636 glBindTexture( GL_TEXTURE_2D, screentexture2);
1637 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1638 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1640 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1645 glClear(GL_DEPTH_BUFFER_BIT);
1646 Game::ReSizeGLScene(90, .1f);
1647 glViewport(0, 0, screenwidth, screenheight);
1649 if (drawmode != normalmode) {
1650 glDisable(GL_DEPTH_TEST);
1651 if (drawmode == motionblurmode) {
1652 glDrawBuffer(GL_FRONT);
1653 glReadBuffer(GL_BACK);
1655 glColor3f (1.0, 1.0, 1.0); // no coloring
1657 glEnable(GL_TEXTURE_2D);
1658 glBindTexture( GL_TEXTURE_2D, screentexture);
1659 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1660 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1661 glDisable(GL_DEPTH_TEST);
1662 glDisable(GL_CULL_FACE);
1663 glDisable(GL_LIGHTING);
1665 glMatrixMode(GL_PROJECTION);
1668 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1669 glMatrixMode(GL_MODELVIEW);
1672 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1673 glTranslatef(1, 1, 0);
1674 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1676 if (drawmode == motionblurmode) {
1677 if (motionbluramount < .2)
1678 motionbluramount = .2;
1679 glColor4f(1, 1, 1, motionbluramount);
1683 glVertex3f(-1, -1, 0.0f);
1684 glTexCoord2f(texcoordwidth, 0);
1685 glVertex3f(1, -1, 0.0f);
1686 glTexCoord2f(texcoordwidth, texcoordheight);
1687 glVertex3f(1, 1, 0.0f);
1688 glTexCoord2f(0, texcoordheight);
1689 glVertex3f(-1, 1, 0.0f);
1693 if (drawmode == realmotionblurmode) {
1694 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1695 glClear(GL_COLOR_BUFFER_BIT);
1696 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1697 glBindTexture( GL_TEXTURE_2D, screentexture);
1698 glColor4f(1, 1, 1, .5);
1702 glVertex3f(-1, -1, 0.0f);
1703 glTexCoord2f(texcoordwidth, 0);
1704 glVertex3f(1, -1, 0.0f);
1705 glTexCoord2f(texcoordwidth, texcoordheight);
1706 glVertex3f(1, 1, 0.0f);
1707 glTexCoord2f(0, texcoordheight);
1708 glVertex3f(-1, 1, 0.0f);
1711 glBindTexture( GL_TEXTURE_2D, screentexture2);
1712 glColor4f(1, 1, 1, .5);
1716 glVertex3f(-1, -1, 0.0f);
1717 glTexCoord2f(texcoordwidth, 0);
1718 glVertex3f(1, -1, 0.0f);
1719 glTexCoord2f(texcoordwidth, texcoordheight);
1720 glVertex3f(1, 1, 0.0f);
1721 glTexCoord2f(0, texcoordheight);
1722 glVertex3f(-1, 1, 0.0f);
1725 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1727 if (drawmode == doublevisionmode) {
1728 static float crosseyedness;
1729 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1730 if (crosseyedness > 1)
1732 if (crosseyedness < 0)
1734 glColor4f(1, 1, 1, 1);
1735 glDisable(GL_BLEND);
1740 glVertex3f(-1, -1, 0.0f);
1741 glTexCoord2f(texcoordwidth, 0);
1742 glVertex3f(1, -1, 0.0f);
1743 glTexCoord2f(texcoordwidth, texcoordheight);
1744 glVertex3f(1, 1, 0.0f);
1745 glTexCoord2f(0, texcoordheight);
1746 glVertex3f(-1, 1, 0.0f);
1749 if (crosseyedness) {
1750 glColor4f(1, 1, 1, .5);
1753 glTranslatef(.015 * crosseyedness, 0, 0);
1757 glVertex3f(-1, -1, 0.0f);
1758 glTexCoord2f(texcoordwidth, 0);
1759 glVertex3f(1, -1, 0.0f);
1760 glTexCoord2f(texcoordwidth, texcoordheight);
1761 glVertex3f(1, 1, 0.0f);
1762 glTexCoord2f(0, texcoordheight);
1763 glVertex3f(-1, 1, 0.0f);
1768 if (drawmode == glowmode) {
1769 glColor4f(.5, .5, .5, .5);
1771 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1773 glTranslatef(.01, 0, 0);
1776 glVertex3f(-1, -1, 0.0f);
1777 glTexCoord2f(texcoordwidth, 0);
1778 glVertex3f(1, -1, 0.0f);
1779 glTexCoord2f(texcoordwidth, texcoordheight);
1780 glVertex3f(1, 1, 0.0f);
1781 glTexCoord2f(0, texcoordheight);
1782 glVertex3f(-1, 1, 0.0f);
1786 glTranslatef(-.01, 0, 0);
1789 glVertex3f(-1, -1, 0.0f);
1790 glTexCoord2f(texcoordwidth, 0);
1791 glVertex3f(1, -1, 0.0f);
1792 glTexCoord2f(texcoordwidth, texcoordheight);
1793 glVertex3f(1, 1, 0.0f);
1794 glTexCoord2f(0, texcoordheight);
1795 glVertex3f(-1, 1, 0.0f);
1799 glTranslatef(.0, .01, 0);
1802 glVertex3f(-1, -1, 0.0f);
1803 glTexCoord2f(texcoordwidth, 0);
1804 glVertex3f(1, -1, 0.0f);
1805 glTexCoord2f(texcoordwidth, texcoordheight);
1806 glVertex3f(1, 1, 0.0f);
1807 glTexCoord2f(0, texcoordheight);
1808 glVertex3f(-1, 1, 0.0f);
1812 glTranslatef(0, -.01, 0);
1815 glVertex3f(-1, -1, 0.0f);
1816 glTexCoord2f(texcoordwidth, 0);
1817 glVertex3f(1, -1, 0.0f);
1818 glTexCoord2f(texcoordwidth, texcoordheight);
1819 glVertex3f(1, 1, 0.0f);
1820 glTexCoord2f(0, texcoordheight);
1821 glVertex3f(-1, 1, 0.0f);
1825 if (drawmode == radialzoommode) {
1826 for (int i = 0; i < 3; i++) {
1827 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1829 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1832 glVertex3f(-1, -1, 0.0f);
1833 glTexCoord2f(texcoordwidth, 0);
1834 glVertex3f(1, -1, 0.0f);
1835 glTexCoord2f(texcoordwidth, texcoordheight);
1836 glVertex3f(1, 1, 0.0f);
1837 glTexCoord2f(0, texcoordheight);
1838 glVertex3f(-1, 1, 0.0f);
1843 glDisable(GL_TEXTURE_2D);
1844 glMatrixMode(GL_PROJECTION);
1846 glMatrixMode(GL_MODELVIEW);
1848 glEnable(GL_DEPTH_TEST);
1849 glEnable(GL_CULL_FACE);
1850 glDisable(GL_BLEND);
1855 glEnable(GL_TEXTURE_2D);
1856 glColor4f(1, 1, 1, 1);
1858 if (consoleselected >= 60)
1859 offset = consoleselected - 60;
1860 text->glPrint(10, 30, " ]", 0, 1, 1024, 768);
1862 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, "_", 0, 1, 1024, 768);
1864 for (unsigned i = 0; i < 15; i++) {
1865 text->glPrint(30 - offset * 10, 30 + i * 20, consoletext[i], 0, 1, 1024, 768);
1870 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1871 multiplier = tempmult;
1878 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1879 tempmult = multiplier;
1883 if ( side == stereoRight || side == stereoCenter ) {
1884 if (drawmode != motionblurmode || mainmenu) {
1889 glDrawBuffer(GL_BACK);
1890 glReadBuffer(GL_BACK);
1894 if (drawtoggle == 2)
1897 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1898 multiplier = tempmult;
1900 //Jordan fixed your warning!
1906 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1909 glDrawBuffer(GL_BACK);
1910 glReadBuffer(GL_BACK);
1911 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1912 Game::ReSizeGLScene(90, .1f);
1914 //draw menu background
1915 glClear(GL_DEPTH_BUFFER_BIT);
1916 glEnable(GL_ALPHA_TEST);
1917 glAlphaFunc(GL_GREATER, 0.001f);
1918 glEnable(GL_TEXTURE_2D);
1919 glDisable(GL_DEPTH_TEST);
1920 glDisable(GL_CULL_FACE);
1921 glDisable(GL_LIGHTING);
1923 glMatrixMode(GL_PROJECTION);
1926 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1927 glMatrixMode(GL_MODELVIEW);
1930 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1932 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1933 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1934 glDisable(GL_BLEND);
1935 glColor4f(0, 0, 0, 1.0);
1936 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1937 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1938 glDisable(GL_TEXTURE_2D);
1940 glVertex3f(-1, -1, 0);
1941 glVertex3f(+1, -1, 0);
1942 glVertex3f(+1, +1, 0);
1943 glVertex3f(-1, +1, 0);
1946 glColor4f(0.4, 0.4, 0.4, 1.0);
1947 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1948 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1949 glEnable(GL_TEXTURE_2D);
1950 Game::Mainmenuitems[4].bind();
1953 glVertex3f(-1, -1, 0);
1955 glVertex3f(+1, -1, 0);
1957 glVertex3f(+1, +1, 0);
1959 glVertex3f(-1, +1, 0);
1963 glMatrixMode(GL_PROJECTION);
1965 glMatrixMode(GL_MODELVIEW);
1969 glMatrixMode(GL_PROJECTION);
1972 glOrtho(0, 640, 0, 480, -100, 100);
1973 glMatrixMode(GL_MODELVIEW);
1976 glEnable(GL_TEXTURE_2D);
1981 glMatrixMode(GL_PROJECTION);
1983 glMatrixMode(GL_MODELVIEW);
1986 glMatrixMode(GL_PROJECTION);
1989 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1990 glMatrixMode(GL_MODELVIEW);
1993 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1995 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1996 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1998 glEnable(GL_TEXTURE_2D);
1999 glColor4f(1, 1, 1, 1);
2000 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2001 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2003 if (!Game::waiting) { // hide the cursor while waiting for a key
2005 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2006 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2007 glTranslatef(1, -1, 0);
2008 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2009 glColor4f(1, 1, 1, 1);
2010 Game::cursortexture.bind();
2014 glVertex3f(-1, -1, 0.0f);
2016 glVertex3f(1, -1, 0.0f);
2018 glVertex3f(1, 1, 0.0f);
2020 glVertex3f(-1, 1, 0.0f);
2026 glMatrixMode(GL_PROJECTION);
2031 if (flashamount > 0) {
2032 if (flashamount > 1)
2034 if (flashdelay <= 0)
2035 flashamount -= multiplier;
2037 if (flashamount < 0)
2039 glDisable(GL_DEPTH_TEST);
2040 glDisable(GL_CULL_FACE);
2041 glDisable(GL_LIGHTING);
2042 glDisable(GL_TEXTURE_2D);
2044 glMatrixMode(GL_PROJECTION);
2047 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2048 glMatrixMode(GL_MODELVIEW);
2051 glScalef(screenwidth, screenheight, 1);
2052 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2054 glColor4f(flashr, flashg, flashb, flashamount);
2056 glVertex3f(0, 0, 0.0f);
2057 glVertex3f(256, 0, 0.0f);
2058 glVertex3f(256, 256, 0.0f);
2059 glVertex3f(0, 256, 0.0f);
2061 glMatrixMode(GL_PROJECTION);
2063 glMatrixMode(GL_MODELVIEW);
2065 glEnable(GL_DEPTH_TEST);
2066 glEnable(GL_CULL_FACE);
2067 glDisable(GL_BLEND);