Browse Source

* implemented OpenGLES renderer

master
Bergmann89 9 years ago
parent
commit
ddc79b5b1b
7 changed files with 668 additions and 219 deletions
  1. +1
    -6
      examples/simple/TextSuiteTest.lpi
  2. +189
    -178
      examples/simple/TextSuiteTest.lps
  3. +2
    -2
      utsFontCreatorFreeType.pas
  4. +24
    -29
      utsOpenGLUtils.pas
  5. +2
    -4
      utsRendererOpenGL.pas
  6. +417
    -0
      utsRendererOpenGLES.pas
  7. +33
    -0
      utsTypes.pas

+ 1
- 6
examples/simple/TextSuiteTest.lpi View File

@@ -44,7 +44,6 @@
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uMainForm"/>
</Unit1>
<Unit2>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
@@ -72,7 +71,6 @@
<Unit7>
<Filename Value="..\..\utsFontCreatorGDI.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsFontCreatorGDI"/>
</Unit7>
<Unit8>
<Filename Value="..\..\utsCodePages.pas"/>
@@ -85,17 +83,14 @@
<Unit10>
<Filename Value="..\..\utsFontCreatorFreeType.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsFontCreatorFreeType"/>
</Unit10>
<Unit11>
<Filename Value="..\..\utsGDI.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsGDI"/>
</Unit11>
<Unit12>
<Filename Value="..\..\utsFreeType.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsFreeType"/>
</Unit12>
<Unit13>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
@@ -112,7 +107,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);old"/>
<OtherUnitFiles Value="..\..;..\..\old;..\..\OpenGLCore"/>
<OtherUnitFiles Value="..\..;..\..\old;..\..\OpenGLCore;..\..\..\dglOpenGLES"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>


+ 189
- 178
examples/simple/TextSuiteTest.lps View File

