Tutorial 7
Vectorial text and linseg
In this tutorial we'll learn how to
draw vectorial text (which is text made up of lines) and how to use
the csound instruction linseg.
We start
everything as usual:
<CsoundSynthesizer>
<CsOptions>
-+Y
</CsOptions>
<CsInstruments>
#include "OpenGL.h"
sr=100
kr =100
ksmps=1
nchnls=1
GLfps 30
GLpanel "OpenGL panel",
512, 512
GLpanel_end
FLrun
glMatrixMode $GL_PROJECTION
glLoadIdentity
gluPerspective 60,0.1,100
glMatrixMode $GL_MODELVIEW
glEnable $GL_BLEND
glBlendFunc
$GL_SRC_ALPHA,$GL_DST_ALPHA
GLinsert_i $GL_NOT_VALID
glClear $GL_COLOR_BUFFER_BIT
+ $GL_DEPTH_BUFFER_BIT
GLinsert_i 1.1
gisine ftgen 1,0,1024,10,1
instr 2
kenv linseg 0,3,1,p3-8,1,5,0
ired = p4
irot = p5
iy = p6
glLoadIdentity
tosc GLoscil 1,120,1
glTranslate -1,-1,-3
glRotate irot,0,1,0
glTranslate -1,iy, tosc
glColor ired,1,0,t (kenv)
glLineWidth 1
glScale 1/1000,1/1000,1/1000
GLUTprints
"www.oocities.org/mantaraya36@CsoundAV Tutorials",
$GLUT_STROKE_ROMAN, -150,0,0,0
GLinsert 1.5
endin
</CsInstruments>
<CsScore>
i 2 2 28 1 0 0
i 2 3 27 0.8 0 1
i 2 4 26 0.6 0 2
i 2 5 25 0 270 0
i 2 6 24 0 270 1
i 2 7 23 0 270 2
i 2 8 22 1 90 0
i 2 9 21 1 90 1
i 2 10 20 1 90 2
</CsScore>
</CsoundSynthesizer>
This
example shows an effective way to draw text on the screen. Since it
is vectorial (drawn from lines) it is a bit limited, and doesn't have
fonts that are very interesting. It can create a good effect, though
when used creatively. In a later tutorial, we'll explore the flashier
3D fonts.The fonts that can currently be used are the following:
- $GLUT_STROKE_ROMAN
(vectorial)
$GLUT_STROKE_MONO_ROMAN (vectorial)
Experiment changing the parameter in
the instruction GLUTprints. Also notice the great flexibility
of the instruction linseg, which creates an envelope which can
span the whole of the note, no matter the duration, because it is a
function of duration. An envelope is a 'shape' that modifies some
parameter. It can be thought of as a form of automation in this case.
Back
to OpenGL Tutorials Index