1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
:mod:`psychopy.tools.gltools`
----------------------------------------
.. automodule:: psychopy.tools.gltools
.. currentmodule:: psychopy.tools.gltools
Overview
~~~~~~~~
.. autosummary::
createProgram
createProgramObjectARB
compileShader
compileShaderObjectARB
embedShaderSourceDefs
deleteObject
deleteObjectARB
attachShader
attachObjectARB
detachShader
detachObjectARB
linkProgram
linkProgramObjectARB
validateProgram
validateProgramARB
useProgram
useProgramObjectARB
getInfoLog
getUniformLocations
getAttribLocations
createQueryObject
beginQuery
endQuery
getQuery
getAbsTimeGPU
createFBO
attach
isComplete
deleteFBO
blitFBO
useFBO
createRenderbuffer
deleteRenderbuffer
createTexImage2D
createTexImage2DMultisample
deleteTexture
VertexArrayInfo
createVAO
drawVAO
deleteVAO
VertexBufferInfo
createVBO
bindVBO
unbindVBO
mapBuffer
unmapBuffer
deleteVBO
setVertexAttribPointer
enableVertexAttribArray
disableVertexAttribArray
createMaterial
useMaterial
createLight
useLights
setAmbientLight
ObjMeshInfo
loadObjFile
loadMtlFile
createUVSphere
createPlane
createMeshGridFromArrays
createMeshGrid
createBox
transformMeshPosOri
calculateVertexNormals
getIntegerv
getFloatv
getString
getOpenGLInfo
Details
~~~~~~~
.. autofunction:: createProgram
.. autofunction:: createProgramObjectARB
.. autofunction:: compileShader
.. autofunction:: compileShaderObjectARB
.. autofunction:: embedShaderSourceDefs
.. autofunction:: deleteObject
.. autofunction:: deleteObjectARB
.. autofunction:: attachShader
.. autofunction:: attachObjectARB
.. autofunction:: detachShader
.. autofunction:: detachObjectARB
.. autofunction:: linkProgram
.. autofunction:: linkProgramObjectARB
.. autofunction:: validateProgram
.. autofunction:: validateProgramARB
.. autofunction:: useProgram
.. autofunction:: useProgramObjectARB
.. autofunction:: getInfoLog
.. autofunction:: getUniformLocations
.. autofunction:: getAttribLocations
.. autofunction:: createQueryObject
.. autofunction:: beginQuery
.. autofunction:: endQuery
.. autofunction:: getQuery
.. autofunction:: getAbsTimeGPU
.. autofunction:: createFBO
.. autofunction:: attach
.. autofunction:: isComplete
.. autofunction:: deleteFBO
.. autofunction:: blitFBO
.. autofunction:: useFBO
.. autofunction:: createRenderbuffer
.. autofunction:: deleteRenderbuffer
.. autofunction:: createTexImage2D
.. autofunction:: createTexImage2DMultisample
.. autofunction:: deleteTexture
.. autofunction:: createVAO
.. autofunction:: drawVAO
.. autofunction:: deleteVAO
.. autofunction:: createVBO
.. autofunction:: bindVBO
.. autofunction:: unbindVBO
.. autofunction:: mapBuffer
.. autofunction:: unmapBuffer
.. autofunction:: deleteVBO
.. autofunction:: setVertexAttribPointer
.. autofunction:: enableVertexAttribArray
.. autofunction:: disableVertexAttribArray
.. autofunction:: createMaterial
.. autofunction:: useMaterial
.. autofunction:: createLight
.. autofunction:: useLights
.. autofunction:: setAmbientLight
.. autofunction:: loadObjFile
.. autofunction:: loadMtlFile
.. autofunction:: createUVSphere
.. autofunction:: createPlane
.. autofunction:: createMeshGridFromArrays
.. autofunction:: createMeshGrid
.. autofunction:: createBox
.. autofunction:: transformMeshPosOri
.. autofunction:: calculateVertexNormals
.. autofunction:: getIntegerv
.. autofunction:: getFloatv
.. autofunction:: getString
.. autofunction:: getOpenGLInfo
Examples
~~~~~~~~
**Working with Framebuffer Objects (FBOs):**
Creating an empty framebuffer with no attachments::
fbo = createFBO() # invalid until attachments are added
Create a render target with multiple color texture attachments::
colorTex = createTexImage2D(1024,1024) # empty texture
depthRb = createRenderbuffer(800,600,internalFormat=GL.GL_DEPTH24_STENCIL8)
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, fbo.id)
attach(GL.GL_COLOR_ATTACHMENT0, colorTex)
attach(GL.GL_DEPTH_ATTACHMENT, depthRb)
attach(GL.GL_STENCIL_ATTACHMENT, depthRb)
# or attach(GL.GL_DEPTH_STENCIL_ATTACHMENT, depthRb)
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0)
Attach FBO images using a context. This automatically returns to the previous
FBO binding state when complete. This is useful if you don't know the current
binding state::
with useFBO(fbo):
attach(GL.GL_COLOR_ATTACHMENT0, colorTex)
attach(GL.GL_DEPTH_ATTACHMENT, depthRb)
attach(GL.GL_STENCIL_ATTACHMENT, depthRb)
How to set userData some custom function might access::
fbo.userData['flags'] = ['left_eye', 'clear_before_use']
Binding an FBO for drawing/reading::
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, fb.id)
Depth-only framebuffers are valid, sometimes need for generating shadows::
depthTex = createTexImage2D(800, 600,
internalFormat=GL.GL_DEPTH_COMPONENT24,
pixelFormat=GL.GL_DEPTH_COMPONENT)
fbo = createFBO([(GL.GL_DEPTH_ATTACHMENT, depthTex)])
Deleting a framebuffer when done with it. This invalidates the framebuffer's ID
and makes it available for use::
deleteFBO(fbo)
|