2022-02-15 18:04:54 +01:00
|
|
|
Class {
|
|
|
|
#name : #DiyaRendererContext,
|
|
|
|
#superclass : #DiyaSingleton,
|
|
|
|
#instVars : [
|
|
|
|
'mouse',
|
2022-03-02 20:11:01 +01:00
|
|
|
'display',
|
|
|
|
'vbo',
|
2022-03-03 19:19:40 +01:00
|
|
|
'vao',
|
|
|
|
'texture0',
|
|
|
|
'projection',
|
|
|
|
'buffer'
|
2022-02-15 18:04:54 +01:00
|
|
|
],
|
|
|
|
#pools : [
|
|
|
|
'OpenGLConstants',
|
|
|
|
'OpenGLTypes'
|
|
|
|
],
|
|
|
|
#category : #'Diya-Graphics'
|
|
|
|
}
|
|
|
|
|
2022-03-02 20:11:01 +01:00
|
|
|
{ #category : #'instance creation' }
|
|
|
|
DiyaRendererContext class >> cleanUpInstance: singleton [
|
|
|
|
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
|
|
|
]
|
|
|
|
|
2022-03-03 19:19:40 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaRendererContext >> buffer [
|
|
|
|
^ buffer
|
|
|
|
]
|
|
|
|
|
2022-03-02 20:11:01 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaRendererContext >> destroy [
|
|
|
|
vao delete.
|
|
|
|
vbo delete.
|
2022-03-03 19:19:40 +01:00
|
|
|
texture0 delete.
|
2022-03-02 20:11:01 +01:00
|
|
|
]
|
|
|
|
|
2022-02-15 18:04:54 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaRendererContext >> display [
|
|
|
|
^ display
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaRendererContext >> display: anObject [
|
|
|
|
display := anObject
|
|
|
|
]
|
|
|
|
|
2022-03-02 20:11:01 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaRendererContext >> initialize [
|
|
|
|
super initialize.
|
|
|
|
vbo := OpenGLVertexBuffer new.
|
|
|
|
vao := OpenGLVertexArray new.
|
2022-03-03 19:19:40 +01:00
|
|
|
texture0 := OpenGLTexture fromUnit: 0.
|
2022-03-02 20:11:01 +01:00
|
|
|
vao bind.
|
|
|
|
vbo bind: GL_ARRAY_BUFFER.
|
2022-03-03 19:19:40 +01:00
|
|
|
projection := Array2D identity: 4.
|
2022-03-06 12:07:20 +01:00
|
|
|
buffer := FFIExternalArray externalNewType: GLfloat size: self class maxFloatBufferSize .
|
2022-03-03 19:19:40 +01:00
|
|
|
buffer autoRelease.
|
2022-03-06 12:07:20 +01:00
|
|
|
vbo data: GL_ARRAY_BUFFER data: nil size:self class maxFloatBufferSize*4 usage: GL_DYNAMIC_DRAW.
|
2022-03-03 19:19:40 +01:00
|
|
|
|
2022-03-02 20:11:01 +01:00
|
|
|
]
|
|
|
|
|
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
|
|
|
|
]
|
|
|
|
|
2022-02-15 18:04:54 +01:00
|
|
|
{ #category : #'as yet unclassified' }
|
|
|
|
DiyaRendererContext >> resolution [
|
|
|
|
^ (display w) @ (display h)
|
|
|
|
]
|
2022-03-02 20:11:01 +01:00
|
|
|
|
2022-03-03 19:19:40 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaRendererContext >> texture0 [
|
|
|
|
^ texture0
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
|
|
DiyaRendererContext >> useProjection: aClass [
|
|
|
|
projection := aClass fromDisplay: self display
|
|
|
|
]
|
|
|
|
|
2022-03-02 20:11:01 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaRendererContext >> vao [
|
|
|
|
^ vao
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaRendererContext >> vbo [
|
|
|
|
^ vbo
|
|
|
|
]
|