views:

197

answers:

1

I have an openGL display that I would like to write unit-tests for. However, I'm not sure what sort of tests should be written to ensure my display is working properly? I Know I can test that the context was created successfully. But, because it is a graphical element, and working correctly is based on what is displayed, does everything else requires manual testing? Should I just use a bunch of calls to glGetError?

This is probably a stupid question, but I figured I would ask to see what you all had to say.

+3  A: 

It depends on what you are doing.

You can unit test the calls themselves, by using glGetError, etc. This is often useful, but often only slightly useful.

I have also done this in the past by writing a series of images in advance, and using them as a reference image. You can then handle your display, and do things such as render to a texture and do a pixel by pixel compare against your reference images. Just be aware that you may need to have some level of "fuzziness" in your comparison, as different drivers may not be pixel-identical for the same rendering.

VTK uses this approach on their dashboard tests, for example. Many of the tests write an image and compare them against the "correct" reference image.

Reed Copsey