Hi, I am making a game with Ruby/SDL and have run into trouble finding a GUI to cooperate. I have seen numerous examples of wxWindows in combination with SDL (wxPython and PyGame), but have yet to be able to do it in ruby (PyGame example: http://wiki.wxpython.org/index.cgi/IntegratingPyGame). I am not very good with wxRuby as this is my first time using it and thought some more knowledgable users could help me out. Thanks! Steve
Hello Steve, I''ve taken a stab at making Ruby/SDL work with wxRuby. The short answer is, you can''t (easily) make it work with 0.9.4 of Ruby/SDL. I''m attempting to compile 0.9.5 but there''s no makefile for it. The issue is that in order to make SDL live in an existing window you have to set an environment variable. Sadly, setting the environment variable in Ruby doesn''t cause it to be available to SDL. 0.9.5 has a putenv function that should allow for setting the environment variable. Frankly, having to set your windowID as an environment variable seems like the most backwards way of specifying it. Also, I will have to submit a patch to Window.i for wxRuby2 as get_handle doesn''t return a value you can use. Roy Steven Davidovitz wrote:> Hi, > I am making a game with Ruby/SDL and have run into trouble finding a GUI > to cooperate. I have seen numerous examples of wxWindows in combination > with SDL (wxPython and PyGame), but have yet to be able to do it in ruby > (PyGame example: http://wiki.wxpython.org/index.cgi/IntegratingPyGame). > I am not very good with wxRuby as this is my first time using it and > thought some more knowledgable users could help me out. > > Thanks! > Steve
Very cool. I was wondering if the patch was applied in the latest CVS as I have Ruby/SDL 0.9.5 installed (Gentoo) and could test out the code. Thanks, Steve Roy Sutton wrote:>Hello Steve, > >I''ve taken a stab at making Ruby/SDL work with wxRuby. The short answer >is, you can''t (easily) make it work with 0.9.4 of Ruby/SDL. I''m >attempting to compile 0.9.5 but there''s no makefile for it. The issue >is that in order to make SDL live in an existing window you have to set >an environment variable. Sadly, setting the environment variable in >Ruby doesn''t cause it to be available to SDL. 0.9.5 has a putenv >function that should allow for setting the environment variable. >Frankly, having to set your windowID as an environment variable seems >like the most backwards way of specifying it. > >Also, I will have to submit a patch to Window.i for wxRuby2 as >get_handle doesn''t return a value you can use. > >Roy > >Steven Davidovitz wrote: > > >>Hi, >>I am making a game with Ruby/SDL and have run into trouble finding a GUI >>to cooperate. I have seen numerous examples of wxWindows in combination >>with SDL (wxPython and PyGame), but have yet to be able to do it in ruby >>(PyGame example: http://wiki.wxpython.org/index.cgi/IntegratingPyGame). >>I am not very good with wxRuby as this is my first time using it and >>thought some more knowledgable users could help me out. >> >>Thanks! >>Steve >> >> > >_______________________________________________ >wxruby-users mailing list >wxruby-users at rubyforge.org >http://rubyforge.org/mailman/listinfo/wxruby-users > > >
This is the code I was going to use. It''s not really smart but it might work! My patch to fix the get_handle for wxRuby2 isn''t applied yet. Maybe this''ll work with 0.6 if you change the require to ''wxruby''. I don''t know, I don''t have the old version installed. Roy require ''wx'' class MyFrame < Wx::Frame def initialize(title, pos, size) super(nil, -1, title, pos, size) # ENV[''SDL_WINDOWID''] = self.get_handle # ENV[''SDL_VIDEODRIVER''] = ''windib'' require ''sdl'' SDL.putenv("SDL_WINDOWID=#{self.get_handle}") SDL.putenv("SDL_VIDEODRIVER=windib") SDL.init( SDL::INIT_VIDEO ) screen = SDL::setVideoMode(size.x, size.y, 0, SDL::SWSURFACE) sred = screen.format.mapRGB(255,0,0) screen.drawAALine(20,20,300,200,sred) screen.drawAACircle(100,100,50,[87,87,87]) screen.drawAAFilledCircle(300,300,30,sred) screen.drawAAEllipse(320,240,100,200,[200,255,0]) end end class RbApp < Wx::App def on_init frame = MyFrame.new("Wx and SDL test", Wx::Point.new(50, 50), Wx::Size.new(450,340)) frame.show(TRUE) end end a = RbApp.new a.main_loop() Steven Davidovitz wrote:> Very cool. I was wondering if the patch was applied in the latest CVS as > I have Ruby/SDL 0.9.5 installed (Gentoo) and could test out the code. > > Thanks, > Steve > > Roy Sutton wrote: > > >> Hello Steve, >> >> I''ve taken a stab at making Ruby/SDL work with wxRuby. The short answer >> is, you can''t (easily) make it work with 0.9.4 of Ruby/SDL. I''m >> attempting to compile 0.9.5 but there''s no makefile for it. The issue >> is that in order to make SDL live in an existing window you have to set >> an environment variable. Sadly, setting the environment variable in >> Ruby doesn''t cause it to be available to SDL. 0.9.5 has a putenv >> function that should allow for setting the environment variable. >> Frankly, having to set your windowID as an environment variable seems >> like the most backwards way of specifying it. >> >> Also, I will have to submit a patch to Window.i for wxRuby2 as >> get_handle doesn''t return a value you can use. >> >> Roy >> >> Steven Davidovitz wrote: >> >> >> >>> Hi, >>> I am making a game with Ruby/SDL and have run into trouble finding a GUI >>> to cooperate. I have seen numerous examples of wxWindows in combination >>> with SDL (wxPython and PyGame), but have yet to be able to do it in ruby >>> (PyGame example: http://wiki.wxpython.org/index.cgi/IntegratingPyGame). >>> I am not very good with wxRuby as this is my first time using it and >>> thought some more knowledgable users could help me out. >>> >>> Thanks! >>> Steve >>> >>> >>> >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> >> >> >> > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > >
No dice. I get an X Windows Error (I had to remove the SDL_VIDEODRIVER line, because it seemed Windows specific) when I run it ("serial 45 error_code 3 request_code 3 minor_code 0"). It was a BadWindow error so it was most likely something to do with get_handle and WindowID. Steven Roy Sutton wrote:>This is the code I was going to use. It''s not really smart but it might >work! My patch to fix the get_handle for wxRuby2 isn''t applied yet. >Maybe this''ll work with 0.6 if you change the require to ''wxruby''. I >don''t know, I don''t have the old version installed. > >Roy > >require ''wx'' > >class MyFrame < Wx::Frame > def initialize(title, pos, size) > super(nil, -1, title, pos, size) > ># ENV[''SDL_WINDOWID''] = self.get_handle ># ENV[''SDL_VIDEODRIVER''] = ''windib'' > > require ''sdl'' > > SDL.putenv("SDL_WINDOWID=#{self.get_handle}") > SDL.putenv("SDL_VIDEODRIVER=windib") > > SDL.init( SDL::INIT_VIDEO ) > screen = SDL::setVideoMode(size.x, size.y, 0, SDL::SWSURFACE) > > sred = screen.format.mapRGB(255,0,0) > screen.drawAALine(20,20,300,200,sred) > screen.drawAACircle(100,100,50,[87,87,87]) > screen.drawAAFilledCircle(300,300,30,sred) > screen.drawAAEllipse(320,240,100,200,[200,255,0]) > > end >end > >class RbApp < Wx::App > def on_init > frame = MyFrame.new("Wx and SDL test", Wx::Point.new(50, 50), >Wx::Size.new(450,340)) > frame.show(TRUE) > end >end > >a = RbApp.new >a.main_loop() > >Steven Davidovitz wrote: > > >>Very cool. I was wondering if the patch was applied in the latest CVS as >>I have Ruby/SDL 0.9.5 installed (Gentoo) and could test out the code. >> >>Thanks, >>Steve >> >>Roy Sutton wrote: >> >> >> >> >>>Hello Steve, >>> >>>I''ve taken a stab at making Ruby/SDL work with wxRuby. The short answer >>>is, you can''t (easily) make it work with 0.9.4 of Ruby/SDL. I''m >>>attempting to compile 0.9.5 but there''s no makefile for it. The issue >>>is that in order to make SDL live in an existing window you have to set >>>an environment variable. Sadly, setting the environment variable in >>>Ruby doesn''t cause it to be available to SDL. 0.9.5 has a putenv >>>function that should allow for setting the environment variable. >>>Frankly, having to set your windowID as an environment variable seems >>>like the most backwards way of specifying it. >>> >>>Also, I will have to submit a patch to Window.i for wxRuby2 as >>>get_handle doesn''t return a value you can use. >>> >>>Roy >>> >>>Steven Davidovitz wrote: >>> >>> >>> >>> >>> >>>>Hi, >>>>I am making a game with Ruby/SDL and have run into trouble finding a GUI >>>>to cooperate. I have seen numerous examples of wxWindows in combination >>>>with SDL (wxPython and PyGame), but have yet to be able to do it in ruby >>>>(PyGame example: http://wiki.wxpython.org/index.cgi/IntegratingPyGame). >>>>I am not very good with wxRuby as this is my first time using it and >>>>thought some more knowledgable users could help me out. >>>> >>>>Thanks! >>>>Steve >>>> >>>> >>>> >>>> >>>> >>>_______________________________________________ >>>wxruby-users mailing list >>>wxruby-users at rubyforge.org >>>http://rubyforge.org/mailman/listinfo/wxruby-users >>> >>> >>> >>> >>> >>> >>_______________________________________________ >>wxruby-users mailing list >>wxruby-users at rubyforge.org >>http://rubyforge.org/mailman/listinfo/wxruby-users >> >> >> >> >> >> > >_______________________________________________ >wxruby-users mailing list >wxruby-users at rubyforge.org >http://rubyforge.org/mailman/listinfo/wxruby-users > > >
Ah, well, I suppose I should have pointed out it was Win32 specific. You can take what I have there and crib off the other part of the page you linked to before. Perhaps on *nix you can actually use the ENV part. Roy Steven Davidovitz wrote:> No dice. > I get an X Windows Error (I had to remove the SDL_VIDEODRIVER line, > because it seemed Windows specific) when I run it ("serial 45 error_code > 3 request_code 3 minor_code 0"). It was a BadWindow error so it was most > likely something to do with get_handle and WindowID. > > Steven > > Roy Sutton wrote: > > >> This is the code I was going to use. It''s not really smart but it might >> work! My patch to fix the get_handle for wxRuby2 isn''t applied yet. >> Maybe this''ll work with 0.6 if you change the require to ''wxruby''. I >> don''t know, I don''t have the old version installed. >> >> Roy >> >> require ''wx'' >> >> class MyFrame < Wx::Frame >> def initialize(title, pos, size) >> super(nil, -1, title, pos, size) >> >> # ENV[''SDL_WINDOWID''] = self.get_handle >> # ENV[''SDL_VIDEODRIVER''] = ''windib'' >> >> require ''sdl'' >> >> SDL.putenv("SDL_WINDOWID=#{self.get_handle}") >> SDL.putenv("SDL_VIDEODRIVER=windib") >> >> SDL.init( SDL::INIT_VIDEO ) >> screen = SDL::setVideoMode(size.x, size.y, 0, SDL::SWSURFACE) >> >> sred = screen.format.mapRGB(255,0,0) >> screen.drawAALine(20,20,300,200,sred) >> screen.drawAACircle(100,100,50,[87,87,87]) >> screen.drawAAFilledCircle(300,300,30,sred) >> screen.drawAAEllipse(320,240,100,200,[200,255,0]) >> >> end >> end >> >> class RbApp < Wx::App >> def on_init >> frame = MyFrame.new("Wx and SDL test", Wx::Point.new(50, 50), >> Wx::Size.new(450,340)) >> frame.show(TRUE) >> end >> end >> >> a = RbApp.new >> a.main_loop() >> >> Steven Davidovitz wrote: >> >> >> >>> Very cool. I was wondering if the patch was applied in the latest CVS as >>> I have Ruby/SDL 0.9.5 installed (Gentoo) and could test out the code. >>> >>> Thanks, >>> Steve >>> >>> Roy Sutton wrote: >>> >>> >>> >>> >>> >>>> Hello Steve, >>>> >>>> I''ve taken a stab at making Ruby/SDL work with wxRuby. The short answer >>>> is, you can''t (easily) make it work with 0.9.4 of Ruby/SDL. I''m >>>> attempting to compile 0.9.5 but there''s no makefile for it. The issue >>>> is that in order to make SDL live in an existing window you have to set >>>> an environment variable. Sadly, setting the environment variable in >>>> Ruby doesn''t cause it to be available to SDL. 0.9.5 has a putenv >>>> function that should allow for setting the environment variable. >>>> Frankly, having to set your windowID as an environment variable seems >>>> like the most backwards way of specifying it. >>>> >>>> Also, I will have to submit a patch to Window.i for wxRuby2 as >>>> get_handle doesn''t return a value you can use. >>>> >>>> Roy >>>> >>>> Steven Davidovitz wrote: >>>> >>>> >>>> >>>> >>>> >>>> >>>>> Hi, >>>>> I am making a game with Ruby/SDL and have run into trouble finding a GUI >>>>> to cooperate. I have seen numerous examples of wxWindows in combination >>>>> with SDL (wxPython and PyGame), but have yet to be able to do it in ruby >>>>> (PyGame example: http://wiki.wxpython.org/index.cgi/IntegratingPyGame). >>>>> I am not very good with wxRuby as this is my first time using it and >>>>> thought some more knowledgable users could help me out. >>>>> >>>>> Thanks! >>>>> Steve >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> _______________________________________________ >>>> wxruby-users mailing list >>>> wxruby-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/wxruby-users >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>> _______________________________________________ >>> wxruby-users mailing list >>> wxruby-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/wxruby-users >>> >>> >>> >>> >>> >>> >>> >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> >> >> >> > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > >