1
General / Re: This is bizarre... Why would NOT drawing something be causing a lag? 6/9 SOLVED!
« on: June 26, 2020, 08:03:24 pm »The point I was trying to make is that whenever any render target is changed, it should be cleared, drawn and displayed. This is the same for both your window and your render texture. When I said "display" the render texture, I mean using the display() method, not showing it on the window.
Remember, if you clear a render target (render texture or window, for example), it should also be displayed after you've finished drawing to it. And, you should always clear it first after displaying it is the last thing that happened. clear/draw/display
You can draw the "render sprite" (the sprite used to draw the render texture to the window) window every frame but the texture itself needs to treated with the clear/draw/display cycle every time (you change it).
Yes, I know. I always clear, draw, and display. I have a whole function for drawing my levels that takes care of it. I clear the texture, draw to it, display it, and then assign it to a sprite for drawing to the window on every frame. I only draw the level when I need to, so I have a flag that is set when the texture is drawn.
If you've already used them (for points, I presume), moving on to using larger primitives should be comfortable enough for you. Instead of one vertex per output (as in point primitive), it would be multiple vertices per output (3 for triangle primitive and 4 for quads). The strips/fans can be a little more complicated at first but can reduce the number of required once you understand them.
Yes, I'll look into them when I need them. What is interesting, is that after my recent modifications to my game (having it the way that it was in the first post), there is no longer any lagging going on. But that could also be due to my code doing more since then. I'm not sure, but my game works fine now with the clock timing.
Thank you for your help Hapax.