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

Function rend_DrawScaledChunkedBitmap

renderer/HardwareBaseGPU.cpp:326–369  ·  view source on GitHub ↗

given a chunked bitmap, renders it.scaled

Source from the content-addressed store, hash-verified

324
325// given a chunked bitmap, renders it.scaled
326void rend_DrawScaledChunkedBitmap(chunked_bitmap *chunk, int x, int y, int neww, int newh, uint8_t alpha) {
327 int *bm_array = chunk->bm_array;
328 int w = chunk->w;
329 int h = chunk->h;
330 int piece_w;
331 int piece_h;
332 int screen_w, screen_h;
333 int i, t;
334
335 float scalew, scaleh;
336
337 scalew = ((float)neww) / ((float)chunk->pw);
338 scaleh = ((float)newh) / ((float)chunk->ph);
339 piece_w = scalew * ((float)bm_w(bm_array[0], 0));
340 piece_h = scaleh * ((float)bm_h(bm_array[0], 0));
341 rend_GetProjectionParameters(&screen_w, &screen_h);
342 rend_SetOverlayType(OT_NONE);
343 rend_SetLighting(LS_NONE);
344 rend_SetColorModel(CM_MONO);
345 rend_SetZBufferState(0);
346 rend_SetAlphaType(AT_CONSTANT_TEXTURE);
347 rend_SetAlphaValue(alpha);
348 rend_SetWrapType(WT_WRAP);
349 for (i = 0; i < h; i++) {
350 for (t = 0; t < w; t++) {
351 int dx = x + (piece_w * t);
352 int dy = y + (piece_h * i);
353 int dw, dh;
354 if ((dx + piece_w) > screen_w)
355 dw = piece_w - ((dx + piece_w) - screen_w);
356 else
357 dw = piece_w;
358 if ((dy + piece_h) > screen_h)
359 dh = piece_h - ((dy + piece_h) - screen_h);
360 else
361 dh = piece_h;
362
363 float u2 = (float)dw / (float)piece_w;
364 float v2 = (float)dh / (float)piece_h;
365 rend_DrawScaledBitmap(dx, dy, dx + dw, dy + dh, bm_array[i * w + t], 0, 0, u2, v2);
366 }
367 }
368 rend_SetZBufferState(1);
369}
370
371// Sets some global preferences for the renderer
372int rend_SetPreferredState(renderer_preferred_state *pref_state) {

Callers 2

TelCom_BltToScreenFunction · 0.50
TCGoalsRenderCallbackFunction · 0.50

Calls 11

bm_wFunction · 0.85
bm_hFunction · 0.85
rend_SetOverlayTypeFunction · 0.70
rend_SetLightingFunction · 0.70
rend_SetColorModelFunction · 0.70
rend_SetZBufferStateFunction · 0.70
rend_SetAlphaTypeFunction · 0.70
rend_SetAlphaValueFunction · 0.70
rend_SetWrapTypeFunction · 0.70
rend_DrawScaledBitmapFunction · 0.70

Tested by

no test coverage detected