Skip to content Skip to sidebar Skip to footer

Blitting Pygame.surface() Onto Pygame.opengl Display

How can I blit a pygame.Surface() object onto a pygame.OPENGL display and flip the display? import pygame pygame.init() RES = (640, 480) display = pygame.display.set_mode(RES, py

Solution 1:

You cannot. To avoid the error, the display surface needs to use the pygame.OPENGLBLIT flag instead of the pygame.OPENGL flag, however after running code like this:

import pygame
import sys

pygame.init()

RES = (640, 480)
display = pygame.display.set_mode(RES, pygame.OPENGLBLIT)

bg_img = pygame.Surface(RES).
bg_img.fill((255, 255, 255))

display.blit(bg_img, (0, 0))
pygame.display.flip()
input()
pygame.quit()
sys.exit()

the display window remains blank.

The pygame documentation lists this flag as:

create an OpenGL rendering context / and use it for blitting. Obsolete.

You will need to find a way to do whatever you were trying in pyOpenGL itself instead.

Post a Comment for "Blitting Pygame.surface() Onto Pygame.opengl Display"