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

Pages: [1] 2
1
I finally found out that there was a class instance using tgui that was not deleted  :(

2

when i close my game. the background cmd window show :

Failed to activate OpenGL context:

An internal OpenGL call failed in Texture.cpp<104>
Expression:
 glDeleteTexture(1,&texture)
Error description:
 GL_INVALID_OPERATION
 The specified operation is not allowed in the current stats.

 

3
General / Re: MineCraft.. Where to start?
« on: February 16, 2024, 12:16:22 pm »

You have to be proficient in opengl, data structures, and algorithms

4
I dread and hate using multithreading. Threads are not safe. difficult.I always avoid using threads

5
System / Re: Process finished with exit code -1073741515 (0xC0000135)
« on: January 30, 2024, 01:58:53 am »
Adding the mingw directory to the path is always correct. He previously mentioned missing libstdc++-6.dll belonging to mingw

6
System / Re: Process finished with exit code -1073741515 (0xC0000135)
« on: January 29, 2024, 03:33:07 am »
The sfml environment is definitely not configured correctly. Add the sfml directory and mingw directory to the system path env variable. Set the correct library directory at compile time. There would be no problem.
error LNK2019 mean  the library cannot be found during the link process

7
Graphics / Re: Drawing Vertex Array with big Texture
« on: January 26, 2024, 12:02:55 pm »
What is the maximum texture size that sfml can draw?

8
I fixed an issue that caused a crash at the end of the program using TGUI libraries.
The reason is a flaw in the code design
I built a game state machine, and different game state classes.
Each game state class has a tgui object and draws it
When I created a tgui::button for the GameStatusGaming state, the program ran fine, but when I closed the program, it crashed in vs debug mode

I've tried many versions of tgui with this problem, so it's not a problem with tgui per se
I finally found that these game state classes were not released in my state machine destructor, which is what caused the tgui to crash.
I released them in the destructor of the state machine
        virtual ~GameStatusMachine(){
                //Destruction status class
                for(const auto &status:m_statusList){
                        delete status;
                }
        }
 
But it crashed again after the program ended
I set a breakpoint at the destructor and I see that there's no breakpoint running,This means that the state machine is not destroyed after the program ends
I checked the main function, it created a new game window class, and it didn't get released after the function ended
        GameWindow *window;
        try{
                window = new GameWindow;
        }
        catch(const char *e){
                std::cerr<<e<<"\n";
                return -1;
        }
        window->show();
        return 0;
 

So these status classes and TGUIs are not destroyed after the main function ends, they are still running, waiting for the system to release them.tgui components are still trying to draw,So it leads to a crash
I manually released the game window class,
        delete window;
        return 0;
 
I ran again without crashing at the end

9
General / Re: I found a range-based for loop issue with vs2012
« on: December 19, 2023, 07:32:28 am »
Thank you, it is true, I tried the const reference and now the cpu usage is normal using Range-based for loop.

10
General / I found a range-based for loop issue with vs2012
« on: December 19, 2023, 04:16:09 am »
I'm using VertexArray to draw a tilemap
        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
        {
                // apply the transform
                states.transform *= getTransform();
                //Range-based for loop is used here, compiling with vs2012 and running with a high cpu usage of 30%,so one cpu core is at full load
                //but threre is no problem with vs2013
                //for (auto content:m_verticesAndTexture){
                //      states.texture = &content.second;
                //      target.draw(content.first, states);
                //}
                //Use the classic for loop instead,The cpu usage returned to normal after compiling with vs2012
                for(int i=0;i<m_verticesAndTexture.size();i++){
                        states.texture = &m_verticesAndTexture[i].second;
                        target.draw(m_verticesAndTexture[i].first, states);
                }

        }
 
I don't think vs2012 supports c++11 very well

11
I know the way in vc++ windows.Import the file in the resource view and then use the LoadResource LockResource function to free up resources,But it seems you can't do that with the g++ compiler

12
I think you're right.master.
I tried the comparison again and found no increase in cpu usage, I don't know why maybe I got the wrong comparison earlier.
I don't have to change it if it doesn't take up too much cpu after drawing a lot of sprites. It seems inefficient, but it's not worth mentioning for modern hardware, is it?

13
I am running the program in debug mode, and I know that debug mode takes up more cpu. But calculating transformations on every frame i think is an inefficient approach. Why waste cpu on this?

14
Oh, thanks

15
My SpriteSheet only animates faces to the right, and if I want it to left animation, I have to detect the sprite direction every time the Sprite is updated,and  using transfrom,animation from right to left, but my cpu usage increased by 2%. Is there a better way?
        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const{
                states.transform *= getTransform();
                //if sprite orientation left
                if (m_spriteOrientation == SpriteOrientation::LEFT){
                        //set Origin
                        m_sprite->setOrigin(sf::Vector2f(m_sprite->getLocalBounds().width - m_sprite->getOrigin().x, 0));
                        //Horizontal flip,sprite face to left
                        m_sprite->scale(-1.f, 1.f);

                }
                //draw sprite
                target.draw(*m_sprite, states);

                //if sprite orientation left
                if (m_spriteOrientation == SpriteOrientation::LEFT){
                        //Flip back,sprite face to right
                        m_sprite->scale(-1.f, 1.f);
                        //Restore Origin
                        m_sprite->setOrigin(sf::Vector2f(0, 0));
                }

        }
 


Pages: [1] 2
anything