1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include "engine.h"
#include "TestSDKHelpers.h"
#include <GL/osmesa.h>
int TestSDKExternalWindowOSMesa(int argc, char* argv[])
{
int size[] = { 300, 300 };
// Create an RGBA buffer to hold the rendered image
std::vector<unsigned char> buffer(size[0] * size[1] * 4);
// Create an OSMesa context
OSMesaContext ctx = OSMesaCreateContext(OSMESA_RGBA, nullptr);
if (!ctx)
{
std::cerr << "OSMesa context creation failed!\n";
return EXIT_FAILURE;
}
// Bind the buffer to the context
if (!OSMesaMakeCurrent(ctx, buffer.data(), GL_UNSIGNED_BYTE, size[0], size[1]))
{
std::cerr << "OSMesaMakeCurrent failed!\n";
OSMesaDestroyContext(ctx);
return EXIT_FAILURE;
}
f3d::engine eng = f3d::engine::createExternalOSMesa();
eng.getWindow().setSize(size[0], size[1]);
eng.getScene().add(std::string(argv[1]) + "/data/cow.vtp");
if (!TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/", argv[2],
"TestSDKExternalWindowOSMesa"))
{
OSMesaDestroyContext(ctx);
return EXIT_FAILURE;
}
OSMesaDestroyContext(ctx);
return EXIT_SUCCESS;
}
|