MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / onRender

Method onRender

Engine/source/gui/controls/guiColorPicker.cpp:361–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
362{
363 if (mStateBlock.isNull())
364 {
365 GFXStateBlockDesc desc;
366 desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
367 desc.setZReadWrite(false);
368 desc.zWriteEnable = false;
369 desc.setCullMode(GFXCullNone);
370 mStateBlock = GFX->createStateBlock(desc);
371 }
372
373 RectI boundsRect(offset, getExtent());
374 renderColorBox(boundsRect);
375
376 if (mPositionChanged || mBitmap == NULL)
377 {
378 bool nullBitmap = false;
379
380 if (mPositionChanged == false && mBitmap == NULL)
381 nullBitmap = true;
382
383 mPositionChanged = false;
384 Point2I extent = getRoot()->getExtent();
385
386 // If we are anything but a pallete, change the pick color
387 if (mDisplayMode != pPallet)
388 {
389 Point2I resolution = getRoot()->getExtent();
390
391 U32 buf_x = offset.x + mSelectorPos.x + 1;
392 U32 buf_y = resolution.y - (extent.y - (offset.y + mSelectorPos.y + 1));
393
394 GFXTexHandle bb(resolution.x, resolution.y, GFXFormatR8G8B8A8_SRGB, &GFXRenderTargetSRGBProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__));
395
396 Point2I tmpPt(buf_x, buf_y);
397
398 GFXTarget *targ = GFX->getActiveRenderTarget();
399 targ->resolveTo(bb);
400
401 if (mBitmap)
402 {
403 delete mBitmap;
404 mBitmap = NULL;
405 }
406
407 mBitmap = new GBitmap(bb.getWidth(), bb.getHeight(),false,GFXFormatR8G8B8A8);
408
409 bb.copyToBmp(mBitmap);
410
411 if (!nullBitmap)
412 {
413 if (mSelectColor)
414 {
415 Point2I pos = findColor(mSetColor, offset, resolution, *mBitmap);
416 mSetColor = mSetColor.BLACK;
417 mSelectColor = false;
418 setSelectorPos(pos);

Callers

nothing calls this directly

Calls 13

avarFunction · 0.85
setBlendMethod · 0.80
setZReadWriteMethod · 0.80
setCullModeMethod · 0.80
createStateBlockMethod · 0.80
getExtentMethod · 0.80
getActiveRenderTargetMethod · 0.80
isNullMethod · 0.45
resolveToMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
copyToBmpMethod · 0.45

Tested by

no test coverage detected