I was following a youtube video on using Hazel https://www.youtube.com/watch?v=zn7N7zHgCcs and I have everyday installed quite OK. However I encounter an exception in Hazelnut.exe "Access violation executing location 0x0000000 on Hazel::OpenGLShader::CreateProgram.
If anyone is familiar with Hazel and has looked at "The Cherno" youtube videos and can help, that would be greatly appreciated.
I'm unfamiliar with "Hazel" and "The Cherno". I can only offer an educated guess without access to your code and information about your computer.
From names alone I assume that your program explicitly links symbols at runtime during some initialization process. I suspect that this initialization process fails, is defective, doesn't happen, or doesn't happen early enough.
Use a debugger to figure out which symbol(s) are problematic. The problematic symbol(s) are most likely functions that are expected to be explicitly linked, for example glCreateProgram.
@Ganado, Yes, I have the entire code from github and the exe is generated after running the solution file. The exception occurs at line 319 of the OpenGLShader.cpp file, but I don't understand that code enough yet to debug it. So I am actually looking for help from someone who understands that code. I just need to use Hazel to achieve other things I need but I am not conversant with it.
The GUI being used is GLFW, but I see no calls like glfwInit() anywhere. (Edit: Actually I do see the call, GitHub's search functionality is just garbage.)
Is like 50 in https://github.com/TheCherno/Hazel/blob/master/Hazel/src/Platform/Windows/WindowsWindow.cpp being hit?
The underlying problem may be that GLEW, which GLFW apparently uses, in order to link correct OpenGL calls, isn't being initialized.
serg06 wrote:
If it's a problem with GLFW, you can ask them for an error message before they crash your program.
Sorry please bear with me, not yet conversant with lots of things. Should the code above be placed at the beginning of which file ? WindowsWindow.cpp? The arguments description and "GLFW error" seem not to match. It says argument of type char* is not compatible with parameter of type LPCWSTR. How do I initialize GLEW?
LPCWSTR is MS speak for pointer to type const wchar_t (which is 16 bit and used by MS for unicode chars instead of char).
Are you compiling as unicode or multi-byte character set?
If compiling as unicode then you use wchar_t instead of char. If you don't need to compile as unicode, then try changing the compile character set to multi-byte.
Thanks for directing me aright with the L"GLFW Error". Actually I was trying to define and set that function at the location you just mentioned, but I observed that glfwSetErrorCallback() wont take as input argument a function that returns void; such as void glfw_onError(). I will try to redefine the function to return GLFWerrorfun and let you know.
Hmm, post the compiler error message you get. GLFWerrorfun is a function pointer type so doubt that should be the return type of the callback function passed into glfwSetErrorCallback.
Because according to the documentation, GLFWerrorfun is defined as: typedefvoid(* GLFWerrorfun) (int error_code, constchar *description)
Meaning it's a pointer to a function that returns void, and expects (int, const char*) as parameters.
The problem may be that the 'description' being passed to MessageBox is not a wide string. So you may have to convert the description into a wide string.
Or, instead of calling MessageBox, explicitly use the ASCII version, MessageBoxA and remove the L from L"GLFW Error".
OK, so I changed MessageBox to MessageBoxA and I did not need to have wchar_t and L prepended to "GFLW error". And the signatures/types matched to have gflw_onerror as input to glfwSetErrorCallback. However I don't find any message box popup when i run it and I still have the Access violation error.
Below is the top part of the code I have within Hazel namespace of WindowsWindow.cpp:
Update: @Ganado, I just managed to isolate the problem code section! Within the function definition void OpenGLShader::CreateProgram() I removed everything that had to do with shaders and the exe ran at least reasonably ok enough for me to proceed with the things I need to learn. Thank you so much for supporting me through this. Greatly appreciated!.