------------------------
//Buttons
//--------------------------------------------------------------------------TExampleForm.LightingButton1Click(Sender: TObject); lighted then glDisable (GL_LIGHTING) else glEnable (GL_LIGHTING);:=not lighted; .Invalidate;//not need; TExampleForm.BlendButton1Click (Sender: TObject);:=not blended; .Invalidate ;; TExampleForm.MoveCubeButton1Click ( Sender: TObject);:=not MoveCube; .Invalidate ;; TExampleForm.MoveBackgroundButton1Click (Sender: TObject);:=not MoveBackground; .Invalidate ;; TExampleForm.RotateZButton1Click (Sender: TObject) ;. Start; .Invalidate ;; TExampleForm. RotateZButton2Click (Sender: TObject);:=not ParticleBlended; .Invalidate ;;
//++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++
//---------------------------------------------------------------------------TExampleForm.FormResize(Sender: TObject); OpenGLControl1 lt; gt; nil then.SetBounds (10, 30, Width - 120, Height - 40) ;. SetBounds (Width - 90, 5, 80, 25) ;. SetBounds (Width - 90, 50, 80, 25) ;; TExampleForm.ExitButton1Click (Sender: TObject) ;;; TExampleForm.OpenGLControl1Paint (Sender: TObject); myInit;
{init lighting variables}
{ambient color} [0]:=0.5; [1]:=0.5; [2]:=0.5; [3]:=1.0;
{diffuse color} [0]:=0.8; [1]:=0.0; [2]:=0.0; [3]:=1.0;
{diffuse position} [0]:=0.0; [1]:=0.0; [2]:=3.0; [3]:=1.0;
{diffuse 2 color} dif [0]:=0.0; dif [1]:=0.8; dif [2]:=0.0; dif [3]:=1.0;
{diffuse 2 position} pos [0]:=3.0; pos [1]:=0.0; pos [2]:=3.0; pos [3]:=1.0;
{diffuse 3 color} dif [0]:=0.0; dif [1]:=0.0; dif [2]:=0.8; dif [3]:=1.0;
{diffuse 3 position} pos [0]:=- 3.0; pos [1]:=0.0; pos [2]:=0.0; pos [3]:=1.0;
{fog color} [0]:=0.5; [1]:=0.5; [2]:=0.5; [3]:=1.0 ;; GLInitialized: boolean=false; InitGL ;: Integer; GLInitialized then exit;:=true;
{setting lighting conditions}(GL_LIGHT0,GL_AMBIENT,lightamb);(GL_LIGHT1,GL_AMBIENT,lightamb);(GL_LIGHT2,GL_DIFFUSE,lightdif);(GL_LIGHT2,GL_POSITION,lightpos);(GL_LIGHT3,GL_DIFFUSE,light2dif);(GL_LIGHT3,GL_POSITION,light2pos);(GL_LIGHT4,GL_POSITION,light3pos);(GL_LIGHT4,GL_DIFFUSE,light3dif);(GL_LIGHT0);(GL_LIGHT1);(GL_LIGHT2);(GL_LIGHT3);(GL_LIGHT4);(3, textures [0]); i:=0 to 2 do begin (GL_TEXTURE_2D, Textures[i]);(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);D(GL_TEXTURE_2D,0,3,MyglTextures[i].Width,MyglTextures[i].Height,0
,GL_RGB,GL_UNSIGNED_BYTE,MyglTextures[i].Data);;(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
{instead of GL_MODULATE you can try GL_DECAL or GL_BLEND} (GL_TEXTURE_2D);// Enables 2d textures (0.0,0.0,0.0,1.0);// Sets background color (1.0); (GL_LEQUAL);// The type of depth test to do (GL_DEPTH_TEST);// Enables depth testing (GL_SMOOTH);// Enables smooth color shading
{blending} f (1.0,1.0,1.0,0.5);// Full Brightness, 50% Alpha (NEW) (GL_SRC_ALPHA, GL_ONE); (GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
{}(GL_LINE_SMOOTH_HINT,GL_NICEST);(GL_POLYGON_SMOOTH_HINT,GL_NICEST);(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
//creating display lists:=glGenLists (1); (ParticleList, GL_COMPILE); (GL_TEXTURE_2D, textures [0]); (GL_TRIANGLE_STRIP); f (0.0, 0.0, 1.0); f ( 1.0, 1.0); glVertex3f (+0.025, +0.025, 0); f (0.0, 5.0); glVertex3f (- 0.025, +0.025, 0); f (1.0, 0.0); glVertex3f (+0.025, - 0.025, 0); f (0.0, 0.0); glVertex3f (- 0.025, - 0.025, 0) ;;;:=ParticleList + 1; (BackList, GL_COMPILE); (GL_TEXTURE_2D, textures [2]); (GL_QUADS);
{Front Face} f (0.0, 0.0, 1.0); f (1.0, 1.0); glVertex3f (2.5, 2.5, 2.5); f (0.0, 1.0); glVertex3f (- 2.5, 2.5, 2.5); f (0.0, 0.0); glVertex3f (- 2.5, - 2.5, 2.5); f (1.0, 0.0); glVertex3f (2.5, - 2.5, 2.5);
{Back Face} f (0.0, 0.0, - 1.0); f (0.0, 1.0); glVertex3f (2.5, 2.5, - 2.5); f (0.0, 0.0); glVertex3f (2.5, - 2.5, - 2.5); f (1.0, 0.0); glVertex3f (- 2.5, - 2.5, - 2.5); f (1.0, 1.0); glVertex3f (- 2.5, 2.5, - 2.5);
{Left Face} f (- 1.0, 0.0, 0.0); f (1.0, 1.0); glVertex3f (- 2.5, 2.5, 2.5); f (0.0, 1.0); glVertex3f (- 2.5, 2.5, - 2.5); f (0.0, 0.0); glVertex3f (- 2.5, - 2.5, - 2.5); f (1.0, 0.0); glVertex3f (- 2.5, - 2.5, 2.5);
{Right Face} f (1.0, 0.0, 0.0); f (1.0, 1.0); glVertex3f (2.5, 2.5, - 2.5); f (0.0, 1.0); glVertex3f (2.5, 2.5, 2.5); f (0.0, 0.0); glVertex3f (2.5, - 2.5, 2.5); f (1.0, 0.0); glVertex3f (2.5, - 2.5, - 2.5);