I am porting my simple lwjgl3 game to C++, and got Error: WGL: The driver does not appear to support OpenGL
. The code is almost identical in java, so I'm wondering what's wrong and how to fix it:
int main(int argc, char** argv) {
glfwSetErrorCallback(error_callback);
if (!glfwInit()) {
std::cerr << "Failed to initialize GLFW" << std::endl;
return -1;
}
glfwDefaultWindowHints();
//glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
//glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
glfwWindowHint(GLFW_SAMPLES, 4);
GLFWwindow* window = glfwCreateWindow(640, 480, "Example", nullptr, nullptr);
if (!window) {
std::cerr << "Failed to create window" << std::endl;
glfwTerminate();
return -1;
}
...
I am using msys2 and mingw-w64, and compiled the program in mingw-w64 shell. First I thought the problem was with the glfw3 i built, so I used lwjgl3 copy of glfw instead and got the same error. I have tried the recommended hints, context versions, etc., but to no avail. I am pretty sure that the driver supports OpenGL, and just to make sure I also checked for updates.
While testing stuff to see what works and doesn't, I have confirmed that all glfw and SFML examples are not working (both I have built with mingw-w64). No errors during compilation, no exceptions and/or errors in cmd, no window created as well.
I'm not very familiar with windows development so I'm not sure if this is an issue with the mingw-w64, glfw or wgl.
Using only the standalone mingw-w64 solved it. The same program runs fine now without any errors, not to mention that the glfw and SFML examples now run as well.
I have not yet discovered what could be causing the error, I suppose it has something to do with msys2 but for now the problem is solved.