1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2025-01-15 17:18:23 +01:00
Diya-API/Diya/DiyaInit.class.st

49 lines
1013 B
Smalltalk
Raw Normal View History

2021-12-18 22:49:03 +01:00
Class {
#name : #DiyaInit,
#superclass : #Object,
#classVars : [
'singleton'
],
#pools : [
'SDL2Constants',
'SDL2Types'
],
#category : #'Diya-Core'
}
{ #category : #'instance creation' }
DiyaInit class >> uniqueInstance [
singleton ifNil: [ singleton := self new ].
^ singleton
]
{ #category : #events }
DiyaInit >> checkDrivers [
|ndriver usableDrivers|
ndriver := SDL2 SDLGetNumVideoDrivers.
usableDrivers := OrderedCollection new.
Transcript show: 'Available drivers: '.
0 to: ndriver - 1 do: [ :i | |dname|
dname := SDL2 SDLGetVideoDriver: i.
Transcript show: dname, ' '.
(SDL2 SDLVideoInit: dname) = 0 ifTrue:[
usableDrivers add: dname.
SDL2 SDLVideoQuit
]
].
Transcript cr.
]
{ #category : #events }
DiyaInit >> eventLoop [
|status|
self checkDrivers.
status := SDL2 init: SDL_INIT_EVERYTHING.
status = 0 ifFalse:[
^ self error: SDL2 getErrorMessage.
].
Transcript show: 'Current selected video driver ', (SDL2 SDLGetCurrentVideoDriver); cr.
SDL2 quit
]