我最近开始关注
these
OpenGL教程。我一直没有遇到麻烦,直到
你好窗口
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)
返回false。这会导致以下错误:
Exception thrown at 0x00000000 in openGL_001.exe: 0xC0000005: Access violation executing location 0x00000000.
和
Unhandled exception at 0x7281C1ED in openGL_001.exe: 0xC0000005: Access violation executing location 0x00000000.
glViewport(0, 0, 800, 600)
很高兴
已成功处理OpenGL的函数指针。我尝试使用以下方法使其工作
很高兴
configurations
语言:C/C++,规格:OpenGl
代码:
#include <iostream>
#include <glad\glad.h>
#include <GLFW\glfw3.h>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
int main() {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "Learn OpenGL", NULL, NULL);
if (window = NULL) {
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cout << "Failed to initialise GLAD" << std::endl;
}
glViewport(0, 0, 800, 600);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
//render loop
while (!glfwWindowShouldClose(window)) {
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
-
Windows 10
-
Visual Studio 2015社区
-