@@ -4,7 +4,7 @@
<PathDelim Value="\"/>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="65">
<Units Count="67">
<Unit0>
<Filename Value="TextSuiteTest.lpr"/>
<IsPartOfProject Value="True"/>
@@ -18,7 +18,6 @@
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uMainForm"/>
<EditorIndex Value="-1"/>
<TopLine Value="140"/>
<CursorPos X="59" Y="154"/>
@@ -28,8 +27,10 @@
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsRendererOpenGL"/>
<TopLine Value="48"/>
<CursorPos X="36" Y="65"/>
<IsVisibleTab Value="True"/>
<WindowIndex Value="1"/>
<TopLine Value="171"/>
<CursorPos Y="187"/>
<UsageCount Value="70"/>
<Loaded Value="True"/>
</Unit2>
@@ -37,10 +38,8 @@
<Filename Value="..\..\utsTextSuite.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsTextSuite"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="310"/>
<CursorPos X="51" Y="324"/>
<TopLine Value="216"/>
<CursorPos X="55" Y="316"/>
<UsageCount Value="70"/>
<Loaded Value="True"/>
</Unit3>
@@ -54,10 +53,11 @@
<Filename Value="..\..\utsTypes.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsTypes"/>
<EditorIndex Value="-1"/>
<TopLine Value="93"/>
<CursorPos X="5" Y="109"/>
<EditorIndex Value="4"/>
<TopLine Value="173"/>
<CursorPos X="59" Y="191"/>
<UsageCount Value="70"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="..\..\utsUtils.pas"/>
@@ -70,10 +70,8 @@
<Unit7>
<Filename Value="..\..\utsFontCreatorGDI.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsFontCreatorGDI"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<WindowIndex Value="-1"/>
<TopLine Value="517"/>
<CursorPos Y="526"/>
<UsageCount Value="70"/>
@@ -97,7 +95,6 @@
<Unit10>
<Filename Value="..\..\utsFontCreatorFreeType.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsFontCreatorFreeType"/>
<EditorIndex Value="-1"/>
<TopLine Value="237"/>
<CursorPos X="51" Y="339"/>
@@ -106,7 +103,6 @@
<Unit11>
<Filename Value="..\..\utsGDI.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsGDI"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="284"/>
@@ -116,7 +112,6 @@
<Unit12>
<Filename Value="..\..\utsFreeType.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsFreeType"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="292"/>
@@ -124,13 +119,33 @@
<UsageCount Value="46"/>
</Unit12>
<Unit13>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsOpenGLUtils"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<TopLine Value="206"/>
<CursorPos X="40" Y="220"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="..\..\utsRendererOpenGLES.pas"/>
<UnitName Value="utsRendererOpenGLES"/>
<EditorIndex Value="1"/>
<TopLine Value="172"/>
<CursorPos Y="12"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit14>
<Unit15>
<Filename Value="new\utsTextSuite.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1886"/>
<CursorPos X="33" Y="1904"/>
<UsageCount Value="89"/>
</Unit13>
<Unit14>
</Unit15>
<Unit16>
<Filename Value="old\TextSuite.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
@@ -143,237 +158,236 @@
<CursorPos X="3" Y="302"/>
</ExtraEditor1>
<UsageCount Value="84"/>
</Unit14>
<Unit15>
</Unit16>
<Unit17>
<Filename Value="old\TextSuiteImports.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="656"/>
<CursorPos X="20" Y="635"/>
<UsageCount Value="84"/>
</Unit15>
<Unit16>
</Unit17>
<Unit18>
<Filename Value="old\TextSuiteWideUtils.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="1243"/>
<CursorPos X="18" Y="1257"/>
<UsageCount Value="84"/>
</Unit16>
<Unit17>
</Unit18>
<Unit19>
<Filename Value="old\TextSuiteClasses.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="654"/>
<CursorPos X="25" Y="673"/>
<UsageCount Value="84"/>
</Unit17>
<Unit18>
</Unit19>
<Unit20>
<Filename Value="old\TextSuitePostProcess.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="163"/>
<CursorPos X="61" Y="141"/>
<UsageCount Value="84"/>
</Unit18>
<Unit19>
</Unit20>
<Unit21>
<Filename Value="old\TextSuiteTTFUtils.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="83"/>
<CursorPos X="3" Y="91"/>
<UsageCount Value="84"/>
</Unit19>
<Unit20>
</Unit21>
<Unit22>
<Filename Value="old\TextSuiteVersion.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/>
<UsageCount Value="84"/>
</Unit20>
<Unit21>
</Unit22>
<Unit23>
<Filename Value="new\utsFontCreatorGDI.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="655"/>
<CursorPos X="53" Y="662"/>
<UsageCount Value="48"/>
</Unit21>
<Unit22>
</Unit23>
<Unit24>
<Filename Value="new\utsTtfUtils.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="128"/>
<CursorPos X="17" Y="144"/>
<UsageCount Value="40"/>
</Unit22>
<Unit23>
</Unit24>
<Unit25>
<Filename Value="new\utsTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="152"/>
<CursorPos X="5" Y="168"/>
<UsageCount Value="40"/>
</Unit23>
<Unit24>
</Unit25>
<Unit26>
<Filename Value="new\utsUtils.pas"/>
<EditorIndex Value="-1"/>
<CursorPos Y="20"/>
<UsageCount Value="40"/>
</Unit24>
<Unit25>
</Unit26>
<Unit27>
<Filename Value="new\utsRendererOpenGL.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="356"/>
<CursorPos X="20" Y="376"/>
<UsageCount Value="37"/>
</Unit25>
<Unit26>
</Unit27>
<Unit28>
<Filename Value="..\bitSpace\_projects\MassiveUniverseOnline\bitSpaceEngine\src\OpenGLCore\uglcTypes.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="261"/>
<CursorPos X="3" Y="277"/>
<UsageCount Value="35"/>
</Unit26>
<Unit27>
</Unit28>
<Unit29>
<Filename Value="..\bitSpace\_projects\MassiveUniverseOnline\bitSpaceEngine\src\OpenGLCore\dglOpenGL.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1066"/>
<CursorPos X="27" Y="1082"/>
<UsageCount Value="30"/>
</Unit27>
<Unit28>
</Unit29>
<Unit30>
<Filename Value="new\uglctextsuite.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="3" Y="13"/>
<UsageCount Value="11"/>
</Unit28>
<Unit29>
</Unit30>
<Unit31>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\ustringh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="113"/>
<CursorPos X="10" Y="129"/>
<UsageCount Value="38"/>
</Unit29>
<Unit30>
</Unit31>
<Unit32>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\ustrings.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="2091"/>
<CursorPos X="5" Y="2098"/>
<UsageCount Value="21"/>
</Unit30>
<Unit31>
</Unit32>
<Unit33>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\systemh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="502"/>
<CursorPos X="3" Y="518"/>
<UsageCount Value="36"/>
</Unit31>
<Unit32>
</Unit33>
<Unit34>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\heaph.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="71"/>
<CursorPos X="10" Y="95"/>
<UsageCount Value="24"/>
</Unit32>
<Unit33>
</Unit34>
<Unit35>
<Filename Value="old\TextSuiteCPUUtils.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<CursorPos X="23" Y="20"/>
<UsageCount Value="14"/>
</Unit33>
<Unit34>
</Unit35>
<Unit36>
<Filename Value="..\glBitmap\glBitmap\glBitmap.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="14" Y="14"/>
<UsageCount Value="2"/>
</Unit34>
<Unit35>
</Unit36>
<Unit37>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\objpas\math.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="1011"/>
<CursorPos X="47" Y="1015"/>
<UsageCount Value="6"/>
</Unit35>
<Unit36>
</Unit37>
<Unit38>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\mathh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="84"/>
<CursorPos X="14" Y="101"/>
<UsageCount Value="6"/>
</Unit36>
<Unit37>
</Unit38>
<Unit39>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\genmath.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="152"/>
<CursorPos X="10" Y="155"/>
<UsageCount Value="6"/>
</Unit37>
<Unit38>
</Unit39>
<Unit40>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\dynlibs.pas"/>
<UnitName Value="dynlibs"/>
<EditorIndex Value="-1"/>
<TopLine Value="143"/>
<CursorPos X="3" Y="149"/>
<UsageCount Value="30"/>
</Unit38>
<Unit39>
</Unit40>
<Unit41>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\win\dynlibs.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="26"/>
<CursorPos X="10" Y="42"/>
<UsageCount Value="28"/>
</Unit39>
<Unit40>
</Unit41>
<Unit42>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\win\sysosh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="11"/>
<CursorPos X="3" Y="19"/>
<UsageCount Value="11"/>
</Unit40>
<Unit41>
</Unit42>
<Unit43>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\objpash.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="177"/>
<CursorPos X="22" Y="195"/>
<UsageCount Value="15"/>
</Unit41>
<Unit42>
</Unit43>
<Unit44>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\objpas\sysutils\sysunih.inc"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="25"/>
<CursorPos X="34" Y="43"/>
<UsageCount Value="26"/>
</Unit42>
<Unit43>
</Unit44>
<Unit45>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\packages\fcl-base\src\syncobjs.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="113"/>
<CursorPos X="25" Y="115"/>
<UsageCount Value="16"/>
</Unit43>
<Unit44>
</Unit45>
<Unit46>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\objpas\classes\classesh.inc"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="311"/>
<CursorPos X="14" Y="327"/>
<UsageCount Value="23"/>
</Unit44>
<Unit45>
</Unit46>
<Unit47>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\inc\objpas.inc"/>
<EditorIndex Value="-1"/>
<UsageCount Value="29"/>
</Unit45>
<Unit46>
</Unit47>
<Unit48>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\include\control.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="2843"/>
<CursorPos Y="2858"/>
<UsageCount Value="13"/>
</Unit46>
<Unit47>
</Unit48>
<Unit49>
<Filename Value="C:\Users\Erik\Desktop\RectPacking\unit1.pas"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
@@ -383,252 +397,249 @@
<TopLine Value="376"/>
<CursorPos X="74" Y="397"/>
<UsageCount Value="21"/>
</Unit47>
<Unit48>
</Unit49>
<Unit50>
<Filename Value="..\bitSpace\_projects\MassiveUniverseOnline\bitSpaceEngine\src\OpenGLCore\uglcArrayBuffer.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="102"/>
<CursorPos X="37" Y="112"/>
<UsageCount Value="10"/>
</Unit48>
<Unit49>
</Unit50>
<Unit51>
<Filename Value="..\bitSpace\_projects\MassiveUniverseOnline\bitSpaceEngine\src\OpenGLCore\uglcBitmap.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="1047"/>
<CursorPos X="15" Y="1043"/>
<UsageCount Value="8"/>
</Unit49>
<Unit50>
</Unit51>
<Unit52>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\objpas\objpas.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="19"/>
<CursorPos X="8" Y="35"/>
<UsageCount Value="8"/>
</Unit50>
<Unit51>
</Unit52>
<Unit53>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\include\application.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="966"/>
<CursorPos Y="981"/>
<UsageCount Value="8"/>
</Unit51>
<Unit52>
</Unit53>
<Unit54>
<Filename Value="..\bitSpace\_projects\MassiveUniverseOnline\bitSpaceEngine\src\SpaceEngine\uengFrameLimiter.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="14"/>
<CursorPos X="13" Y="14"/>
<UsageCount Value="8"/>
</Unit52>
<Unit53>
</Unit54>
<Unit55>
<Filename Value="..\..\old\TextSuiteClasses.pas"/>
<UnitName Value="TextSuiteClasses"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="2705"/>
<CursorPos X="3" Y="2698"/>
<UsageCount Value="18"/>
</Unit53>
<Unit54>
</Unit55>
<Unit56>
<Filename Value="..\..\old\TextSuite.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="29"/>
<CursorPos X="3" Y="45"/>
<UsageCount Value="14"/>
</Unit54>
<Unit55>
</Unit56>
<Unit57>
<Filename Value="..\..\old\TextSuiteWideUtils.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="1362"/>
<CursorPos X="3" Y="1390"/>
<UsageCount Value="14"/>
</Unit55>
<Unit56>
</Unit57>
<Unit58>
<Filename Value="..\..\utsWideStringUtils.pas"/>
<EditorIndex Value="-1"/>
<CursorPos Y="9"/>
<UsageCount Value="18"/>
</Unit56>
<Unit57>
</Unit58>
<Unit59>
<Filename Value="..\..\old\TextSuiteCPUUtils.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<UsageCount Value="13"/>
</Unit57>
<Unit58>
</Unit59>
<Unit60>
<Filename Value="..\..\old\TextSuiteImports.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<CursorPos X="41" Y="12"/>
<UsageCount Value="13"/>
</Unit58>
<Unit59>
</Unit60>
<Unit61>
<Filename Value="..\..\old\TextSuiteOptions.inc"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<UsageCount Value="13"/>
</Unit59>
<Unit60>
</Unit61>
<Unit62>
<Filename Value="..\..\old\TextSuitePostProcess.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="261"/>
<CursorPos X="23" Y="345"/>
<UsageCount Value="13"/>
</Unit60>
<Unit61>
</Unit62>
<Unit63>
<Filename Value="..\..\old\TextSuiteTTFUtils.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<UsageCount Value="13"/>
</Unit61>
<Unit62>
</Unit63>
<Unit64>
<Filename Value="..\..\old\TextSuiteVersion.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<UsageCount Value="13"/>
</Unit62>
<Unit63>
</Unit64>
<Unit65>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\2.7.1\source\rtl\win\wininc\unifun.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="53"/>
<CursorPos X="22" Y="69"/>
<UsageCount Value="26"/>
</Unit63>
<Unit64>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utsOpenGLUtils"/>
</Unit65>
<Unit66>
<Filename Value="..\..\..\dglOpenGLES\dglOpenGLES.pas"/>
<UnitName Value="dglOpenGLES"/>
<EditorIndex Value="2"/>
<TopLine Value="297"/>
<CursorPos X="31" Y="382"/>
<UsageCount Value="21"/>
<TopLine Value="64"/>
<CursorPos X="48" Y="74"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit64>
</Unit66>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="24" Column="57" TopLine="5"/>
<Filename Value="..\..\utsRendererOpenGLES.pas"/>
<Caret Line="17" Column="22" TopLine="5"/>
</Position1>
<Position2>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="327" TopLine="317"/>
<Filename Value="..\..\..\dglOpenGLES\dglOpenGLES.pas"/>
</Position2>
<Position3>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="335" Column="17" TopLine="317"/>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="210" Column="38" TopLine="196"/>
</Position3>
<Position4>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="26" Column="60" TopLine="8"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="378" Column="31" TopLine="297"/>
</Position4>
<Position5>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="69" Column="15" TopLine="54"/>
<Caret Line="21" Column="26" TopLine="5"/>
</Position5>
<Position6>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="27" Column="66" TopLine="10"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="54" TopLine="39"/>
</Position6>
<Position7>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="55" TopLine="55"/>
<Caret Line="53" TopLine="41"/>
</Position7>
<Position8>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="177" TopLine="171"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="143" Column="120" TopLine="133"/>
</Position8>
<Position9>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="9" Column="52"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="74" Column="15" TopLine="63"/>
</Position9>
<Position10>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="17" Column="15"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="191" Column="5" TopLine="177"/>
</Position10>
<Position11>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="55" Column="48" TopLine="39"/>
<Caret Line="132" Column="3" TopLine="128"/>
</Position11>
<Position12>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="58" Column="59" TopLine="39"/>
<Caret Line="190" Column="24" TopLine="176"/>
</Position12>
<Position13>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="102" Column="18" TopLine="81"/>
<Filename Value="..\..\utsTypes.pas"/>
<Caret Line="186" Column="55" TopLine="170"/>
</Position13>
<Position14>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="128" Column="30" TopLine="120"/>
<Caret Line="190" Column="24" TopLine="176"/>
</Position14>
<Position15>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="102" Column="18" TopLine="81"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="192" Column="7" TopLine="174"/>
</Position15>
<Position16>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="19" Column="119" TopLine="3"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="194" Column="45" TopLine="178"/>
</Position16>
<Position17>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="63" Column="7" TopLine="46"/>
<Caret Line="53" TopLine="9"/>
</Position17>
<Position18>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="153" Column="29" TopLine="137"/>
<Caret Line="198" Column="12" TopLine="187"/>
</Position18>
<Position19>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="20" Column="7" TopLine="3"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="207" Column="7" TopLine="187"/>
</Position19>
<Position20>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="122" Column="41" TopLine="106"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="205" Column="22" TopLine="189"/>
</Position20>
<Position21>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="22" Column="15" TopLine="6"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="216" TopLine="192"/>
</Position21>
<Position22>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="137" Column="27" TopLine="121"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="207" Column="71" TopLine="193"/>
</Position22>
<Position23>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="170" Column="15" TopLine="154"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="274" Column="17" TopLine="259"/>
</Position23>
<Position24>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="227" TopLine="199"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="18" Column="5" TopLine="2"/>
</Position24>
<Position25>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="30" Column="17" TopLine="15"/>
<Caret Line="75" Column="5" TopLine="73"/>
</Position25>
<Position26>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="81" Column="34" TopLine="64"/>
<Caret Line="62" Column="67" TopLine="47"/>
</Position26>
<Position27>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="211" Column="14" TopLine="200"/>
<Caret Line="19" Column="15" TopLine="3"/>
</Position27>
<Position28>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="74" Column="40" TopLine="53"/>
<Filename Value="..\..\..\dglOpenGLES\dglOpenGLES.pas"/>
<Caret Line="59" Column="33" TopLine="52"/>
</Position28>
<Position29>
<Filename Value="..\..\utsTextSuite.pas"/>
<Caret Line="973" TopLine="957"/>
<Filename Value="..\..\utsRendererOpenGL.pas"/>
<Caret Line="191" Column="39" TopLine="171"/>
</Position29>
<Position30>
<Filename Value="..\..\utsTextSuite.pas"/>
<Caret Line="1502" Column="61" TopLine="1496"/>
<Filename Value="..\..\utsOpenGLUtils.pas"/>
<Caret Line="225" Column="19" TopLine="206"/>
</Position30>
</JumpHistory>
</ProjectSession>


