1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
import pygame, sys
from pygame.locals import *
import OpenGL
OpenGL.USE_ACCELERATE = False
from OpenGL.GL import *
from OpenGL.GL.EXT.framebuffer_object import *
from OpenGL import error
def draw():
glClearColor(0.0, 0.0, 0.0, 0.0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
# draw stuff here
pygame.display.flip()
def main():
pygame.init()
pygame.display.set_mode((512, 512), OPENGL | DOUBLEBUF)
# setup a texture
tex = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, tex)
glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, None
)
glBindTexture(GL_TEXTURE_2D, 0)
# setup teh fbo
fbo = glGenFramebuffersEXT(1)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo)
glBindTexture(GL_TEXTURE_2D, tex)
# this call produces an error!
glFramebufferTexture2DEXT(
GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0
)
while 1:
event = pygame.event.poll()
if event.type is QUIT:
sys.exit(0)
draw()
print('OK')
break
if __name__ == "__main__":
main()
|