News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
segmentation fault while using fltk??
Author Message
jyf1987
Member
***


Posts: 58
Group: Registered
Joined: Jun 2008
Status: Offline
Reputation: 0
Post: #1
segmentation fault while using fltk??

this is my test code to use fltk
the problem is when i add
fltk.fl_circle(110,100,50)

this will make a segmentation fault!
if remove this ,the script works well,so how to solve it?

ps:the problem both occur at win/lin
and other simple draw method will occur this too,


the code:[/code]

Code:
ww=220
wh=200

math.randomseed(os.time())

w=fltk:Fl_Window(ww,wh,"my fltk demo")
b=fltk:Fl_Box(2,2,218,198)
b:color(fltk.FL_WHITE)
b:box(fltk.FL_FLAT_BOX)



fltk.fl_circle(110,100,50)


w:show()
Fl:run()


Cheers
jyf
08-16-2008 03:54 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #2
RE: segmentation fault while using fltk??

all drawing functions require that you make_current the window on which you want to draw, and in some cases you may need to also set the font and color.

You should refer to the drawing examples provided with the murgaLua distibution, and you might need to play around a bit. If I recall correctly, most of the drawing things I've tried have also required the drawing functions to be put inside a function.

08-16-2008 12:29 PM
Find all posts by this user Quote this message in a reply
jyf1987
Member
***


Posts: 58
Group: Registered
Joined: Jun 2008
Status: Offline
Reputation: 0
Post: #3
RE: segmentation fault while using fltk??

but i want to draw things when the window load,so which function should i put inside the draw action?


Cheers
jyf
08-16-2008 02:16 PM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #4
RE: segmentation fault while using fltk??

I did this very thing not long ago, and it required some poking before I came up with something that worked. Eventually found it needed to be drawn before Fl:run for some reason, which required a flush and a check. I never quite understood exactly what was happening, but this was the only way it would draw when the window itself was drawn:

Code:
my_window:show()
Fl:flush() -- these two lines are necessary to draw before run() is called
Fl:check()
my_drawing_function()
Fl:run()


The code is shown in practice in the beta4 version of the murgaLua demos package (test-lcd_numbers.lua)
http://www.murga-projects.com/forum/atta...php?aid=40

08-16-2008 11:19 PM
Find all posts by this user Quote this message in a reply
jyf1987
Member
***


Posts: 58
Group: Registered
Joined: Jun 2008
Status: Offline
Reputation: 0
Post: #5
RE: segmentation fault while using fltk??

it's true,thank u very much


Cheers
jyf
08-17-2008 11:16 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: