1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2024-12-26 19:38:22 +01:00
Diya-API/Diya/OpenGLVertexBuffer.class.st

100 lines
3.2 KiB
Smalltalk
Raw Permalink Normal View History

2022-02-13 17:15:23 +01:00
Class {
#name : #OpenGLVertexBuffer,
#superclass : #DiyaBaseObject,
#instVars : [
'vertexBufferID'
],
#pools : [
'OpenGLConstants',
'OpenGLTypes'
],
#category : #'Diya-OpenGL'
}
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> bind: target buffer: buffer [
^ self ffiCall: #(void glBindBuffer( GLenum target,GLuint buffer))
]
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> bufferData:target size: size data: data usage: usage [
^self ffiCall: #(void glBufferData( GLenum target,GLsizeiptr size,const void * data,GLenum usage))
]
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> deleteBuffersSize:n buffers: buffers [
^self ffiCall: #(void glDeleteBuffers( GLsizei n,const GLuint * buffers))
]
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> ffiLibraryName [
^ OpenGL ffiLibraryName
]
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> genVertexBuffersSize:n buffers: buffers [
^self ffiCall: #(void glGenBuffers( GLsizei n,GLuint * buffers))
]
2022-02-14 00:02:14 +01:00
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> getBufferData: target offset: offset size: size data: data [
^self ffiCall: #(void glGetBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,void * data))
]
2022-02-13 17:15:23 +01:00
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> namedBufferData:buffer size: size data: data usage: usage [
^self ffiCall: #(void glNamedBufferData(GLuint buffer,GLsizeiptr size,const void *data,GLenum usage))
]
2022-03-03 19:19:40 +01:00
{ #category : #'as yet unclassified' }
OpenGLVertexBuffer class >> subData:target offset: offset size: size data: data [
^self ffiCall: #(void glBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const void * data))
]
2022-08-13 23:48:23 +02:00
{ #category : #initialization }
2022-02-13 17:15:23 +01:00
OpenGLVertexBuffer >> bind: target [
^OpenGLVertexBuffer bind:target buffer: self vertexBufferID
]
2022-08-13 23:48:23 +02:00
{ #category : #'accessing - data' }
2022-03-03 19:19:40 +01:00
OpenGLVertexBuffer >> data:target data: data size: size usage: usage [
2022-08-13 23:48:23 +02:00
"self bind: target."
2022-03-03 19:19:40 +01:00
^OpenGLVertexBuffer bufferData: target size: size data:(data ifNil:[data] ifNotNil: [data getHandle]) usage: usage
]
2022-08-13 23:48:23 +02:00
{ #category : #'accessing - data' }
2022-02-13 17:15:23 +01:00
OpenGLVertexBuffer >> data:target data: data usage: usage [
2022-08-13 23:48:23 +02:00
"self bind: target."
2022-03-16 01:32:01 +01:00
^OpenGLVertexBuffer bufferData: target size: (data size) << 2 data:data getHandle usage: usage
2022-02-13 17:15:23 +01:00
]
2022-08-13 23:48:23 +02:00
{ #category : #'add/remove' }
2022-02-13 17:15:23 +01:00
OpenGLVertexBuffer >> delete [
2022-02-14 00:02:14 +01:00
OpenGLVertexBuffer deleteBuffersSize: 1 buffers: vertexBufferID getHandle.
2022-02-13 17:15:23 +01:00
]
{ #category : #initialization }
OpenGLVertexBuffer >> initialize [
vertexBufferID := FFIExternalArray externalNewType: GLint size:1.
vertexBufferID at:1 put: -1.
2022-03-03 19:19:40 +01:00
vertexBufferID autoRelease.
2022-02-14 00:02:14 +01:00
OpenGLVertexBuffer genVertexBuffersSize: 1 buffers: vertexBufferID getHandle
2022-02-13 17:15:23 +01:00
]
2022-08-13 23:48:23 +02:00
{ #category : #'accessing - data' }
2022-03-03 19:19:40 +01:00
OpenGLVertexBuffer >> subData:target offset: offset data:data [
2022-08-13 23:48:23 +02:00
"self bind: target."
2022-03-16 01:32:01 +01:00
^OpenGLVertexBuffer subData: target offset: offset size: (data size) << 2 data: data getHandle
2022-03-03 19:19:40 +01:00
]
2022-08-13 23:48:23 +02:00
{ #category : #'accessing - data' }
2022-03-06 18:33:10 +01:00
OpenGLVertexBuffer >> subData:target offset: offset data:data size: size [
2022-08-13 23:48:23 +02:00
"self bind: target."
2022-03-06 18:33:10 +01:00
^OpenGLVertexBuffer subData: target offset: offset size: size data: data getHandle
]
2022-02-13 17:15:23 +01:00
{ #category : #initialization }
OpenGLVertexBuffer >> vertexBufferID [
^ vertexBufferID at: 1
]