Untitled

mail@pastecode.io avatar
unknown
d
a year ago
1.8 kB
5
Indexable
Never
import std.stdio;
import bindbc.glfw;
import bindbc.opengl;

void main()
{
    /*
    This version attempts to load the GLFW shared library using well-known variations of the library name for the host
    system.
    */

    

    GLFWSupport ret = loadGLFW();
    
    if(ret != glfwSupport) {

        /*
        Handle error. For most use cases, it's reasonable to use the the error handling API in bindbc-loader to retrieve
        error messages for logging and then abort. If necessary, it's possible to determine the root cause via the return
        value:
        */

        if(ret == GLFWSupport.noLibrary) {
            // The GLFW shared library failed to load
        }  
        else if(GLFWSupport.badLibrary) {
            /*
            One or more symbols failed to load. The likely cause is that the shared library is for a lower version than bindbc-glfw was configured to load (via GLFW_31, GLFW_32 etc.)
            */
        }
    }

    writeln(isGLFWLoaded());
    
    if (!glfwInit()) {
        throw new Exception("glfw is fucked");
    }
    
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

    auto window = glfwCreateWindow(600, 400, "potatoes", null, null);

    if (window is null) {
        throw new Exception("window is fucked");
    }



    // // Create OpenGL context
    // // Load supported OpenGL version + supported extensions
    GLSupport retVal = loadOpenGL();
    writeln(retVal);
    if(retVal >= GLSupport.gl41) {
        writeln("ye");
        // configure renderer for OpenGL 4.1
    }
    else {
        throw new Exception("oh no");
    }
    
}