1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import pygame
24 import os
25 from OpenGL.GL import *
26 from OpenGL.GL.ARB.multisample import *
27 import Log
28
31 self.screen = None
32 self.caption = caption
33 self.fullscreen = False
34 self.flags = True
35
36 - def setMode(self, resolution, fullscreen = False, flags = pygame.OPENGL | pygame.DOUBLEBUF,
37 multisamples = 0):
38 if fullscreen:
39 flags |= pygame.FULLSCREEN
40
41 self.flags = flags
42 self.fullscreen = fullscreen
43
44 try:
45 pygame.display.quit()
46 except:
47 pass
48
49 pygame.display.init()
50
51 pygame.display.gl_set_attribute(pygame.GL_RED_SIZE, 8)
52 pygame.display.gl_set_attribute(pygame.GL_GREEN_SIZE, 8)
53 pygame.display.gl_set_attribute(pygame.GL_BLUE_SIZE, 8)
54 pygame.display.gl_set_attribute(pygame.GL_ALPHA_SIZE, 8)
55
56 if multisamples:
57 pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1);
58 pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, multisamples);
59
60 try:
61 self.screen = pygame.display.set_mode(resolution, flags)
62 except Exception, e:
63 Log.error(str(e))
64 if multisamples:
65 Log.warn("Video setup failed. Trying without antialiasing.")
66 pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 0);
67 pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, 0);
68 multisamples = 0
69 self.screen = pygame.display.set_mode(resolution, flags)
70 else:
71 Log.error("Video setup failed. Make sure your graphics card supports 32 bit display modes.")
72 raise
73
74 pygame.display.set_caption(self.caption)
75 pygame.mouse.set_visible(False)
76
77 if multisamples:
78 try:
79 glEnable(GL_MULTISAMPLE_ARB)
80 except:
81 pass
82
83 return bool(self.screen)
84
86 assert self.screen
87
88 return pygame.display.toggle_fullscreen()
89
92
94 return pygame.display.list_modes()
95