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

Pages: 1 2 3 [4]
46
Graphics / Re: sf::RenderTexture clearing part of it
« on: April 02, 2012, 06:30:49 pm »
Nevermind, wrong vertex order *facepalmultimate*

47
Graphics / Re: sf::RenderTexture clearing part of it
« on: April 02, 2012, 06:28:25 pm »
I think you did something wrong, it's not expected, especially if it's slower than rendering sprites.

Oh, please excuse my bloody idiocity, it seems I forgot to put the breaks in my cases and ended up rendering 96 times more geometry *facepalm*
I'm still getting this weird triangle cut off from a side of every tile.
Maybe you could check what I'm doing wrong  :-[

//using a generated terrain field[][] with values from 0 to 24
//creating/initing the vertexArray:
sf::VertexArray vertarr(sf::PrimitiveType::Quads);
        for (int x = 0; x< terrx; ++x)
                for (int y=0; y< terry; ++y)
                {
                        if (field[x][y] != 0)
                        {
                                switch (field[x][y])                   
                                {
                                case 1:
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y), sf::Vector2f(0,0)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y), sf::Vector2f(8,0)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y+8), sf::Vector2f(0,8)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y+8), sf::Vector2f(8,8)));
                                        break;
                                case 2:
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y), sf::Vector2f(0,8)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y), sf::Vector2f(8,8)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y+8), sf::Vector2f(0,16)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y+8), sf::Vector2f(8,16)));
                                        break;
                                case 3:
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y), sf::Vector2f(0,16)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y), sf::Vector2f(8,16)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y+8), sf::Vector2f(0,24)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y+8), sf::Vector2f(8,24)));
                                        break;
                                case 4:
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y), sf::Vector2f(8,0)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y), sf::Vector2f(16,0)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y+8), sf::Vector2f(8,8)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y+8), sf::Vector2f(16,8)));
                                        break;
                               
                                [...]

                                case 24:
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y), sf::Vector2f(56,16)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y), sf::Vector2f(64,16)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x, 8*y+8), sf::Vector2f(56,24)));
                                        vertarr.append(sf::Vertex(sf::Vector2f(8*x+8, 8*y+8), sf::Vector2f(64,24)));
                                        break;
                                }
                        }
                }
//Then in the while rendering with
Window.draw(vertarr,sf::RenderStates(&mud));

 

Quote
The one I mentioned above, so that you could use the src alpha as a mask.
Source alpha is used as a mask in BlendAlpha.
No I mean like (GL_ZERO, GL_ONE_MINUS_SCR_ALPHA), basically the texture would be used as a hole-cutter
Like the 3rd example here http://www.machwerx.com/2009/02/11/glblendfunc/

48
Graphics / Re: Too many sprites?
« on: April 02, 2012, 05:52:57 pm »
Unless you actually have 10500 DIFFERENT sprites I wouldn't do that.
You should make a tiles array/map only with the tiles that are different, then draw those tiles by moving and then rendering, not by actually making lots of sprites.

I have 7500 tiles and I'm only using 24 sprites  :P

49
Graphics / Re: Resolving 2 sprites
« on: April 02, 2012, 05:45:02 pm »
Do you mean the two objects should combine into one?
If so, then you could try using a rendertexture and rendering both sprites onto it.

50
Graphics / Re: sf::RenderTexture clearing part of it
« on: April 02, 2012, 05:41:01 pm »
Today's graphics cards (and even older ones) can render millions of triangles per second.
Well, unless its an Intel graphics card like I have on my laptop. I used a vertexarray, but the framerate is horrible(rendering 7500 sprites was actually faster) and I think I screwed up the texCoords. Are the texture coordinates in pixels or relative to the texture (like in standard opengl, from 0 to 1)? (I tried both ways, still the texture was screwed up  :-\ )

Quote
Nop. What other blending mode do you need?
The one I mentioned above, so that you could use the src alpha as a mask.

51
Graphics / Re: sf::RenderTexture clearing part of it
« on: April 01, 2012, 07:59:51 pm »
Thanks a lot for the quick answer   :D

I'm not sure it's the best solution. Have you tried to use a vertex array instead? So changing a tile would be as simple as changing the texture coordinates of 4 vertices in the array.

That's quite a good idea, especially since it kills the need for multiple renderTextures. But I'm not so sure of performance (I've got around 7500 tiles rendered each frame = 30000 vertexes, but then again I suppose vertexArray uses 3 GL buffers so it might be just what I need :) )

I'm also wondering, is possible to enable other glBlendModes?

52
Graphics / Re: sf::RenderTexture clearing part of it
« on: April 01, 2012, 06:59:38 pm »
But what do you want to do? Create "holes" in your render texture ?

Yes.  I've made a tilemap, that renders to a renderTexture and only changed tiles are updated afterwards. For that I need to remove the old tiles aka clear the place for the new tiles or make "holes" like you said.

I've tried modifying SFML source code by adding BlendClear to the BlendModes enum and setting the case for it (in applyblendmode) to (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA), which is supposed to use the src alpha  as a mask, but it doen't seem to work  :-\

BTW, kind of off topic, but is there any way to shift all pixels in a rendertexture? I was thinking of creating a Worms style destructible pixel world. All the pixels would get rendered to a renderTexture and only the new pixels would get updated as the player moves through the world. The only other way I see to do it is by using 4 renderTextures that get pixels rendered on them as they come into view.
Also, is there any way to render singular pixels to a render texture?

53
Graphics / Re: sf::RenderTexture clearing part of it
« on: March 30, 2012, 05:30:17 pm »
I'm having the same problem. I need to clear a part of a renderTexture, but using transparent sprites/shapes won't work. They have got to have at least 1/255 opacity even with BlendMode set to BlendNone.
As I understand it's a transparent color exception  :-\

I think I might be able to do it with openGL, but I'm still not good enough with it  :(

Common guys, I know you have a solution for this  ;)

Pages: 1 2 3 [4]