|
| 1 | +#include "rendering/CoinOffscreenGLCanvas.h" |
| 2 | + |
| 3 | +#include <Inventor/SoDB.h> |
| 4 | +#include <Inventor/SoRenderManager.h> |
| 5 | +#include <Inventor/SbViewportRegion.h> |
| 6 | +#include <Inventor/nodes/SoCube.h> |
| 7 | +#include <Inventor/nodes/SoSeparator.h> |
| 8 | + |
| 9 | +#include <cstdlib> |
| 10 | +#include <iostream> |
| 11 | + |
| 12 | +namespace { |
| 13 | + |
| 14 | +int skip(const char * reason) |
| 15 | +{ |
| 16 | + std::cout << "SKIP: " << reason << std::endl; |
| 17 | + return 77; |
| 18 | +} |
| 19 | + |
| 20 | +void set_environment(const char * name, const char * value) |
| 21 | +{ |
| 22 | +#ifdef _WIN32 |
| 23 | + _putenv_s(name, value); |
| 24 | +#else |
| 25 | + setenv(name, value, 1); |
| 26 | +#endif |
| 27 | +} |
| 28 | + |
| 29 | +} |
| 30 | + |
| 31 | +int |
| 32 | +main() |
| 33 | +{ |
| 34 | + set_environment("COIN_EGL", "1"); |
| 35 | + set_environment("EGL_PLATFORM", "surfaceless"); |
| 36 | + set_environment("COIN_EGL_CORE_PROFILE", "1"); |
| 37 | + |
| 38 | + SoDB::init(); |
| 39 | + CoinOffscreenGLCanvas canvas; |
| 40 | + canvas.setWantedSize(SbVec2s(32, 32)); |
| 41 | + if (canvas.activateGLContext() == 0) { |
| 42 | + SoDB::finish(); |
| 43 | + return skip("core EGL offscreen context is unavailable"); |
| 44 | + } |
| 45 | + |
| 46 | + SoSeparator * root = new SoSeparator; |
| 47 | + SoCube * cube = new SoCube; |
| 48 | + root->addChild(cube); |
| 49 | + root->ref(); |
| 50 | + |
| 51 | + uint8_t pixel[4] = {0, 0, 0, 0}; |
| 52 | + { |
| 53 | + SoRenderManager manager; |
| 54 | + manager.setViewportRegion(SbViewportRegion(SbVec2s(32, 32))); |
| 55 | + manager.setSceneGraph(root); |
| 56 | + manager.setRenderPipeline(SoRenderManager::RenderPipeline::DRAW_LIST); |
| 57 | + manager.render(TRUE, TRUE); |
| 58 | + canvas.readPixels(pixel, SbVec2s(1, 1), 1, 4); |
| 59 | + } |
| 60 | + |
| 61 | + root->unref(); |
| 62 | + canvas.deactivateGLContext(); |
| 63 | + SoDB::finish(); |
| 64 | + |
| 65 | + if (pixel[0] == 0 && pixel[1] == 0 && pixel[2] == 0) { |
| 66 | + std::cerr << "FAIL: manager DrawList pipeline produced no pixels" << std::endl; |
| 67 | + return 1; |
| 68 | + } |
| 69 | + return 0; |
| 70 | +} |
0 commit comments