亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

嘗試用 LWJGL3 繪制基本形狀

嘗試用 LWJGL3 繪制基本形狀

慕容708150 2021-06-01 10:12:42
所以我想使用 VAO 和 VBO 繪制一個形狀,我認為我做的一切都是正確的,但是每當我運行我的代碼時,我都會得到帶有清晰顏色的窗口。在調用創建功能之前嘗試初始化三角形時,我遇到了一個問題,我是否缺少一些開始繪圖的函數?這是我的代碼:int vaoId, vboId, vertexCount;float[] vertices = {    // Left bottom triangle    -0.5f, 0.5f,    -0.5f, -0.5f,    0.5f, -0.5f,};private void init() {    if (!glfwInit()) {        throw new IllegalStateException("Failed to Initialize GLFW!");    }    int width = 1000;    int height = 1000;    glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);    window = glfwCreateWindow(width, height, "App", NULL, NULL);    if (window == 0) {        throw new IllegalStateException("Failed to create Window!");    }    GLFWVidMode videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());    glfwSetWindowPos(window, (videoMode.width() - width) / 2, (videoMode.height() - height) / 2);    // Make the OpenGL context current    glfwMakeContextCurrent(window);    // Enable v-sync    glfwSwapInterval(1);    glfwShowWindow(window);}private void loop() {    // This line is critical for LWJGL's interoperation with GLFW's    // OpenGL context, or any context that is managed externally.    // LWJGL detects the context that is current in the current thread,    // creates the GLCapabilities instance and makes the OpenGL    // bindings available for use.    GL.createCapabilities();    initTriangle();    // Run the rendering loop until the user has attempted to close    // the window or has pressed the ESCAPE key.    while (!glfwWindowShouldClose(window)) {        glClear(GL_COLOR_BUFFER_BIT); // clear the framebuffer        glBindVertexArray(vaoId);        glEnableVertexAttribArray(0);        glDrawArrays(GL_TRIANGLES, 0, vertexCount);        glDisableVertexAttribArray(0);        glBindVertexArray(0);        glfwSwapBuffers(window); // swap the color buffers        // Poll for window events. The key callback above will only be        // invoked during this call.        glfwPollEvents();    }}希望大家幫幫忙,萬分感謝。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 237 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號