| initialize |
| delete
|
"Very important - a TTexture is not allowed to delete a TForm. This is because a TForm may be shared among multiple TTextures."
tform invalidate: Croquet world ogl.
|
| destroy
|
"destroy me"
super destroy.
self delete.
|
| flipVertically
|
"Flip the texture vertically"
tform form flipVertically.
tform updateAll.
|
| initializeOpaque: aBool extent: targetExtent
|
| mat |
self
initializeWithForm: (Form extent: targetExtent depth: 32)
mipmap: false "aCroquetWorld ogl autoMipmap"
shrinkFit: false. "the form needs to grow"
uvScale _ (tform extent/tform trueExtent) asFloatPoint.
mat _ TMaterial new.
aBool ifTrue:[
mat ambientColor: #(1.0 1.0 1.0 1) asFloatArray.
mat diffuseColor: #(1.0 1.0 1.0 1) asFloatArray.
] ifFalse:[
mat ambientColor: #(1.0 1.0 1.0 0.9) asFloatArray.
mat diffuseColor: #(1.0 1.0 1.0 0.9) asFloatArray.
].
mat emissiveColor: #(1.0 1.0 1.0 1.0) asFloatArray.
super material: mat.
^self.
|
| initializeWithFileName: fName
|
^self initializeWithFileName: fName mipmap: true shrinkFit: false.
|
| initializeWithFileName: fName mipmap: bMM
|
^self initializeWithFileName: fName mipmap: bMM shrinkFit: false.
|
| initializeWithFileName: fName mipmap: bMM shrinkFit: bSF
|
^self initializeWithFileName: fName mipmap: bMM shrinkFit: false extension: nil.
|
| initializeWithFileName: fName mipmap: bMM shrinkFit: bSF extension: ext
|
tform _ TForm fromFileNamed: fName mipmap: bMM shrinkFit: bSF extension: ext.
self setup.
|
| initializeWithForm: baseForm mipmap: bMM shrinkFit: bSF
|
self initializeWithForm: baseForm mipmap: bMM shrinkFit: bSF extension: nil.
|
| initializeWithForm: baseForm mipmap: bMM shrinkFit: bSF extension: ext
|
tform _ TForm fromForm: baseForm mipmap: bMM shrinkFit: bSF extension: ext.
self setup.
|
| setup
|
baseScale _ 0.01.
extent _ tform extent * baseScale.
self aspectFixed: true.
self aspect: (extent y/extent x) asFloat.
self texture: self.
uvScale _ 1.0@1.0.
uvOffset _ 0.0@0.0.
uvAngle _ 0.0.
extent _ extent * baseScale. "save the original value if we have to render this object."
self objectName: tform fileName.
tform addParent: self.
mode _ GLModulate.
|
| render |
| disable: ogl
|
ogl changeTexture ifFalse:[^false].
ogl glDisable: GLTexture2d.
|
| enable: ogl
|
(tform notNil and: [tform bind: ogl]) ifTrue:[.
ogl glEnable: GLTexture2d.
timeStamp ~= ogl timeStamp ifTrue:[self update.].
ogl glTexParameteri: GLTexture2d with: GLTextureWrapS with:GLRepeat;
glTexParameteri: GLTexture2d with: GLTextureWrapT with:GLRepeat.].
timeStamp _ ogl timeStamp.
|
| renderFrame: ogl parent: parent root: root
|
self update.
^ super renderFrame: ogl parent: parent root: root.
|
| renderFrame: ogl space: space
|
self update.
^ super renderFrame: ogl space: space.
|
| renderPrimitive: ogl
|
self enable: ogl.
ogl glTexEnvi: GLTextureEnv with: GLTextureEnvMode with: mode.
super renderPrimitive: ogl.
self disable:ogl.
|
| update
|
"This is used when you are about to use or render this texture. This is called whenever we are send #enable: to the texture, and it is only called once per render."
|
| upload
|
tform updateAll.
|
| uploadDirtyRect: aRectangle
|
tform upload: Croquet world ogl dirtyRect: aRectangle
|