In my previous post I was asking about a snake game I was working on. I got it to draw and behave properly, but I ended up with issues where the program locked up after the snake has around 20+ segments. This would be a very lame game if the snake did not get bigger so I went down the rabbit hole of device contexts and memory leaks. (I suspected I created a leak and that was why it locked when I had more segments.). I have spent probably a day and a half reading about the four device context types and how they were used. I read probably ten different tutorials and spent most my time on the MSDN documentation pages.
I have had issues understanding pointers in the pas so it is making this difficult as everything is done with handles which seem to be for the most part an abstraction pointer to an object that the application can't directly affect. So I have a couple questions about the device contexts. Basicly I want to draw all application drawing to a Memory DC and then after everything is done I would bltbit to SRCCOPY to the display context as I think this would eliminate all the screen flickering. I am having some issues understanding proper use of the selectobject() getobject() and deleteobject() functions to prevent any memory leaks.
Do you have to delete an object after EVERY selectobject() function?
If a memory DC can only hold one bitmap would I have to use 2 memory DCs and one display DC? One DC for slecting BITMAPs into. Another to draw everything onto and a final one being the display one? (If that would even work I am guessing I would have to set one of the memory DC to hold a BITMAP the size of the window)
Sorry for the lengthy post but I wanted to communicate what I have read and where I am still sketchy. I don't want to post code as I want to understand the concept rather than just have someone give me the right code. If you can answer with a link that explains in lamen terms that would be cool too. Thnx in advance for your time.