PDA

View Full Version : How to Clip Scrolling Text



BigBMan
03-09-2011, 07:41 AM
You say that clipping a scroll text area is slow on Android. Any chance you could share the implementation with us so we can try it out (I obviously don't care about Android right now)? Trying to clip the bottom and top of a scroll area.

Seth
03-09-2011, 01:23 PM
Sure - there is a commented out example in RTSimpleApp/source/GUI/AboutMenu.cpp

Find this part:


/*
//this is one way to clip the image on the bottom - glClipPlane is too slow/broken on Android so we actually won't use it
EntityComponent *pClip = pScroll->AddComponent(new RenderClipComponent);
pClip->GetVar("clipMode")->Set(uint32(RenderClipComponent::CLIP_MODE_BOTTOM)) ;
*/

//another way would be to just blit a colored bar over the bottom:
//pEnt = CreateOverlayRectEntity(pBG, CL_Rectf(0, GetScreenSizeYf()-offsetFromBottom, GetScreenSizeXf(), 320),

MAKE_RGBA(0,0,0,100));

//but the nicest way is to blit a matching bar at the bottom with transparency:
Entity *pOverlay = CreateOverlayEntity(pBG, "", "interface/bg_stone_overlay.rttex", 0, GetScreenSizeYf()+1);
SetAlignmentEntity(pOverlay, ALIGNMENT_DOWN_LEFT);

And change to:



//this is one way to clip the image on the bottom - glClipPlane is too slow/broken on Android so we actually won't use it
EntityComponent *pClip = pScroll->AddComponent(new RenderClipComponent);
pClip->GetVar("clipMode")->Set(uint32(RenderClipComponent::CLIP_MODE_BOTTOM)) ;


//another way would be to just blit a colored bar over the bottom:
//pEnt = CreateOverlayRectEntity(pBG, CL_Rectf(0, GetScreenSizeYf()-offsetFromBottom, GetScreenSizeXf(), 320), MAKE_RGBA(0,0,0,100));
/*
//but the nicest way is to blit a matching bar at the bottom with transparency:
Entity *pOverlay = CreateOverlayEntity(pBG, "", "interface/bg_stone_overlay.rttex", 0, GetScreenSizeYf()+1);
SetAlignmentEntity(pOverlay, ALIGNMENT_DOWN_LEFT);
*/

Also, you'll have to add shared/entity/RenderClipComponent.cpp to your project.

You should be able to run RTSimpleApp, click on About, and see the scroller cut off at the bottom.

On Windows, you can add more RenderClipComponents and say, cut off the top or sides too, but on iOS I think the GLES driver limits you to just one (glClipPlane) at a time.

BigBMan
03-12-2011, 10:59 PM
ah, but I won't be able to clip the top and bottom without overlaying an image (a GLES constraint)... bummer. Oh well, thanks for your help though!