Category Archives: Uncategorized

OpenGL Multi-Window, Multi-Context Demo

 

A demo of a small demo I created showing off multiple OpenGL windows, each with its own context. Note that the lag is because I was recording it, normally it runs just fine.

The demo was created using GLFW3, GLEW (compiled with the GLEW_MX directive) and GLM. You can see the full code here.

I tried multi-threading the demo but the frame rate dropped to around 60 fps from what is shown in the video, it also caused the Nvidia drivers to crash.

See here for some general information on using multiple OpenGL contexts.


Advertisements

For vs For Each

I’ve been curious for a while now about the performance of the MS for each C++ extension compared to the traditional for loop. So a couple of weeks ago I dug up and old performance testing framework I’d put together and found out for myself.

The Framework works by running a specified piece of code (using a function pointer) a specified number of times. It uses Microsoft’s Query Performance Counter (QPC) to time the code each run and reports the average time as well as some other stats. I used it to run a number of different For and For each loops on the same data/container to see which one performs best. A reset function can be specified and used to reset data between each test run. The Full framework used can be found Here. Continue reading For vs For Each

To get things started…

To get things started I thought I’d post some information I promised a friend on easy multi-threading techniques in C#/.Net.

First trick is to use the Parrallel Class. This is a new addition in .Net 4.0 that provides version of for and foreach that will automatically split up the loop to run across multiple threads, depending on how many cores the System CPU has and how much load each core is under (this can be controlled too, if need be).

The other is Background Workers. Background workers are best used for slow jobs that might cause the UI to lock up (such as long file IO operations). A Background worker runs whatever task you give it on a separate thread, preventing the UI from locking up and allowing the user to do other thing while they wait for it to complete. The background worker provides a series of events for monitoring its progress.

Hope you find these useful in your future .Net projects.