File: test_sf2946226.py

package info (click to toggle)
pyopengl 3.1.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 11,216 kB
  • sloc: python: 80,468; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 955 bytes parent folder | download | duplicates (2)
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
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()

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