MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / opengl_MakeBitmapCurrent

Function opengl_MakeBitmapCurrent

renderer/HardwareOpenGL.cpp:1074–1138  ·  view source on GitHub ↗

Utilizes a LRU cacheing scheme to select/upload textures the opengl driver

Source from the content-addressed store, hash-verified

1072
1073// Utilizes a LRU cacheing scheme to select/upload textures the opengl driver
1074int opengl_MakeBitmapCurrent(int handle, int map_type, int tn) {
1075 int w, h;
1076 int texnum;
1077
1078 if (map_type == MAP_TYPE_LIGHTMAP) {
1079 w = GameLightmaps[handle].square_res;
1080 h = GameLightmaps[handle].square_res;
1081 } else {
1082 if (Force_one_texture) {
1083 handle = 0;
1084 }
1085
1086 w = bm_w(handle, 0);
1087 h = bm_h(handle, 0);
1088 }
1089
1090 if (w != h) {
1091 mprintf(0, "Can't use non-square textures with OpenGL!\n");
1092 return 0;
1093 }
1094
1095 // See if the bitmaps is already in the cache
1096 if (map_type == MAP_TYPE_LIGHTMAP) {
1097 if (OpenGL_lightmap_remap[handle] == 65535) {
1098 texnum = opengl_MakeTextureObject(tn);
1099 SET_WRAP_STATE(OpenGL_lightmap_states[handle], 1);
1100 SET_FILTER_STATE(OpenGL_lightmap_states[handle], 0);
1101 OpenGL_lightmap_remap[handle] = texnum;
1102 opengl_TranslateBitmapToOpenGL(texnum, handle, map_type, 0, tn);
1103 } else {
1104 texnum = OpenGL_lightmap_remap[handle];
1105 if (GameLightmaps[handle].flags & LF_CHANGED)
1106 opengl_TranslateBitmapToOpenGL(texnum, handle, map_type, 1, tn);
1107 }
1108 } else {
1109 if (OpenGL_bitmap_remap[handle] == 65535) {
1110 texnum = opengl_MakeTextureObject(tn);
1111 SET_WRAP_STATE(OpenGL_bitmap_states[handle], 1);
1112 SET_FILTER_STATE(OpenGL_bitmap_states[handle], 0);
1113 OpenGL_bitmap_remap[handle] = texnum;
1114 opengl_TranslateBitmapToOpenGL(texnum, handle, map_type, 0, tn);
1115 } else {
1116 texnum = OpenGL_bitmap_remap[handle];
1117 if (GameBitmaps[handle].flags & BF_CHANGED) {
1118 opengl_TranslateBitmapToOpenGL(texnum, handle, map_type, 1, tn);
1119 }
1120 }
1121 }
1122
1123 if (OpenGL_last_bound[tn] != texnum) {
1124 if (UseMultitexture && Last_texel_unit_set != tn) {
1125#if (defined(_USE_OGL_ACTIVE_TEXTURES))
1126 oglActiveTextureARB(GL_TEXTURE0_ARB + tn);
1127 Last_texel_unit_set = tn;
1128#endif
1129 }
1130
1131 dglBindTexture(GL_TEXTURE_2D, texnum);

Callers 1

gpu_BindTextureFunction · 0.70

Calls 4

bm_wFunction · 0.85
bm_hFunction · 0.85
opengl_MakeTextureObjectFunction · 0.70

Tested by

no test coverage detected