So basically what I am trying to do is to add a letter package with OpenGL, since there is no real alternative on it. (glBitmap just shows some weirds stuff on my screen)
alphabet = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]#refer to the drawings of the shape I made, in list
alphastring = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] #refer to the letter in string, it makes it easier to compare
lettreLiens = [liena, lienb, lienc, liend, liene, lienf, lieng, lienh, lieni, lienj, lienk, lienl,lienm,lienn,lieno,lienp,lienq,lienr,lien_s,lient,lienu,lienv,lienw,lienx,lieny,lienz] #the links for the points I've drawn, note that lien_s is correct
class text:
def __init__(self,texte,bigness,x,y):
self.texte = texte
self.bigness = bigness
self.x = x
self.y = y
self.textPos = 1
self.textList = self.texte.split(',')
print(len(self.textList))
for self.l in range(0,(len(self.textList))):
for self.n in range(0,25):
if self.textList[self.l] == alphastring[self.n]:
for self.point in alphabet[self.n]:
self.point[0]+=int(self.x)
self.point[1]+=int(self.y)
self.point[0] += int(self.textPos)
self.n = 0
self.textPos+=1
def run(self):
for self.l in range(0,(len(self.textList))):
for self.n in range(0,25):
if self.textList[self.l] == alphastring[self.n]:
glBegin(GL_LINES)
for link in (lettreLiens[self.n]):
for vertex in link:
glVertex3fv(alphabet[self.n][vertex])
glEnd()
self.n = 0
The problem is that OpenGL only render one shape for each letter. If I create an instance for the word hello it will just show he lo on the screen. I also tried to create an instance for hel, and then lo and this do not work either.
The major issue is that you store a point for each letter. But you don't store a point for each letter of the text which you want to render, instead you store a one point for each letter which is used. This causes, that if a letter is used twice, only the position of the last occurrence of the letter is stored.
I recommend to omit the calculation of the letter positions and to render the text on the fly:
See the preview: