texturec.bmx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. ' Copyright (c) 2015-2018 Bruce A Henderson
  2. ' All rights reserved.
  3. '
  4. ' Redistribution and use in source and binary forms, with or without
  5. ' modification, are permitted provided that the following conditions are met:
  6. '
  7. ' * Redistributions of source code must retain the above copyright notice, this
  8. ' list of conditions and the following disclaimer.
  9. '
  10. ' * Redistributions in binary form must reproduce the above copyright notice,
  11. ' this list of conditions and the following disclaimer in the documentation
  12. ' and/or other materials provided with the distribution.
  13. '
  14. ' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  15. ' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. ' IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. ' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  18. ' FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. ' DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  20. ' SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  21. ' CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  22. ' OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. ' OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. '
  25. SuperStrict
  26. Rem
  27. bbdoc: BGFX Texture Compiler
  28. End Rem
  29. Module gfx.texturec
  30. ?linuxx86
  31. ModuleInfo "CC_OPTS: -mfpmath=sse -msse2 -std=c++0x"
  32. ?linuxx64
  33. ModuleInfo "CC_OPTS: -mfpmath=sse -msse2 -std=c++0x"
  34. ?macos
  35. ModuleInfo "CC_OPTS: -msse2"
  36. ?win32
  37. ModuleInfo "CC_OPTS: -mfpmath=sse -msse2 -std=c++0x"
  38. ModuleInfo "CC_OPTS: -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS"
  39. ?raspberrypi
  40. ModuleInfo "CC_OPTS: -std=c++0x"
  41. ?
  42. Import "common.bmx"
  43. Type TOptions
  44. Field optionsPtr:Byte Ptr
  45. Method New()
  46. optionsPtr = bmx_bimg_options_new()
  47. End Method
  48. Method SetMaxSize:TOptions(maxSize:Int)
  49. bmx_bimg_options_setMaxSize(optionsPtr, maxSize)
  50. Return Self
  51. End Method
  52. Method SetEdge:TOptions(edge:Float = 0.0)
  53. bmx_bimg_options_setEdge(optionsPtr, edge)
  54. Return Self
  55. End Method
  56. Method SetFormat:TOptions(format:Int)
  57. bmx_bimg_options_setFormat(optionsPtr, format)
  58. Return Self
  59. End Method
  60. Method SetQuality:TOptions(quality:Int)
  61. bmx_bimg_options_setQuality(optionsPtr, quality)
  62. Return Self
  63. End Method
  64. Method SetMips:TOptions(mips:Int)
  65. bmx_bimg_options_setMips(optionsPtr, mips)
  66. Return Self
  67. End Method
  68. Method SetNormalMap:TOptions(normalMap:Int)
  69. bmx_bimg_options_setNormalMap(optionsPtr, normalMap)
  70. Return Self
  71. End Method
  72. Method SetEquirect:TOptions(equirect:Int)
  73. bmx_bimg_options_setEquirect(optionsPtr, equirect)
  74. Return Self
  75. End Method
  76. Method SetIqa:TOptions(iqa:Int)
  77. bmx_bimg_options_setIqa(optionsPtr, iqa)
  78. Return Self
  79. End Method
  80. Method SetPma:TOptions(pma:Int)
  81. bmx_bimg_options_setPma(optionsPtr, pma)
  82. Return Self
  83. End Method
  84. Method SetSdf:TOptions(sdf:Int)
  85. bmx_bimg_options_setSdf(optionsPtr, sdf)
  86. Return Self
  87. End Method
  88. Method SetAlphaTest:TOptions(alphaTest:Int)
  89. bmx_bimg_options_setAlphaTest(optionsPtr, alphaTest)
  90. Return Self
  91. End Method
  92. Method SetOutputType:TOptions(outputType:Int)
  93. bmx_bimg_options_setOutputType(optionsPtr, outputType)
  94. Return Self
  95. End Method
  96. Method Delete()
  97. If optionsPtr Then
  98. bmx_bimg_options_free(optionsPtr)
  99. optionsPtr = Null
  100. End If
  101. End Method
  102. End Type
  103. Rem
  104. bbdoc:
  105. End Rem
  106. Function TextureC(in:TStream, out:TStream, options:TOptions = Null)
  107. Local iStream:TBxStreamWrapper = New TBxStreamWrapper.Create(in)
  108. Local oStream:TBxStreamWrapper = New TBxStreamWrapper.Create(out)
  109. If options Then
  110. bmx_bimg_texturec_convert(iStream.bxStreamPtr, oStream.bxStreamPtr, options.optionsPtr)
  111. Else
  112. bmx_bimg_texturec_convert(iStream.bxStreamPtr, oStream.bxStreamPtr, Null)
  113. End If
  114. iStream.Free()
  115. oStream.Free()
  116. End Function