Changes in / [cb405de:7145e24] in python-game
Legend:
- Unmodified
- Added
- Removed
-
game.py
rcb405de r7145e24 8 8 [w, h] = [0, 0] 9 9 10 def render(surface, overlay, font, showOverlay): 10 def render(surface, overlay, font, state): 11 #surface.fill((0, 0, 0)) 12 11 13 #glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); 12 14 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: 21 16 renderOverlay(overlay, font) 22 23 glPushAttrib(GL_ALL_ATTRIB_BITS)24 17 projectOverlay(surface, overlay) 25 glPopAttrib(GL_ALL_ATTRIB_BITS) 18 else: 19 render3d(surface) 26 20 27 21 … … 30 24 #pygame.draw.circle(overlay, (255, 0, 0), (int(w/2), int(h/2)), 540) 31 25 #overlay.set_colorkey((255,0,0)) 32 overlay.fill((0, 0, 0, 255))33 26 34 27 text = font.render("2D drawing", True, (0, 128, 0)) … … 40 33 41 34 glPushMatrix() 42 43 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)44 45 35 glTranslatef(0.0,0.0,-zNear) 46 36 … … 52 42 53 43 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) 55 47 56 48 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) … … 154 146 gameDisplay = pygame.display.set_mode((w, h), pygame.FULLSCREEN|pygame.DOUBLEBUF|pygame.OPENGL) 155 147 156 # Look into pygame.HWSURFACE for hardware-accelerated surfaces 157 overlay = pygame.Surface((w, h), pygame.SRCALPHA) 148 overlay = pygame.Surface((w, h)) 158 149 159 150 pygame.display.set_caption('Space Game') … … 164 155 165 156 running = True 166 s howOverlay= False157 state = False 167 158 168 159 zNear = 1.0/math.tan(math.radians(45.0/2)) … … 184 175 running = False 185 176 elif event.key == pygame.K_SPACE: 186 s howOverlay = not showOverlay177 state = not state 187 178 188 render(gameDisplay, overlay, font, showOverlay) 179 #print(event) 180 181 render(gameDisplay, overlay, font, state) 189 182 190 183 pygame.display.flip()
Note:
See TracChangeset
for help on using the changeset viewer.