Explorar el Código

Updated USE_SERVICE_CONTEXT workaround thnx NelsonChu etc.

GLScene hace 5 años
padre
commit
a149c9e26c

+ 1 - 1
Demos/Delphi/extrusion/cutoutstar/Unit1.pas

@@ -21,7 +21,7 @@ uses
   GLS.MultiPolygon,
   GLS.SceneViewer,
  
-  GLS.Coordinates, GLS.BaseClasses,,
+  GLS.Coordinates,
   GLS.BaseClasses;
 
 type

+ 1 - 1
Demos/Delphi/meshes/feedback/Unit1.pas

@@ -32,7 +32,7 @@ type
     GLCube1: TGLCube;
     GLFreeForm1: TGLFreeForm;
     Button1: TButton;
-    GLS.Feedback1: TGLS.Feedback;
+    GLS.Feedback1: TGLFeedback;
     GLDodecahedron1: TGLDodecahedron;
     MeshObject1: TGLDummyCube;
     MeshObject2: TGLDummyCube;

+ 2 - 2
Source/Format3DSUtils.pas

@@ -5854,12 +5854,12 @@ begin
   with Result do
   begin
     //--- header Information
-    NameStr := ansistring(NodeHdrChunk^.Data.NodeHdr^.ObjNameStr);
+    NameStr := AnsiString(NodeHdrChunk^.Data.NodeHdr^.ObjNameStr);
     Flags1 := NodeHdrChunk^.Data.NodeHdr^.Flags1;
     Flags2 := NodeHdrChunk^.Data.NodeHdr^.Flags2;
 
     //--- get parent name if there is one
-    ParentStr := ansistring(GetParentName(Source, NodeHdrChunk));
+    ParentStr := AnsiString(GetParentName(Source, NodeHdrChunk));
 
     //--- Instance
     if Assigned(InstData) then

+ 1 - 1
Source/GLS.Context.pas

@@ -23,7 +23,7 @@ uses
   VCL.Consts,
 
 {$IFDEF USE_SERVICE_CONTEXT}
-  GLSGenerics,
+  GLS.Generics,
 {$ENDIF}
 
   GLS.OpenGLTokens,

+ 2 - 0
Source/GLS.GeomObjects.pas

@@ -34,6 +34,8 @@ uses
   GLS.GeometryBB,
   GLS.VectorFileObjects,
   GLS.PipelineTransformation,
+  GLS.Material,
+  GLS.Texture,
 
   GLS.Context,
   GLS.Objects,

+ 4 - 4
Source/GLS.Graphics.pas

@@ -597,7 +597,6 @@ begin
   //
 end;
 
