1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2025-07-16 13:59:54 +02:00

19 Commits

Author SHA1 Message Date
f10ad2449c Update Jenkinsfile
All checks were successful
gitea-sync/Diya-API/pipeline/head This commit looks good
2022-09-26 10:57:19 +02:00
0faefcae12 Update Jenkinsfile
Some checks reported errors
gitea-sync/Diya-API/pipeline/head Something is wrong with the build of this commit
2022-09-26 10:55:46 +02:00
85968f7b6a Update Jenkinsfile 2022-09-26 10:55:04 +02:00
b393432256 Update Jenkinsfile
Some checks reported errors
gitea-sync/Diya-API/pipeline/head Something is wrong with the build of this commit
2022-09-26 10:53:41 +02:00
8639bc4d65 Update Jenkinsfile
Some checks are pending
gitea-sync/Diya-API/pipeline/head Build queued...
2022-09-26 10:53:34 +02:00
79e42786e8 Update Jenkinsfile
Some checks failed
gitea-sync/Diya-API/pipeline/head There was a failure building this commit
2022-09-26 10:52:20 +02:00
cf89a8ca59 Update Jenkinsfile
Some checks failed
gitea-sync/Diya-API/pipeline/head There was a failure building this commit
2022-09-26 10:44:52 +02:00
f61e17de9c rendering improvement
Some checks reported errors
gitea-sync/Diya-API/pipeline/head Something is wrong with the build of this commit
2022-08-16 00:59:35 +02:00
3c00e1d181 refactory code, support inline style, improve text rendering 2022-08-15 12:28:09 +02:00
0b7396242a Refactor code on System clock 2022-08-14 22:49:36 +02:00
681d8951b7 remove unused selectors 2022-08-14 22:38:06 +02:00
0e78e6769d Meta node should not visible 2022-08-14 22:22:39 +02:00
8978c06efa Initialize global vars 2022-08-14 18:33:19 +02:00
74ce2b0f37 Supporting read system settings from file 2022-08-14 18:13:23 +02:00
2d09a8501a Refactory code 2022-08-14 16:52:22 +02:00
142f14e936 Rendering context now use multiple texture units to boost performance (on RPI zero, the performance gain is more than 10 FPS ) 2022-08-14 15:42:59 +02:00
677145f1a1 Add missing code of the previous commit 2022-08-14 01:39:09 +02:00
26368c37ab Rendering improvement: render a limited number of nodes (based on FPS setting) on the back buffer each iterration.
The back buffer is only swapped when all nodes are rendered
2022-08-14 01:38:22 +02:00
c7af75550f code refactory on rendering context 2022-08-13 23:48:23 +02:00
31 changed files with 727 additions and 393 deletions

View File

