- procedure TCad3D.RenderObjects;
- var
- i: Integer;
- begin
- //glDisable(GL_DEPTH_TEST);
- glEnable(GL_DEPTH_TEST);
- //glEnable(GL_Normalize);
- //glFrontFace(GL_CW);
- if Culling then
- glEnable(GL_CULL_FACE)
- else
- glDisable(GL_CULL_FACE);
- if AntiAliasing then
- glEnable(GL_LINE_SMOOTH)
- else
- glDisable(GL_LINE_SMOOTH);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity;
- if Wireframe then
- glPolygonmode(GL_FRONT_AND_BACK, GL_LINE)
- else
- glPolygonmode(GL_FRONT_AND_BACK, GL_FILL);
- FColorBackGround := SetAlpha(FColorBackGround, 0);
- Objects.ObjekteSortieren(FCamera.CameraPosition, FCamera.PointOfRotation);
- //http://www.delphigl.com/forum/viewtopic.php?f=2&t=5107&start=15&hilit=transparente+objekte
- glDisable(GL_BLEND);
- for i := 0 to Objects.Count - 1 do
- with Objects.Items[i] do
- if AlphaComponent(Color[0]) >= 255 then
- begin
- DrawObjects(i, 0);
- end;
- glEnable(GL_BLEND);
- for i := 0 to Objects.Count - 1 do
- with Objects.Items[i] do
- if AlphaComponent(Color[0]) < 255 then
- begin
- //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); <- 1. Foto Renderer aus Wiki
- glBlendFunc(GL_ONE_MINUS_DST_ALPHA,GL_DST_ALPHA); //test <- 2. Foto- Renderer aus Forum
- glDepthFunc(GL_GREATER);
- glDepthMask(FALSE);
- DrawObjects(i, 1);
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- glPolygonmode(GL_FRONT_AND_BACK, GL_LINE);
- glLineWidth(2);
- DrawObjects(i, 2);
- glPopAttrib;
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDepthFunc(GL_LEQUAL);
- glDepthMask(true);
- DrawObjects(i, 3);
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- glPolygonmode(GL_FRONT_AND_BACK, GL_LINE);
- glLineWidth(2);
- DrawObjects(i, 4);
- glPopAttrib;
- end;
- glDepthFunc(GL_GREATER);
- glDepthMask(FALSE);
- glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
- for i := 0 to Objects.Count - 1 do
- with Objects.Items[i] do
- if AlphaComponent(Color[0]) >= 255 then
- begin
- DrawObjects(i, 5);
- end;
- if Axis then
- Draw.DrawAxis(AxisLength, ColorAxis1);
- glDisable(GL_BLEND);
- glDepthFunc(GL_LEQUAL);
- glDepthMask(True);
- for i := 0 to Objects.Count - 1 do
- with Objects.Items[i] do
- if AlphaComponent(Color[0]) >= 255 then
- begin
- DrawObjects(i, 6);
- end;
- if Axis then
- Draw.DrawAxis(AxisLength, ColorAxis1);
- end;