Skip to content

Commit 6f35aac

Browse files
committed
add example for r3d
1 parent 975f3c4 commit 6f35aac

File tree

15 files changed

+1380
-167
lines changed

15 files changed

+1380
-167
lines changed

examples/extra/r3d/directional/r3d_directional.lpr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ TRayApplication = class(TCustomApplication)
1717
material: TMaterial;
1818
camera: TCamera3D;
1919
transforms: PMatrix;
20-
//transforms: array of TMatrix;
2120
procedure Init;
2221
procedure Update;
2322
procedure Draw;

examples/extra/r3d/fog/r3d_fog.lpi

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CONFIG>
3+
<ProjectOptions>
4+
<Version Value="12"/>
5+
<General>
6+
<Flags>
7+
<MainUnitHasCreateFormStatements Value="False"/>
8+
<MainUnitHasTitleStatement Value="False"/>
9+
<MainUnitHasScaledStatement Value="False"/>
10+
</Flags>
11+
<SessionStorage Value="InProjectDir"/>
12+
<Title Value="r3d_fog"/>
13+
<UseAppBundle Value="False"/>
14+
<ResourceType Value="res"/>
15+
</General>
16+
<BuildModes>
17+
<Item Name="Default" Default="True"/>
18+
</BuildModes>
19+
<PublishOptions>
20+
<Version Value="2"/>
21+
<UseFileFilters Value="True"/>
22+
</PublishOptions>
23+
<RunParams>
24+
<FormatVersion Value="2"/>
25+
</RunParams>
26+
<RequiredPackages>
27+
<Item>
28+
<PackageName Value="ray4laz"/>
29+
</Item>
30+
</RequiredPackages>
31+
<Units>
32+
<Unit>
33+
<Filename Value="r3d_fog.lpr"/>
34+
<IsPartOfProject Value="True"/>
35+
</Unit>
36+
</Units>
37+
</ProjectOptions>
38+
<CompilerOptions>
39+
<Version Value="11"/>
40+
<Target>
41+
<Filename Value="../../../../binary/r3d_fog"/>
42+
</Target>
43+
<SearchPaths>
44+
<IncludeFiles Value="$(ProjOutDir)"/>
45+
<UnitOutputDirectory Value="../../../../temp/$(TargetCPU)-$(TargetOS)"/>
46+
</SearchPaths>
47+
<Linking>
48+
<Debugging>
49+
<DebugInfoType Value="dsDwarf3"/>
50+
</Debugging>
51+
</Linking>
52+
</CompilerOptions>
53+
<Debugging>
54+
<Exceptions>
55+
<Item>
56+
<Name Value="EAbort"/>
57+
</Item>
58+
<Item>
59+
<Name Value="ECodetoolError"/>
60+
</Item>
61+
<Item>
62+
<Name Value="EFOpenError"/>
63+
</Item>
64+
</Exceptions>
65+
</Debugging>
66+
</CONFIG>