+ 2
- 2
utsFontCreatorFreeType.pas View File

@@ -5,7 +5,7 @@ unit utsFontCreatorFreeType;
interface

uses
Classes, SysUtils, syncobjs, dynlibs,
Classes, SysUtils,
utsTextSuite, utsTypes, utsFreeType;

type
@@ -315,7 +315,7 @@ begin
if (err <> 0) then
raise EtsException.Create('unable to set char size: error=' + IntToStr(err));

FillByte(prop, SizeOf(prop), 0);
FillByte(prop{%H-}, SizeOf(prop), 0);
prop.AntiAliasing := tsAANormal;
prop.FaceName := face^.family_name;
prop.StyleName := face^.style_name;


+ 24
- 29
utsOpenGLUtils.pas View File

@@ -5,19 +5,16 @@ unit utsOpenGLUtils;
interface

uses
Classes, SysUtils, syncobjs,
Classes, SysUtils,
utsTextSuite, utsTypes;

type
TtsQuadPosF = array[0..3] of TtsPositionF;
TtsCharRenderRefOpenGL = class(TtsCharRenderRef)
public
TextureID: Integer; // ID of OpenGL texture where the char is stored in
TexCoordSize: TtsPositionF; // size of the char in texture coords (0.0 - 1.0)
TexCoordPos: TtsPositionF; // position of the char in texture coords (0.0 - 1.0)
VertexSize: TtsPositionF; // size of the char in world coords
VertexPos: TtsPositionF; // size of the char in world coords

