Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: rbSFML  (Read 139452 times)

0 Members and 4 Guests are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: rbSFML
« Reply #135 on: April 01, 2012, 09:53:37 am »
Nice :)
Laurent Gomila - SFML developer

vivo

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Email
Re: rbSFML
« Reply #136 on: April 18, 2012, 01:07:44 pm »
Hello all, first I'd like to thank all you for your effort within this project.

I'm completely newbie with SFML but I'm going to try to develop some king of engine for adventure games, 2D and as simple as possible. If the project makes sense i'll post any progress.

Well, I was just introducing my self.
Installing rbSFML was rough, now at now I've finally made it thanks to Groogy's Installation guide (Linux).
Not sure, but i think I still have some errors, dont know if are normal errors or maybe are related with the instalation I made:

Code: [Select]
Loaded 'sfml/system'
Loaded 'sfml/window'
Loaded 'sfml/graphics'
Loaded 'sfml/audio'
Loaded suite /usr/local/bin/rake
Started
EEF.FEE..............EEE....EEE........FEF
Finished in 0.848552 seconds.

  1) Error:
test_compare(TestClock):
NoMethodError: undefined method `>' for SFML::Clock(0.100312s):SFML::Clock
    test/System/Clock.rb:49:in `test_compare'

  2) Error:
test_elapsed_time(TestClock):
TypeError: can't convert Fixnum into SFML::Time
    test/System/Clock.rb:30:in `test_elapsed_time'

  3) Failure:
test_equal(TestClock) [test/System/Clock.rb:15]:
<SFML::Clock(0.200389s)> expected but was
<SFML::Clock(0.200430s)>.

  4) Failure:
test_inspect(TestClock) [test/System/Clock.rb:23]:
Expected /SFML::Clock\(\d+ms\)/ to match "SFML::Clock(0.000000s)".

  5) Error:
test_reset(TestClock):
TypeError: can't convert Fixnum into SFML::Time
    test/System/Clock.rb:35:in `test_reset'

  6) Error:
test_subclass(TestClock):
TypeError: can't convert Fixnum into SFML::Time
    test/System/Clock.rb:66:in `test_subclass'

  7) Error:
test_initialization3(TestVector2):
TypeError: Did not receive expected types ( 'Fixnum', 'Float' )
    test/System/Vector2.rb:24:in `initialize'
    test/System/Vector2.rb:24:in `new'
    test/System/Vector2.rb:24:in `test_initialization3'

  8) Error:
test_inspect(TestVector2):
TypeError: Did not receive expected types ( 'Fixnum', 'Float' )
    test/System/Vector2.rb:56:in `initialize'
    test/System/Vector2.rb:56:in `new'
    test/System/Vector2.rb:56:in `test_inspect'

  9) Error:
test_operators(TestVector2):
TypeError: Did not receive expected types ( 'Fixnum', 'Float' )
    test/System/Vector2.rb:35:in `initialize'
    test/System/Vector2.rb:35:in `new'
    test/System/Vector2.rb:35:in `test_operators'

 10) Error:
test_initialization3(TestVector3):
TypeError: Did not receive expected types ( 'Fixnum', 'Float' )
    test/System/Vector3.rb:28:in `initialize'
    test/System/Vector3.rb:28:in `new'
    test/System/Vector3.rb:28:in `test_initialization3'

 11) Error:
test_inspect(TestVector3):
TypeError: Did not receive expected types ( 'Fixnum', 'Float' )
    test/System/Vector3.rb:62:in `initialize'
    test/System/Vector3.rb:62:in `new'
    test/System/Vector3.rb:62:in `test_inspect'

 12) Error:
test_operators(TestVector3):
TypeError: Did not receive expected types ( 'Fixnum', 'Float' )
    test/System/Vector3.rb:41:in `initialize'
    test/System/Vector3.rb:41:in `new'
    test/System/Vector3.rb:41:in `test_operators'

 13) Failure:
test_subclass(TestVideoMode) [test/Window/VideoMode.rb:100]:
Expected SFML::VideoMode(1366x768, 24-bits) to be an instance of TestVideoMode::MyVideoMode, not SFML::VideoMode.

 14) Error:
test1(TestWindow):
NoMethodError: undefined method `opened?' for SFML::Window(0x92367d0):SFML::Window
    test/Window/Window.rb:10:in `test1'

 15) Failure:
test_exceptions(TestWindow) [test/Window/Window.rb:38]:
[TypeError] exception expected, not
Class: <RuntimeError>
Message: <"SFML::Window can not be copied!">
---Backtrace---
test/Window/Window.rb:38:in `initialize_copy'
test/Window/Window.rb:38:in `initialize_dup'
test/Window/Window.rb:38:in `dup'
test/Window/Window.rb:38:in `block in test_exceptions'
---------------

42 tests, 374 assertions, 4 failures, 11 errors, 0 skips

Test run options: --seed 49933
/usr/local/bin/rake: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:002474 d:002474 TOP   
---------------------------

-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.1.9(rb_vm_bugreport+0xa5) [0xe1cfb5]
/usr/local/lib/libruby.so.1.9(+0xa85e9) [0xd005e9]
/usr/local/lib/libruby.so.1.9(rb_bug+0x28) [0xd00698]
/usr/local/lib/libruby.so.1.9(+0x156088) [0xdae088]
[0xa4a40c]
/usr/lib/libX11.so.6(_XSend+0x14c) [0x626dec]
/usr/lib/libX11.so.6(_XReply+0x60) [0x626f90]
/usr/lib/libX11.so.6(XSync+0x67) [0x61a867]
/usr/lib/fglrx/libGL.so.1(+0x4b205) [0x43b205]
[0x5600001]
/usr/lib/fglrx/dri/fglrx_dri.so(+0x15e6f3a) [0x3a53f3a]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html



« Last Edit: April 19, 2012, 06:02:34 pm by Laurent »

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: rbSFML
« Reply #137 on: April 19, 2012, 02:38:26 pm »
When trying to compile rbSFML on windows I get this message:
Code: [Select]
sh.exe"-3.1$ rake
Creating sfml/system.so
Creating sfml/window.so
Compiling ext/Graphics/Font.cpp
ext/Graphics/Font.cpp: In function 'VALUE rbFont::LoadFromStream(VALUE, VALUE)':
ext/Graphics/Font.cpp:133: error: cannot declare variable 'stream' to be of abstract type 'rbInputStream'
ext/InputStream.hpp:31: note:   because the following virtual functions are pure within 'rbInputStream':
include/SFML/System/InputStream.hpp:59: note:   virtual sf::Int64 sf::InputStream::read(char*, sf::Int64)
rake aborted!
Command failed with status (1): [g++  -O3 -fno-omit-frame-pointer -g -Wextr...]

Tasks: TOP => default => all => graphics
(See full trace by running task with --trace)

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: rbSFML
« Reply #138 on: April 19, 2012, 04:46:10 pm »
Alright the first problem looked like you were trying to run the tests? I haven't implemented tests for the release candidate yet so don't depend on it to check that it works. If it's tests you have implemented yourself then please send them to me to have a look at.

And the second problem with rbSFML not compiling were probably that you didn't have the latest version of rbSFML and the latest version of SFML. (I think I have forgotten to update the SFML version on the README I'll check it out now).
Just make sure you have the latests of both and it will work ;)

Thank you guys and keep on coming in with these reports. Whenever you create anything in rbSFML I am interested to see it so create a thread here in the ruby forum and tell me about it. It will inspire me to make rbSFML even better!
« Last Edit: April 19, 2012, 04:49:10 pm by Groogy »
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: rbSFML
« Reply #139 on: April 19, 2012, 05:36:34 pm »
First of all: Thank you for the quick answer!
I completely deleted what i had before, redownloaded rbSFML and SFML2 and now it compiles without problems. The "rake test" and "rake samples" both fail to run though, and even the program you posted crashes:
Code: [Select]
sh.exe"-3.1$ ruby test.rb
Failed to create texture, invalid size (0x0)
Failed to create texture, invalid size (0x0)
Trying to access the pixels of an empty image
Failed to create texture, invalid size (0x0)
Trying to access the pixels of an empty image
test.rb:11:in `initialize': Failed to create texture, invalid size (0x0) (SFML::Error)
        from test.rb:11:in `new'
        from test.rb:11:in `<main>'
