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 - zakkor

Pages: 1 [2]
16
Graphics / Vertex Array using individual textures?
« on: June 02, 2014, 07:47:42 pm »
I implemented a small top-down tilebased game using individual textures and sprites to draw the map, and now I'm experiencing poor performance due to the large amount of draw calls (I'm guessing that's what it is.)
Looking at the vertex array tutorial (http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php) I can see that it uses a tileset. If I were to implement a tileset, I think i would need to rewrite a lot of code, so what I'm asking is: is it possible to just add(convert) the sprites that have textures and positions already assigned to them to the vertex array and then just draw that?
I know this is not the most optimized way, but I'm thinking the sprite creation and handling is negligible performance-wise (correct me if I'm wrong). Would this grant me a noticeable performance boost?
How do I do it?

If you need me to post some code, don't hesitate to ask, please!

17
Graphics / Re: sf::Text wrap?
« on: April 18, 2014, 11:31:18 pm »
I have absolutely no idea how to use sf::Font, sf::Glyph and sf::Text to do this, lol.
As far as I understand it, I should get the width (in pixels, right?) of the string using sf::Glyph, then check to see if it's bigger than the width of the window, and if it is, insert a newline at the nearest space?
This is really confusing, I don't know where to begin :(

18
Graphics / Re: sf::Text wrap?
« on: April 18, 2014, 10:19:15 pm »
"hello\nworld" is the actual string. I wonder if it's getting stripped of its escape sequence properties or something, getting reduced to just flat text. Is that even possible?
I did something like:
goodString.compare(badString);
And the output is -1, so they can't be the same

Also: It's read as a newline in characters. I tried using \\n but it's the same thing :(

19
Graphics / Re: sf::Text wrap?
« on: April 18, 2014, 10:07:41 pm »
Also tested by manually setting the string to \n\r or \r and it still works. I wonder what's happening here

20
Graphics / Re: sf::Text wrap?
« on: April 18, 2014, 10:00:07 pm »

text.setString(std::get<0> (tuplePar)); //the string is "hello\nworld", same as below


text.setString("hello\nworld");

First example is trying to to set it as a string from a file, and the string gets read correctly( it displays the right thing) but doesnt seem to work.
second example is setting it manually to the exact same string and it works. What's up?

21
Graphics / Re: sf::Text wrap?
« on: April 18, 2014, 09:52:28 pm »
Shit, you're right. I fiddled around with my stuff and it appears my input thingy is messing with the escape sequence somehow. Anyway, thanks.

22
Graphics / Re: sf::Text wrap?
« on: April 18, 2014, 09:42:39 pm »
Which SFML version are you using? I'm asking because SFML does handle newlines.
The latest one I think? 2.1

Is it as simple as just creating a sf::Text object and setting the text to something like "te \n st" ? Because I'm doing that and it doesnt seem to be working.

23
Graphics / Re: sf::Text wrap?
« on: April 18, 2014, 09:06:47 pm »
Alrighty. One more thing: How do I figure out exactly how wide any given text is? Also, how do I know how much lower to render the text on the new line, regardless of font size?

24
Graphics / Re: sf::Text wrap?
« on: April 18, 2014, 08:56:34 pm »
Do you mean I need to create a new text object and draw it under the previous object for each new line?

25
Graphics / sf::Text wrap?
« on: April 18, 2014, 08:03:34 pm »
After some digging around, I couldn't find much. Any idea how to insert a newline if the text goes off screen? Also: if i display a sf::Text like "testing \n newline" it will just display it on the same line, no newline.

26
Audio / Re: Sound stops playing once sf::Sound object goes out of scope?
« on: February 21, 2014, 02:09:38 pm »
Nevermind. It seems the sf::Sound object also needs to be alive for the sound to play.

27
Audio / Sound stops playing once sf::Sound object goes out of scope?
« on: February 21, 2014, 02:08:21 pm »
#ifndef PLAY_HPP_INCLUDED
#define PLAY_HPP_INCLUDED

void Game::play(std::string soundName)
{
    std::cout << "Loading sounds...\n";
    if (!buffer.loadFromFile(soundName))
        std::cout << "Error: Could not find sound file named " << soundName << " !\n";

    sf::Sound sound;
    sound.setBuffer(buffer);
    sound.play();
    std::cout << "Playing \"" << soundName << "\"\n";
}

#endif // PLAY_HPP_INCLUDED
 

'buffer' is declared outside, and is still in scope when play() is called, but the sound doesn't play. any ideas?

Pages: 1 [2]
anything