Size: TtsPosition;
TexMat: TtsMatrix4f;
VertMat: TtsMatrix4f;
constructor Create;
end;

@@ -61,9 +58,8 @@ type

function CreateNewTexture: PtsFontTexture; virtual;
procedure FreeTexture(var aTexture: PtsFontTexture); virtual;
procedure UploadTexData(const aCharRef: TtsCharRenderRefOpenGL;
const aCharImage: TtsImage; const X, Y: Integer); virtual;

procedure UploadTexData(const aCharRef: TtsCharRenderRefOpenGL; const aCharImage: TtsImage; const X, Y: Integer); virtual;
protected
function CreateRenderRef(const aChar: TtsChar; const aCharImage: TtsImage): TtsCharRenderRef; override;
procedure FreeRenderRef(const aCharRef: TtsCharRenderRef); override;
@@ -92,10 +88,9 @@ constructor TtsCharRenderRefOpenGL.Create;
begin
inherited Create;
TextureID := 0;
FillByte(TexCoordPos, SizeOf(TexCoordPos), 0);
FillByte(TexCoordSize, SizeOf(TexCoordSize), 0);
FillByte(VertexPos, SizeOf(VertexPos), 0);
FillByte(VertexSize, SizeOf(VertexSize), 0);
FillByte(TexMat, SizeOf(TexMat), 0);
FillByte(VertMat, SizeOf(VertMat), 0);
FillByte(Size, SizeOf(Size), 0);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -152,8 +147,7 @@ begin
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsBaseOpenGL.UploadTexData(const aCharRef: TtsCharRenderRefOpenGL;
const aCharImage: TtsImage; const X, Y: Integer);
procedure TtsBaseOpenGL.UploadTexData(const aCharRef: TtsCharRenderRefOpenGL; const aCharImage: TtsImage; const X, Y: Integer);
begin
// DUMMY
end;
@@ -211,21 +205,22 @@ var
item := InsertToTree(aTexture^.Usage, 0, 0, aTexture^.Size, aTexture^.Size, x, y);
if not Assigned(item) then
raise EtsRendererOpenGL.Create('unable to add glyph to texture');

