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

Aktuelle Zeit: Fr Jul 18, 2025 15:13

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



Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: glreadpixels with delphi?
BeitragVerfasst: Mo Mai 03, 2004 18:53 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
I am still trying to select faces and vertexes. For now i am trying to use the backbuffer for it. 24bit truecolor would give me enough colours for selecting them. But i am a bit puzzled on the glreadpixels command as it seems to write its data into pointer like structure.

-Are there any delphi tutorials or examples on the usage of it?

-When reading out only 1 pixel the date returned like a pointer to an array of byte allowing me to result[0] is red result[1] = green and result[2] = blue???

_________________
http://3das.noeska.com - create adventure games without programming


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mai 03, 2004 20:33 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Dez 13, 2002 12:18
Beiträge: 1063
Here is the code I use for occlusion testing of single pixels, your code would be very similar:
Code:
  1. // return if a point in world space is occluded by on-screen geometry
  2.  
  3. function PointIsOccluded(p: TVec) : boolean;
  4.  
  5.   var
  6.     viewport: TVector4i;
  7.     mvmatrix, projmatrix: TMatrix4d;
  8.     winx, winy, winz: GLdouble;
  9.     bufferZ: float;
  10.  
  11.   begin
  12.     glGetIntegerv (GL_VIEWPORT, addr(viewport));
  13.     glGetDoublev (GL_MODELVIEW_MATRIX, addr(mvmatrix));
  14.     glGetDoublev (GL_PROJECTION_MATRIX, addr(projmatrix));
  15.     // project world space onto screen
  16.     gluProject(p.x, p.y, p.z, mvmatrix, projmatrix, viewport, @winx, @winy, @winz);
  17.       // read back pixel from depth buffer
  18.       glReadPixels(round(winx), round(winy),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, @bufferZ);
  19.     result := bufferZ < winZ;
  20.   end;
  21.  


The last parameter in glReadPixels is a pointer to an array of your own, which is filled by the GL (in this special case of mine, it's a single float value, since I only read back the depth component of one pixel - more interesting (but not for this topic) would be the rectangular version, which is used to brighten/darken light flares, if a light source is partially occluded).

_________________
Viel Spaß beim Programmieren,
Mars
http://www.basegraph.com/


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mai 03, 2004 21:42 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
i figured out the data returned

for var i need to use:
pixel: array [0..2] of GLubyte;

and the reading goes with: glreadpixels(....,@pixel);

But now an other problem appeared. I need to disable lighting. And use glcolor3f to provide a color for mesh (or face etc.) But that does not appear to work as my meshes all turn white. Hmm... Better return to the redbook again...

_________________
http://3das.noeska.com - create adventure games without programming


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


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 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:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.007s | 16 Queries | GZIP : On ]