Welcome to the new Friends-of-FPC!

Here you can find all kinds of information about the FreePascal Compiler. We have many tutorials and howtos as well as a selection of tools to help you with your programming. We also have some example codes for you. And if you want to contribute some information/ sources/ tools yourself you can do so.
Also we have finally relaunched the FoFPC forum. It's your chance for some Q&A about everything FreePascal.

Friends-of-FPC

Tutorials: Learn how to code with FreePascal.

Source Codes: A collection of examples, miscellaneous source codes and open source stuff.

Tools and Help Files: Intro- duction of some tools that might help you with FPC.

Community

Forum: Ask or answer questions about the FreePascal Compiler, programming or just babble about coding.

Contribute! Contribute your own Tutorial, Source Codes or Tools and send them to us!

Website

About: Information about Friends-of-FPC.org.

Einführung in OpenGL - Teil 15 - by Delax

Jetzt zur letzten Art von Licht unserer Lichtquelle. Für direktes Licht benötigen wir schon wieder zusätzliche Variablen.

  AmbientLight : array[0..3] of glFloat = (0.5,0.5,0.5,1.0);
  DiffuseLight : array[0..3] of glFloat = (1.0,1.0,1.0,1.0);
  SpecularLight : array[0..3] of glFloat = (1.0,1.0,1.0,1.0);
  SpecularReflection : array[0..3] of glFloat = (0.4,0.4,0.4,1.0);
  LightPosition : array[0..3] of glFloat;

SpecularLight enthält die Definition des Lichts, SpecularReflection ist die Intensität der Reflektionen unseres Materials.

  glEnable(GL_LIGHTING);
  glLightfv(GL_LIGHT0,GL_AMBIENT, @AmbientLight);
  glLightfv(GL_LIGHT0,GL_DIFFUSE, @DiffuseLight);
  glLightfv(GL_LIGHT0,GL_SPECULAR, @SpecularLight);
  glEnable(GL_LIGHT0);

  LightPosition[0] := 0.0;  LightPosition[1] := 0.0;
  LightPosition[2] := 0.0;  LightPosition[3] := 1.0;

  glLightfv(GL_LIGHT0,GL_POSITION,@LightPosition);

  glEnable(GL_COLOR_MATERIAL);
  glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
  glMaterialfv(GL_FRONT, GL_SPECULAR, @SpecularReflection);
  glMateriali(GL_FRONT,GL_SHININESS,10);

Zuerst fügen wir bei der Erstellung von LIGHT0 das direkte Licht hinzu und verweisen auf die Definition im Array.

Bei der Definition des Materials setzen wir mit glMaterialfv(GL_FRONT, GL_SPECULAR, @SpecularReflection); die Definition der Reflektionen bzw. welcher Farbanteil der Lichtquelle reflektiert wird.

Schließlich definieren wir noch mit glMateriali(GL_FRONT,GL_SHININESS,10); wie die Reflektionen auf dem Material zu sehen sind. Bei 0 zieht sich eine Reflektion über die ganze Fläche hin, bei 128 handelt es sich um eine begrenzte, helle und sehr "scharfe" Reflektion.

Bei der Darstellung ändert sich nichts. Die Szene bleibt wie gehabt, nur die Beleuchtung ändert sich bzw. die Reflektionen kommen hinzu. Schaut es euch an und spielt damit - wie immer halt. Holt euch das Beispiel hier.

Delax/ Sundancer Inc.
[delax@sundancerinc.de]

Back to previous page

Useful Links









Link to us