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

Pages: 1 2 [3]
31
Graphics / Re: shader keep being bound after call to draw ?
« on: May 29, 2014, 12:11:57 am »
nevermind, I figured it out and it had nothing to do with what I explain in that post.... I can't delete the topic though

32
Graphics / shader keep being bound after call to draw ?
« on: May 28, 2014, 11:19:10 pm »
Hi
I'm trying to understand code from a library
here Sprite3d is a class derived from sf::Sprite:
 
void Sprite3d::draw(sf::RenderTarget& target, ShaderPack& shaderPack)
{
   //a texture was already set for "this"
    screen.draw(*this, &shader1);

    sf::Sprite sprite(*this);
    sprite.setTexture(heightmap);
    heightmapScreen.draw(sprite, &shader2);
}

this produces an unexpected result (for me!) where it seems that the shader1 is being called twice, the second time being during the second draw call, after shader2 is called. Is this normal?
For reference, if I do this instead:
 
void Sprite3d::draw(sf::RenderTarget& target, ShaderPack& shaderPack)
{
   //a texture was already set for "this"
    screen.draw(*this, &shader1);

    sf::Sprite sprite;
    sprite.setTexture(heightmap);
    heightmapScreen.draw(sprite, &shader2);
}
it produces a different result, and seems to call each shader 1 time, which is what I expect would have happened in the first example.

What am I missing here ? The code I'm looking at seems to be actually relying on the behavior from the 1st sample, so it's probably not a bug. I'm smelling that something is very fishy in the copy constructor of sf::Sprite but I'm unable to understand what exactly goes on... any idea?

33
Graphics / Re: limited 3D transforms to textures ?
« on: May 20, 2014, 12:52:53 am »
yeah you're right for the buildings, I should probably use a sf::sprite for now and handle manually the ordering, there probably wouldn't be tons of building sprites at once on the screen, and anyway I can't do this with the same vertex array.

about the ground tile potentially overllaping the characters, would you have any idea how to achieve this ?The only solution I see would be to have each new horizontal line of tile in its own vertex array, and then draw them according their depth.

34
Graphics / Re: limited 3D transforms to textures ?
« on: May 20, 2014, 12:22:29 am »
If you simply draw the tiles (and what's in them) from top to bottom, then buildings on lower tiles will naturally get drawn over some of the objects standing on higher tiles.

yes, that's what I'm doing and it's working great (for instance in the pic you see the grass overlapping the sand tiles a bit)
the issue would be when a character is partially behind elements that are drawn in the vertex array. Since the vertex array is drawn in a single draw call, there's no way I can interleave a drawing of the character

35
Graphics / Re: limited 3D transforms to textures ?
« on: May 19, 2014, 11:51:19 pm »
It should be fairly easy to do that with a vertex shader, though for a transformation this simple it might be best to stick with your existing solution.
for which image?

for the first one it's indeed pretty simple.
The general problem I'd like to avoid would be to manually detect which tiles are behind / in front of the character (for instance when you go behind a building), that's why I was thinking of making one vertexarray for each "face" of the building and somehow have them draw correctly according to where the blue plane is in my 2nd picture. So would it still be possible?

36
Graphics / limited 3D transforms to textures ?
« on: May 19, 2014, 11:40:48 pm »
Hi
for a simple isometric game I'm drawing things like that :
(click to show/hide)
I'm just drawing a tiles with a diamong shape and then on top a vertex array of diamond "borders" in cyan.

would it be possible in SFML to instead, define all of this as a simple top-view grid with regular "rectangular" tile images, and then perform3D  transformations to obtain the picture I just posted?

Also, would it be possible to do something like that  ?
(click to show/hide)
ie I somehow define 2 textures and their orientation, and I have the ordering be correctly drawn after I do some transformation

Would it be possible in SFML or would I need to use the underlying OpenGL calls?

thanks!

37
SFML projects / Re: Eleutheromania - 2D RPG - Work in progress
« on: May 19, 2014, 08:46:08 pm »
Hi !
I'm pretty impressed with what you have done !
I'm wondering : how do you manage the collision detections ?  Is it just a grid or a more complex structure ?
thanks!

38
Graphics / [Theory] Sprite Layering
« on: January 26, 2012, 06:49:01 pm »
Hi
the easiest and most generic way I found to do this was:
1) place every sprite you are going to draw in an STL container (assuming that they are not already) - obviously just store a pointer and not a copy
2) sort this container with std::sort and a custom comparaison function that works on Y
3) iterate over the container to draw each item

For the problem of 2 sprites having the same Y, you can put in your comparaison function that if the two Y values are equal, you are then comparing with any other member value. For instance I compare the adresses of the items, which insures that the order will always be the same if 2 objects are not moving and have the same Y value

39
Graphics / Problems with Tile displaying
« on: January 11, 2012, 07:18:15 pm »
Hi, I had the same problem using subrect. You can try to put SetSmooth to false for the sf::texture, it that still doesn't work, the workaround I found is to pre-compute 1 proper sf::texture for each tile, so you don't have to use subrect on one big image

40
Graphics / Sprites only drawn once
« on: December 07, 2011, 12:25:39 pm »
i'm not sure that it's legal to downcast using reinterpret_cast, since you have no guarantee that the members of the derived class are placed at the same memory location as the members of sf::sprite, usually people use dynamic_cast on pointers to do this
I also don't really see why you need to derive SFML classes when you could just encapsulate them in your object

edit : you should check
std::cout << "In link: " << object.GetImage() << "\n";
instead of
std::cout << "In link: " << sprite.GetImage() << "\n";
the second time, it's possible that the memory location is different

41
Graphics / Tilemap at 7 fps
« on: November 30, 2011, 11:08:52 pm »
That's not really how a tile engine is supposesd to be  working since you are re-computing each tile position at each frame...
Anyway you have to have your basic tiles preloaded and NOT extract them from the tileset at each frame

42
Graphics / text window
« on: November 19, 2011, 01:05:20 am »
Hi
is there anyway to do a "text window" in SFML?
IE I define a rectangle of fixed size and I want the text to "fit" into this rectangle using line breaks, and tell me if the text entered is too long.
Is there any way to do this?
thanks

Pages: 1 2 [3]