OpenGL and Vertex Arrays

Advanced game related topics
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post by Danilo »

Polo wrote:I do that: I have one memory with the vertices, one with the
indexes. The fact is I want to use these stuffs which are in
memory, and that I don't know how to do...
Just use the memory address instead the address of the array:

Code: Select all

Structure Vertex
  x.f
  y.f
  z.f
EndStructure
 
VertexMem = AllocateMemory(1,SizeOf(Vertex)*8)
*mem.Vertex = VertexMem

Restore vertices
For i=0 To 7
  Read var.f : *mem\x = var
  Read var.f : *mem\y = var
  Read var.f : *mem\z = var
  *mem + SizeOf(Vertex)
Next

;...

glVertexPointer_(3, #GL_FLOAT, 0, VertexMem) ; <<-- using mem address here

DataSection 
  vertices:
    Data.f -1.0,  1.0,  1.0 
    Data.f  1.0,  1.0,  1.0 
    Data.f  1.0, -1.0,  1.0 
    Data.f -1.0, -1.0,  1.0 
    Data.f -1.0,  1.0, -1.0 
    Data.f  1.0,  1.0, -1.0 
    Data.f  1.0, -1.0, -1.0 
    Data.f -1.0, -1.0, -1.0 
EndDataSection
In traumatic's code its vertices() and indices() - it returns
the memory address of the array. Just replace it with your
memory address.
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
Post Reply