| 1126 | } |
| 1127 | |
| 1128 | void CRenderMap::RenderSwitchmap(CSwitchTile *pSwitchTile, int w, int h, float Scale, ColorRGBA Color, int RenderFlags) |
| 1129 | { |
| 1130 | float ScreenX0, ScreenY0, ScreenX1, ScreenY1; |
| 1131 | Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); |
| 1132 | |
| 1133 | // calculate the final pixelsize for the tiles |
| 1134 | float TilePixelSize = 1024 / 32.0f; |
| 1135 | float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth(); |
| 1136 | float FinalTilesetScale = FinalTileSize / TilePixelSize; |
| 1137 | |
| 1138 | if(Graphics()->HasTextureArraysSupport()) |
| 1139 | Graphics()->QuadsTex3DBegin(); |
| 1140 | else |
| 1141 | Graphics()->QuadsBegin(); |
| 1142 | Graphics()->SetColor(Color); |
| 1143 | |
| 1144 | int StartY = (int)(ScreenY0 / Scale) - 1; |
| 1145 | int StartX = (int)(ScreenX0 / Scale) - 1; |
| 1146 | int EndY = (int)(ScreenY1 / Scale) + 1; |
| 1147 | int EndX = (int)(ScreenX1 / Scale) + 1; |
| 1148 | |
| 1149 | // adjust the texture shift according to mipmap level |
| 1150 | float TexSize = 1024.0f; |
| 1151 | float Frac = (1.25f / TexSize) * (1 / FinalTilesetScale); |
| 1152 | float Nudge = (0.5f / TexSize) * (1 / FinalTilesetScale); |
| 1153 | |
| 1154 | for(int y = StartY; y < EndY; y++) |
| 1155 | for(int x = StartX; x < EndX; x++) |
| 1156 | { |
| 1157 | int mx = x; |
| 1158 | int my = y; |
| 1159 | |
| 1160 | if(RenderFlags & TILERENDERFLAG_EXTEND) |
| 1161 | { |
| 1162 | if(mx < 0) |
| 1163 | mx = 0; |
| 1164 | if(mx >= w) |
| 1165 | mx = w - 1; |
| 1166 | if(my < 0) |
| 1167 | my = 0; |
| 1168 | if(my >= h) |
| 1169 | my = h - 1; |
| 1170 | } |
| 1171 | else |
| 1172 | { |
| 1173 | if(mx < 0) |
| 1174 | continue; // mx = 0; |
| 1175 | if(mx >= w) |
| 1176 | continue; // mx = w-1; |
| 1177 | if(my < 0) |
| 1178 | continue; // my = 0; |
| 1179 | if(my >= h) |
| 1180 | continue; // my = h-1; |
| 1181 | } |
| 1182 | |
| 1183 | int c = mx + my * w; |
| 1184 | |
| 1185 | unsigned char Index = pSwitchTile[c].m_Type; |
no test coverage detected