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

Pages: [1]
1
Graphics / Saving vertex Array as image
« on: August 31, 2020, 07:44:55 am »
So, i have successfully used vertex array to draw graphics on the screen faster. Now is the time to save the contents of the window as an image. I tried to do the following but it results in either black image, blurry image, contents of the wrong frame etc.

           
sf::Vector2u windowSize = window.getSize();
           
            sf::Texture texture;
            texture.create(windowSize.x, windowSize.y);
            texture.update(window);

            sf::Image screenshot = texture.copyToImage();
            screenshot.saveToFile("maze_generator.png");

            window.close();
 

What options do i have while saving the vertex array as image

2
Graphics / Faster maze generation
« on: August 30, 2020, 12:42:33 pm »

Update: Replaced the algo with vertex array and everything is blazing fast. This is no longer a problem.!!

Guys, i created a maze generator and solver it works perfectly.

But the only problem i am facing is as i increase the grid size [ 16000 x 16000 ] , the fps drops extra low. ( with the animation of the rendering of maze on ) but if the graphical rendering is  off then it does it in 33 seconds

The paste bin for the code is : https://pastebin.com/qf3peRMV [ this is the code for the maze solver / i could not find the code for the generator ]

i'll try to explain what i do : i created a cell class which holds the coordinate and the walls, then i create a 2d array of the cells and then render this grid apply the dfs maze algo and it works.


How can i improve the speed with the graphics on? after researching a bit i got to know:
i can reduce it by using less draw calls by using a vertex array? and using a 1d array too improves speed

3
Graphics / Saving image of maze
« on: June 21, 2020, 07:39:29 pm »
Note: For some reason i cannot close this post, but i have found the answer. The reason was that, if you have  ever programmed the recursive backtracking, i was looping through the stack which of course sped up the draw but while saving it still saved the old unmodified version.

I created a maze generator using sfml and cpp. Once the program is run it creates a maze saves its specs in the format of txt file and then proceed to save a image. Everything works fine, but if i increase the size of the grid or decrease the size of cell dimensions some part of the maze is not saved in the image.

What i see on the screen [dont worry about the not responding part] = first image

vs what is saved = second image

If you want to see the source code you can find it on my github:https://github.com/irrevocablesake/website-code/blob/master/Maze%20Generator/ep3/main.cpp

And if you want a walkthrough of the working of the code, you can read it on my blog:https://irrevocablesake.github.io/series/challenges/Maze%20Generator/index.html

Note for Mode: My blog is not monetized as of the timing and i am just treating it as a fun archive for projects and challenges.

if(once)
        {
            cout<<"maze done!!";

            ofstream output("maze.txt");

            output<<rows<<" "<<cols<<" "<<cellDimensions<<endl;

            for(int i=0;i<rows;i++)
            {
                for(int j=0;j<cols;j++)
                {
                    for(int k=0;k<4;k++)
                    {
                        output<<grid[j].wall[k]<<" ";
                    }
                    output<<endl;
                }
            }

            // std::chrono::milliseconds timespan(60000);
            // std::this_thread::sleep_for(timespan);

            sf::Vector2u windowSize = window.getSize();
            sf::Texture texture;
            texture.create(windowSize.x, windowSize.y);
            texture.update(window);

            sf::Image screenshot = texture.copyToImage();
            screenshot.saveToFile("sc.png");   
            once=0;
        }
I feel like the last few statements where i try to save the image are the problem.

Thanks You!

Pages: [1]