How to create a windows with background color SkyBlue using OpenGL in C

1 Answer

0 votes
#include <GL/glew.h>
#include <GLFW/glfw3.h>

#include <stdio.h>

int main(void)
{
    if (!glfwInit()) {
        printf("glfwInit() Error!");
        return -1;
    }

    GLFWwindow *window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL);
    if (!window) {
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);

    if (glewInit() != GLEW_OK) {
        printf("glewInit() Error!");
        return -1;
    }

    glClearColor(0.196078f, 0.6f, 0.8f, 1.0f); // SkyBlue

    while (!glfwWindowShouldClose(window)) {
        glClear(GL_COLOR_BUFFER_BIT);
        
        glfwSwapBuffers(window);

        glfwPollEvents();
    }

    glfwTerminate();

    return 0;
}



/*
run:


*/

 



answered Jun 5, 2021 by avibootz
...