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

Pages: [1] 2 3 ... 8
1
General discussions / Re: Baffled by problem and need help
« on: March 27, 2014, 09:27:39 pm »
Quote
Baffled by problem and need help
General discussions is the wrong forum, there's a whole section about help requests. Furthermore, this is a very bad thread title. With so many posts, you should know that ;)

Also, you can use the edit function instead of 4 posts in a row. That keeps the description more readable, readers will still be notified about the change.

Yeah, I lost my mind thinking on this and these rules evaded me :(

2
General discussions / Re: Baffled by problem and need help
« on: March 27, 2014, 08:02:16 pm »
Setting j and i equal to the vector size - 1 fixes the problem, but it still begs the question of why it didn't work to begin with. Near as I can tell, it should have. I am truly puzzled.

3
General discussions / Re: Baffled by problem and need help
« on: March 27, 2014, 07:58:13 pm »
When it creates the error, it will also skip

std::cout << "Processing layer " << i <<" of gui" << std::endl;
 

4
General discussions / Re: Baffled by problem and need help
« on: March 27, 2014, 07:54:33 pm »
Further, commenting out the section where j and i are set to the vector size, it does not create the error. Why would the loop increment the values to be higher than the vector size and then ignore it's check when it is clearly false?

5
General discussions / Baffled by problem and need help
« on: March 27, 2014, 07:44:03 pm »
OK, so I have just the strangest problem and I can't figure out why it is happening.

I have this bit of code, which makes the error.

bool nextLayerBlocked = false;

        for( unsigned int i = 0; i < interactiveElements.size() && nextLayerBlocked == false; ++i )
        {
            std::cout << "Processing layer " << i <<" of gui" << std::endl;

            for( unsigned int j = 0; j < interactiveElements[i].size(); ++j )
            {
                std::cout << "Processing element " << j << " of layer " << i << std::endl;

                interactiveElements[i][j]->HandleInput( userInput );

                if( interactiveElements[i][j]->IsLayerBlocking() == true )
                {
                    std::cout << "Next Layer is blocked" << std::endl;

                    nextLayerBlocked = true;
                }

                if( interactiveElements[i][j]->IsBlocking() == true )
                {
                    std::cout << "Element is blocking" << std::endl;

                    activeElement = interactiveElements[i][j];

                    j = interactiveElements[i].size();
                    i = interactiveElements.size();
                }

                std::cout << "j = " << j << " i = " << i << std::endl;
            }
        }
 

Now, when ran in the debugger, it works exactly as expected. When not run in debugger, however, it crashes. What happens not in the debugger is that when an element blocks and it sets j and i to be equal to the sizes to exit the loop, the for loops ignore their check! The cout's report the numbers as being 1 larger than they are at the end, like the loops increase them by 1 and say, yup, these numbers are still smaller than the vector size. This in turn causes a segment fault.

What baffles me is the fact that it works fine when run through the debugger, but then fails when not. I don't understand. It's probably something small and stupid, but I can't find it.

6
Graphics / Re: Map Editor Problem
« on: February 19, 2014, 12:05:47 am »
Damn, I'm so stupid...
Anyway, thanks for help...

I would not say stupid, you just committed an over sight. Everyone does it and we all feel stupid when we find them.

7
Graphics / Re: Map Editor Problem
« on: February 18, 2014, 11:07:08 pm »
sf::Texture textureObj;
 

Your sprites all point to this texture. If you change the actual texture inside of the sf::Texture, which is what the sprites all point to, then you will change what the sprites display.

What you need is a vector or map for your textures.

8
Graphics / Re: Bullet and Gun problem
« on: February 18, 2014, 10:48:08 pm »
Debugger will show you where the access violation is occurring.

9
Graphics / Re: Query about draw function
« on: February 18, 2014, 09:18:16 pm »
Well, first of all, sprite is const, and you are trying to alter it.

"object type is: const Sprite"

10
Graphics / Re: How to give a shader an array of values?
« on: February 18, 2014, 02:19:30 pm »
Use textures to store collections of values. Textures are the arrays of the graphics card. Depending on what you exactly want to do, the API that SFML provides might not be enough, and you would have to use raw OpenGL.

What do you need the arrays for?

The pixels are going to be shaded according to twp values, each of which will have different places on the screen, and the number can change as well. I think I could do it without passing the arrays into the shader and work on each separately by having a loop that goes through each point and the two values in the main program. Each iteration would run the shader and draw it unto a render texture, then draw the render texture to the window, but I think doing it all on the shader in one go would be a lot faster.

The number of elements in the array would be changing too.

I appreciate the help very much. I'm extremely new to this stuff.

11
Graphics / How to give a shader an array of values?
« on: February 18, 2014, 06:40:32 am »
A friend of mine and I are making a program for fun, and it has fallen to me to write a shader to display the results. The shader is a fragment shader. In order to do what it needs to do, I need to get two arrays of float values. How can I use an array inside a shader and how can I pass this array from the c++ program into the shader program?

I've been looking, but the results haven't been helping me much. They are also in the context of just opengl and glsl, and I'm not sure how that would apply to the SFML context.

12
Graphics / Re: Shader is running really slow. Not sure what it is.
« on: February 17, 2014, 06:59:33 am »
I try to be and occasionally I succeed.

Also, I tested it and you do not need the sf::RectangleShape here
 renderTexture.draw(testShape,&testShader);
 
I did this instead and it works near as I can tell
renderTexture.draw(sprite,&testShader);
 

13
Graphics / Re: Shader is running really slow. Not sure what it is.
« on: February 17, 2014, 06:50:11 am »
The problem section is here
texture = renderTexture.getTexture();
sprite.setTexture(texture);
 

You are copying a texture and then setting this in the sprite and then drawing the sprite.

I instead did this outside of the while loop
sprite.setTexture(renderTexture.getTexture());
 

Then this section
Window.clear(sf::Color::Black);
testShader.setParameter("resolution",100,100);
testShader.setParameter("time",time1.getElapsedTime().asSeconds());
renderTexture.clear();
renderTexture.draw(testShape,&testShader);
renderTexture.display();
texture = renderTexture.getTexture();
sprite.setTexture(texture);
Window.draw(sprite);
Window.display();
 
became this
Window.clear(sf::Color::Black);
testShader.setParameter("resolution",1280,720);
testShader.setParameter("time",time1.getElapsedTime().asSeconds());

renderTexture.clear();
renderTexture.draw(testShape,&testShader);
renderTexture.display();

Window.draw(sprite);
Window.display();
 

The main problem was you were copying a texture, which is a heavy weight operation, and in this case completely unnecessary. The sprite just needs it's texture set once as the sprite contains a pointer to its texture. Copying the texture was unnecessary since you can just set the sprite's texture to be the texture inside the render texture and then any changes will automatically be taken into account when you draw the sprite since the sprite points to the texture inside the render texture.

With these changes it runs silky smooth at ~180 fps on my machine, which is ~5 years old. The graphics card is an nvidia 8800 GTX

14
Graphics / Re: Shader is running really slow. Not sure what it is.
« on: February 17, 2014, 06:44:55 am »
I think I found the problem in your code. I just made a change and it runs at max resoltuion at over 175fps. Will follow up with a post in a few minutes showing the problem I found.

15
Graphics / Re: Shader is running really slow. Not sure what it is.
« on: February 17, 2014, 06:41:53 am »
I changed it to take up the entire 1280x720 resolution and it now runs at around 23 fps.

do you mind showing the code please? I want to see exactly what you put

testShape.setSize(sf::Vector2f(1280,720));
testShader.loadFromFile("wave2.txt",sf::Shader::Fragment);
renderTexture.create(1280,720);
 

Instead of
 testShape.setSize(sf::Vector2f(500,500));
   testShader.loadFromFile("wave2.vert",sf::Shader::Fragment);
   renderTexture.create(500,500);
 

I had to change it from a .vert file to a .txt file because I couldn't quite figure out how to make a .vert file, though I don't know if this matters or not.

I also changed
 testShader.setParameter("resolution",100,100);
 
to
 testShader.setParameter("resolution",1280,720);
 


I also ran it with a blank shader file and it did not change the FPS. It was still running at ~20fps.

Pages: [1] 2 3 ... 8
anything