glhead.bmx uses them.
Also,
Sorry about the length of that - what's the name of the tag that puts it in a scrollable box?
EDIT: Thanks, mephtis.
BTW, don't worry about the maths in the SetPos method. I just copied and pasted it (on the whole) from DrawImage. It basically sets four vertex co-ordinates per sprite (top-left, top-right, bottom-right, bottom-left in turn) with texture co-ordinates to match. It's more complex than it could be, because I've left in the transform bits that could potentially let you rotate the sprites.
Also,
Rem Teamonkey's simple vertex array demo End Rem Strict Const ARRAY_SIZE = 1000 ' 1000 sprites Const SCREEN_W = 800 Const SCREEN_H = 600 Type TImageArray Field image:Int Field img_width:Int, img_height:Int, tex_width:Int, tex_height:Int Field frame:Int = 0 Field size:Int Field ver:Float[] ' Vertex array Field tex:Float[] ' Texture co-ordinates array Function Create:TImageArray(pixmap_in:TPixmap, size_in:Int) Assert(size_in > 0) Local timg:TImageArray = New TImageArray timg.image = bglTexFromPixmap(pixmap_in) timg.img_width = pixmap_in.width timg.img_height = pixmap_in.height timg.tex_width = timg.img_width timg.tex_height = timg.img_height bglAdjustTexSize timg.tex_width,timg.tex_height timg.ver = New Float[size_in*8] ' 2*4 vertices per index timg.tex = New Float[size_in*8] timg.size = size_in Assert(timg.ver.length=size_in*8 And timg.tex.length=size_in*8) Return timg End Function Method DrawAll() glEnable GL_TEXTURE_2D glBindTexture GL_TEXTURE_2D,image glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR glEnableClientState(GL_VERTEX_ARRAY) glEnableClientState(GL_TEXTURE_COORD_ARRAY) glVertexPointer(2,GL_FLOAT,0,ver) glTexCoordPointer(2,GL_FLOAT,0,tex) glDrawArrays(GL_QUADS, 0, size*4) End Method Method SetPos(index:Int, x#, y#) Assert(index>=0 And index<size) Local origin_x#, origin_y# GetOrigin(origin_x, origin_y) Local x0# = 0.0 Local x1# = tex_width Local y0# = 0.0 Local y1# = tex_height Local tx# = x + origin_x Local ty# = y + origin_y ' These are transform parameters. Const ix# = 1.0 Const iy# = 0.0 Const jx# = 0.0 Const jy# = 1.0 ' Texture co-ordinates. Local u0# = 0.0 Local u1# = Float(tex_width)/Float(img_width) Local v0# = 0.0 Local v1# = Float(tex_height)/Float(img_height) ' Calculate vertex positions ver[index*8 + 0] = x0*ix + y0*iy + tx ' x first ver[index*8 + 2] = x1*ix + y0*iy + tx ver[index*8 + 4] = x1*ix + y1*iy + tx ver[index*8 + 6] = x0*ix + y1*iy + tx ver[index*8 + 1] = x0*jx + y0*jy + ty ' now the y's ver[index*8 + 3] = x1*jx + y0*jy + ty ver[index*8 + 5] = x1*jx + y1*jy + ty ver[index*8 + 7] = x0*jx + y1*jy + ty ' Extract texture co-ordinates tex[index*8 + 0] = u0 tex[index*8 + 2] = u1 tex[index*8 + 4] = u1 tex[index*8 + 6] = u0 tex[index*8 + 1] = v0 tex[index*8 + 3] = v0 tex[index*8 + 5] = v1 tex[index*8 + 7] = v1 End Method End Type ' ***** ' START ' ***** Graphics SCREEN_W, SCREEN_H, 0 Cls Local img:TPixmap = LoadPixmap("ball.png") Local imgArr:TImageArray = TImageArray.Create(img, ARRAY_SIZE) SetBlend ALPHABLEND For Local i=0 To (ARRAY_SIZE)-1 Local x# = RndFloat()*SCREEN_W Local y# = RndFloat()*SCREEN_H imgArr.SetPos(i,x,y) Next imgArr.DrawAll() Flip WaitKey
Sorry about the length of that - what's the name of the tag that puts it in a scrollable box?
EDIT: Thanks, mephtis.
BTW, don't worry about the maths in the SetPos method. I just copied and pasted it (on the whole) from DrawImage. It basically sets four vertex co-ordinates per sprite (top-left, top-right, bottom-right, bottom-left in turn) with texture co-ordinates to match. It's more complex than it could be, because I've left in the transform bits that could potentially let you rotate the sprites.