Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating to work for BB10.

  • Loading branch information...
commit 9d7b779fd2b4cef4ce7439071e4bbba647c9ac74 1 parent fcd2627
@dducharme dducharme authored
View
88 Box2D/.cproject
@@ -29,17 +29,17 @@
<option id="com.qnx.qcc.option.compiler.optlevel.953425253" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
<option id="com.qnx.qcc.option.compile.debug.1238842882" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.includePath.2101944593" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/..&quot;"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.179181128" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.997094739" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
- <option id="com.qnx.qcc.option.compiler.qccoptions.818491294" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.ccoptions.1727505453" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.cppoptions.967893752" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.818491294" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.ccoptions.1727505453" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.cppoptions.967893752" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions"/>
<inputType id="com.qnx.qcc.inputType.compiler.1052375653" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool command="qcc" commandLinePattern="${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}" errorParsers="" id="com.qnx.qcc.tool.assembler.235679084" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
@@ -51,7 +51,7 @@
<option id="com.qnx.qcc.option.assembler.defines.248901193" name="Defines (-D)" superClass="com.qnx.qcc.option.assembler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
- <option id="com.qnx.qcc.option.assembler.qccoptions.424909209" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.assembler.qccoptions.424909209" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions"/>
<inputType id="com.qnx.qcc.inputType.assembler.1226267419" superClass="com.qnx.qcc.inputType.assembler"/>
</tool>
<tool id="com.qnx.qcc.tool.linker.1720713142" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
@@ -106,8 +106,8 @@
<tool errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="com.qnx.qcc.tool.compiler.1891882552" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compiler.optlevel.586647430" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
<option id="com.qnx.qcc.option.compiler.includePath.1977087982" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/..&quot;"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.842954972" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
@@ -115,14 +115,14 @@
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
<option id="com.qnx.qcc.option.compiler.pie.1334372624" name="Position Independent Executable (-fPIE)" superClass="com.qnx.qcc.option.compiler.pie" value="false" valueType="boolean"/>
- <option id="com.qnx.qcc.option.compiler.qccoptions.265572551" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.ccoptions.1870323425" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.cppoptions.899009364" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.265572551" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.ccoptions.1870323425" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.cppoptions.899009364" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions"/>
<option id="com.qnx.qcc.option.compile.debug.1690098494" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<inputType id="com.qnx.qcc.inputType.compiler.184748740" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool errorParsers="" id="com.qnx.qcc.tool.assembler.731936224" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
- <option id="com.qnx.qcc.option.assembler.qccoptions.1700933545" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.assembler.qccoptions.1700933545" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions"/>
<option id="com.qnx.qcc.option.assembler.includePath.2019506018" name="Include Directories (-I)" superClass="com.qnx.qcc.option.assembler.includePath" valueType="includePath">
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
@@ -180,22 +180,22 @@
<option id="com.qnx.qcc.option.compile.debug.520312180" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.472580232" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.includePath.2030140158" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/..&quot;"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.821774254" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.383671200" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
- <option id="com.qnx.qcc.option.compiler.qccoptions.3413853" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.ccoptions.2065441688" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.cppoptions.576994207" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.3413853" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.ccoptions.2065441688" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.cppoptions.576994207" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions"/>
<inputType id="com.qnx.qcc.inputType.compiler.1432221039" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool errorParsers="" id="com.qnx.qcc.tool.assembler.540292969" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
<option id="com.qnx.qcc.option.assembler.debug.113460494" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.assembler.qccoptions.812571533" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.assembler.qccoptions.812571533" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions"/>
<option id="com.qnx.qcc.option.assembler.includePath.310436882" name="Include Directories (-I)" superClass="com.qnx.qcc.option.assembler.includePath" valueType="includePath">
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
@@ -253,22 +253,22 @@
<option id="com.qnx.qcc.option.compile.debug.346868869" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.1876903982" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.includePath.1859912327" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/..&quot;"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.380154019" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.402428449" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
- <option id="com.qnx.qcc.option.compiler.qccoptions.907709810" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.ccoptions.967224935" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.cppoptions.1793569431" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.907709810" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.ccoptions.967224935" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.cppoptions.1793569431" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions"/>
<inputType id="com.qnx.qcc.inputType.compiler.438142777" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool errorParsers="" id="com.qnx.qcc.tool.assembler.825769829" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
<option id="com.qnx.qcc.option.assembler.debug.410076869" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.assembler.qccoptions.1992559762" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.assembler.qccoptions.1992559762" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions"/>
<option id="com.qnx.qcc.option.assembler.includePath.880395357" name="Include Directories (-I)" superClass="com.qnx.qcc.option.assembler.includePath" valueType="includePath">
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
@@ -281,7 +281,7 @@
<tool id="com.qnx.qcc.tool.linker.669746342" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
<option id="com.qnx.qcc.option.linker.langcpp.801928326" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.debug.1632012788" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.linker.coverage.932375732" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
+ <option id="com.qnx.qcc.option.linker.coverage.932375732" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.libraryPaths.406532910" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
@@ -325,22 +325,22 @@
<option id="com.qnx.qcc.option.compiler.optlevel.393779006" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
<option id="com.qnx.qcc.option.compile.debug.777472131" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.includePath.1960696327" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/..&quot;"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.1430966345" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.1403383687" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
- <option id="com.qnx.qcc.option.compiler.qccoptions.1082073963" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.ccoptions.946424939" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.cppoptions.894304306" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.1082073963" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.ccoptions.946424939" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.cppoptions.894304306" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions"/>
<inputType id="com.qnx.qcc.inputType.compiler.351510711" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool errorParsers="" id="com.qnx.qcc.tool.assembler.1955272892" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
<option id="com.qnx.qcc.option.assembler.debug.536691710" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.assembler.qccoptions.112346841" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.assembler.qccoptions.112346841" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions"/>
<option id="com.qnx.qcc.option.assembler.includePath.1144133472" name="Include Directories (-I)" superClass="com.qnx.qcc.option.assembler.includePath" valueType="includePath">
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
@@ -397,22 +397,22 @@
<option id="com.qnx.qcc.option.compile.debug.46629761" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.1120977682" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.includePath.1183778381" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/..&quot;"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.575083826" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.611645638" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
- <option id="com.qnx.qcc.option.compiler.qccoptions.1338290163" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.ccoptions.850629086" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.cppoptions.1528837481" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.1338290163" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.ccoptions.850629086" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.cppoptions.1528837481" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions"/>
<inputType id="com.qnx.qcc.inputType.compiler.1168567688" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool errorParsers="" id="com.qnx.qcc.tool.assembler.590519496" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
<option id="com.qnx.qcc.option.assembler.debug.1125406336" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.assembler.qccoptions.367758329" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.assembler.qccoptions.367758329" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions"/>
<option id="com.qnx.qcc.option.assembler.includePath.1800306015" name="Include Directories (-I)" superClass="com.qnx.qcc.option.assembler.includePath" valueType="includePath">
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
@@ -470,22 +470,22 @@
<option id="com.qnx.qcc.option.compile.debug.1003148683" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.315945136" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.includePath.923350403" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/..&quot;"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.1818380861" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.54144030" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
- <option id="com.qnx.qcc.option.compiler.qccoptions.1153810041" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.ccoptions.1432263074" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions" valueType="stringList"/>
- <option id="com.qnx.qcc.option.compiler.cppoptions.1526239860" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.1153810041" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.ccoptions.1432263074" name="Compiler Options (-Wc,)" superClass="com.qnx.qcc.option.compiler.ccoptions"/>
+ <option id="com.qnx.qcc.option.compiler.cppoptions.1526239860" name="Preprocessor Options (-Wp,)" superClass="com.qnx.qcc.option.compiler.cppoptions"/>
<inputType id="com.qnx.qcc.inputType.compiler.557398473" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool errorParsers="" id="com.qnx.qcc.tool.assembler.330999222" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
<option id="com.qnx.qcc.option.assembler.debug.31767557" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.assembler.qccoptions.2047436613" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions" valueType="stringList"/>
+ <option id="com.qnx.qcc.option.assembler.qccoptions.2047436613" name="QCC Options" superClass="com.qnx.qcc.option.assembler.qccoptions"/>
<option id="com.qnx.qcc.option.assembler.includePath.384900656" name="Include Directories (-I)" superClass="com.qnx.qcc.option.assembler.includePath" valueType="includePath">
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
<listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
@@ -498,7 +498,7 @@
<tool id="com.qnx.qcc.tool.linker.2056195038" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
<option id="com.qnx.qcc.option.linker.langcpp.792322970" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.debug.880186683" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.linker.coverage.1455201868" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
+ <option id="com.qnx.qcc.option.linker.coverage.1455201868" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.libraryPaths.1620921731" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
View
0  qnx/Box2D/Makefile → Build/blackberry/Box2D/Makefile
File renamed without changes
View
0  qnx/Box2D/x86/Makefile → Build/blackberry/Box2D/arm/Makefile
File renamed without changes
View
0  qnx/Box2D/x86/a/Makefile → ...d/blackberry/Box2D/arm/a.le.v7.g/Makefile
File renamed without changes
View
0  qnx/Box2D/x86/a.g/Makefile → Build/blackberry/Box2D/arm/a.le.v7/Makefile
File renamed without changes
View
26 Build/blackberry/Box2D/common.mk
@@ -0,0 +1,26 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+NAME=Box2D
+
+#===== CCFLAGS - add the flags to the C compiler command line.
+CCFLAGS+=-Y_gpp
+
+#===== EXTRA_INCVPATH - a space-separated list of directories to search for include files.
+EXTRA_INCVPATH+=$(PRODUCT_ROOT)/../../
+
+#===== EXTRA_SRCVPATH - a space-separated list of directories to search for source files.
+EXTRA_SRCVPATH+=$(PRODUCT_ROOT)/../../Box2D/Collision \
+ $(PRODUCT_ROOT)/../../Box2D/Collision/Shapes \
+ $(PRODUCT_ROOT)/../../Box2D/Common \
+ $(PRODUCT_ROOT)/../../Box2D/Dynamics \
+ $(PRODUCT_ROOT)/../../Box2D/Dynamics/Contacts \
+ $(PRODUCT_ROOT)/../../Box2D/Dynamics/Joints \
+ $(PRODUCT_ROOT)/../../Box2D/Rope
+
+include $(MKFILES_ROOT)/qtargets.mk
+
+OPTIMIZE_TYPE_g=none
+OPTIMIZE_TYPE=$(OPTIMIZE_TYPE_$(filter g, $(VARIANTS)))
View
0  qnx/Box2D/arm/Makefile → Build/blackberry/Box2D/x86/Makefile
File renamed without changes
View
0  qnx/Box2D/arm/a.le.v7/Makefile → Build/blackberry/Box2D/x86/a.g/Makefile
File renamed without changes
View
0  qnx/Box2D/arm/a.le.v7.g/Makefile → Build/blackberry/Box2D/x86/a/Makefile
File renamed without changes
View
0  qnx/Makefile → Build/blackberry/Makefile
File renamed without changes
View
49 Testbed/.cproject
@@ -28,11 +28,11 @@
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
<option id="com.qnx.qcc.option.compiler.includePath.520737343" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Box2D}&quot;/.."/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Framework}&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/qnx}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/blackberry}&quot;"/>
</option>
<inputType id="com.qnx.qcc.inputType.compiler.2145409249" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
@@ -71,7 +71,7 @@
<sourceEntries>
<entry excluding="Main.cpp|Render.cpp|Render.h" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Framework"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Tests"/>
- <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="qnx"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="blackberry"/>
</sourceEntries>
</configuration>
</storageModule>
@@ -103,11 +103,11 @@
</option>
<option id="com.qnx.qcc.option.compiler.pie.1773227739" name="Position Independent Executable (-fPIE)" superClass="com.qnx.qcc.option.compiler.pie" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.includePath.1258374688" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Box2D}&quot;/.."/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Framework}&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/qnx}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/blackberry}&quot;"/>
</option>
<inputType id="com.qnx.qcc.inputType.compiler.908391454" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
@@ -177,11 +177,11 @@
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
<option id="com.qnx.qcc.option.compiler.includePath.464136247" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Box2D}&quot;/.."/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Framework}&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/qnx}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/blackberry}&quot;"/>
</option>
<inputType id="com.qnx.qcc.inputType.compiler.1221866723" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
@@ -251,11 +251,11 @@
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
<option id="com.qnx.qcc.option.compiler.includePath.633178741" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Box2D}&quot;/.."/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Framework}&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/qnx}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/blackberry}&quot;"/>
</option>
<inputType id="com.qnx.qcc.inputType.compiler.2126979598" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
@@ -265,7 +265,7 @@
</tool>
<tool id="com.qnx.qcc.tool.linker.1625833181" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
<option id="com.qnx.qcc.option.linker.debug.148610801" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.linker.coverage.1607947490" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
+ <option id="com.qnx.qcc.option.linker.coverage.1607947490" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.langcpp.1355607773" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.libraries.681920365" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
<listOptionValue builtIn="false" value="Box2D"/>
@@ -323,11 +323,11 @@
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
<option id="com.qnx.qcc.option.compiler.includePath.999907681" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Box2D}&quot;/.."/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Framework}&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/qnx}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/blackberry}&quot;"/>
</option>
<inputType id="com.qnx.qcc.inputType.compiler.413519788" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
@@ -395,11 +395,11 @@
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
<option id="com.qnx.qcc.option.compiler.includePath.17861402" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Box2D}&quot;/.."/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Framework}&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/qnx}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/blackberry}&quot;"/>
</option>
<inputType id="com.qnx.qcc.inputType.compiler.1260178121" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
@@ -468,11 +468,11 @@
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
<option id="com.qnx.qcc.option.compiler.includePath.630596314" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/qnx6/usr/include/freetype2"/>
- <listOptionValue builtIn="false" value="C:/bbndk-2.0.1/target/target-override/usr/include"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Box2D}&quot;/.."/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Framework}&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/qnx}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/blackberry}&quot;"/>
</option>
<inputType id="com.qnx.qcc.inputType.compiler.701882111" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
@@ -482,7 +482,7 @@
</tool>
<tool id="com.qnx.qcc.tool.linker.165004802" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
<option id="com.qnx.qcc.option.linker.debug.944760787" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
- <option id="com.qnx.qcc.option.linker.coverage.448121798" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
+ <option id="com.qnx.qcc.option.linker.coverage.448121798" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.langcpp.18083201" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.libraries.540797260" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
<listOptionValue builtIn="false" value="Box2D"/>
@@ -590,4 +590,5 @@
<resource resourceType="PROJECT" workspacePath="/box2dTestbed"/>
</storageModule>
<storageModule moduleId="com.qnx.tools.ide.qde.core.QNXProjectProperties"/>
+ <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
</cproject>
View
5 Testbed/Framework/GLES-Render.cpp
@@ -52,7 +52,6 @@ void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* old_vertices, int vertexCount
void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)
{
-
const float32 k_segments = 16.0f;
int vertexCount=16;
const float32 k_increment = 2.0f * b2_pi / k_segments;
@@ -160,9 +159,7 @@ void GLESDebugDraw::DrawString(int x, int y, const char *string, ...)
glPushMatrix();
glLoadIdentity();
- glColor4f(0.9f, 0.6f, 0.6f, 1.0f);
-
- bbutil_render_text(_font, buffer, x, y);
+ bbutil_render_text(_font, buffer, x, y, 0.9f, 0.6f, 0.6f, 1.0f);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
View
8 Testbed/Framework/GLES-Render.h
@@ -39,13 +39,13 @@ class GLESDebugDraw : public b2Draw
virtual void DrawAABB(b2AABB* aabb, const b2Color& color);
#ifdef __QNX__
- void SetFont(const font_t *font) { _font = font; }
+ void SetFont(font_t *font) { _font = font; }
void SetScreenSize(float width, float height);
private:
- const font_t *_font;
- float _screenWidth;
- float _screenHeight;
+ font_t *_font;
+ float _screenWidth;
+ float _screenHeight;
#endif
};
View
886 Testbed/blackberry/bbutil.cpp
@@ -0,0 +1,886 @@
+/*
+ * Copyright (c) 2011-2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <assert.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/keycodes.h>
+#include <time.h>
+#include <stdbool.h>
+#include <math.h>
+
+#include "bbutil.h"
+
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#include "png.h"
+
+EGLDisplay egl_disp;
+EGLSurface egl_surf;
+
+static EGLConfig egl_conf;
+static EGLContext egl_ctx;
+
+static screen_context_t screen_ctx;
+static screen_window_t screen_win;
+static screen_display_t screen_disp;
+static int nbuffers = 2;
+
+static int initialized = 0;
+
+struct font_t {
+ unsigned int font_texture;
+ float pt;
+ float advance[128];
+ float width[128];
+ float height[128];
+ float tex_x1[128];
+ float tex_x2[128];
+ float tex_y1[128];
+ float tex_y2[128];
+ float offset_x[128];
+ float offset_y[128];
+ float max_height;
+ int initialized;
+};
+
+static void
+bbutil_egl_perror(const char *msg)
+{
+ static const char *errmsg[] = {
+ "function succeeded",
+ "EGL is not initialized, or could not be initialized, for the specified display",
+ "cannot access a requested resource",
+ "failed to allocate resources for the requested operation",
+ "an unrecognized attribute or attribute value was passed in an attribute list",
+ "an EGLConfig argument does not name a valid EGLConfig",
+ "an EGLContext argument does not name a valid EGLContext",
+ "the current surface of the calling thread is no longer valid",
+ "an EGLDisplay argument does not name a valid EGLDisplay",
+ "arguments are inconsistent",
+ "an EGLNativePixmapType argument does not refer to a valid native pixmap",
+ "an EGLNativeWindowType argument does not refer to a valid native window",
+ "one or more argument values are invalid",
+ "an EGLSurface argument does not name a valid surface configured for rendering",
+ "a power management event has occurred",
+ "unknown error code"
+ };
+
+ int message_index = eglGetError() - EGL_SUCCESS;
+
+ if (message_index < 0 || message_index > 14)
+ message_index = 15;
+
+ fprintf(stderr, "%s: %s\n", msg, errmsg[message_index]);
+}
+
+int
+bbutil_init_egl(screen_context_t ctx)
+{
+ int usage;
+ int format = SCREEN_FORMAT_RGBX8888;
+ EGLint interval = 1;
+ int rc, num_configs;
+ char *width_str = getenv("WIDTH");
+ char *height_str = getenv("HEIGHT");
+
+ EGLint attrib_list[]= { EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_RENDERABLE_TYPE, 0,
+ EGL_NONE};
+
+ usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
+ attrib_list[9] = EGL_OPENGL_ES_BIT;
+
+ //Simple egl initialization
+ screen_ctx = ctx;
+
+ egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (egl_disp == EGL_NO_DISPLAY) {
+ bbutil_egl_perror("eglGetDisplay");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = eglInitialize(egl_disp, NULL, NULL);
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglInitialize");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = eglBindAPI(EGL_OPENGL_ES_API);
+
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglBindApi");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ if(!eglChooseConfig(egl_disp, attrib_list, &egl_conf, 1, &num_configs)) {
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, NULL);
+
+ if (egl_ctx == EGL_NO_CONTEXT) {
+ bbutil_egl_perror("eglCreateContext");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_create_window(&screen_win, screen_ctx);
+ if (rc) {
+ perror("screen_create_window");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);
+ if (rc) {
+ perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);
+ if (rc) {
+ perror("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
+ if (rc) {
+ perror("screen_get_window_property_pv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ int buffer_size[2];
+ if (width_str && height_str)
+ {
+ buffer_size[0] = atoi(width_str);
+ buffer_size[1] = atoi(height_str);
+ }
+ else
+ {
+ int size[2];
+ int angle = atoi(getenv("ORIENTATION"));
+
+ rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
+ if (rc) {
+ perror("screen_get_window_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ screen_display_mode_t screen_mode;
+ rc = screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
+ if (rc) {
+ perror("screen_get_display_property_pv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ buffer_size[0] = size[0];
+ buffer_size[1] = size[1];
+
+ if ((angle == 0) || (angle == 180)) {
+ if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
+ ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
+ buffer_size[1] = size[0];
+ buffer_size[0] = size[1];
+ }
+ } else if ((angle == 90) || (angle == 270)){
+ if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
+ ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
+ buffer_size[1] = size[0];
+ buffer_size[0] = size[1];
+ }
+ } else {
+ fprintf(stderr, "Navigator returned an unexpected orientation angle.\n");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_create_window_buffers(screen_win, nbuffers);
+ if (rc) {
+ perror("screen_create_window_buffers");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, NULL);
+ if (egl_surf == EGL_NO_SURFACE) {
+ bbutil_egl_perror("eglCreateWindowSurface");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx);
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglMakeCurrent");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = eglSwapInterval(egl_disp, interval);
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglSwapInterval");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ initialized = 1;
+
+ return EXIT_SUCCESS;
+}
+
+void
+bbutil_terminate()
+{
+ //Typical EGL cleanup
+ if (egl_disp != EGL_NO_DISPLAY) {
+ eglMakeCurrent(egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ if (egl_surf != EGL_NO_SURFACE) {
+ eglDestroySurface(egl_disp, egl_surf);
+ egl_surf = EGL_NO_SURFACE;
+ }
+ if (egl_ctx != EGL_NO_CONTEXT) {
+ eglDestroyContext(egl_disp, egl_ctx);
+ egl_ctx = EGL_NO_CONTEXT;
+ }
+ if (screen_win != NULL) {
+ screen_destroy_window(screen_win);
+ screen_win = NULL;
+ }
+ eglTerminate(egl_disp);
+ egl_disp = EGL_NO_DISPLAY;
+ }
+ eglReleaseThread();
+
+ initialized = 0;
+}
+
+void
+bbutil_swap()
+{
+ int rc = eglSwapBuffers(egl_disp, egl_surf);
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglSwapBuffers");
+ }
+}
+
+/* Finds the next power of 2 */
+static inline int
+nextp2(int x)
+{
+ int val = 1;
+ while(val < x) val <<= 1;
+ return val;
+}
+
+font_t* bbutil_load_font(const char* path, int point_size, int dpi)
+{
+ FT_Library library;
+ FT_Face face;
+ int c;
+ int i, j;
+ font_t* font;
+
+ if (!initialized) {
+ fprintf(stderr, "EGL has not been initialized\n");
+ return NULL;
+ }
+
+ if (!path){
+ fprintf(stderr, "Invalid path to font file\n");
+ return NULL;
+ }
+
+ if(FT_Init_FreeType(&library)) {
+ fprintf(stderr, "Error loading Freetype library\n");
+ return NULL;
+ }
+ if (FT_New_Face(library, path,0,&face)) {
+ fprintf(stderr, "Error loading font %s\n", path);
+ return NULL;
+ }
+
+ if(FT_Set_Char_Size ( face, point_size * 64, point_size * 64, dpi, dpi)) {
+ fprintf(stderr, "Error initializing character parameters\n");
+ return NULL;
+ }
+
+ font = (font_t*) malloc(sizeof(font_t));
+
+ if (!font) {
+ fprintf(stderr, "Unable to allocate memory for font structure\n");
+ return NULL;
+ }
+
+ font->initialized = 0;
+ font->pt = point_size;
+
+ glGenTextures(1, &(font->font_texture));
+
+ //Let each glyph reside in 32x32 section of the font texture
+ int segment_size_x = 0, segment_size_y = 0;
+ int num_segments_x = 16;
+ int num_segments_y = 8;
+
+ FT_GlyphSlot slot;
+ FT_Bitmap bmp;
+ int glyph_width, glyph_height;
+ font->max_height = 0.0f;
+
+ //First calculate the max width and height of a character in a passed font
+ for(c = 0; c < 128; c++) {
+ if(FT_Load_Char(face, c, FT_LOAD_RENDER)) {
+ fprintf(stderr, "FT_Load_Char failed\n");
+ free(font);
+ return NULL;
+ }
+
+ slot = face->glyph;
+ bmp = slot->bitmap;
+
+ glyph_width = bmp.width;
+ glyph_height = bmp.rows;
+
+ if (glyph_width > segment_size_x) {
+ segment_size_x = glyph_width;
+ }
+
+ if (glyph_height > segment_size_y) {
+ segment_size_y = glyph_height;
+ }
+ }
+
+ int font_tex_width = nextp2(num_segments_x * segment_size_x);
+ int font_tex_height = nextp2(num_segments_y * segment_size_y);
+
+ int bitmap_offset_x = 0, bitmap_offset_y = 0;
+
+ GLubyte* font_texture_data = (GLubyte*) calloc(2 * font_tex_width * font_tex_height, sizeof(GLubyte));
+
+ if (!font_texture_data) {
+ fprintf(stderr, "Failed to allocate memory for font texture\n");
+ free(font);
+ return NULL;
+ }
+
+ // Fill font texture bitmap with individual bmp data and record appropriate size, texture coordinates and offsets for every glyph
+ for(c = 0; c < 128; c++) {
+ if(FT_Load_Char(face, c, FT_LOAD_RENDER)) {
+ fprintf(stderr, "FT_Load_Char failed\n");
+ free(font);
+ return NULL;
+ }
+
+ slot = face->glyph;
+ bmp = slot->bitmap;
+
+ glyph_width = bmp.width;
+ glyph_height = bmp.rows;
+
+ div_t temp = div(c, num_segments_x);
+
+ bitmap_offset_x = segment_size_x * temp.rem;
+ bitmap_offset_y = segment_size_y * temp.quot;
+
+ for (j = 0; j < glyph_height; j++) {
+ for (i = 0; i < glyph_width; i++) {
+ font_texture_data[2 * ((bitmap_offset_x + i) + (j + bitmap_offset_y) * font_tex_width) + 0] =
+ font_texture_data[2 * ((bitmap_offset_x + i) + (j + bitmap_offset_y) * font_tex_width) + 1] =
+ (i >= bmp.width || j >= bmp.rows)? 0 : bmp.buffer[i + bmp.width * j];
+ }
+ }
+
+ if (bmp.rows > font->max_height)
+ font->max_height = bmp.rows;
+
+ font->advance[c] = (float)(slot->advance.x >> 6);
+ font->tex_x1[c] = (float)bitmap_offset_x / (float) font_tex_width;
+ font->tex_x2[c] = (float)(bitmap_offset_x + bmp.width) / (float)font_tex_width;
+ font->tex_y1[c] = (float)bitmap_offset_y / (float) font_tex_height;
+ font->tex_y2[c] = (float)(bitmap_offset_y + bmp.rows) / (float)font_tex_height;
+ font->width[c] = bmp.width;
+ font->height[c] = bmp.rows;
+ font->offset_x[c] = (float)slot->bitmap_left;
+ font->offset_y[c] = (float)((slot->metrics.horiBearingY-face->glyph->metrics.height) >> 6);
+ }
+
+ glBindTexture(GL_TEXTURE_2D, font->font_texture);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, font_tex_width, font_tex_height, 0, GL_LUMINANCE_ALPHA , GL_UNSIGNED_BYTE, font_texture_data);
+
+ free(font_texture_data);
+
+ FT_Done_Face(face);
+ FT_Done_FreeType(library);
+
+ font->initialized = 1;
+ return font;
+}
+
+void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r, float g, float b, float a)
+{
+ int i, c;
+ GLfloat *vertices;
+ GLfloat *texture_coords;
+ GLshort* indices;
+
+ float pen_x = 0.0f;
+
+ if (!font) {
+ fprintf(stderr, "Font must not be null\n");
+ return;
+ }
+
+ if (!font->initialized) {
+ fprintf(stderr, "Font has not been loaded\n");
+ return;
+ }
+
+ if (!msg) {
+ return;
+ }
+
+ const int msg_len = strlen(msg);
+
+ vertices = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len);
+ texture_coords = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len);
+
+ indices = (GLshort*) malloc(sizeof(GLfloat) * 6 * msg_len);
+
+ for(i = 0; i < msg_len; ++i) {
+ c = msg[i];
+
+ vertices[8 * i + 0] = x + pen_x + font->offset_x[c];
+ vertices[8 * i + 1] = y + font->max_height - font->offset_y[c];
+ vertices[8 * i + 2] = vertices[8 * i + 0] + font->width[c];
+ vertices[8 * i + 3] = vertices[8 * i + 1];
+ vertices[8 * i + 4] = vertices[8 * i + 0];
+ vertices[8 * i + 5] = vertices[8 * i + 1] - font->height[c];
+ vertices[8 * i + 6] = vertices[8 * i + 2];
+ vertices[8 * i + 7] = vertices[8 * i + 5];
+
+ texture_coords[8 * i + 0] = font->tex_x1[c];
+ texture_coords[8 * i + 1] = font->tex_y2[c];
+ texture_coords[8 * i + 2] = font->tex_x2[c];
+ texture_coords[8 * i + 3] = font->tex_y2[c];
+ texture_coords[8 * i + 4] = font->tex_x1[c];
+ texture_coords[8 * i + 5] = font->tex_y1[c];
+ texture_coords[8 * i + 6] = font->tex_x2[c];
+ texture_coords[8 * i + 7] = font->tex_y1[c];
+
+ indices[i * 6 + 0] = 4 * i + 0;
+ indices[i * 6 + 1] = 4 * i + 1;
+ indices[i * 6 + 2] = 4 * i + 2;
+ indices[i * 6 + 3] = 4 * i + 2;
+ indices[i * 6 + 4] = 4 * i + 1;
+ indices[i * 6 + 5] = 4 * i + 3;
+
+ //Assume we are only working with typewriter fonts
+ pen_x += font->advance[c];
+ }
+
+ glEnable(GL_TEXTURE_2D);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ glColor4f(r, g, b, a);
+
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+ glTexCoordPointer(2, GL_FLOAT, 0, texture_coords);
+ glBindTexture(GL_TEXTURE_2D, font->font_texture);
+
+ glDrawElements(GL_TRIANGLES, 6 * msg_len, GL_UNSIGNED_SHORT, indices);
+
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ glDisable(GL_TEXTURE_2D);
+
+ free(vertices);
+ free(texture_coords);
+ free(indices);
+}
+
+void bbutil_destroy_font(font_t* font)
+{
+ if (!font) {
+ return;
+ }
+
+ glDeleteTextures(1, &(font->font_texture));
+
+ free(font);
+}
+
+void bbutil_measure_text(font_t* font, const char* msg, float* width, float* height)
+{
+ int i, c;
+
+ if (!msg) {
+ return;
+ }
+
+ const int msg_len =strlen(msg);
+
+ if (width) {
+ //Width of a text rectangle is a sum advances for every glyph in a string
+ *width = 0.0f;
+
+ for(i = 0; i < msg_len; ++i) {
+ c = msg[i];
+ *width += font->advance[c];
+ }
+ }
+
+ if (height) {
+ //Height of a text rectangle is a high of a tallest glyph in a string
+ *height = 0.0f;
+
+ for(i = 0; i < msg_len; ++i) {
+ c = msg[i];
+
+ if (*height < font->height[c]) {
+ *height = font->height[c];
+ }
+ }
+ }
+}
+
+int bbutil_load_texture(const char* filename, int* width, int* height, float* tex_x, float* tex_y, unsigned int *tex)
+{
+ unsigned int i;
+ GLuint format;
+ //header for testing if it is a png
+ png_byte header[8];
+
+ if (!tex) {
+ return EXIT_FAILURE;
+ }
+
+ //open file as binary
+ FILE *fp = fopen(filename, "rb");
+ if (!fp) {
+ return EXIT_FAILURE;
+ }
+
+ //read the header
+ fread(header, 1, 8, fp);
+
+ //test if png
+ int is_png = !png_sig_cmp(header, 0, 8);
+ if (!is_png) {
+ fclose(fp);
+ return EXIT_FAILURE;
+ }
+
+ //create png struct
+ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (!png_ptr) {
+ fclose(fp);
+ return EXIT_FAILURE;
+ }
+
+ //create png info struct
+ png_infop info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) {
+ png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
+ fclose(fp);
+ return EXIT_FAILURE;
+ }
+
+ //create png info struct
+ png_infop end_info = png_create_info_struct(png_ptr);
+ if (!end_info) {
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
+ fclose(fp);
+ return EXIT_FAILURE;
+ }
+
+ //setup error handling (required without using custom error handlers above)
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+ fclose(fp);
+ return EXIT_FAILURE;
+ }
+
+ //init png reading
+ png_init_io(png_ptr, fp);
+
+ //let libpng know you already read the first 8 bytes
+ png_set_sig_bytes(png_ptr, 8);
+
+ // read all the info up to the image data
+ png_read_info(png_ptr, info_ptr);
+
+ //variables to pass to get info
+ int bit_depth, color_type;
+ png_uint_32 image_width, image_height;
+
+ // get info about png
+ png_get_IHDR(png_ptr, info_ptr, &image_width, &image_height, &bit_depth, &color_type, NULL, NULL, NULL);
+
+ switch (color_type)
+ {
+ case PNG_COLOR_TYPE_RGBA:
+ format = GL_RGBA;
+ break;
+ case PNG_COLOR_TYPE_RGB:
+ format = GL_RGB;
+ break;
+ default:
+ fprintf(stderr,"Unsupported PNG color type (%d) for texture: %s", (int)color_type, filename);
+ fclose(fp);
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+ return 0;
+ }
+
+ // Update the png info struct.
+ png_read_update_info(png_ptr, info_ptr);
+
+ // Row size in bytes.
+ int rowbytes = png_get_rowbytes(png_ptr, info_ptr);
+
+ // Allocate the image_data as a big block, to be given to opengl
+ png_byte *image_data = (png_byte*) malloc(sizeof(png_byte) * rowbytes * image_height);
+
+ if (!image_data) {
+ //clean up memory and close stuff
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+ fclose(fp);
+ return EXIT_FAILURE;
+ }
+
+ //row_pointers is for pointing to image_data for reading the png with libpng
+ png_bytep *row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * image_height);
+ if (!row_pointers) {
+ //clean up memory and close stuff
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+ free(image_data);
+ fclose(fp);
+ return EXIT_FAILURE;
+ }
+
+ // set the individual row_pointers to point at the correct offsets of image_data
+ for (i = 0; i < image_height; i++) {
+ row_pointers[image_height - 1 - i] = image_data + i * rowbytes;
+ }
+
+ //read the png into image_data through row_pointers
+ png_read_image(png_ptr, row_pointers);
+
+ unsigned int tex_width, tex_height;
+
+ tex_width = nextp2(image_width);
+ tex_height = nextp2(image_height);
+
+ glGenTextures(1, tex);
+ glBindTexture(GL_TEXTURE_2D, (*tex));
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ if ((tex_width != image_width) || (tex_height != image_height) ) {
+ glTexImage2D(GL_TEXTURE_2D, 0, format, tex_width, tex_height, 0, format, GL_UNSIGNED_BYTE, NULL);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_width, image_height, format, GL_UNSIGNED_BYTE, image_data);
+ } else {
+ glTexImage2D(GL_TEXTURE_2D, 0, format, tex_width, tex_height, 0, format, GL_UNSIGNED_BYTE, image_data);
+ }
+
+ GLint err = glGetError();
+
+ //clean up memory and close stuff
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+ free(image_data);
+ free(row_pointers);
+ fclose(fp);
+
+ if (err == 0) {
+ //Return physical with and height of texture if pointers are not null
+ if(width) {
+ *width = image_width;
+ }
+ if (height) {
+ *height = image_height;
+ }
+ //Return modified texture coordinates if pointers are not null
+ if(tex_x) {
+ *tex_x = ((float) image_width - 0.5f) / ((float)tex_width);
+ }
+ if(tex_y) {
+ *tex_y = ((float) image_height - 0.5f) / ((float)tex_height);
+ }
+ return EXIT_SUCCESS;
+ } else {
+ fprintf(stderr, "GL error %i \n", err);
+ return EXIT_FAILURE;
+ }
+}
+
+int bbutil_calculate_dpi(screen_context_t ctx)
+{
+ int rc;
+ int screen_phys_size[2];
+
+ rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_PHYSICAL_SIZE, screen_phys_size);
+ if (rc) {
+ perror("screen_get_display_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ //Simulator will return 0,0 for physical size of the screen, so use 170 as default dpi
+ if ((screen_phys_size[0] == 0) && (screen_phys_size[1] == 0)) {
+ return 170;
+ } else {
+ int screen_resolution[2];
+ rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
+ if (rc) {
+ perror("screen_get_display_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+ double diagonal_pixels = sqrt(screen_resolution[0] * screen_resolution[0] + screen_resolution[1] * screen_resolution[1]);
+ double diagonal_inches = 0.0393700787 * sqrt(screen_phys_size[0] * screen_phys_size[0] + screen_phys_size[1] * screen_phys_size[1]);
+ return (int)(diagonal_pixels / diagonal_inches + 0.5);
+
+ }
+}
+
+int bbutil_rotate_screen_surface(int angle)
+{
+ int rc, rotation, skip = 1, temp;;
+ EGLint interval = 1;
+ int size[2];
+
+ if ((angle != 0) && (angle != 90) && (angle != 180) && (angle != 270)) {
+ fprintf(stderr, "Invalid angle\n");
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &rotation);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ return EXIT_FAILURE;
+ }
+
+ switch (angle - rotation) {
+ case -270:
+ case -90:
+ case 90:
+ case 270:
+ temp = size[0];
+ size[0] = size[1];
+ size[1] = temp;
+ skip = 0;
+ break;
+ }
+
+ if (!skip) {
+ rc = eglMakeCurrent(egl_disp, NULL, NULL, NULL);
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglMakeCurrent");
+ return EXIT_FAILURE;
+ }
+
+ rc = eglDestroySurface(egl_disp, egl_surf);
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglMakeCurrent");
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE, size);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ return EXIT_FAILURE;
+ }
+ egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, NULL);
+ if (egl_surf == EGL_NO_SURFACE) {
+ bbutil_egl_perror("eglCreateWindowSurface");
+ return EXIT_FAILURE;
+ }
+
+ rc = eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx);
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglMakeCurrent");
+ return EXIT_FAILURE;
+ }
+
+ rc = eglSwapInterval(egl_disp, interval);
+ if (rc != EGL_TRUE) {
+ bbutil_egl_perror("eglSwapInterval");
+ return EXIT_FAILURE;
+ }
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
View
132 Testbed/blackberry/bbutil.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011-2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _UTILITY_H_INCLUDED
+#define _UTILITY_H_INCLUDED
+
+#include <EGL/egl.h>
+#include <screen/screen.h>
+#include <sys/platform.h>
+
+extern EGLDisplay egl_disp;
+extern EGLSurface egl_surf;
+
+typedef struct font_t font_t;
+
+
+#define BBUTIL_DEFAULT_FONT "/usr/fonts/font_repository/monotype/arial.ttf"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Initializes EGL
+ *
+ * @param libscreen context that will be used for EGL setup
+ * @return EXIT_SUCCESS if initialization succeeded otherwise EXIT_FAILURE
+ */
+int bbutil_init_egl(screen_context_t ctx);
+
+/**
+ * Terminates EGL
+ */
+void bbutil_terminate();
+
+/**
+ * Swaps default bbutil window surface to the screen
+ */
+void bbutil_swap();
+
+/**
+ * Loads the font from the specified font file.
+ * NOTE: should be called after a successful return from bbutil_init() or bbutil_init_egl() call
+ * @param font_file string indicating the absolute path of the font file
+ * @param point_size used for glyph generation
+ * @param dpi used for glyph generation
+ * @return pointer to font_t structure on success or NULL on failure
+ */
+font_t* bbutil_load_font(const char* font_file, int point_size, int dpi);
+
+/**
+ * Destroys the passed font
+ * @param font to be destroyed
+ */
+void bbutil_destroy_font(font_t* font);
+
+/**
+ * Renders the specified message using current font starting from the specified
+ * bottom left coordinates.
+ * NOTE: must be called after a successful return from bbutil_init() or bbutil_init_egl() call
+
+ *
+ * @param font to use for rendering
+ * @param msg the message to display
+ * @param x, y position of the bottom-left corner of text string in world coordinate space
+ * @param rgba color for the text to render with
+ */
+void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r, float g, float b, float a);
+
+/**
+ * Returns the non-scaled width and height of a string
+ * NOTE: must be called after a successful return from bbutil_init() or bbutil_init_egl() call
+
+ *
+ * @param font to use for measurement of a string size
+ * @param msg the message to get the size of
+ * @param return pointer for width of a string
+ * @param return pointer for height of a string
+ */
+void bbutil_measure_text(font_t* font, const char* msg, float* width, float* height);
+
+/**
+ * Creates and loads a texture from a png file
+ * NOTE: must be called after a successful return from bbutil_init() or bbutil_init_egl() call
+
+ *
+ * @param filename path to texture png
+ * @param return width of texture
+ * @param return height of texture
+ * @param return gl texture handle
+ * @return EXIT_SUCCESS if texture loading succeeded otherwise EXIT_FAILURE
+ */
+
+int bbutil_load_texture(const char* filename, int* width, int* height, float* tex_x, float* tex_y, unsigned int* tex);
+
+/**
+ * Returns dpi for a given screen
+
+ *
+ * @param ctx path libscreen context that corresponds to display of interest
+ * @return dpi for a given screen
+ */
+
+int bbutil_calculate_dpi(screen_context_t ctx);
+
+/**
+ * Rotates the screen to a given angle
+
+ *
+ * @param angle to rotate screen surface to, must by 0, 90, 180, or 270
+ * @return EXIT_SUCCESS if texture loading succeeded otherwise EXIT_FAILURE
+ */
+
+int bbutil_rotate_screen_surface(int angle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
View
59 Testbed/qnx/bbmain.cpp → Testbed/blackberry/main.cpp
@@ -25,6 +25,7 @@
#include <bps/screen.h>
#include <bps/bps.h>
#include <bps/event.h>
+#include <bps/virtualkeyboard.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
@@ -42,6 +43,8 @@
#include "bbutil.h"
+#define KEYBOARD_HITSIZE 20
+
namespace
{
int32 testIndex = 0;
@@ -52,6 +55,7 @@ namespace
Settings settings;
int32 width = 640;
int32 height = 480;
+ int32 screen_height;
int32 framePeriod = 16; // = 1/60 * 1000
int32 mainWindow;
float settingsHz = 60.0;
@@ -64,8 +68,9 @@ namespace
struct gestures_set * set;
b2Vec2 centerPrev;
b2Vec2 centerNext;
- const font_t* font;
+ font_t* font;
screen_context_t screen_cxt;
+ bool keyboard_visible = false;
}
// convert the timespec into milliseconds
@@ -315,14 +320,11 @@ static void gestureCallback(gesture_base_t* gesture, mtouch_event_t* event, void
*/
static void initGestures()
{
- gesture_tap_t* tap;
- gesture_double_tap_t* double_tap;
-
set = gestures_set_alloc();
- if (NULL != set)
+ if (set)
{
- tap = tap_gesture_alloc(NULL, gestureCallback, set);
- double_tap = double_tap_gesture_alloc(NULL, gestureCallback, set);
+ tap_gesture_alloc(NULL, gestureCallback, set);
+ double_tap_gesture_alloc(NULL, gestureCallback, set);
tfpan_gesture_alloc(NULL, gestureCallback, set);
pinch_gesture_alloc(NULL, gestureCallback, set);
}
@@ -366,7 +368,12 @@ void handleScreenEvent(bps_event_t *event)
if (!rc)
{
if (screen_val == SCREEN_EVENT_MTOUCH_TOUCH)
+ {
MouseDown(mtouch_event.x, mtouch_event.y);
+
+ if (!keyboard_visible && mtouch_event.x < KEYBOARD_HITSIZE && mtouch_event.y > screen_height - KEYBOARD_HITSIZE)
+ virtualkeyboard_show();
+ }
else if (screen_val == SCREEN_EVENT_MTOUCH_MOVE)
test->MouseMove(ConvertScreenToWorld(mtouch_event.x, mtouch_event.y));
else
@@ -404,7 +411,7 @@ int initialize()
int dpi = bbutil_calculate_dpi(screen_cxt);
- font = bbutil_load_font("/usr/fonts/font_repository/monotype/tahoma.ttf", 6, dpi);
+ font = bbutil_load_font("/usr/fonts/font_repository/monotype/tahoma.ttf", 5, dpi);
if (!font)
return EXIT_FAILURE;
@@ -416,6 +423,7 @@ int initialize()
width = surface_width;
height = surface_height;
+ screen_height = surface_height;
// calculate the position of the next/prev buttons in world coordinates
centerPrev.x = width / 2 - 88;
@@ -456,6 +464,10 @@ void drawWidgets()
glMatrixMode(GL_MODELVIEW);
+ b2Vec2 axis(1.0f, 0.0f);
+ b2Vec2 point(10.0f, 10.0f);
+ const b2Color color2(0.0f, 0.0f, 1.0f);
+
localDraw.DrawCircle(centerPrev, radius, color);
localDraw.DrawCircle(centerNext, radius, color);
@@ -500,6 +512,14 @@ void render()
viewZoom = 1.0f;
settings.viewCenter.Set(0.0f, 20.0f);
Resize(width, height);
+
+ if (keyboard_visible)
+ {
+ int pixels;
+
+ virtualkeyboard_get_height(&pixels);
+ MouseScrollBy(0, -pixels);
+ }
}
}
@@ -507,6 +527,7 @@ int main(int argc, char *argv[])
{
int exit_application = 0;
int rc;
+ int pixels;
//Create a screen context that will be used to create an EGL surface to to receive libscreen events
screen_create_context(&screen_cxt, 0);
@@ -516,8 +537,10 @@ int main(int argc, char *argv[])
//Initialize BPS library
bps_initialize();
+ virtualkeyboard_request_events(0);
+
//Use utility code to initialize EGL for 2D rendering with GL ES 1.1
- if (EXIT_SUCCESS != bbutil_init_egl(screen_cxt, GL_ES_1, AUTO))
+ if (EXIT_SUCCESS != bbutil_init_egl(screen_cxt))//, GL_ES_1, AUTO))
{
fprintf(stderr, "bbutil_init_egl failed\n");
bbutil_terminate();
@@ -599,7 +622,23 @@ int main(int argc, char *argv[])
{
int domain = bps_event_get_domain(event);
- if (domain == screen_get_domain())
+ if (domain == virtualkeyboard_get_domain())
+ {
+ switch (bps_event_get_code(event))
+ {
+ case VIRTUALKEYBOARD_EVENT_VISIBLE:
+ keyboard_visible = true;
+ virtualkeyboard_get_height(&pixels);
+ MouseScrollBy(0, -pixels);
+ break;
+ case VIRTUALKEYBOARD_EVENT_HIDDEN:
+ keyboard_visible = false;
+ virtualkeyboard_get_height(&pixels);
+ MouseScrollBy(0, pixels);
+ break;
+ }
+ }
+ else if (domain == screen_get_domain())
{
handleScreenEvent(event);
}
View
894 Testbed/qnx/bbutil.cpp
@@ -1,894 +0,0 @@
-#include <assert.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/keycodes.h>
-#include <time.h>
-#include <stdbool.h>
-#include <math.h>
-
-#include "bbutil.h"
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#include "png.h"
-
-EGLDisplay egl_disp;
-EGLSurface egl_surf;
-
-static EGLConfig egl_conf;
-static EGLContext egl_ctx;
-
-static screen_context_t screen_ctx;
-static screen_window_t screen_win;
-static screen_display_t screen_disp;
-static int nbuffers = 2;
-
-static int initialized = 0;
-
-static void
-bbutil_egl_perror(const char *msg) {
- static const char *errmsg[] = {
- "function succeeded",
- "EGL is not initialized, or could not be initialized, for the specified display",
- "cannot access a requested resource",
- "failed to allocate resources for the requested operation",
- "an unrecognized attribute or attribute value was passed in an attribute list",
- "an EGLConfig argument does not name a valid EGLConfig",
- "an EGLContext argument does not name a valid EGLContext",
- "the current surface of the calling thread is no longer valid",
- "an EGLDisplay argument does not name a valid EGLDisplay",
- "arguments are inconsistent",
- "an EGLNativePixmapType argument does not refer to a valid native pixmap",
- "an EGLNativeWindowType argument does not refer to a valid native window",
- "one or more argument values are invalid",
- "an EGLSurface argument does not name a valid surface configured for rendering",
- "a power management event has occurred",
- };
-
- fprintf(stderr, "%s: %s\n", msg, errmsg[eglGetError() - EGL_SUCCESS]);
-}
-EGLConfig bbutil_choose_config(EGLDisplay egl_disp, enum RENDERING_API api) {
- EGLConfig egl_conf = (EGLConfig)0;
- EGLConfig *egl_configs;
- EGLint egl_num_configs;
- EGLint val;
- EGLBoolean rc;
- EGLint i;
-
- rc = eglGetConfigs(egl_disp, NULL, 0, &egl_num_configs);
- if (rc != EGL_TRUE) {
- bbutil_egl_perror("eglGetConfigs");
- return egl_conf;
- }
- if (egl_num_configs == 0) {
- fprintf(stderr, "eglGetConfigs: could not find a configuration\n");
- return egl_conf;
- }
-
- egl_configs = (EGLConfig *)malloc(egl_num_configs * sizeof(*egl_configs));
- if (egl_configs == NULL) {
- fprintf(stderr, "could not allocate memory for %d EGL configs\n", egl_num_configs);
- return egl_conf;
- }
-
- rc = eglGetConfigs(egl_disp, egl_configs,
- egl_num_configs, &egl_num_configs);
- if (rc != EGL_TRUE) {
- bbutil_egl_perror("eglGetConfigs");
- free(egl_configs);
- return egl_conf;
- }
-
- for (i = 0; i < egl_num_configs; i++) {
- eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_SURFACE_TYPE, &val);
- if (!(val & EGL_WINDOW_BIT)) {
- continue;
- }
-
- eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_RENDERABLE_TYPE, &val);
- if (!(val & api)) {
- continue;
- }
-
- eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_DEPTH_SIZE, &val);
- if ((api & (GL_ES_1|GL_ES_2)) && (val == 0)) {
- continue;
- }
-
- eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_RED_SIZE, &val);
- if (val != 8) {
- continue;
- }
- eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_GREEN_SIZE, &val);
- if (val != 8) {
- continue;
- }
-
- eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_BLUE_SIZE, &val);
- if (val != 8) {
- continue;
- }
-
- eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_BUFFER_SIZE, &val);
- if (val != 32) {
- continue;
- }
-
- egl_conf = egl_configs[i];
- break;
- }
-
- free(egl_configs);
-
- if (egl_conf == (EGLConfig)0) {
- fprintf(stderr, "bbutil_choose_config: could not find a matching configuration\n");
- }
-
- return egl_conf;
-}
-
-int
-bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api, enum ORIENTATION orientation) {
- int usage;
- int format = SCREEN_FORMAT_RGBX8888;
- EGLint interval = 1;
- int rc;
- EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
-
- if (api == GL_ES_1) {
- usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
- } else if (api == GL_ES_2) {
- usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
- } else if (api == VG) {
- usage = SCREEN_USAGE_OPENVG | SCREEN_USAGE_ROTATION;
- } else {
- fprintf(stderr, "invalid api setting\n");
- return EXIT_FAILURE;
- }
-
- //Simple egl initialization
- screen_ctx = ctx;
-
- egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (egl_disp == EGL_NO_DISPLAY) {
- bbutil_egl_perror("eglGetDisplay");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- rc = eglInitialize(egl_disp, NULL, NULL);
- if (rc != EGL_TRUE) {
- bbutil_egl_perror("eglInitialize");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- if ((api == GL_ES_1) || (api == GL_ES_2)) {
- rc = eglBindAPI(EGL_OPENGL_ES_API);
- } else if (api == VG) {
- rc = eglBindAPI(EGL_OPENVG_API);
- }
-
- if (rc != EGL_TRUE) {
- bbutil_egl_perror("eglBindApi");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- egl_conf = bbutil_choose_config(egl_disp, api);
- if (egl_conf == (EGLConfig)0) {
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- if (api == GL_ES_2) {
- egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, attributes);
- } else {
- egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, NULL);
- }
-
- if (egl_ctx == EGL_NO_CONTEXT) {
- bbutil_egl_perror("eglCreateContext");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- rc = screen_create_window(&screen_win, screen_ctx);
- if (rc) {
- perror("screen_create_window");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);
- if (rc) {
- perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);
- if (rc) {
- perror("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- rc = screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
- if (rc) {
- perror("screen_get_window_property_pv");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- if (orientation != AUTO) {
- int screen_resolution[2];
- rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
- if (rc) {
- perror("screen_get_display_property_iv");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- int angle = atoi(getenv("ORIENTATION"));
- int buffer_size[2] = {screen_resolution[0], screen_resolution[1]};
- int flip = false;
-
- if (((angle == 90) || (angle == 270)) && (orientation == LANDSCAPE)) {
- angle = 0;
- buffer_size[0] = screen_resolution[1];
- buffer_size[1] = screen_resolution[0];
- flip = true;
- } else if (((angle == 0) || (angle == 180)) && (orientation == PORTRAIT)) {
- buffer_size[0] = screen_resolution[1];
- buffer_size[1] = screen_resolution[0];
- flip = true;
- }
-
- if (flip) {
- rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle);
- if (rc) {
- perror("screen_set_window_property_iv");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);
- if (rc) {
- perror("screen_set_window_property_iv");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
- }
- }
-
- rc = screen_create_window_buffers(screen_win, nbuffers);
- if (rc) {
- perror("screen_create_window_buffers");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, NULL);
- if (egl_surf == EGL_NO_SURFACE) {
- bbutil_egl_perror("eglCreateWindowSurface");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- rc = eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx);
- if (rc != EGL_TRUE) {
- bbutil_egl_perror("eglMakeCurrent");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- rc = eglSwapInterval(egl_disp, interval);
- if (rc != EGL_TRUE) {
- bbutil_egl_perror("eglSwapInterval");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
-
- initialized = true;
-
- return EXIT_SUCCESS;
-}
-
-void
-bbutil_terminate() {
- //Typical EGL cleanup
- if (egl_disp != EGL_NO_DISPLAY) {
- eglMakeCurrent(egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- if (egl_surf != EGL_NO_SURFACE) {
- eglDestroySurface(egl_disp, egl_surf);
- egl_surf = EGL_NO_SURFACE;
- }
- if (egl_ctx != EGL_NO_CONTEXT) {
- eglDestroyContext(egl_disp, egl_ctx);
- egl_ctx = EGL_NO_CONTEXT;
- }
- if (screen_win != NULL) {
- screen_destroy_window(screen_win);
- screen_win = NULL;
- }
- eglTerminate(egl_disp);
- egl_disp = EGL_NO_DISPLAY;
- }
- eglReleaseThread();
-
- initialized = false;
-}
-
-void
-bbutil_swap() {
- int rc = eglSwapBuffers(egl_disp, egl_surf);
- if (rc != EGL_TRUE) {
- bbutil_egl_perror("eglSwapBuffers");
- }
-}
-
-/* Finds the next power of 2 */
-static inline int
-nextp2(int x)
-{
- int val = 1;
- while(val < x) val <<= 1;
- return val;
-}
-
-font_t* bbutil_load_font(const char* path, int point_size, int dpi) {
- FT_Library library;
- FT_Face face;
- int c;
- int i, j;
- font_t* font;
-
- if (!initialized) {
- fprintf(stderr, "EGL has not been initialized\n");
- return NULL;
- }
-
- if (!path){
- fprintf(stderr, "Invalid path to font file\n");
- return NULL;
- }
-
- if(FT_Init_FreeType(&library)) {
- fprintf(stderr, "Error loading Freetype library\n");
- return NULL;
- }
- if (FT_New_Face(library, path,0,&face)) {
- fprintf(stderr, "Error loading font %s\n", path);
- return NULL;
- }
-
- if(FT_Set_Char_Size ( face, point_size * 64, point_size * 64, dpi, dpi)) {
- fprintf(stderr, "Error initializing character parameters\n");
- return NULL;
- }
-
- font = (font_t*) malloc(sizeof(font_t));
- font->initialized = false;
-
- glGenTextures(1, &(font->font_texture));
-
- //Let each glyph reside in 32x32 section of the font texture
- int segment_size_x = 0, segment_size_y = 0;
- int num_segments_x = 16;
- int num_segments_y = 8;
-
- FT_GlyphSlot slot;
- FT_Bitmap bmp;
- int glyph_width, glyph_height;
- font->max_height = 0;
-
- //First calculate the max width and height of a character in a passed font
- for(c = 0; c < 128; c++) {
- if(FT_Load_Char(face, c, FT_LOAD_RENDER)) {
- fprintf(stderr, "FT_Load_Char failed\n");
- free(font);
- return NULL;
- }
-
- slot = face->glyph;
- bmp = slot->bitmap;
-
- //glyph_width = nextp2(bmp.width);
- //glyph_height = nextp2(bmp.rows);
-
- glyph_width = bmp.width;
- glyph_height = bmp.rows;
-
- if (glyph_width > segment_size_x) {
- segment_size_x = glyph_width;
- }
-
- if (glyph_height > segment_size_y) {
- segment_size_y = glyph_height;
- }
- }
-
- int font_tex_width = nextp2(num_segments_x * segment_size_x);
- int font_tex_height = nextp2(num_segments_y * segment_size_y);
-
- int bitmap_offset_x = 0, bitmap_offset_y = 0;
-
- GLubyte* font_texture_data = (GLubyte*) malloc(sizeof(GLubyte) * 2 * font_tex_width * font_tex_height);
-
- if (!font_texture_data) {
- fprintf(stderr, "Failed to allocate memory for font texture\n");
- free(font);
- return NULL;
- }
-
- // Fill font texture bitmap with individual bmp data and record appropriate size, texture coordinates and offsets for every glyph
- for(c = 0; c < 128; c++) {
- if(FT_Load_Char(face, c, FT_LOAD_RENDER)) {
- fprintf(stderr, "FT_Load_Char failed\n");
- free(font);
- return NULL;
- }
-
- slot = face->glyph;
- bmp = slot->bitmap;
-
- glyph_width = nextp2(bmp.width);
- glyph_height = nextp2(bmp.rows);
-
- div_t temp = div(c, num_segments_x);
-
- bitmap_offset_x = segment_size_x * temp.rem;
- bitmap_offset_y = segment_size_y * temp.quot;
-
- for (j = 0; j < glyph_height; j++) {
- for (i = 0; i < glyph_width; i++) {
- font_texture_data[2 * ((bitmap_offset_x + i) + (j + bitmap_offset_y) * font_tex_width) + 0] =