mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-27 11:58:21 +01:00
code refactory on rendering context
This commit is contained in:
parent
c1f2de2896
commit
c7af75550f
@ -32,14 +32,11 @@ Diya2DPrimShape >> draw [
|
|||||||
context texture0 setImage2D: self texture.
|
context texture0 setImage2D: self texture.
|
||||||
context texture0 active.
|
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_DYNAMIC_DRAW.
|
context vbo data: GL_ARRAY_BUFFER data: vbuffer usage: GL_DYNAMIC_DRAW.
|
||||||
OpenGL drawArrays: type first:0 count:((vbuffer size )>> 2 ).
|
OpenGL drawArrays: type first:0 count:((vbuffer size )>> 2 ).
|
||||||
"reset value"
|
"reset value"
|
||||||
self texture ifNotNil: [self texture drop.].
|
self texture ifNotNil: [self texture drop.].
|
||||||
self borderWidth > 0 ifTrue: [ self drawBorder ].
|
self borderWidth > 0 ifTrue: [ self drawBorder ].
|
||||||
context vao disableAttribute: 0.
|
|
||||||
OpenGL
|
OpenGL
|
||||||
disable: GL_CULL_FACE;
|
disable: GL_CULL_FACE;
|
||||||
disable: GL_BLEND.
|
disable: GL_BLEND.
|
||||||
|
@ -41,6 +41,7 @@ DiyaRendererContext >> assets: anObject [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
DiyaRendererContext >> destroy [
|
DiyaRendererContext >> destroy [
|
||||||
|
vao disableAttribute: 0.
|
||||||
vao delete.
|
vao delete.
|
||||||
vbo delete.
|
vbo delete.
|
||||||
texture0 delete.
|
texture0 delete.
|
||||||
@ -66,6 +67,8 @@ DiyaRendererContext >> initialize [
|
|||||||
vbo bind: GL_ARRAY_BUFFER.
|
vbo bind: GL_ARRAY_BUFFER.
|
||||||
projection := Array2D identity: 4.
|
projection := Array2D identity: 4.
|
||||||
assets := AssetManager new.
|
assets := AssetManager new.
|
||||||
|
vao enableAttribute: 0.
|
||||||
|
OpenGLVertexArray vertexAttributePointerIndex: 0 size:4 type: GL_FLOAT normalized: GL_FALSE stride: 16 pointer: nil.
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
@ -28,7 +28,7 @@ DiyaRootNode >> draw [
|
|||||||
c := self ? #bgColor.
|
c := self ? #bgColor.
|
||||||
OpenGL clearColorR: c red G: c green B: c blue A: c alpha.
|
OpenGL clearColorR: c red G: c green B: c blue A: c alpha.
|
||||||
OpenGL clear: GL_COLOR_BUFFER_BIT.
|
OpenGL clear: GL_COLOR_BUFFER_BIT.
|
||||||
context vbo bind: GL_ARRAY_BUFFER.
|
"context vbo bind: GL_ARRAY_BUFFER."
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'add/remove' }
|
{ #category : #'add/remove' }
|
||||||
|
@ -51,24 +51,24 @@ OpenGLVertexBuffer class >> subData:target offset: offset size: size data: data
|
|||||||
^self ffiCall: #(void glBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const void * data))
|
^self ffiCall: #(void glBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const void * data))
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #initialization }
|
||||||
OpenGLVertexBuffer >> bind: target [
|
OpenGLVertexBuffer >> bind: target [
|
||||||
^OpenGLVertexBuffer bind:target buffer: self vertexBufferID
|
^OpenGLVertexBuffer bind:target buffer: self vertexBufferID
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #'accessing - data' }
|
||||||
OpenGLVertexBuffer >> data:target data: data size: size usage: usage [
|
OpenGLVertexBuffer >> data:target data: data size: size usage: usage [
|
||||||
self bind: target.
|
"self bind: target."
|
||||||
^OpenGLVertexBuffer bufferData: target size: size data:(data ifNil:[data] ifNotNil: [data getHandle]) usage: usage
|
^OpenGLVertexBuffer bufferData: target size: size data:(data ifNil:[data] ifNotNil: [data getHandle]) usage: usage
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #'accessing - data' }
|
||||||
OpenGLVertexBuffer >> data:target data: data usage: usage [
|
OpenGLVertexBuffer >> data:target data: data usage: usage [
|
||||||
self bind: target.
|
"self bind: target."
|
||||||
^OpenGLVertexBuffer bufferData: target size: (data size) << 2 data:data getHandle usage: usage
|
^OpenGLVertexBuffer bufferData: target size: (data size) << 2 data:data getHandle usage: usage
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #'add/remove' }
|
||||||
OpenGLVertexBuffer >> delete [
|
OpenGLVertexBuffer >> delete [
|
||||||
OpenGLVertexBuffer deleteBuffersSize: 1 buffers: vertexBufferID getHandle.
|
OpenGLVertexBuffer deleteBuffersSize: 1 buffers: vertexBufferID getHandle.
|
||||||
]
|
]
|
||||||
@ -81,15 +81,15 @@ OpenGLVertexBuffer >> initialize [
|
|||||||
OpenGLVertexBuffer genVertexBuffersSize: 1 buffers: vertexBufferID getHandle
|
OpenGLVertexBuffer genVertexBuffersSize: 1 buffers: vertexBufferID getHandle
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #'accessing - data' }
|
||||||
OpenGLVertexBuffer >> subData:target offset: offset data:data [
|
OpenGLVertexBuffer >> subData:target offset: offset data:data [
|
||||||
self bind: target.
|
"self bind: target."
|
||||||
^OpenGLVertexBuffer subData: target offset: offset size: (data size) << 2 data: data getHandle
|
^OpenGLVertexBuffer subData: target offset: offset size: (data size) << 2 data: data getHandle
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #'accessing - data' }
|
||||||
OpenGLVertexBuffer >> subData:target offset: offset data:data size: size [
|
OpenGLVertexBuffer >> subData:target offset: offset data:data size: size [
|
||||||
self bind: target.
|
"self bind: target."
|
||||||
^OpenGLVertexBuffer subData: target offset: offset size: size data: data getHandle
|
^OpenGLVertexBuffer subData: target offset: offset size: size data: data getHandle
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user