When I delete the lines causing the crash the program runs but I only get pink squares instead of text and similar errors.
Is it possible that it doesn't work because I've used the Ruby installer to get ruby?

In case it's relevant the outputs of the rake test thingies ("rake samples" show a "program crashed" dialog right before the last line):
Code: [Select]
sh.exe"-3.1$ rake test
Loaded 'sfml/system'
Loaded 'sfml/window'
Loaded 'sfml/graphics'
Loaded 'sfml/audio'
rake aborted!
uninitialized constant SFML::Graphics

Tasks: TOP => test
(See full trace by running task with --trace)
sh.exe"-3.1$ rake samples
c:/Ruby193/bin/ruby.exe sound.rb
canary.wav:
  SFML::Time(0.005756s) seconds
  11025 samples / sec
sound.rb:22:in `play_sound'c:/Ruby193/bin/ruby.exe window.rb
c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- opengl (LoadError)
        from c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from window.rb:11:in `<main>'

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: rbSFML
« Reply #140 on: April 19, 2012, 05:41:37 pm »
The test and samples rake targets are not updated yet to the release candidate so they won't work. I'll work on the documentation first.

And the test sample I gave here didn't work? I'll look into it and see if I made a bobo somewhere.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: rbSFML
« Reply #141 on: April 19, 2012, 06:01:51 pm »
This is really weird, I haven't changed anything here. This should work. Just to be sure I checked so the SFML examples worked and they do. I have no idea.

I don't get an error response but I do get error results(text works but sprite isn't shown and no error message is written.)
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: rbSFML
« Reply #142 on: April 19, 2012, 06:07:25 pm »
The error is on my side. I just ported the sample over to C++ and get the same error. So everything is alright with rbSFML, I made a mistake installing SFML somewhere.
Thanks again.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: rbSFML
« Reply #143 on: April 19, 2012, 06:17:42 pm »
Actually the example did have a mistake in it ^^
It's fixed now. It won't fix your problem but you will be confused if you don't have this correction.

I have forgotten to add the texture to the sprite. The example is updated and fixed now.
It also made me find a mistake I had done in the sprite initialize method which has also been fixed.

If you have problems with installing SFML I can help you with that as well but you should post those questions in another forum ^^
« Last Edit: April 19, 2012, 06:24:41 pm by Groogy »
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: rbSFML
« Reply #144 on: April 19, 2012, 08:02:15 pm »
Reredownloaded and rerecompiled SFML and made sure that I replace every SFML dll I have on my machine and got it to work.
Thank you for the binding and your support!

I'll try to use this for the upcoming ludum dare. How well do small scale games in ruby perform? I've heard that ruby's garbage collection and it being a scripting language slows down real-time applications quite a bit, but for smaller projects this shouldn't really be problem, right? (Also, sorry if these questions are too off-topic. I don't really know where else to ask them.)
« Last Edit: April 19, 2012, 08:04:14 pm by Lupinius »

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: rbSFML
« Reply #145 on: April 19, 2012, 08:23:07 pm »
I'll try to use this for the upcoming ludum dare. How well do small scale games in ruby perform? I've heard that ruby's garbage collection and it being a scripting language slows down real-time applications quite a bit, but for smaller projects this shouldn't really be problem, right? (Also, sorry if these questions are too off-topic. I don't really know where else to ask them.)

Awesome I'm looking forward to seeing it!

You can start a new topic about it and I can answer all questions you have about optimizations in Ruby, benchmarks comparing to other languages, strengths of ruby versus other languages and a lot more. Anything you need to make your project work ;)

It will be awesome to see a Ludum Dare project in Ruby.

I can for instance say that I am working on making a Open Worlded RPG in Ruby. Well mostly in ruby. The OpenGL Renderer will be writtin in C++ running on it's own thread with only a small layer between it and Ruby. So most code will still be ruby code. It's currently named Ymir as in the nordic mythological giant which body was used to create the world ;)
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

vivo

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Email
Re: rbSFML
« Reply #146 on: April 19, 2012, 09:04:32 pm »
I've tried your sample and its ok for me too. But later I changed the code as you will see in order to load the texture from a file:

require 'sfml/system'
require 'sfml/window'
require 'sfml/graphics'

window = SFML::RenderWindow.new( [ 800, 600 ], "Test" )

text = SFML::Text.new( "Hello World!" )
text.color = [ 255, 0, 255 ]
text.position = [ 10, 10 ]
image = SFML::Image.new( 100, 100, SFML::Color::White )

#this works
texture = SFML::Texture.new("cute_image.jpg")

#this doesn't
#texture = SFML::Texture.new();
#texture.loadFromFile("cute_image.jpg")

sprite = SFML::Sprite.new( texture )
sprite.origin = [ 50, 50 ]
texture.update( image )

while window.open?
  window.clear
  window.draw text
  window.draw sprite
  window.display
 
  sprite.position = SFML::Mouse.position( window )
 
  window.each_event do |event|
    if event.type == SFML::Event::Closed
      window.close
    end
  end
end
 


As you can see I firstly tried with the "loadFromFile" method (following the SFML 2.0 documentation) but It gave me the following error:

vivo@ubuntu:~/Escritorio/proyectoAG/primer_juego$ ruby groogy_sample.rb
groogy_sample.rb:19:in `<main>': undefined method `loadFromFile' for SFML::Sprite(0x969ff30):SFML::Sprite (NoMethodError)
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server "X�1   ��&"
      after 119 requests (118 known processed) with 0 events remaining.
vivo@ubuntu:~/Escritorio/proyectoAG/primer_juego$ vi groogy_sample.rb
vivo@ubuntu:~/Escritorio/proyectoAG/primer_juego$ ruby groogy_sample.rb
groogy_sample.rb:17:in `<main>': undefined method `loadFromFile' for SFML::Texture(0x0, 0x98cec98):SFML::Texture (NoMethodError)


Then I tried succesfully loading it using its class constructor and it worked, so I guess you made some changes for ruby.
I know you are working on it, but is there any kind of documentation about this changes? or not yet?

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: rbSFML
« Reply #147 on: April 19, 2012, 09:24:07 pm »
I'm currently working on the documentation. And this is just a little mistake on my side. I forgot to add the SFML aliases for the texture class. Keep giving me errors like this. There will probably be a lot of them.

A fix is already up for this problem :)
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

vivo

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Email
Re: rbSFML
« Reply #148 on: April 19, 2012, 09:43:39 pm »
Documentation will be great

Ok, then count on me for at least next two mounths, im going to work on rbSFML and i will report almost everything (found) :)

I've noticed that exception errors are not controlled, i will report them too

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: rbSFML
« Reply #149 on: April 19, 2012, 09:44:06 pm »
Just downloaded that fix. You seem to have a typo ;)
Code: [Select]
sh.exe"-3.1$ ruby main.rb
c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': undefined method `load_from_tream' for class `SFML::Texture' (NameError)
        from c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from main.rb:1:in `<main>'
Either that or I suck at downloading again.