Skip to content

Commit

Permalink
Merge pull request #3357 from luminosuslight/sdl2_multisamples
Browse files Browse the repository at this point in the history
Fixes #3254: Setting multisamples in SDL2
  • Loading branch information
akshayaurora committed Jul 7, 2015
2 parents ac4bc0c + b7c1bd6 commit fd54e81
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions kivy/core/window/_window_sdl2.pyx
Expand Up @@ -3,6 +3,7 @@ include "../../../kivy/graphics/config.pxi"

from libc.string cimport memcpy
from os import environ
from kivy.config import Config

cdef class _WindowSDL2Storage:
cdef SDL_Window *win
Expand Down Expand Up @@ -73,9 +74,28 @@ cdef class _WindowSDL2Storage:
x = SDL_WINDOWPOS_UNDEFINED
if y is None:
y = SDL_WINDOWPOS_UNDEFINED

self.win = SDL_CreateWindow(NULL, x, y, width, height,
self.win_flags)

# Multisampling:
# (The number of samples is limited to 4, because greater values
# aren't supported with some video drivers.)
cdef int multisamples
multisamples = Config.getint('graphics', 'multisamples')
if multisamples > 0:
# try to create window with multisampling:
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, min(multisamples, 4))
self.win = SDL_CreateWindow(NULL, x, y, width, height,
self.win_flags)
if not self.win:
# if an error occured, create window without multisampling:
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0)
self.win = SDL_CreateWindow(NULL, x, y, width, height,
self.win_flags)
else:
self.win = SDL_CreateWindow(NULL, x, y, width, height,
self.win_flags)

if not self.win:
self.die()

Expand All @@ -86,7 +106,7 @@ cdef class _WindowSDL2Storage:
if not self.ctx:
self.die()
SDL_JoystickOpen(0)

SDL_EventState(SDL_DROPFILE, SDL_ENABLE)
cdef int w, h
SDL_GetWindowSize(self.win, &w, &h)
Expand Down

0 comments on commit fd54e81

Please sign in to comment.