@ -8,12 +8,6 @@ Class {
#category : #'Diya-Core'
}
{ #category : #'instance creation' }
AssetManager class >> defaultAssetLocation [
^Smalltalk imageDirectory / 'assets'
]
{ #category : #'instance creation' }
AssetManager class >> fromLocation: loc [
^self new from: loc; yourself
@ -21,12 +15,14 @@ AssetManager class >> fromLocation: loc [
{ #category : #adding }
AssetManager >> addAsset: value [
assets at: value name put: value
assets at: value name put: value.
^ value
]
{ #category : #adding }
AssetManager >> addAssetName: name value: value [
assets at: name put: value
assets at: name put: value.
^ value
]
{ #category : #'instance creation' }
@ -38,7 +34,7 @@ AssetManager >> from: location [
AssetManager >> initialize [
super initialize.
assets := Dictionary new.
base := self class defaultAssetLocation
base := DiyaSystemSettings assetPath
]
{ #category : #accessing }

View File

@ -2,8 +2,7 @@ Class {
#name : #Diya2DNode,
#superclass : #DiyaNode,
#instVars : [
'vbuffer',
'voffset'
'vbuffer'
],
#category : #'Diya-Graphics'
}
@ -44,7 +43,6 @@ Diya2DNode >> initialize [
tf := MatrixTransform2x3 identity .
shader := Diya2DShader uniqueInstance.
vbuffer := nil.
voffset := 0.
]
{ #category : #accessing }

View File

@ -28,10 +28,11 @@ Diya2DPrimShape >> draw [
blendFnWithSfactor: GL_SRC_ALPHA dfactor: GL_ONE_MINUS_SRC_ALPHA.
"configure vao vbo for texture QUAD"
self texture ifNotNil: [
context setTexture: self texture.
self texture setup.
context useTexture: self texture.
].
voffset := context submitData: vbuffer.
OpenGL drawArrays: type first: voffset count:((vbuffer size )>> 2 ).
context submitData: vbuffer.
OpenGL drawArrays: type first:0 count:((vbuffer size )>> 2 ).
"reset value"
self texture ifNotNil: [self texture drop.].
self borderWidth > 0 ifTrue: [ self drawBorder ].
@ -85,9 +86,16 @@ Diya2DPrimShape >> setUpShader [
super setUpShader.
self shader
setUniform: #u_color value: (self ? #color) asGL4FArray;
setUniform: #u_bg_color value: (self ? #bgColor) asGL4FArray;
setUniform: #u_texture_type value:
(self texture ifNil: [ 0 ] ifNotNil:[self texture format]).
setUniform: #u_bg_color value: (self ? #bgColor) asGL4FArray.
self texture ifNotNil: [
self shader
setUniform: #u_texture value: self texture unit;
setUniform: #u_texture_type value: self texture format.
]
ifNil:
[
self shader setUniform: #u_texture_type value: 0.
].
]
{ #category : #accessing }

View File

@ -4,7 +4,6 @@ Class {
#instVars : [
'currapp',
'txtFPS',
'event',
'running'
],
#category : #'Diya-Applications'
@ -12,19 +11,19 @@ Class {
{ #category : #initialization }
DiyaApplicationLauncher >> appNode [
^root children first
^node children first
]
{ #category : #initialization }
DiyaApplicationLauncher >> bindGlobalEvent [
|pointer |
pointer := root addNode: (DiyaCircle r: 10) at: 200@200.
pointer := node addNode: (DiyaCircle r: 10) at: 200@200.
pointer styleName: #pointer.
root on: #keydown do:[:e| self stdlog: 'keydown...'. running := false.].
root on: #quit do: [:e| running := false].
root on: #(fingerdown fingermotion mousemotion) do:[:e|
target on: #keydown do:[:e| self stdlog: 'keydown...'. running := false.].
target on: #quit do: [:e| running := false].
target on: #(fingerdown fingermotion mousemotion) do:[:e|
pointer position: e mapped worldPosition.
DiyaRendererContext uniqueInstance mouse: (e mapped x) @ (e mapped y).
DiyaRenderer mouse: (e mapped x) @ (e mapped y).
].
]
@ -34,70 +33,7 @@ DiyaApplicationLauncher >> defaultApplication [
]
{ #category : #initialization }
DiyaApplicationLauncher >> initialize [
super initialize.
root := DiyaRootNode new.
currapp := nil.
]
{ #category : #initialization }
DiyaApplicationLauncher >> launch: app [
currapp ifNotNil: [
currapp quit.
root empty.
].
currapp := app uniqueInstance.
self context assets: currapp am.
[
self stdlog: 'Loading application'.
currapp root visibility: false.
currapp setup.
self appNode addNode: currapp root.
self process: true.
currapp root visibility: true.
self stdlog: 'Application LOADED'.
] fork.
]
{ #category : #initialization }
DiyaApplicationLauncher >> main [
| fps delta|
delta := DiyaClock uniqueInstance delta asMilliSeconds.
fps := DiyaBoot maxFPS.
delta = 0 ifFalse:[ fps := (1000/ delta) asInteger].
txtFPS data: ('FPS:', fps asString).
[(SDL2 pollEvent: event) > 0] whileTrue: [
root trigger: (DiyaEvent from: event mapped).
].
currapp ifNotNil: [currapp main.].
root stepDown.
self process: false.
root render.
]
{ #category : #initialization }
DiyaApplicationLauncher >> process: force [
|Q node maxProcessingTime|
maxProcessingTime := (1000 / DiyaBoot maxFPS) asInteger >> 1.
Q := root processingQueue.
Q ifEmpty:[^ self].
[
node := Q removeFirst.
node process.
Q isNotEmpty and: (
(DiyaClock uniqueInstance lapDelta asMilliSeconds < maxProcessingTime) or: force)
] whileTrue
]
{ #category : #accessing }
DiyaApplicationLauncher >> running [
^ running
]
{ #category : #initialization }
DiyaApplicationLauncher >> setup [
event := SDL_Event new.
DiyaApplicationLauncher >> defineLayout [
DiyaUIThemesManager uniqueInstance currentTheme
define: #fps_text styles: {
#color -> Color red.
@ -109,11 +45,60 @@ DiyaApplicationLauncher >> setup [
#bgColor -> Color orange.
#border -> 3
}.
root addNode: (DiyaCompositeNode new) at: 0@0.
txtFPS := root addNode:(DiyaText data: '') at: ( self context resolution x - 80)@(self context resolution y - 40).
node addNode: (DiyaCompositeNode new) at: 0@0.
txtFPS := node addNode:(DiyaText data: '') at: ( self context resolution x - 80)@(self context resolution y - 40).
node addNode: (DiyaTimerNode timeout: 0 do: [:n| self updateFPS ] ).
txtFPS extent: 80@40.
txtFPS styleName: #fps_text.
self bindGlobalEvent.
running := true.
self launch: self defaultApplication.
self loadNode.
]
{ #category : #initialization }
DiyaApplicationLauncher >> initialize [
super initialize.
node := DiyaCompositeNode new.
currapp := nil.
]
{ #category : #initialization }
DiyaApplicationLauncher >> launch: app [
currapp ifNotNil: [
currapp quit.
].
currapp := app uniqueInstance.
self context assets: currapp am.
currapp target: self appNode.
currapp onloaded:[
self stdlog: 'Application LOADED'.
].
]
{ #category : #initialization }
DiyaApplicationLauncher >> onloaded: aBlock [
|loader|
running := true.
loader := DiyaDefaultSystemLoader on: target.
loader job: [ DiyaFontManager uniqueInstance loadFonts. ] name: 'Loading fonts...'.
loader job: [ self defineLayout ] name: 'Define layout...'.
loader onloaded: [
node children do:[:c| target addNode: c at: c position].
node := target.
aBlock value.
self launch: self defaultApplication.
]
]
{ #category : #accessing }
DiyaApplicationLauncher >> running [
^ running
]
{ #category : #initialization }
DiyaApplicationLauncher >> updateFPS [
| fps delta|
delta := DiyaSystemClock delta.
fps := DiyaSystemSettings maxFPS.
delta = 0 ifFalse:[ fps := (1000/ delta) asInteger].
txtFPS data: ('FPS:', fps asString).
]

View File

@ -2,8 +2,10 @@ Class {
#name : #DiyaApplicationModel,
#superclass : #DiyaSingleton,
#instVars : [
'root',
'am'
'node',
'am',
'target',
'context'
],
#category : #'Diya-Applications'
}
@ -20,30 +22,42 @@ DiyaApplicationModel >> cleanup [
{ #category : #accessing }
DiyaApplicationModel >> context [
^DiyaRendererContext uniqueInstance
^DiyaRenderer
]
{ #category : #initialization }
DiyaApplicationModel >> initialize [
super initialize.
context := DiyaRenderer
]
{ #category : #'as yet unclassified' }
DiyaApplicationModel >> loadNode [
|pseudoRoot|
pseudoRoot := DiyaRootNode new.
pseudoRoot addNode: node.
pseudoRoot processQueue do:[:el|
el process
].
]
{ #category : #accessing }
DiyaApplicationModel >> main [
DiyaApplicationModel >> node [
^ node
]
{ #category : #accessing }
DiyaApplicationModel >> onloaded: aBlock [
self subclassResponsibility
]
{ #category : #accessing }
DiyaApplicationModel >> quit [
node empty.
self cleanup
]
{ #category : #accessing }
DiyaApplicationModel >> root [
^ root
]
{ #category : #accessing }
DiyaApplicationModel >> setup [
self subclassResponsibility
{ #category : #initialization }
DiyaApplicationModel >> target: aNode [
target := aNode.
]

View File

@ -7,7 +7,7 @@ Class {
{ #category : #initialization }
DiyaBaseApplication >> initialize [
super initialize.
root := DiyaCompositeNode new.
root styleName: #global.
node := DiyaCompositeNode new.
node styleName: #global.
am := AssetManager new.
]

View File

@ -18,12 +18,10 @@ Class {
{ #category : #'class initialization' }
DiyaBoot class >> initialize [
Smalltalk globals at: #DiyaDisplay put: nil
]
{ #category : #'instance creation' }
DiyaBoot class >> maxFPS [
^60
Smalltalk globals at: #DiyaDisplay put: nil.
Smalltalk globals at: #DiyaSystemClock put: nil.
Smalltalk globals at: #DiyaRenderer put: nil.
Smalltalk globals at: #DiyaSystemSettings put: nil.
]
{ #category : #'instance creation' }
@ -36,12 +34,6 @@ DiyaBoot class >> startx [
self uniqueInstance run
]
{ #category : #events }
DiyaBoot >> GLinit. [
OpenGL viewportX: 0 Y:0 W: display w H: display h.
OpenGL enable: GL_TEXTURE_2D.
]
{ #category : #events }
DiyaBoot >> createGLContext [
context := SDL2 glCreateContext: window.
@ -86,10 +78,11 @@ DiyaBoot >> init [
display := SDL_DisplayMode externalNew autoRelease.
SDL2 SDLGetCurrentDisplayMode: display from:0.
SDL2 showCursor: 0.
DiyaSingleton resetAll.
Smalltalk globals at: #Display ifAbsentPut:display.
Smalltalk globals at: #DiyaDisplay put:display.
DiyaSingleton resetAll.
DiyaFontManager uniqueInstance loadFonts.
Smalltalk globals at: #DiyaSystemSettings put: DiyaSettings uniqueInstance.
Smalltalk globals at: #DiyaSystemClock put: DiyaClock uniqueInstance.
]
{ #category : #events }
@ -97,23 +90,28 @@ DiyaBoot >> initialize [
display := nil.
window := nil.
context := nil.
clock := DiyaClock uniqueInstance.
clock := DiyaSystemClock.
]
{ #category : #events }
DiyaBoot >> render [
|launcher|
DiyaRendererContext uniqueInstance.
|launcher event|
event := SDL_Event new.
launcher := DiyaApplicationLauncher uniqueInstance.
launcher setup.
self GLinit.
"Init the Open GL view port and enable 2D texture"
OpenGL viewportX: 0 Y:0 W: display w H: display h.
OpenGL enable: GL_TEXTURE_2D.
launcher target: DiyaRenderer root.
launcher onloaded: [self stdlog: 'Launcher loaded'].
[ launcher running ] whileTrue: [
DiyaClock uniqueInstance tick.
launcher main.
SDL2 glSwapWindow: window.
DiyaSystemClock tick.
[(SDL2 pollEvent: event) > 0] whileTrue: [
DiyaRenderer root trigger: (DiyaEvent from: event mapped).
].
DiyaRenderer render.
SDL2 delay:
(0 max:
(1000/ self class maxFPS) asInteger - (DiyaClock uniqueInstance lapDelta asMilliSeconds)).
(1000/ DiyaSystemSettings maxFPS) asInteger - (DiyaSystemClock lapDelta)).
].
]
@ -205,6 +203,7 @@ DiyaBoot >> startx [
display: display;
window: window;
useProjection: OrthoProjectionMatrix.
Smalltalk globals at: #DiyaRenderer put: DiyaRendererContext uniqueInstance.
self render.
context delete.
window destroy.

View File

@ -23,12 +23,12 @@ DiyaClock >> elapsedTime [
DiyaClock >> initialize [
monotonic := DateAndTime now.
lastTick := monotonic.
lapTime := 0 asDuration.
lapTime := 0.
]
{ #category : #initialization }
DiyaClock >> lapDelta [
^ ((DateAndTime now) - lastTick)
^ ((DateAndTime now) - lastTick) asMilliSeconds
]
{ #category : #initialization }
@ -38,6 +38,6 @@ DiyaClock >> lapTime [
{ #category : #initialization }
DiyaClock >> tick [
lapTime := (DateAndTime now) - lastTick.
lapTime := self lapDelta.
lastTick := DateAndTime now.
]

View File

@ -33,7 +33,7 @@ DiyaConvexPolygon >> calculateVertices [
{ #category : #initialization }
DiyaConvexPolygon >> drawLines [
OpenGL drawArrays: GL_LINE_LOOP first:voffset count: (vbuffer size >> 2) - 1.
OpenGL drawArrays: GL_LINE_LOOP first:0 count: (vbuffer size >> 2) - 1.
]
{ #category : #initialization }

View File

@ -0,0 +1,24 @@
Class {
#name : #DiyaDefaultAppLoader,
#superclass : #DiyaDefaultSystemLoader,
#instVars : [
'label'
],
#category : #'Diya-Applications'
}
{ #category : #initialization }
DiyaDefaultAppLoader >> updateLayout [
super updateLayout.
label ifNil:[
label := node addNode: (DiyaText new) at: (progress position + (0@25)).
label inlineStyle: #xAlign value: #center
].
label extent: (progress extent x) @ 40.
]
{ #category : #scheduling }
DiyaDefaultAppLoader >> updateProgress: name percent: p [
label data: name.
progress percent: p
]

View File

@ -0,0 +1,21 @@
Class {
#name : #DiyaDefaultSystemLoader,
#superclass : #DiyaLoader,
#instVars : [
'progress'
],
#category : #'Diya-Applications'
}
{ #category : #initialization }
DiyaDefaultSystemLoader >> updateLayout [
|xtent|
xtent := DiyaRenderer resolution.
progress ifNil:[progress := node addNode: (DiyaLoadingBar new) at: 20@((xtent y >> 1) - 50)].
progress extent: (xtent x - 40) @ 20.
]
{ #category : #scheduling }
DiyaDefaultSystemLoader >> updateProgress: name percent: p [
progress percent: p
]

View File

@ -1,6 +1,9 @@
Class {
#name : #DiyaExampleApp,
#superclass : #DiyaBaseApplication,
#instVars : [
'loader'
],
#category : #'Diya-Applications'
}
@ -9,14 +12,107 @@ DiyaExampleApp >> cleanup [
]
{ #category : #accessing }
DiyaExampleApp >> defineNodes [
|node2 node1 img ell label icon button texture loading|
node := DiyaCompositeNode new.
texture := DiyaImageTex new.
label := node addNode: (DiyaLabel new) at: 10@40.
label extent: 250@24.
label styleName:#text_icon_1.
label icon: 16rF254.
node1 := node addNode: (DiyaRectangle size:100@150 shader: DiyaExampleShader uniqueInstance) at: 300 @ 40.
node1 rotation: 45.
node1 scale: 2.0@2.0.
node1 on: #(mousebuttondown fingerdown) do:[:e|
label txt: 'RECT ', (node1 local: e mapped worldPosition) asIntegerPoint asString].
img := node addNode: (DiyaImageView from:'mrsang.png') at: 10 @ 400.
img styleName: #image_view.
img extent:200@200.
node on: #(mousebuttondown fingerdown) do:[:e|
"change texture"
|p|
p := e mapped worldPosition.
label txt: 'Mouse ', p asIntegerPoint asString.
DiyaRenderer assets
addAsset:(texture fromDisplay: (Rectangle origin: ((p x - 100) @ (p y - 100)) extent: 200@200 ) as: 'capture').
img textureNamed: 'capture'.
].
node2 := node addNode: (DiyaRectangle new) at: 10@80.
node2 styleName: #rect_view.
node2 extent: 240@320.
node2 := node addNode: (DiyaText data: String loremIpsum) at: 10@80.
node2 extent: 240@320.
node2 wordWrap: true.
node2 styleName: #text_view.
node2 := node addNode: (DiyaLine from: 10@10 to: 200@200).
node2 styleName: #line_view.
ell := node addNode: (DiyaEllipse rx:100 ry: 70) at: 120@300.
ell scale: 1.2 @ 1.2.
ell styleName: #ell_view.
"ell rotation: 30."
ell textureNamed:'mrsang.png'.
ell addNode: (DiyaTimerNode timeout: 1000 / 6 do:[:n |
n parent rotation: n parent rotation + 10.
] ).
ell on: #(mousebuttondown fingerdown) do:[:e|
label txt: 'Ellipse clicked', (ell local:e mapped worldPosition) asIntegerPoint asString].
node2 := node addNode: (DiyaConvexPolygon points:{0@40. 150@190. 200@20. 100@0}) at: 250@60.
node2 textureNamed: 'mrsang.png'.
node2 styleName: #poly_view.
icon := node addNode: (DiyaFontIcon data: #(16rF101 16rF155 16rF185 16rF21B 16rF298 16rF254)) at: 240@500.
icon styleName: #text_icon_2.
button := node addNode: (DiyaButton text: 'Click me !') at: 240@460.
icon := DiyaFontIcon data: 16rF130.
"icon := DiyaImageIcon from: 'mrsang.png'."
icon addNode:(DiyaTimerNode timeout: 1000 / 12 do:[:n |
n parent rotation: n parent rotation + 10 pivot: n parent extent / 2.
] ).
button extent: 200@40.
button icon: icon "'mrsang.png'".
"button rotation: Float pi / 2.0."
button styleName: #button_view.
loading := node addNode: (DiyaLoadingBar new) at: 240@550.
loading extent: 200 @ 20.
loading addNode: (DiyaTimerNode timeout: 2000 do:[:n |
|p|
p := (n parent percent + 10).
p > 100 ifTrue:[ p := 0].
n parent percent: p.
] ).
loading := node addNode: (DiyaLoadingBar new) at: 240@580.
loading extent: 200 @ 20.
loading addNode: (DiyaTimerNode timeout: 1000 do:[:n |
|p|
p := (n parent percent + 10).
p > 100 ifTrue:[ p := 0].
n parent percent: p.
] ).
]
{ #category : #accessing }
DiyaExampleApp >> defineStyleSheet [
|fmgr style|
fmgr := DiyaFontManager uniqueInstance.
#(16 24) do:[:fontSize|
#(16 18 24) do:[:fontSize|
self stdlog: 'Init font size ', fontSize asString, ' of ', fmgr defaultFamily.
style := fmgr style: fmgr defaultStyle from: fmgr defaultFamily.
style textureOf: fontSize.
(style textureOf: fontSize)" genPrintableASCII" .
].
DiyaUIThemesManager uniqueInstance currentTheme
define: #text_icon_1 styles: {
@ -68,103 +164,26 @@ DiyaExampleApp >> defineStyleSheet [
]
{ #category : #accessing }
DiyaExampleApp >> main [
DiyaExampleApp >> initialize [
super initialize.
loader := nil
]
{ #category : #accessing }
DiyaExampleApp >> setup [
|node node1 img ell label icon button texture loading|
texture := DiyaImageTex new.
"DiyaRendererContext uniqueInstance assets
addAsset:
((Form fromDisplay: ( Rectangle origin: 0@0 corner: 300@300 )) asDiyaTexture: 'display')."
self defineStyleSheet.
label := root addNode: (DiyaLabel new) at: 10@40.
label extent: 250@24.
label styleName:#text_icon_1.
label icon: 16rF254.
DiyaExampleApp >> onloaded: aBlock [
loader ifNil: [ loader := DiyaDefaultAppLoader on: target ].
loader job: [ self defineStyleSheet ] name: 'Initializing themes...'.
loader job: [
self defineNodes.
self loadNode.
] name: 'Initializing UI elements...'.
"node1 := root addNode: (DiyaRectangle size:100@150 shader: DiyaExampleShader uniqueInstance) at: 300 @ 40.
node1 rotation: 45.
node1 scale: 2.0@2.0.
node1 on: #(mousebuttondown fingerdown) do:[:e|
label txt: 'RECT ', (node1 local: e mapped worldPosition) asIntegerPoint asString]."
img := root addNode: (DiyaImageView from:'mrsang.png') at: 10 @ 400.
img styleName: #image_view.
img extent:200@200.
root on: #(mousebuttondown fingerdown) do:[:e|
"change texture"
|p|
p := e mapped worldPosition.
label txt: 'Mouse ', p asIntegerPoint asString.
DiyaRendererContext uniqueInstance assets
addAsset:(texture fromDisplay: (Rectangle origin: ((p x - 100) @ (p y - 100)) extent: 200@200 ) as: 'capture').
img textureNamed: 'capture'.
loader onloaded: [
node children do:[:e|
target addNode: e at: e position.
node := target.
].
aBlock value
].
node := root addNode: (DiyaRectangle new) at: 10@80.
node styleName: #rect_view.
node extent: 240@320.
node := root addNode: (DiyaText data: String loremIpsum) at: 10@80.
node extent: 240@320.
node wordWrap: true.
node styleName: #text_view.
node := root addNode: (DiyaLine from: 10@10 to: 200@200).
node styleName: #line_view.
ell := root addNode: (DiyaEllipse rx:100 ry: 70) at: 120@300.
ell scale: 1.2 @ 1.2.
ell styleName: #ell_view.
"ell rotation: 30."
ell textureNamed:'mrsang.png'.
ell addNode: (DiyaTimerNode timeout: 1000 / 6 do:[:n |
n parent rotation: n parent rotation + 10.
] ).
ell on: #(mousebuttondown fingerdown) do:[:e|
label txt: 'Ellipse clicked', (ell local:e mapped worldPosition) asIntegerPoint asString].
node := root addNode: (DiyaConvexPolygon points:{0@40. 150@190. 200@20. 100@0}) at: 250@60.
node textureNamed: 'mrsang.png'.
node styleName: #poly_view.
icon := root addNode: (DiyaFontIcon data: #(16rF101 16rF155 16rF185 16rF21B 16rF298 16rF254)) at: 240@500.
icon styleName: #text_icon_2.
button := root addNode: (DiyaButton text: 'Click me !') at: 240@460.
icon := DiyaFontIcon data: 16rF130.
"icon := DiyaImageIcon from: 'mrsang.png'."
icon addNode:(DiyaTimerNode timeout: 1000 / 12 do:[:n |
n parent rotation: n parent rotation + 10 pivot: n parent extent / 2.
] ).
button extent: 200@40.
button icon: icon "'mrsang.png'".
"button rotation: Float pi / 2.0."
button styleName: #button_view.
loading := root addNode: (DiyaLoadingBar new) at: 240@550.
loading extent: 200 @ 20.
loading addNode: (DiyaTimerNode timeout: 2000 do:[:n |
|p|
p := (n parent percent + 10).
p > 100 ifTrue:[ p := 0].
n parent percent: p.
] ).
loading := root addNode: (DiyaLoadingBar new) at: 240@580.
loading extent: 200 @ 20.
loading addNode: (DiyaTimerNode timeout: 1000 do:[:n |
|p|
p := (n parent percent + 10).
p > 100 ifTrue:[ p := 0].
n parent percent: p.
] ).
^ root
]

View File

@ -13,13 +13,6 @@ DiyaFontManager class >> cleanUpInstance: singleton [
singleton reset.
]
{ #category : #'as yet unclassified' }
DiyaFontManager class >> searchPaths [
^ {
Smalltalk imageDirectory / 'fonts'
}
]
{ #category : #initialization }
DiyaFontManager >> defaultFamily [
^'Ubuntu'
@ -66,7 +59,7 @@ DiyaFontManager >> loadFace: face [
DiyaFontManager >> loadFile: aFile [
| path face i numfaces |
path := aFile fullName convertToWithConverter: UTF8TextConverter new.
Transcript show: 'Loading font file ', path;cr.
self stdlog: 'Loading font file ', path.
i := 0.
numfaces := nil.
[ face := FreeTypeFace basicNew
@ -90,7 +83,9 @@ DiyaFontManager >> loadFonts [
{ #category : #initialization }
DiyaFontManager >> loadFonts: force [
force ifTrue:[self reset].
self class searchPaths do:[:path| self loadPath: path].
DiyaSystemSettings fontPaths
select:[:p| p asFileReference exists]
thenDo:[:path| self loadPath: path].
]

View File

@ -1,9 +1,6 @@
Class {
#name : #DiyaImageTex,
#superclass : #OpenGLTexImage2D,
#instVars : [
'name'
],
#pools : [
'OpenGLConstants',
'OpenGLTypes'
@ -55,6 +52,7 @@ DiyaImageTex >> fromDisplay: aRect as: assetName [
data ifNotNil: [data free].
width := aRect extent x asInteger.
height := aRect extent y asInteger.
commited := false.
data := FFIExternalArray externalNewType: GLubyte size: self bytesSize.
LibC memset: data getHandle value: 0 size: data size.
data autoRelease.
@ -89,6 +87,7 @@ DiyaImageTex >> fromFile: aPath [
LibC memCopy: surface pixels getHandle to: data getHandle size: data size.
SDL2
freeSurface: surface.
commited := false.
self stdlog: 'Loaded ', aPath fullName.
]
@ -100,6 +99,7 @@ DiyaImageTex >> fromForm: aForm name: aName [
surface := self surfaceFromForm: aForm.
width := surface w.
height := surface h.
commited := false.
data := FFIExternalArray externalNewType: GLubyte size: self bytesSize.
LibC memset: data getHandle value: 0 size: data size.
data autoRelease.
@ -124,11 +124,6 @@ DiyaImageTex >> mipmap [
^false
]
{ #category : #accessing }
DiyaImageTex >> name [
^ name
]
{ #category : #accessing }
DiyaImageTex >> setup [
OpenGLTexture

View File

@ -94,8 +94,8 @@ DiyaLine >> process [
at: 3 put: 0.0;
at: 4 put: 0.0;
at: 5 put: extent x;
at: 6 put: extent y;
at: 5 put: extent x asFloat;
at: 6 put: extent y asFloat;
at: 7 put: 0.0;
at: 8 put: 0.0.
^true

81
Diya/DiyaLoader.class.st Normal file
View File

@ -0,0 +1,81 @@
Class {
#name : #DiyaLoader,
#superclass : #DiyaBaseObject,
#instVars : [
'node',
'jobs',
'target'
],
#category : #'Diya-Applications'
}
{ #category : #'instance creation' }
DiyaLoader class >> on: target [
^ self new target: target; yourself
]
{ #category : #scheduling }
DiyaLoader >> executeJobs: callback [
"target visibility: false."
target empty.
target addNode: node.
"target visibility: true".
node visibility: true.
self updateLayout.
500 milliSeconds wait.
self job: [ 500 milliSeconds wait. ] name: 'finishing' .
jobs withIndexDo: [ :job :i|
self updateProgress: job key percent: ((i - 1) * 100 / (jobs size)) asInteger.
job value value.
].
jobs := OrderedCollection new.
self updateProgress: 'Finishing...' percent: 100.
node visibility: false.
target empty.
callback value.
target visibility: true.
]
{ #category : #initialization }
DiyaLoader >> initialize [
super initialize.
node := DiyaCompositeNode new.
jobs := OrderedCollection new.
target := nil.
]
{ #category : #scheduling }
DiyaLoader >> job: aBlock name: aName [
jobs add: (aName -> aBlock)
]
{ #category : #accessing }
DiyaLoader >> node [
^ node
]
{ #category : #scheduling }
DiyaLoader >> onloaded: aBlock [
[ self executeJobs: aBlock ] fork"At: Processor userBackgroundPriority".
]
{ #category : #accessing }
DiyaLoader >> target [
^ target
]
{ #category : #accessing }
DiyaLoader >> target: anObject [
target := anObject
]
{ #category : #initialization }
DiyaLoader >> updateLayout [
self subclassResponsibility
]
{ #category : #scheduling }
DiyaLoader >> updateProgress: name percent: p [
self subclassResponsibility
]

View File

@ -24,6 +24,11 @@ DiyaMetaNode >> extent [
^ 0@0
]
{ #category : #initialization }
DiyaMetaNode >> initialize [
visibility := false.
]
{ #category : #testing }
DiyaMetaNode >> inner: aPoint [
^ false

View File

@ -14,6 +14,7 @@ Class {
'root',
'styleName',
'style',
'inlineStyle',
'id',
'visibility',
'pivot'
@ -31,9 +32,11 @@ DiyaNode class >> with: shader [
^self new shader: shader; yourself
]
{ #category : #accessing }
{ #category : #styling }
DiyaNode >> ? styleAttr [
| value|
value := inlineStyle at: styleAttr ifAbsent:[nil].
value ifNotNil: [ ^value ].
styleName ifNotNil: [
style ifNil: [
style := DiyaUIThemesManager uniqueInstance currentTheme ? (self styleName).
@ -46,12 +49,12 @@ DiyaNode >> ? styleAttr [
^ parent ? styleAttr
]
{ #category : #accessing }
{ #category : #'add/remove' }
DiyaNode >> addNode: node [
^self addNode: node at: 0@0
]
{ #category : #accessing }
{ #category : #'add/remove' }
DiyaNode >> addNode: node at: pos [
children ifNil: [ ^self ].
node parent: self.
@ -79,6 +82,13 @@ DiyaNode >> draw [
{ #category : #requirements }
DiyaNode >> empty [
children ifNotNil: [
children do:[:c|
c root: nil.
c setClean.
c visibility: false.
]
].
children := OrderedCollection new.
]
@ -87,15 +97,6 @@ DiyaNode >> extent [
^ self subclassResponsibility
]
{ #category : #processing }
DiyaNode >> forceReload [
self process.
children ifNotNil: [
children do:[:c|
c forceReload
]]
]
{ #category : #accessing }
DiyaNode >> id [
^ id
@ -106,17 +107,23 @@ DiyaNode >> initialize [
super initialize.
parent := nil.
shader := nil.
context := DiyaRendererContext uniqueInstance.
context := DiyaRenderer.
children := OrderedCollection new.
ehandlers := Dictionary new.
styleName := nil.
style := nil.
root := nil.
inlineStyle := Dictionary new.
visibility := true.
pivot := 0@0.
id := self className,'#',(Random new nextInt: 1e6) asString.
]
{ #category : #styling }
DiyaNode >> inlineStyle: name value: value [
inlineStyle at: name put: value
]
{ #category : #testing }
DiyaNode >> inner: aPoint [
^ self subclassResponsibility
@ -174,15 +181,16 @@ DiyaNode >> register: aBlock to: eventName [
]
{ #category : #removing }
{ #category : #'add/remove' }
DiyaNode >> remove [
self setClean.
root := nil.
parent ifNotNil: [ parent removeChild: self ]
]
{ #category : #removing }
{ #category : #'add/remove' }
DiyaNode >> removeChild: c [
c setClean.
c root: nil.
c visibility: false.
children ifNotNil: [ children remove: c ifAbsent:[ ]]
]
@ -192,7 +200,21 @@ DiyaNode >> render [
shader ifNotNil: [self setUpShader].
self draw.
children ifNil: [ ^self ].
children do: [:c| c render ].
root ifNil: [ ^self ].
root renderNext: children
]
{ #category : #'add/remove' }
DiyaNode >> replaceChild: aNode with: anotherNode [
|index|
children ifNil: [ ^ self ].
index := children indexOf: aNode.
index = 0 ifTrue:[^ self].
children at: index put: anotherNode.
anotherNode parent: self.
anotherNode root: self root.
anotherNode setDirtyAll.
aNode root: nil.
]
{ #category : #accessing }
@ -262,10 +284,9 @@ DiyaNode >> setUpShader [
|mem|
mem := self tf asGLBuffer.
shader use;
setUniform: #u_time value: DiyaClock uniqueInstance elapsedTime asFloat;
setUniform: #u_time value: DiyaSystemClock elapsedTime asFloat;
setUniform: #u_projection value: {GL_FALSE. context projection buffer};
setUniform: #u_resolution value: { context resolution x. context resolution y };
setUniform: #u_texture value: 0;
setUniform: #u_transform value: {GL_TRUE. mem}.
context mouse ifNotNil: [
"in shader, window origin is bottom left conor of the window
@ -329,7 +350,6 @@ DiyaNode >> trigger: evt [
handler value: evt].
children ifNil: [^self].
evt enable ifTrue: [
"evt mapped triggableOn: children first."
children select: [:node | evt mapped triggableOn: node ] thenDo:[:node| node trigger: evt]
].
]
@ -346,5 +366,7 @@ DiyaNode >> visibility [
{ #category : #accessing }
DiyaNode >> visibility: anObject [
visibility := anObject
visibility := anObject.
children ifNotNil: [
children do:[:c| c visibility: anObject ] ]
]

View File

@ -16,7 +16,7 @@ DiyaRectangle class >> size: size shader:s [
{ #category : #initialization }
DiyaRectangle >> drawLines [
OpenGL drawArrays: GL_LINE_LOOP first:voffset count: (vbuffer size >> 2).
OpenGL drawArrays: GL_LINE_LOOP first:0 count: (vbuffer size >> 2).
]
@ -47,16 +47,16 @@ DiyaRectangle >> process [
at: 4 put: 0.0;
at: 5 put: 0.0;
at: 6 put: extent y;
at: 6 put: extent y asFloat;
at: 7 put: 0.0;
at: 8 put: 1.0;
at: 9 put: extent x;
at: 10 put: extent y;
at: 9 put: extent x asFloat;
at: 10 put: extent y asFloat;
at: 11 put: 1.0;
at: 12 put: 1.0;
at: 13 put: extent x;
at: 13 put: extent x asFloat;
at: 14 put: 0.0;
at: 15 put: 1.0;
at: 16 put: 0.0.

View File

@ -6,12 +6,12 @@ Class {
'display',
'vbo',
'vao',
'texture0',
'textures',
'projection',
'assets',
'window',
'vbuffer',
'voffset'
'root',
'lock'
],
#pools : [
'OpenGLConstants',
@ -20,11 +20,6 @@ Class {
#category : #'Diya-Graphics'
}
{ #category : #accessing }
DiyaRendererContext class >> bufferSize [
^ 524288 "512Kb"
]
{ #category : #'instance creation' }
DiyaRendererContext class >> cleanUpInstance: singleton [
singleton ifNil:[^self].
@ -36,6 +31,11 @@ DiyaRendererContext class >> maxFloatBufferSize [
^4096
]
{ #category : #accessing }
DiyaRendererContext class >> maxTextureNumber [
^ 32
]
{ #category : #accessing }
DiyaRendererContext >> assets [
^ assets
@ -47,17 +47,12 @@ DiyaRendererContext >> assets: anObject [
]
{ #category : #accessing }
DiyaRendererContext >> destroy [
self disableGLAttribute: 0.
vbuffer free.
DiyaRendererContext >> destroy [
vao disableAttribute: 0.
vao delete.
vbo delete.
texture0 delete.
]
{ #category : #registration }
DiyaRendererContext >> disableGLAttribute: attribute [
vao disableAttribute: attribute
textures do: [:e | e key delete ].
textures := OrderedCollection new.
]
{ #category : #accessing }
@ -70,9 +65,13 @@ DiyaRendererContext >> display: anObject [
display := anObject
]
{ #category : #registration }
DiyaRendererContext >> enableGLAttribute: attribute [
vao enableAttribute: attribute.
{ #category : #rendering }
DiyaRendererContext >> findTextureUnit [
textures withIndexDo: [ :e :i|
e value ifNil: [ ^ i - 1]
].
"random unit value"
^ (Random new nextInt: self class maxTextureNumber) - 1
]
{ #category : #accessing }
@ -80,19 +79,28 @@ DiyaRendererContext >> initialize [
super initialize.
vbo := OpenGLVertexBuffer new.
vao := OpenGLVertexArray new.
texture0 := OpenGLTexture fromUnit: 0.
textures := Dictionary new.
lock := Mutex new.
vao bind.
vbo bind: GL_ARRAY_BUFFER.
projection := Array2D identity: 4.
assets := AssetManager new.
"allocate vbuffer"
vbuffer := FFIExternalArray externalNewType: GLfloat size: self class bufferSize.
vbuffer autoRelease.
voffset := 0.
vbo data: GL_ARRAY_BUFFER data: vbuffer usage: GL_STREAM_DRAW.
self enableGLAttribute: 0.
OpenGLVertexArray vertexAttributePointerIndex: 0 size:4 type: GL_FLOAT normalized: GL_FALSE stride: 16 pointer: nil.
vao enableAttribute: 0.
OpenGLVertexArray
vertexAttributePointerIndex: 0
size:4
type: GL_FLOAT
normalized: GL_FALSE
stride: 16
pointer: nil.
textures :=
(1 to: self class maxTextureNumber ) collect:[:i|
(OpenGLTexture fromUnit: i - 1) -> nil] .
]
{ #category : #accessing }
DiyaRendererContext >> lock [
^ lock
]
{ #category : #accessing }
@ -110,9 +118,12 @@ DiyaRendererContext >> projection [
^ projection
]
{ #category : #registration }
DiyaRendererContext >> resetBuffer [
voffset := 0
{ #category : #rendering }
DiyaRendererContext >> render [
root render.
root readyForSwap ifTrue: [
SDL2 glSwapWindow: window.
]
]
{ #category : #accessing }
@ -120,54 +131,41 @@ DiyaRendererContext >> resolution [
^ (display w) @ (display h)
]
{ #category : #registration }
DiyaRendererContext >> setTexture: texture [
texture setup.
texture0 setImage2D: texture.
texture0 active.
]
{ #category : #registration }
DiyaRendererContext >> submitData: data [
|n|
n := self voffset.
voffset := voffset + (data size << 2).
voffset > self class bufferSize ifTrue:[
^ DiyaCoreAPIError signal: 'Out of video buffer memory'
].
vbo subData: GL_ARRAY_BUFFER offset: n data: data.
^ (n >> 4)
]
{ #category : #accessing }
DiyaRendererContext >> texture0 [
^ texture0
DiyaRendererContext >> root [
root ifNil: [ root := DiyaRootNode new ].
^ root
]
{ #category : #registration }
{ #category : #rendering }
DiyaRendererContext >> submitData: vbuffer [
vbo data: GL_ARRAY_BUFFER data: vbuffer usage: GL_STATIC_DRAW.
]
{ #category : #'transformation matrices' }
DiyaRendererContext >> useProjection: aClass [
projection := aClass fromDisplay: self display
]
{ #category : #accessing }
DiyaRendererContext >> vao [
^ vao
]
{ #category : #accessing }
DiyaRendererContext >> vbo [
^ vbo
]
{ #category : #accessing }
DiyaRendererContext >> vbuffer [
^ vbuffer
]
{ #category : #accessing }
DiyaRendererContext >> voffset [
^ voffset
{ #category : #rendering }
DiyaRendererContext >> useTexture: aTexture [
|assoc|
aTexture unit == -1 ifTrue:[ aTexture unit: self findTextureUnit].
assoc := textures at: aTexture unit + 1.
assoc value = aTexture ifFalse:[
"unregister current texture"
assoc value ifNotNil: [ assoc value commited: false ].
aTexture commited: false.
assoc value: aTexture.
].
assoc key active.
aTexture commited ifTrue:[ ^ self ].
"self stdlog: 'Commit data data to texture ', aTexture name, ' on Unit ', aTexture unit asString."
assoc key setImage2D: aTexture.
aTexture commited: true.
]
{ #category : #accessing }

View File

@ -2,16 +2,12 @@ Class {
#name : #DiyaRootNode,
#superclass : #DiyaNode,
#instVars : [
'Q'
'Q',
'R'
],
#category : #'Diya-Graphics'
}
{ #category : #accessing }
DiyaRootNode >> Q [
^ Q
]
{ #category : #accessing }
DiyaRootNode >> boundingBox [
^ Rectangle origin: 0@0 corner: context resolution
@ -25,16 +21,14 @@ DiyaRootNode >> cleanDirtyNode: aNode [
{ #category : #accessing }
DiyaRootNode >> draw [
|c|
context resetBuffer.
c := self ? #bgColor.
OpenGL clearColorR: c red G: c green B: c blue A: c alpha.
OpenGL clear: GL_COLOR_BUFFER_BIT.
"context vbo bind: GL_ARRAY_BUFFER."
]
{ #category : #'add/remove' }
DiyaRootNode >> enqueueDirtyNode: aNode [
(Q includes: aNode ) ifFalse:[ Q add: aNode].
Q addIfNotPresent: aNode
]
{ #category : #accessing }
@ -49,7 +43,8 @@ DiyaRootNode >> initialize [
shader := nil.
root := self.
styleName := #global.
Q := OrderedCollection new
Q := OrderedCollection new.
R := OrderedCollection new.
]
{ #category : #accessing }
@ -67,11 +62,35 @@ DiyaRootNode >> process [
]
{ #category : #accessing }
DiyaRootNode >> processingQueue [
{ #category : #controlling }
DiyaRootNode >> processQueue [
^ Q
]
{ #category : #testing }
DiyaRootNode >> readyForSwap [
^ R isEmpty
]
{ #category : #rendering }
DiyaRootNode >> render [
| maxProcessingTime|
self stepDown.
R ifEmpty: [
self draw.
self renderNext: children
].
maxProcessingTime := (1000 / DiyaSystemSettings maxFPS) asInteger.
[
self spinOnce: maxProcessingTime
] whileTrue
]
{ #category : #rendering }
DiyaRootNode >> renderNext: nodes [
R addAllFirstUnlessAlreadyPresent: nodes.
]
{ #category : #initialization }
DiyaRootNode >> setClean [
@ -85,6 +104,24 @@ DiyaRootNode >> setDirty [
]
{ #category : #rendering }
DiyaRootNode >> spinOnce: maxProcessingTime [
|node|
Q ifNotEmpty: [
node := Q removeFirst.
node process.
"context lock critical: [node process]."
].
R ifNotEmpty: [
node := R removeFirst.
node render.
"context lock critical: [node render]. "
].
(Q isEmpty and: R isEmpty) ifTrue: [ ^false ].
DiyaSystemSettings renderAtOnce ifTrue: [ ^ true ].
^(DiyaSystemClock lapDelta < maxProcessingTime)
]
{ #category : #accessing }
DiyaRootNode >> updateTF [
"donothing"

View File

@ -0,0 +1,90 @@
Class {
#name : #DiyaSettings,
#superclass : #DiyaSingleton,
#instVars : [
'maxFPS',
'fontPaths',
'assetPath',
'renderAtOnce'
],
#category : #'Diya-Core'
}
{ #category : #'as yet unclassified' }
DiyaSettings class >> defaultSettingFile [
^ Smalltalk imageDirectory / 'settings.json'
]
{ #category : #accessing }
DiyaSettings >> assetPath [
^ assetPath
]
{ #category : #accessing }
DiyaSettings >> assetPath: anObject [
assetPath := anObject
]
{ #category : #accessing }
DiyaSettings >> fontPaths [
^ fontPaths
]
{ #category : #accessing }
DiyaSettings >> fontPaths: anObject [
fontPaths := anObject
]
{ #category : #initialization }
DiyaSettings >> initialize [
super initialize.
maxFPS := 60.
renderAtOnce := false.
fontPaths := { Smalltalk imageDirectory / 'fonts' }.
assetPath := Smalltalk imageDirectory / 'assets'.
self loadFromFile.
self logSettings
]
{ #category : #initialization }
DiyaSettings >> loadFromFile [
|d v|
self class defaultSettingFile exists ifFalse: [
self stderror: 'Setting file not found. Using default settings'.
^self
].
d := STON fromStream: self class defaultSettingFile readStream.
maxFPS := d at:'max_fps' ifAbsent:[maxFPS].
v := d at:'asset_dir' ifAbsent:[nil].
v ifNotNil: [ assetPath := v ].
renderAtOnce := d at: 'render_all_at_once' ifAbsent:[renderAtOnce ].
fontPaths := fontPaths , (d at:'font_dirs' ifAbsent:[#()]).
]
{ #category : #initialization }
DiyaSettings >> logSettings [
self stdlog: 'max_fps = ', maxFPS asString.
self stdlog: 'font_dirs = ', fontPaths asString.
self stdlog: 'asset_dir = ', assetPath asString.
self stdlog: 'render_all_at_once = ', renderAtOnce asString.
]
{ #category : #accessing }
DiyaSettings >> maxFPS [
^ maxFPS
]
{ #category : #accessing }
DiyaSettings >> maxFPS: anObject [
maxFPS := anObject
]
{ #category : #accessing }
DiyaSettings >> renderAtOnce [
^ renderAtOnce
]
{ #category : #accessing }
DiyaSettings >> renderAtOnce: anObject [
renderAtOnce := anObject
]

View File

@ -25,7 +25,7 @@ DiyaSingleton class >> new [
{ #category : #'instance creation' }
DiyaSingleton class >> reset [
|singleton key|
key := self class asString asSymbol.
key := self class.
singleton := singletons at: key ifAbsent: [ ^ self ].
self cleanUpInstance: singleton.
singletons removeKey: key
@ -38,7 +38,7 @@ DiyaSingleton class >> resetAll [
{ #category : #'instance creation' }
DiyaSingleton class >> uniqueInstance [
^singletons at: self class asString asSymbol ifAbsentPut: [ super new ].
^singletons at: self class ifAbsentPut: [ super new ].
]
{ #category : #initialization }

View File

@ -206,9 +206,6 @@ DiyaText >> process [
data ifNil:[^true].
data ifEmpty:[^true].
texture ifNil: [ self initTexture ].
texheight = texture height ifFalse: [
texheight := texture height.
].
vbuffer ifNotNil: [vbuffer free].
vbuffer := FFIExternalArray externalNewType: GLfloat size: data size * 16.
vbuffer autoRelease.
@ -230,6 +227,14 @@ DiyaText >> splitLines [
] whileTrue.
]
{ #category : #stepping }
DiyaText >> step [
texture ifNil: [ ^self ].
texheight = texture height ifTrue: [ ^self].
texheight := texture height.
self setDirty
]
{ #category : #accessing }
DiyaText >> styleName: aName [
super styleName: aName.

View File

@ -26,7 +26,7 @@ DiyaTimerNode class >> timeout: ms doOnce: aBlock [
{ #category : #accessing }
DiyaTimerNode >> delta [
^ DiyaClock uniqueInstance delta asMilliSeconds
^ DiyaSystemClock delta
]
{ #category : #accessing }

View File

@ -62,7 +62,6 @@ Class {
'GL_SRC_ALPHA',
'GL_STATIC_DRAW',
'GL_STENCIL_BUFFER_BIT',
'GL_STREAM_DRAW',
'GL_TESS_CONTROL_SHADER',
'GL_TESS_EVALUATION_SHADER',
'GL_TEXTURE_2D',
@ -109,7 +108,6 @@ OpenGLConstants class >> initCommonConstants [
GL_UNIFORM_BUFFER := 16r8A11.
GL_STATIC_DRAW := 16r88E4.
GL_DYNAMIC_DRAW := 16r88E8.
GL_STREAM_DRAW := 16r88E0.
GL_FALSE := 0.
GL_TRUE := 1.
GL_ARRAY_BUFFER_BINDING := 16r8894.

View File

@ -26,7 +26,7 @@ OpenGLFontTex class >> fromFace: face ofSize: size [
^self new fromFace: face ofSize: size; yourself
]
{ #category : #'instance creation' }
{ #category : #processing }
OpenGLFontTex >> blitPixel8: bitmap at: offset size: size [
size = (0@0) ifTrue:[^self].
0 to: size y - 1 do: [ :i|
@ -52,9 +52,9 @@ OpenGLFontTex >> charmap [
{ #category : #accessing }
OpenGLFontTex >> drop [
OpenGL
pixelstorei: GL_UNPACK_ALIGNMENT param: 4;
pixelstorei: GL_UNPACK_ALIGNMENT param: 4";
disable: GL_CULL_FACE;
disable: GL_BLEND.
disable: GL_BLEND".
]
{ #category : #accessing }
@ -67,6 +67,8 @@ OpenGLFontTex >> fromFace: aFace ofSize: size [
|minhang rec iptr charcode w numw|
fontSize := size.
face := aFace.
commited := false.
name := aFace familyName, '@', aFace styleName,'@', size asString.
charmap := Dictionary new.
face setPixelWidth:0 height: self fontSize.
cellw := cellh := minhang := maxbearing := 0.
@ -100,7 +102,7 @@ OpenGLFontTex >> fromFace: aFace ofSize: size [
iptr free.
]
{ #category : #accessing }
{ #category : #processing }
OpenGLFontTex >> genGlyph:c [
|rec offset glyph gsize|
face setPixelWidth:0 height: self fontSize.
@ -122,13 +124,20 @@ OpenGLFontTex >> genGlyph:c [
self reallocateBuffer.
].
].
commited := false.
^glyph
]
{ #category : #processing }
OpenGLFontTex >> genPrintableASCII [
33 to: 126 do: [ :c| self genGlyph: c ]
]
{ #category : #accessing }
OpenGLFontTex >> getGlyph: c [
^(self charmap at: c ifAbsentPut:[self genGlyph:c])
^(self charmap at: c ifAbsentPut:[
self genGlyph:c])
]
{ #category : #initialization }
@ -156,7 +165,7 @@ OpenGLFontTex >> meanww [
^ meanww
]
{ #category : #accessing }
{ #category : #processing }
OpenGLFontTex >> reallocateBuffer [
|newbuffer|
maxrows := maxrows + 4.
@ -169,12 +178,12 @@ OpenGLFontTex >> reallocateBuffer [
]
{ #category : #accessing }
{ #category : #initialization }
OpenGLFontTex >> setup [
OpenGL
enable: GL_CULL_FACE;
"enable: GL_CULL_FACE;
enable: GL_BLEND;
blendFnWithSfactor: GL_SRC_ALPHA dfactor: GL_ONE_MINUS_SRC_ALPHA;
blendFnWithSfactor: GL_SRC_ALPHA dfactor: GL_ONE_MINUS_SRC_ALPHA;"
pixelstorei: GL_UNPACK_ALIGNMENT param: 1.
OpenGLTexture
parameteri: GL_TEXTURE_2D pname: GL_TEXTURE_WRAP_S param: GL_CLAMP_TO_EDGE;

View File

@ -10,7 +10,10 @@ Class {
'border',
'format',
'type',
'data'
'data',
'unit',
'commited',
'name'
],
#pools : [
'OpenGLConstants',
@ -34,6 +37,16 @@ OpenGLTexImage2D >> bytesSize [
^(width * height) << 2
]
{ #category : #accessing }
OpenGLTexImage2D >> commited [
^ commited
]
{ #category : #accessing }
OpenGLTexImage2D >> commited: anObject [
commited := anObject
]
{ #category : #accessing }
OpenGLTexImage2D >> data [
^ data
@ -87,6 +100,13 @@ OpenGLTexImage2D >> height: anObject [
height := anObject
]
{ #category : #initialization }
OpenGLTexImage2D >> initialize [
super initialize.
unit := -1.
commited := false
]
{ #category : #accessing }
OpenGLTexImage2D >> internalFormat [
^ internalFormat
@ -112,6 +132,11 @@ OpenGLTexImage2D >> mipmap [
^false
]
{ #category : #accessing }
OpenGLTexImage2D >> name [
^ name
]
{ #category : #accessing }
OpenGLTexImage2D >> setup [
^self subclassResponsibility
@ -137,6 +162,16 @@ OpenGLTexImage2D >> type: anObject [
type := anObject
]
{ #category : #accessing }
OpenGLTexImage2D >> unit [
^ unit
]
{ #category : #accessing }
OpenGLTexImage2D >> unit: anObject [
unit := anObject
]
{ #category : #accessing }
OpenGLTexImage2D >> width [
^ width

View File

@ -26,7 +26,7 @@ OpenGLVertexBuffer class >> deleteBuffersSize:n buffers: buffers [
^self ffiCall: #(void glDeleteBuffers( GLsizei n,const GLuint * buffers))
]
{ #category : #'library path' }
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> ffiLibraryName [
^ OpenGL ffiLibraryName
]
@ -51,24 +51,24 @@ OpenGLVertexBuffer class >> subData:target offset: offset size: size data: data
^self ffiCall: #(void glBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const void * data))
]
{ #category : #'as yet unclassified' }
{ #category : #initialization }
OpenGLVertexBuffer >> bind: target [
^OpenGLVertexBuffer bind:target buffer: self vertexBufferID
]
{ #category : #'as yet unclassified' }
{ #category : #'accessing - data' }
OpenGLVertexBuffer >> data:target data: data size: size usage: usage [
self bind: target.
"self bind: target."
^OpenGLVertexBuffer bufferData: target size: size data:(data ifNil:[data] ifNotNil: [data getHandle]) usage: usage
]
{ #category : #'as yet unclassified' }
{ #category : #'accessing - data' }
OpenGLVertexBuffer >> data:target data: data usage: usage [
self bind: target.
"self bind: target."
^OpenGLVertexBuffer bufferData: target size: (data size) << 2 data:data getHandle usage: usage
]
{ #category : #'as yet unclassified' }
{ #category : #'add/remove' }
OpenGLVertexBuffer >> delete [
OpenGLVertexBuffer deleteBuffersSize: 1 buffers: vertexBufferID getHandle.
]
@ -78,19 +78,18 @@ OpenGLVertexBuffer >> initialize [
vertexBufferID := FFIExternalArray externalNewType: GLint size:1.
vertexBufferID at:1 put: -1.
vertexBufferID autoRelease.
OpenGLVertexBuffer genVertexBuffersSize: 1 buffers: vertexBufferID getHandle.
OpenGLVertexBuffer genVertexBuffersSize: 1 buffers: vertexBufferID getHandle
]
{ #category : #'as yet unclassified' }
{ #category : #'accessing - data' }
OpenGLVertexBuffer >> subData:target offset: offset data:data [
self bind: target.
"self bind: target."
^OpenGLVertexBuffer subData: target offset: offset size: (data size) << 2 data: data getHandle
]
{ #category : #'as yet unclassified' }
{ #category : #'accessing - data' }
OpenGLVertexBuffer >> subData:target offset: offset data:data size: size [
self bind: target.
"self bind: target."
^OpenGLVertexBuffer subData: target offset: offset size: size data: data getHandle
]

View File

@ -8,6 +8,6 @@ SDL_TouchFingerEvent >> triggableOn: aNode [
{ #category : #'*Diya' }
SDL_TouchFingerEvent >> worldPosition [
|resolution|
resolution := DiyaRendererContext uniqueInstance resolution.
resolution := DiyaRenderer resolution.
^((self x)* (resolution x) ) @ ((self y)* (resolution y)).
]

3
Jenkinsfile vendored
View File

@ -20,7 +20,8 @@ pipeline{
{
stage('Build image from SDK') {
steps {
build job: 'Diya-image', propagate: true, wait: true
// build specific multi-branch job on master branch
build job: 'gitea-sync/DiyaSDK/master', propagate: true, wait: true
}
}
}