MCPcopy Create free account
hub / github.com/DFHack/dfhack / rendermax

Function rendermax

plugins/rendermax/rendermax.cpp:316–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314
315
316static command_result rendermax(color_ostream &out, vector <string> & parameters)
317{
318 if(parameters.size()==0)
319 return CR_WRONG_USAGE;
320 if(!enabler->renderer->uses_opengl())
321 {
322 out.printerr("Sorry, this plugin needs open GL-enabled printmode. Try STANDARD or other non-2D.\n");
323 return CR_FAILURE;
324 }
325 string cmd=parameters[0];
326 if(cmd=="trippy")
327 {
328 removeOld();
329 installNew(new renderer_trippy(enabler->renderer),MODE_TRIPPY);
330 return CR_OK;
331 }
332 else if(cmd=="truecolor")
333 {
334 if(current_mode!=MODE_TRUECOLOR)
335 {
336 removeOld();
337 installNew(new renderer_test(enabler->renderer),MODE_TRUECOLOR);
338 }
339 if(current_mode==MODE_TRUECOLOR && parameters.size()==2)
340 {
341 rgbf red(1,0,0),green(0,1,0),blue(0,0,1),white(1,1,1);
342 rgbf cur=white;
343 rgbf dim(0.2f,0.2f,0.2f);
344 string col=parameters[1];
345 if(col=="red")
346 cur=red;
347 else if(col=="green")
348 cur=green;
349 else if(col=="blue")
350 cur=blue;
351
352 renderer_test* r=reinterpret_cast<renderer_test*>(enabler->renderer);
353 std::lock_guard<std::mutex> guard{r->dataMutex};
354 int h=gps->dimy;
355 int w=gps->dimx;
356 int cx=w/2;
357 int cy=h/2;
358 int rad=cx;
359 if(rad>cy)rad=cy;
360 rad/=2;
361 int radsq=rad*rad;
362 for(size_t i=0;i<r->lightGrid.size();i++)
363 {
364 r->lightGrid[i]=dim;
365 }
366 for(int i=-rad;i<rad;i++)
367 for(int j=-rad;j<rad;j++)
368 {
369 if((i*i+j*j)<radsq)
370 {
371 float val=(radsq-i*i-j*j)/(float)radsq;
372 r->lightGrid[(cx+i)*h+(cy+j)]=dim+cur*val;
373 }

Callers

nothing calls this directly

Calls 11

removeOldFunction · 0.85
installNewFunction · 0.85
lockGridsFunction · 0.85
resetGridsFunction · 0.85
unlockGridsFunction · 0.85
uses_openglMethod · 0.80
setHourMethod · 0.80
enable_hooksFunction · 0.70
sizeMethod · 0.45
debugMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected