Hello, I am trying to upload a PixBuf to an OpenGL texture. I want it to be as optimized as possible. Of course, I'll first need to get it work properly, but I also want it to be quick, since I will upload one to a texture on every frame rendering of my application. What is the best way to do so?
Right now, I have something like this: pixels = buffer.get_pixels() w = image.get_width() # 320 h = image.get_height() # 240 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_id) glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels) glPixelStorei(GL_UNPACK_ALIGNMENT, 1) glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST) My example is not quite working yet, (see http://bitbucket.org/aalex/toonplayer/src/tip/scripts/gl-pixbuf.py ) but I am working to get it OK. I am worried, though, that converting a PixBuf to a Python string will slow things down a lot. Maybe should I use gtk.gdk.PixBuf.get_pixels_array() instead of get_pixels()? But still, will that be quick enough? The most optimized thing to do would be to create a C function that would look like this: void pixbuf_to_texture(int w, int h, GdkPixBuf buffer) { glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 3, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(buffer)); } Does anyone have advices regarding this issue? Thanks a lot ! Alexandre Quessy http://alexandre.quessy.net _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/