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

Pages: 1 ... 9 10 [11] 12 13 ... 15
151
Graphics / Re: How to make VertexArray with RenderState semi transparent.
« on: September 24, 2013, 12:51:23 pm »
The question you have to ask yourself anyways is, whether you really want to draw the whole map again and then adjust the view, or whether you can to render something specifically for the minimap.
It seams really easy and efficient to draw map on 2 views. It takes so little cpu usage to do so that i don't mind it.
I just want to add transparency to minimap as optimal option. I personally don't mind the minimap but on my last project i had requests for transparency so they can see more of game so i want to :
Add minimap in different sizes as Slider in options, Add minimap transparency as Slider in options,
Currently i have done the size, but i cant figure out how to make transparency i am missing something.
I am currently looking intro making 2 sf::VertexArray of map... The game currently takes about 15mb on runtime and its pc game so it can go allot above that point imo.

152
Graphics / Re: How to make VertexArray with RenderState semi transparent.
« on: September 24, 2013, 12:08:34 pm »
Rather (255, 255, 255, 200), if you want to see the tile's texture ;)
That is exactly what i want to do.
But i fear i have not explained what i require in detail so i will do it now:
First of all i am drawing a map that has colors (255,255,255,255).
When i am drawing minimap i am actually drawing a map but in other view.
And i want to be able to set minimap transparency.

1: Editing each vertex color to 255,255,255,200 for each minimap draw and to 255,255,255,255 for each Map draw is not efficient at all. So i am looking for something i did not figure out yet.

153
Graphics / Re: How to make my own "progress bar"?
« on: September 23, 2013, 10:34:32 pm »
If you want any chance to success you need to do everything by your self.
Think about it multyple times before posting and try figure it on your own before asking for help.
If that fails we are here.

What you want to do is probably following
Make a sf::RectangleShape and set its sf::RectangleShape::setTexture(to texture of loadingbar)
then each loop sf::RectangeShape::setTextureRect(sf::IntRect(X,Y, Calculated progress, height))
Draw it.

I may not understand your question, its probably lack of information.
You require math to calculate how much of bar you need to draw or?
It above helps, am glad i could be of help, case else i tried.

154
Graphics / How to make VertexArray with RenderState semi transparent.
« on: September 23, 2013, 10:25:43 pm »
Hello.
I was experimenting with minimap and i am drawing it as vertexArray with RenderState witch only has texture.
My question is how would i set its alpha color to (200) of 255, or 80% or something big so its just transparent?
Using BlendMode gave me weird results... and i think that is not what i am looking for, so any help is apprechiated.

155
SFML projects / Re: What are you working on?
« on: September 21, 2013, 04:37:46 pm »
I am working on a 2d realTime Survival/Action with top down view.
Currently i have finished implementing movement, AI movement, Map, Minimap, Collision, and behind scenes stuff.

156
I liked this so much.
One thing was really annoying, i hit jump as soon as i land and i didn't jump (I am guessing i pressed it just a little before i landed but i have to release and press the key again to jump and it kinda was pain to hassle that).
All in all i enjoyed even if i didn't see most because my monitor is super dark but the enemies stood out from the background so it wasn't big of a issue.

157
Graphics / Re: If object position is out of vissible screen, is it drawn?
« on: September 02, 2013, 06:36:56 pm »
Thank you on lightning fast respond  :).
I am just asking that because i drawn 100*100*4+5000*4 vertices that are textures and still getting 600-1200 fps with additional logic thrown in that mix and i am very surprised on that performace.
And most of them go out of screen so i was just wondering.

158
Graphics / If object position is out of vissible screen, is it drawn?
« on: September 02, 2013, 06:16:49 pm »
Hello.
If an rectangle with (X=0 Y=0 W=10 H=10) is drawn to a window that its position and size is
(X=100, Y=100, W=600, H=400)
Will the object be drawn and use cpu? or is it gonna check if it is in visible screen and not draw it.

159
Bump.
Can anyone check if the code last posted causes issues that where described on other systems pretty please.

160
Minimal example for the issue i am experiencing:

While holding "A" on keyboard, on far right side of the square that is being drawn there is one vertical line of pixels that is brighter then it is supposed to be(as in in texture)
While holding "D" on keyboard, on far left side of the square that is being drawn there is one vertical line of pixels that is brighter then it is supposed to be...

Texture used
"http://postimg.org/image/wj5onh7e5/"

