Стартовый пул

This commit is contained in:
2024-04-02 08:46:59 +03:00
parent fd57fffd3a
commit 3bb34d000b
5591 changed files with 3291734 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="opengltest1"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="BGRABitmapPack"/>
</Item1>
<Item2>
<PackageName Value="lazopenglcontext"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="opengltest1.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="opengltest1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@@ -0,0 +1,21 @@
program opengltest1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, lazopenglcontext, Unit1
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@@ -0,0 +1,10 @@
object Form1: TForm1
Left = 230
Height = 240
Top = 121
Width = 320
Caption = 'Ground test'
OnCreate = FormCreate
OnDestroy = FormDestroy
LCLVersion = '1.4.0.4'
end

View File

@@ -0,0 +1,156 @@
unit Unit1;
{
-For using OpenGl with BGRABitmap and LCl:
-Add two packages (take a look at project inspector!)
-Then you need a TOpenGLControl and do create stuff and setting events
-If you want OpenGl speed you should use a texture again and again, dont make it each time unless it is necceray so here we will load them once
-For making texture you can use TBGLBitmap or IBGLTexture
-TBGLBitmap is like a TBGRABitmap with OpenGl stuff and a texture property, you can draw, load and whatever here and then use its texture and if you dont need it later free it.
-IBGLTexture is an interface so you dont need to free it,just use it and note that it will use less memory
-After loading you need to draw background with BGLViewPort
-After that draw your textures with BGLCanvas. for more info just take a look at it's class
-In the end do SwapBuffers so all you paint goes to buffer and will draw
-For more info you should check other demos, classes, Wiki or ask on the forum
http://forum.lazarus.freepascal.org/index.php?board=46.0
}
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
OpenGLContext, BGRABitmap, BGRABitmapTypes, BGRAOpenGL;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ private declarations }
OriginalBounds: TRect;
OriginalWindowState: TWindowState;
procedure SwitchFullScreen;
public
bmp: TBGLBitmap;
Tex: IBGLTexture;
OpenGLControl: TOpenGLControl;
DataLoaded: boolean;
procedure Load;
procedure Unload;
procedure OpenGLControlDblClick(Sender: TObject);
procedure OpenGLControlPaint(Sender: TObject);
procedure OpenGLControlMouseMove(Sender: TObject; {%H-}Shift: TShiftState; {%H-}X, {%H-}Y: integer);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.SwitchFullScreen;
begin
if BorderStyle <> bsNone then begin
// To full screen
OriginalWindowState := WindowState;
OriginalBounds := BoundsRect;
BorderStyle := bsNone;
BoundsRect := Screen.MonitorFromWindow(Handle).BoundsRect;
end else begin
// From full screen
BorderStyle := bsSizeable;
if OriginalWindowState = wsMaximized then
WindowState := wsMaximized
else
BoundsRect := OriginalBounds;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
OpenGLControl := TOpenGLControl.Create(Self);
with OpenGLControl do
begin
Align := alClient;
Parent := Self;
OnPaint := @OpenGLControlPaint;
OnMouseMove := @OpenGLControlMouseMove;
OnDblClick := @OpenGLControlDblClick;
//If you dont do it,you will have some problems
AutoResizeViewport := True;
end;
DataLoaded := False;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
OpenGLControl.Free;
end;
procedure TForm1.Load;
var path: string;
begin
if not DataLoaded then
begin
path := ExtractFilePath(Application.ExeName) + '..' + PathDelim + 'tux_game' + PathDelim + 'ground.png';
//Do this :
//Way1
//Tex := BGLTexture(path);
//Or this for more editing options
//Way2
bmp := TBGLBitmap.Create(path);
bmp.Rectangle(0,0,bmp.Width,bmp.Height,BGRABlack,dmSet);
Tex:=bmp.MakeTextureAndFree;
//Or whatever you want!
DataLoaded := True;
end;
end;
procedure TForm1.Unload;
begin
if DataLoaded then
begin
Tex := nil;
DataLoaded := False;
end;
end;
// double-click to switch to full screen
procedure TForm1.OpenGLControlDblClick(Sender: TObject);
begin
Unload; //context may change when switching to full-screen
SwitchFullScreen;
end;
procedure TForm1.OpenGLControlPaint(Sender: TObject);
var
mousePos: TPoint;
begin
{ Load data }
Load;
{ Draw Background }
BGLViewPort(OpenGLControl.Width, OpenGLControl.Height, BGRAWhite);
{ Draw Texture }
mousePos := ScreenToClient(Mouse.CursorPos);
BGLCanvas.PutImage(mousePos.x - Tex.Width div 2, mousePos.y - Tex.Height div 2, Tex);
{ Update }
OpenGLControl.SwapBuffers;
end;
procedure TForm1.OpenGLControlMouseMove(Sender: TObject; Shift: TShiftState; X, Y: integer);
begin
OpenGLControl.DoOnPaint;
end;
end.