I've been translating C++, OpenGL, and GLUT code into D, Derelict OpenGL, and Derelict GLFW using:

import derelict.opengl3.gl3;
import derelict.glfw3.glfw3;

auto window = glfwCreateWindow(800, 600, "Shaders", null, null);

etc.


Things have been going well. I then tried to implement window resizing with a callback function and the glfwSetWindowSizeCallback() statement.


void windowResizeCallback(GLFWwindow* window, int width, int height)
{
    glViewport(0, 0, width, height);
}

and

glfwSetWindowSizeCallback(window, &windowResizeCallback);


however, I kept getting the following compiler error:
Error 1 Error: function pointer glfwSetWindowSizeCallback (GLFWwindow*, extern (C) void function(GLFWwindow*, int, int) nothrow) is not callable using argument types (GLFWwindow*, void function(GLFWwindow* window, int width, int height))

Well, I was able to get it to compile and work by adding the following "decoration"

extern (C) nothrow
{
void windowResizeCallback(GLFWwindow* window, int width, int height)
    {
        glViewport(0, 0, width, height);
    }
}


Now it resizes the screen successfully, but I feel like I've failed by using extern (C) nothrow. Shouldn't Derelict GLFW be providing a D interface?

Maybe GLFW callback functions can't handled through Derelict GLFW?


Reply via email to