Changes in / [a7d1e5e:3511899] in python-game


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • game.py

    ra7d1e5e r3511899  
    88[w, h] = [0, 0]
    99
    10 def render(surface, overlay, font, showOverlay):
     10def render(surface, overlay, font, state):
     11   #surface.fill((0, 0, 0))
     12
    1113   #glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE);
    1214
    13    # I should really figure out which attributes in the 2D rendering
    14    # break the 3d rendering and reset those back instead of resetting
    15    # all attributes
    16    glPushAttrib(GL_ALL_ATTRIB_BITS)
    17    render3d(surface)
    18    glPopAttrib(GL_ALL_ATTRIB_BITS)
    19 
    20    if showOverlay:
     15   if state:
    2116      renderOverlay(overlay, font)
    22 
    23       glPushAttrib(GL_ALL_ATTRIB_BITS)
    2417      projectOverlay(surface, overlay)
    25       glPopAttrib(GL_ALL_ATTRIB_BITS)
     18   else:
     19      render3d(surface)
    2620
    2721
     
    3024   #pygame.draw.circle(overlay, (255, 0, 0), (int(w/2), int(h/2)), 540)
    3125   #overlay.set_colorkey((255,0,0))
    32    overlay.fill((0, 0, 0, 255))
    3326
    3427   text = font.render("2D drawing", True, (0, 128, 0))
     
    4033   
    4134   glPushMatrix()
    42 
    43    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    44 
    4535   glTranslatef(0.0,0.0,-zNear)
    4636
     
    5242
    5343   glBindTexture(GL_TEXTURE_2D, glGenTextures(1))
    54    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData)
     44   # maybe use GL_RGBA here instead
     45   #glPixelStorei(GL_UNPACK_ALIGNMENT,1)
     46   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData)
    5547
    5648   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
     
    154146   gameDisplay = pygame.display.set_mode((w, h), pygame.FULLSCREEN|pygame.DOUBLEBUF|pygame.OPENGL)
    155147
    156 # Look into pygame.HWSURFACE for hardware-accelerated surfaces
    157 overlay = pygame.Surface((w, h), pygame.SRCALPHA)
     148overlay = pygame.Surface((w, h))
    158149
    159150pygame.display.set_caption('Space Game')
     
    164155
    165156running = True
    166 showOverlay = False
     157state = False
    167158
    168159zNear = 1.0/math.tan(math.radians(45.0/2))
     
    184175            running = False
    185176         elif event.key == pygame.K_SPACE:
    186             showOverlay = not showOverlay
     177            state = not state
    187178
    188    render(gameDisplay, overlay, font, showOverlay)
     179      #print(event)
     180
     181   render(gameDisplay, overlay, font, state)
    189182
    190183   pygame.display.flip()
Note: See TracChangeset for help on using the changeset viewer.