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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - garthos

Pages: [1]
1
General discussions / Re: Installing SFML 2.0 on linux for dummies
« on: December 16, 2012, 11:13:28 am »
I used the sfml2 cmake tutorials and found this was all I needed.
Infact I liked cmake so much I went on to install sfml2 sfml1.6 thor1.1 thor2

I did stumbled with the static libraries for sfml2. I compiled them fine.
But run out of puff when configuring code blocks. It look like I had to add each of those additional dependencies one by one to codeblocks build options. For each project. No thanks. Maybe at release time but not as curiosity.





2
Graphics / tearing using kubuntu nvidia
« on: December 16, 2012, 10:43:23 am »
Hi,

I've been experiencing pretty bad tearing when moving my sprites around the screen. From reading the forums and the documentation I've checked my code and played with my framerates and vsync to no avail.
I was able to reproduce the tearing writing a basic program.

I didn't notice the tearing when using windows7-64 sfml1.6 but have noticed now since using
KDE desktop for ubuntu 12.04 and sfml2. (and an older Pentium4 computer).

Loathing to try different gfx drivers (currently using nvidia 304.43 geforce 7600gt) without knowing in advance what will work. I moved onto gnome3 shell as this has resolved 99% of the tearing.

So my question is to the other linux/ubuntu users using nvdia gfx card what desktop are you using and have you had similar tearing issues with KDE? what were your solutions?



3
Can you confirm whether move should also use whole numbers?
For example I am currently doing this. If I understood this correctly I shouldn't tell it to move 2.568 pixels.
I should either round it to 2 or 3.
 
 
 float moveAmount = _velocity  * elapsedTime.asSeconds();
   GetSprite().move(moveAmount, 0);


4
Thanks again, sanity back in check ;)

Interesting, I'm guessing rasterization issues can exist in other (rendering) methods and not specifically to setOrigin. Obviously I need to take greater care when using floats.

Without having a complete grasp of which methods these are, whats the rule of thumb here ?
Do I need to identify these methods in SFML one by one or is there a better approach ?

edit.
Actually, I am the one creating the decimal point by dividing height by 2. SFML rendering floats are whole numbers? So I need not to worry whether my floats are a decimal unless I have specifically modified it. Would that be correct?


