unit testing

Hello,

A cool stuff is the unit testing, returning “OK” or “KO”.

However, with OpenGL, when we use textures, matrices, or draw primitives, the results are in the GPU and it seems more difficult to make unit testing returning OK or KO.

Do you know standard tests to do with OpenGL?

Thanks a lot!!!

I’m not sure I understand you, but I think you are looking for glGetError

http://www.opengl.org/sdk/docs/man/xhtml/glGetError.xml

Do you know standard tests to do with OpenGL?

I think you’re forgetting what the purpose of a unit test is. A unit test exists to make sure that a piece of code that you own has some specified behavior.

You don’t own the driver. You could unit test the driver, if you want. But the most you might be able to do is file bug reports to NVIDIA/ATI.

Your unit tests shouldn’t be focused on rendering, but on your objects/functions that call the renderer. So you’re more interested in whether or not you’re sending the right data, rather than what OpenGL’s actual results are. In many cases, you can just put glGetError checks in appropriate locations.

Unit testing graphics code is hard, really hard. When you take a good look at your code, a lot of it won’t even call into your renderer, that code can be tested with standard approaches. For testing your actual renderer, you can write to frame buffers and read back the results, comparing against some known truth. Even something this basic is a good sanity check for running on different cards or if your renderer does something spiffy (e.g. automatically set shaders uniforms). Ultimately, you are going to run into issues with different cards, drivers, operating systems, configurations (AA or no AA), etc. The best we’ve done is allow different ways to compare images and different tolerances.

This is a great point. I’ve never tried it but I’ve always thought that if you have your renderer abstracted, you could write one for “dependency injection” for unit tests. For example, when you know your code is correct. you run it with a renderer that writes the calls to disk, then when the unit tests are ran, it verifies the same calls are made. I’m sure this would be quite involved but I’m curious if anyone has ever experimented.

Regards,
Patrick