You've already forked lazarus-ccr
initial import of files
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1801 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
96
components/nvidia-widgets/src/nvwidgets/examples/example.lpi
Normal file
96
components/nvidia-widgets/src/nvwidgets/examples/example.lpi
Normal file
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveClosedFiles Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="3">
|
||||
<Unit0>
|
||||
<Filename Value="example.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="example"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="..\nvglwidgets.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="nvGLWidgets"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\..\nvglutils\nvShaderUtils.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="nvShaderUtils"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="example"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..;..\..\nvglutils"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<AllowLabel Value="False"/>
|
||||
<CPPInline Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
191
components/nvidia-widgets/src/nvwidgets/examples/example.pp
Normal file
191
components/nvidia-widgets/src/nvwidgets/examples/example.pp
Normal file
@ -0,0 +1,191 @@
|
||||
program example;
|
||||
|
||||
{$mode objfpc}
|
||||
{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
GLut, GL, GLu,
|
||||
nvWidgets, nvGlutWidgets, nvGLWidgets, nvShaderUtils;
|
||||
|
||||
type
|
||||
UIOption = (
|
||||
OPTION_DIFF,
|
||||
OPTION_DXT5_YCOCG,
|
||||
OPTION_COMPRESS,
|
||||
OPTION_ANIMATE,
|
||||
OPTION_THUMBNAIL,
|
||||
OPTION_COUNT);
|
||||
|
||||
var
|
||||
options: array [UIOption] of boolean;
|
||||
ui: GlutUIContext;
|
||||
win_w: integer = 512;
|
||||
win_h: integer = 512;
|
||||
errorScale: double = 4;
|
||||
compressionRate: double = 1;
|
||||
texture: GLuint = 0;
|
||||
|
||||
procedure closeapp;
|
||||
begin
|
||||
FreeAndNil(ui);
|
||||
halt(0);
|
||||
end;
|
||||
|
||||
procedure idle; cdecl;
|
||||
begin
|
||||
glutPostRedisplay;
|
||||
end;
|
||||
|
||||
procedure key(k: byte; x: integer; y: integer); cdecl;
|
||||
begin
|
||||
ui.keyboard(k, x, y);
|
||||
|
||||
case k of
|
||||
27, Ord('q'):
|
||||
closeapp;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure special(key: integer; x: integer; y: integer); cdecl;
|
||||
begin
|
||||
ui.specialKeyboard(key, x, y);
|
||||
end;
|
||||
|
||||
procedure resize(w: integer; h: integer); cdecl;
|
||||
begin
|
||||
ui.reshape(w, h);
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
win_w := w;
|
||||
win_h := h;
|
||||
end;
|
||||
|
||||
procedure mouse(button: integer; state: integer; x: integer; y: integer); cdecl;
|
||||
begin
|
||||
ui.mouse(button, state, x, y);
|
||||
end;
|
||||
|
||||
procedure motion(x: integer; y: integer); cdecl;
|
||||
begin
|
||||
ui.mouseMotion(x, y);
|
||||
end;
|
||||
|
||||
procedure doUI;
|
||||
const
|
||||
formatLabel: array [0..1] of string = ('YCoCg-DXT5', 'DXT1');
|
||||
var
|
||||
none: Rect;
|
||||
formatIdx: integer;
|
||||
Text: string;
|
||||
textureRect: Rect;
|
||||
begin
|
||||
none.Rect(0, 0);
|
||||
|
||||
ui._begin;
|
||||
|
||||
ui.beginGroup(GroupFlags_GrowDownFromLeft);
|
||||
|
||||
ui.doCheckButton(none, 'Enable compression', options[OPTION_COMPRESS]);
|
||||
|
||||
if options[OPTION_COMPRESS] then
|
||||
begin
|
||||
ui.beginGroup(GroupFlags_GrowLeftFromTop or GroupFlags_LayoutNoMargin);
|
||||
ui.doCheckButton(none, 'Show difference', options[OPTION_DIFF]);
|
||||
|
||||
if options[OPTION_DIFF] then
|
||||
ui.doHorizontalSlider(none, 1, 16, errorScale);
|
||||
|
||||
ui.endGroup;
|
||||
|
||||
ui.beginGroup(GroupFlags_GrowLeftFromTop);
|
||||
ui.doLabel(none, 'Format');
|
||||
|
||||
if options[OPTION_DXT5_YCOCG] then
|
||||
formatIdx := 0
|
||||
else
|
||||
formatIdx := 1;
|
||||
|
||||
ui.doComboBox(none, 2, formatLabel, formatIdx);
|
||||
options[OPTION_DXT5_YCOCG] := formatIdx = 0;
|
||||
ui.endGroup;
|
||||
end;
|
||||
|
||||
ui.doCheckButton(none, 'Display dummy texture', options[OPTION_THUMBNAIL]);
|
||||
|
||||
if options[OPTION_THUMBNAIL] then
|
||||
begin
|
||||
textureRect.Rect(0, 0, 100, 100);
|
||||
ui.doTextureView(textureRect, texture, textureRect);
|
||||
end;
|
||||
ui.endGroup;
|
||||
|
||||
if options[OPTION_COMPRESS] then
|
||||
begin
|
||||
ui.beginGroup(GroupFlags_GrowDownFromRight);
|
||||
|
||||
if ui.doButton(none, 'Benchmark') then
|
||||
begin
|
||||
// doBenchmark = true;
|
||||
end;
|
||||
|
||||
if compressionRate <> 0 then
|
||||
begin
|
||||
Text := Format('%.2d Mpixels/sec', [100]);
|
||||
ui.doLabel(none, Text);
|
||||
end;
|
||||
|
||||
ui.endGroup;
|
||||
end;
|
||||
|
||||
// Pass non-ui mouse events to the manipulator
|
||||
//updateManipulator(ui, manipulator);
|
||||
ui._end;
|
||||
end;
|
||||
|
||||
procedure display; cdecl;
|
||||
begin
|
||||
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
glLoadIdentity;
|
||||
doUI;
|
||||
glutSwapBuffers;
|
||||
end;
|
||||
|
||||
var
|
||||
texture_data: array [0..3] of cardinal = ($FFFF0000, $FF0000FF, $FF00FF00, $FF00FF00);
|
||||
|
||||
begin
|
||||
glutInit(@argc, argv);
|
||||
glutInitWindowSize(win_w, win_h);
|
||||
glutInitDisplayMode(GLUT_DOUBLE or GLUT_DEPTH or GLUT_RGB);
|
||||
glutCreateWindow('UI example');
|
||||
|
||||
ui := GlutUIContext.Create;
|
||||
|
||||
if not ui.init(win_w, win_h) then
|
||||
begin
|
||||
writeln('UI initialization failed');
|
||||
closeapp;
|
||||
end;
|
||||
|
||||
glutReportErrors;
|
||||
|
||||
glGenTextures(1, @texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, @texture_data);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glClearColor(0, 0, 0, 1);
|
||||
glutDisplayFunc(@display);
|
||||
|
||||
glutMouseFunc(@mouse);
|
||||
glutMotionFunc(@motion);
|
||||
glutPassiveMotionFunc(@motion);
|
||||
glutIdleFunc(@idle);
|
||||
glutKeyboardFunc(@key);
|
||||
glutSpecialFunc(@special);
|
||||
glutReshapeFunc(@resize);
|
||||
glutMainLoop;
|
||||
end.
|
||||
|
Reference in New Issue
Block a user