Skip to content

Instantly share code, notes, and snippets.

@joeyespo
Created May 21, 2011 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeyespo/984278 to your computer and use it in GitHub Desktop.
Save joeyespo/984278 to your computer and use it in GitHub Desktop.
A Python port of the initialization code from a gamedev.net post
# Ported from: http://www.gamedev.net/topic/318673-fbo-question/
#
# Revised to remove the references to cocos2d
import pyglet
from pyglet.gl import *
from ctypes import c_ulong
def init():
# Ported from: http://www.gamedev.net/topic/318673-fbo-question/
numBuffers = 1
lp_color_tex = c_ulong()
glGenTextures(numBuffers, lp_color_tex);
color_tex = lp_color_tex
# initialize textures
glBindTexture(GL_TEXTURE_2D,color_tex);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,512,512,0,GL_RGBA,GL_INT,0);
lp_depth_rb = c_ulong()
glGenRenderbuffersEXT(1, lp_depth_rb);
depth_rb = lp_depth_rb.value
# initialize depth render buffer
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 512, 512);
lp_fb = c_ulong()
glGenFramebuffersEXT(numBuffers, lp_fb);
fb = lp_fb.value
# initialize frame buffers
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,color_tex, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);
if __name__ == '__main__':
init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment