-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·30 lines (22 loc) · 815 Bytes
/
main.py
File metadata and controls
executable file
·30 lines (22 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sdl2 import *
# There are more pythonic ways of doing this, by using the sdl2.ext module.
def main():
SDL_Init(SDL_INIT_VIDEO)
win = SDL_CreateWindow(b"Hello World!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 620, 387, SDL_WINDOW_SHOWN)
ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC)
bmp = SDL_LoadBMP(b"../img/grumpy-cat.bmp")
tex = SDL_CreateTextureFromSurface(ren, bmp)
SDL_FreeSurface(bmp)
for i in range(20):
SDL_RenderClear(ren)
SDL_RenderCopy(ren, tex, None, None)
SDL_RenderPresent(ren)
SDL_Delay(100)
SDL_DestroyTexture(tex)
SDL_DestroyRenderer(ren)
SDL_DestroyWindow(win)
SDL_Quit()
if __name__ == "__main__":
main()