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.

OpenGL/ FPC - Chapter 15 - by Delax

Now to the last type of light. And as usual, we do need additional variables fo it.

  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 contains the definitions of our light and SpecularReflection is the intensity of the reflections on 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);

Now we create our LIGHT0 with the new values for specular light. We also set some new definitions in our material definitions. We tell OpenGL that our materials reflect the specular light. We also define the shininess of the materials with glMateriali(GL_FRONT,GL_SHININESS,10);

The main scene stays the same. Only the light is different now. As always: play around with it. Get the example here.

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

Back to previous page

Useful Links









Link to us