将 pygame.Surface() blitting 到 pygame.OPENGL 显示 [英] blitting pygame.Surface() onto pygame.OPENGL display

查看:104
本文介绍了将 pygame.Surface() blitting 到 pygame.OPENGL 显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 pygame.Surface() 对象 blit 到 pygame.OPENGL 显示器上并翻转显示器?

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, pygame.FULLSCREEN | pygame.OPENGL)

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

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

给我

Traceback (most recent call last):
  File "C:/Game Dev/TESTS/Clock Comparison/opengl_test.py", line 12, in <module>
    display.blit(bg_img, (0, 0))
error: Cannot blit to OPENGL Surfaces (OPENGLBLIT is ok)

推荐答案

你不能.为了避免错误,显示表面需要使用 pygame.OPENGLBLIT 标志而不是 pygame.OPENGL 标志,但是在运行代码之后这个:

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()

显示窗口保持空白.

pygame 文档将此标志列为:

The pygame documentation lists this flag as:

创建一个 OpenGL 渲染上下文/并将其用于 blitting.过时了.

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

您需要找到一种方法来代替 pyOpenGL 本身的任何尝试.

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

这篇关于将 pygame.Surface() blitting 到 pygame.OPENGL 显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