examples/extra/r3d/fog/r3d_fog.lpr

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
program r3d_fog;
2+
3+
{$mode objfpc}{$H+}
4+
5+
uses
6+
{$IFDEF LINUX} cthreads,{$ENDIF}
7+
Classes, SysUtils, CustApp, raylib, r3d;
8+
9+
type
10+
{ TRayApplication }
11+
TRayApplication = class(TCustomApplication)
12+
protected
13+
procedure DoRun; override;
14+
private
15+
sponza: TModel;
16+
camera: TCamera3D;
17+
procedure Init;
18+
procedure Update;
19+
procedure Draw;
20+
Procedure Close;
21+
public
22+
constructor Create(TheOwner: TComponent); override;
23+
destructor Destroy; override;
24+
end;
25+
26+
const AppTitle = '[r3d] - fog example';
27+
28+
{ TRayApplication }
29+
30+
constructor TRayApplication.Create(TheOwner: TComponent);
31+
begin
32+
inherited Create(TheOwner);
33+
34+
InitWindow(800, 600, AppTitle); // for window settings, look at example - window flags
35+
Init;
36+
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
37+
end;
38+
39+
procedure TRayApplication.DoRun;
40+
begin
41+
42+
while (not WindowShouldClose) do // Detect window close button or ESC key
43+
begin
44+
// Update your variables here
45+
Update;
46+
// Draw
47+
BeginDrawing();
48+
Draw;
49+
EndDrawing();
50+
end;
51+
52+
// Stop program loop
53+
Terminate;
54+
end;
55+
56+
procedure TRayApplication.Init;
57+
var i: integer;
58+
light: TR3D_Light;
59+
begin
60+
R3D_Init(GetScreenWidth(), GetScreenHeight(), 0);
61+
SetTargetFPS(60);
62+
63+
sponza := LoadModel('resources/sponza.glb');
64+
65+
for i := 0 to sponza.materialCount -1 do
66+
begin
67+
sponza.materials[i].maps[MATERIAL_MAP_ALBEDO].color := WHITE;
68+
sponza.materials[i].maps[MATERIAL_MAP_OCCLUSION].value := 1.0;
69+
sponza.materials[i].maps[MATERIAL_MAP_ROUGHNESS].value := 1.0;
70+
sponza.materials[i].maps[MATERIAL_MAP_METALNESS].value := 1.0;
71+
end;
72+
73+
R3D_SetFogMode(R3D_FOG_EXP);
74+
75+
light := R3D_CreateLight(R3D_LIGHT_DIR);
76+
R3D_SetLightDirection(light, Vector3Create( 0, -1, 0 ));
77+
R3D_SetLightActive(light, true);
78+
79+
camera.Create(Vector3Create(0,0,0), Vector3Create(0,0,-1), Vector3Create(0,1,0), 60);
80+
81+
DisableCursor();
82+
83+
end;
84+
85+
procedure TRayApplication.Update;
86+
begin
87+
UpdateCamera(@camera, CAMERA_FREE);
88+
end;
89+
90+
procedure TRayApplication.Draw;
91+
begin
92+
R3D_Begin(camera);
93+
R3D_DrawModel(sponza, Vector3Create(0,0,0), 1.0);
94+
R3D_End();
95+
96+
DrawFPS(10, 10);
97+
end;
98+
99+
procedure TRayApplication.Close;
100+
begin
101+
UnloadModel(sponza);
102+
R3D_Close();
103+
end;
104+
105+
destructor TRayApplication.Destroy;
106+
begin
107+
Close;
108+
CloseWindow(); // Close window and OpenGL context
109+
110+
// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
111+
TraceLog(LOG_INFO, 'your first window is close and destroy');
112+
113+
inherited Destroy;
114+
end;
115+
116+
var
117+
Application: TRayApplication;
118+
begin
119+
Application:=TRayApplication.Create(nil);
120+
Application.Title:=AppTitle;
121+
Application.Run;
122+
Application.Free;
123+
end.
124+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CONFIG>
3+
<ProjectOptions>
4+
<Version Value="12"/>
5+
<General>
6+
<Flags>
7+
<MainUnitHasCreateFormStatements Value="False"/>
8+
<MainUnitHasTitleStatement Value="False"/>
9+
<MainUnitHasScaledStatement Value="False"/>
10+
</Flags>
11+
<SessionStorage Value="InProjectDir"/>
12+
<Title Value="r3d_instanced"/>
13+
<UseAppBundle Value="False"/>
14+
<ResourceType Value="res"/>
15+
</General>
16+
<BuildModes>
17+
<Item Name="Default" Default="True"/>
18+
</BuildModes>
19+
<PublishOptions>
20+
<Version Value="2"/>
21+
<UseFileFilters Value="True"/>
22+
</PublishOptions>
23+
<RunParams>
24+
<FormatVersion Value="2"/>
25+
</RunParams>
26+
<RequiredPackages>
27+
<Item>
28+
<PackageName Value="ray4laz"/>
29+
</Item>
30+
</RequiredPackages>
31+
<Units>
32+
<Unit>
33+
<Filename Value="r3d_instanced.lpr"/>
34+
<IsPartOfProject Value="True"/>
35+
</Unit>
36+
</Units>
37+
</ProjectOptions>
38+
<CompilerOptions>
39+
<Version Value="11"/>
40+
<Target>
41+
<Filename Value="../../../../binary/r3d_instanced"/>
42+
</Target>
43+
<SearchPaths>
44+
<IncludeFiles Value="$(ProjOutDir)"/>
45+
<UnitOutputDirectory Value="../../../../temp/$(TargetCPU)-$(TargetOS)"/>
46+
</SearchPaths>
47+
<Linking>
48+
<Debugging>
49+
<DebugInfoType Value="dsDwarf3"/>
50+
</Debugging>
51+
</Linking>
52+
</CompilerOptions>
53+
<Debugging>
54+
<Exceptions>
55+
<Item>
56+
<Name Value="EAbort"/>
57+
</Item>
58+
<Item>
59+
<Name Value="ECodetoolError"/>
60+
</Item>
61+
<Item>
62+
<Name Value="EFOpenError"/>
63+
</Item>
64+
</Exceptions>
65+
</Debugging>
66+
</CONFIG>

0 commit comments

Comments
 (0)