Handbook
Glossary
draw-world* ( world -- )
Factor handbook
»
UI framework
»
Implementing new gadgets
»
Customizing gadget appearance
»
Implementing custom drawing logic
»
Subclassing worlds
Prev:
resize-world ( world -- )
Vocabulary
ui
.
gadgets
.
worlds
Inputs
world
a
world
Outputs
None
Word description
Called when
world
needs to be redrawn. The world's OpenGL context is current when this method is called.
Definition
IN:
ui.gadgets.worlds
GENERIC:
draw-world*
( world -- )
Methods
USING:
accessors
bunny
bunny.model
kernel
opengl.demo-support
opengl.gl
sequences
ui.gadgets.worlds
;
M:
bunny-world
draw-world*
dup
draw-seq>>
empty?
[
drop
]
[
0.15 0.15 0.15 1.0
glClearColor
16640
glClear
dup
demo-world-set-matrix
GL_MODELVIEW
glMatrixMode
0.02 -0.105 0.0
glTranslatef
[
geom>>
]
[
get-draw
]
bi
draw-bunny
]
if
;
USING:
accessors
gpu.demos.bunny
kernel
ui.gadgets.worlds
;
M:
bunny-world
draw-world*
dup
bunny>>
dup
bunny-loaded?
[
dup
bunny-state-filled?
[
drop
]
[
fill-bunny-state
]
if
draw-sobeled-bunny
]
[
drop
draw-loading
]
if
;
USING:
accessors
alien
alien.c-types
alien.data
chipmunk.demo
chipmunk.ffi
classes.struct
kernel
opengl.gl
sequences
ui.gadgets.worlds
;
M::
chipmunk-world
draw-world*
( world -- )
1 1 1 0
glClearColor
GL_COLOR_BUFFER_BIT
glClear
GL_PROJECTION
glMatrixMode
glLoadIdentity
-320 320 -240 240 -1 1
glOrtho
0.5 0.5 0
glTranslatef
GL_VERTEX_ARRAY
glEnableClientState
world
space>>
:>
space 3
glPointSize
0 0 0
glColor3f
GL_POINTS
glBegin
space
bodies>>
[
num>>
]
[
arr>>
swap
void*
<c-direct-array>
]
bi
[
cpBody
memory>struct
p>>
[
x>>
]
[
y>>
]
bi
glVertex2f
]
each
glEnd
2
glPointSize
1 0 0
glColor3f
GL_POINTS
glBegin
space
arbiters>>
[
num>>
]
[
arr>>
swap
void*
<c-direct-array>
]
bi
[
cpArbiter
memory>struct
[
numContacts>>
]
[
contacts>>
>c-ptr
swap
cpContact
<c-direct-array>
]
bi
[
p>>
[
x>>
]
[
y>>
]
bi
glVertex2f
]
each
]
each
glEnd
;
USING:
accessors
destructors
fluids
gpu.effects.blur
gpu.effects.step
gpu.state
gpu.util
kernel
make
math.vectors
sequences
specialized-arrays.instances.alien.c-types.float
ui.gadgets.worlds
;
M::
fluids-world
draw-world*
( world -- )
world
particles>>
[
[
p>>
[
first
,
]
[
second
,
]
bi
]
each
]
curry
float-array{
}
make
:>
verts
[
verts world
texture>>
30.0 world
dim>>
{
4 4
}
v/
blended-point-sprite-batch
&dispose
blend-state
new
set-gpu-state
gaussian-blur
&dispose
world
ramp>>
world
dim>>
step-texture
&dispose
world
dim>>
draw-texture
]
with-destructors
;
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
colors
kernel
opengl
opengl.demos.gl4
opengl.gl
opengl.shaders
ui.gadgets.worlds
;
M:
gl4demo-world
draw-world*
COLOR:
aqua
gl-clear
dup
testing-program>>
[
over
vao>>
glBindVertexArray
GL_TRIANGLES
0 3
glDrawArrays
drop
]
with-gl-program
drop
;
USING:
accessors
gml.viewer
gpu.framebuffers
gpu.render
gpu.state
gpu.util.wasd
kernel
ui.gadgets.worlds
;
M:
gml-viewer-world
draw-world*
system-framebuffer
{
{
default-attachment
{
0.0 0.0 0.0 1.0
}
}
{
depth-attachment
1.0
}
}
clear-framebuffer
[
dup
view-faces?>>
[
T{
depth-state
{
comparison
cmp-less
}
}
set-gpu-state
{
{
"primitive-mode"
[
drop
triangles-mode
]
}
{
"indexes"
[
face-indices>>
]
}
{
"uniforms"
[
<mvp-uniforms>
]
}
{
"vertex-array"
[
vertex-array>>
]
}
}
<render-set>
render
T{
depth-state
}
set-gpu-state
]
[
drop
]
if
]
[
dup
view-edges?>>
[
{
{
"primitive-mode"
[
drop
lines-mode
]
}
{
"indexes"
[
edge-indices>>
]
}
{
"uniforms"
[
<mvp-uniforms>
]
}
{
"vertex-array"
[
vertex-array>>
]
}
}
<render-set>
render
]
[
drop
]
if
]
[
{
{
"primitive-mode"
[
drop
points-mode
]
}
{
"indexes"
[
point-indices>>
]
}
{
"uniforms"
[
<mvp-uniforms>
]
}
{
"vertex-array"
[
vertex-array>>
]
}
}
<render-set>
render
]
tri
;
USING:
model-viewer
ui.gadgets.worlds
;
M:
model-world
draw-world*
draw-model
;
USING:
kernel
ui.gadgets.worlds
ui.gadgets.worlds.null
;
M:
null-world
draw-world*
drop
;
USING:
accessors
kernel
papier
papier.render
ui.gadgets.worlds
;
M:
papier-world
draw-world*
[
renderer>>
]
[
uniforms>>
]
[
slabs>>
]
tri
draw-slabs
;
USING:
accessors
gpu.demos.raytrace
gpu.render
kernel
ui.gadgets.worlds
;
M:
raytrace-world
draw-world*
{
{
"primitive-mode"
[
drop
triangle-strip-mode
]
}
{
"indexes"
[
drop
T{
index-range
{
count 4
}
}
]
}
{
"uniforms"
[
<sphere-uniforms>
]
}
{
"vertex-array"
[
vertex-array>>
]
}
}
<render-set>
render
;
USING:
accessors
combinators
kernel
opengl
opengl.demo-support
opengl.gl
opengl.shaders
spheres
ui.gadgets.worlds
;
M:
spheres-world
draw-world*
{
[
(draw-reflection-texture)
]
[
demo-world-set-matrix
]
[
sphere-scene
]
[
reflection-texture>>
GL_TEXTURE_CUBE_MAP
GL_TEXTURE0
bind-texture-unit
]
[
texture-sphere-program>>
[
[
"surface_texture"
glGetUniformLocation
0
glUniform1i
]
[
{
0.0 0.0 0.0
}
4.0
(draw-sphere)
]
bi
]
with-gl-program
]
}
cleave
;
USING:
accessors
combinators
grid-meshes
kernel
opengl
opengl.gl
opengl.shaders
sequences
terrain
ui.gadgets.worlds
;
M:
terrain-world
draw-world*
{
[
set-modelview-matrix
]
[
terrain-texture>>
GL_TEXTURE_2D
GL_TEXTURE0
bind-texture-unit
]
[
sky-texture>>
GL_TEXTURE_2D
GL_TEXTURE1
bind-texture-unit
]
[
GL_DEPTH_TEST
glDisable
dup
sky-program>>
[
[
nip
"sky"
glGetUniformLocation
1
glUniform1i
]
[
"sky_gradient"
glGetUniformLocation
swap
sky-gradient
glUniform1f
]
[
"sky_theta"
glGetUniformLocation
swap
sky-theta
glUniform1f
]
2tri
{
-1.0 -1.0
}
{
2.0 2.0
}
gl-fill-rect
]
with-gl-program
]
[
GL_DEPTH_TEST
glEnable
dup
terrain-program>>
[
[
"heightmap"
glGetUniformLocation
0
glUniform1i
]
[
"component_scale"
glGetUniformLocation
COMPONENT-SCALE
first4
glUniform4f
]
bi
terrain-mesh>>
draw-grid-mesh
]
with-gl-program
]
}
cleave
gl-error
;
USING:
game.debug.tests
ui.gadgets.worlds
;
M:
tests-world
draw-world*
draw-debug-tests
;
USING:
accessors
cache
combinators
kernel
ui.gadgets.worlds
ui.render
;
M:
world
draw-world*
{
[
gl-draw-init
]
[
draw-gadget
]
[
text-handle>>
[
purge-cache
]
when*
]
[
images>>
[
purge-cache
]
when*
]
}
cleave
;