1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2024-12-27 20:08:22 +01:00
Diya-API/Diya/DiyaRendererContext.class.st

141 lines
2.5 KiB
Smalltalk
Raw Normal View History

2022-02-15 18:04:54 +01:00
Class {
#name : #DiyaRendererContext,
#superclass : #DiyaSingleton,
#instVars : [
'mouse',
'display',
'vbo',
2022-03-03 19:19:40 +01:00
'vao',
'texture0',
'projection',
'assets',
'window',
'root'
2022-02-15 18:04:54 +01:00
],
#pools : [
'OpenGLConstants',
'OpenGLTypes'
],
#category : #'Diya-Graphics'
}
{ #category : #'instance creation' }
DiyaRendererContext class >> cleanUpInstance: singleton [
2022-03-15 19:11:19 +01:00
singleton ifNil:[^self].
singleton destroy
]
2022-03-06 12:07:20 +01:00
{ #category : #'instance creation' }
DiyaRendererContext class >> maxFloatBufferSize [
2022-03-06 18:33:10 +01:00
^4096
2022-03-06 12:07:20 +01:00
]
{ #category : #accessing }
DiyaRendererContext >> assets [
^ assets
]
{ #category : #accessing }
DiyaRendererContext >> assets: anObject [
assets := anObject
]
{ #category : #accessing }
DiyaRendererContext >> destroy [
2022-08-13 23:48:23 +02:00
vao disableAttribute: 0.
vao delete.
vbo delete.
2022-03-03 19:19:40 +01:00
texture0 delete.
]
2022-02-15 18:04:54 +01:00
{ #category : #accessing }
DiyaRendererContext >> display [
^ display
]
{ #category : #accessing }
DiyaRendererContext >> display: anObject [
display := anObject
]
{ #category : #accessing }
DiyaRendererContext >> initialize [
super initialize.
vbo := OpenGLVertexBuffer new.
vao := OpenGLVertexArray new.
2022-03-03 19:19:40 +01:00
texture0 := OpenGLTexture fromUnit: 0.
vao bind.
vbo bind: GL_ARRAY_BUFFER.
2022-03-03 19:19:40 +01:00
projection := Array2D identity: 4.
assets := AssetManager new.
2022-08-13 23:48:23 +02:00
vao enableAttribute: 0.
OpenGLVertexArray vertexAttributePointerIndex: 0 size:4 type: GL_FLOAT normalized: GL_FALSE stride: 16 pointer: nil.
]
2022-02-15 18:04:54 +01:00
{ #category : #accessing }
DiyaRendererContext >> mouse [
^ mouse
]
{ #category : #accessing }
DiyaRendererContext >> mouse: anObject [
mouse := anObject
]
2022-03-03 19:19:40 +01:00
{ #category : #accessing }
DiyaRendererContext >> projection [
^ projection
]
{ #category : #rendering }
DiyaRendererContext >> render [
root render.
root readyForSwap ifTrue: [
SDL2 glSwapWindow: window.
]
]
{ #category : #accessing }
2022-02-15 18:04:54 +01:00
DiyaRendererContext >> resolution [
^ (display w) @ (display h)
]
{ #category : #accessing }
DiyaRendererContext >> root [
root ifNil: [ root := DiyaRootNode new ].
^ root
]
2022-03-03 19:19:40 +01:00
{ #category : #accessing }
DiyaRendererContext >> texture0 [
^ texture0
]
{ #category : #'transformation matrices' }
2022-03-03 19:19:40 +01:00
DiyaRendererContext >> useProjection: aClass [
projection := aClass fromDisplay: self display
]
{ #category : #accessing }
DiyaRendererContext >> vao [
^ vao
]
{ #category : #accessing }
DiyaRendererContext >> vbo [
^ vbo
]
{ #category : #accessing }
DiyaRendererContext >> window [
^ window
]
{ #category : #accessing }
DiyaRendererContext >> window: anObject [
window := anObject
]