[SDL] FLTK and SDL two windows

Alvin alvinbeach at gmail.com
Sat Feb 3 15:45:05 PST 2007


On Saturday 03 February 2007 16:52:32 Taylor "Assbone" Peterson wrote:
> I'm using FLTK 1.1.x.  I'm looping FLTK with FL::run().
>
> I'm just starting to learn how to use FLTK.  This is how I have it set up:
>
> void make_window();
> main(){
> make_window();
> SDL LOOP
>
> return FL::run
> }
> void make_window(){
> FLTK STUFF
> }
>
> I'm not sure what you mean by threads and threading  '_'.
>
> Thanks,
> Taylor

The reason why nothing in the FLTK window works is that Fl::run() is being 
called after the SDL LOOP code. Try this:


void make_window();
main()
{
   make_window();

  Fl::add_check(SDL UPDATE FUNCTION);

   return FL::run;
}

void make_window()
{
   FLTK STUFF
}

Here I use SDL UPDATE FUNCTION. What this would be is one iteration of your 
SDL LOOP. Think of it as the code between the { and } of the while-loop 
statement. 

Doing it this way will have FLTK call the SDL UPDATE FUNCTION right before it 
flushes the display and checks for events (keyboard, mouse, redrawing, etc.). 
You can find the documentation for this and the rest of the FLTK API here: 
http://www.fltk.org/doc-1.1/toc.html

Now, after saying all this, I cannot say if your game with be slow or 
sluggish. It all depends on how long it takes the SDL UPDATE FUNCTION to 
execute, including any other function that it calls. FLTK will not be able to 
do anything else until your SDL UPDATE FUNCTION returns. This is why I 
suggest putting the SDL UPDATE FUNCTION in its own thread. This way FLTK and 
the SDL parts can happen independent of each other.

I believe this discussion is moving away from being SDL related and is 
becoming off topic for this list. For more FLTK information and help, check 
out the FLTK newsgroup:

Use the server: news.easysw.com in your news reader. Then subscribe to the 
fltk.general newsgroup.

Or use can use the web interface here:

http://www.fltk.org/newsgroups.php

The newsgroup is very active and there are lots of people that would be 
willing to help. I frequent it every day. :)

Alvin


More information about the SDL mailing list