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

Aktuelle Zeit: Fr Jul 18, 2025 12:24

Foren-Übersicht » Programmierung » OpenGL
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 2 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Transparenz mit Texturen
BeitragVerfasst: Sa Mai 27, 2006 14:02 
Offline
DGL Member

Registriert: Di Mai 24, 2005 16:43
Beiträge: 710
hi, ich habe schon lange gesucht, aber nur sachen über transparentcolor usw gefunden,
was ich vorhabe ist, ein QUAD mit einer textur drauf halbtransparent zu machen, also so
dass man durchgucken kann, so sieht der rohbau aus:
Code:
  1.  
  2. procedure DrawPlate(aPlate: TPlate; trans: boolean = false);
  3. var
  4.   x, y, z: double;
  5. begin
  6.   x := aPlate.position.x;
  7.   y := aPlate.position.y;
  8.   z := aPlate.position.z;
  9.   if trans then
  10.   begin
  11.   //
  12.   end;
  13. //PLATETEXTUR
  14.   glBindTexture(GL_TEXTURE_2D, platetex);
  15. //PLATE
  16.   glBegin(GL_QUADS);
  17.     glTexCoord2f(0,0); glVertex3f(x + aplate.size.x / 2,y + aplate.size.y / 2,z);
  18.     glTexCoord2f(1,0); glVertex3f(x - aplate.size.x / 2,y + aplate.size.y / 2,z);
  19.     glTexCoord2f(1,1); glVertex3f(x - aplate.size.x / 2,y - aplate.size.y / 2,z);
  20.     glTexCoord2f(0,1); glVertex3f(x + aplate.size.x / 2,y - aplate.size.y / 2,z);
  21.   glEnd;
  22.   if trans then
  23.   begin
  24.   //
  25.   end;
  26. end;
  27.  

ich habe es schon geschaft das teil transparent zu bekomnmen, leider war dann keine textur mehr drauf :(

vielen dank schonmal ;)

mfg


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 27, 2006 16:31 
Offline
DGL Member

Registriert: Di Mai 24, 2005 16:43
Beiträge: 710
ok das hier geht:
Code:
  1.  
  2. procedure DrawPlate(aPlate: TPlate; trans: boolean = false);
  3. var
  4.   x, y, z: double;
  5. begin
  6.   x := aPlate.position.x;
  7.   y := aPlate.position.y;
  8.   z := aPlate.position.z;
  9.   if trans then
  10.   begin
  11.     glEnable(GL_BLEND);
  12.     glDisable(GL_LIGHTING);
  13.     glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);
  14.     glColor4f(0.5,0.5,0.5,0.5);
  15.   end;
  16. //PLATETEXTUR
  17.   glBindTexture(GL_TEXTURE_2D, platetex);
  18. //PLATE
  19.   glBegin(GL_QUADS);
  20.     //Vorn
  21.     glTexCoord2f(0,0); glVertex3f(x + aplate.size.x / 2,y + aplate.size.y / 2,z - aPlate.size.z / 2);
  22.     glTexCoord2f(1,0); glVertex3f(x - aplate.size.x / 2,y + aplate.size.y / 2,z - aPlate.size.z / 2);
  23.     glTexCoord2f(1,1); glVertex3f(x - aplate.size.x / 2,y - aplate.size.y / 2,z - aPlate.size.z / 2);
  24.     glTexCoord2f(0,1); glVertex3f(x + aplate.size.x / 2,y - aplate.size.y / 2,z - aPlate.size.z / 2);
  25.     //Hinten
  26.     glTexCoord2f(0,0); glVertex3f(x + aplate.size.x / 2,y + aplate.size.y / 2,z + aPlate.size.z / 2);
  27.     glTexCoord2f(1,0); glVertex3f(x - aplate.size.x / 2,y + aplate.size.y / 2,z + aPlate.size.z / 2);
  28.     glTexCoord2f(1,1); glVertex3f(x - aplate.size.x / 2,y - aplate.size.y / 2,z + aPlate.size.z / 2);
  29.     glTexCoord2f(0,1); glVertex3f(x + aplate.size.x / 2,y - aplate.size.y / 2,z + aPlate.size.z / 2);
  30.     //Rechts
  31.     glTexCoord2f(0,0); glVertex3f(x + aplate.size.x / 2,y + aplate.size.y / 2,z + aPlate.size.z / 2);
  32.     glTexCoord2f(1,0); glVertex3f(x + aplate.size.x / 2,y + aplate.size.y / 2,z - aPlate.size.z / 2);
  33.     glTexCoord2f(1,1); glVertex3f(x + aplate.size.x / 2,y - aplate.size.y / 2,z - aPlate.size.z / 2);
  34.     glTexCoord2f(0,1); glVertex3f(x + aplate.size.x / 2,y - aplate.size.y / 2,z + aPlate.size.z / 2);
  35.     //Links
  36.     glTexCoord2f(0,0); glVertex3f(x - aplate.size.x / 2,y + aplate.size.y / 2,z + aPlate.size.z / 2);
  37.     glTexCoord2f(1,0); glVertex3f(x - aplate.size.x / 2,y + aplate.size.y / 2,z - aPlate.size.z / 2);
  38.     glTexCoord2f(1,1); glVertex3f(x - aplate.size.x / 2,y - aplate.size.y / 2,z - aPlate.size.z / 2);
  39.     glTexCoord2f(0,1); glVertex3f(x - aplate.size.x / 2,y - aplate.size.y / 2,z + aPlate.size.z / 2);
  40.     //Oben
  41.     glTexCoord2f(0,0); glVertex3f(x + aplate.size.x / 2,y + aplate.size.y / 2,z - aPlate.size.z / 2);
  42.     glTexCoord2f(1,0); glVertex3f(x - aplate.size.x / 2,y + aplate.size.y / 2,z - aPlate.size.z / 2);
  43.     glTexCoord2f(1,1); glVertex3f(x - aplate.size.x / 2,y + aplate.size.y / 2,z + aPlate.size.z / 2);
  44.     glTexCoord2f(0,1); glVertex3f(x + aplate.size.x / 2,y + aplate.size.y / 2,z + aPlate.size.z / 2);
  45.     //Unten
  46.     glTexCoord2f(0,0); glVertex3f(x + aplate.size.x / 2,y - aplate.size.y / 2,z - aPlate.size.z / 2);
  47.     glTexCoord2f(1,0); glVertex3f(x - aplate.size.x / 2,y - aplate.size.y / 2,z - aPlate.size.z / 2);
  48.     glTexCoord2f(1,1); glVertex3f(x - aplate.size.x / 2,y - aplate.size.y / 2,z + aPlate.size.z / 2);
  49.     glTexCoord2f(0,1); glVertex3f(x + aplate.size.x / 2,y - aplate.size.y / 2,z + aPlate.size.z / 2);
  50.   glEnd;
  51.   if trans then
  52.   begin
  53.     glDisable(GL_BLEND);
  54.     glEnable(GL_LIGHTING);
  55.   end;
  56. end;
  57.  


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


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 4 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.008s | 14 Queries | GZIP : On ]