The problem is:
Edit: So, how can I point the GLFWwindow *window pointer from main, to CreateWindow() function, where glfwCreateWindow() function returns a pointer to the original pointer in main()?
Calling the function CreateWindow is causing unexpected results. After function call, original *window struct is NULL and a segmentation fault occurs.
This is the main:
int main() {
clear();
GLFWwindow *window;
CreateWindow(window, 800, 600);
assert(window != NULL);
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
}
DestroyWindow(window);
return 0;}
This is the called function:
void CreateWindow(GLFWwindow *window, int width, int height) {
if(!glfwInit()){
printf("Unable to init glfw!");
}
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
window = glfwCreateWindow(width, height,"Vulkan",NULL,NULL);
glfwSetWindowUserPointer(window, window);};
This here is the result:
test: engine_core.c:28: main: Assertion `window != NULL' failed.
[1] 3248 abort (core dumped) ./test