mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-26 03:18:22 +01:00
Add global display object that refers to current SDL display
This commit is contained in:
parent
4a95c7d6df
commit
676113a697
@ -16,6 +16,11 @@ Class {
|
||||
#category : #'Diya-Runtime'
|
||||
}
|
||||
|
||||
{ #category : #'class initialization' }
|
||||
DiyaBoot class >> initialize [
|
||||
Smalltalk globals at: #DiyaDisplay put: nil
|
||||
]
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
DiyaBoot class >> maxFPS [
|
||||
^60
|
||||
@ -79,6 +84,8 @@ DiyaBoot >> init [
|
||||
status = 0
|
||||
ifFalse: [ ^ DiyaCoreAPIError signal: SDL2 getErrorMessage ].
|
||||
display := SDL_DisplayMode externalNew autoRelease.
|
||||
Smalltalk globals at: #Display ifAbsentPut:display.
|
||||
Smalltalk globals at: #DiyaDisplay put:display.
|
||||
SDL2 SDLGetCurrentDisplayMode: display from:0.
|
||||
SDL2 showCursor: 0.
|
||||
DiyaSingleton resetAll.
|
||||
@ -181,10 +188,7 @@ DiyaBoot >> showSystemInfo [
|
||||
stream nextPutAll: rinfo name readString; nextPutAll:' '.
|
||||
].
|
||||
stream cr.
|
||||
stream nextPutAll:'Display resolution: ';
|
||||
nextPutAll:display w asString;
|
||||
nextPutAll: 'x';
|
||||
nextPutAll: display h asString; cr.
|
||||
stream nextPutAll: DiyaDisplay asString; cr.
|
||||
self stdout nextPutAll: stream contents
|
||||
|
||||
]
|
||||
|
@ -51,8 +51,7 @@ ImageInitializer >> initializeImage [
|
||||
do: [ :c |
|
||||
[ c initialize ]
|
||||
on: Error
|
||||
do: [ c = Cursor
|
||||
ifFalse: [ retryList add: c ] ] ].
|
||||
do: [ retryList add: c ] ].
|
||||
retryList
|
||||
do: [ :c |
|
||||
Transcript
|
||||
|
@ -1,11 +1,23 @@
|
||||
Extension { #name : #SDL2 }
|
||||
|
||||
{ #category : #'*Diya' }
|
||||
SDL2 class >> SDLAllocFormat: pixel_format [
|
||||
^ self ffiCall: #(SDL_PixelFormat * SDL_AllocFormat(Uint32 pixel_format))
|
||||
|
||||
]
|
||||
|
||||
{ #category : #'*Diya' }
|
||||
SDL2 class >> SDLClearError [
|
||||
^ self ffiCall: #(void SDL_ClearError(void))
|
||||
|
||||
]
|
||||
|
||||
{ #category : #'*Diya' }
|
||||
SDL2 class >> SDLFreeFormat: handle [
|
||||
^ self ffiCall: #(void SDL_FreeFormat(SDL_PixelFormat *handle))
|
||||
|
||||
]
|
||||
|
||||
{ #category : #'*Diya' }
|
||||
SDL2 class >> SDLGetCurrentDisplayMode: mode from:index [
|
||||
^ self ffiCall: #(int SDL_GetCurrentDisplayMode(int index, SDL_DisplayMode* mode))
|
||||
|
@ -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' }
|
||||
SDL_DisplayMode >> driverdata [
|
||||
"This method was automatically generated"
|
||||
@ -37,6 +51,11 @@ SDL_DisplayMode >> driverdata: anObject [
|
||||
handle pointerAt: OFFSET_DRIVERDATA put: anObject getHandle.
|
||||
]
|
||||
|
||||
{ #category : #other }
|
||||
SDL_DisplayMode >> forceDisplayUpdate [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #'accessing structure variables' }
|
||||
SDL_DisplayMode >> format [
|
||||
"This method was automatically generated"
|
||||
@ -61,6 +80,11 @@ SDL_DisplayMode >> h: anObject [
|
||||
handle signedLongAt: OFFSET_H put: anObject
|
||||
]
|
||||
|
||||
{ #category : #'accessing structure variables' }
|
||||
SDL_DisplayMode >> height [
|
||||
^ self h
|
||||
]
|
||||
|
||||
{ #category : #'accessing structure variables' }
|
||||
SDL_DisplayMode >> refresh_rate [
|
||||
"This method was automatically generated"
|
||||
@ -84,3 +108,8 @@ SDL_DisplayMode >> w: anObject [
|
||||
"This method was automatically generated"
|
||||
handle signedLongAt: OFFSET_W put: anObject
|
||||
]
|
||||
|
||||
{ #category : #'accessing structure variables' }
|
||||
SDL_DisplayMode >> width [
|
||||
^ self w
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user