[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] open gl blit
> It seem open gl blit don't work even with
> OPENGL|DOUBLEBUF|OPENGLBLIT flag any one success
> blit to or from opengl screen ?
i've never actually done anything with the OPENGLBLIT mode.
i just did some simple testing (following along the C SDL
example) but i couldn't get the blit to draw anything.
i'll try to figure out why that is, but i don't think its
a big deal. just use the standard GL functions to blit
a 2d image to the screen. remember, opengl's coordinate
system is bottom to top, opposite of SDL/pygame.
here's some code that shows that....
import pygame, pygame.image
from pygame.locals import *
from OpenGL.GL import *
#create opengl screen and clear it
screen = pygame.display.set_mode((300,300), OPENGL)
#load image and get pixel buffer
image = pygame.image.load('cowbaby.ppm')
pixels = pygame.image.tostring(image, 'RGBA', 1)
size = image.get_size()
#setup opengl for 2d drawing
glOrtho(0, 300, 0, 300, 0, 1)
#show the image onscreen
glDrawPixels(size, size, GL_RGBA, GL_UNSIGNED_BYTE, pix)
pygame mailing list