int main()
{
        sf::VertexArray arr;
        arr.setPrimitiveType(sf::PrimitiveType::Quads);
        arr.resize(4*4*4);
        for(int y = 0; y < 4; y++)
        {
                for(int x = 0; x < 4; x++)
                {
                        arr[(x+(y*4))*4+0].position = sf::Vector2f(x*32+0, y*32+0);
                        arr[(x+(y*4))*4+1].position = sf::Vector2f(x*32+32, y*32+0);
                        arr[(x+(y*4))*4+2].position = sf::Vector2f(x*32+32, y*32+32);
                        arr[(x+(y*4))*4+3].position = sf::Vector2f(x*32+0, y*32+32);

                        arr[(x+(y*4))*4+0].texCoords = sf::Vector2f(0+0, 0+0);
                        arr[(x+(y*4))*4+1].texCoords = sf::Vector2f(0+32, 0+0);
                        arr[(x+(y*4))*4+2].texCoords = sf::Vector2f(0+32, 0+32);
                        arr[(x+(y*4))*4+3].texCoords = sf::Vector2f(0+0, 0+32);
                }
        }

        sf::Texture tex;
        tex.loadFromFile("img.png");

        sf::RenderStates state;
        state.texture = &tex;

        sf::RenderWindow win;
        win.create(sf::VideoMode(640,480,32), "game");
        win.setFramerateLimit(60);

        sf::View view;
        view.reset(sf::FloatRect(0, 0, 640, 480));

        while(win.isOpen())
        {
                sf::Event event;
                while(win.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                                win.close();
                        if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::A)
                                view.move(-1, 0);
                        if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::D)
                                view.move(1, 0);
                }
                win.setView(view);
                win.draw(arr, state);
                win.display();

                win.clear();
        }

    return 0;
}
 

Using floats will almost always cause those weird lines to appear, stick with whole integers. 

Also using textures that are a power of 2(2, 4, 8, 16, 32, 64, 128...) may yeild non'weird' results as graphics cards generally made to handle textures with power of 2 way easier and better than non standard texture sizes.
Ive bean reading on how openGL, graphics work on drawing since i was suspecting that it was my GPU issue not the SFML.
Those suggestions are great for someone of my knowledge(i should read up more)!

You can read the official tutorial about vertex arrays, it explains the usage very well.

By the way, your code is unnecessarily complicated:
            if(color == false)
            {
                arr[(x + (y*5))*4+0].texCoords = sf::Vector2f(0*32, 0*32);
                arr[(x + (y*5))*4+1].texCoords = sf::Vector2f(0*32+32, 0*32);
                arr[(x + (y*5))*4+2].texCoords = sf::Vector2f(0*32+32, 0*32+32);
                arr[(x + (y*5))*4+3].texCoords = sf::Vector2f(0*32, 0*32+32);
            }
            else
            {
                arr[(x + (y*5))*4+0].texCoords = sf::Vector2f(1*32, 0*32);
                arr[(x + (y*5))*4+1].texCoords = sf::Vector2f(1*32+32, 0*32);
                arr[(x + (y*5))*4+2].texCoords = sf::Vector2f(1*32+32, 0*32+32);
                arr[(x + (y*5))*4+3].texCoords = sf::Vector2f(1*32, 0*32+32);
            }

First, instead of color == false you can write !color, and second, you can combine the statements by using a variable for 0 and 1 (or even color itself, exploiting the conversion from bool to int). Third, the index (x + (y*5))*4 is needlessly repeated, which can be avoided with a std::size_t variable.

Apart from that: sf::BlendMode::BlendNone is not valid C++03, only valid C++11. For non-scoped enums, I would still recommend to write sf::BlendNone, since the enumerators are spread in the sf namespace anyway.
I noticed error appeared when those two colors where mixed so i tried something fast, on top of my mind and easily readable. I will comment the code next time.

