Author Topic: LaserBoy in FLTK  (Read 36439 times)

0 Members and 1 Guest are viewing this topic.

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
LaserBoy in FLTK
« on: September 11, 2009, 02:44:07 am »
I just wanted to drop in a word or two about the current development of LaserBoy.

As some of you know, I am working on porting LaserBoy from SDL over to FLTK.

So far, I have created a double project. That is to say, I have two targets defined in my Makefile. LaserBoy (in Linux; LaserBoy.exe in Windows) is the usual SDL version and LaserBoy_FLTK is the FLTK version. So, now when I build all of the project, I get both executables.

I am doing all of my new development on a Windows 2000 machine with my Linux Laptop next to me. From it, I have mounted my shared Windows LaserBoy folder and I am building the executables in Linux from the excact same code.

I still have not figured out all of the weird ways of FLTK events and the FLTK event loop. And I still haven't found adequate replacements for some of the SDL timing mechanisms, like SDL_Delay() or SDL_GetTicks(). And I haven't figured out how to wait for a key tap and then go on... or how to listen for a key tap and stop!

But, I have gotten LaserBoy Space to display properly in a FLTK window and I can even press and hold the arrow keys and they do what they are supposed to do!

So it looks like I am moving in the right direction.

James.  :)
« Last Edit: September 11, 2009, 03:04:12 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline drlava

  • Sr. Member
  • ****
  • Posts: 314
  • Milliwatts: 18
    • View Profile
Re: LaserBoy in FLTK
« Reply #1 on: September 11, 2009, 12:31:39 pm »
The FLTK event loop is built-in and runs in the background when you execute Fl::run(); after the GUI windows are created.  You can ovverride the built-in event loop and make your own which repeatedly calls Fl::check() among doing other things.  I think keyboard events are trapped automatically.
In fluid, each window runs its callback when the x button is clicked, so you must put the o->hide(); in there.
Each button/control has initialization code space in fluid and it callback area is in fluid also. 
For keypresses and (gasp) mouse events look at the window's handle() method in the fltk manual.  :)


It's a great system once you get the hang of it.

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: LaserBoy in FLTK
« Reply #2 on: September 11, 2009, 05:43:29 pm »
I inherited from Fl_Double_Window into my top level LaserBoy_FLTK_GUI class.

So it is-a Fl_Double_Window.

I defined the function handle to intercept events.

I got that far.

It is responding to some things. It seems to be OK with a press and hold as a series of key down events, however when I make the window larger than a certain size, it stops redrawing itself. It draws once on the key down and once on the key up and whatever happed in between, you didn't see.

James.  :)
« Last Edit: September 11, 2009, 05:46:03 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline drlava

  • Sr. Member
  • ****
  • Posts: 314
  • Milliwatts: 18
    • View Profile
Re: LaserBoy in FLTK
« Reply #3 on: September 11, 2009, 07:33:43 pm »
FLTK only redraws when it thinks it's absolutely necessary.  For some things like images they only redraw if you tell them to.  For these cases, you need to just call the redraw() method for the things that need to be redrawn.  For example, ->redraw() can be done every time after the processing is done after a key capture in your main loop.

ILD SOS does not have a main loop.

Again, please use fluid.  ILD SOS has over 4700 lines of code for the GUI sections alone and going through that without fluid would be a nightmare.

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: LaserBoy in FLTK
« Reply #4 on: September 11, 2009, 07:49:11 pm »
4,700 lines of code..... HAH!  %)

LaserBoy_TUI and LaserBoy_SDL_GUI constitute the text user interface and its event loop for SDL.

The code that defines these two classes is well over 12,000 lines of hand written ASCII, with no visual management at all!

This has nothing to do with the inner workings of the LaserBoy_Space class that contains and manages all of the 3D color vector art.

Run it. Test it. Fix it. Run it. Test it. Fix it. Run it. Test it. Fix it. Run it. Test it. Fix it.  ;D

