Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Fr Mär 29, 2024 03:23

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Autor Nachricht
BeitragVerfasst: Do Mai 19, 2005 22:07 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 11, 2003 13:23
Beiträge: 25
Wohnort: South Africa
Hi All

Is is possible to use the above mentioned functions with arrays of pointers?

EG:

Code:
  1.  
  2.     glEnableClientState(GL_VERTEX_ARRAY);
  3.     glEnableClientState(GL_NORMAL_ARRAY);
  4.     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  5.       glVertexPointer(3, GL_FLOAT, 0, lSubMesh.Vertices);
  6.       glNormalPointer(GL_FLOAT,0,lSubMesh.Normals);
  7.       glTexCoordPointer(3,GL_FLOAT,0,lSubMesh.TexCoords);
  8.  
  9.       glDrawElements(GL_TRIANGLES,Length(lSubMesh.Indices),GL_UNSIGNED_INT,lSubMesh.Indices);
  10.  
  11.     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  12.     glDisableClientState(GL_NORMAL_ARRAY);
  13.     glDisableClientState(GL_VERTEX_ARRAY);
  14.  


Where lSubMesh.Vertices, lSubMesh.Normals and lSubMesh.TexCoords are defined as :

Code:
  1.  
  2. TAVectorArray = Array of TAffineVector;
  3. TPAVectorArray = Array of PAffineVector;
  4. PAVectorArray = ^TAVectorArray;
  5.  
  6. FTexCoords : TPAVectorArray;
  7. FVertices : TPAVectorArray;
  8. FNormals : TPAVectorArray;
  9.  


And the Arrays are populated like this:

Code:
  1.  
  2. procedure TRGLSubMesh.ChangePointerArrays(aVertices, aNormals,
  3.   aTexCoords: PAVectorArray);
  4. var
  5.   lFace : TRGLFace;
  6.   i, lIndex : Integer;
  7. begin
  8.   lFace := Faces.Face[Faces.Count - 1];
  9.   for i := 0 to 2 do
  10.   begin
  11.     lIndex := Length(FTexCoords);
  12.     SetLength(FTexCoords,Length(FTexCoords) + 1);
  13.     SetLength(FVertices,Length(FVertices) + 1);
  14.     SetLength(FNormals,Length(FNormals) + 1);
  15.     SetLength(FIndices,Length(FIndices) + 1);
  16.     FTexCoords[lIndex] := @aTexCoords^[lFace.TextureIndexes[i]];
  17.     FNormals[lIndex] := @aNormals^[lFace.NormalIndexes[i]];
  18.     FVertices[lIndex] := @aVertices^[lFace.VerticeIndexs[i]];
  19.     FIndices[lIndex] := lIndex;
  20.   end;
  21. end;
  22.  


Any help or guidance would be greatly appreciated :)

_________________
Im out of my mind but please leave a message...
www.sulaco.co.za


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Do Mai 19, 2005 23:22 
Offline
DGL Member

Registriert: Fr Dez 19, 2003 14:27
Beiträge: 107
Wohnort: Indianapolis, USA
glVertexPointer expects to get the address of your first vertex and not the address of a pointer that points to the vertex. Unless I misunderstood your problem, I don't think that's possible.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 21, 2005 16:20 
Offline
DGL Member

Registriert: Sa Jan 22, 2005 21:10
Beiträge: 225
Tokter is right. It doesn't work. Those functions want their data in one chunk.

But there is another thing:

Code:
  1.  
  2.     SetLength(FTexCoords,Length(FTexCoords) + 1);
  3.     SetLength(FVertices,Length(FVertices) + 1);
  4.     SetLength(FNormals,Length(FNormals) + 1);
  5.  


If you do stuff like that too often (by loading a whole map that way for example), it will lead you to very big memoryfragmentation problems...

_________________
[18:30] tomok: so wie ich das sehe : alles. was nich was anderes ist als nen Essay ist nen Essay

hi, i'm a signature viruz, plz set me as your signature and help me spread :)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 21, 2005 16:29 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Dez 28, 2002 11:13
Beiträge: 2244
And use VBO to store the arrays in video memory.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 21, 2005 19:23 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Nov 13, 2004 11:00
Beiträge: 229
Wohnort: Steinhude
AL hat geschrieben:
Tokter is right. It doesn't work. Those functions want their data in one chunk.
Code:
  1.  
  2.     SetLength(FTexCoords,Length(FTexCoords) + 1);
  3.     SetLength(FVertices,Length(FVertices) + 1);
  4.     SetLength(FNormals,Length(FNormals) + 1);
  5.  


If you do stuff like that too often (by loading a whole map that way for example), it will lead you to very big memoryfragmentation problems...


not too mention that calls of setlength are not fast


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mai 23, 2005 18:56 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 11, 2003 13:23
Beiträge: 25
Wohnort: South Africa
LarsMiddendorf hat geschrieben:
And use VBO to store the arrays in video memory.


The code above is used for my character animation class, so i'm not sure VBO will work here.

If it will, I'm all ears :) :D


The problem is fixed :)

You guys where 100% the data needs to be in sequential blocks in memory for GL to read it, Its a pity that the pointer idea didnt work because it makes the memory footprint VERY small. :(

I eventually went back to normal vert arrays, and am now trying to reduce the load on the memory, by reusing arrays and animations for multiple characters etc...

Thanx for the help :)

_________________
Im out of my mind but please leave a message...
www.sulaco.co.za


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mai 23, 2005 21:07 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Dez 28, 2002 11:13
Beiträge: 2244
You can also use VBO's with dynamic data. Use GL_DYNAMIC_DRAW if the data is used multiple times and GL_STREAM_DRAW if it is used only once. When updating a buffer, it is the best to use glBufferSubData or to map the buffer and to copy the array directly.
The driver should give you a new buffer when using WRITE_ONLY_ARB with glMapBuffer, so that the new buffer can filled while the hw is rendering the old.
This can give you a quite large speed increase. There ist an old NV_Vertex_Array_Range demo that uses the same technique and it was many times faster than using the default vertex arrays although the application was writing directly to AGP oder video memory every frame.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mai 25, 2005 18:39 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 11, 2003 13:23
Beiträge: 25
Wohnort: South Africa
Ahh yes :)

Thank you Lars

That will help me LOTS :)

VBO's are still a bit of mystery to me, but from what I have read they work almost the same as Vert arrays, so I should be able to understand them, without too much hastle

Thanx again

PS: Current statistics for my anim class using 41 characters (All wth two animations blending) totaling 109 000 Triangles are:

GFX Card: GF 6800 GT
FPS: 160
Memory Usage: WAAAYYYYYYYY TOOOO MUCH!
CPU: AMD 64 3500 +
MEM : 1023

Havent tested on my older cards/PC's yet, so i'll post those stats later.

_________________
Im out of my mind but please leave a message...
www.sulaco.co.za


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 13 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.216s | 17 Queries | GZIP : On ]