item^.ref := TtsCharRenderRefOpenGL.Create;
result := item^.ref;

// Text Coords
result.TextureID := aTexture^.ID;
result.TexCoordPos.x := x / aTexture^.Size;
result.TexCoordPos.y := y / aTexture^.Size;
result.TexCoordSize.x := aCharImage.Width / aTexture^.Size;
result.TexCoordSize.y := aCharImage.Height / aTexture^.Size;
// Vertex Coords
result.VertexPos.x := -aChar.GlyphRect.Left;
result.VertexPos.y := -aChar.GlyphRect.Top - aChar.GlyphOrigin.y;
result.VertexSize.x := aCharImage.Width;
result.VertexSize.y := aCharImage.Height;
result.TextureID := aTexture^.ID;
result.Size := tsPosition(aCharImage.Width, aCharImage.Height);
result.TexMat := tsMatrix4f(
tsVector4f(aCharImage.Width / aTexture^.Size, 0.0, 0.0, 0.0),
tsVector4f(0.0, aCharImage.Height / aTexture^.Size, 0.0, 0.0),
tsVector4f(0.0, 0.0, 1.0, 0.0),
tsVector4f(x / aTexture^.Size, y / aTexture^.Size, 0.0, 1.0));
result.VertMat := tsMatrix4f(
tsVector4f(aCharImage.Width, 0.0, 0.0, 0.0),
tsVector4f(0.0, aCharImage.Height, 0.0, 0.0),
tsVector4f(0.0, 0.0, 1.0, 0.0),
tsVector4f(-aChar.GlyphRect.Left, -aChar.GlyphRect.Top - aChar.GlyphOrigin.y, 0.0, 1.0));

UploadTexData(result, aCharImage, x, y);
end;
@@ -281,8 +276,8 @@ var
w := X2 - X1;
h := Y2 - Y1;
if not Assigned(aItem) or
(w < ref.VertexSize.x) or
(h < ref.VertexSize.y) then
(w < ref.Size.x) or
(h < ref.Size.y) then
exit;

result := (aItem^.ref = ref);


+ 2
- 4
utsRendererOpenGL.pas View File

@@ -184,13 +184,11 @@ begin
glMatrixMode(GL_TEXTURE);
glPushMatrix;
glLoadIdentity;
glTranslatef(ref.TexCoordPos.x, ref.TexCoordPos.y, 0);
glScalef(ref.TexCoordSize.x, ref.TexCoordSize.y, 1);
glMultMatrixf(@ref.TexMat[0, 0]);

glMatrixMode(GL_MODELVIEW);
glPushMatrix;
glTranslatef(ref.VertexPos.x, ref.VertexPos.y, 0);
glScalef(ref.VertexSize.x, ref.VertexSize.y, 1);
glMultMatrixf(@ref.VertMat[0, 0]);

glBindBuffer(GL_ARRAY_BUFFER, fVBO);
glEnableClientState(GL_VERTEX_ARRAY);


+ 417
- 0
utsRendererOpenGLES.pas View File

@@ -0,0 +1,417 @@
unit utsRendererOpenGLES;

{$mode objfpc}{$H+}
{.$DEFINE DEBUG}

interface

uses
Classes, SysUtils,
utsTextSuite, utsTypes, utsOpenGLUtils, dglOpenGLES;

type
TtsRendererOpenGLES = class(TtsBaseOpenGL)
private
fModelViewMatrix: TtsMatrix4f;
fProjMatrix: TtsMatrix4f;
fShaderProgram: GLuint;
fVBO: GLuint;
fShader: GLuint;

fCharPosLocation: GLint;
fCharTexPosLocation: GLint;
fCharOffsetLocation: GLint;

procedure SetModelViewMatrix(aValue: TtsMatrix4f);
procedure SetProjectionMatrix(aValue: TtsMatrix4f);
procedure SetShaderProgram(aValue: GLuint);

function LoadShader: GLuint;

procedure UpdateUniformProjMat;
procedure UpdateUniformModelMat;
procedure UpdateUniformCharOffset;
protected
function CreateNewTexture: PtsFontTexture; override;
procedure FreeTexture(var aTexture: PtsFontTexture); override;
procedure UploadTexData(const aCharRef: TtsCharRenderRefOpenGL;
const aCharImage: TtsImage; const X, Y: Integer); override;

procedure BeginRender; override;

procedure SetDrawPos(const X, Y: Integer); override;
procedure MoveDrawPos(const X, Y: Integer); override;
procedure SetColor(const aColor: TtsColor4f); override;
procedure Render(const aCharRef: TtsCharRenderRef); override;
public
property ShaderProgram: GLuint read fShaderProgram write SetShaderProgram;
property ProjectionMatrix: TtsMatrix4f read fProjMatrix write SetProjectionMatrix;
property ModelViewMatrix: TtsMatrix4f read fModelViewMatrix write SetModelViewMatrix;

constructor Create(const aContext: TtsContext; const aFormat: TtsFormat);
destructor Destroy; override;
end;

implementation

type
TVertex = packed record
pos: array[0..1] of GLfloat;
tex: array[0..1] of GLfloat;
end;

const
ATTRIB_LOCATION_POSITION = 0;
ATTRIB_LOCATION_TEXCOORD = 1;
ATTRIB_NAME_POSITION = 'inPosition';
ATTRIB_NAME_TEXCOORD = 'inTexCoord';
UNIFORM_NAME_TEXTURE = 'uTexture';
UNIFORM_NAME_MODELVIEWMAT = 'uModelViewMat';
UNIFORM_NAME_PROJMAT = 'uProjMat';
UNIFORM_NAME_CHARTEXPOS = 'uCharTexPos';
UNIFORM_NAME_CHARPOS = 'uCharPos';
UNIFORM_NAME_CHAROFFSET = 'uCharOffset';
VERTEX_SHADER =
'attribute vec2 inPosition;' +
'attribute vec2 inTexCoord;' +
'varying vec2 vTexCoord;' +
'uniform mat4 uModelViewMat;' +
'uniform mat4 uProjMat;' +
'uniform mat4 uCharTexPos;' +
'uniform mat4 uCharPos;' +
'uniform ivec2 uCharOffset;' +
'void main() {' +
' vec4 pos = uCharPos * vec4(inPosition, 0.0, 1.0);' +
' pos += vec4(uCharOffset, 0.0, 0.0);' +
' gl_Position = uProjMat * uModelViewMat * pos;' +
' vTexCoord = (uCharTexPos * vec4(inTexCoord, 0.0, 1.0)).st;' +
'}';
FRAGMENT_SHADER =
'uniform sampler2D uTexture;' +
'varying vec2 vTexCoord;' +
'void main() {' +
' gl_FragColor = texture2D(uTexture, vTexCoord);' +
'}';

FORMAT_TYPES: array[TtsFormat] of packed record
InternalFormat: GLenum;
Format: GLenum;
DataFormat: GLenum;
end = (
( //tsFormatEmpty
InternalFormat: 0;
Format: 0;
DataFormat: 0),
( //tsFormatRGBA8
InternalFormat: GL_RGBA;
Format: GL_RGBA;
DataFormat: GL_UNSIGNED_BYTE),
( //tsFormatLumAlpha8
InternalFormat: GL_LUMINANCE_ALPHA;
Format: GL_LUMINANCE_ALPHA;
DataFormat: GL_UNSIGNED_BYTE),
( //tsFormatAlpha8
InternalFormat: GL_ALPHA;
Format: GL_ALPHA;
DataFormat: GL_UNSIGNED_BYTE),
( //tsFormatAlpha8
InternalFormat: GL_LUMINANCE;
Format: GL_LUMINANCE;
DataFormat: GL_UNSIGNED_BYTE)
);

VBO_DATA: array[0..3] of TVertex = (
(pos: (0.0, 0.0); tex: (0.0, 0.0)),
(pos: (0.0, 1.0); tex: (0.0, 1.0)),
(pos: (1.0, 0.0); tex: (1.0, 0.0)),
(pos: (1.0, 1.0); tex: (1.0, 1.0))
);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TtsRendererOpenGLES///////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.SetModelViewMatrix(aValue: TtsMatrix4f);
begin
fModelViewMatrix := aValue;
UpdateUniformModelMat;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.SetProjectionMatrix(aValue: TtsMatrix4f);
begin
fProjMatrix := aValue;
UpdateUniformProjMat;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.SetShaderProgram(aValue: GLuint);
begin
if (fShaderProgram = aValue) then
exit;

