If it's a software issue, at worst, you back up all your important files, "nuke" the hard drive and reinstall everything.
If it's a hardware issue, then it depends on what you have. A PC can easily be fixed with an inexpensive graphics card. Most PCs, if they have onboard video, will have a slot for a video card anyway. A laptop is more trouble, but replacement graphics cards can be had and some places will switch them out at a low cost. Of course, for a laptop, price the work first. It might be better to spend a bit more and get a new laptop.
There should be programs you can download that will "stress test" your video card. If the problem doesn't happen with that, it's definitely not a hardware issue. If it does happen, the question is if it was a hardware issue or if the stress test "tripped" the problem in software. Software glitches are hard to diagnose unless the computer gives you a message describing with some detail what went wrong. If you get a prompt to save a "report" on the incident, do that...it can be helpful.
I had a quirky video card at work. Turned out the cooling fan's bearing failed, so it wasn't running. The heat of the video card made it act funny as soon as I did anything that put a strain on the card. Replacing the fan with an aftermarket one solved the problem and salvaged the card.