I am working on a simple 2d game in sfml, and I recently ran into a problem when trying to write a mod system for the game. Basically, the mod system works by loading a dll into memory, and calling functions from it that return a subclass of one defined in my game. The loading works fine and the object is instantiated correctly, but it appears to have broken part of my rendering code that worked before, namely this part:
void Environment::render(sf::RenderWindow& window) {
for (Spawner* spawner : m_spawners) {
spawner->render(window);
}
for (Enemy* enemy : m_enemies) {
enemy->render(window);
}
m_player.render(window);
sf::RectangleShape shape(sf::Vector2f(20, 400));
shape.setFillColor(sf::Color::Black);
window.draw(shape);
shape.setPosition(420, 0);
window.draw(shape);
shape.setSize(sf::Vector2f(400, 20));
shape.setPosition(0, 0);
window.draw(shape);
shape.setPosition(20, 420);
window.draw(shape);
}
While the spawners are rendering, the console prints a bunch of opengl errors. After further investigation with the debugger (visual studio). It appears that my spawner->render() function is never being called, which is odd. I'm not entirely sure what is happening here as this code works fine with spawners that are instantiated in the executable and not loaded from the dll. I'm new to loading a dll at runtime, is there some sort of problem I'm missing here?