mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-27 03:48:21 +01:00
Text rendering is greatly improved
This commit is contained in:
parent
a751a6a6d3
commit
bd9d406c85
6
Diya/Color.extension.st
Normal file
6
Diya/Color.extension.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Extension { #name : #Color }
|
||||||
|
|
||||||
|
{ #category : #'*Diya' }
|
||||||
|
Color >> asGL4FArray [
|
||||||
|
^{self red. self green. self blue. self alpha }
|
||||||
|
]
|
@ -1,15 +1,20 @@
|
|||||||
Class {
|
Class {
|
||||||
#name : #Diya2DNode,
|
#name : #Diya2DNode,
|
||||||
#superclass : #DiyaNode,
|
#superclass : #DiyaNode,
|
||||||
|
#instVars : [
|
||||||
|
'color'
|
||||||
|
],
|
||||||
#category : #'Diya-Graphics'
|
#category : #'Diya-Graphics'
|
||||||
}
|
}
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #accessing }
|
||||||
Diya2DNode >> gltf: points do: block [
|
Diya2DNode >> color [
|
||||||
^ points collect: [ :point | |coord|
|
^ color
|
||||||
coord := self tf +* { point x. point y. 1.0 }.
|
]
|
||||||
block value: coord first value: (coord at:2)
|
|
||||||
]
|
{ #category : #accessing }
|
||||||
|
Diya2DNode >> color: anObject [
|
||||||
|
color := anObject
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #initialization }
|
{ #category : #initialization }
|
||||||
@ -19,6 +24,14 @@ Diya2DNode >> initialize [
|
|||||||
scale := 1.0@1.0.
|
scale := 1.0@1.0.
|
||||||
rotation := 0.0.
|
rotation := 0.0.
|
||||||
tf := Array2D identity: 3.
|
tf := Array2D identity: 3.
|
||||||
|
shader := Diya2DShader uniqueInstance.
|
||||||
|
color := Color white
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #initialization }
|
||||||
|
Diya2DNode >> setUpShader [
|
||||||
|
super setUpShader.
|
||||||
|
shader setUniform: #u_color value: self color asGL4FArray.
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
@ -42,6 +55,8 @@ Diya2DNode >> updateTF [
|
|||||||
0.0. scale y. 0.0.
|
0.0. scale y. 0.0.
|
||||||
0.0. 0.0. 1.0
|
0.0. 0.0. 1.0
|
||||||
}).
|
}).
|
||||||
self parent isRoot ifTrue: [ ^tf ].
|
self parent isRoot ifFalse: [ tf := self parent tf +* tf ].
|
||||||
tf := self parent tf +* tf
|
children ifNotNil: [
|
||||||
|
children do:[:c| c updateTF ]].
|
||||||
|
|
||||||
]
|
]
|
||||||
|
33
Diya/Diya2DPrimShape.class.st
Normal file
33
Diya/Diya2DPrimShape.class.st
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
Class {
|
||||||
|
#name : #Diya2DPrimShape,
|
||||||
|
#superclass : #Diya2DNode,
|
||||||
|
#instVars : [
|
||||||
|
'texture'
|
||||||
|
],
|
||||||
|
#category : #'Diya-Graphics'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #initialization }
|
||||||
|
Diya2DPrimShape >> initialize [
|
||||||
|
super initialize.
|
||||||
|
texture := nil.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #initialization }
|
||||||
|
Diya2DPrimShape >> setUpShader [
|
||||||
|
super setUpShader.
|
||||||
|
texture ifNotNil: [
|
||||||
|
self shader
|
||||||
|
setUniform: #u_use_texture value:1.
|
||||||
|
].
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Diya2DPrimShape >> texture [
|
||||||
|
^ texture
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Diya2DPrimShape >> texture: anObject [
|
||||||
|
texture := anObject
|
||||||
|
]
|
57
Diya/Diya2DShader.class.st
Normal file
57
Diya/Diya2DShader.class.st
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
Class {
|
||||||
|
#name : #Diya2DShader,
|
||||||
|
#superclass : #OpenGLSL,
|
||||||
|
#category : #'Diya-Shaders'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Diya2DShader class >> fragmentShader [
|
||||||
|
^'
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform vec2 u_resolution;
|
||||||
|
uniform vec2 u_mouse;
|
||||||
|
uniform float u_time;
|
||||||
|
// 2D uniforms
|
||||||
|
uniform int u_use_texture;
|
||||||
|
uniform vec4 u_color;
|
||||||
|
uniform vec4 u_border_color;
|
||||||
|
uniform sampler2D u_texture;
|
||||||
|
varying vec2 texcoord;
|
||||||
|
void main(void) {
|
||||||
|
vec4 texcolor = vec4(1,1,1,1);
|
||||||
|
if(u_use_texture == 1)
|
||||||
|
{
|
||||||
|
texcolor = vec4(1, 1, 1, texture2D(u_texture, texcoord).a);
|
||||||
|
}
|
||||||
|
gl_FragColor = texcolor * u_color;
|
||||||
|
}'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Diya2DShader class >> vertexShader [
|
||||||
|
^'
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#endif
|
||||||
|
uniform mat4 u_projection;
|
||||||
|
uniform mat3 u_transform;
|
||||||
|
varying vec2 texcoord;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 coord_global = u_transform * vec3(gl_Vertex.xy, 1.0);
|
||||||
|
gl_Position = u_projection * vec4(coord_global.xy, 0, 1.0);
|
||||||
|
texcoord = gl_Vertex.zw;
|
||||||
|
}'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #initialization }
|
||||||
|
Diya2DShader >> setUpUniforms [
|
||||||
|
self addUniform: #u_texture of: Uniform1i.
|
||||||
|
self addUniform: #u_use_texture of: Uniform1i.
|
||||||
|
self addUniform: #u_color of: Uniform4F.
|
||||||
|
self addUniform: #u_border_color of: Uniform4F.
|
||||||
|
self addUniform: #u_border of: Uniform1i.
|
||||||
|
]
|
@ -17,6 +17,11 @@ Class {
|
|||||||
#category : #'Diya-Runtime'
|
#category : #'Diya-Runtime'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #'instance creation' }
|
||||||
|
DiyaBoot class >> maxFPS [
|
||||||
|
^60
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #'instance creation' }
|
{ #category : #'instance creation' }
|
||||||
DiyaBoot class >> startUp: status [
|
DiyaBoot class >> startUp: status [
|
||||||
self startx.
|
self startx.
|
||||||
@ -61,6 +66,23 @@ DiyaBoot >> createWindow [
|
|||||||
^window
|
^window
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #events }
|
||||||
|
DiyaBoot >> exampleNodes [
|
||||||
|
|root text rec style|
|
||||||
|
root := DiyaRootNode new.
|
||||||
|
rec := root addNode: (DiyaRectangle size: 208@288) at: 250 @ 200.
|
||||||
|
style := DiyaFontManager uniqueInstance style: 'Bold' from: 'Ubuntu'.
|
||||||
|
rec texture: (style textureOf: 16).
|
||||||
|
rec color: (Color r: 1.0 g:0.0 b:1.0 alpha:1.0 ).
|
||||||
|
rec := root addNode: (DiyaRectangle size:100@150 shader: DiyaExampleShader uniqueInstance) at: 20 @ 400.
|
||||||
|
rec rotation: (Float pi / -8.0).
|
||||||
|
rec scale: 1.5@1.5.
|
||||||
|
text := root addNode: (DiyaText data: String loremIpsum) at: 20@320.
|
||||||
|
text extent: 200@320.
|
||||||
|
^ root
|
||||||
|
"text rotation:(Float pi / 4.0); scale: 2.0@2.0."
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #events }
|
{ #category : #events }
|
||||||
DiyaBoot >> init [
|
DiyaBoot >> init [
|
||||||
| status |
|
| status |
|
||||||
@ -107,26 +129,27 @@ DiyaBoot >> randomColorChannel [
|
|||||||
|
|
||||||
{ #category : #events }
|
{ #category : #events }
|
||||||
DiyaBoot >> render [
|
DiyaBoot >> render [
|
||||||
|event root rec text|
|
|event root text delta|
|
||||||
event := SDL_Event new.
|
event := SDL_Event new.
|
||||||
root := DiyaRootNode new.
|
root := self exampleNodes.
|
||||||
DiyaRenderer uniqueInstance root: root.
|
DiyaRenderer uniqueInstance root: root.
|
||||||
rec := root addNode: (DiyaRectangle size: 120@160 shader: GLSimpleShader uniqueInstance) at: 250 @ 200.
|
text := root addNode:(DiyaText data: 'tick') at: (display w - 80)@40.
|
||||||
rec := root addNode: (DiyaRectangle size: 50@50 shader: GLSimpleShader uniqueInstance) at: 250 @ 500.
|
text extent: 80@40.
|
||||||
rec rotation: (Float pi / -8.0).
|
text fontSize: 20.
|
||||||
rec scale: 1.5@1.5.
|
text color: Color red.
|
||||||
text := root addNode: (DiyaText data: String loremIpsum shader: TotoShader uniqueInstance) at: 20@320.
|
|
||||||
text extent: 200@320.
|
|
||||||
"text rotation:(Float pi / 4.0)."
|
|
||||||
self GLinit.
|
self GLinit.
|
||||||
OpenGL viewportX: 0 Y:0 W: display w H: display h.
|
OpenGL viewportX: 0 Y:0 W: display w H: display h.
|
||||||
"TODO: maybe give node to customize this"
|
|
||||||
[ running ] whileTrue: [
|
[ running ] whileTrue: [
|
||||||
(SDL2 pollEvent: event) > 0 ifTrue: [
|
delta := DiyaClock uniqueInstance delta asMilliSeconds.
|
||||||
|
text data: ('FPS:', (1000/delta) asInteger asString).
|
||||||
|
DiyaClock uniqueInstance tick.
|
||||||
|
[(SDL2 pollEvent: event) > 0] whileTrue: [
|
||||||
self processEvent: event
|
self processEvent: event
|
||||||
].
|
].
|
||||||
DiyaRenderer uniqueInstance render.
|
DiyaRenderer uniqueInstance render.
|
||||||
SDL2 glSwapWindow: window.
|
SDL2 glSwapWindow: window.
|
||||||
|
delta := DiyaClock uniqueInstance delta asMilliSeconds.
|
||||||
|
SDL2 delay: (0 max: (1000/ self class maxFPS) asInteger - delta). "60 fps"
|
||||||
].
|
].
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2,11 +2,17 @@ Class {
|
|||||||
#name : #DiyaClock,
|
#name : #DiyaClock,
|
||||||
#superclass : #DiyaSingleton,
|
#superclass : #DiyaSingleton,
|
||||||
#instVars : [
|
#instVars : [
|
||||||
'monotonic'
|
'monotonic',
|
||||||
|
'lastTick'
|
||||||
],
|
],
|
||||||
#category : #'Diya-Runtime'
|
#category : #'Diya-Runtime'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #initialization }
|
||||||
|
DiyaClock >> delta [
|
||||||
|
^(DateAndTime now) - lastTick
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #initialization }
|
{ #category : #initialization }
|
||||||
DiyaClock >> elapsedTime [
|
DiyaClock >> elapsedTime [
|
||||||
^(DateAndTime now) - monotonic
|
^(DateAndTime now) - monotonic
|
||||||
@ -15,4 +21,10 @@ DiyaClock >> elapsedTime [
|
|||||||
{ #category : #initialization }
|
{ #category : #initialization }
|
||||||
DiyaClock >> initialize [
|
DiyaClock >> initialize [
|
||||||
monotonic := DateAndTime now.
|
monotonic := DateAndTime now.
|
||||||
|
lastTick := monotonic.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #initialization }
|
||||||
|
DiyaClock >> tick [
|
||||||
|
lastTick := DateAndTime now.
|
||||||
]
|
]
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
Class {
|
|
||||||
#name : #DiyaDefaultShader,
|
|
||||||
#superclass : #OpenGLSL,
|
|
||||||
#category : #'Diya-Shaders'
|
|
||||||
}
|
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
DiyaDefaultShader class >> fragmentShader [
|
|
||||||
^ '
|
|
||||||
#ifdef GL_ES
|
|
||||||
precision mediump float;
|
|
||||||
#endif
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
gl_FragColor = vec4(1.0,1.0,1.0,1.0);
|
|
||||||
}
|
|
||||||
'
|
|
||||||
]
|
|
@ -1,11 +1,11 @@
|
|||||||
Class {
|
Class {
|
||||||
#name : #GLSimpleShader,
|
#name : #DiyaExampleShader,
|
||||||
#superclass : #OpenGLSL,
|
#superclass : #Diya2DShader,
|
||||||
#category : #'Diya-Shaders'
|
#category : #'Diya-Shaders'
|
||||||
}
|
}
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GLSimpleShader class >> fragmentShader [
|
DiyaExampleShader class >> fragmentShader [
|
||||||
^ '
|
^ '
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
@ -17,7 +17,6 @@ void main()
|
|||||||
{
|
{
|
||||||
vec2 mouse = u_mouse / u_resolution;
|
vec2 mouse = u_mouse / u_resolution;
|
||||||
vec2 px = (gl_FragCoord.xy/u_resolution);
|
vec2 px = (gl_FragCoord.xy/u_resolution);
|
||||||
|
|
||||||
gl_FragColor = vec4(px/mouse, abs(sin(u_time)), 1.0);
|
gl_FragColor = vec4(px/mouse, abs(sin(u_time)), 1.0);
|
||||||
}
|
}
|
||||||
'
|
'
|
@ -120,6 +120,7 @@ DiyaNode >> position: anObject [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaNode >> render [
|
DiyaNode >> render [
|
||||||
|
shader ifNotNil: [ self setUpShader ].
|
||||||
self draw.
|
self draw.
|
||||||
children ifNil: [ ^self ].
|
children ifNil: [ ^self ].
|
||||||
children do: [:c | c render ].
|
children do: [:c | c render ].
|
||||||
@ -147,6 +148,22 @@ DiyaNode >> scale: anObject [
|
|||||||
self updateTF.
|
self updateTF.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
DiyaNode >> setUpShader [
|
||||||
|
shader use;
|
||||||
|
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. self tf asGLBuffer}.
|
||||||
|
context mouse ifNotNil: [
|
||||||
|
"in shader, window origin is bottom left conor of the window
|
||||||
|
the mouse position should be transformed to this coodinate"
|
||||||
|
shader setUniform: #u_mouse value:
|
||||||
|
{ context mouse x. context resolution y - context mouse y }.
|
||||||
|
].
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaNode >> shader [
|
DiyaNode >> shader [
|
||||||
shader ifNil: [
|
shader ifNil: [
|
||||||
|
@ -1,32 +1,30 @@
|
|||||||
Class {
|
Class {
|
||||||
#name : #DiyaRectangle,
|
#name : #DiyaRectangle,
|
||||||
#superclass : #Diya2DNode,
|
#superclass : #Diya2DPrimShape,
|
||||||
#category : #'Diya-Graphics'
|
#category : #'Diya-Graphics'
|
||||||
}
|
}
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaRectangle >> draw [
|
DiyaRectangle >> draw [
|
||||||
{
|
{
|
||||||
0.0. 0.0. 1.0.
|
0.0. extent y. 0.0. 0.0.
|
||||||
0.0. extent y. 1.0.
|
0. 0. 0.0. 1.0.
|
||||||
extent x. extent y. 1.0.
|
extent x. 0.0. 1.0. 1.0.
|
||||||
extent x. 0.0. 1.0.
|
0.0. extent y. 0.0. 0.0.
|
||||||
|
extent x. 0.0. 1.0. 1.0.
|
||||||
|
extent x. extent y. 1.0. 0.0.
|
||||||
} doWithIndex: [:e :i| context buffer at: i put: e].
|
} doWithIndex: [:e :i| context buffer at: i put: e].
|
||||||
shader use.
|
texture ifNotNil: [
|
||||||
shader setUniform: #u_time value: DiyaClock uniqueInstance elapsedTime asFloat.
|
self texture setup.
|
||||||
shader setUniform: #u_transform value: {GL_TRUE. self tf asGLBuffer}.
|
context texture0 setImage2D: self texture.
|
||||||
shader setUniform: #u_projection value: {GL_FALSE. context projection buffer}.
|
context texture0 active.
|
||||||
shader setUniform: #u_resolution value: { context resolution x. context resolution y }.
|
|
||||||
context mouse ifNotNil: [
|
|
||||||
"in shader, window origin is bottom left conor of the window
|
|
||||||
the mouse position should be transformed to this coodinate"
|
|
||||||
shader setUniform: #u_mouse value: { context mouse x. context resolution y - context mouse y }.
|
|
||||||
].
|
].
|
||||||
context vao enableAttribute: 0.
|
context vao enableAttribute: 0.
|
||||||
OpenGLVertexArray vertexAttributePointerIndex: 0 size:3 type: GL_FLOAT normalized: GL_FALSE stride: 0 pointer: nil.
|
OpenGLVertexArray vertexAttributePointerIndex: 0 size:4 type: GL_FLOAT normalized: GL_FALSE stride: 16 pointer: nil.
|
||||||
context vbo subData: GL_ARRAY_BUFFER offset:0 data: context buffer.
|
context vbo subData: GL_ARRAY_BUFFER offset:0 data: context buffer size: 96.
|
||||||
OpenGL drawArrays: GL_QUADS first:0 count: 4.
|
OpenGL drawArrays: GL_TRIANGLES first:0 count: 6.
|
||||||
context vao disableAttribute: 0.
|
context vao disableAttribute: 0.
|
||||||
|
texture ifNotNil: [self texture drop]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
@ -24,7 +24,7 @@ DiyaRendererContext class >> cleanUpInstance: singleton [
|
|||||||
|
|
||||||
{ #category : #'instance creation' }
|
{ #category : #'instance creation' }
|
||||||
DiyaRendererContext class >> maxFloatBufferSize [
|
DiyaRendererContext class >> maxFloatBufferSize [
|
||||||
^512
|
^4096
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
@ -6,7 +6,7 @@ Class {
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaRootNode >> draw [
|
DiyaRootNode >> draw [
|
||||||
OpenGL clearColorR: 1.0 G: 0.0 B: 1.0 A:0.
|
OpenGL clearColorR: 0.0 G: 0.0 B: 0.0 A:0.
|
||||||
OpenGL clear: GL_COLOR_BUFFER_BIT.
|
OpenGL clear: GL_COLOR_BUFFER_BIT.
|
||||||
context vbo bind: GL_ARRAY_BUFFER.
|
context vbo bind: GL_ARRAY_BUFFER.
|
||||||
]
|
]
|
||||||
@ -15,7 +15,7 @@ DiyaRootNode >> draw [
|
|||||||
DiyaRootNode >> initialize [
|
DiyaRootNode >> initialize [
|
||||||
super initialize.
|
super initialize.
|
||||||
parent := self.
|
parent := self.
|
||||||
shader := DiyaDefaultShader uniqueInstance.
|
shader := nil.
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #testing }
|
{ #category : #testing }
|
||||||
|
@ -37,74 +37,36 @@ DiyaText >> data: anObject [
|
|||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaText >> draw [
|
DiyaText >> draw [
|
||||||
data ifNil: [ ^self ].
|
data ifNil: [ ^self ].
|
||||||
style := DiyaFontManager uniqueInstance style: self fontStyle from: self fontName.
|
|
||||||
OpenGL
|
|
||||||
enable: GL_CULL_FACE;
|
|
||||||
enable: GL_BLEND;
|
|
||||||
blendFnWithSfactor: GL_SRC_ALPHA dfactor: GL_ONE_MINUS_SRC_ALPHA;
|
|
||||||
pixelstorei: GL_UNPACK_ALIGNMENT param: 1.
|
|
||||||
self shader
|
self shader
|
||||||
use;
|
setUniform: #u_use_texture value:1.
|
||||||
setUniform: #u_time value: DiyaClock uniqueInstance elapsedTime asFloat;
|
|
||||||
setUniform: #u_projection value: {GL_FALSE. context projection buffer};
|
|
||||||
setUniform: #u_transform value: {GL_TRUE. self tf asGLBuffer};
|
|
||||||
setUniform: #u_texture value: 0;
|
|
||||||
setUniform: #u_resolution value: { context resolution x. context resolution y }.
|
|
||||||
"configure vao vbo for texture QUAD"
|
"configure vao vbo for texture QUAD"
|
||||||
context texture0 active.
|
style := DiyaFontManager uniqueInstance style: self fontStyle from: self fontName.
|
||||||
|
self texture setup.
|
||||||
context texture0 setImage2D: self texture.
|
context texture0 setImage2D: self texture.
|
||||||
OpenGLTexture
|
context texture0 active.
|
||||||
parameteri: GL_TEXTURE_2D pname: GL_TEXTURE_WRAP_S param: GL_CLAMP_TO_EDGE;
|
|
||||||
parameteri: GL_TEXTURE_2D pname: GL_TEXTURE_WRAP_T param: GL_CLAMP_TO_EDGE;
|
|
||||||
parameteri: GL_TEXTURE_2D pname: GL_TEXTURE_MIN_FILTER param: GL_LINEAR;
|
|
||||||
parameteri: GL_TEXTURE_2D pname: GL_TEXTURE_MAG_FILTER param: GL_LINEAR.
|
|
||||||
context vao enableAttribute: 0.
|
context vao enableAttribute: 0.
|
||||||
OpenGLVertexArray vertexAttributePointerIndex: 0 size:4 type: GL_FLOAT normalized: GL_FALSE stride: 16 pointer: nil .
|
OpenGLVertexArray vertexAttributePointerIndex: 0 size:4 type: GL_FLOAT normalized: GL_FALSE stride: 16 pointer: nil .
|
||||||
self drawText.
|
self drawText.
|
||||||
context vao disableAttribute: 0.
|
context vao disableAttribute: 0.
|
||||||
"reset value"
|
"reset value"
|
||||||
OpenGL
|
self texture drop.
|
||||||
pixelstorei: GL_UNPACK_ALIGNMENT param: 4;
|
|
||||||
disable: GL_CULL_FACE;
|
|
||||||
disable: GL_BLEND.
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
DiyaText >> drawCharacter: c at: offset [
|
|
||||||
|x y w h glyph tex2D|
|
|
||||||
tex2D := self texture.
|
|
||||||
c = (Character space asciiValue) ifTrue:[
|
|
||||||
^offset setX: (offset x + ((tex2D spacing )* (self scale x)) ) setY: offset y.
|
|
||||||
].
|
|
||||||
glyph := tex2D getGlyph: c.
|
|
||||||
((offset x > self extent x) and: (glyph extent x > 0)) ifTrue:[
|
|
||||||
offset setX: 0.0 setY: (offset y )- (tex2D linespace * (self scale y)).].
|
|
||||||
x := offset x + ((glyph bearing x )*(self scale x)).
|
|
||||||
y := offset y - ((tex2D cellh) * (self scale y)).
|
|
||||||
w := (glyph extent x)*(self scale x).
|
|
||||||
h := (glyph extent y)*(self scale y).
|
|
||||||
{x. y + h. glyph texcoord origin x. glyph texcoord origin y.
|
|
||||||
x. y. glyph texcoord origin x. glyph texcoord corner y.
|
|
||||||
x + w. y. glyph texcoord corner x. glyph texcoord corner y.
|
|
||||||
x. y + h. glyph texcoord origin x. glyph texcoord origin y.
|
|
||||||
x + w. y. glyph texcoord corner x. glyph texcoord corner y.
|
|
||||||
x + w. y + h. glyph texcoord corner x. glyph texcoord origin y. } withIndexDo: [ :e :i| context buffer at:i put: e ].
|
|
||||||
context vbo subData: GL_ARRAY_BUFFER offset: 0 data: context buffer.
|
|
||||||
OpenGL drawArrays: GL_TRIANGLES first:0 count:6.
|
|
||||||
offset setX: (offset x + ((glyph advance x )* (self scale x)) ) setY: offset y.
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaText >> drawSubStringFrom: lower at: offset [
|
DiyaText >> drawSubStringFrom: lower at: offset [
|
||||||
|upper vertices count|
|
|upper vertices count index tex2D|
|
||||||
upper := lower + ((data size - lower) min:(context buffer size / 6) asInteger) - 1.
|
upper := lower + ((data size - lower) min:(context buffer size / 24) asInteger).
|
||||||
count := 0.
|
count := 0.
|
||||||
|
index := 1.
|
||||||
|
tex2D := self texture.
|
||||||
lower to: upper do: [ :i|
|
lower to: upper do: [ :i|
|
||||||
vertices := self getCharsVertices:(data at:i) asciiValue offset: offset.
|
vertices := self getCharsVertices:(data at:i) asciiValue offset: offset on: tex2D.
|
||||||
vertices withIndexDo: [
|
vertices do: [
|
||||||
:e :p| context buffer at: count*4 + p put:e ].
|
:e| context buffer at: index put:e.
|
||||||
count := count + (vertices size /4) asInteger.
|
index := index + 1.
|
||||||
|
].
|
||||||
|
vertices ifNotEmpty: [ count := count + 6 ].
|
||||||
].
|
].
|
||||||
context vbo subData: GL_ARRAY_BUFFER offset: 0 data: context buffer.
|
context vbo subData: GL_ARRAY_BUFFER offset: 0 data: context buffer.
|
||||||
OpenGL drawArrays: GL_TRIANGLES first:0 count:count.
|
OpenGL drawArrays: GL_TRIANGLES first:0 count:count.
|
||||||
@ -122,33 +84,6 @@ DiyaText >> drawText [
|
|||||||
] whileTrue.
|
] whileTrue.
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
DiyaText >> fillVerticesBuffer: buffer at: offset tex: tex [
|
|
||||||
|x y w h|
|
|
||||||
"x := offset x + ((tex bearing x )*(self scale x)).
|
|
||||||
y := offset y - (((tex height) - (tex bearing y))*(self scale y)).
|
|
||||||
w := (tex width)*(self scale x).
|
|
||||||
h := (tex height)*(self scale y)."
|
|
||||||
x := 0.
|
|
||||||
y := 0.
|
|
||||||
w := tex width.
|
|
||||||
h := tex height.
|
|
||||||
{x. y + h. 0.0. 0.0.
|
|
||||||
x. y. 0.0. 1.0.
|
|
||||||
x + w. y. 1.0. 1.0.
|
|
||||||
x. y + h. 0.0. 0.0.
|
|
||||||
x + w. y. 1.0. 1.0.
|
|
||||||
x + w. y + h. 1.0. 0.0. } withIndexDo: [ :e :i| buffer at:i put: e ]
|
|
||||||
|
|
||||||
|
|
||||||
"{x. y + h. 0.0. 0.0.
|
|
||||||
x. y. 0.0. 1.0.
|
|
||||||
x + w. y. 1.0. 1.0.
|
|
||||||
x. y + h. 0.0. 0.0.
|
|
||||||
x + w. y. 1.0. 1.0.
|
|
||||||
x + w. y + h. 1.0. 0.0. }"
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaText >> fontName [
|
DiyaText >> fontName [
|
||||||
^ fontName
|
^ fontName
|
||||||
@ -180,21 +115,21 @@ DiyaText >> fontStyle: anObject [
|
|||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaText >> getCharsVertices:c offset: offset [
|
DiyaText >> getCharsVertices:c offset: offset on: tex2D [
|
||||||
|x y w h glyph tex2D|
|
|x y w h glyph gsize|
|
||||||
tex2D := self texture.
|
|
||||||
c = (Character space asciiValue) ifTrue:[
|
c = (Character space asciiValue) ifTrue:[
|
||||||
offset setX: (offset x + ((tex2D spacing )* (self scale x)) ) setY: offset y.
|
offset setX: (offset x + (tex2D spacing ) ) setY: offset y.
|
||||||
^ { }.
|
^ {}.
|
||||||
].
|
].
|
||||||
glyph := tex2D getGlyph: c.
|
glyph := tex2D getGlyph: c.
|
||||||
((offset x > self extent x) and: (glyph extent x > 0)) ifTrue:[
|
gsize := glyph extent.
|
||||||
offset setX: 0.0 setY: (offset y )- (tex2D linespace * (self scale y)).].
|
((offset x > self extent x) and: (gsize x > 0)) ifTrue:[
|
||||||
x := offset x + ((glyph bearing x )*(self scale x)).
|
offset setX: 0.0 setY: (offset y )- (tex2D linespace).].
|
||||||
y := offset y - ((tex2D cellh) * (self scale y)).
|
x := offset x + (glyph bearing x).
|
||||||
w := (glyph extent x)*(self scale x).
|
y := offset y - (tex2D cellh).
|
||||||
h := (glyph extent y)*(self scale y).
|
w := (gsize x).
|
||||||
offset setX: (offset x + ((glyph advance x )* (self scale x)) ) setY: offset y.
|
h := (gsize y).
|
||||||
|
offset setX: (offset x + (glyph advance x)) setY: offset y.
|
||||||
^{x. y + h. glyph texcoord origin x. glyph texcoord origin y.
|
^{x. y + h. glyph texcoord origin x. glyph texcoord origin y.
|
||||||
x. y. glyph texcoord origin x. glyph texcoord corner y.
|
x. y. glyph texcoord origin x. glyph texcoord corner y.
|
||||||
x + w. y. glyph texcoord corner x. glyph texcoord corner y.
|
x + w. y. glyph texcoord corner x. glyph texcoord corner y.
|
||||||
@ -208,7 +143,7 @@ DiyaText >> initialize [
|
|||||||
super initialize.
|
super initialize.
|
||||||
self fontName: 'Ubuntu'.
|
self fontName: 'Ubuntu'.
|
||||||
self fontStyle: 'Regular'.
|
self fontStyle: 'Regular'.
|
||||||
self fontSize: 14.
|
self fontSize: 16.
|
||||||
data := nil.
|
data := nil.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
Class {
|
|
||||||
#name : #GLTexShader,
|
|
||||||
#superclass : #OpenGLSL,
|
|
||||||
#category : #'Diya-Shaders'
|
|
||||||
}
|
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
GLTexShader class >> fragmentShader [
|
|
||||||
^ '
|
|
||||||
#ifdef GL_ES
|
|
||||||
precision mediump float;
|
|
||||||
#endif
|
|
||||||
uniform sampler2D u_texture;
|
|
||||||
uniform vec2 u_resolution;
|
|
||||||
|
|
||||||
void main(){
|
|
||||||
//vec2 uv = gl_FragCoord.xy / u_resolution;
|
|
||||||
vec4 sampled = vec4(1.0, 1.0, 1.0, texture2D(u_texture,gl_FragCoord.zw).r);
|
|
||||||
gl_FragColor = vec4(1.0,1.0,1.0,1.0)* sampled; //texture2D(u_texture,uv.xy);
|
|
||||||
}
|
|
||||||
|
|
||||||
'
|
|
||||||
]
|
|
@ -14,6 +14,7 @@ Class {
|
|||||||
'GL_BLEND',
|
'GL_BLEND',
|
||||||
'GL_BLUE',
|
'GL_BLUE',
|
||||||
'GL_BYTE',
|
'GL_BYTE',
|
||||||
|
'GL_CLAMP_TO_BORDER',
|
||||||
'GL_CLAMP_TO_EDGE',
|
'GL_CLAMP_TO_EDGE',
|
||||||
'GL_COLOR_BUFFER_BIT',
|
'GL_COLOR_BUFFER_BIT',
|
||||||
'GL_COMPILE_STATUS',
|
'GL_COMPILE_STATUS',
|
||||||
@ -39,6 +40,7 @@ Class {
|
|||||||
'GL_LINE_STRIP',
|
'GL_LINE_STRIP',
|
||||||
'GL_LINK_STATUS',
|
'GL_LINK_STATUS',
|
||||||
'GL_MAX_TEXTURE_SIZE',
|
'GL_MAX_TEXTURE_SIZE',
|
||||||
|
'GL_NEAREST',
|
||||||
'GL_ONE_MINUS_SRC_ALPHA',
|
'GL_ONE_MINUS_SRC_ALPHA',
|
||||||
'GL_PACK_ALIGNMENT',
|
'GL_PACK_ALIGNMENT',
|
||||||
'GL_POINTS',
|
'GL_POINTS',
|
||||||
@ -168,9 +170,10 @@ OpenGLConstants class >> initTextureConstants [
|
|||||||
GL_TEXTURE_MIN_FILTER := 16r2801.
|
GL_TEXTURE_MIN_FILTER := 16r2801.
|
||||||
GL_TEXTURE_MAG_FILTER := 16r2800.
|
GL_TEXTURE_MAG_FILTER := 16r2800.
|
||||||
GL_LINEAR := 16r2601.
|
GL_LINEAR := 16r2601.
|
||||||
|
GL_NEAREST := 16r2600.
|
||||||
GL_TEXTURE_UNIT_BASE := 16r84C0.
|
GL_TEXTURE_UNIT_BASE := 16r84C0.
|
||||||
GL_MAX_TEXTURE_SIZE := 16r0D33
|
GL_MAX_TEXTURE_SIZE := 16r0D33.
|
||||||
|
GL_CLAMP_TO_BORDER := 16r812D
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'class initialization' }
|
{ #category : #'class initialization' }
|
||||||
|
@ -4,7 +4,8 @@ Class {
|
|||||||
#instVars : [
|
#instVars : [
|
||||||
'charmap',
|
'charmap',
|
||||||
'cellw',
|
'cellw',
|
||||||
'cellh'
|
'cellh',
|
||||||
|
'spacing'
|
||||||
],
|
],
|
||||||
#pools : [
|
#pools : [
|
||||||
'OpenGLConstants',
|
'OpenGLConstants',
|
||||||
@ -56,10 +57,10 @@ OpenGLFontTex >> createBitmapFontFrom: bitmaps metrics: metrics maxBearing: maxb
|
|||||||
0 to: 15 do: [ :row|
|
0 to: 15 do: [ :row|
|
||||||
0 to: 15 do: [ :col| |glyph|
|
0 to: 15 do: [ :col| |glyph|
|
||||||
offset := (col * cellw) @ (row*cellh).
|
offset := (col * cellw) @ (row*cellh).
|
||||||
glyph := (DiyaFontGlyph origin: offset extent: (((metrics at: currChar) first x) @ cellh)).
|
glyph := (DiyaFontGlyph origin: offset extent: (((metrics at: currChar) first x asInteger) @ cellh)).
|
||||||
glyph
|
glyph
|
||||||
bearing: ((metrics at: currChar) at: 2);
|
bearing: ((metrics at: currChar) at: 2) asFloatPoint;
|
||||||
advance: ((metrics at: currChar) at: 3);
|
advance: ((metrics at: currChar) at: 3) asFloatPoint;
|
||||||
texcoord: (Rectangle origin: (glyph origin/ (self extent) ) asFloatPoint corner: ((glyph corner) / (self extent)) asFloatPoint ).
|
texcoord: (Rectangle origin: (glyph origin/ (self extent) ) asFloatPoint corner: ((glyph corner) / (self extent)) asFloatPoint ).
|
||||||
charmap add:glyph.
|
charmap add:glyph.
|
||||||
self blitPixel8: (bitmaps at: currChar) at: (offset x) @ ((offset y) + maxbearing - ((metrics at: currChar) last) ) size: (metrics at: currChar) first.
|
self blitPixel8: (bitmaps at: currChar) at: (offset x) @ ((offset y) + maxbearing - ((metrics at: currChar) last) ) size: (metrics at: currChar) first.
|
||||||
@ -68,6 +69,14 @@ OpenGLFontTex >> createBitmapFontFrom: bitmaps metrics: metrics maxBearing: maxb
|
|||||||
].
|
].
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
OpenGLFontTex >> drop [
|
||||||
|
OpenGL
|
||||||
|
pixelstorei: GL_UNPACK_ALIGNMENT param: 4;
|
||||||
|
disable: GL_CULL_FACE;
|
||||||
|
disable: GL_BLEND.
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #'instance creation' }
|
{ #category : #'instance creation' }
|
||||||
OpenGLFontTex >> fromFace: face ofSize: size [
|
OpenGLFontTex >> fromFace: face ofSize: size [
|
||||||
|minhang maxbearing rec metrics bitmaps |
|
|minhang maxbearing rec metrics bitmaps |
|
||||||
@ -83,7 +92,12 @@ OpenGLFontTex >> fromFace: face ofSize: size [
|
|||||||
0 to: 255 do: [ :c |
|
0 to: 255 do: [ :c |
|
||||||
|bmp bmpsize|
|
|bmp bmpsize|
|
||||||
face loadCharacter: c flags: (1 << 2).
|
face loadCharacter: c flags: (1 << 2).
|
||||||
metrics add: { ((rec glyph metrics width) /64)@ ((rec glyph metrics height) /64). (face glyph hBearing). (face glyph advance). (rec glyph metrics horiBearingY) / 64}.
|
metrics add: {
|
||||||
|
(((rec glyph metrics width) /64)@ ((rec glyph metrics height) /64)).
|
||||||
|
(face glyph hBearing).
|
||||||
|
(face glyph advance).
|
||||||
|
((rec glyph metrics horiBearingY) / 64)
|
||||||
|
}.
|
||||||
maxbearing := maxbearing max: ((rec glyph metrics horiBearingY) / 64).
|
maxbearing := maxbearing max: ((rec glyph metrics horiBearingY) / 64).
|
||||||
cellw := cellw max: ((rec glyph metrics width) / 64).
|
cellw := cellw max: ((rec glyph metrics width) / 64).
|
||||||
minhang := minhang min: ((( rec glyph metrics horiBearingY) - (rec glyph metrics height )) / 64).
|
minhang := minhang min: ((( rec glyph metrics horiBearingY) - (rec glyph metrics height )) / 64).
|
||||||
@ -94,6 +108,7 @@ OpenGLFontTex >> fromFace: face ofSize: size [
|
|||||||
bitmaps add: bmp.
|
bitmaps add: bmp.
|
||||||
].
|
].
|
||||||
cellh := maxbearing - minhang.
|
cellh := maxbearing - minhang.
|
||||||
|
spacing := (cellw / 2) asInteger.
|
||||||
self createBitmapFontFrom: bitmaps metrics: metrics maxBearing: maxbearing.
|
self createBitmapFontFrom: bitmaps metrics: metrics maxBearing: maxbearing.
|
||||||
bitmaps do:[:p| p free].
|
bitmaps do:[:p| p free].
|
||||||
]
|
]
|
||||||
@ -122,6 +137,20 @@ OpenGLFontTex >> linespace [
|
|||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
OpenGLFontTex >> spacing [
|
OpenGLFontTex >> setup [
|
||||||
^ cellw / 2
|
OpenGL
|
||||||
|
enable: GL_CULL_FACE;
|
||||||
|
enable: GL_BLEND;
|
||||||
|
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;
|
||||||
|
parameteri: GL_TEXTURE_2D pname: GL_TEXTURE_WRAP_T param: GL_CLAMP_TO_EDGE;
|
||||||
|
parameteri: GL_TEXTURE_2D pname: GL_TEXTURE_MIN_FILTER param: GL_LINEAR;
|
||||||
|
parameteri: GL_TEXTURE_2D pname: GL_TEXTURE_MAG_FILTER param: GL_LINEAR.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
OpenGLFontTex >> spacing [
|
||||||
|
^ spacing
|
||||||
]
|
]
|
||||||
|
@ -109,18 +109,7 @@ OpenGLSL class >> useProgram:program [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
OpenGLSL class >> vertexShader [
|
OpenGLSL class >> vertexShader [
|
||||||
^ '
|
^self subclassResponsibility
|
||||||
#ifdef GL_ES
|
|
||||||
precision mediump float;
|
|
||||||
#endif
|
|
||||||
uniform mat4 u_projection;
|
|
||||||
uniform mat3 u_transform;
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec3 coord_global = u_transform * vec3(gl_Vertex.xy, 1.0);
|
|
||||||
gl_Position = u_projection * vec4(coord_global.xy, 0, 1.0);
|
|
||||||
}
|
|
||||||
'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #initialization }
|
{ #category : #initialization }
|
||||||
|
@ -52,6 +52,11 @@ OpenGLTexImage2D >> debug [
|
|||||||
stdlog: 'internalformat :',internalFormat hex
|
stdlog: 'internalformat :',internalFormat hex
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
OpenGLTexImage2D >> drop [
|
||||||
|
^self subclassResponsibility
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
OpenGLTexImage2D >> extent [
|
OpenGLTexImage2D >> extent [
|
||||||
^ width @ height
|
^ width @ height
|
||||||
@ -97,6 +102,11 @@ OpenGLTexImage2D >> level: anObject [
|
|||||||
level := anObject
|
level := anObject
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
OpenGLTexImage2D >> setup [
|
||||||
|
^self subclassResponsibility
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
OpenGLTexImage2D >> target [
|
OpenGLTexImage2D >> target [
|
||||||
^ target
|
^ target
|
||||||
@ -107,6 +117,11 @@ OpenGLTexImage2D >> target: anObject [
|
|||||||
target := anObject
|
target := anObject
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
OpenGLTexImage2D >> teardown [
|
||||||
|
^self subclassResponsibility
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
OpenGLTexImage2D >> type [
|
OpenGLTexImage2D >> type [
|
||||||
^ type
|
^ type
|
||||||
|
@ -87,6 +87,12 @@ OpenGLVertexBuffer >> subData:target offset: offset data:data [
|
|||||||
^OpenGLVertexBuffer subData: target offset: offset size: data size * 4 data: data getHandle
|
^OpenGLVertexBuffer subData: target offset: offset size: data size * 4 data: data getHandle
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'as yet unclassified' }
|
||||||
|
OpenGLVertexBuffer >> subData:target offset: offset data:data size: size [
|
||||||
|
self bind: target.
|
||||||
|
^OpenGLVertexBuffer subData: target offset: offset size: size data: data getHandle
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #initialization }
|
{ #category : #initialization }
|
||||||
OpenGLVertexBuffer >> vertexBufferID [
|
OpenGLVertexBuffer >> vertexBufferID [
|
||||||
^ vertexBufferID at: 1
|
^ vertexBufferID at: 1
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
Class {
|
|
||||||
#name : #TotoShader,
|
|
||||||
#superclass : #OpenGLSL,
|
|
||||||
#category : #'Diya-Shaders'
|
|
||||||
}
|
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
|
||||||
TotoShader class >> fragmentShader [
|
|
||||||
^'
|
|
||||||
#ifdef GL_ES
|
|
||||||
precision highp float;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
varying vec2 texcoord;
|
|
||||||
uniform sampler2D u_texture;
|
|
||||||
uniform vec2 u_resolution;
|
|
||||||
uniform vec2 u_mouse;
|
|
||||||
uniform float u_time;
|
|
||||||
void main(void) {
|
|
||||||
gl_FragColor = vec4(1, 1, 1, texture2D(u_texture, texcoord).a) * vec4(1,1,1,1);
|
|
||||||
}'
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
|
||||||
TotoShader class >> vertexShader [
|
|
||||||
^'
|
|
||||||
#ifdef GL_ES
|
|
||||||
precision mediump float;
|
|
||||||
#endif
|
|
||||||
uniform mat4 u_projection;
|
|
||||||
uniform mat3 u_transform;
|
|
||||||
varying vec2 texcoord;
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec3 coord_global = u_transform * vec3(gl_Vertex.xy, 1.0);
|
|
||||||
gl_Position = u_projection * vec4(coord_global.xy, 0, 1.0);
|
|
||||||
texcoord = gl_Vertex.zw;
|
|
||||||
}'
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #initialization }
|
|
||||||
TotoShader >> setUpUniforms [
|
|
||||||
self addUniform: #u_texture of: Uniform1i.
|
|
||||||
]
|
|
Loading…
Reference in New Issue
Block a user