Skip to content

Instantly share code, notes, and snippets.

@std-microblock
Created January 26, 2025 10:31
Show Gist options
  • Select an option

  • Save std-microblock/2d7cb4ed154ed8969d0ca5ec755fa799 to your computer and use it in GitHub Desktop.

Select an option

Save std-microblock/2d7cb4ed154ed8969d0ca5ec755fa799 to your computer and use it in GitHub Desktop.
Simple glfw&glad transparent window test
#include "glad/glad.h"
#include "GLFW/glfw3.h"
int main() {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
auto window = glfwCreateWindow(800, 600, "Test", nullptr, nullptr);
if (!window) {
std::println("Failed to create window");
return 1;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::println("Failed to initialize GLAD");
return 1;
}
while (!glfwWindowShouldClose(window)) {
glClearColor(0.1, 0.1, 0.1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);
glVertex2f(-0.5, -0.5);
glColor3f(0, 1, 0);
glVertex2f(0.5, -0.5);
glColor3f(0, 0, 1);
glfwSwapBuffers(window);
glfwPollEvents();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment