1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2024-12-27 11:58:21 +01:00

Add global display object that refers to current SDL display

This commit is contained in:
Dany LE 2022-08-08 16:35:04 +02:00
parent 4a95c7d6df
commit 676113a697
4 changed files with 50 additions and 6 deletions

View File

@ -16,6 +16,11 @@ Class {
#category : #'Diya-Runtime' #category : #'Diya-Runtime'
} }
{ #category : #'class initialization' }
DiyaBoot class >> initialize [
Smalltalk globals at: #DiyaDisplay put: nil
]
{ #category : #'instance creation' } { #category : #'instance creation' }
DiyaBoot class >> maxFPS [ DiyaBoot class >> maxFPS [
^60 ^60
@ -79,6 +84,8 @@ DiyaBoot >> init [
status = 0 status = 0
ifFalse: [ ^ DiyaCoreAPIError signal: SDL2 getErrorMessage ]. ifFalse: [ ^ DiyaCoreAPIError signal: SDL2 getErrorMessage ].
display := SDL_DisplayMode externalNew autoRelease. display := SDL_DisplayMode externalNew autoRelease.
Smalltalk globals at: #Display ifAbsentPut:display.
Smalltalk globals at: #DiyaDisplay put:display.
SDL2 SDLGetCurrentDisplayMode: display from:0. SDL2 SDLGetCurrentDisplayMode: display from:0.
SDL2 showCursor: 0. SDL2 showCursor: 0.
DiyaSingleton resetAll. DiyaSingleton resetAll.
@ -181,10 +188,7 @@ DiyaBoot >> showSystemInfo [
stream nextPutAll: rinfo name readString; nextPutAll:' '. stream nextPutAll: rinfo name readString; nextPutAll:' '.
]. ].
stream cr. stream cr.
stream nextPutAll:'Display resolution: '; stream nextPutAll: DiyaDisplay asString; cr.
nextPutAll:display w asString;
nextPutAll: 'x';
nextPutAll: display h asString; cr.
self stdout nextPutAll: stream contents self stdout nextPutAll: stream contents
] ]

View File

@ -51,8 +51,7 @@ ImageInitializer >> initializeImage [
do: [ :c | do: [ :c |
[ c initialize ] [ c initialize ]
on: Error on: Error
do: [ c = Cursor do: [ retryList add: c ] ].
ifFalse: [ retryList add: c ] ] ].
retryList retryList
do: [ :c | do: [ :c |
Transcript Transcript

View File

@ -1,11 +1,23 @@
Extension { #name : #SDL2 } Extension { #name : #SDL2 }
{ #category : #'*Diya' }
SDL2 class >> SDLAllocFormat: pixel_format [
^ self ffiCall: #(SDL_PixelFormat * SDL_AllocFormat(Uint32 pixel_format))
]
{ #category : #'*Diya' } { #category : #'*Diya' }
SDL2 class >> SDLClearError [ SDL2 class >> SDLClearError [
^ self ffiCall: #(void SDL_ClearError(void)) ^ self ffiCall: #(void SDL_ClearError(void))
] ]
{ #category : #'*Diya' }
SDL2 class >> SDLFreeFormat: handle [
^ self ffiCall: #(void SDL_FreeFormat(SDL_PixelFormat *handle))
]
{ #category : #'*Diya' } { #category : #'*Diya' }
SDL2 class >> SDLGetCurrentDisplayMode: mode from:index [ SDL2 class >> SDLGetCurrentDisplayMode: mode from:index [
^ self ffiCall: #(int SDL_GetCurrentDisplayMode(int index, SDL_DisplayMode* mode)) ^ self ffiCall: #(int SDL_GetCurrentDisplayMode(int index, SDL_DisplayMode* mode))

View File

@ -25,6 +25,20 @@ SDL_DisplayMode class >> fieldsDesc [
) )
] ]
{ #category : #converting }
SDL_DisplayMode >> asString [
^ 'SDL display: ', self width asString, 'x', self height asString, ' - ', self depth asString, ' bits depth'.
]
{ #category : #'accessing structure variables' }
SDL_DisplayMode >> depth [
|format depth|
format := SDL2 SDLAllocFormat: self format.
depth := format BitsPerPixel.
SDL2 SDLFreeFormat: format.
^depth
]
{ #category : #'accessing structure variables' } { #category : #'accessing structure variables' }
SDL_DisplayMode >> driverdata [ SDL_DisplayMode >> driverdata [
"This method was automatically generated" "This method was automatically generated"
@ -37,6 +51,11 @@ SDL_DisplayMode >> driverdata: anObject [
handle pointerAt: OFFSET_DRIVERDATA put: anObject getHandle. handle pointerAt: OFFSET_DRIVERDATA put: anObject getHandle.
] ]
{ #category : #other }
SDL_DisplayMode >> forceDisplayUpdate [
]
{ #category : #'accessing structure variables' } { #category : #'accessing structure variables' }
SDL_DisplayMode >> format [ SDL_DisplayMode >> format [
"This method was automatically generated" "This method was automatically generated"
@ -61,6 +80,11 @@ SDL_DisplayMode >> h: anObject [
handle signedLongAt: OFFSET_H put: anObject handle signedLongAt: OFFSET_H put: anObject
] ]
{ #category : #'accessing structure variables' }
SDL_DisplayMode >> height [
^ self h
]
{ #category : #'accessing structure variables' } { #category : #'accessing structure variables' }
SDL_DisplayMode >> refresh_rate [ SDL_DisplayMode >> refresh_rate [
"This method was automatically generated" "This method was automatically generated"
@ -84,3 +108,8 @@ SDL_DisplayMode >> w: anObject [
"This method was automatically generated" "This method was automatically generated"
handle signedLongAt: OFFSET_W put: anObject handle signedLongAt: OFFSET_W put: anObject
] ]
{ #category : #'accessing structure variables' }
SDL_DisplayMode >> width [
^ self w
]