fShaderProgram := aValue;
fCharPosLocation := glGetUniformLocation(fShaderProgram, UNIFORM_NAME_CHARPOS);
fCharTexPosLocation := glGetUniformLocation(fShaderProgram, UNIFORM_NAME_CHARTEXPOS);
fCharOffsetLocation := glGetUniformLocation(fShaderProgram, UNIFORM_NAME_CHAROFFSET);

UpdateUniformProjMat;
UpdateUniformModelMat;
UpdateUniformCharOffset;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TtsRendererOpenGLES.LoadShader: GLuint;

{$IFDEF DEBUG}
procedure PrintShaderInfo(const aObj: GLuint);
var
msg: PChar;
bLen: GLint;
sLen: GLsizei;
begin
bLen := 0;
glGetShaderiv(aObj, GL_INFO_LOG_LENGTH, @bLen);
if bLen > 1 then begin
GetMem(msg, bLen * SizeOf(Char));
try
glGetShaderInfoLog(aObj, bLen, @sLen, msg);
WriteLn(String(msg));
finally
FreeMem(msg);
end;
end;
end;

procedure PrintProgramInfo(const aObj: GLuint);
var
msg: PChar;
bLen: GLint;
sLen: GLsizei;
begin
bLen := 0;
glGetProgramiv(aObj, GL_INFO_LOG_LENGTH, @bLen);
if bLen > 1 then begin
GetMem(msg, bLen * SizeOf(Char));
try
glGetProgramInfoLog(aObj, bLen, @sLen, msg);
WriteLn(String(msg));
finally
FreeMem(msg);
end;
end;
end;
{$ENDIF}

function CreateObj(const aCode: String; const aType: GLenum): GLuint;
var
code: PAnsiChar;
len: GLint;
begin
result := glCreateShader(aType);
len := Length(aCode);
code := PAnsiChar(aCode);
glShaderSource(result, 1, @code, @len);
glCompileShader(result);
{$IFDEF DEBUG}PrintShaderInfo(result);{$ENDIF}
end;

var
fragObj, vertObj: GLuint;
uLoc: Integer;
begin
result := glCreateProgram();
vertObj := CreateObj(VERTEX_SHADER, GL_VERTEX_SHADER);
fragObj := CreateObj(FRAGMENT_SHADER, GL_FRAGMENT_SHADER);
glAttachShader(result, vertObj);
glAttachShader(result, fragObj);
glLinkProgram(result);
{$IFDEF DEBUG}PrintProgramInfo(result);{$ENDIF}
glBindAttribLocation(result, ATTRIB_LOCATION_POSITION, ATTRIB_NAME_POSITION);
glBindAttribLocation(result, ATTRIB_LOCATION_TEXCOORD, ATTRIB_NAME_TEXCOORD);
uLoc := glGetUniformLocation(result, UNIFORM_NAME_TEXTURE);
if (uLoc >= 0) then begin
glUseProgram(result);
glUniform1i(uLoc, 0);
glUseProgram(0);
end;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.UpdateUniformProjMat;
var
loc: Integer;
begin
loc := glGetUniformLocation(fShaderProgram, UNIFORM_NAME_PROJMAT);
if (loc >= 0) then begin
glUseProgram(fShaderProgram);
glUniformMatrix4fv(loc, 1, false, @fProjMatrix[0, 0]);
glUseProgram(0);
end;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.UpdateUniformModelMat;
var
loc: Integer;
begin
loc := glGetUniformLocation(fShaderProgram, UNIFORM_NAME_MODELVIEWMAT);
if (loc >= 0) then begin
glUseProgram(fShaderProgram);
glUniformMatrix4fv(loc, 1, false, @fModelViewMatrix[0, 0]);
glUseProgram(0);
end;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.UpdateUniformCharOffset;
begin
if (fCharOffsetLocation >= 0) then begin
glUseProgram(fShaderProgram);
glUniform2iv(fCharOffsetLocation, 1, @RenderPos.x);
glUseProgram(0);
end;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TtsRendererOpenGLES.CreateNewTexture: PtsFontTexture;
begin
new(result);
try
FillByte(result^, SizeOf(result^), 0);
new(result^.Usage);
FillByte(result^.Usage^, SizeOf(result^.Usage^), 0);
result^.Size := TextureSize;

