Texturing and minor GL fixes
Removed Numeric texture reshaping bits in TexMan in favor of
pygame.image.tostring, which has the added benefit of making the texture
properly oriented. Changed accompanying texture coordinates in Collage
and Sprite to work for the now right-side-up textures. The default for
config.square_textures is now False.
Unrelatedly, added a glViewport() call in Engine.init() because my
savage wouldn't display anything without it.
(x,y+ctexsize[1],0)
]
texcoordarray += [
- (1.0,0.0),(1.0,1.0),(0.0,1.0),(0.0,0.0)
+ (0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0)
]
nvertices += 4
f.close()
import pygame
from pygame.locals import *
from Sprite import Sprite
-from Numeric import array,reshape
try:
from OpenGL.GL import *
sres = [int(n * config.scalefactor) for n in resolution]
except AttributeError:
sres = resolution
- flags = OPENGL|DOUBLEBUF|HWSURFACE
+ flags = OPENGL|DOUBLEBUF
try:
if config.fullscreen:
flags |= FULLSCREEN
pass
pygame.display.set_mode(sres, flags)
+ glViewport(0, 0, sres[0], sres[1])
# Set up the camera
glLoadIdentity()
glMatrixMode(GL_PROJECTION)
,'f')
if self.flip and self.mirror:
texcoordarray = array(
- ((0.0,0.0),(0.0,1.0),(1.0,1.0),(1.0,0.0))
+ ((1.0,1.0),(0.0,1.0),(0.0,0.0),(1.0,0.0))
,'f')
elif self.flip:
texcoordarray = array(
- ((0.0,1.0),(0.0,0.0),(1.0,0.0),(1.0,1.0))
+ ((0.0,1.0),(1.0,1.0),(1.0,0.0),(0.0,0.0))
,'f')
elif self.mirror:
texcoordarray = array(
- ((1.0,1.0),(1.0,0.0),(0.0,0.0),(0.0,1.0))
+ ((1.0,0.0),(0.0,0.0),(0.0,1.0),(1.0,1.0))
,'f')
else:
texcoordarray = array(
- ((1.0,0.0),(1.0,1.0),(0.0,1.0),(0.0,0.0))
+ ((0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0))
,'f')
index = array((0,1,2,3),'i')
for i in range(0,len(self.frames)):
from OpenGL.GLU import *
import pygame
from pygame.locals import *
-from Numeric import array,reshape,concatenate
from util import *
import config
newImage.fill((255,255,255,0))
newImage.blit(image, (0, th - h)) # We want this in the lower corner
- # Freaking pygame making us do this by hand...
- colors = pygame.surfarray.pixels3d(newImage)
- alphas = pygame.surfarray.pixels_alpha(newImage)
- alphas = reshape(alphas, (tw,th,1))
- pixels = concatenate((colors,alphas),2)
+ pixels = pygame.image.tostring(newImage, "RGBA", True)
# Create Texture
texture = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, texture)
- glTexImage2Dub(GL_TEXTURE_2D, 0, GL_RGBA8, 0, GL_RGBA, pixels)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, pixels)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
# If your card has trouble with non-square textures (my TNT seems to), set this
# to true to make all textures square
-square_textures = True
-#scalefactor = 2
+square_textures = False
+#scalefactor = 1.0
#fullscreen = True