Created
January 26, 2025 10:31
-
-
Save std-microblock/2d7cb4ed154ed8969d0ca5ec755fa799 to your computer and use it in GitHub Desktop.
Simple glfw&glad transparent window test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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