1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- // ---------------------------------------------------------------------------
- #pragma hdrstop
- #include "fCustomQuadC.h"
- // ---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "GLS.BaseClasses"
- #pragma link "GLS.Behaviours"
- #pragma link "GLS.Cadencer"
- #pragma link "GLS.Coordinates"
- #pragma link "GLS.GeomObjects"
- #pragma link "GLS.Material"
- #pragma link "GLS.Objects"
- #pragma link "GLS.Scene"
- #pragma link "GLS.SceneViewer"
- #pragma link "GLS.Context"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- // ---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) {
- }
- // ---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender) {
- SetGLSceneMediaDir();
- // dynamically create 2 materials and load 2 textures
- GLMaterialLibrary->AddTextureMaterial("wood", "ashwood.jpg")
- ->Material->FrontProperties->Emission->Color = clrGray50;
- GLMaterialLibrary->AddTextureMaterial("wood", "ashwood.jpg")
- ->Material->FaceCulling = fcNoCull;
- GLMaterialLibrary->AddTextureMaterial("stone", "walkway.jpg")
- ->Material->FrontProperties->Emission->Color = clrGray50;
- GLMaterialLibrary->AddTextureMaterial("stone", "walkway.jpg")
- ->Material->FaceCulling = fcNoCull;
- }
- // ---------------------------------------------------------------------------
- void __fastcall TForm1::DirectOpenGL1Render(TObject *Sender,
- TGLRenderContextInfo &rci)
- {
- TGLLibMaterial *Material;
- // disable face culling
- //glDisable(GL_CULL_FACE);
- // 1st quad, textured with 'wood', using standard method
- GLMaterialLibrary->ApplyMaterial("wood", rci);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 1);
- glVertex3f(0.5, 0.5, -0.5);
- glTexCoord2f(0, 0);
- glVertex3f(-0.5, 0.5, -0.5);
- glTexCoord2f(1, 0);
- glVertex3f(-0.5, 0, 0.5);
- glTexCoord2f(1, 1);
- glVertex3f(0.5, 0, 0.5);
- glEnd;
- GLMaterialLibrary->UnApplyMaterial(rci);
- // 2nd quad, textured with 'stone'
- // we "manually" apply the material, this can be usefull if you want to have
- // some dynamic material control
- Material = GLMaterialLibrary->Materials->GetLibMaterialByName("stone");
- Material->Material->Apply(rci); // - unconsistent content
- glBegin(GL_QUADS);
- glTexCoord2f(0, 1);
- glVertex3f(0.5, -0.5, -0.5);
- glTexCoord2f(0, 0);
- glVertex3f(0.5, 0, 0.5);
- glTexCoord2f(1, 0);
- glVertex3f(-0.5, 0, 0.5);
- glTexCoord2f(1, 1);
- glVertex3f(-0.5, -0.5, -0.5);
- glEnd;
- Material->Material->UnApply(rci);
- // enable face culling again
- glEnable(GL_CULL_FACE);
- }
- // ---------------------------------------------------------------------------
|