Показать сообщение отдельно
  #6  
Старый 20.01.2011, 14:29
Аватар для ALexandr555
ALexandr555 ALexandr555 вне форума
Специалист
 
Регистрация: 09.10.2010
Адрес: Тольятти
Сообщения: 803
Версия Delphi: Delphi 7
Репутация: 2064
По умолчанию

Код:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Draw;
end;

procedure TForm1.Draw;
      var
        quadObj :GLUquadricObj;
      begin
       glEnable(Gl_TEXTURE_2d);
        glClear(GL_DEPTH_BUFFER_BIT xor GL_COLOR_BUFFER_BIT);
        quadObj:=gluNewQuadric;
        gluQuadricDrawStyle(quadObj, GLU_FILL);
        CreateSphere(0, 0, 0, 10, 48);
        gluDeleteQuadric(quadObj);
        SwapBuffers(ghDC);
        glPushMatrix;
end;


procedure TForm1.CreateSphere(CX, CY, CZ, Radius : glFloat; N : Integer);  // N = precision
var I, J : Integer;
    theta1,theta2,theta3 : glFloat;
    X, Y, Z, px, py, pz : glFloat;
begin
  SphereDL :=glGenLists(1);
  glNewList(SphereDL, GL_COMPILE);
 LoadTexture('images/earth.jpg', DayTex, FALSE);
    if Radius < 0 then Radius :=-Radius;
    if n < 0 then n := -n;
    if (n < 4) OR (Radius <= 0) then
    begin
      glBegin(GL_POINTS);
        glVertex3f(CX, CY, CZ);
      glEnd();
      exit;
    end;

    for J :=0 to N DIV 2 -1 do
    begin
      theta1 := J*2*PI/N - PI/2;
      theta2 := (J+1)*2*PI/n - PI/2;
      glBegin(GL_QUAD_STRIP);
        For I :=0 to N do
        begin
          theta3 := i*2*PI/N;
          x := cos(theta2) * cos(theta3);
          y := sin(theta2);
          z := cos(theta2) * sin(theta3);
          px := CX + Radius*x;
          py := CY + Radius*y;
          pz := CZ + Radius*z;

  //        glNormal3f(X, Y, Z);
          glTexCoord2f(1-I/n, 2*(J+1)/n);
          glVertex3f(px,py,pz);

          X := cos(theta1) * cos(theta3);
          Y := sin(theta1);
          Z := cos(theta1) * sin(theta3);
          px := CX + Radius*X;
          py := CY + Radius*Y;
          pz := CZ + Radius*Z;

  //        glNormal3f(X, Y, Z);
          glTexCoord2f(1-i/n, 2*j/n);
          glVertex3f(px,py,pz);
        end;
      glEnd();
    end;
  glEndList();
end;


вот попробовал но черный экран кто скажет почему не работает?
Ответить с цитированием