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
General / Re: Efficient ways to create buttons
« on: June 26, 2024, 04:44:50 pm »
I think the first way is good, each button should judge the event for itself.

2
Graphics / Re: Sprite not displaying after successful texture load
« on: June 26, 2024, 04:41:38 pm »
You'll need to make sure that the image is loaded and that the textured sprite is visible

3
General / Is SFML message-driven or event-driven?
« on: April 29, 2024, 03:49:48 pm »
i asked ai and it says:

It is based on an event-driven model.In SFML, the main event loop is controlled by the SFML application. The application constantly retrieves events from the event queue and responds accordingly. This event loop is responsible for receiving user input, updating game state, rendering graphics, and other operations.
 
Is it true?

4
Graphics / hello. a question about setTextureRect
« on: March 27, 2024, 05:18:02 pm »
I use RectangleShape to hold the map. I use setTextureRect to adjust the area where the map appears in RectangleShape .
 But if I set the area to exceed the size of the original map, there's a blur of color around it. I wonder if I can remove these colors or make them black
 rectangleShape.setTextureRect(sf::IntRect(-100,-10,9000,9000));
 
The original size was 8000*8000.The picture of the problem is attached

5
I finally found out that there was a class instance using tgui that was not deleted  :(

6

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.

 

7
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

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

9
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

10
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

11
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?

12
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

13
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.

14
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

15
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

Pages: [1] 2