drawing from a list
BlitzMax Forums/OpenGL Module/drawing from a list| 
 | ||
| Hi, i have a bit of code that geneterates a list of x,y positions to draw some quads, it then goes thru and draws them.  however it only seems to like to add 3 or 4 even tho there are 30 being added 
SuperStrict
SetGraphicsDriver GLGraphicsDriver()
GLGraphics 640,480
Global tmpImg:TPixmap,tex%
tmpImg = LoadPixmap("pen.png");
tex = GLTexFromPixmap(tmpImg);
Type Units
	Field sx:Float=0.0;
	Field sy:Float=0.0;
End Type
Global penList:TList = New TList	
glInit();
Repeat
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
	glLoadIdentity()
	For Local tl:units = EachIn penList
	
	glTranslatef(tl.sx,tl.sy,0);
	glBegin(GL_QUADS);								
		
 		glcolor4f(1,0,0,0);glVertex3f(0, 0, 0.0);			
		glcolor4f(0,1,0,0);glVertex3f(0, 32, 0.0);			
		glcolor4f(0,0,1,0);glVertex3f(32,32, 0.0);			
		glcolor4f(1,0,1,0);glVertex3f(32,0, 0.0);			
		
	glEnd();		
	Next
	
Flip()
Until KeyDown(key_escape)
Function AddNew()
	
	Local tl:Units = New Units;
	penList.addlast tl;
	tl.sx = Rnd(300);
	tl.sy = Rnd(300);
End Function
Function glInit()
SeedRnd MilliSecs()
For Local i:Int = 1 To 60
	addnew()
Next
	glViewport(0,0,640,480);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glortho (0.0,640,480,0,-1.0,1.0);
	glMatrixMode(GL_MODELVIEW);				
	glLoadIdentity();					
	glClearColor(1,1,1,1);
End Function
can n e one spot a reason ?? | 
| 
 | ||
| it's because you're putting the random quads outside the view.. try reducing your rnd(300) to something smaller.. like 30.. | 
| 
 | ||
| ok, i have done that, even setting it to 1 gives it an undisred effect, the quads draw but in a linear position | 
| 
 | ||
| sorted it i just changed: glTranslatef(tl.sx,tl.sy,0); glBegin(GL_QUADS); to glTranslatef(0,0,0);glLoadIdentity();Translatef(tl.sx,tl.sy,0); glBegin(GL_QUADS); and it works as expected, not sure if this is the correct way to do it, but hey if it does what its ment to do :) |