Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <GLFW/glfw3.h>
- // Function prototypes
- void Init();
- void Terminate();
- /// <summary>
- /// A simple class to mimic was Vixnil described
- /// </summary>
- class CustomWindowObject
- {
- public:
- // Constructor
- CustomWindowObject()
- {
- m_window = glfwCreateWindow(500, 500, "Vixnil Test", nullptr, nullptr);
- }
- // Destructor
- ~CustomWindowObject()
- {
- if (m_window)
- {
- glfwDestroyWindow(m_window);
- m_window = nullptr;
- }
- }
- // Public property
- GLFWwindow* m_window;
- };
- /// <summary>
- /// Main entry point
- /// </summary>
- int main(int argc, const char** argv)
- {
- // Attempt to initialize GLFW
- Init();
- // Set some window hints
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- #ifdef __APPLE__
- glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
- #endif // __APPLE__
- // Create the window
- auto myWindow = new CustomWindowObject();
- // Begin the draw loop
- while (!glfwWindowShouldClose(myWindow->m_window))
- {
- glfwSwapBuffers(myWindow->m_window);
- glfwPollEvents();
- }
- // Delete the custom window object
- delete myWindow;
- myWindow = nullptr;
- // Terminate the app
- Terminate();
- // Satisfy the main function
- return 0;
- }
- /// <summary>
- /// Attempt to initialize the app
- /// </summary>
- void Init()
- {
- if (!glfwInit())
- {
- exit(EXIT_FAILURE);
- }
- }
- /// <summary>
- /// Terminates the app
- /// </summary>
- void Terminate()
- {
- glfwTerminate();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement