2022-03-06 18:33:10 +01:00
|
|
|
Class {
|
|
|
|
#name : #Diya2DPrimShape,
|
|
|
|
#superclass : #Diya2DNode,
|
|
|
|
#instVars : [
|
|
|
|
'texture'
|
|
|
|
],
|
|
|
|
#category : #'Diya-Graphics'
|
|
|
|
}
|
|
|
|
|
2022-03-06 19:50:19 +01:00
|
|
|
{ #category : #initialization }
|
|
|
|
Diya2DPrimShape >> draw [
|
|
|
|
vbuffer ifNil: [ ^self ].
|
|
|
|
"configure vao vbo for texture QUAD"
|
|
|
|
self texture ifNotNil: [
|
|
|
|
self texture setup.
|
2022-03-08 23:30:01 +01:00
|
|
|
context texture0 setImage2D: self texture.
|
2022-03-06 19:50:19 +01:00
|
|
|
context texture0 active.
|
|
|
|
].
|
|
|
|
context vao enableAttribute: 0.
|
|
|
|
OpenGLVertexArray vertexAttributePointerIndex: 0 size:4 type: GL_FLOAT normalized: GL_FALSE stride: 16 pointer: nil .
|
|
|
|
context vbo data: GL_ARRAY_BUFFER data: vbuffer usage: GL_STATIC_DRAW.
|
|
|
|
OpenGL drawArrays: GL_TRIANGLES first:0 count:nvertices.
|
|
|
|
context vao disableAttribute: 0.
|
|
|
|
"reset value"
|
|
|
|
self texture ifNotNil: [self texture drop.].
|
|
|
|
]
|
|
|
|
|
2022-03-06 18:33:10 +01:00
|
|
|
{ #category : #initialization }
|
|
|
|
Diya2DPrimShape >> initialize [
|
|
|
|
super initialize.
|
|
|
|
texture := nil.
|
2022-03-06 19:50:19 +01:00
|
|
|
children := nil
|
2022-03-06 18:33:10 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
Diya2DPrimShape >> setUpShader [
|
2022-03-08 23:30:01 +01:00
|
|
|
super setUpShader
|
|
|
|
texture ifNotNil:[
|
2022-03-06 18:33:10 +01:00
|
|
|
self shader
|
2022-03-08 23:30:01 +01:00
|
|
|
setUniform: #u_texture_type value: texture format.
|
2022-03-06 18:33:10 +01:00
|
|
|
].
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DPrimShape >> texture [
|
|
|
|
^ texture
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DPrimShape >> texture: anObject [
|
|
|
|
texture := anObject
|
|
|
|
]
|