I create a game and I would like to set the gamma of the screen. For example:
import pygame
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((600, 450))
font = pygame.font.SysFont('consolas', 25)
red = 1
green = 1
blue = 1
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
exit()
screen.fill((20, 20, 20))
# draw colored zones
for x in range(600):
pygame.draw.line(screen, (x * 255 / 600, 0, 0), (x, 0), (x, 100))
for x in range(600):
pygame.draw.line(screen, (0, x * 255 / 600, 0), (x, 100), (x, 200))
for x in range(600):
pygame.draw.line(screen, (0, 0, x * 255 / 600), (x, 200), (x, 300))
if pygame.mouse.get_pressed()[0]:
x, y = pygame.mouse.get_pos()
if y < 100:
red = x / 300
pygame.display.set_gamma(red, green, blue)
elif y < 200:
green = x / 300
pygame.display.set_gamma(red, green, blue)
elif y < 300:
blue = x / 300
pygame.display.set_gamma(red, green, blue)
text = 'pygame.display.set_gamma(%.2f, %.2f, %.2f)' % (red, green, blue)
text = font.render(text, 0, (255, 255, 255), True)
screen.blit(text, (10, 440 - text.get_height())) # render the text
pygame.display.flip()
But when I updated my pygame version to 2.0.0.dev6, the gamma correction didn't work, and I saw ugly colors, blue and yellow flashing irregularly.
I'm on Windows 10.
EDIT 1
After investigation, the green color seems not to be handled by the set_gamma function. When I change x value in the color (0, x * 255 / 600, 0), nothing happens.
EDIT 2
I now have the latest pygame version - now litteraly nothing happens.
According to the documentation,
Not all systems and hardware support gamma ramps
Ok! Maybe my computer doesn't handle this function! But:
if the function succeeds it will return True.
And I get True, even if nothing works as expected.
Does someone see clearly in this mess of bugs?