mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-27 03:48:21 +01:00
refactory logging
This commit is contained in:
parent
ae9c884997
commit
1884963e4e
@ -38,39 +38,10 @@ DiyaBoot class >> uniqueInstance [
|
|||||||
^ singleton
|
^ singleton
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #events }
|
|
||||||
DiyaBoot >> 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 }
|
{ #category : #events }
|
||||||
DiyaBoot >> createRenderer [
|
DiyaBoot >> createRenderer [
|
||||||
|numdriver rinfo|
|
|
||||||
numdriver := SDL2 SDLGetNumRenderDrivers.
|
|
||||||
Transcript show: 'SDL_RENDER_DRIVER available:'.
|
|
||||||
rinfo := SDL_RendererInfo externalNew autoRelease.
|
|
||||||
0 to: numdriver - 1 do:[:i|
|
|
||||||
SDL2 SDLGetRendererDriverInfo: rinfo from: i.
|
|
||||||
Transcript show: rinfo name readString, ' '.
|
|
||||||
].
|
|
||||||
Transcript cr.
|
|
||||||
renderer := window primCreateRenderer: -1 flags: SDL_RENDERER_ACCELERATED.
|
renderer := window primCreateRenderer: -1 flags: SDL_RENDERER_ACCELERATED.
|
||||||
renderer ifNil: [ ^self error: SDL2 getErrorMessage ].
|
renderer ifNil: [ ^self error: SDL2 getErrorMessage ].
|
||||||
renderer primGetRendererInfo: rinfo.
|
|
||||||
Transcript show: 'SDL_RENDER_DRIVER selected: ', rinfo name readString;cr.
|
|
||||||
^renderer
|
^renderer
|
||||||
|
|
||||||
]
|
]
|
||||||
@ -91,23 +62,12 @@ DiyaBoot >> createWindow [
|
|||||||
|
|
||||||
{ #category : #events }
|
{ #category : #events }
|
||||||
DiyaBoot >> init [
|
DiyaBoot >> init [
|
||||||
| status nvdrivers |
|
| status |
|
||||||
Transcript show:'System: ',
|
|
||||||
(Smalltalk globals at: #CODENAME ifAbsent:['']),
|
|
||||||
'-v',(Smalltalk globals at: #VERSION ifAbsent: ['']);
|
|
||||||
cr.
|
|
||||||
status := SDL2 init: SDL_INIT_EVERYTHING.
|
status := SDL2 init: SDL_INIT_EVERYTHING.
|
||||||
status = 0
|
status = 0
|
||||||
ifFalse: [ ^ self error: SDL2 getErrorMessage ].
|
ifFalse: [ ^ self error: SDL2 getErrorMessage ].
|
||||||
nvdrivers := SDL2 SDLGetNumVideoDrivers.
|
display := SDL_DisplayMode externalNew autoRelease.
|
||||||
Transcript show: 'Supported video dirvers:'.
|
SDL2 SDLGetCurrentDisplayMode: display from:0.
|
||||||
0 to: nvdrivers -1 do: [ :i |
|
|
||||||
Transcript show: (SDL2 SDLGetVideoDriver: i), ' '.
|
|
||||||
].
|
|
||||||
Transcript cr.
|
|
||||||
Transcript show: 'Current selected video driver: ',
|
|
||||||
(SDL2 SDLGetCurrentVideoDriver);
|
|
||||||
cr.
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #events }
|
{ #category : #events }
|
||||||
@ -155,16 +115,17 @@ DiyaBoot >> render [
|
|||||||
{ #category : #events }
|
{ #category : #events }
|
||||||
DiyaBoot >> run [
|
DiyaBoot >> run [
|
||||||
self init.
|
self init.
|
||||||
display := SDL_DisplayMode externalNew autoRelease.
|
self startx.
|
||||||
SDL2 SDLGetCurrentDisplayMode: display from:0.
|
|
||||||
self startx
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #events }
|
{ #category : #running }
|
||||||
DiyaBoot >> run: screenSize [
|
DiyaBoot >> run: screenSize [
|
||||||
|
self run: screenSize app: nil
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #running }
|
||||||
|
DiyaBoot >> run: screenSize app: application [
|
||||||
self init.
|
self init.
|
||||||
display := SDL_DisplayMode externalNew autoRelease.
|
|
||||||
SDL2 SDLGetCurrentDisplayMode: display from:0.
|
|
||||||
display w: screenSize x.
|
display w: screenSize x.
|
||||||
display h: screenSize y.
|
display h: screenSize y.
|
||||||
self startx
|
self startx
|
||||||
@ -172,21 +133,53 @@ DiyaBoot >> run: screenSize [
|
|||||||
|
|
||||||
{ #category : #events }
|
{ #category : #events }
|
||||||
DiyaBoot >> setCursorPosition: mappedEvt [
|
DiyaBoot >> setCursorPosition: mappedEvt [
|
||||||
Transcript show: 'x: ', mappedEvt x asString, ' - y: ', mappedEvt y asString; cr.
|
|
||||||
window warpMouseX:((mappedEvt x)* (display w) )
|
window warpMouseX:((mappedEvt x)* (display w) )
|
||||||
Y: ((mappedEvt y) * (display h))
|
Y: ((mappedEvt y) * (display h))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #logging }
|
||||||
|
DiyaBoot >> showSystemInfo [
|
||||||
|
|stream numdriver rinfo |
|
||||||
|
stream := String new writeStream.
|
||||||
|
stream nextPutAll:'System: ';
|
||||||
|
nextPutAll:(Smalltalk globals at: #CODENAME ifAbsent:['']);
|
||||||
|
nextPutAll: '-v';
|
||||||
|
nextPutAll:(Smalltalk globals at: #VERSION ifAbsent: ['']);cr.
|
||||||
|
numdriver := SDL2 SDLGetNumVideoDrivers.
|
||||||
|
stream nextPutAll: 'Supported video dirvers:'.
|
||||||
|
0 to: numdriver -1 do: [ :i |
|
||||||
|
stream nextPutAll: (SDL2 SDLGetVideoDriver: i); nextPutAll: ' '.
|
||||||
|
].
|
||||||
|
stream cr.
|
||||||
|
stream nextPutAll: 'Current selected video driver: ';
|
||||||
|
nextPutAll:(SDL2 SDLGetCurrentVideoDriver);cr.
|
||||||
|
numdriver := SDL2 SDLGetNumRenderDrivers.
|
||||||
|
stream nextPutAll: 'SDL_RENDER_DRIVER available:'.
|
||||||
|
rinfo := SDL_RendererInfo externalNew autoRelease.
|
||||||
|
0 to: numdriver - 1 do:[:i|
|
||||||
|
SDL2 SDLGetRendererDriverInfo: rinfo from: i.
|
||||||
|
stream nextPutAll: rinfo name readString; nextPutAll:' '.
|
||||||
|
].
|
||||||
|
stream cr.
|
||||||
|
renderer primGetRendererInfo: rinfo.
|
||||||
|
stream nextPutAll: 'SDL_RENDER_DRIVER selected: '; nextPutAll: rinfo name readString; cr.
|
||||||
|
stream nextPutAll:'Display resolution: ';
|
||||||
|
nextPutAll:display w asString;
|
||||||
|
nextPutAll: 'x';
|
||||||
|
nextPutAll: display h asString; cr.
|
||||||
|
Transcript show: stream contents
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #events }
|
{ #category : #events }
|
||||||
DiyaBoot >> startx [
|
DiyaBoot >> startx [
|
||||||
Transcript show:'Display resolution: ', display w asString, 'x',display h asString;cr.
|
|
||||||
window := self createWindow.
|
window := self createWindow.
|
||||||
renderer := self createRenderer.
|
renderer := self createRenderer.
|
||||||
|
self showSystemInfo.
|
||||||
self render.
|
self render.
|
||||||
renderer destroy.
|
renderer destroy.
|
||||||
window destroy.
|
window destroy.
|
||||||
SDL2 quit.
|
SDL2 quit.
|
||||||
Transcript show: 'System quit'; cr.
|
|
||||||
self class reset.
|
self class reset.
|
||||||
Smalltalk garbageCollect.
|
Smalltalk garbageCollect.
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user