Created
November 12, 2025 18:22
-
-
Save 8Observer8/81dc4cea56969e4015cb5807aff38d12 to your computer and use it in GitHub Desktop.
Background color using OpenGL, Pygame, and Python
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
| # pip install PyOpenGL Pygame | |
| import pygame | |
| from OpenGL.GL import * | |
| from pygame.locals import * | |
| def main(): | |
| pygame.init() | |
| pygame.display.set_mode((350, 350), DOUBLEBUF | OPENGL) | |
| pygame.display.set_caption("PyOpenGL, Pygame, Python") | |
| glClearColor(0.2, 0.2, 0.2, 1) | |
| running = True | |
| while running: | |
| for event in pygame.event.get(): | |
| if event.type == pygame.QUIT: | |
| running = False | |
| glClear(GL_COLOR_BUFFER_BIT) | |
| pygame.display.flip() | |
| pygame.time.wait(10) | |
| pygame.quit() | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment