Einzelnen Beitrag anzeigen

Benutzerbild von littleDave
littleDave

Registriert seit: 27. Apr 2006
Ort: München
556 Beiträge
 
Delphi 7 Professional
 
#6

Re: OpenGl Rendercontex schützen

  Alt 16. Jun 2008, 15:15
Delphi-Quellcode:
procedure DrawPosition;
Var
    x1,x2,
  x12,x21,
  z1,y1,
  y2,x,y,hd : GLfloat;
  d1,d2 : GLfloat;
  overdraw : GLfloat;

begin

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity;
  gluPerspective(45, BassBoxInfo^.w / BassBoxInfo^.h, 1, 1000.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity;

  d1 := 0.05;
  d2 := 0.01;
  overdraw := 0.03;

  // PushAttrib
  glPushAttrib(GL_ALL_ATTRIB_BITS);
  try
    // RenderCode
    glDepthMask(ByteBool(GL_FALSE));
    glDisable(GL_LIGHTING);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE);
    
    // <---------- FINALLY WEG GEMACHT
   
    // Rendern
   glBindTexture(GL_TEXTURE_2D, BarTexture);
   glColor4f( 1.0, 1.0, 1.0, 0.0);

   z1 := -4.0;
   y1 := -1.65;
   y2 := y1 + d1 - d2 + overdraw;
   x1 := -2.21;
   x2 := 2.20;
   x12 := x1 + (d1 - d2) * 0.3;
   x21 := x2 - (d1 - d2) * 0.3;

   glBegin(GL_QUADS);

      glTexCoord2f(0.0, 0.0);
      glVertex3f(x1, y2, z1);
      glTexCoord2f(1.0, 0.0);
      glVertex3f(x1, y1, z1);
      glTexCoord2f(1.0, 0.3);
      glVertex3f(x12, y1, z1);
      glTexCoord2f(0.0, 0.3);
      glVertex3f(x12, y2, z1);
      glTexCoord2f(0.0, 0.3);
      glVertex3f(x12, y2, z1);
      glTexCoord2f(1.0, 0.3);
      glVertex3f(x12, y1, z1);
      glTexCoord2f(1.0, 0.7);
      glVertex3f(x21, y1, z1);
      glTexCoord2f(0.0, 0.7);
      glVertex3f(x21, y2, z1);
      glTexCoord2f(0.0, 0.7);
      glVertex3f(x21, y2, z1);
      glTexCoord2f(1.0, 0.7);
      glVertex3f(x21, y1, z1);
      glTexCoord2f(1.0, 1.0);
      glVertex3f(x2, y1, z1);
      glTexCoord2f(0.0, 1.0);
      glVertex3f(x2, y2, z1);

   glEnd();

   glBindTexture(GL_TEXTURE_2D, PeaksTexture);

   hd :=(d1 - d2) * 4.0;
   x :=(x2 - x1) * CurrentPositionPart + x1;
   y :=(y2 + y1) * 0.5;

   glBegin(GL_QUADS);
  glTexCoord2f(0.0, 0.0);
  glVertex3f(x - hd, y - hd, z1);
  glTexCoord2f(0.0, 1.0);
  glVertex3f(x - hd, y + hd, z1);
  glTexCoord2f(1.0, 1.0);
  glVertex3f(x + hd, y + hd, z1);
  glTexCoord2f(1.0, 0.0);
  glVertex3f(x + hd, y - hd, z1);
  glEnd();
  
  // <--------- TRY - BLOCK WEG GEMACHT
  
  finally
    glPopAttrib;
  end;

end;
Jabber: littleDave@jabber.org
in case of 1 is 0 do external raise while in public class of object array else repeat until 1 is 0
  Mit Zitat antworten Zitat