dimanche 1 décembre 2019

RTTR - Reflect existing methods from a library

I am trying to use rttr to add reflection to existing OpenGL drawing commands. I am on Windows 10, VS 2019.

This is in my entry file, above main:

#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <rttr/registration>

using namespace rttr;

static const GLenum TGL_LINES = GL_LINES;
void tBegin(GLenum mode) {
    glBegin(mode);
}
void tEnd() {
    glEnd();
}
void tVertex2f(float x, float y) {
    glVertex2f(x, y);
}

RTTR_REGISTRATION
{
    using namespace rttr;
    // with registration lines removed, program runs without error
    registration::property_readonly("GL_LINES", &TGL_LINES);
    registration::method("begin", &tBegin);
    registration::method("end", &tEnd);
    registration::method("vertex2f", &tVertex2f);
}

I am able to build successfully but at runtime upon registering the reflections, VS gives an Exception Unhandled dialog popup for ucrtbase.dll:

Unhandled exception at 0x7677CAA2 (ucrtbase.dll) in glfw-node.exe:
An invalid parameter was passed to a function that considers invalid parameters fatal.

When the registration::property_readonly and registration::method lines are removed, the program runs without issue, including OpenGL.





Aucun commentaire:

Enregistrer un commentaire