Changeset c8cc13f in python-game
- Timestamp:
- Apr 3, 2017, 1:22:44 AM (8 years ago)
- Branches:
- master
- Children:
- cb405de
- Parents:
- 1af0f6d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
game.py
r1af0f6d rc8cc13f 8 8 [w, h] = [0, 0] 9 9 10 def render(surface, overlay, font, state): 11 #surface.fill((0, 0, 0)) 12 10 def render(surface, overlay, font, showOverlay): 13 11 #glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); 14 12 … … 16 14 # break the 3d rendering and reset those back instead of resetting 17 15 # all attributes 18 if state: 16 glPushAttrib(GL_ALL_ATTRIB_BITS) 17 render3d(surface) 18 glPopAttrib(GL_ALL_ATTRIB_BITS) 19 20 if showOverlay: 19 21 renderOverlay(overlay, font) 22 20 23 glPushAttrib(GL_ALL_ATTRIB_BITS) 21 24 projectOverlay(surface, overlay) 22 glPopAttrib(GL_ALL_ATTRIB_BITS)23 else:24 glPushAttrib(GL_ALL_ATTRIB_BITS)25 render3d(surface)26 25 glPopAttrib(GL_ALL_ATTRIB_BITS) 27 26 … … 31 30 #pygame.draw.circle(overlay, (255, 0, 0), (int(w/2), int(h/2)), 540) 32 31 #overlay.set_colorkey((255,0,0)) 32 overlay.fill((0, 0, 0, 255)) 33 33 34 34 text = font.render("2D drawing", True, (0, 128, 0)) … … 52 52 53 53 glBindTexture(GL_TEXTURE_2D, glGenTextures(1)) 54 # maybe use GL_RGBA here instead 55 #glPixelStorei(GL_UNPACK_ALIGNMENT,1) 56 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData) 54 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData) 57 55 58 56 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) … … 156 154 gameDisplay = pygame.display.set_mode((w, h), pygame.FULLSCREEN|pygame.DOUBLEBUF|pygame.OPENGL) 157 155 158 overlay = pygame.Surface((w, h)) 156 # Look into pygame.HWSURFACE for hardware-accelerated surfaces 157 overlay = pygame.Surface((w, h), pygame.SRCALPHA) 159 158 160 159 pygame.display.set_caption('Space Game') … … 165 164 166 165 running = True 167 s tate= False166 showOverlay = False 168 167 169 168 zNear = 1.0/math.tan(math.radians(45.0/2)) … … 185 184 running = False 186 185 elif event.key == pygame.K_SPACE: 187 s tate = not state186 showOverlay = not showOverlay 188 187 189 #print(event) 190 191 render(gameDisplay, overlay, font, state) 188 render(gameDisplay, overlay, font, showOverlay) 192 189 193 190 pygame.display.flip()
Note:
See TracChangeset
for help on using the changeset viewer.