Changeset 12


Ignore:
Timestamp:
Jun 27, 2010, 12:53:53 PM (10 years ago)
Author:
sam
Message:

Alpha test.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test-map.py

    r8 r12  
    1212
    1313import numpy
     14from math import sin, cos
    1415
    1516textures = [0,0]
     
    3536    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
    3637
     38    #glEnable(GL_ALPHA_TEST)
     39    glEnable(GL_BLEND)
     40    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
     41    #glBlendFunc(GL_SRC_ALPHA, GL_ONE)
     42
     43
    3744def load_textures():
    3845    texturefile = os.path.join('art','test','groundtest.png')
    3946    textureSurface = pygame.image.load(texturefile)
    40     textureData = pygame.image.tostring(textureSurface, "RGBX", 1)
     47    textureData = pygame.image.tostring(textureSurface, "RGBA", 1)
    4148
    4249    glBindTexture(GL_TEXTURE_2D, textures[0])
     
    104111
    105112def draw():
    106     glClear(GL_DEPTH_BUFFER_BIT) # Full redraw: no need to clear color buffer
     113    #glClear(GL_DEPTH_BUFFER_BIT) # Full redraw: no need to clear color buffer
     114    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    107115    glLoadIdentity()
    108116
     
    117125        [ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 ],
    118126        [ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
    119         [ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
    120         [ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
    121         [ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
    122         [ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
     127        [ 51, 51, 52, 52, 52, 51, 52, 52, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
     128        [ 51, 51, 52, 52, 52, 51, 51, 52, 51, 52, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
     129        [ 51, 51, 52, 52, 52, 51, 51, 51, 51, 51, 51, 52, 52, 51, 51, 51, 51, 51, 51, 51 ],
     130        [ 51, 51, 52, 52, 52, 51, 51, 51, 51, 51, 51, 52, 52, 51, 51, 51, 51, 51, 51, 51 ],
    123131        [ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
    124132        [ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 ],
    125133    ]
     134    glPushMatrix()
     135    glTranslatef(50.0 * sin(frames * 0.05), 50.0 * cos(frames * 0.08), 0)
     136    put_map(themap)
     137    glPopMatrix()
     138    glTranslatef(0, 0, 0.2)
    126139    put_map(themap)
    127140
     141frames = 0
     142
    128143def main():
     144    global frames
    129145
    130146    video_flags = OPENGL|DOUBLEBUF
Note: See TracChangeset for help on using the changeset viewer.