-
 // -------------------- RGBA Utils
 
 procedure GammaCorrectRGBArray(base: Pointer; pixelCount: Integer;
@@ -2010,8 +2009,8 @@ begin
     PBO.AllocateHandle;
     if PBO.IsDataNeedUpdate then
     begin
-      { This may work with multiple unshared context, but never tested
-        because unlikely. }
+      (* This may work with multiple unshared context, but never tested
+        because unlikely. *)
       PBO.BindBufferData(nil, MaxInteger(Size, 1024), GL_STREAM_DRAW);
       if Assigned(MapAddress) then
         if not PBO.UnmapBuffer then
@@ -2024,7 +2023,8 @@ begin
 
     if FSourceStream = nil then
     begin
-      FSourceStream := TFileStream.Create(ResourceName + IntToHex(FStreamLevel, 2));
+      FSourceStream := TFileStream.Create(ResourceName + 
+	  IntToHex(FStreamLevel,2), fmOpenRead + fmShareDenyNone);
     end;
 
     // Move to position of next piece and read it

+ 14 - 4
Source/GLS.PolygonTesselation.pas

@@ -34,7 +34,7 @@ implementation
 var
   TessMesh: TMeshObject;
   TessFace: TFGIndexTexCoordList;
-  TessExtraVertices: Integer;
+  TessVerticesCount, TessExtraVertices: Integer;
   TessVertices: PAffineVectorArray;
 
 procedure DoTessBegin(mode: Cardinal);
@@ -68,6 +68,14 @@ end;
 function AllocNewVertex: PAffineVector;
 begin
   Inc(TessExtraVertices);
+  
+  // Allocate more memory if needed
+  if TessExtraVertices > TessVerticesCount then
+  begin
+    TessVerticesCount := TessVerticesCount * 2;
+    Reallocmem(TessVertices, TessVerticesCount * SizeOf(TAffineVector));
+  end;
+  
   Result := @TessVertices[TessExtraVertices - 1];
 end;
 
@@ -92,10 +100,12 @@ begin
   end
   else
     TessMesh := Mesh.MeshObjects[0];
-
+	
+  // vertices count.
+  TessVerticesCount := Vertexes.Count;
   // allocate extra buffer used by GLU in complex polygons.
-  GetMem(TessVertices, Vertexes.Count * SizeOf(TAffineVector));
 
+  GetMem(TessVertices, TessVerticesCount * SizeOf(TAffineVector));
   // make a Tessellation GLU object.
   Tess := gluNewTess;
 
@@ -142,7 +152,7 @@ begin
   gluDeleteTess(tess);
 
   // deallocate extra buffer used by GLU in complex polygons.
-  FreeMem(TessVertices, Vertexes.Count * SizeOf(TAffineVector));
+  FreeMem(TessVertices, TessVerticesCount * SizeOf(TAffineVector));
 end;
 
 end.

+ 1 - 21
Source/GLS.Silhouette.pas

@@ -106,7 +106,7 @@ type
     function GetFaceCount: integer;
     function ReuseOrFindVertexID(const SeenFrom: TAffineVector; ASilhouette: TGLSilhouette; index: integer): integer;
   public
-    // Clears out all connectivity information. 
+    // Clears out all connectivity information.
     procedure Clear; virtual;
     procedure CreateSilhouette(const silhouetteParameters: TGLSilhouetteParameters; var ASilhouette: TGLSilhouette;
       AddToSilhouette: Boolean);
@@ -278,13 +278,10 @@ end;
 constructor TGLConnectivity.Create(APrecomputeFaceNormal: Boolean);
 begin
   FFaceVisible := TByteList.Create;
-
   FFaceVertexIndex := TIntegerList.Create;
   FFaceNormal := TAffineVectorList.Create;
-
   FEdgeVertices := TIntegerList.Create;
   FEdgeFaces := TIntegerList.Create;
-
   FPrecomputeFaceNormal := APrecomputeFaceNormal;
   FVertexMemory := TIntegerList.Create;
   FVertices := TAffineVectorList.Create;
@@ -293,19 +290,14 @@ end;
 destructor TGLConnectivity.Destroy;
 begin
   Clear;
-
   FFaceVisible.Free;
   FFaceVertexIndex.Free;
   FFaceNormal.Free;
-
   FEdgeVertices.Free;
   FEdgeFaces.Free;
-
   FVertexMemory.Free;
-
   if Assigned(FVertices) then
     FVertices.Free;
-
   inherited;
 end;
 
@@ -317,7 +309,6 @@ begin
   FFaceVertexIndex.Clear;
   FFaceNormal.Clear;
   FVertexMemory.Clear;
-
   if FVertices <> nil then
     FVertices.Clear;
 end;
@@ -337,10 +328,8 @@ begin
     ASilhouette := TGLSilhouette.Create
   else if not AddToSilhouette then
     ASilhouette.Flush;
-
   // Clear the vertex memory
   FVertexMemory.Flush;
-
   // Update visibility information for all Faces
   vis := FFaceVertexIndex.List;
   for i := 0 to FaceCount - 1 do
@@ -353,16 +342,13 @@ begin
       faceNormal := CalcPlaneNormal(verticesList^[vis^[0]], verticesList^[vis^[1]], verticesList^[vis^[2]]);
       faceIsVisible := (PointProject(silhouetteParameters.SeenFrom, FVertices.List^[vis^[0]], faceNormal) >= 0);
     end;
-
     FFaceVisible[i] := Byte(faceIsVisible);
-
     if (not faceIsVisible) and silhouetteParameters.CappingRequired then
       ASilhouette.CapIndices.Add(ReuseOrFindVertexID(silhouetteParameters.SeenFrom, ASilhouette, vis^[0]),
         ReuseOrFindVertexID(silhouetteParameters.SeenFrom, ASilhouette, vis^[1]),
         ReuseOrFindVertexID(silhouetteParameters.SeenFrom, ASilhouette, vis^[2]));
     vis := @vis[3];
   end;
-
   for i := 0 to EdgeCount - 1 do
   begin
     face0ID := FEdgeFaces[i * 2 + 0];
@@ -412,7 +398,6 @@ begin
   begin
     oldCount := FVertexMemory.Count;
     FVertexMemory.Count := index + 1;
-
     List := FVertexMemory.List;
     for i := oldCount to FVertexMemory.Count - 1 do
       List^[i] := -1;
@@ -452,7 +437,6 @@ begin
     end;
     edgesVertices := @edgesVertices[2];
   end;
-
   // No edge was found, create a new one
   FEdgeVertices.Add(vertexIndex0, vertexIndex1);
   FEdgeFaces.Add(FaceID, -1);
@@ -468,7 +452,6 @@ begin
 
   if FPrecomputeFaceNormal then
     FFaceNormal.Add(CalcPlaneNormal(FVertices.List^[Vi0], FVertices.List^[Vi1], FVertices.List^[vi2]));
-
   FaceID := FFaceVisible.Add(0);
   AddIndexedEdge(Vi0, Vi1, FaceID);
   AddIndexedEdge(Vi1, vi2, FaceID);
@@ -483,7 +466,6 @@ begin
   Vi0 := FVertices.FindOrAdd(vertex0);
   Vi1 := FVertices.FindOrAdd(vertex1);
   vi2 := FVertices.FindOrAdd(vertex2);
-
   result := AddIndexedFace(Vi0, Vi1, vi2);
 end;
 
@@ -495,10 +477,8 @@ begin
   Vi1 := FVertices.FindOrAdd(vertex1);
   vi2 := FVertices.FindOrAdd(vertex2);
   Vi3 := FVertices.FindOrAdd(vertex3);
-
   // First face
   result := AddIndexedFace(Vi0, Vi1, vi2);
-
   // Second face
   AddIndexedFace(vi2, Vi3, Vi0);
 end;