There's really no point in me using FLUID yet. At the moment, I'm just trying to replace SDL with FLTK. There are no visual objects in my window yet.... except for the window and a box that is the same size where I can blast my bitmap.

James.  :)
« Last Edit: September 11, 2009, 11:50:10 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline drlava

  • Sr. Member
  • ****
  • Posts: 314
  • Milliwatts: 18
    • View Profile
Re: LaserBoy in FLTK
« Reply #5 on: September 11, 2009, 08:01:08 pm »
.. and they are a pain to go through what's your point?..

If you did it in fluid, think about this: adding a file, open dialog would be a snap, along with a full menu on top.  And you should be thinking about having many laserboy spaces (windows) in (or with) one GUI window.

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: LaserBoy in FLTK
« Reply #6 on: September 11, 2009, 08:11:22 pm »
I guess I move like a giant turtle when it comes to that.

I think I know where I am right now and I'm pretty comfortable with the idea of moving forward from here.

I should probably forget about the SDL code, that I already have, that reads the keyboard and just start off by making the whole GUI in FLUID and connecting it to the innards of LaserBoy_Space.

I still think it would be cool to maintain the keyboard responce and just add a GUI on top of that.

I guess you had a kind of advantage in that you started your project in FLTK!

LaserBoy has never been in a true windowing, event-driven, environment.

SDL can be a lot like the Linux console.

James.  :)
« Last Edit: September 11, 2009, 08:16:39 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline Fanny Pack

  • Hero Member
  • *****
  • Posts: 645
  • Milliwatts: -20
  • Gender: Male
    • View Profile
Re: LaserBoy in FLTK
« Reply #7 on: September 11, 2009, 08:50:03 pm »
Spaghetti only has 2 lines of GUI code.  The rest of the code turns your computer into a porn server.  The rest is built into .NET.

Offline meandean

  • Sr. Member
  • ****
  • Posts: 466
  • Milliwatts: 13
  • It's about sight AND sound.
    • View Profile
Re: LaserBoy in FLTK
« Reply #8 on: September 11, 2009, 11:41:54 pm »
Quote
Spaghetti only has 2 lines of GUI code.  The rest of the code turns your computer into a porn server.  The rest is built into .NET.

 Man... That's deep!!!
"Patience is for the dead."

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: LaserBoy in FLTK
« Reply #9 on: September 11, 2009, 11:45:21 pm »
I'm just wondering if the porn server serves the porn it finds on the computer it is installed on, or what?

That could be interesting!  ;)

James.  :)
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: LaserBoy in FLTK
« Reply #10 on: September 11, 2009, 11:54:22 pm »
.. and they are a pain to go through what's your point?..

I must like that kind of pain.  %)

James.  :)
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: LaserBoy in FLTK
« Reply #11 on: September 12, 2009, 12:46:28 am »
I think I'm starting to get this well enough to completely miss the point and work around the whole thing!  ;D

Given enough time, I bet I could get the most sophisticated windows widgets set to look like a command prompt!  %)

I've almost got this 2.5HP Briggs and Stratton lawn mower engine fitted into this Mazarotti.  8)

James.  :)
« Last Edit: September 12, 2009, 12:48:24 am by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline drlava

  • Sr. Member
  • ****
  • Posts: 314
  • Milliwatts: 18
    • View Profile
Re: LaserBoy in FLTK
« Reply #12 on: September 12, 2009, 01:29:23 am »
sounded like you were getting the right idea up on post 6.  You've got to let go of the idea of laserboy being the master and let FLTK own it and slap it around a little.

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: LaserBoy in FLTK
« Reply #13 on: September 12, 2009, 01:43:39 am »
We'll see who's the boss!

I think I can work this in the right direction.

It is going to take a lot of work and too many LaserBoy releases to even bother to guess at a number!  :P

But, trust me. I will break FLTK and it will be my bitch.  8)

James.  :)
« Last Edit: September 12, 2009, 01:58:07 am by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.7 © 2008-2024, SimplePortal