-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
glewInit() returning "Unknown Error" #417
Comments
What does |
|
The entire thing is quite long, but it is in this text file if the top doesn't provide enough information. |
glxinfo looks healthy to me. Will look into it. |
Could you also provide the numeric value of the error code from |
It returns 4 |
I'm running it now and glewGetErrorString() returns "Missing GL version", instead of "Unknown error" (IDK why) |
If you're able to put some printfs in the function Is glewGetProcAddress failing?
It's an unusual problem you're having, if I had to guess it's |
I could make a change to return a different error code for the glewGetProcAddress null check, perhaps. |
glew.c |
i added some printf()'s (likely incorrectly as I am not particularly familiar with C) and now the section you outlined looks like this:
I feel as if I am using them improperly because getString returns something indecipherable when I print it treating it like a char* (It also gives a warning that it may be a lossy conversion) : (��H�U) (I also added an int main() { glewContextInit(); } at the bottom) |
getString is a pointer to a function, so that's a useful diagnostic, next check if dot is zero.
(Actually my C feels a bit rusty) |
dot == 0 So that seems to be the issue. |
And what is the value of s?
|
|
glGetString should only be returning What's the Linux distro and version, and what's the computer brand and model? |
Computer brand: DELL |
Ah, Arch! It's like you're sending bug reports from the future. I'm on Ubuntu 22.04 here. |
Does GLEW typically run into issues with arch? |
While I was running through glew.c, it seems as if the getString() function seems to be the issue for me. Do you know where it comes from? I tried recompiling with glGetString() replacing it but it ran into the same issue. If I tried a printf() statement like:
or
or even if I just gave "GL_VERSION_4_6" as an input, it segfaults (and when I replace getString() with a variable assigned to that value it still segfaults, even if don't run it in glew.c and do it somewhere else entirely with the libraries linked and the headers included) glGetString(GL_VERSION) works fine whenever I use the same function in C++, it only breaks for me in c. |
No, I shouldn't complain about Arch. One other diagnostic, does glewinfo also crash? If not, what's the output? |
glewinfo doesn't crash thankfully, the output is quite long though. I have glewinfo's output in this textfile, if that helps. I took a peek and just looked for "init" and found this:
I don't know what it necessarily does or if it is required. It would be cool to think of my issues being a potential future warning, although I would wager its more likely I am missing something or making a small mistake (I am quite new to programming so its likely not an issue with the software). |
Do double-check that you're definitely making the context current, before calling glewInit. |
I did invoke glfwMakeContextCurrent() before glewInit(), but when I combed through my code I forgot that I had left in glewGetErrorString(1), instead of glewGetErrorString(err) somehow. The "Missing GL Version error" was actually my mistake, it still says unknown error when I run my program and have the correct glewGetErrorString() argument ( glewGetErrorString(err) ) (Everything below "Problem!" in the code I have written is irrelevant as it returns, so looking through my code is less arduous than it may seem, this also is the entire fire, there is nothing obscured)
I made a copy of the edited glew.c file in the directory where my triangle.cpp file is, and I included it in the header. GLEW does not have an issue with retrieving the GL_VERSION, as this is the output of the executed triangle binary:
The issue is still unknown it seems. |
Perhaps then, build in debug mode and step through glewInit. |
It doesn't seem to be able to grab my display:
display returns null |
I am having a similar issue. The following code on Arch fails with ‘main: failed to initialize GLEW: Unknown error’: #include <err.h>
#include <stddef.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
int
main(void)
{
if (glfwInit() == 0)
errx(1, "failed to initialize GLFW");
GLFWwindow *win = glfwCreateWindow(640, 400, "Hello, World!", NULL, NULL);
if (win == NULL)
errx("failed to create window");
glfwMakeContextCurrent(win);
GLenum e = glewInit();
if (e != GLEW_OK)
errx("failed to initialize GLEW: %s", glewGetErrorString(e));
while (!glfwWindowShouldClose(win)) {
/* ... */
}
glfwTerminate();
return EXIT_SUCCESS;
} You can view my output of |
Ah, seems to be an issue with me being on Wayland. I was able to fix this by building with |
I have the same problem。I use wxGLCanvas (wxWidgets build with gtk2) , glewInit is ok , it return 4 when wxWidgets(build with gtk3, glXGetCurrentDisplay() retrun NULL. Platform and version information
|
Hello @chenliangabc if you could attach the output of glxinfo and glewinfo, would appreciate it. |
|
@nigels-com Hello, can you see the problem from the output |
@chenliangabc Your glxinfo and glewinfo look perfectly normal to me. |
I use
|
Sorry, is wxWidgtes build problem, |
I have the same problem on openSUSE Leap 15.6 System
Code to replicate the issue#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
int main(void)
{
GLFWwindow* window;
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
if (!window) {
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
GLenum error = glGetError();
if (error != GL_NO_ERROR)
{
std::cout << "OpenGL Error: " << error << std::endl;
}
GLenum glewinit = glewInit();
if (glewinit != GLEW_OK) {
std::cout << "GLEW error: " << glewGetErrorString(glewinit) << std::endl;
exit(EXIT_FAILURE);
}
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
} It fails with WorkaroundsInterestingly enough the problem goes away when linking to system libglfw.so provided from the repo rather than the one I've compiled myself following their standard compile instructions. The issue also goes away if I compile GLEW with |
I've been able to pin point specific version of glfw that causes this crash. If I compile and link to glfw 3.3.10 (the one also shipped by openSUSE Leap repos) everything works fine, but if I link to glfw 3.4 then |
Triangle.cpp
I haven't been able to find any solutions to my problem, and glewInit() returning "Unknown Error" is not helping much unfortunately.
Im working with:
4.6 (Compatibility Profile) Mesa 24.1.5-arch1.1
Mesa Intel(R) HD Graphics 520 (SKL GT2)
So linux may be the issue, but I am just looking for some clarification.
Thank you for any help you are able to provide as I cannot seem to understand my issue.
The text was updated successfully, but these errors were encountered: