Access violation reading location
Пишу игру, написал код создания окна, и после компиляции выдаёт ошибку, не сразу, а после создания окна:
Unhandled exception at 0x00007FF68C479580 in clahsofclans.exe: 0xC0000005: Access violation reading location 0x000000000000001C
код window.cpp
#include "window.h"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
GLFWwindow* window::Window;
int window::init(int width, int hight, const char* title) {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// glfw: создание окна
GLFWwindow* window = glfwCreateWindow(width, hight, title, NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
}
bool window::isSHouldClose(){
return glfwWindowShouldClose(Window);// ошибку здесь появляется
}
void window::swapBuffers() {
glfwSwapBuffers(Window);
}
void window::PollEvents() {
glfwPollEvents();
}
void window::processInput(GLFWwindow* Window) {
if (glfwGetKey(Window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(Window, true);
}
void window::termenate() {
glfwTerminate();
}
main.cpp
#include "window.h"
#include <iostream>
// Константы
const unsigned int WIDTH = 800;
const unsigned int HEIGHT = 600;
int main()
{
GLFWwindow* Window;
window::init(WIDTH, HEIGHT, "clahs of clans");
while (!window::isSHouldClose())
{
// Обработка ввода
window::processInput(window::Window);
// Выполнение рендеринга
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
window::PollEvents();
window::swapBuffers();
}
window::termenate();
return 0;
}