0

The code I am trying to run is the same code that was in the tutorial on https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Base_code yet every time I try to run it it does not seem to work.

#include <vulkan/vulkan.h>

#include <iostream>
#include <stdexcept>
#include <cstdlib>
#include <GLFW/glfw3.h>
#define GLFW_INCLUDE_VULKAN

const uint32_t WIDTH = 800;
const uint32_t HEIGHT = 600;


class HelloTriangleApplication {
public:
    void run() {
        initWindow();
        initVulkan();
        mainLoop();
        cleanup();
    }

private:
    void initWindow() {
        glfwInit();

        glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
        glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);

        window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr);
    }
    void initVulkan() {

    }

    void mainLoop() {
        while (!glfwWindowShouldClose(window)) {
            glfwPollEvents();
        }
    }

    void cleanup() {
        glfwDestroyWindow(window);

        glfwTerminate();
    }
};

int main() {
    HelloTriangleApplication app;

    try {
        app.run();
    }
    catch (const std::exception& e) {
        std::cerr << e.what() << std::endl;
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

The errors I am getting are the following:

identifier "GLFW_CLIENT_API" is undefined; line 26

identifier "GLFW_NO_API" is undefined; line 26

identifier "GLFW_RESIZABLE" is undefined; line 27

identifier "GLFW_FALSE" is undefined; line 27

identifier "window" is undefined; line 29

identifier "window" is undefined; line 36

identifier "window" is undefined; line 42

'window' undeclared identifier; line 36

'window' undeclared identifier; line 42

I copied one for one what was on the tutorial, I added all of the additional dependencies and made sure I have not made any typos yet it still doesn't seem to work.

I have been searching for anything that can help on what is happening but I have yet to find one. If anyone can figure this out it would be very much appreciated.

  • 1
    Not sure, but maybe you need `#define GLFW_INCLUDE_VULCAN` before `#include `? – Adrian Mole Oct 21 '22 at 05:23
  • 2
    *"I copied one for one what was on the tutorial"* -- not quite. Look for the part of the tutorial that mentions `GLFWwindow* window;`. That accounts for the latter errors. – JaMiT Oct 21 '22 at 05:25

0 Answers0