Flowchart for Empty GLFW Window

Published April 04, 2019
Advertisement

This example just create a window and clear a canvas with color. Tools: VS2015, GLFW, OpenGL, C++. All libraries are included in the project. You can just download and run it. But you need to set your Visual Studio version in the project settings, Platform Toolset, see the screenshot below:

Spoiler

PlatformToolset.png.3c9a59798e0e30baeee97b337b6bbe48.png

Visual Studio Project: EmptyWindow_GlfwOpenGL31Cpp.zip

main.cpp

Spoiler


#include <glad/glad.h>
#include <GLFW/glfw3.h>

// Create a window with GLFW library
int main()
{
    // Initialization
    glfwInit();                     // Initialize the GLFW library
                                    // Create a window
    GLFWwindow *window = glfwCreateWindow(256, 256, "Empty Window", nullptr, nullptr);
    glfwMakeContextCurrent(window); // Create OpenGL context for drawing
    gladLoadGL();                   // Initialize the GLAD library

    glClearColor(0.2f, 0.3f, 0.3f, 1.0f); // Set a color for clearing a canvas

    // Main Loop of Application
    // Should the window be closed?
    while (!glfwWindowShouldClose(window))
    {
        // Check if any events have been activated
        // (key pressed, mouse moved etc.) and call
        // corresponding response functions
        glfwPollEvents();

        glClear(GL_COLOR_BUFFER_BIT);   // Clear canvas with previously specified color
        glfwSwapBuffers(window);        // Swap the front and back buffers when rendering
    }

    // Clean up resources
    // Clean up GLFW Library Resources
    glfwTerminate();

    return 0;
}

 

DRAKON-flowchart Sandbox

Spoiler

20190405010145.png.9a2f22f20ef052f298f9bbb70626b65a.png

If you do not know what is DRAKON-flowchart, you can watch this short video that I found in Youtube:

Spoiler

 

 

2 likes 3 comments

Comments

Rutin

Really cool, thanks for sharing. I'll look into DRAKON-flowchart to play around in it.

April 04, 2019 08:47 PM
8Observer8

Thank you for your feedback. Yes, this tool is amazing. I like it so much. I want to apply this tool for game development. I think it is very good alternative for standard flowcharts.

I added the "main.cpp" code in my entry and I added the "Clean up GLFW Library Resources" Action icon in the "Clean up resources" branch of DRAKON-flowchart. Check above.

April 04, 2019 09:00 PM
Choo Wagga Choo Choo

oh for sure...this guys got it.  Around the VisualStudio2013 era, this is exactly where I lived. This setup right here. (oglcore 3.3) Loved it. Now...the grass is not always greener. I know you would be better at this 8Observer8, dear sir...what I noticed was there seemed to be some drag in the glfw loop that I couldn't identify and my other sadness was input lag. I think timing was fine. I eventually moved to try custom / native / handle it yourself types and such, finding in some cases, you could do it better. What I'd be interested in is a comparable timing test of this against raw api creation / message handling. I think the extra layer costs some. Any way to try that?

looking for one last half-life3 confirmed... :)

Ah, a blog todo list...just noticed. <slaps head> and yes, the flow chart is very pretty.

April 05, 2019 05:19 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement