How to create an empty window with specific color using GLFW and bgfx in C++

1 Answer

0 votes
#include <GLFW/glfw3.h>
#include "bgfx/bgfx.h"

#define GLFW_EXPOSE_NATIVE_WIN32
#include "GLFW/glfw3native.h"

#define WIDTH 1200
#define HEIGHT 800

int main(int argc, char* argv[]) {

    if (!glfwInit())
        return 1;

    GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "bgfx 3d graphics library", NULL, NULL);

    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);

    bgfx::Init init;

    init.platformData.nwh = glfwGetWin32Window(window);

    init.resolution.width = WIDTH;
    init.resolution.height = HEIGHT;
    init.resolution.reset = BGFX_RESET_VSYNC;

    if (!bgfx::init(init))
        return 1;

    bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x33AA55FF, 1.0f, 0);
    bgfx::setViewRect(0, 0, 0, WIDTH, HEIGHT);
    bgfx::touch(0);

    while (!glfwWindowShouldClose(window)) {
        glfwPollEvents();
        bgfx::frame();
    }

    bgfx::shutdown();
    glfwTerminate();
}

 



answered Feb 6, 2022 by avibootz
edited Mar 13, 2022 by avibootz
...