5
Graphics / Re: So close ...I just need a little push please :3
« on: November 29, 2012, 09:25:37 pm »
Is correct because you aren't using pointers, you're using references. (They are C++'s way of passing things around. Essentially they are hidden pointers)

lol, when I learn't about pointers and references I worked out they did pretty much the same thing, with references having some restrictions on them. I also learn't that pointers were harder to use. Not being sure which one to use in which case I opted to learn pointers because I could always use a pointer instead of a reference.

So I have found myself in bad habit of only using pointers. I have often read that if a reference is suitable you should use that.

Had my c++ book had mentioned that pointers were the original C way of doings things and references were the C++ way I would have understood the relationship between the two so much better. Thank you for sharing that.

6
Thank you. That works a treat.

Text.setOrigin( floor(Text.getLocalBounds().width /2) , floor(Text.getLocalBounds().height /2 ));

But I do have to ask why? just for my own sanity.

My problem was caused by using a decimal place in setOrigin(155,23.5);
setOrigin accepts two float parameters, and I understood the float type caters for decimal places.
What am I missing here? I am confused.

Lastly, what do you mean by "artifacts". Does that mean sf::Text only or does this apply to sprites and shapes as well ?



 

7
Hello again,

I have replicated my problem below.
I have tried using both getLocalBounds and getGlobalBounds to no avail.
As you can see the stray pixel appears above the G in Game Over. (Screen shot attached.)
If I remove setOrigin line the stray pixel is removed.

I understand getGlobalBounds is using a rectangle and my text is well text.
If this is the problem can you suggest what method I should be using to find the centre of my Text?

Many thanks in advance.

int main()
{
        //Game::Start();

     sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
     sf::Font font;
     if (!font.loadFromFile("images/Arial.ttf"))
         return EXIT_FAILURE;

    sf::Text Text ( "Game Over", font, 60);

    //Text.setOrigin( Text.getLocalBounds().width /2 , Text.getLocalBounds().height /2 );
        Text.setOrigin( (Text.getGlobalBounds().width /2) , (Text.getGlobalBounds().height /2 ));
        Text.setPosition(400,300);

     while (window.isOpen())
     {
        window.draw(Text);
        window.display();
     }
    return 0;
}
 



[attachment deleted by admin]

8
Audio / Re: Audio Issue
« on: October 27, 2012, 09:40:06 am »
I'm still learning the audio library myself, and are using 1.6 not 2, but heres my 2 cents.

A trap I seem to fall into is not giving the sound any time to play. I assume it goes out of scope before it has played. So you need a loop to keep it alive after calling .Play()

while (mySound.GetStatus() == sf::Sound::Playing)
    {
        // Display the playing position
       // std::cout << "\rPlaying... " << std::fixed << soundSprite.GetPlayingOffset() << " sec\n";
       // Leave some CPU time for other threads
        sf::Sleep(0.1f);
    }

This is a better description quoted from http://en.sfml-dev.org/forums/index.php?topic=6342.0
No you don't need this loop to play the sound, it is played in a separate thread so the main one can do whatever it wants.
You just need to make sure that the instance lives as long as you're playing it. If it is destroyed before, obviously the music will stop ;)

9
Phew, You have saved me from spending any more time with Dependency Watcher and messing up my DLL's <sigh of relief>.

in regards to missing code, I commented it out as it was originally hanging like this (I have changed .wav file now).

sound.wav :
 0.370068 sec
 11025 samples / sec
 1 channels
Playing... 0.00 sec

But after reading your reply I put it back in. It failed, like above. But then worked when running it a second time. After some playing around, trying to break it again so I could find the problem. It was my Comodo Firewall sand boxing it.
Not sure why this stops it from working, as my other SFML graphics library projects work fine sand boxed.

Oh well, Comodo Firewall users beware.

p.s.
 :-[ with that said, I didn't realize I needed the extra code. I will have to go back to the tutorials to see how I missed that.

Thank you for your time.

10
Audio / Stumped, unable to make the simpliest of sounds play - no error
« on: October 20, 2012, 04:43:27 pm »
Hi,
I am having trouble getting any sound with your tutorial code to work. I am using code::blocks 10.05, sfml 1.6 on win7-64. Its the first time I have used the audio library. But I have got another tutorial too work playing sound and music. Kaboom.wav is actually from that tutorial and plays in windows media player fine.
http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition-Part-9.aspx

#include <SFML/Audio.hpp>
#include <iomanip>
#include <iostream>

int main()
{
    // Load a sound buffer from a wav file
    sf::SoundBuffer Buffer;
    if (!Buffer.LoadFromFile("kaboom.wav"))
    {
        std::cout << "unable to load file\n";
        return EXIT_FAILURE;
    }

    // Display sound informations
    std::cout << "sound.wav :" << std::endl;
    std::cout << " " << Buffer.GetDuration()      << " sec"           << std::endl;
    std::cout << " " << Buffer.GetSampleRate()    << " samples / sec" << std::endl;
    std::cout << " " << Buffer.GetChannelsCount() << " channels"      << std::endl;

    // Create a sound instance and play it
    sf::Sound sound(Buffer);
    sound.Play();

output
sound.wav :
 4.97952 sec
 48000 samples / sec
 2 channels

Process returned 0 (0x0)   execution time : 0.454 s
Press any key to continue.

No sound played. No errors when compiling or at runtime.

I have placed these files with my executable and with my .cpp code.
audio-sound.exe (my executable).
libgcc_s_dw2-1.dll
libsndfile-1.dll
sfml-audio.dll
sfml-graphics.dll
sfml-network.dll
sfml-system.dll
sfml-window.dll

I have these files in order in my build options -> linker options -> other options.
-lsfml-audio
-lsfml-graphics
-lsfml-window
-lsfml-system

any ideas?

Pages: [1]