-
例子的基础知识:
界面设计:
界面关系描述:
object Form1: TForm1 Left = 290 Top = 175 Caption = 'Blur' ClientHeight = 462 ClientWidth = 518 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object GLSceneViewer: TGLSceneViewer Left = 0 Top = 45 Width = 518 Height = 417 Camera = GLCamera1//相机 Buffer.FogEnvironment.FogColor.Color = {1283003F1283003F0000803F0000803F} Buffer.FogEnvironment.FogStart = 1.000000000000000000 Buffer.FogEnvironment.FogEnd = 3.000000000000000000 Buffer.BackgroundColor = clBackground Buffer.AmbientColor.Color = {0000000000000000000000000000803F} FieldOfView = 153.029327392578100000 Align = alClient OnMouseMove = GLSceneViewerMouseMove//鼠标事件 TabOrder = 0 end object Panel1: TPanel Left = 0 Top = 0 Width = 518 Height = 45 Align = alTop Caption = ' ' TabOrder = 1 object Label1: TLabel Left = 8 Top = 4 Width = 54 Height = 13 Caption = 'Blur Preset:' FocusControl = ComboBox1 end object Label2: TLabel Left = 216 Top = 4 Width = 61 Height = 13 Caption = 'Render Size:' FocusControl = ComboBox2 end object LabelFPS: TLabel Left = 376 Top = 26 Width = 20 Height = 13 Caption = 'FPS' end object ComboBox1: TComboBox Left = 8 Top = 20 Width = 161 Height = 21 Style = csDropDownList ItemIndex = 0 TabOrder = 0 Text = 'pNone (no change)' OnClick = ComboBox1Click Items.Strings = ( 'pNone (no change)' 'pGlossy' 'pBeastView' 'pOceanDepth' 'pDream' 'pOverBlur' 'pAdvancedBlur') end object ComboBox2: TComboBox Left = 216 Top = 20 Width = 145 Height = 21 Style = csDropDownList ItemIndex = 5 TabOrder = 1 Text = '256' OnChange = ComboBox2Change Items.Strings = ( '8' '16' '32' '64' '128' '256' '512') end end object GLScene1: TGLScene ObjectsSorting = osRenderFarthestFirst Left = 44 Top = 64 object GLLightSource1: TGLLightSource//光源 Ambient.Color = {BEC0403FBEC0403FBEC0403F0000803F} ConstAttenuation = 1.000000000000000000 Diffuse.Color = {BEC0403FBEC0403FBEC0403F0000803F} Position.Coordinates = {56551B40F9FF2D40F6FF3B400000803F} LightStyle = lsOmni SpotCutOff = 180.000000000000000000 end object GLCube1: TGLCube//立方体 Material.MaterialLibrary = GLMaterialLibrary1//材质 Material.LibMaterialName = 'LibMaterial' Direction.Coordinates = {82B16B3E068E77BF3986DFBD00000000} PitchAngle = -95.500000000000000000 Position.Coordinates = {DB9FEC3E806395BE509F213F0000803F} TurnAngle = 6.500000000000000000 Up.Coordinates = {DD7324BEE3EB17BE6BCE793F00000000} end object GLSphere1: TGLSphere//球 Material.MaterialLibrary = GLMaterialLibrary2//材质 Material.LibMaterialName = 'LibMaterial' Position.Coordinates = {6E3D38BF0A5515BE733C1CBF0000803F} Radius = 0.500000000000000000 end object GLDummyCube1: TGLDummyCube// CubeSize = 1.000000000000000000 end object GLCamera1: TGLCamera//相机 DepthOfView = 100.000000000000000000 FocalLength = 50.000000000000000000 NearPlaneBias = 0.100000001490116100 TargetObject = GLDummyCube1 Position.Coordinates = {41A38A3F6847033F2894FA3F0000803F} Direction.Coordinates = {A5C4F6BE96EA77BE3E9257BF00000000} Up.Coordinates = {B74DF6BD4B62783F582A57BE00000000} end end object GLMaterialLibrary1: TGLMaterialLibrary Materials = < item Name = 'LibMaterial' Tag = 0 Material.Texture.ImageClassName = 'TGLPicFileImage'//Texture是一个关注点 Material.Texture.Image.PictureFileName = 'marbletiles.jpg'//程序运行时要加载相片 Material.Texture.MagFilter = maNearest Material.Texture.MinFilter = miNearest Material.Texture.TextureMode = tmModulate Material.Texture.Compression = tcNone Material.Texture.Disabled = False end> TexturePaths = '..\..\..\..\media\'//相片的路径 Left = 140 Top = 64 end object GLCadencer1: TGLCadencer//动画节拍器 Scene = GLScene1 SleepLength = 0 OnProgress = GLCadencer1Progress//节拍事件 Left = 44 Top = 144 end object Timer1: TTimer OnTimer = Timer1Timer Left = 260 Top = 64 end object GLMaterialLibrary2: TGLMaterialLibrary//第二个材质库 Materials = < item Name = 'LibMaterial' Tag = 0 Material.Texture.ImageClassName = 'TGLPicFileImage' Material.Texture.Image.PictureFileName = 'marbletiles.jpg' Material.Texture.MagFilter = maNearest Material.Texture.MinFilter = miNearest Material.Texture.TextureMode = tmModulate Material.Texture.Compression = tcNone Material.Texture.Disabled = False end> TexturePaths = '..\..\..\..\media\' Left = 400 Top = 88 end end
代码控制:
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, GLWin32Viewer, GLScene, GLObjects, GLTexture, GLHudObjects, GLCompositeImage, GLFileJPEG, GLCadencer, StdCtrls, ExtCtrls, GLBlur, GLCrossPlatform, GLMaterial, GLCoordinates, BaseClasses, Jpeg, GLUtils; type TForm1 = class(TForm) GLScene1: TGLScene; GLCamera1: TGLCamera; GLMaterialLibrary1: TGLMaterialLibrary; GLCube1: TGLCube; GLLightSource1: TGLLightSource; GLSceneViewer: TGLSceneViewer; GLCadencer1: TGLCadencer; GLSphere1: TGLSphere; Panel1: TPanel; ComboBox1: TComboBox; Label1: TLabel; Label2: TLabel; ComboBox2: TComboBox; Timer1: TTimer; GLDummyCube1: TGLDummyCube; LabelFPS: TLabel; GLMaterialLibrary2: TGLMaterialLibrary; procedure FormCreate(Sender: TObject); procedure GLCadencer1Progress(Sender: TObject; const deltaTime, newTime: Double); procedure ComboBox1Click(Sender: TObject); procedure ComboBox2Change(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure GLSceneViewerMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); private { Private declarations } oldx, oldy: integer; public { Public declarations } B: TGLBlur; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin SetGLSceneMediaDir(); // Add GLBlur to scene B := TGLBlur.Create(self); GLSphere1.AddChild(B); B.TargetObject := GLCube1; B.RenderWidth := 256; B.RenderHeight := 256; // Load texture for objects GLMaterialLibrary1.Materials[0].Material.Texture.Image.LoadFromFile('HPIM5446.JPG');//加载相片 GLMaterialLibrary2.Materials[0].Material.Texture.Image.LoadFromFile('HPIM5446.JPG'); ComboBox1.ItemIndex := 1; ComboBox2.ItemIndex := 2; ComboBox1Click(self); end; procedure TForm1.GLCadencer1Progress(Sender: TObject; const deltaTime, newTime: Double); begin GLCube1.Turn(deltatime * 10); GLSphere1.Turn(deltatime * 50); end; procedure TForm1.ComboBox1Click(Sender: TObject); begin B.Preset := TGLBlurPreset(ComboBox1.itemIndex); end; procedure TForm1.ComboBox2Change(Sender: TObject); begin B.RenderWidth := StrToInt(ComboBox2.Items[ComboBox2.ItemIndex]); B.RenderHeight := B.RenderWidth; end; procedure TForm1.Timer1Timer(Sender: TObject); begin LabelFPS.Caption := FloatToStr(Trunc(GLSceneViewer.FramesPerSecond))+ ' FPS'; // GLSceneViewer.ResetPerformanceMonitor; end; procedure TForm1.GLSceneViewerMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if ssLeft in Shift then begin GLCamera1.MoveAroundTarget(1 * (oldy - y), 1 * (oldx - x)); end; oldx := x; oldy := y; end; end.
相关推荐
delphi的glscene最新版例子和源代码大集合,内容很全
delphi用Glscene做的小程序,视窗缩放、旋转,物体的选取、移动等。对初学Glscene有帮助。
glscene包用一delphi
在CSDN的Delphi游戏及图形处理板块中网友凌风写过一篇不错的帖子,讲述GLScene的基本应用,另外还将GLScene的帮助文档翻译后制成电子档共享给大家。 也感谢培客网的方育华提供的这份资源。 觉得应该共享,拿出来和...
delphi GLScene Demos and Samples delphi GLScene Demos and Samples delphi GLScene Demos and Samples
GLScene中文帮助文档,3D开发的利器,希望对大家有用。
亲自测量,可用的Delphi第三方控件GLScene包。
and 10.3 Rio,delphi,图像,图形,3D控件,包含演示源代码,网上找了很久 基本都不能用于DELPHI XE10,要不编译失败,要不代码不兼容,这个已经在32位程序输出,系统64位win10,XE10.3环境下测试成功的,有英文安装...
delphi glscene demo 源代码演示大全
GLScene知道是什么是吧,基于OpenGL的3D开发包,是目前delphi下最好的。 安装时会出现GLScene.inc not found的错误,把Source下的GLScene.inc拷到包所在目录即可 enjoy it!
GLScene_Ear_water
delphi glscene控件 一个不错的3d delphi 控件
GLScene是一个基于OpenGL的Delphi,C ++ Builder和Lazarus的3D库。它提供可视组件和对象,允许在图形应用程序中描述和渲染3D场景
使用到了 GLScene 控件组 <br>本例只在介绍初步TGLScene的使用
GLScene 1.1 Full Source D7-XE7.rar
The release of GLScene v2.1 for Embarcadero RAD Studio Delphi & C++Builder 11.0 3D绘图组件 最新版V2.1 Extended support for third-party libraries GR32, BASS, FMOD, OpenAL, ODE and Newton. The ...
一个茶壶的旋转的小实例
Delphi 下最新的一套3D组件,十分强大,带几十个Demo,做OpenGL开发的朋友可下载看看。 带有安装方法。
GLScene is an OpenGL based 3D library for Delphi. It provides visual components and objects allowing description and rendering of 3D scenes in an easy, no-hassle, yet powerfull manner.
Glscene实例,包含glscene很多动态属性和方法