161
I have bean working over 3-4 hours on this issue so far, i have figured out so far.
1: I am unable to reproduce the issue in small scale.
2: I am unable to locate the issue when using large scare(Copied part by part from a project where i done get such a error and i don't get the jiggering and flickering of edge pixels)
3: Retyped, also tried copying from other project a copy of code for each part that is in touch with the VertexArray, RenderWindow, Texture, Loading vertexArray...
I will try to give it another try later in the week, maybe i am overseeing something big.

162
Working on it since i posted last post.
Having issue atm.

Texture http://postimg.org/image/8pfoen5kh/
With this code the movement of the map is jumpy, cant reproduce the issue of blur
int main()
{
        sf::Texture tex;
        tex.loadFromFile("img.png");

        sf::VertexArray arr;
        arr.setPrimitiveType(sf::PrimitiveType::Quads);
        arr.resize(5*5*4);
        bool color = false;
        for(int y = 0; y < 5; y++)
        {
                for(int x = 0; x < 5; x++)
                {
                        arr[(x + (y*5))*4+0].position = sf::Vector2f(x*32, y*32);
                        arr[(x + (y*5))*4+1].position = sf::Vector2f(x*32+32, y*32);
                        arr[(x + (y*5))*4+2].position = sf::Vector2f(x*32+32, y*32+32);
                        arr[(x + (y*5))*4+3].position = sf::Vector2f(x*32, y*32+32);
                       
                        if(color == false)
                        {
                                arr[(x + (y*5))*4+0].texCoords = sf::Vector2f(0*32, 0*32);
                                arr[(x + (y*5))*4+1].texCoords = sf::Vector2f(0*32+32, 0*32);
                                arr[(x + (y*5))*4+2].texCoords = sf::Vector2f(0*32+32, 0*32+32);
                                arr[(x + (y*5))*4+3].texCoords = sf::Vector2f(0*32, 0*32+32);
                        }
                        else
                        {
                                arr[(x + (y*5))*4+0].texCoords = sf::Vector2f(1*32, 0*32);
                                arr[(x + (y*5))*4+1].texCoords = sf::Vector2f(1*32+32, 0*32);
                                arr[(x + (y*5))*4+2].texCoords = sf::Vector2f(1*32+32, 0*32+32);
                                arr[(x + (y*5))*4+3].texCoords = sf::Vector2f(1*32, 0*32+32);
                        }
                       
                        color = !color;
                }
        }

        int posX = 0, posY = 0;

        sf::RenderStates state;
        state.texture = &tex;
        sf::Transform transform;
        transform.translate(posX, posY);
        state.transform = transform;
        state.blendMode = sf::BlendMode::BlendNone;

        sf::RenderWindow renWin;
        renWin.create(sf::VideoMode(800,600,32), "This is not the best song in the world, this is just a tribbute");
        renWin.setFramerateLimit(60);

        while(renWin.isOpen())
        {
                sf::Event event;
                while(renWin.pollEvent(event))
                {
                        switch(event.type)
                        {
                        case sf::Event::Closed:
                                renWin.close();
                                break;

                        case sf::Event::KeyPressed:
                                switch(event.key.code)
                                {
                                case sf::Keyboard::W:
                                        posY -= 1;
                                        break;
                                case sf::Keyboard::S:
                                        posY += 1;
                                        break;
                                case sf::Keyboard::A:
                                        posX -= 1;
                                        break;
                                case sf::Keyboard::D:
                                        posX += 1;
                                        break;
                                default:
                                        break;
                                }
                                break;

                        default:
                                break;
                        }
}
                        sf::RenderStates state;
                        state.texture = &tex;
                        sf::Transform transform;
                        transform.translate(posX, posY);
                        state.transform = transform;
                        state.blendMode = sf::BlendMode::BlendNone;

                        renWin.draw(arr, state);
                        renWin.display();
                        renWin.clear();
               
        }
        return 0;
}

EDIT::: THIS CODE HAS A MASSIVE FLAW.
Each event loop was bad.
i had all logic in event loop. FIXED NOW

Can you link me to a proper window with vertexArray using texture array so i test that.
I have just too complicated code to pluck it out and post it

163
Graphics / Re: mismatch of desktop resolution and RenderWindow resolution
« on: September 01, 2013, 10:44:54 am »
There is a way to grab all possible resolutions supported by your GPU.
Chose one that is most fitting to your screen resolution.
Or just print them all out to see if you have one that is in your desktop if not... i would say its a bug/error.

164
When its not float, it seems as it is screan tearing all the time.
With VSync and or limited fps to my screen i get weird look...
Somehow edges of "Color change" flicker and have different color"
So for example, imagine a 50x50 blocks of white and black going in chess board patern over whole screen,
when moving the screen around at 1 pixel per frame, the edges of color difference are having different colors then the ones i set them to have.
edges pixels of black block have gray on it... while white have the same issue.
With black & green, only the green is distorted and it gets whiter green then it should have.
I have tried to get screen of what i am experiencing but i just cant get it...

EDITED.

Anywhere a example how to move vertex array around without issue like this so i can test.
Somehow i do not think its sfml issue maybe my graphics card is, or something.

165
Hello.
I have a vertexArray that has sf::Quads made in squares to represent 32x32 pixels.
The issue is when i am moving around the vertexArray using sf::transform, and it always happens when i pass in a float value of(x.5) x being any value.

Image as expected
http://postimg.org/image/ymzl93ead/
When moving at one frame this is dispalyed
http://postimg.org/image/j2s7ik45x/

Ever had this happen to someone?
What is the fix for the solution? it is really eye catching when moving map around and it cant be tolerated.
One solution is to check if i am passing (x.5) intro the translate and add or remove (x.1) but i find that not being global solution to issue.
Is behavior like this intent or did i make a mistake?

Pages: 1 ... 9 10 [11] 12 13 ... 15