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

Pages: 1 [2]
16
Graphics / Re: Bitmap font -> Chatbox (with scrollbar)
« on: February 14, 2013, 07:12:51 pm »
Thank you for replying. I don't think I've stated anywhere that I needed code. I simply need some help on this subject since I haven't done this before.
I am able to draw the glyphs using a function that takes an std::string as parameter at specified coordinates.
This is not the problem. (no idea if this is the most efficient solution)

Wrapping the text up should not be a problem also.

My question is therefore (which I should have stated previously): is a sf::View suitable/efficient for scrolling and what would the calculations/position for the scrollbar/view be (thumb size and position)?

17
Graphics / Bitmap font -> Chatbox (with scrollbar)
« on: February 14, 2013, 05:40:46 pm »
Hello all,

How would I go about creating a chatbox using nothing but a bitmap font.

The problem is creating the actual box with scrollable text (vertical scrollbar).
Can this be created with a view or are there better solutions?

Don't have any idea how to begin approaching this, any help is appreciated.

18
Graphics / Re: sf::Sprite vector reference to sf::Texture vector
« on: November 27, 2012, 05:20:26 pm »
If a push_back to tileSheets results in a tileSheets needing to expand, all the references to textures in sprTiles will be invalidated.

You might try using a std::deque for tileSheets.
Thanks, I had no idea it would be invalidated by expanding. Solved.

19
Graphics / sf::Sprite vector reference to sf::Texture vector
« on: November 27, 2012, 03:46:40 pm »
Well, I'm having a bit of a head-scratch here.
I understand that Sprites are references to Textures and the Textures need to be initialized for the Sprites to draw.

In this case, I have a vector of Textures in class TexMgr in which I store all tilesheets:
TexMgr.h:
std::vector<sf::Texture> tileSheets;
std::map<unsigned long, unsigned long> tileIDs;

TexMgr.cpp:
void TexMgr::addTilesheet(sf::Texture &tilesheet) {
        tileSheets.push_back(tilesheet);
}
 

Now I want to store each tile in each tilesheet of the previous vector into a seperate Sprite vector:
TexMgr.h:
std::vector<sf::Sprite> sprTiles;
TexMgr.cpp:
void TexMgr::addTile(sf::Sprite &tile, unsigned long id) {
        sprTiles.push_back(tile);
        tileIDs[id] = sprTiles.size() - 1;
}
 

and finally draw the sprite using:
sf::Sprite* TexMgr::getTileSpr(unsigned long id) {
        return &sprTiles[tileIDs[id]];
}
 

I don't think this is the correct way of doing things because the rendered Sprite is white.
Could anyone lighten me up, any help is appreciated.

20
Graphics / Re: sf::Image -> sf::Texture -> sf::Sprite slow process
« on: November 23, 2012, 06:15:01 pm »
I load a tilesheet, then subrect a tile from that tilesheet and store it in a new Tile instance. My problem is loading, not rendering.
EDIT: I think I get it now, thanks for helping me.

21
Graphics / Re: sf::Image -> sf::Texture -> sf::Sprite slow process
« on: November 23, 2012, 06:02:50 pm »
A reference is better than a pointer in the draw function. As I explained in my post the RAM to GPU passing is what makes it slow, it's not a problem with an average amount of textures, but if it grows too big it can generate bad time issues like the one you are experiencing it seems.

Quote
By map with 1800 you mean 1800 instances of THAT class?

If this is your case then it's bound to be slow. There are better ways to work around it, but that depends on what you need done with those 1800 textures...
Well, I need to render it to the screen. Care to provide an example of how it can be done better ?

22
Graphics / Re: sf::Image -> sf::Texture -> sf::Sprite slow process
« on: November 23, 2012, 05:47:39 pm »
Removed*

23
Graphics / Re: sf::Image -> sf::Texture -> sf::Sprite slow process
« on: November 23, 2012, 05:42:31 pm »
What do you mean by slow?
As in not fast..

Say my map contains 1800 tiles.
What I mean by slow, is that the loading time will take up to 5-20 seconds for the whole map to be loaded for rendering. I need a faster method for loading images to textures.

24
Graphics / sf::Image -> sf::Texture -> sf::Sprite slow process
« on: November 23, 2012, 05:02:46 pm »
Why is it that loading textures from files is such a slow process.
I'm either doing something wrong, or SFML is just too slow for my needs.

I load each tile in a tilesheet into an sf::Image using a subRect. All goes well and is pretty fast too.
Now the real problem is getting it into a texture using texture.loadFromImage which well then be put into a sprite for rendering.

I need to use it this way because I need image.createMaskFromColor to filter a certain color.
Is there a way to avoid loadFromImage without removing the createMaskFromColor functionality?

(I'm using SFML 2.0)

Pages: 1 [2]