Re: trying to do a blinking text cursor
Jack Andrews <[email protected]>
| Newsgroups | gmane.comp.lib.sdl |
|---|---|
| Message-ID | <CAJvHTNwKK2nhLLm0KBZvWMTkjHZ3o7gkkstfEVL9pY3n=M=U4w@mail.gmail.com> |
> skip rendering the cursor entirely on the blink-off phases?
So would I have a texture which is the text without the cursor, and a
texture with only cursor then
SDL_Texture ts[2];
SDL_Rect*rs[2]={NULL,&cursor_rect};
id=SDL_AddTimer(500,ontimer,(V*)1);
ie=SDL_AddTimer(500,ontimer,(V*)2);
int ontimer(V*x)
{
t=(int)x;
for(int i=0;i<t;i++)
SDL_RenderCopy(renderer,ts[i],0,rs[i]);
}
or something like that...?
On 7 August 2016 at 02:12, Chris Bush <[email protected]> wrote:
> On 6 August 2016 at 11:55, Jack Andrews <[email protected]> wrote:
>
>>
>> for the default, I'd like a browser-like blinking "I" cursor between
>> pos-1 and pos.
>>
>
> My initial thought: would it be enough to skip rendering the cursor
> entirely on the blink-off phases?
>
> If you just want to invert the render draw color for a rect, would
> something like this work?
>
> Uint8 r, g, b, a;
> SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
> SDL_SetRenderDrawColor(renderer, 255 - r, 255 - g, 255 - b, a);
>
> Since the rect only defines the draw area, you'd want to update the render
> draw color.
>
> If your cursor is a fancy image or something, you may want to store an
> inverted version and alternate between on and off.
>
> Getting into fancier territory (altering pixels under the rect, etc.),
> follow Jonathan's lead.
>
> Hope this helps.
>
> CB
>
>
> _______________________________________________
> SDL mailing list
> [email protected]
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org