{"id":267,"date":"2021-02-25T10:12:14","date_gmt":"2021-02-25T02:12:14","guid":{"rendered":"http:\/\/liyanliang.net\/?p=267"},"modified":"2021-02-25T10:15:14","modified_gmt":"2021-02-25T02:15:14","slug":"openglrotatecube","status":"publish","type":"post","link":"http:\/\/liyanliang.net\/index.php\/2021\/02\/25\/openglrotatecube\/","title":{"rendered":"OpenGL\u7ed8\u5236\u65cb\u8f6c\u7acb\u65b9\u4f53"},"content":{"rendered":"\n<p class=\"has-cyan-bluish-gray-background-color has-background\">\u6982\u8981<\/p>\n\n\n\n<p>\u4e3b\u8981\u4ecb\u7ecd\u4f7f\u7528OpenGL\u7ed8\u5236\u4e00\u4e2a\u7acb\u65b9\u4f53\uff0c\u5e76\u7ed9\u7acb\u65b9\u4f53\u7684\u516d\u4e2a\u9762\u8d4b\u4e88\u4e0d\u540c\u7684\u989c\u8272\uff0c\u5e76\u4f7f\u7acb\u65b9\u4f53\u53ef\u4ee5\u81ea\u52a8\u65cb\u8f6c\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u952e\u76d8\u6309\u952eA\u3001D\u3001W\u3001S\u8fdb\u884c\u5de6\u3001\u53f3\u3001\u4e0a\u3001\u4e0b\u79fb\u52a8\u3002<\/p>\n\n\n\n<p>1.\u4f7f\u7528GLM\u51fd\u6570\u5e93(OpenGL Mathematics)\u8fdb\u884c\u7acb\u65b9\u4f53\u4e3e\u77e9\u9635\u7684\u53d8\u6362\u8fd0\u7b97\uff1b<\/p>\n\n\n\n<p>2.\u4f7f\u7528PVM\u77e9\u9635\u8fdb\u884c\u5750\u6807\u7cfb\u53d8\u6362\u3002PVM\u77e9\u9635\u5373 P:projection;V:view;M:model\u3002model\u77e9\u9635\u5bf9\u5e94\u4ece\u5c40\u90e8\u5750\u6807\u7cfb\u5230\u4e16\u754c\u5750\u6807\u7cfb\u7684\u53d8\u6362\uff1bview\u77e9\u9635\u5bf9\u5e94\u4ece\u4e16\u754c\u5750\u6807\u7cfb\u5230\u89c2\u5bdf\u5750\u6807\u7cfb\u7684\u53d8\u6362\uff1bprojection \u77e9\u9635\u5bf9\u5e94\u4ece\u89c2\u5bdf\u5750\u6807\u7cfb\u5230\u526a\u88c1\u7a7a\u95f4\u7684\u53d8\u6362\u3002<\/p>\n\n\n\n<p>3.\u901a\u8fc7\u6ce8\u518c\u9f20\u6807\u548c\u952e\u76d8\u63a7\u5236\u51fd\u6570\uff0c\u4f7f\u7acb\u65b9\u4f53\u53ef\u4ee5\u901a\u8fc7\u8bbe\u5907\u63a7\u5236\u3002<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background\">\u6548\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/liyanliangpublic.oss-cn-hongkong.aliyuncs.com\/img\/RotateCube.gif\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background\">\u4e3b\u8981\u5b9e\u73b0\u4ee3\u7801 <\/p>\n\n\n\n<p>main.cpp<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include \"glad.c\"\n\n#include &lt;glad\/glad.h>\n#include &lt;GLFW\/glfw3.h>\n#include &lt;stb_image.h>\n\n#include &lt;glm\/glm.hpp>\n#include &lt;glm\/gtc\/matrix_transform.hpp>\n#include &lt;glm\/gtc\/type_ptr.hpp>\n\n#include &lt;learnopengl\/shader_m.h>\n#include &lt;learnopengl\/camera.h>\n#include &lt;learnopengl\/model.h>\n\n#include &lt;iostream>\n#include &lt;GL\/gl.h>\n#include &lt;GL\/glu.h>\n\n\/\/\u9f20\u6807\u952e\u76d8\u54cd\u5e94\u51fd\u6570\nvoid framebuffer_size_callback(GLFWwindow* window, int width, int height);\nvoid mouse_callback(GLFWwindow* window, double xpos, double ypos);\nvoid scroll_callback(GLFWwindow* window, double xoffset, double yoffset);\nvoid processInput(GLFWwindow *window);\n\n\nconst char *vertexShaderSource = \"#version 330 core\\n\"\n\t\"layout (location = 0) in vec3 aPos;\\n\"\n\t\"layout (location = 1) in vec3 PosColor;\\n\"\n\t\"out vec3 positionColor;\\n\"\n\t\"uniform mat4 model;\\n\"\n\t\"uniform mat4 view;\\n\"\n\t\"uniform mat4 projection;\\n\"\n\t\"void main()\\n\"\n\t\"{\\n\"\n\t\"   gl_Position = projection * view * model * vec4(aPos, 1.0);\\n\"\n\t\"\tpositionColor=PosColor;\\n\"\n\t\"}\\0\";\n\nconst char *fragmentShaderSource = \"#version 330 core\\n\"\n\t\"out vec4 FragColor;\\n\"\n\t\"in vec3 positionColor;\\n\"\n\t\"void main()\\n\"\n\t\"{\\n\"\n\t\"   FragColor = vec4(positionColor,1.0);\\n\"\n\t\"}\\n\\0\";\n\n\nconst float vertices[] = {                  \/\/\u7acb\u65b9\u4f53\u6570\u7ec4\n\t-0.5f, -0.5f, -0.5f, 1.0f,0.0f,0.0f,\n\t0.5f, -0.5f, -0.5f,  1.0f,0.0f,0.0f,\n\t0.5f,  0.5f, -0.5f,  1.0f,0.0f,0.0f,\n\t0.5f,  0.5f, -0.5f,  1.0f,0.0f,0.0f,\n\t-0.5f,  0.5f, -0.5f,  1.0f,0.0f,0.0f,\n\t-0.5f, -0.5f, -0.5f,  1.0f,0.0f,0.0f,\n\n\t-0.5f, -0.5f,  0.5f,  0.0f,1.0f,0.0f,\n\t0.5f, -0.5f,  0.5f,  0.0f,1.0f,0.0f,\n\t0.5f,  0.5f,  0.5f,  0.0f,1.0f,0.0f,\n\t0.5f,  0.5f,  0.5f,  0.0f,1.0f,0.0f,\n\t-0.5f,  0.5f,  0.5f,  0.0f,1.0f,0.0f,\n\t-0.5f, -0.5f,  0.5f,  0.0f,1.0f,0.0f,\n\n\t-0.5f,  0.5f,  0.5f,  0.0f,0.0f,1.0f,\n\t-0.5f,  0.5f, -0.5f,  0.0f,0.0f,1.0f,\n\t-0.5f, -0.5f, -0.5f,  0.0f,0.0f,1.0f,\n\t-0.5f, -0.5f, -0.5f,  0.0f,0.0f,1.0f,\n\t-0.5f, -0.5f,  0.5f,  0.0f,0.0f,1.0f,\n\t-0.5f,  0.5f,  0.5f,  0.0f,0.0f,1.0f,\n\n\t0.5f,  0.5f,  0.5f,  0.5f,0.0f,0.0f,\n\t0.5f,  0.5f, -0.5f,  0.5f,0.0f,0.0f,\n\t0.5f, -0.5f, -0.5f,  0.5f,0.0f,0.0f,\n\t0.5f, -0.5f, -0.5f,  0.5f,0.0f,0.0f,\n\t0.5f, -0.5f,  0.5f,  0.5f,0.0f,0.0f,\n\t0.5f,  0.5f,  0.5f,  0.5f,0.0f,0.0f,\n\n\t-0.5f, -0.5f, -0.5f,  0.0f,0.5f,0.0f,\n\t0.5f, -0.5f, -0.5f,  0.0f,0.5f,0.0f,\n\t0.5f, -0.5f,  0.5f,  0.0f,0.5f,0.0f,\n\t0.5f, -0.5f,  0.5f,  0.0f,0.5f,0.0f,\n\t-0.5f, -0.5f,  0.5f,  0.0f,0.5f,0.0f,\n\t-0.5f, -0.5f, -0.5f,  0.0f,0.5f,0.0f,\n\n\t-0.5f,  0.5f, -0.5f,  0.0f,0.0f,0.5f,\n\t0.5f,  0.5f, -0.5f,  0.0f,0.0f,0.5f,\n\t0.5f,  0.5f,  0.5f,  0.0f,0.0f,0.5f,\n\t0.5f,  0.5f,  0.5f,  0.0f,0.0f,0.5f,\n\t-0.5f,  0.5f,  0.5f,  0.0f,0.0f,0.5f,\n\t-0.5f,  0.5f, -0.5f,  0.0f,0.0f,0.5f\n};\n\nfloat screen_width = 1920.0f;          \/\/\u7a97\u53e3\u5bbd\u5ea6\nfloat screen_height = 1080.0f;          \/\/\u7a97\u53e3\u9ad8\u5ea6\n\/\/\u76f8\u673a\u53c2\u6570\nglm::vec3 camera_position = glm::vec3(0.0f, 0.0f, 3.0f);     \/\/\u6444\u50cf\u673a\u4f4d\u7f6e\nglm::vec3 camera_front = glm::vec3(0.0f, 0.0f, -1.0f);       \/\/\u6444\u50cf\u673a\u65b9\u5411\nglm::vec3 camera_up = glm::vec3(0.0f, 1.0f, 0.0f);           \/\/\u6444\u50cf\u673a\u4e0a\u5411\u91cf\n\/\/\u89c6\u91ce\nfloat fov = 45.0f;\n\n\nCamera camera(glm::vec3(0.0f, 0.0f, 3.0f));\nfloat lastX = screen_width \/ 2.0f;\nfloat lastY = screen_height \/ 2.0f;\nbool firstMouse = true;\n\nfloat deltaTime = 0.0f;\nfloat lastFrame = 0.0f;\n\nint main() {\n\t\/\/ \u521d\u59cb\u5316GLFW\n\tglfwInit();                                                     \/\/ \u521d\u59cb\u5316GLFW\n\tglfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);                  \/\/ OpenGL\u7248\u672c\u4e3a3.3\uff0c\u4e3b\u6b21\u7248\u672c\u53f7\u5747\u8bbe\u4e3a3\n\tglfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);\n\tglfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);  \/\/ \u4f7f\u7528\u6838\u5fc3\u6a21\u5f0f(\u65e0\u9700\u5411\u540e\u517c\u5bb9\u6027)\n\tglfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);            \/\/ \u5982\u679c\u4f7f\u7528\u7684\u662fMac OS X\u7cfb\u7edf\uff0c\u9700\u52a0\u4e0a\u8fd9\u884c\n\tglfwWindowHint(GLFW_RESIZABLE, FALSE);\t\t\t\t\t\t    \/\/ \u4e0d\u53ef\u6539\u53d8\u7a97\u53e3\u5927\u5c0f\n\n\t\/\/ \u521b\u5efa\u7a97\u53e3(\u5bbd\u3001\u9ad8\u3001\u7a97\u53e3\u540d\u79f0)\n\tauto window = glfwCreateWindow(screen_width, screen_height, \"Cube\", nullptr, nullptr);\n\tif (window == nullptr) {                                        \/\/ \u5982\u679c\u7a97\u53e3\u521b\u5efa\u5931\u8d25\uff0c\u8f93\u51faFailed to Create OpenGL Context\n\t\tstd::cout &lt;&lt; \"Failed to Create OpenGL Context\" &lt;&lt; std::endl;\n\t\tglfwTerminate();\n\t\treturn -1;\n\t}\n\tglfwMakeContextCurrent(window);                                 \/\/ \u5c06\u7a97\u53e3\u7684\u4e0a\u4e0b\u6587\u8bbe\u7f6e\u4e3a\u5f53\u524d\u7ebf\u7a0b\u7684\u4e3b\u4e0a\u4e0b\u6587\n\n\tglfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n\tglfwSetCursorPosCallback(window, mouse_callback);\n\tglfwSetScrollCallback(window, scroll_callback);\n\tglfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);\n\n\n\t\/\/ \u521d\u59cb\u5316GLAD\uff0c\u52a0\u8f7dOpenGL\u51fd\u6570\u6307\u9488\u5730\u5740\u7684\u51fd\u6570\n\tif (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))\n\t{\n\t\tstd::cout &lt;&lt; \"Failed to initialize GLAD\" &lt;&lt; std::endl;\n\t\treturn -1;\n\t}\n\n\t\/\/ \u6307\u5b9a\u5f53\u524d\u89c6\u53e3\u5c3a\u5bf8(\u524d\u4e24\u4e2a\u53c2\u6570\u4e3a\u5de6\u4e0b\u89d2\u4f4d\u7f6e\uff0c\u540e\u4e24\u4e2a\u53c2\u6570\u662f\u6e32\u67d3\u7a97\u53e3\u5bbd\u3001\u9ad8)\n\tglViewport(0, 0, screen_width, screen_height);\n\n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\/\/ build and compile our shader program\n\t\/\/ ------------------------------------\n\t\/\/ vertex shader\n\tunsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);\n\tglShaderSource(vertexShader, 1, &amp;vertexShaderSource, NULL);\n\tglCompileShader(vertexShader);\n\t\/\/ check for shader compile errors\n\tint success;\n\tchar infoLog[512];\n\tglGetShaderiv(vertexShader, GL_COMPILE_STATUS, &amp;success);\n\tif (!success)\n\t{\n\t\tglGetShaderInfoLog(vertexShader, 512, NULL, infoLog);\n\t\tstd::cout &lt;&lt; \"ERROR::SHADER::VERTEX::COMPILATION_FAILED\\n\" &lt;&lt; infoLog &lt;&lt; std::endl;\n\t}\n\t\/\/ fragment shader\n\tunsigned int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);\n\tglShaderSource(fragmentShader, 1, &amp;fragmentShaderSource, NULL);\n\tglCompileShader(fragmentShader);\n\t\/\/ check for shader compile errors\n\tglGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &amp;success);\n\tif (!success)\n\t{\n\t\tglGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);\n\t\tstd::cout &lt;&lt; \"ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\\n\" &lt;&lt; infoLog &lt;&lt; std::endl;\n\t}\n\t\/\/ link shaders\n\tunsigned int shaderProgram = glCreateProgram();\n\tglAttachShader(shaderProgram, vertexShader);\n\tglAttachShader(shaderProgram, fragmentShader);\n\tglLinkProgram(shaderProgram);\n\t\/\/ check for linking errors\n\tglGetProgramiv(shaderProgram, GL_LINK_STATUS, &amp;success);\n\tif (!success) {\n\t\tglGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);\n\t\tstd::cout &lt;&lt; \"ERROR::SHADER::PROGRAM::LINKING_FAILED\\n\" &lt;&lt; infoLog &lt;&lt; std::endl;\n\t}\n\tglDeleteShader(vertexShader);\n\tglDeleteShader(fragmentShader);\n\n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n\n\t\/\/Shader shader(\"..\/debug\/shader\/task-cube.vs\", \"..\/debug\/shader\/task-cube.fs\");\/\/\u52a0\u8f7d\u7740\u8272\u5668\n\n\t\/\/ \u751f\u6210\u5e76\u7ed1\u5b9aVAO\u548cVBO\n\tGLuint vertex_array_object; \/\/ == VAO\n\tglGenVertexArrays(1, &amp;vertex_array_object);\n\tglBindVertexArray(vertex_array_object);\n\n\tGLuint vertex_buffer_object; \/\/ == VBO\n\tglGenBuffers(1, &amp;vertex_buffer_object);\n\tglBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object);\n\t\/\/ \u5c06\u9876\u70b9\u6570\u636e\u7ed1\u5b9a\u81f3\u5f53\u524d\u9ed8\u8ba4\u7684\u7f13\u51b2\u4e2d\n\tglBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);\n\n\t\/\/ \u8bbe\u7f6e\u9876\u70b9\u5c5e\u6027\u6307\u9488\n\tglVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);\n\tglEnableVertexAttribArray(0);\n\n\tglVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3 * sizeof(float)));\n\tglEnableVertexAttribArray(1);\n\n\n\tglEnable(GL_DEPTH_TEST);\n\t\/\/ Render loop\u4e3b\u5faa\u73af\n\twhile (!glfwWindowShouldClose(window)) { \n\t\t\/\/\u8ba1\u7b97\u6bcf\u5e27\u7684\u65f6\u95f4\u5dee\n\t\tfloat currentFrame = glfwGetTime();\n\t\tdeltaTime = currentFrame - lastFrame;\n\t\tlastFrame = currentFrame;\n\t\tprocessInput(window);\n\n\t\t\/\/\u8fdb\u5165\u4e3b\u5faa\u73af\uff0c\u6e05\u7406\u989c\u8272\u7f13\u51b2\u6df1\u5ea6\u7f13\u51b2\n\t\tglClearColor(0.0f, 0.34f, 0.57f, 1.0f);\n\t\tglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\/\/\u6e05\u7406\u989c\u8272\u7f13\u51b2\u548c\u6df1\u5ea6\u7f13\u51b2\n\n\t\t\/\/shader.use();\n\t\tglUseProgram(shaderProgram);\n\n\t\t\/\/ Transform\u5750\u6807\u53d8\u6362\u77e9\u9635\n\t\tglm::mat4 model(1);\/\/model\u77e9\u9635\uff0c\u5c40\u90e8\u5750\u6807\u53d8\u6362\u81f3\u4e16\u754c\u5750\u6807\n\t\tmodel = glm::translate(model, glm::vec3(0.0,0.0,0.0));\n\t\tmodel = glm::rotate(model, (float)glfwGetTime(), glm::vec3(0.5f, 1.0f, 0.0f));\n\t\tmodel = glm::scale(model, glm::vec3(1.0f,1.0f,1.0f));\n\t\tglm::mat4 view(1);\/\/view\u77e9\u9635\uff0c\u4e16\u754c\u5750\u6807\u53d8\u6362\u81f3\u89c2\u5bdf\u5750\u6807\u7cfb\n\t\tview = camera.GetViewMatrix();\n\t\tglm::mat4 projection(1);\/\/projection\u77e9\u9635\uff0c\u6295\u5f71\u77e9\u9635\n\t\tprojection = glm::perspective(glm::radians(camera.Zoom), screen_width \/ screen_height, 0.1f, 100.0f);\n\n\t\t\/\/ \u5411\u7740\u8272\u5668\u4e2d\u4f20\u5165\u53c2\u6570\n\t\tstd::string strModel = \"model\";\n\t\tstd::string strView = \"view\";\n\t\tstd::string strProjection = \"projection\";\n\n\t    glUniformMatrix4fv(glGetUniformLocation(shaderProgram, strModel.c_str()), 1, GL_FALSE, &amp;model[0][0]);\n\t\tglUniformMatrix4fv(glGetUniformLocation(shaderProgram, strView.c_str()), 1, GL_FALSE, &amp;view[0][0]);\n\t\tglUniformMatrix4fv(glGetUniformLocation(shaderProgram, strProjection.c_str()), 1, GL_FALSE, &amp;projection[0][0]);\n\n\n\t\t\/\/\u7ed8\u5236\n\t\tglBindVertexArray(vertex_array_object);\n\t\tglDrawArrays(GL_TRIANGLES, 0, 36);\n\t\tglBindVertexArray(0);\n\n\n\t\tglfwSwapBuffers(window);\n\t\tglfwPollEvents();\n\t}\n\t\/\/\u91ca\u653eVAOVBO\n\tglDeleteVertexArrays(1, &amp;vertex_array_object);\n\tglDeleteBuffers(1, &amp;vertex_buffer_object);\n\n\t\/\/ \u6e05\u7406\u6240\u6709\u7684\u8d44\u6e90\u5e76\u6b63\u786e\u9000\u51fa\u7a0b\u5e8f\n\tglfwTerminate();\n\treturn 0;\n}\n\nvoid processInput(GLFWwindow *window)\n{\n\tif (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)\n\t{\n\t\tglfwSetWindowShouldClose(window, true);\n\t}\n\n\tif (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)\n\t{\n\t\tcamera.ProcessKeyboard(FORWARD, deltaTime);\n\t}\n\n\tif (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)\n\t{\n\t\tcamera.ProcessKeyboard(BACKWARD, deltaTime);\n\t}\n\n\tif (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)\n\t{\n\t\tcamera.ProcessKeyboard(LEFT, deltaTime);\n\t}\n\n\tif (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)\n\t{\n\t\tcamera.ProcessKeyboard(RIGHT, deltaTime);\n\t}\n}\n\nvoid framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n\tglViewport(0, 0, width, height);\n}\n\nvoid mouse_callback(GLFWwindow* window, double xpos, double ypos)\n{\n\tif (firstMouse)\n\t{\n\t\tlastX = xpos;\n\t\tlastY = ypos;\n\t\tfirstMouse = false;\n\t}\n\n\tfloat xoffset = xpos - lastX;\n\tfloat yoffset = lastY - ypos;\n\n\tlastX = xpos;\n\tlastY = ypos;\n\n\tcamera.ProcessMouseMovement(xoffset, yoffset);\n}\n\nvoid scroll_callback(GLFWwindow* window, double xoffset, double yoffset)\n{\n\tcamera.ProcessMouseScroll(yoffset);\n}<\/pre>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background\">\u5b8c\u6574\u7684\u9879\u76ee\u4ee3\u7801<\/p>\n\n\n\n<p>\u94fe\u63a5\uff1a<a href=\"https:\/\/pan.baidu.com\/s\/1GH_3Yqe4FJt6ivZ1DZkhSA\">https:\/\/pan.baidu.com\/s\/1GH_3Yqe4FJt6ivZ1DZkhSA<\/a> <\/p>\n\n\n\n<p>\u63d0\u53d6\u7801\uff1au8gs<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background\">\u53c2\u8003\u8d44\u6599<\/p>\n\n\n\n<p><a href=\"https:\/\/www.icourse163.org\/learn\/HUST-1003636001?tid=1457257442#\/learn\/content?type=detail&amp;id=1232561377&amp;sm=1\">https:\/\/www.icourse163.org\/learn\/HUST-1003636001?tid=1457257442#\/learn\/content?type=detail&amp;id=1232561377&amp;sm=1<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 \u4e3b\u8981\u4ecb\u7ecd\u4f7f\u7528OpenGL\u7ed8\u5236\u4e00\u4e2a\u7acb\u65b9\u4f53\uff0c\u5e76\u7ed9\u7acb\u65b9\u4f53\u7684\u516d\u4e2a\u9762\u8d4b\u4e88\u4e0d\u540c\u7684\u989c\u8272\uff0c\u5e76\u4f7f\u7acb\u65b9\u4f53\u53ef\u4ee5\u81ea\u52a8\u65cb\u8f6c\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u952e\u76d8\u6309\u952eA\u3001D\u3001W\u3001S\u8fdb\u884c\u5de6\u3001\u53f3\u3001\u4e0a\u3001\u4e0b\u79fb\u52a8\u3002 1.\u4f7f\u7528GLM\u51fd\u6570\u5e93(OpenGL Mathematics)\u8fdb\u884c\u7acb\u65b9\u4f53\u4e3e\u77e9\u9635\u7684\u53d8\u6362\u8fd0\u7b97\uff1b 2.\u4f7f\u7528PVM\u77e9\u9635\u8fdb\u884c\u5750\u6807\u7cfb\u53d8\u6362\u3002PVM\u77e9\u9635\u5373 P:projection;V:view;M:model\u3002model\u77e9\u9635\u5bf9\u5e94\u4ece\u5c40\u90e8\u5750\u6807\u7cfb\u5230\u4e16\u754c\u5750\u6807\u7cfb\u7684\u53d8\u6362\uff1bview\u77e9\u9635\u5bf9\u5e94\u4ece\u4e16\u754c\u5750\u6807\u7cfb\u5230\u89c2\u5bdf\u5750\u6807\u7cfb\u7684\u53d8\u6362\uff1bprojection \u77e9\u9635\u5bf9\u5e94\u4ece\u89c2\u5bdf\u5750\u6807\u7cfb\u5230\u526a\u88c1\u7a7a\u95f4\u7684\u53d8\u6362\u3002 3.\u901a\u8fc7\u6ce8\u518c\u9f20\u6807\u548c\u952e\u76d8\u63a7\u5236\u51fd\u6570\uff0c\u4f7f\u7acb\u65b9\u4f53\u53ef\u4ee5\u901a\u8fc7\u8bbe\u5907\u63a7\u5236\u3002 \u6548\u679c \u4e3b\u8981\u5b9e\u73b0\u4ee3\u7801 main.cpp \u5b8c\u6574\u7684\u9879\u76ee\u4ee3\u7801 \u94fe\u63a5\uff1ahttps:\/\/pan.baidu.com\/s\/1GH_3Yqe4FJt6ivZ1DZkhSA \u63d0\u53d6\u7801\uff1au8gs \u53c2\u8003\u8d44\u6599 https:\/\/www.icourse163.org\/learn\/HUST-1003636001?tid=1457257442#\/learn\/content?type=detail&amp;id=1232561377&amp;sm=1<\/p>\n","protected":false},"author":1,"featured_media":270,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[15],"class_list":["post-267","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-opengl","tag-opengl"],"_links":{"self":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/comments?post=267"}],"version-history":[{"count":1,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":269,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/267\/revisions\/269"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/media\/270"}],"wp:attachment":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/media?parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/categories?post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/tags?post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}