Initializes the texture cache for Direct3D
| 1005 | |
| 1006 | // Initializes the texture cache for Direct3D |
| 1007 | int d3d_TextureCacheInit() { |
| 1008 | int i; |
| 1009 | |
| 1010 | // Clear our cache slots |
| 1011 | for (i = 0; i < MAX_LIGHTMAPS; i++) { |
| 1012 | GameLightmaps[i].cache_slot = -1; |
| 1013 | } |
| 1014 | |
| 1015 | for (i = 0; i < MAX_BITMAPS; i++) { |
| 1016 | GameBitmaps[i].cache_slot = -1; |
| 1017 | } |
| 1018 | |
| 1019 | for (i = 0; i < MAX_BUMPMAPS; i++) { |
| 1020 | GameBumpmaps[i].cache_slot = -1; |
| 1021 | } |
| 1022 | |
| 1023 | // Allocate room to hold all our surfaces |
| 1024 | UploadSurfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(NUM_TEXTURE_CLASSES * sizeof(LPDIRECTDRAWSURFACE4)); |
| 1025 | if (UploadSurfaces == NULL) { |
| 1026 | mprintf(0, "Couldn't allocate memory for UploadSurfaces!\n"); |
| 1027 | |
| 1028 | rend_SetErrorMessage("Couldn't alloc mem for UploadSurfaces!"); |
| 1029 | return 0; |
| 1030 | } |
| 1031 | |
| 1032 | // Allocate room to hold all our 4444 surfaces |
| 1033 | Upload4444Surfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(NUM_TEXTURE_CLASSES * sizeof(LPDIRECTDRAWSURFACE4)); |
| 1034 | if (Upload4444Surfaces == NULL) { |
| 1035 | mprintf(0, "Couldn't allocate memory for Upload4444Surfaces!\n"); |
| 1036 | |
| 1037 | rend_SetErrorMessage("Couldn't alloc mem for Upload4444Surfaces!"); |
| 1038 | return 0; |
| 1039 | } |
| 1040 | |
| 1041 | BitmapTextureSurfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(MAX_BITMAPS * sizeof(LPDIRECTDRAWSURFACE4)); |
| 1042 | if (BitmapTextureSurfaces == NULL) { |
| 1043 | mprintf(0, "Couldn't allocate memory for BitmapTextureSurfaces!\n"); |
| 1044 | |
| 1045 | rend_SetErrorMessage("Couldn't alloc mem for BitmapTextureSurfaces!"); |
| 1046 | return 0; |
| 1047 | } |
| 1048 | |
| 1049 | // Allocate room to hold all our surfaces |
| 1050 | LightmapTextureSurfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(MAX_LIGHTMAPS * sizeof(LPDIRECTDRAWSURFACE4)); |
| 1051 | if (LightmapTextureSurfaces == NULL) { |
| 1052 | mprintf(0, "Couldn't allocate memory for LightmapTextureSurfaces!\n"); |
| 1053 | rend_SetErrorMessage("Couldn't alloc mem for LightmapTextureSurfaces!"); |
| 1054 | return 0; |
| 1055 | } |
| 1056 | |
| 1057 | if (d3d_CanBumpmap) { |
| 1058 | BumpmapTextureSurfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(MAX_BUMPMAPS * sizeof(LPDIRECTDRAWSURFACE4)); |
| 1059 | if (BumpmapTextureSurfaces == NULL) { |
| 1060 | mprintf(0, "Couldn't allocate memory for BumpmapTextureSurfaces!\n"); |
| 1061 | rend_SetErrorMessage("Couldn't alloc mem for BumpmapTextureSurfaces!"); |
| 1062 | return 0; |
| 1063 | } |
| 1064 |
no test coverage detected