MCPcopy Create free account
hub / github.com/assaultcube/AC / blendbox

Function blendbox

source/src/rendergl.cpp:303–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303void blendbox(int x1, int y1, int x2, int y2, bool border, int tex, color *c)
304{
305 glDepthMask(GL_FALSE);
306 if(tex>=0)
307 {
308 glBindTexture(GL_TEXTURE_2D, tex);
309 if(c)
310 {
311 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
312 glColor4f(c->r, c->g, c->b, c->alpha);
313 }
314 else
315 {
316 glDisable(GL_BLEND);
317 glColor3f(1, 1, 1);
318 }
319
320 int texw = 512;
321 int texh = texw;
322 int cols = (int)((x2-x1)/texw+1);
323 int rows = (int)((y2-y1)/texh+1);
324 xtraverts += cols*rows*4;
325
326 loopj(rows)
327 {
328 float ytexcut = 0.0f;
329 float yboxcut = 0.0f;
330 if((j+1)*texh>y2-y1) // cut last row to match the box height
331 {
332 yboxcut = (float)(((j+1)*texh)-(y2-y1));
333 ytexcut = (float)(((j+1)*texh)-(y2-y1))/texh;
334 }
335
336 loopi(cols)
337 {
338 float xtexcut = 0.0f;
339 float xboxcut = 0.0f;
340 if((i+1)*texw>x2-x1)
341 {
342 xboxcut = (float)(((i+1)*texw)-(x2-x1));
343 xtexcut = (float)(((i+1)*texw)-(x2-x1))/texw;
344 }
345
346 glBegin(GL_TRIANGLE_STRIP);
347 glTexCoord2f(0, 0); glVertex2f((float)x1+texw*i, (float)y1+texh*j);
348 glTexCoord2f(1-xtexcut, 0); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*j);
349 glTexCoord2f(0, 1-ytexcut); glVertex2f((float)x1+texw*i, y1+texh*(j+1)-yboxcut);
350 glTexCoord2f(1-xtexcut, 1-ytexcut); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*(j+1)-yboxcut);
351 glEnd();
352 }
353 }
354
355 if(!c) glEnable(GL_BLEND);
356 }
357 else
358 {
359 glDisable(GL_TEXTURE_2D);
360

Callers 10

framedquadtextureFunction · 0.85
rendercursorFunction · 0.85
renderbgMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
gl_drawhudFunction · 0.85
r_accuracyFunction · 0.85
renderhudtexturepreviewFunction · 0.85
renderMethod · 0.85

Calls 1

box2dFunction · 0.85

Tested by

no test coverage detected