Source Code Fullscreen OpenGL Overlay with Python (ogl/glfw)

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Meow

Gimme food hooman.
Fleep Tier Donator
Nobleman
Apr 24, 2020
149
3,743
4
How long you been coding/hacking?
3 years, few months
Not trying to measure with @erxn's overlay. This one is on a lower level and using raw opengl instead of pygame. The method used here can also be used on any other language.

Requirements:
pip install pypiwin32 pywin32 pyopengl pyopengl-accelerate glfw
Usage:
with FullScreenOverlay() as overlay:
    while overlay.loop:
        # Simple white square
        glBegin(GL_QUADS)
        glVertex2f(100, 100)
        glVertex2f(200, 100)
        glVertex2f(200, 200)
        glVertex2f(100, 200)
        glEnd()

        overlay.update()
Class:
# coding=utf-8

import glfw
import win32gui
import win32con

from OpenGL.GL import *


class FullScreenOverlay:
    def __init__(self):
        glfw.init()
        self.video_mode, self.window = self.__create_window()

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        glfw.terminate()

    def __create_window(self):
        # glfw
        glfw.window_hint(glfw.DECORATED, 0)
        glfw.window_hint(glfw.TRANSPARENT_FRAMEBUFFER, 1)
        glfw.window_hint(glfw.FLOATING, 1)
        video_mode = glfw.get_video_mode(glfw.get_primary_monitor())
        window = glfw.create_window(
            video_mode.size.width - 1,
            video_mode.size.height - 1,
            "Overlay", None, None
        )
        glfw.make_context_current(window)

        # ws_ex_transparent
        hwnd = glfw.get_win32_window(window)
        win32gui.SetWindowLong(
            hwnd, win32con.GWL_EXSTYLE,
            win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_TRANSPARENT
        )

        # opengl
        glInitGl46VERSION()
        glOrtho(0, video_mode.size.width, 0, video_mode.size.height, -1, 1)

        return video_mode, window

    @property
    def loop(self):
        return not glfw.window_should_close(self.window)

    def update(self):
        glfw.swap_buffers(self.window)
        glfw.poll_events()
 
Last edited:
  • Love
  • Like
Reactions: Rake and XdarionX
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods