| 1009 | } |
| 1010 | |
| 1011 | void CRenderMap::RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, ColorRGBA Color, int RenderFlags) |
| 1012 | { |
| 1013 | float ScreenX0, ScreenY0, ScreenX1, ScreenY1; |
| 1014 | Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); |
| 1015 | |
| 1016 | // calculate the final pixelsize for the tiles |
| 1017 | float TilePixelSize = 1024 / 32.0f; |
| 1018 | float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth(); |
| 1019 | float FinalTilesetScale = FinalTileSize / TilePixelSize; |
| 1020 | |
| 1021 | if(Graphics()->HasTextureArraysSupport()) |
| 1022 | Graphics()->QuadsTex3DBegin(); |
| 1023 | else |
| 1024 | Graphics()->QuadsBegin(); |
| 1025 | Graphics()->SetColor(Color); |
| 1026 | |
| 1027 | int StartY = (int)(ScreenY0 / Scale) - 1; |
| 1028 | int StartX = (int)(ScreenX0 / Scale) - 1; |
| 1029 | int EndY = (int)(ScreenY1 / Scale) + 1; |
| 1030 | int EndX = (int)(ScreenX1 / Scale) + 1; |
| 1031 | |
| 1032 | // adjust the texture shift according to mipmap level |
| 1033 | float TexSize = 1024.0f; |
| 1034 | float Frac = (1.25f / TexSize) * (1 / FinalTilesetScale); |
| 1035 | float Nudge = (0.5f / TexSize) * (1 / FinalTilesetScale); |
| 1036 | |
| 1037 | for(int y = StartY; y < EndY; y++) |
| 1038 | for(int x = StartX; x < EndX; x++) |
| 1039 | { |
| 1040 | int mx = x; |
| 1041 | int my = y; |
| 1042 | |
| 1043 | if(RenderFlags & TILERENDERFLAG_EXTEND) |
| 1044 | { |
| 1045 | if(mx < 0) |
| 1046 | mx = 0; |
| 1047 | if(mx >= w) |
| 1048 | mx = w - 1; |
| 1049 | if(my < 0) |
| 1050 | my = 0; |
| 1051 | if(my >= h) |
| 1052 | my = h - 1; |
| 1053 | } |
| 1054 | else |
| 1055 | { |
| 1056 | if(mx < 0) |
| 1057 | continue; // mx = 0; |
| 1058 | if(mx >= w) |
| 1059 | continue; // mx = w-1; |
| 1060 | if(my < 0) |
| 1061 | continue; // my = 0; |
| 1062 | if(my >= h) |
| 1063 | continue; // my = h-1; |
| 1064 | } |
| 1065 | |
| 1066 | int c = mx + my * w; |
| 1067 | |
| 1068 | unsigned char Index = pTele[c].m_Type; |
no test coverage detected