Tema: OpenGL
Ver Mensaje Individual
  #12  
Antiguo 16-04-2013
Avatar de cesarsoftware
cesarsoftware cesarsoftware is offline
Miembro
 
Registrado: nov 2006
Posts: 241
Reputación: 18
cesarsoftware Va por buen camino
Cita:
Empezado por blackx5n Ver Mensaje
1- Que version de delphi usaste para el codigo que posteaste
Delphi 2007
Cita:
Empezado por blackx5n Ver Mensaje
2- Tengo que tener instalado el opengl que version, o solo funciona con agregar al uses opengl.
solo agrega en el uses la unidad opengl
Cita:
Empezado por blackx5n Ver Mensaje
3- Que tipo de variables son h_DC y h_RC de el procedimiento glInicia;
Son handles, necesitas la unidad windows en el uses en mi caso son globales
h_DC : HDC; // handle del contexto del formulario
h_RC : HGLRC; // handle del contexto OpenGL
Cita:
Empezado por blackx5n Ver Mensaje
4- Que tipo de componente es el SpinZoom y SimCfg
SpinZoom: TUpDown;
SimCfg es un formulario que contiene la configuracion base
Cita:
Empezado por blackx5n Ver Mensaje
5- Que procedimiento es el glIniciaLuz();
Código Delphi [-]
procedure TfrmOpenGl.glIniciaLuz();
begin
  ambientLight[1] := 0.30;
  ambientLight[2] := 0.30;
  ambientLight[3] := 0.30;
  ambientLight[4] := 1.0;
  diffuseLight[1] := 0.1;
  diffuseLight[2] := 0.1;
  diffuseLight[3] := 0.1;
  diffuseLight[4] := 1.0;
  specularLight[1] := 0.5;
  specularLight[2] := 0.5;
  specularLight[3] := 0.5;
  specularLight[4] := 0.5;
  specurefLight[1] := 1.0;
  specurefLight[2] := 1.0;
  specurefLight[3] := 1.0;
  specurefLight[4] := 1.0;
  positionLight[1] := 0.0;
  positionLight[2] := 0.0;
  positionLight[3] := 150.0;
  positionLight[4] := 1.0;
end;

procedure TfrmOpenGl.glAjustaLuz();
begin
  // Definir Luz numero 0
  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, @ambientLight);
  glLightfv(GL_LIGHT0, GL_AMBIENT, @ambientLight);       // luz ambiente
  glLightfv(GL_LIGHT0, GL_DIFFUSE, @diffuseLight);       // luz difusa
  glLightfv(GL_LIGHT0, GL_SPECULAR, @specularLight);     // luz especular
  glLightfv(GL_LIGHT0, GL_POSITION, @positionLight);     // posiciona la luz
  if SpinLuzFoco.Value <> 0 then begin
    glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 90);             // Angulo corte a 90º
    glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, SpinLuzFoco.Value); // Foco brillante
  end else begin
    glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180);              // Angulo corte a 180º
    glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 0);            // sin Foco
  end;
  glEnable(GL_LIGHT0);                                   // enciende luz nº 0
  glEnable(GL_COLOR_MATERIAL); // activa seguimiento del color
  glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);  // material sigue a color
  glMaterialfv(GL_FRONT, GL_SPECULAR, @specurefLight);// reflexivo especular
  glMaterial(GL_FRONT_AND_BACK, GL_SHININESS, 32);       // brillo moderado
end;

procedure TfrmOpenGl.BotonResetLuzClick(Sender: TObject);
begin
  glIniciaLuz();
  SpinLuzAmbiente.Value := 0;
end;

procedure TfrmOpenGl.SpinLuzAmbienteChange(Sender: TObject);
begin
  if EsNumero(SpinLuzAmbiente.Text) then begin
    ambientLight[1] := SpinLuzAmbiente.Value / 100;
    ambientLight[2] := SpinLuzAmbiente.Value / 100;
    ambientLight[3] := SpinLuzAmbiente.Value / 100;
    ambientLight[4] := 1.0;
    glDibuja();
  end;
end;
__________________
Disfruta de la vida ahora, vas a estar muerto mucho tiempo.
Responder Con Cita