mirror of
https://github.com/lxsang/Diya-API.git
synced 2025-07-16 22:09:47 +02:00
Compare commits
1 Commits
master
...
single_buf
Author | SHA1 | Date | |
---|---|---|---|
d99d6f3604 |
@ -8,6 +8,12 @@ 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
|
||||
@ -15,14 +21,12 @@ AssetManager class >> fromLocation: loc [
|
||||
|
||||
{ #category : #adding }
|
||||
AssetManager >> addAsset: value [
|
||||
assets at: value name put: value.
|
||||
^ value
|
||||
assets at: value name put: value
|
||||
]
|
||||
|
||||
{ #category : #adding }
|
||||
AssetManager >> addAssetName: name value: value [
|
||||
assets at: name put: value.
|
||||
^ value
|
||||
assets at: name put: value
|
||||
]
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
@ -34,7 +38,7 @@ AssetManager >> from: location [
|
||||
AssetManager >> initialize [
|
||||
super initialize.
|
||||
assets := Dictionary new.
|
||||
base := DiyaSystemSettings assetPath
|
||||
base := self class defaultAssetLocation
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -2,7 +2,8 @@ Class {
|
||||
#name : #Diya2DNode,
|
||||
#superclass : #DiyaNode,
|
||||
#instVars : [
|
||||
'vbuffer'
|
||||
'vbuffer',
|
||||
'voffset'
|
||||
],
|
||||
#category : #'Diya-Graphics'
|
||||
}
|
||||
@ -43,6 +44,7 @@ Diya2DNode >> initialize [
|
||||
tf := MatrixTransform2x3 identity .
|
||||
shader := Diya2DShader uniqueInstance.
|
||||
vbuffer := nil.
|
||||
voffset := 0.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -28,11 +28,10 @@ Diya2DPrimShape >> draw [
|
||||
blendFnWithSfactor: GL_SRC_ALPHA dfactor: GL_ONE_MINUS_SRC_ALPHA.
|
||||
"configure vao vbo for texture QUAD"
|
||||
self texture ifNotNil: [
|
||||
self texture setup.
|
||||
context useTexture: self texture.
|
||||
context setTexture: self texture.
|
||||
].
|
||||
context submitData: vbuffer.
|
||||
OpenGL drawArrays: type first:0 count:((vbuffer size )>> 2 ).
|
||||
voffset := context submitData: vbuffer.
|
||||
OpenGL drawArrays: type first: voffset count:((vbuffer size )>> 2 ).
|
||||
"reset value"
|
||||
self texture ifNotNil: [self texture drop.].
|
||||
self borderWidth > 0 ifTrue: [ self drawBorder ].
|
||||
@ -86,16 +85,9 @@ Diya2DPrimShape >> setUpShader [
|
||||
super setUpShader.
|
||||
self shader
|
||||
setUniform: #u_color value: (self ? #color) asGL4FArray;
|
||||
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.
|
||||
].
|
||||
setUniform: #u_bg_color value: (self ? #bgColor) asGL4FArray;
|
||||
setUniform: #u_texture_type value:
|
||||
(self texture ifNil: [ 0 ] ifNotNil:[self texture format]).
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -4,6 +4,7 @@ Class {
|
||||
#instVars : [
|
||||
'currapp',
|
||||
'txtFPS',
|
||||
'event',
|
||||
'running'
|
||||
],
|
||||
#category : #'Diya-Applications'
|
||||
@ -11,19 +12,19 @@ Class {
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaApplicationLauncher >> appNode [
|
||||
^node children first
|
||||
^root children first
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaApplicationLauncher >> bindGlobalEvent [
|
||||
|pointer |
|
||||
pointer := node addNode: (DiyaCircle r: 10) at: 200@200.
|
||||
pointer := root addNode: (DiyaCircle r: 10) at: 200@200.
|
||||
pointer styleName: #pointer.
|
||||
target on: #keydown do:[:e| self stdlog: 'keydown...'. running := false.].
|
||||
target on: #quit do: [:e| running := false].
|
||||
target on: #(fingerdown fingermotion mousemotion) do:[:e|
|
||||
root on: #keydown do:[:e| self stdlog: 'keydown...'. running := false.].
|
||||
root on: #quit do: [:e| running := false].
|
||||
root on: #(fingerdown fingermotion mousemotion) do:[:e|
|
||||
pointer position: e mapped worldPosition.
|
||||
DiyaRenderer mouse: (e mapped x) @ (e mapped y).
|
||||
DiyaRendererContext uniqueInstance mouse: (e mapped x) @ (e mapped y).
|
||||
].
|
||||
]
|
||||
|
||||
@ -33,7 +34,70 @@ DiyaApplicationLauncher >> defaultApplication [
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaApplicationLauncher >> defineLayout [
|
||||
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.
|
||||
DiyaUIThemesManager uniqueInstance currentTheme
|
||||
define: #fps_text styles: {
|
||||
#color -> Color red.
|
||||
@ -45,60 +109,11 @@ DiyaApplicationLauncher >> defineLayout [
|
||||
#bgColor -> Color orange.
|
||||
#border -> 3
|
||||
}.
|
||||
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 ] ).
|
||||
root addNode: (DiyaCompositeNode new) at: 0@0.
|
||||
txtFPS := root addNode:(DiyaText data: '') at: ( self context resolution x - 80)@(self context resolution y - 40).
|
||||
txtFPS extent: 80@40.
|
||||
txtFPS styleName: #fps_text.
|
||||
self bindGlobalEvent.
|
||||
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).
|
||||
self launch: self defaultApplication.
|
||||
]
|
||||
|
@ -2,10 +2,8 @@ Class {
|
||||
#name : #DiyaApplicationModel,
|
||||
#superclass : #DiyaSingleton,
|
||||
#instVars : [
|
||||
'node',
|
||||
'am',
|
||||
'target',
|
||||
'context'
|
||||
'root',
|
||||
'am'
|
||||
],
|
||||
#category : #'Diya-Applications'
|
||||
}
|
||||
@ -22,42 +20,30 @@ DiyaApplicationModel >> cleanup [
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaApplicationModel >> context [
|
||||
^DiyaRenderer
|
||||
^DiyaRendererContext uniqueInstance
|
||||
]
|
||||
|
||||
{ #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 >> node [
|
||||
^ node
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaApplicationModel >> onloaded: aBlock [
|
||||
DiyaApplicationModel >> main [
|
||||
self subclassResponsibility
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaApplicationModel >> quit [
|
||||
node empty.
|
||||
self cleanup
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaApplicationModel >> target: aNode [
|
||||
target := aNode.
|
||||
{ #category : #accessing }
|
||||
DiyaApplicationModel >> root [
|
||||
^ root
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaApplicationModel >> setup [
|
||||
self subclassResponsibility
|
||||
]
|
||||
|
@ -7,7 +7,7 @@ Class {
|
||||
{ #category : #initialization }
|
||||
DiyaBaseApplication >> initialize [
|
||||
super initialize.
|
||||
node := DiyaCompositeNode new.
|
||||
node styleName: #global.
|
||||
root := DiyaCompositeNode new.
|
||||
root styleName: #global.
|
||||
am := AssetManager new.
|
||||
]
|
||||
|
@ -18,10 +18,12 @@ Class {
|
||||
|
||||
{ #category : #'class initialization' }
|
||||
DiyaBoot class >> initialize [
|
||||
Smalltalk globals at: #DiyaDisplay put: nil.
|
||||
Smalltalk globals at: #DiyaSystemClock put: nil.
|
||||
Smalltalk globals at: #DiyaRenderer put: nil.
|
||||
Smalltalk globals at: #DiyaSystemSettings put: nil.
|
||||
Smalltalk globals at: #DiyaDisplay put: nil
|
||||
]
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
DiyaBoot class >> maxFPS [
|
||||
^60
|
||||
]
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
@ -34,6 +36,12 @@ 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.
|
||||
@ -78,11 +86,10 @@ 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.
|
||||
Smalltalk globals at: #DiyaSystemSettings put: DiyaSettings uniqueInstance.
|
||||
Smalltalk globals at: #DiyaSystemClock put: DiyaClock uniqueInstance.
|
||||
DiyaSingleton resetAll.
|
||||
DiyaFontManager uniqueInstance loadFonts.
|
||||
]
|
||||
|
||||
{ #category : #events }
|
||||
@ -90,28 +97,23 @@ DiyaBoot >> initialize [
|
||||
display := nil.
|
||||
window := nil.
|
||||
context := nil.
|
||||
clock := DiyaSystemClock.
|
||||
clock := DiyaClock uniqueInstance.
|
||||
]
|
||||
|
||||
{ #category : #events }
|
||||
DiyaBoot >> render [
|
||||
|launcher event|
|
||||
event := SDL_Event new.
|
||||
|launcher|
|
||||
DiyaRendererContext uniqueInstance.
|
||||
launcher := DiyaApplicationLauncher uniqueInstance.
|
||||
"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 setup.
|
||||
self GLinit.
|
||||
[ launcher running ] whileTrue: [
|
||||
DiyaSystemClock tick.
|
||||
[(SDL2 pollEvent: event) > 0] whileTrue: [
|
||||
DiyaRenderer root trigger: (DiyaEvent from: event mapped).
|
||||
].
|
||||
DiyaRenderer render.
|
||||
DiyaClock uniqueInstance tick.
|
||||
launcher main.
|
||||
SDL2 glSwapWindow: window.
|
||||
SDL2 delay:
|
||||
(0 max:
|
||||
(1000/ DiyaSystemSettings maxFPS) asInteger - (DiyaSystemClock lapDelta)).
|
||||
(1000/ self class maxFPS) asInteger - (DiyaClock uniqueInstance lapDelta asMilliSeconds)).
|
||||
].
|
||||
]
|
||||
|
||||
@ -203,7 +205,6 @@ DiyaBoot >> startx [
|
||||
display: display;
|
||||
window: window;
|
||||
useProjection: OrthoProjectionMatrix.
|
||||
Smalltalk globals at: #DiyaRenderer put: DiyaRendererContext uniqueInstance.
|
||||
self render.
|
||||
context delete.
|
||||
window destroy.
|
||||
|
@ -23,12 +23,12 @@ DiyaClock >> elapsedTime [
|
||||
DiyaClock >> initialize [
|
||||
monotonic := DateAndTime now.
|
||||
lastTick := monotonic.
|
||||
lapTime := 0.
|
||||
lapTime := 0 asDuration.
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaClock >> lapDelta [
|
||||
^ ((DateAndTime now) - lastTick) asMilliSeconds
|
||||
^ ((DateAndTime now) - lastTick)
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
@ -38,6 +38,6 @@ DiyaClock >> lapTime [
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaClock >> tick [
|
||||
lapTime := self lapDelta.
|
||||
lapTime := (DateAndTime now) - lastTick.
|
||||
lastTick := DateAndTime now.
|
||||
]
|
||||
|
@ -33,7 +33,7 @@ DiyaConvexPolygon >> calculateVertices [
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaConvexPolygon >> drawLines [
|
||||
OpenGL drawArrays: GL_LINE_LOOP first:0 count: (vbuffer size >> 2) - 1.
|
||||
OpenGL drawArrays: GL_LINE_LOOP first:voffset count: (vbuffer size >> 2) - 1.
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
|
@ -1,24 +0,0 @@
|
||||
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
|
||||
]
|
@ -1,21 +0,0 @@
|
||||
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
|
||||
]
|
@ -1,9 +1,6 @@
|
||||
Class {
|
||||
#name : #DiyaExampleApp,
|
||||
#superclass : #DiyaBaseApplication,
|
||||
#instVars : [
|
||||
'loader'
|
||||
],
|
||||
#category : #'Diya-Applications'
|
||||
}
|
||||
|
||||
@ -12,107 +9,14 @@ 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 18 24) do:[:fontSize|
|
||||
#(16 24) do:[:fontSize|
|
||||
self stdlog: 'Init font size ', fontSize asString, ' of ', fmgr defaultFamily.
|
||||
style := fmgr style: fmgr defaultStyle from: fmgr defaultFamily.
|
||||
(style textureOf: fontSize)" genPrintableASCII" .
|
||||
style textureOf: fontSize.
|
||||
].
|
||||
DiyaUIThemesManager uniqueInstance currentTheme
|
||||
define: #text_icon_1 styles: {
|
||||
@ -164,26 +68,103 @@ DiyaExampleApp >> defineStyleSheet [
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaExampleApp >> initialize [
|
||||
super initialize.
|
||||
loader := nil
|
||||
DiyaExampleApp >> main [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
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...'.
|
||||
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.
|
||||
|
||||
loader onloaded: [
|
||||
node children do:[:e|
|
||||
target addNode: e at: e position.
|
||||
node := target.
|
||||
].
|
||||
aBlock value
|
||||
"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'.
|
||||
|
||||
].
|
||||
|
||||
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
|
||||
]
|
||||
|
@ -13,6 +13,13 @@ DiyaFontManager class >> cleanUpInstance: singleton [
|
||||
singleton reset.
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
DiyaFontManager class >> searchPaths [
|
||||
^ {
|
||||
Smalltalk imageDirectory / 'fonts'
|
||||
}
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaFontManager >> defaultFamily [
|
||||
^'Ubuntu'
|
||||
@ -59,7 +66,7 @@ DiyaFontManager >> loadFace: face [
|
||||
DiyaFontManager >> loadFile: aFile [
|
||||
| path face i numfaces |
|
||||
path := aFile fullName convertToWithConverter: UTF8TextConverter new.
|
||||
self stdlog: 'Loading font file ', path.
|
||||
Transcript show: 'Loading font file ', path;cr.
|
||||
i := 0.
|
||||
numfaces := nil.
|
||||
[ face := FreeTypeFace basicNew
|
||||
@ -83,9 +90,7 @@ DiyaFontManager >> loadFonts [
|
||||
{ #category : #initialization }
|
||||
DiyaFontManager >> loadFonts: force [
|
||||
force ifTrue:[self reset].
|
||||
DiyaSystemSettings fontPaths
|
||||
select:[:p| p asFileReference exists]
|
||||
thenDo:[:path| self loadPath: path].
|
||||
self class searchPaths do:[:path| self loadPath: path].
|
||||
|
||||
]
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
Class {
|
||||
#name : #DiyaImageTex,
|
||||
#superclass : #OpenGLTexImage2D,
|
||||
#instVars : [
|
||||
'name'
|
||||
],
|
||||
#pools : [
|
||||
'OpenGLConstants',
|
||||
'OpenGLTypes'
|
||||
@ -52,7 +55,6 @@ 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.
|
||||
@ -87,7 +89,6 @@ DiyaImageTex >> fromFile: aPath [
|
||||
LibC memCopy: surface pixels getHandle to: data getHandle size: data size.
|
||||
SDL2
|
||||
freeSurface: surface.
|
||||
commited := false.
|
||||
self stdlog: 'Loaded ', aPath fullName.
|
||||
]
|
||||
|
||||
@ -99,7 +100,6 @@ 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,6 +124,11 @@ DiyaImageTex >> mipmap [
|
||||
^false
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaImageTex >> name [
|
||||
^ name
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaImageTex >> setup [
|
||||
OpenGLTexture
|
||||
|
@ -94,8 +94,8 @@ DiyaLine >> process [
|
||||
at: 3 put: 0.0;
|
||||
at: 4 put: 0.0;
|
||||
|
||||
at: 5 put: extent x asFloat;
|
||||
at: 6 put: extent y asFloat;
|
||||
at: 5 put: extent x;
|
||||
at: 6 put: extent y;
|
||||
at: 7 put: 0.0;
|
||||
at: 8 put: 0.0.
|
||||
^true
|
||||
|
@ -1,81 +0,0 @@
|
||||
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
|
||||
]
|
@ -24,11 +24,6 @@ DiyaMetaNode >> extent [
|
||||
^ 0@0
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaMetaNode >> initialize [
|
||||
visibility := false.
|
||||
]
|
||||
|
||||
{ #category : #testing }
|
||||
DiyaMetaNode >> inner: aPoint [
|
||||
^ false
|
||||
|
@ -14,7 +14,6 @@ Class {
|
||||
'root',
|
||||
'styleName',
|
||||
'style',
|
||||
'inlineStyle',
|
||||
'id',
|
||||
'visibility',
|
||||
'pivot'
|
||||
@ -32,11 +31,9 @@ DiyaNode class >> with: shader [
|
||||
^self new shader: shader; yourself
|
||||
]
|
||||
|
||||
{ #category : #styling }
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> ? styleAttr [
|
||||
| value|
|
||||
value := inlineStyle at: styleAttr ifAbsent:[nil].
|
||||
value ifNotNil: [ ^value ].
|
||||
styleName ifNotNil: [
|
||||
style ifNil: [
|
||||
style := DiyaUIThemesManager uniqueInstance currentTheme ? (self styleName).
|
||||
@ -49,12 +46,12 @@ DiyaNode >> ? styleAttr [
|
||||
^ parent ? styleAttr
|
||||
]
|
||||
|
||||
{ #category : #'add/remove' }
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> addNode: node [
|
||||
^self addNode: node at: 0@0
|
||||
]
|
||||
|
||||
{ #category : #'add/remove' }
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> addNode: node at: pos [
|
||||
children ifNil: [ ^self ].
|
||||
node parent: self.
|
||||
@ -82,13 +79,6 @@ DiyaNode >> draw [
|
||||
|
||||
{ #category : #requirements }
|
||||
DiyaNode >> empty [
|
||||
children ifNotNil: [
|
||||
children do:[:c|
|
||||
c root: nil.
|
||||
c setClean.
|
||||
c visibility: false.
|
||||
]
|
||||
].
|
||||
children := OrderedCollection new.
|
||||
]
|
||||
|
||||
@ -97,6 +87,15 @@ DiyaNode >> extent [
|
||||
^ self subclassResponsibility
|
||||
]
|
||||
|
||||
{ #category : #processing }
|
||||
DiyaNode >> forceReload [
|
||||
self process.
|
||||
children ifNotNil: [
|
||||
children do:[:c|
|
||||
c forceReload
|
||||
]]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> id [
|
||||
^ id
|
||||
@ -107,23 +106,17 @@ DiyaNode >> initialize [
|
||||
super initialize.
|
||||
parent := nil.
|
||||
shader := nil.
|
||||
context := DiyaRenderer.
|
||||
context := DiyaRendererContext uniqueInstance.
|
||||
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
|
||||
@ -181,16 +174,15 @@ DiyaNode >> register: aBlock to: eventName [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #'add/remove' }
|
||||
{ #category : #removing }
|
||||
DiyaNode >> remove [
|
||||
self setClean.
|
||||
root := nil.
|
||||
parent ifNotNil: [ parent removeChild: self ]
|
||||
]
|
||||
|
||||
{ #category : #'add/remove' }
|
||||
{ #category : #removing }
|
||||
DiyaNode >> removeChild: c [
|
||||
c setClean.
|
||||
c root: nil.
|
||||
c visibility: false.
|
||||
children ifNotNil: [ children remove: c ifAbsent:[ ]]
|
||||
]
|
||||
|
||||
@ -200,21 +192,7 @@ DiyaNode >> render [
|
||||
shader ifNotNil: [self setUpShader].
|
||||
self draw.
|
||||
children ifNil: [ ^self ].
|
||||
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.
|
||||
children do: [:c| c render ].
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -284,9 +262,10 @@ DiyaNode >> setUpShader [
|
||||
|mem|
|
||||
mem := self tf asGLBuffer.
|
||||
shader use;
|
||||
setUniform: #u_time value: DiyaSystemClock elapsedTime asFloat;
|
||||
setUniform: #u_time value: DiyaClock uniqueInstance 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
|
||||
@ -350,6 +329,7 @@ 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]
|
||||
].
|
||||
]
|
||||
@ -366,7 +346,5 @@ DiyaNode >> visibility [
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> visibility: anObject [
|
||||
visibility := anObject.
|
||||
children ifNotNil: [
|
||||
children do:[:c| c visibility: anObject ] ]
|
||||
visibility := anObject
|
||||
]
|
||||
|
@ -16,7 +16,7 @@ DiyaRectangle class >> size: size shader:s [
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaRectangle >> drawLines [
|
||||
OpenGL drawArrays: GL_LINE_LOOP first:0 count: (vbuffer size >> 2).
|
||||
OpenGL drawArrays: GL_LINE_LOOP first:voffset 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 asFloat;
|
||||
at: 6 put: extent y;
|
||||
at: 7 put: 0.0;
|
||||
at: 8 put: 1.0;
|
||||
|
||||
at: 9 put: extent x asFloat;
|
||||
at: 10 put: extent y asFloat;
|
||||
at: 9 put: extent x;
|
||||
at: 10 put: extent y;
|
||||
at: 11 put: 1.0;
|
||||
at: 12 put: 1.0;
|
||||
|
||||
at: 13 put: extent x asFloat;
|
||||
at: 13 put: extent x;
|
||||
at: 14 put: 0.0;
|
||||
at: 15 put: 1.0;
|
||||
at: 16 put: 0.0.
|
||||
|
@ -6,12 +6,12 @@ Class {
|
||||
'display',
|
||||
'vbo',
|
||||
'vao',
|
||||
'textures',
|
||||
'texture0',
|
||||
'projection',
|
||||
'assets',
|
||||
'window',
|
||||
'root',
|
||||
'lock'
|
||||
'vbuffer',
|
||||
'voffset'
|
||||
],
|
||||
#pools : [
|
||||
'OpenGLConstants',
|
||||
@ -20,6 +20,11 @@ Class {
|
||||
#category : #'Diya-Graphics'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRendererContext class >> bufferSize [
|
||||
^ 524288 "512Kb"
|
||||
]
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
DiyaRendererContext class >> cleanUpInstance: singleton [
|
||||
singleton ifNil:[^self].
|
||||
@ -31,11 +36,6 @@ DiyaRendererContext class >> maxFloatBufferSize [
|
||||
^4096
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRendererContext class >> maxTextureNumber [
|
||||
^ 32
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRendererContext >> assets [
|
||||
^ assets
|
||||
@ -47,12 +47,17 @@ DiyaRendererContext >> assets: anObject [
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRendererContext >> destroy [
|
||||
vao disableAttribute: 0.
|
||||
DiyaRendererContext >> destroy [
|
||||
self disableGLAttribute: 0.
|
||||
vbuffer free.
|
||||
vao delete.
|
||||
vbo delete.
|
||||
textures do: [:e | e key delete ].
|
||||
textures := OrderedCollection new.
|
||||
texture0 delete.
|
||||
]
|
||||
|
||||
{ #category : #registration }
|
||||
DiyaRendererContext >> disableGLAttribute: attribute [
|
||||
vao disableAttribute: attribute
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -65,13 +70,9 @@ DiyaRendererContext >> display: anObject [
|
||||
display := anObject
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
DiyaRendererContext >> findTextureUnit [
|
||||
textures withIndexDo: [ :e :i|
|
||||
e value ifNil: [ ^ i - 1]
|
||||
].
|
||||
"random unit value"
|
||||
^ (Random new nextInt: self class maxTextureNumber) - 1
|
||||
{ #category : #registration }
|
||||
DiyaRendererContext >> enableGLAttribute: attribute [
|
||||
vao enableAttribute: attribute.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -79,28 +80,19 @@ DiyaRendererContext >> initialize [
|
||||
super initialize.
|
||||
vbo := OpenGLVertexBuffer new.
|
||||
vao := OpenGLVertexArray new.
|
||||
textures := Dictionary new.
|
||||
lock := Mutex new.
|
||||
texture0 := OpenGLTexture fromUnit: 0.
|
||||
vao bind.
|
||||
vbo bind: GL_ARRAY_BUFFER.
|
||||
projection := Array2D identity: 4.
|
||||
assets := AssetManager new.
|
||||
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
|
||||
"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.
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -118,12 +110,9 @@ DiyaRendererContext >> projection [
|
||||
^ projection
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
DiyaRendererContext >> render [
|
||||
root render.
|
||||
root readyForSwap ifTrue: [
|
||||
SDL2 glSwapWindow: window.
|
||||
]
|
||||
{ #category : #registration }
|
||||
DiyaRendererContext >> resetBuffer [
|
||||
voffset := 0
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -131,41 +120,54 @@ 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 >> root [
|
||||
root ifNil: [ root := DiyaRootNode new ].
|
||||
^ root
|
||||
|
||||
|
||||
|
||||
DiyaRendererContext >> texture0 [
|
||||
^ texture0
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
DiyaRendererContext >> submitData: vbuffer [
|
||||
vbo data: GL_ARRAY_BUFFER data: vbuffer usage: GL_STATIC_DRAW.
|
||||
]
|
||||
|
||||
{ #category : #'transformation matrices' }
|
||||
{ #category : #registration }
|
||||
DiyaRendererContext >> useProjection: aClass [
|
||||
projection := aClass fromDisplay: self display
|
||||
]
|
||||
|
||||
{ #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 }
|
||||
DiyaRendererContext >> vao [
|
||||
^ vao
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRendererContext >> vbo [
|
||||
^ vbo
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRendererContext >> vbuffer [
|
||||
^ vbuffer
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRendererContext >> voffset [
|
||||
^ voffset
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -2,12 +2,16 @@ Class {
|
||||
#name : #DiyaRootNode,
|
||||
#superclass : #DiyaNode,
|
||||
#instVars : [
|
||||
'Q',
|
||||
'R'
|
||||
'Q'
|
||||
],
|
||||
#category : #'Diya-Graphics'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRootNode >> Q [
|
||||
^ Q
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaRootNode >> boundingBox [
|
||||
^ Rectangle origin: 0@0 corner: context resolution
|
||||
@ -21,14 +25,16 @@ 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 addIfNotPresent: aNode
|
||||
(Q includes: aNode ) ifFalse:[ Q add: aNode].
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -43,8 +49,7 @@ DiyaRootNode >> initialize [
|
||||
shader := nil.
|
||||
root := self.
|
||||
styleName := #global.
|
||||
Q := OrderedCollection new.
|
||||
R := OrderedCollection new.
|
||||
Q := OrderedCollection new
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -62,35 +67,11 @@ DiyaRootNode >> process [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #controlling }
|
||||
DiyaRootNode >> processQueue [
|
||||
{ #category : #accessing }
|
||||
DiyaRootNode >> processingQueue [
|
||||
^ 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 [
|
||||
|
||||
@ -104,24 +85,6 @@ 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"
|
||||
|
@ -1,90 +0,0 @@
|
||||
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
|
||||
]
|
@ -25,7 +25,7 @@ DiyaSingleton class >> new [
|
||||
{ #category : #'instance creation' }
|
||||
DiyaSingleton class >> reset [
|
||||
|singleton key|
|
||||
key := self class.
|
||||
key := self class asString asSymbol.
|
||||
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 ifAbsentPut: [ super new ].
|
||||
^singletons at: self class asString asSymbol ifAbsentPut: [ super new ].
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
|
@ -206,6 +206,9 @@ 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.
|
||||
@ -227,14 +230,6 @@ 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.
|
||||
|
@ -26,7 +26,7 @@ DiyaTimerNode class >> timeout: ms doOnce: aBlock [
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaTimerNode >> delta [
|
||||
^ DiyaSystemClock delta
|
||||
^ DiyaClock uniqueInstance delta asMilliSeconds
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -62,6 +62,7 @@ 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',
|
||||
@ -108,6 +109,7 @@ 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.
|
||||
|
@ -26,7 +26,7 @@ OpenGLFontTex class >> fromFace: face ofSize: size [
|
||||
^self new fromFace: face ofSize: size; yourself
|
||||
]
|
||||
|
||||
{ #category : #processing }
|
||||
{ #category : #'instance creation' }
|
||||
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,8 +67,6 @@ 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.
|
||||
@ -102,7 +100,7 @@ OpenGLFontTex >> fromFace: aFace ofSize: size [
|
||||
iptr free.
|
||||
]
|
||||
|
||||
{ #category : #processing }
|
||||
{ #category : #accessing }
|
||||
OpenGLFontTex >> genGlyph:c [
|
||||
|rec offset glyph gsize|
|
||||
face setPixelWidth:0 height: self fontSize.
|
||||
@ -124,20 +122,13 @@ 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 }
|
||||
@ -165,7 +156,7 @@ OpenGLFontTex >> meanww [
|
||||
^ meanww
|
||||
]
|
||||
|
||||
{ #category : #processing }
|
||||
{ #category : #accessing }
|
||||
OpenGLFontTex >> reallocateBuffer [
|
||||
|newbuffer|
|
||||
maxrows := maxrows + 4.
|
||||
@ -178,12 +169,12 @@ OpenGLFontTex >> reallocateBuffer [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
{ #category : #accessing }
|
||||
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;
|
||||
|
@ -10,10 +10,7 @@ Class {
|
||||
'border',
|
||||
'format',
|
||||
'type',
|
||||
'data',
|
||||
'unit',
|
||||
'commited',
|
||||
'name'
|
||||
'data'
|
||||
],
|
||||
#pools : [
|
||||
'OpenGLConstants',
|
||||
@ -37,16 +34,6 @@ OpenGLTexImage2D >> bytesSize [
|
||||
^(width * height) << 2
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> commited [
|
||||
^ commited
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> commited: anObject [
|
||||
commited := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> data [
|
||||
^ data
|
||||
@ -100,13 +87,6 @@ OpenGLTexImage2D >> height: anObject [
|
||||
height := anObject
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
OpenGLTexImage2D >> initialize [
|
||||
super initialize.
|
||||
unit := -1.
|
||||
commited := false
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> internalFormat [
|
||||
^ internalFormat
|
||||
@ -132,11 +112,6 @@ OpenGLTexImage2D >> mipmap [
|
||||
^false
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> name [
|
||||
^ name
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> setup [
|
||||
^self subclassResponsibility
|
||||
@ -162,16 +137,6 @@ OpenGLTexImage2D >> type: anObject [
|
||||
type := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> unit [
|
||||
^ unit
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> unit: anObject [
|
||||
unit := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
OpenGLTexImage2D >> width [
|
||||
^ width
|
||||
|
@ -26,7 +26,7 @@ OpenGLVertexBuffer class >> deleteBuffersSize:n buffers: buffers [
|
||||
^self ffiCall: #(void glDeleteBuffers( GLsizei n,const GLuint * buffers))
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : #'library path' }
|
||||
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 : #initialization }
|
||||
{ #category : #'as yet unclassified' }
|
||||
OpenGLVertexBuffer >> bind: target [
|
||||
^OpenGLVertexBuffer bind:target buffer: self vertexBufferID
|
||||
]
|
||||
|
||||
{ #category : #'accessing - data' }
|
||||
{ #category : #'as yet unclassified' }
|
||||
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 : #'accessing - data' }
|
||||
{ #category : #'as yet unclassified' }
|
||||
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 : #'add/remove' }
|
||||
{ #category : #'as yet unclassified' }
|
||||
OpenGLVertexBuffer >> delete [
|
||||
OpenGLVertexBuffer deleteBuffersSize: 1 buffers: vertexBufferID getHandle.
|
||||
]
|
||||
@ -78,18 +78,19 @@ 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 : #'accessing - data' }
|
||||
{ #category : #'as yet unclassified' }
|
||||
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 : #'accessing - data' }
|
||||
{ #category : #'as yet unclassified' }
|
||||
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
|
||||
]
|
||||
|
||||
|
@ -8,6 +8,6 @@ SDL_TouchFingerEvent >> triggableOn: aNode [
|
||||
{ #category : #'*Diya' }
|
||||
SDL_TouchFingerEvent >> worldPosition [
|
||||
|resolution|
|
||||
resolution := DiyaRenderer resolution.
|
||||
resolution := DiyaRendererContext uniqueInstance resolution.
|
||||
^((self x)* (resolution x) ) @ ((self y)* (resolution y)).
|
||||
]
|
||||
|
3
Jenkinsfile
vendored
3
Jenkinsfile
vendored
@ -20,8 +20,7 @@ pipeline{
|
||||
{
|
||||
stage('Build image from SDK') {
|
||||
steps {
|
||||
// build specific multi-branch job on master branch
|
||||
build job: 'gitea-sync/DiyaSDK/master', propagate: true, wait: true
|
||||
build job: 'Diya-image', propagate: true, wait: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user