glGenTextures(1, @result^.ID);
glBindTexture(GL_TEXTURE_2D, result^.ID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(
GL_TEXTURE_2D,
0,
FORMAT_TYPES[Format].InternalFormat,
result^.Size,
result^.Size,
0,
FORMAT_TYPES[Format].Format,
FORMAT_TYPES[Format].DataFormat,
nil);

PushTexture(result);
except
if Assigned(result^.Usage) then
Dispose(result^.Usage);
Dispose(result);
end;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.FreeTexture(var aTexture: PtsFontTexture);
begin
if Assigned(aTexture) then
glDeleteTextures(1, @aTexture^.ID);
inherited FreeTexture(aTexture);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.UploadTexData(const aCharRef: TtsCharRenderRefOpenGL; const aCharImage: TtsImage; const X, Y: Integer);
begin
glBindTexture(GL_TEXTURE_2D, aCharRef.TextureID);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glTexSubImage2D(GL_TEXTURE_2D, 0,
x, y, aCharImage.Width, aCharImage.Height,
FORMAT_TYPES[aCharImage.Format].Format,
FORMAT_TYPES[aCharImage.Format].DataFormat,
aCharImage.Data);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.BeginRender;
begin
inherited BeginRender;
glColor4f(Color.r, Color.g, Color.b, Color.a);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.SetDrawPos(const X, Y: Integer);
begin
inherited SetDrawPos(X, Y);
UpdateUniformCharOffset;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.MoveDrawPos(const X, Y: Integer);
begin
inherited MoveDrawPos(X, Y);
UpdateUniformCharOffset;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.SetColor(const aColor: TtsColor4f);
begin
inherited SetColor(aColor);
glColor4f(Color.r, Color.g, Color.b, Color.a);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TtsRendererOpenGLES.Render(const aCharRef: TtsCharRenderRef);
var
ref: TtsCharRenderRefOpenGL;
begin
if Assigned(aCharRef) and (aCharRef is TtsCharRenderRefOpenGL) then begin
ref := (aCharRef as TtsCharRenderRefOpenGL);

glBindTexture(GL_TEXTURE_2D, ref.TextureID);
glBindBuffer(GL_ARRAY_BUFFER, fVBO);
glEnableVertexAttribArray(ATTRIB_LOCATION_POSITION);
glVertexAttribPointer(ATTRIB_LOCATION_POSITION, 2, GL_FLOAT, false, SizeOf(TVertex), Pointer(0));
glEnableVertexAttribArray(ATTRIB_LOCATION_TEXCOORD);
glVertexAttribPointer(ATTRIB_LOCATION_TEXCOORD, 2, GL_FLOAT, false, SizeOf(TVertex), Pointer(8));
glUseProgram(fShaderProgram);

if (fCharPosLocation >= 0) then
glUniformMatrix4fv(fCharPosLocation, 1, false, @ref.VertMat);
if (fCharTexPosLocation >= 0) then
glUniformMatrix4fv(fCharTexPosLocation, 1, false, @ref.TexMat);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

glUseProgram(0);
glDisableVertexAttribArray(ATTRIB_LOCATION_TEXCOORD);
glDisableVertexAttribArray(ATTRIB_LOCATION_POSITION);
glBindTexture(GL_TEXTURE_2D, 0);
end;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TtsRendererOpenGLES.Create(const aContext: TtsContext; const aFormat: TtsFormat);
var
viewport: array[0..3] of Integer;
begin
inherited Create(aContext, aFormat);

glGenBuffers(1, @fVBO);
glBindBuffer(GL_ARRAY_BUFFER, fVBO);
glBufferData(GL_ARRAY_BUFFER, SizeOf(TVertex) * Length(VBO_DATA), @VBO_DATA[0].pos[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

glGetIntegerv(GL_VIEWPORT, @viewport);
fProjMatrix := tsMatrix4f(
tsVector4f(2 / viewport[2], 0.0, 0.0, 0.0),
tsVector4f( 0.0, -2 / viewport[3], 0.0, 0.0),
tsVector4f( 0.0, 0.0, -0.1, 0.0),
tsVector4f( -1.0, 1.0, 0.0, 1.0));
fModelViewMatrix := TS_MATRIX_IDENTITY;
fShader := LoadShader;
ShaderProgram := fShader;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TtsRendererOpenGLES.Destroy;
begin
glDeleteBuffers(1, @fVBO);
glDeleteProgram(fShader);
inherited Destroy;
end;

end.

+ 33
- 0
utsTypes.pas View File

@@ -159,6 +159,9 @@ type
end;
PtsColor4ub = ^TtsColor4ub;

TtsVector4f = array[0..3] of Single;
TtsMatrix4f = array[0..3] of TtsVector4f;

TtsTextMetric = packed record
Ascent: Integer;
Descent: Integer;
@@ -179,10 +182,15 @@ const
TS_MODES_MODULATE_ALL: TtsImageModes = (tsModeModulate, tsModeModulate, tsModeModulate, tsModeModulate);
TS_MODES_MODULATE_ALPHA: TtsImageModes = (tsModeReplace, tsModeReplace, tsModeReplace, tsModeModulate);

TS_MATRIX_IDENTITY: TtsMatrix4f = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));

function tsColor4f(r, g, b, a: Single): TtsColor4f;
function tsModes(r, g, b, a: TtsImageMode): TtsImageModes;
function tsRect(const l, t, r, b: Integer): TtsRect;
function tsPosition(const x, y: Integer): TtsPosition;
function tsPositionF(const x, y: Single): TtsPositionF;
function tsVector4f(X, Y, Z, W: Single): TtsVector4f;
function tsMatrix4f(X, Y, Z, P: TtsVector4f): TtsMatrix4f;

function tsFormatSize(const aFormat: TtsFormat): Integer;
procedure tsFormatMap(const aFormat: TtsFormat; var aData: PByte; const aColor: TtsColor4f);
@@ -235,6 +243,31 @@ begin
result.y := y;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function tsPositionF(const x, y: Single): TtsPositionF;
begin
result.x := x;
result.y := y;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function tsVector4f(X, Y, Z, W: Single): TtsVector4f;
begin
result[0] := X;
result[1] := Y;
result[2] := Z;
result[3] := W;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function tsMatrix4f(X, Y, Z, P: TtsVector4f): TtsMatrix4f;
begin
result[0] := X;
result[1] := Y;
result[2] := Z;
result[3] := P;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function tsFormatSize(const aFormat: TtsFormat): Integer;
begin


Loading…
Cancel
Save