Click here to Skip to main content
15,905,010 members

Comments by Rick York (Top 200 by date)

Rick York yesterday View    
That is a rather curious design if that is what you have to do. I have written a lot of programs that do rendering both 2D (usually GDI+) and 3D (OpenGL, see my profile) and they are almost always double buffered and I have never had a persistent memory DC. It is always drawn to, written to the device, and then automatically deleted. That means this topic has never come up for me because I always do printing from the device. Why do you need to print from the memory context? Also - the printer and device (nearly) always have different resolutions so why does that make a difference in this case?
Rick York 2 days ago View    
Deleted
I think those should not have the trailing backslash. The form for a string literal is :
const char * literal = "some text "
"another line of text "
"and it can keep going "
"with no commas or backslashes "
"and then it ends with a semicolon";
Rick York 2 days ago View    
Why in the wide world of sports did this question from August of 2022 need to be updated???
Rick York 15-May-24 3:51am View    
I have written code that does insertion into an array before and I found there two key things. First is pre-allocate more memory than will ever be actually needed for the array. Second is the function memmove is very handy for moving the array elements down to make room for the new item(s). In my case it was an array of characters but the principles are the same.
Rick York 10-May-24 12:50pm View    
I have fought this battle for years. That is, how can I have event logging and trace messages and display them at the same time? We could never come up with a high performance method with files so we resorted to using a shared memory buffer and then writing a separate extraction process that displayed the messages and/or wrote them to files. My current implementation is VERY high performance with an average message logging time of 750 nanoseconds. The best performance I have seen writing to a console is more than ten times slower and that's only after the text buffer has been filled once. Until then, it's another ten times slower and it takes 9000 events to fill the default buffer. Writing to a file is slower than that.

That's my recommendation: implement a ring buffer in shared memory and a separate process (I call a slurper) to display and archive the data. The buffer I use has 32K slots, 256 bytes each, and occupies 8MB of memory. One nice thing about this is multiple processes can utilize the same buffer and, if you do it right, you can have multiple buffer instances.