Handbook
Glossary
gl4compute-world
Vocabulary
opengl
.
demos
.
compute
Definition
USING:
game.worlds
math
;
IN:
opengl.demos.compute
TUPLE:
gl4compute-world
<
game-world
program compute-program texture vertices vao vbo
{
frame-count
fixnum
initial:
0
}
;
Methods
USING:
accessors
combinators
game.worlds
kernel
math
opengl
opengl.demos.compute
opengl.gl
opengl.shaders
opengl.textures
sequences
specialized-arrays.instances.alien.c-types.float
;
M:
gl4compute-world
begin-game-world
vertex-shader
fragment-shader
<simple-gl-program>
>>program
compute-shader
<compute-program>
>>compute-program
float-array{
-1.0
1.0
0.0
0.0
1.0
-1.0
-1.0
0.0
0.0
0.0
1.0
1.0
0.0
1.0
1.0
1.0
-1.0
0.0
1.0
0.0
}
>>vertices
create-vertex-array
>>vao
create-gl-buffer
>>vbo
dup
[
vbo>>
]
[
vertices>>
length
4
*
]
[
vertices>>
]
tri
GL_STATIC_DRAW
glNamedBufferData
dup
[
vao>>
0
]
[
vbo>>
]
bi
0 5 4
*
glVertexArrayVertexBuffer
dup
vao>>
{
[
0
glEnableVertexArrayAttrib
]
[
0 3
GL_FLOAT
GL_FALSE
0
glVertexArrayAttribFormat
]
[
0 0
glVertexArrayAttribBinding
]
[
1
glEnableVertexArrayAttrib
]
[
1 2
GL_FLOAT
GL_FALSE
3 4
*
glVertexArrayAttribFormat
]
[
1 0
glVertexArrayAttribBinding
]
}
cleave
GL_TEXTURE_2D
create-texture
>>texture
dup
texture>>
{
[
1
GL_RGBA32F
TEXTURE_WIDTH
TEXTURE_HEIGHT
glTextureStorage2D
]
[
GL_TEXTURE_WRAP_S
GL_CLAMP_TO_EDGE
glTextureParameteri
]
[
GL_TEXTURE_WRAP_T
GL_CLAMP_TO_EDGE
glTextureParameteri
]
[
GL_TEXTURE_MAG_FILTER
GL_LINEAR
glTextureParameteri
]
[
GL_TEXTURE_MIN_FILTER
GL_LINEAR
glTextureParameteri
]
}
cleave
dup
texture>>
0
swap
0
GL_FALSE
0
GL_READ_WRITE
GL_RGBA32F
glBindImageTexture
drop
;
USING:
accessors
kernel
math
opengl.demos.compute
opengl.gl
ui.gadgets.worlds
;
M:
gl4compute-world
draw-world*
dup
compute-program>>
glUseProgram
dup
[
compute-program>>
]
[
compute-program>>
"t"
glGetUniformLocation
]
[
frame-count>>
]
tri
glProgramUniform1f
TEXTURE_WIDTH
10
/
TEXTURE_HEIGHT
10
/
1
glDispatchCompute
GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
glMemoryBarrier
GL_COLOR_BUFFER_BIT
GL_DEPTH_BUFFER_BIT
bitor
glClear
dup
program>>
glUseProgram
dup
[
program>>
]
[
program>>
"tex"
glGetUniformLocation
]
bi
0
glProgramUniform1i
dup
texture>>
0
swap
glBindTextureUnit
dup
vao>>
glBindVertexArray
GL_TRIANGLE_STRIP
0 4
glDrawArrays
0
glBindVertexArray
drop
;
USING:
accessors
game.worlds
kernel
opengl
opengl.demos.compute
opengl.shaders
opengl.textures
;
M:
gl4compute-world
end-game-world
dup
compute-program>>
delete-gl-program
dup
program>>
delete-gl-program
dup
texture>>
delete-texture
dup
vbo>>
delete-gl-buffer
dup
vao>>
delete-vertex-array
drop
;
USING:
accessors
game.worlds
kernel
math
opengl.demos.compute
;
M:
gl4compute-world
tick-game-world
dup
handle-input
dup
frame-count>>
dup
500
>
[
drop
0
]
[
1
+
]
if
>>frame-count
drop
;