Changeset a7d1e5e in python-game
- Timestamp:
- Apr 4, 2017, 1:36:04 AM (8 years ago)
- Branches:
- master
- Children:
- a7f54e3, c56629f
- Parents:
- 3511899 (diff), cb405de (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
game.py
r3511899 ra7d1e5e 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 15 if state: 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: 16 21 renderOverlay(overlay, font) 22 23 glPushAttrib(GL_ALL_ATTRIB_BITS) 17 24 projectOverlay(surface, overlay) 18 else: 19 render3d(surface) 25 glPopAttrib(GL_ALL_ATTRIB_BITS) 20 26 21 27 … … 24 30 #pygame.draw.circle(overlay, (255, 0, 0), (int(w/2), int(h/2)), 540) 25 31 #overlay.set_colorkey((255,0,0)) 32 overlay.fill((0, 0, 0, 255)) 26 33 27 34 text = font.render("2D drawing", True, (0, 128, 0)) … … 33 40 34 41 glPushMatrix() 42 43 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 44 35 45 glTranslatef(0.0,0.0,-zNear) 36 46 … … 42 52 43 53 glBindTexture(GL_TEXTURE_2D, glGenTextures(1)) 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) 54 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData) 47 55 48 56 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) … … 146 154 gameDisplay = pygame.display.set_mode((w, h), pygame.FULLSCREEN|pygame.DOUBLEBUF|pygame.OPENGL) 147 155 148 overlay = pygame.Surface((w, h)) 156 # Look into pygame.HWSURFACE for hardware-accelerated surfaces 157 overlay = pygame.Surface((w, h), pygame.SRCALPHA) 149 158 150 159 pygame.display.set_caption('Space Game') … … 155 164 156 165 running = True 157 s tate= False166 showOverlay = False 158 167 159 168 zNear = 1.0/math.tan(math.radians(45.0/2)) … … 175 184 running = False 176 185 elif event.key == pygame.K_SPACE: 177 s tate = not state186 showOverlay = not showOverlay 178 187 179 #print(event) 180 181 render(gameDisplay, overlay, font, state) 188 render(gameDisplay, overlay, font, showOverlay) 182 189 183 190 pygame.display.flip()
Note:
See TracChangeset
for help on using the changeset viewer.