|
Post by chris857 on Nov 14, 2010 14:09:10 GMT -5
I was wondering if anyone else gets this error. With a few programs, after ending the program I get an error saying "Abnormal program termination". Here is the program that most recently causes this:
dim final$ = "FX" dim temp$ dim i,j for j = 1 to 11 temp$ = final$ final$ = "" for i = 1 to len(temp$) if mid$(temp$,i,1) = "X" then final$ = final$ + "X+YF" elseif mid$(temp$,i,1) = "Y" then final$ = final$ + "FX-Y" else final$ = final$ + mid$(temp$,i,1) endif next next dim x = 0 dim y = 0 dim direction = 0 glTranslatef(0,0,-100) glBegin(GL_LINE_STRIP) 'glBegin(GL_LINES) glVertex2f(0,0) for i = 1 to len(final$) if mid$(final$,i,1) = "F" then if direction % 4 = 0 then direction = 0 x = x + 1 elseif direction % 4 = 1 then y = y + 1 elseif direction % 4 = 2 then x = x - 1 elseif direction % 4 = 3 then y = y - 1 endif elseif mid$(final$,i,1) = "+" then direction = direction + 1 elseif mid$(final$,i,1) = "-" then direction = direction - 1 endif glVertex2f(x,y) next glEnd() SwapBuffers() but only if the first for-loop runs for more than ten times. Does anyone know what causes this?
|
|
|
Post by DJLinux on Nov 14, 2010 18:08:13 GMT -5
you use to mutch vertices for one GL_LINE_STRIP if you render it split it in more pieces
Joshy
|
|
|
Post by DJLinux on Nov 14, 2010 18:38:24 GMT -5
Here are an example of how you can split the drawing in pieces of 32 coords per line strip Joshy sub IncColors(&r,&g,&b) r=r+1 g=r/2 b=g/3 glColor3UB(r,g,b) end sub
dim final$ = "FX" dim temp$,char$ dim i,i1,j,flag,d dim r,g,b for j = 1 to 12 temp$ = final$ final$ = "" for i = 1 to len(temp$) ' use mid$() only once char$=mid$(temp$,i,1) if char$ = "X" then final$ = final$ + "X+YF" elseif char$ = "Y" then final$ = final$ + "FX-Y" else final$ = final$ + char$ endif next next
dim x = 0 dim y = 0 dim direction = 0
glTranslatef(0,0,-100)
j=len(final$)-1
glColor3UB(r,g,b) for i=0 to j i1=i+1 ' begin of a new line strip strip ? if (i % 32)=0 then flag=1 glBegin(GL_LINE_STRIP) ' fist time it's 0,0 ' or the last x,y glVertex2f(x,y) end if ' use mid$() only once char$=mid$(final$,i1,1) if char$ = "F" then ' use mod operator only once d=direction % 4 if d = 0 then x = x + 1 elseif d = 1 then y = y + 1 elseif d = 2 then x = x - 1 elseif d = 3 then y = y - 1 endif elseif char$ = "+" then IncColors(r,g,b) direction = direction + 1 elseif char$ = "-" then IncColors(r,g,b) direction = direction - 1 endif glVertex2f(x,y)
' end of current line strip ? if (i1 % 32)=0 then flag=0 glEnd() ' optional show whats going on SwapBuffers() end if next
' close any open line strip ' of course your coords must not be a multiply of 32 if flag<>0 then glEnd() end if
' show it SwapBuffers() end
|
|
|
Post by DJLinux on Nov 14, 2010 20:21:07 GMT -5
|
|
|
Post by chris857 on Nov 14, 2010 20:45:20 GMT -5
What is the limit on vertices in this case? Is it 4096?
|
|
|
Post by DJLinux on Nov 14, 2010 21:21:15 GMT -5
What is the limit on vertices in this case? Is it 4096? I don't know but you can read the specs on opengl.org by the way the strings will crash on recursion too :-( function L_System$(in$,replace$,n) dim result$,char$,i printr n n=n-1 for i = 1 to len(in$) char$=mid$(in$,i,1) if char$="F" then result$=result$+replace$ else result$=result$+char$ end if next if n>0 then result$=L_System$(result$,replace$,n) end if return result$ end function
dim start$,rule$,result$
start$ = "F--F--F--" rule$ = "F+F--F+F" result$ = L_System$(Start$,Rule$,5)
printr result$
|
|
|
Post by Adam on Nov 15, 2010 14:32:16 GMT -5
I have also noticed that this will happen with heavy network usage, everytime i press esc on say my file server for instance, basic4gl crashes
|
|