| 1017 | int effective_stencilshadow = 0; |
| 1018 | |
| 1019 | void gl_drawframe(int w, int h, float changelod, float curfps, int elapsed) |
| 1020 | { |
| 1021 | extern int mapoverride_nostencilshadows, mapoverride_nowaterreflect; |
| 1022 | effective_stencilshadow = mapoverride_nostencilshadows && !ignoreoverride_nostencilshadows ? 0 : stencilshadow; |
| 1023 | bool effective_waterreflect = waterreflect && !editmode && (!mapoverride_nowaterreflect || ignoreoverride_nowaterreflect); |
| 1024 | |
| 1025 | dodynlights(); |
| 1026 | drawminimap(w, h); |
| 1027 | |
| 1028 | recomputecamera(); |
| 1029 | |
| 1030 | aspect = float(w)/h; |
| 1031 | fovy = 2*atan2(tan(float(dynfov())/2*RAD), aspect)/RAD; |
| 1032 | |
| 1033 | float hf = waterlevel - 0.3f; |
| 1034 | bool underwater = camera1->o.z<hf; |
| 1035 | |
| 1036 | glFogi(GL_FOG_START, (fog+64)/8); |
| 1037 | glFogi(GL_FOG_END, fog); |
| 1038 | float fogc[4] = { (fogcolour>>16)/256.0f, ((fogcolour>>8)&255)/256.0f, (fogcolour&255)/256.0f, 1.0f }, |
| 1039 | wfogc[4] = { hdr.watercolor[0]/255.0f, hdr.watercolor[1]/255.0f, hdr.watercolor[2]/255.0f, 1.0f }; |
| 1040 | glFogfv(GL_FOG_COLOR, fogc); |
| 1041 | glClearColor(fogc[0], fogc[1], fogc[2], 1.0f); |
| 1042 | |
| 1043 | glMatrixMode(GL_PROJECTION); |
| 1044 | glLoadIdentity(); |
| 1045 | |
| 1046 | if(underwater) |
| 1047 | { |
| 1048 | fovy += sinf(lastmillis/1000.0f)*2.0f; |
| 1049 | aspect += sinf(lastmillis/1000.0f+PI)*0.1f; |
| 1050 | glFogfv(GL_FOG_COLOR, wfogc); |
| 1051 | glFogi(GL_FOG_START, 0); |
| 1052 | glFogi(GL_FOG_END, (fog+96)/8); |
| 1053 | } |
| 1054 | |
| 1055 | farplane = fog*5/2; |
| 1056 | setperspective(fovy, aspect, 0.15f, farplane); |
| 1057 | glMatrixMode(GL_MODELVIEW); |
| 1058 | |
| 1059 | transplayer(); |
| 1060 | readmatrices(); |
| 1061 | |
| 1062 | if(!underwater && effective_waterreflect) |
| 1063 | { |
| 1064 | extern int wx1; |
| 1065 | if(wx1>=0) |
| 1066 | { |
| 1067 | if(reflectscissor) calcwaterscissor(); |
| 1068 | drawreflection(hf, w, h, changelod, false); |
| 1069 | if(waterrefract) drawreflection(hf, w, h, changelod, true); |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | if(effective_stencilshadow && hasstencil && stencilbits >= 8) glClearStencil((hasSTS || hasST2) && !hasSTW ? 128 : 0); |
| 1074 | glClear((outsidemap(camera1) ? GL_COLOR_BUFFER_BIT : 0) | GL_DEPTH_BUFFER_BIT | (effective_stencilshadow && hasstencil && stencilbits >= 8 ? GL_STENCIL_BUFFER_BIT : 0)); |
| 1075 | |
| 1076 | glEnable(GL_TEXTURE_2D); |
no test coverage detected