The graphics card is probably dead. It's caused by fatigue because of the heating/cooling cycles, causing small fissures in the connections between the graphics chip and the motherboard. Sometimes it seems to be OK again if the connection is restored for some reason (e.g. applied pressure or temperature change), but the problem goes worse with time. There is a "reflow" technique that could help you, but it is just a temporary fix. Best option is to call HP for a motherboard replacement if the PC is still under warranty, otherwise get a new PC and use this one for spares (i.e. extract the hard drive, RAM memory cards, CMOS battery, wi-fi cards...).
This can be caused by the user placing the computer over a pillow or other soft surfaces, blocking the air intakes and vents and causing overheating cycles. But it can also be a design flaw of the heat sink or the graphics chipset. For the record, I'd like to know the model of the PC and the graphics card. I already had this problem with an HP Pavilion dv9500 (i think that was the number) with AMD processor and an nVidia graphics card, and with a Dell Studio 15 with Intel processor and ATI graphics. I know the HP suffered a lot of overheating because of bad habits of the owner (watching movies with the PC on the bed).