diff --git a/CHANGELOG b/CHANGELOG index d3396f5f..74a9aa92 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,20 @@ +v0.8.0 + * __Breaking change__: Removed SOIL since it doesn't compile on macOS Catalina + and replaced it with GID. Added `opengl-images.gpr` to replace SOIL + functionality. + * __Breaking change__: Removed the long-deprecated FTGL binding. + * Fixed the binding of `glGetTransformFeedbackVarying` + * Fixed a bug when creating an empty Depth_Component texture (#135) + * Added package: + - GL.Objects.Queries + * Added missing functionality in: + - GL.Rasterization (glPolygonOffset) + - GL.Objects.Buffers (glDrawTransformFeedback, glDrawTransformFeedbackStream, + glGenTransformFeedbacks, glDeleteTransformFeedbacks, + glBindTransformFeedback, glMapBufferRange, + glFlushMappedBufferRange, glGetBufferSubData) + + * Fixed a bug when querying shaders from a program object (#129). v0.7.0: * Added missing functionality in: - GL.Objects.Buffers (glBindBufferBase, glDrawElementsInstanced, diff --git a/Makefile b/Makefile index f201d904..1ea74639 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ GNATFLAGS ?= GLFW_VERSION ?=3 GPRBUILD = gprbuild ${GNATFLAGS} -p +GPRINSTALL = gprinstall -p WINDOWING_BACKEND := windows GENERATE_EXE := bin/generate.exe diff --git a/README.md b/README.md index fe3c3747..d7ee68a4 100644 --- a/README.md +++ b/README.md @@ -18,36 +18,47 @@ bindings to the following OpenGL-related libraries: significant differences between these two, the most prominent being that GLFW 3 can handle multiple windows. You can set the desired GLFW version for the binding at compile time. - * [SOIL][10] (`opengl-soil.gpr`): The *Simple OpenGL Image Library*. This is a - very tiny library for loading image files into OpenGL textures. It is public - domain. Because it's so tiny, it is linked directly into OpenGLAda. Its - source is included in the OpenGLAda sources. - * [FTGL][11] (`opengl-ftgl.gpr`, **deprecated**): A library built on top of - FreeType that provides an API to load TrueType fonts and render text with - OpenGL. The Ada wrapper only provides basic functionality to load fonts and - render text. As it does not include a wrapper to FreeType, the more low-level - functionality has been excluded. **This wrapper is not maintained anymore in - favor of the new FreeType wrapper.** - * [FreeType][19] (`FreeTypeAda/freetype.gpr`): A library for loading TrueType - and OpenType fonts. OpenGLAda includes [FreeTypeAda][20], a wrapper for the - FreeType library. The project `opengl-text.gpr` provides an original + * [FreeType][19] (`deps/FreeTypeAda/freetype.gpr`): A library for loading + TrueType and OpenType fonts. OpenGLAda includes [FreeTypeAda][20], a wrapper + for the FreeType library. The project `opengl-text.gpr` provides an original higher-level API for rendering text based on FreeTypeAda. + * [GID][10] (`deps/gid/gid.gpr`): The *Generic Image Decoder*. This is an + original Ada library for loading common image formats, which is included in + OpenGLAda. The project `opengl-images.gpr` provides an original higher-level + API for generating OpenGL textures with GID. -OpenGLAda supports MacOSX, Windows and X11-based systems. API documentation can +OpenGLAda supports macOS, Windows and X11-based systems. API documentation can be found on the [project's homepage][4]. -## Windows Installer +### Migrating from C -There is an installer available for Windows + GNAT Community in the -[repository's *releases* section][21] which includes all optional dependencies -except FTGL (because that binding is deprecated). +Compared to C, OpenGLAda provides the features of the following C libraries: -## Prerequisites + * OpenGL + * [GLEW][22]: OpenGLAda loads all post-OpenGL 1.1 subroutines dynamically via + pointers, so that available features may be queried at runtime. + * [GLUT][23]: Long deprecated, yet still referenced from articles about OpenGL. + OpenGLAda provides an optional wrapper for the GLFW library that provides + functionality similar to GLUT. + + Text rendering functionality superior to what GLUT provides are supplied by + `opengl-text.gpr` with the help of the FreeType library. + * [Image loading][24]: OpenGLAda includes the [GID][10] library for image + loading. + +## Building & Installation + +### Windows + +There is an installer available for 64bit Windows + GNAT Community in the +[repository's *releases* section][21] which includes all optional dependencies. + +### Prerequisites In order to build OpenGLAda, you need to have: * A GNAT compiler¹. Compilers known to work well with OpenGLAda are - [GnuAda][12], [GNAT Community 2018][1], and [TDM-GCC][17]. More information + [GnuAda][12], [GNAT Community 2020][1], and [TDM-GCC][17]. More information is available on the [GCC website][5]. * [GPRBuild][2] (is bundled with AdaCore's GNAT distribution). TDM-GCC users can get it from [here][16] (**NOTE: The gprbuild bundled in this zip is @@ -58,20 +69,19 @@ In order to build OpenGLAda, you need to have: * An OpenGL implementation (usually comes bundled with your graphics driver) * Optionally [GLFW][3] (OpenGLAda is pretty useless without the ability to create an OpenGL context.) - * Optionally [FTGL][11] (**deprecated**) * Optionally [FreeType][19] ¹: You may also be able to build OpenGLAda with another Ada compiler and/or without using the `*.gpr` files. You just have to import the sources to your project and whichever build system you are using. I never used other Ada compilers apart from GNAT, so if I accidentally used some GNAT-specific features -in the code, please drop me a message. +in the code, open an issue. -## Installation +### Installation To install OpenGLAda with all optional libraries, execute - $ gprbuild [options] openglada.gpr + $ gprbuild -p [options] openglada.gpr $ gprinstall [options] openglada.gpr Where *[options]* is the set of scenario variables you want to use (generally @@ -82,7 +92,7 @@ in the form of `-X`*name*`=`*value*`). The available variables are: - `x11`: X Windowing System (Linux, BSD, etc) - `windows`: Microsoft Windows - - `quartz`: Quartz Compositor (OS X) + - `quartz`: Quartz Compositor (macOS) * `mode`: May take one of the following values: @@ -111,18 +121,18 @@ in the form of `-X`*name*`=`*value*`). The available variables are: For example, a typical Windows installation would be - $ gprbuild -XWindowing_System=windows -Xmode=release openglada.gpr + $ gprbuild -p -XWindowing_System=windows -Xmode=release openglada.gpr $ gprinstall -XWindowing_System=windows -Xmode=release openglada.gpr -Installing OpenGLAda makes its projects available to `gprbuild` and also to the -GPS GUI. You can now import it like this: +Installing OpenGLAda makes its projects available to `gprbuild` and also to +GNAT Studio. You can now import it like this: with "opengl"; with "opengl-glfw"; with "opengl-text"; -- and so on -**Note:** The projects file `openglada.gpr` is just an aggregate project used +**Note:** The project file `openglada.gpr` is just an aggregate project used for installation. In your projects, depend on `opengl.gpr` and its child projects. @@ -141,51 +151,75 @@ instead: $ gprbuild -P opengl-glfw-test.gpr -XWindowing_System=windows $ gprbuild -P opengl-test.gpr -XWindowing_System=windows + $ gprbuild -P opengl-text-test.gpr -XWindowing_System=windows + $ gprbuild -P opengl-images-test.gpr -XWindowing_System=windows The tests require GLFW, because they need to create windows. By default, they try to link against GLFW 3+. You can instead build the tests against GLFW 2.x -by executing: +by adding the parameter `-XGLFW_Version=2`. - $ gprbuild -P opengl-test.gpr -XWindowing_System=windows -XGLFW_Version=2 - $ gprbuild -P opengl-glfw-test.gpr -XWindowing_System=windows -XGLFW_Version=2 +## Examples -(Substitute `windows` with `x11` or `quartz` if needed.) +Examples are available in [this repository][11]. -## Examples +## Developer Documentation -OpenGLAda comes bundled with a lot of examples. They have mostly been translated -from C examples from OpenGL textbooks. They are located inside the `examples` -folder. Each example has a separate `.gpr` file with which it can be built. +I have written an article about the development of OpenGLAda on AdaCore's blog: -Contributions of examples are always welcome. + * [Part 1][25] + * [Part 2][26] -## Developer Documentation +### Binding Generation + +OpenGL implementations do not necessarily provide the newest OpenGL version, +but possibly some older one with some functionality of the newer versions +provided as extensions. For OpenGLAda, this means that most OpenGL functionality +cannot be linked against via the library loader, since loading the library +would immediately fail if any function is not available, even if the user never +calls it. Most notoriously, Windows does not provide any OpenGL functionality +newer than 1.1 via library loading. + +The remedy for this is that function pointers of newer OpenGL functions must +be queried at runtime. This is a tedious process and similar for each function. +For this reason, OpenGLAda uses a code generator to autogenerate the function +pointer types and the code loading each function, as well as the code importing +OpenGL 1.1 functions via library loading. + +The code generator can be found in `src/generator`. It processes the files found +in `src/gl/specs` and creates the files found in `src/gl/generated`. The +generator is a tool used at compile-time for building OpenGLAda and of no +interest to the general user. The generated files are checked in to version +control. The generator also generates the markdown file which is the base for +the [function mapping list][27] on the website. -OpenGLAda autogenerates its API binding to OpenGL. The autogenerated source -files are those in `src/gl/generated` and they are generated from the `*.spec` -files in `src/gl/specs`. The syntax of the spec files is similar to Ada. +The process of wrapping a new OpenGL function is: -The reason behind this is that all functionality newer than OpenGL 1.1 is not -expected to be provided by the OpenGL implementation. Instead, function pointers -to the implementations should be queried at runtime. This makes it possible for -the user to provide a fallback in case some OpenGL functionality is not -available on the target system. + * Add the function specification to one of the `*.spec` files in `src/gl/specs`. + * Run `make generate`, which builds the generator and generates the Ada code. + * Check in the newly generated code along with the changed spec. -The `generate` tool compiled from `src/generator` will take care of creating -both the API imports from OpenGL and the code for loading the function pointers -at runtime. The tool is only necessary when adding OpenGL API functions to -OpenGLAda and thus not of interest to the general user, since the autogenerated -files are checked in to version control. +The `*.spec` files use a syntax similar to Ada. -If you change the `*.spec` files, running `make generate` afterwards will -update the autogenerated files. Be sure to check them in along with the spec -changes. +### Building the Windows Installer + +The Windows installer is generated with the [WiX Toolset][28]. You'll need its +executables `heat.exe`, `candle.exe` and `light.exe` in your `PATH`. Executing +the script `create-msi.ps1` in the `install` directory containing it will + + * download binaries of the GLFW and FreeType libraries + * build OpenGLAda with GNAT + * install OpenGLAda in a temporary directory + * Build an MSI installer that will copy OpenGLAda's binaries as well as the + GLFW and FreeType libraries into the installation directory of a + GNAT Community installation. ## License -OpenGLAda is distributed under the terms of the [MIT License][7]. The Ada 2012 -logo that is used in the SOIL tests is distributed under the terms of the -[CC BY-ND 3.0][8] license, the original author is [AdaCore][9]. +OpenGLAda, as well as the included libraries FreeTypeAda and GID, are +distributed under the terms of the [MIT License][7]. + +The Ada 2012 logo that is used in the images tests is distributed under the +terms of the [CC BY-ND 3.0][8] license, the original author is [AdaCore][9]. [1]: http://libre.adacore.com/ [2]: http://www.adacore.com/gnatpro/toolsuite/gprbuild/ @@ -196,12 +230,19 @@ logo that is used in the SOIL tests is distributed under the terms of the [7]: COPYING [8]: http://creativecommons.org/licenses/by-nd/3.0/deed.en_GB [9]: http://www.ada2012.org/#the_logo - [10]: http://www.lonesock.net/soil.html - [11]: https://sourceforge.net/projects/ftgl/ + [10]: https://gen-img-dec.sourceforge.io/ + [11]: https://github.com/flyx/OpenGLAda-examples [12]: https://sourceforge.net/projects/gnuada/files/ [13]: http://flyx.github.io/OpenGLAda/setup.html [16]: http://getadanow.com/#get_windows [17]: http://tdm-gcc.tdragon.net/ [19]: https://freetype.org/ [20]: https://github.com/flyx/FreeTypeAda - [21]: https://github.com/flyx/OpenGLAda/releases \ No newline at end of file + [21]: https://github.com/flyx/OpenGLAda/releases + [22]: http://glew.sourceforge.net/ + [23]: https://www.opengl.org/resources/libraries/glut/ + [24]: https://www.khronos.org/opengl/wiki/Image_Libraries + [25]: https://blog.adacore.com/the-road-to-a-thick-opengl-binding-for-ada + [26]: https://blog.adacore.com/the-road-to-a-thick-opengl-binding-for-ada-part-2 + [27]: https://flyx.github.io/OpenGLAda/mapping.html + [28]: https://wixtoolset.org/ \ No newline at end of file diff --git a/FreeTypeAda/.gitrepo b/deps/FreeTypeAda/.gitrepo similarity index 100% rename from FreeTypeAda/.gitrepo rename to deps/FreeTypeAda/.gitrepo diff --git a/FreeTypeAda/COPYING b/deps/FreeTypeAda/COPYING similarity index 100% rename from FreeTypeAda/COPYING rename to deps/FreeTypeAda/COPYING diff --git a/FreeTypeAda/README.md b/deps/FreeTypeAda/README.md similarity index 100% rename from FreeTypeAda/README.md rename to deps/FreeTypeAda/README.md diff --git a/FreeTypeAda/freetype.gpr b/deps/FreeTypeAda/freetype.gpr similarity index 100% rename from FreeTypeAda/freetype.gpr rename to deps/FreeTypeAda/freetype.gpr diff --git a/FreeTypeAda/src/ft-api-glyphs.ads b/deps/FreeTypeAda/src/ft-api-glyphs.ads similarity index 100% rename from FreeTypeAda/src/ft-api-glyphs.ads rename to deps/FreeTypeAda/src/ft-api-glyphs.ads diff --git a/FreeTypeAda/src/ft-api.ads b/deps/FreeTypeAda/src/ft-api.ads similarity index 100% rename from FreeTypeAda/src/ft-api.ads rename to deps/FreeTypeAda/src/ft-api.ads diff --git a/FreeTypeAda/src/ft-errors.adb b/deps/FreeTypeAda/src/ft-errors.adb similarity index 100% rename from FreeTypeAda/src/ft-errors.adb rename to deps/FreeTypeAda/src/ft-errors.adb diff --git a/FreeTypeAda/src/ft-errors.ads b/deps/FreeTypeAda/src/ft-errors.ads similarity index 100% rename from FreeTypeAda/src/ft-errors.ads rename to deps/FreeTypeAda/src/ft-errors.ads diff --git a/FreeTypeAda/src/ft-faces.adb b/deps/FreeTypeAda/src/ft-faces.adb similarity index 100% rename from FreeTypeAda/src/ft-faces.adb rename to deps/FreeTypeAda/src/ft-faces.adb diff --git a/FreeTypeAda/src/ft-faces.ads b/deps/FreeTypeAda/src/ft-faces.ads similarity index 100% rename from FreeTypeAda/src/ft-faces.ads rename to deps/FreeTypeAda/src/ft-faces.ads diff --git a/FreeTypeAda/src/ft-glyphs.adb b/deps/FreeTypeAda/src/ft-glyphs.adb similarity index 100% rename from FreeTypeAda/src/ft-glyphs.adb rename to deps/FreeTypeAda/src/ft-glyphs.adb diff --git a/FreeTypeAda/src/ft-glyphs.ads b/deps/FreeTypeAda/src/ft-glyphs.ads similarity index 100% rename from FreeTypeAda/src/ft-glyphs.ads rename to deps/FreeTypeAda/src/ft-glyphs.ads diff --git a/FreeTypeAda/src/ft-utilities.adb b/deps/FreeTypeAda/src/ft-utilities.adb similarity index 100% rename from FreeTypeAda/src/ft-utilities.adb rename to deps/FreeTypeAda/src/ft-utilities.adb diff --git a/FreeTypeAda/src/ft-utilities.ads b/deps/FreeTypeAda/src/ft-utilities.ads similarity index 100% rename from FreeTypeAda/src/ft-utilities.ads rename to deps/FreeTypeAda/src/ft-utilities.ads diff --git a/FreeTypeAda/src/ft.adb b/deps/FreeTypeAda/src/ft.adb similarity index 100% rename from FreeTypeAda/src/ft.adb rename to deps/FreeTypeAda/src/ft.adb diff --git a/FreeTypeAda/src/ft.ads b/deps/FreeTypeAda/src/ft.ads similarity index 100% rename from FreeTypeAda/src/ft.ads rename to deps/FreeTypeAda/src/ft.ads diff --git a/deps/gid/build.cmd b/deps/gid/build.cmd new file mode 100644 index 00000000..b01748d0 --- /dev/null +++ b/deps/gid/build.cmd @@ -0,0 +1,4 @@ +gprbuild -p -P gid -XBuild_Mode=Debug to_bmp +copy test\to_bmp.exe test\tb.exe +gprbuild -p -P gid -XBuild_Mode=Fast +gprbuild -p -P gid -XBuild_Mode=Smallest mini diff --git a/deps/gid/debug.pra b/deps/gid/debug.pra new file mode 100644 index 00000000..d3691443 --- /dev/null +++ b/deps/gid/debug.pra @@ -0,0 +1,3 @@ +pragma Initialize_Scalars; +-- pragma Normalize_Scalars; -- For all units! + diff --git a/deps/gid/gid-buffering.adb b/deps/gid/gid-buffering.adb new file mode 100644 index 00000000..c6c9fa6f --- /dev/null +++ b/deps/gid/gid-buffering.adb @@ -0,0 +1,79 @@ +with Ada.IO_Exceptions; + +package body GID.Buffering is + + procedure Fill_Buffer(b: in out Input_buffer); + -- ^ Spec here to avoid warning by 'Get_Byte' below (GNAT 2009): + -- warning: call to subprogram with no separate spec prevents inlining + + procedure Fill_Buffer(b: in out Input_buffer) + is + -- + procedure BlockRead( + buffer : out Byte_array; + actually_read: out Natural + ) + is + use Ada.Streams; + Last_Read: Stream_Element_Offset; + begin + if is_mapping_possible then + declare + SE_Buffer_mapped: Stream_Element_Array (1 .. buffer'Length); + -- direct mapping: buffer = SE_Buffer_mapped + for SE_Buffer_mapped'Address use buffer'Address; + pragma Import (Ada, SE_Buffer_mapped); + begin + Read(b.stream.all, SE_Buffer_mapped, Last_Read); + end; + else + declare + SE_Buffer: Stream_Element_Array (1 .. buffer'Length); + -- need to copy array (slightly slower) + begin + Read(b.stream.all, SE_Buffer, Last_Read); + for i in buffer'Range loop + buffer(i):= U8(SE_Buffer(Stream_Element_Offset(i-buffer'First)+SE_Buffer'First)); + end loop; + end; + end if; + actually_read:= Natural(Last_Read); + end BlockRead; + -- + begin + BlockRead( + buffer => b.data, + actually_read => b.MaxInBufIdx + ); + b.InputEoF:= b.MaxInBufIdx = 0; + b.InBufIdx := 1; + end Fill_Buffer; + + procedure Attach_Stream( + b : out Input_buffer; + stm : in Stream_Access + ) + is + begin + b.stream:= stm; + -- Fill_Buffer(b) will be performed on first call of Get_Byte + end Attach_Stream; + + function Is_stream_attached(b: Input_buffer) return Boolean is + begin + return b.stream /= null; + end Is_stream_attached; + + procedure Get_Byte(b: in out Input_buffer; byte: out U8) is + begin + if b.InBufIdx > b.MaxInBufIdx then + Fill_Buffer(b); + if b.InputEoF then + raise Ada.IO_Exceptions.End_Error; + end if; + end if; + byte:= b.data(b.InBufIdx); + b.InBufIdx:= b.InBufIdx + 1; + end Get_Byte; + +end GID.Buffering; diff --git a/deps/gid/gid-buffering.ads b/deps/gid/gid-buffering.ads new file mode 100644 index 00000000..2f764a3f --- /dev/null +++ b/deps/gid/gid-buffering.ads @@ -0,0 +1,28 @@ +private package GID.Buffering is + + -- Attach a buffer to a stream. + procedure Attach_Stream( + b : out Input_buffer; + stm : in Stream_Access + ); + + function Is_stream_attached(b: Input_buffer) return Boolean; + + -- From the first call to Get_Byte, subsequent bytes must be read + -- through Get_Byte as well since the stream is partly read in advance + procedure Get_Byte(b: in out Input_buffer; byte: out U8); + pragma Inline(Get_Byte); + +private + + subtype Size_test_a is Byte_array(1..19); + subtype Size_test_b is Ada.Streams.Stream_Element_Array(1..19); + + -- is_mapping_possible: Compile-time test for checking if + -- a Byte_Array is equivalemnt to a Ada.Streams.Stream_Element_Array. + -- + is_mapping_possible: constant Boolean:= + Size_test_a'Size = Size_test_b'Size and + Size_test_a'Alignment = Size_test_b'Alignment; + +end GID.Buffering; diff --git a/deps/gid/gid-color_tables.adb b/deps/gid/gid-color_tables.adb new file mode 100644 index 00000000..b1d1ca86 --- /dev/null +++ b/deps/gid/gid-color_tables.adb @@ -0,0 +1,67 @@ +with GID.Buffering; + +package body GID.Color_tables is + + procedure Convert(c, d: in U8; rgb: out RGB_color) is + begin + rgb.red := (d and 127) / 4; + rgb.green:= (d and 3) * 8 + c / 32; + rgb.blue := c and 31; + -- + rgb.red := U8((U16(rgb.red ) * 255) / 31); + rgb.green:= U8((U16(rgb.green) * 255) / 31); + rgb.blue := U8((U16(rgb.blue ) * 255) / 31); + end Convert; + + procedure Load_palette (image: in out Image_descriptor) is + c, d: U8; + use GID.Buffering; + begin + if image.palette = null then + return; + end if; + declare + palette: Color_table renames image.palette.all; + begin + for i in palette'Range loop + case image.format is + when BMP => + -- order is BGRx + U8'Read(image.stream, palette(i).blue); + U8'Read(image.stream, palette(i).green); + U8'Read(image.stream, palette(i).red); + U8'Read(image.stream, c); + -- x discarded + when GIF | PNG => + -- buffered; order is RGB + Get_Byte(image.buffer, palette(i).red); + Get_Byte(image.buffer, palette(i).green); + Get_Byte(image.buffer, palette(i).blue); + when TGA => + case image.subformat_id is -- = palette's bit depth + when 8 => -- Grey + U8'Read(image.stream, c); + palette(i).red := c; + palette(i).green:= c; + palette(i).blue := c; + when 15 | 16 => -- RGB, 5 bit per channel + U8'Read(image.stream, c); + U8'Read(image.stream, d); + Convert(c, d, palette(i)); + when 24 | 32 => -- RGB | RGBA, 8 bit per channel + U8'Read(image.stream, palette(i).blue); + U8'Read(image.stream, palette(i).green); + U8'Read(image.stream, palette(i).red); + when others => + null; + end case; + when others => + raise unsupported_image_subformat with + "Palette loading not implemented for " & + Image_format_type'Image(image.format); + end case; + end loop; + end; + end Load_palette; + +end GID.Color_tables; diff --git a/deps/gid/gid-color_tables.ads b/deps/gid/gid-color_tables.ads new file mode 100644 index 00000000..0c1b522a --- /dev/null +++ b/deps/gid/gid-color_tables.ads @@ -0,0 +1,18 @@ +-- +-- Color tables, known as "palettes" +-- + +private package GID.Color_tables is + + -- Load a palette on its defined range, according to + -- the format and subformats loaded by initial + -- steps in GID.Load_image_header + procedure Load_palette (image: in out Image_descriptor); + -- if image.palette = null, nothing happens. + + -- Convert a RGB value packed in 2 bytes + -- (15 bit, 5 bit each channel) into a RGB_Color + -- This is for the TGA format. + procedure Convert(c, d: in U8; rgb: out RGB_color); + +end GID.Color_tables; diff --git a/deps/gid/gid-decoding_bmp.adb b/deps/gid/gid-decoding_bmp.adb new file mode 100644 index 00000000..63c96f7e --- /dev/null +++ b/deps/gid/gid-decoding_bmp.adb @@ -0,0 +1,131 @@ +with GID.Buffering; use GID.Buffering; + +package body GID.Decoding_BMP is + + procedure Load (image: in out Image_descriptor) is + b01, b, br, bg, bb: U8:= 0; + x, x_max, y: Natural; + -- + function Times_257(x: Primary_color_range) return Primary_color_range is + pragma Inline(Times_257); + begin + return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x + -- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8. + end Times_257; + full_opaque: constant Primary_color_range:= Primary_color_range'Last; + -- + procedure Pixel_with_palette is + pragma Inline(Pixel_with_palette); + begin + case Primary_color_range'Modulus is + when 256 => + Put_Pixel( + Primary_color_range(image.palette(Integer(b)).red), + Primary_color_range(image.palette(Integer(b)).green), + Primary_color_range(image.palette(Integer(b)).blue), + full_opaque + ); + when 65_536 => + Put_Pixel( + Times_257(Primary_color_range(image.palette(Integer(b)).red)), + Times_257(Primary_color_range(image.palette(Integer(b)).green)), + Times_257(Primary_color_range(image.palette(Integer(b)).blue)), + -- Times_257 makes max intensity FF go to FFFF + full_opaque + ); + when others => + raise invalid_primary_color_range with "BMP: color range not supported"; + end case; + end Pixel_with_palette; + -- + pair: Boolean; + bit: Natural range 0..7; + -- + line_bits: constant Float:= Float(image.width * Positive_32 (image.bits_per_pixel)); + padded_line_size: constant Positive:= 4 * Integer(Float'Ceiling(line_bits / 32.0)); + unpadded_line_size: constant Positive:= Integer(Float'Ceiling(line_bits / 8.0)); + -- (in bytes) + begin + Attach_Stream(image.buffer, image.stream); + y:= 0; + while y <= Integer (image.height) - 1 loop + x:= 0; + x_max:= Integer (image.width) - 1; + case image.bits_per_pixel is + when 1 => -- B/W + bit:= 0; + Set_X_Y(x,y); + while x <= x_max loop + if bit=0 then + Get_Byte(image.buffer, b01); + end if; + b:= (b01 and 16#80#) / 16#80#; + Pixel_with_palette; + b01:= b01 * 2; -- cannot overflow. + if bit=7 then + bit:= 0; + else + bit:= bit + 1; + end if; + x:= x + 1; + end loop; + when 4 => -- 16 colour image + pair:= True; + Set_X_Y(x,y); + while x <= x_max loop + if pair then + Get_Byte(image.buffer, b01); + b:= (b01 and 16#F0#) / 16#10#; + else + b:= (b01 and 16#0F#); + end if; + pair:= not pair; + Pixel_with_palette; + x:= x + 1; + end loop; + when 8 => -- 256 colour image + Set_X_Y(x,y); + while x <= x_max loop + Get_Byte(image.buffer, b); + Pixel_with_palette; + x:= x + 1; + end loop; + when 24 => -- RGB, 256 colour per primary colour + Set_X_Y(x,y); + while x <= x_max loop + Get_Byte(image.buffer, bb); + Get_Byte(image.buffer, bg); + Get_Byte(image.buffer, br); + case Primary_color_range'Modulus is + when 256 => + Put_Pixel( + Primary_color_range(br), + Primary_color_range(bg), + Primary_color_range(bb), + full_opaque + ); + when 65_536 => + Put_Pixel( + Times_257(Primary_color_range(br)), + Times_257(Primary_color_range(bg)), + Times_257(Primary_color_range(bb)), + -- Times_257 makes max intensity FF go to FFFF + full_opaque + ); + when others => + raise invalid_primary_color_range with "BMP: color range not supported"; + end case; + x:= x + 1; + end loop; + when others => + null; + end case; + for i in unpadded_line_size + 1 .. padded_line_size loop + Get_Byte(image.buffer, b); + end loop; + y:= y + 1; + Feedback((y*100) / Integer (image.height)); + end loop; + end Load; + +end GID.Decoding_BMP; diff --git a/deps/gid/gid-decoding_bmp.ads b/deps/gid/gid-decoding_bmp.ads new file mode 100644 index 00000000..21ca6009 --- /dev/null +++ b/deps/gid/gid-decoding_bmp.ads @@ -0,0 +1,18 @@ +private package GID.Decoding_BMP is + + -------------------- + -- Image decoding -- + -------------------- + + generic + type Primary_color_range is mod <>; + with procedure Set_X_Y (x, y: Natural); + with procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ); + with procedure Feedback (percents: Natural); + -- + procedure Load (image: in out Image_descriptor); + +end GID.Decoding_BMP; diff --git a/deps/gid/gid-decoding_gif.adb b/deps/gid/gid-decoding_gif.adb new file mode 100644 index 00000000..a9485ea8 --- /dev/null +++ b/deps/gid/gid-decoding_gif.adb @@ -0,0 +1,606 @@ +-- GIF Decoder by André van Splunter +-- +-- A GIF stream is made of several "blocks". +-- The image itself is contained in an Image Descriptor block. +-- +with GID.Buffering, GID.Color_tables; + +with Ada.Text_IO; + +package body GID.Decoding_GIF is + + generic + type Number is mod <>; + procedure Read_Intel_x86_number( + from : in out Input_buffer; + n : out Number + ); + pragma Inline(Read_Intel_x86_number); + + procedure Read_Intel_x86_number( + from : in out Input_buffer; + n : out Number + ) + is + b: U8; + m: Number:= 1; + begin + n:= 0; + for i in 1..Number'Size/8 loop + GID.Buffering.Get_Byte(from, b); + n:= n + m * Number(b); + m:= m * 256; + end loop; + end Read_Intel_x86_number; + + procedure Read_Intel is new Read_Intel_x86_number( U16 ); + + ---------- + -- Load -- + ---------- + + procedure Load ( + image : in out Image_descriptor; + next_frame: out Ada.Calendar.Day_Duration + ) + is + local: Image_descriptor; + -- With GIF, each frame is a local image with an eventual + -- palette, different dimensions, etc. ... + + use GID.Buffering; + + type GIFDescriptor is record + ImageLeft, + ImageTop, + ImageWidth, + ImageHeight : U16; + Depth : U8; + end record; + + -- For loading from the GIF file + Descriptor : GIFDescriptor; + + -- Coordinates + X, tlX, brX : Natural; + Y, tlY, brY : Natural; + + -- Code information + subtype Code_size_range is Natural range 2..12; + CurrSize : Code_size_range; + + subtype Color_type is U8; + Transp_color : Color_type:= 0; + + -- GIF data is stored in blocks and sub-blocks. + -- We initialize block_read and block_size to force + -- reading and buffering the next sub-block + block_size : Natural:= 0; + block_read : Natural:= 0; + + function Read_Byte return U8 is + pragma Inline(Read_Byte); + b: U8; + begin + if block_read >= block_size then + Get_Byte(image.buffer, b); + block_size:= Natural(b); + block_read:= 0; + end if; + Get_Byte(image.buffer, b); + block_read:= block_read + 1; + return b; + end Read_Byte; + + -- Used while reading the codes + bits_in : U8:= 8; + bits_buf: U8; + + -- Local procedure to read the next code from the file + function Read_Code return Natural is + bit_mask: Natural:= 1; + code: Natural:= 0; + begin + -- Read the code, bit by bit + for Counter in reverse 0..CurrSize - 1 loop + -- Next bit + bits_in:= bits_in + 1; + -- Maybe, a new byte needs to be loaded with a further 8 bits + if bits_in = 9 then + bits_buf:= Read_Byte; + bits_in := 1; + end if; + -- Add the current bit to the code + if (bits_buf and 1) > 0 then + code:= code + bit_mask; + end if; + bit_mask := bit_mask * 2; + bits_buf := bits_buf / 2; + end loop; + return code; + end Read_Code; + + generic + -- Parameter(s) that are constant through + -- the whole image. Macro-expanded generics and + -- some optimization will trim corresponding "if's" + interlaced : Boolean; + transparency : Boolean; + pixel_mask : U32; + -- + procedure GIF_Decode; + + procedure GIF_Decode is + + procedure Pixel_with_palette(b: U8) is + pragma Inline(Pixel_with_palette); + function Times_257(x: Primary_color_range) return Primary_color_range is + pragma Inline(Times_257); + begin + return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x + -- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8. + end Times_257; + full_opaque: constant Primary_color_range:= Primary_color_range'Last; + begin + if transparency and then b = Transp_color then + Put_Pixel(0,0,0, 0); + return; + end if; + case Primary_color_range'Modulus is + when 256 => + Put_Pixel( + Primary_color_range(local.palette(Integer(b)).red), + Primary_color_range(local.palette(Integer(b)).green), + Primary_color_range(local.palette(Integer(b)).blue), + full_opaque + ); + when 65_536 => + Put_Pixel( + Times_257(Primary_color_range(local.palette(Integer(b)).red)), + Times_257(Primary_color_range(local.palette(Integer(b)).green)), + Times_257(Primary_color_range(local.palette(Integer(b)).blue)), + -- Times_257 makes max intensity FF go to FFFF + full_opaque + ); + when others => + raise invalid_primary_color_range with "GIF: color range not supported"; + end case; + end Pixel_with_palette; + + -- Interlacing + Interlace_pass : Natural range 1..4:= 1; + Span : Natural:= 7; + + -- Local procedure to draw a pixel + procedure Next_Pixel(code: Natural) is + pragma Inline(Next_Pixel); + c : constant Color_type:= Color_type(U32(code) and pixel_mask); + begin + -- Actually draw the pixel on screen buffer + if X < Integer (image.width) then + if interlaced and mode = nice then + for i in reverse 0 .. Span loop + if Y+i < Integer (image.height) then + Set_X_Y(X, Integer (image.height) - (Y+i) - 1); + Pixel_with_palette(c); + end if; + end loop; + elsif Y < Integer (image.height) then + Pixel_with_palette(c); + end if; + end if; + + -- Move on to next pixel + X:= X + 1; + + -- Or next row, if necessary + if X = brX then + X:= tlX; + if interlaced then + case Interlace_pass is + when 1 => + Y:= Y + 8; + if Y >= brY then + Y:= 4; + Interlace_pass:= 2; + Span:= 3; + Feedback((Interlace_pass*100)/4); + end if; + when 2 => + Y:= Y + 8; + if Y >= brY then + Y:= 2; + Interlace_pass:= 3; + Span:= 1; + Feedback((Interlace_pass*100)/4); + end if; + when 3 => + Y:= Y + 4; + if Y >= brY then + Y:= 1; + Interlace_pass:= 4; + Span:= 0; + Feedback((Interlace_pass*100)/4); + end if; + when 4 => + Y:= Y + 2; + end case; + if mode = fast and then Y < Integer (image.height) then + Set_X_Y(X, Integer (image.height) - Y - 1); + end if; + else -- not interlaced + Y:= Y + 1; + if Y < Integer (image.height) then + Set_X_Y(X, Integer (image.height) - Y - 1); + end if; + if Y mod 32 = 0 then + Feedback((Y*100) / Integer (image.height)); + end if; + end if; + end if; + end Next_Pixel; + + -- The string table + Prefix : array ( 0..4096 ) of Natural:= (others => 0); + Suffix : array ( 0..4096 ) of Natural:= (others => 0); + -- Top of Stack was 1024 until files from + -- https://www.kaggle.com/c/carvana-image-masking-challenge + -- broke it (July 2017)... + Stack : array ( 0..2048 ) of Natural; + + -- Special codes (specific to GIF's flavour of LZW) + ClearCode : constant Natural:= 2 ** CurrSize; -- Reset code + EndingCode: constant Natural:= ClearCode + 1; -- End of file + FirstFree : constant Natural:= ClearCode + 2; -- Strings start here + + Slot : Natural:= FirstFree; -- Last read code + InitCodeSize : constant Code_size_range:= CurrSize + 1; + TopSlot : Natural:= 2 ** InitCodeSize; -- Highest code for current size + Code : Natural; + StackPtr : Integer:= 0; + Fc : Integer:= 0; + Oc : Integer:= 0; + C : Integer; + BadCodeCount : Natural:= 0; -- the number of bad codes found + + begin -- GIF_Decode + -- The decoder source and the cool comments are kindly donated by + -- André van Splunter. + -- + CurrSize:= InitCodeSize; + -- This is the main loop. For each code we get we pass through the + -- linked list of prefix codes, pushing the corresponding "character" + -- for each code onto the stack. When the list reaches a single + -- "character" we push that on the stack too, and then start unstacking + -- each character for output in the correct order. Special handling is + -- included for the clear code, and the whole thing ends when we get + -- an ending code. + C := Read_Code; + while C /= EndingCode loop + -- If the code is a clear code, reinitialize all necessary items. + if C = ClearCode then + CurrSize := InitCodeSize; + Slot := FirstFree; + TopSlot := 2 ** CurrSize; + -- Continue reading codes until we get a non-clear code + -- (Another unlikely, but possible case...) + C := Read_Code; + while C = ClearCode loop + C := Read_Code; + end loop; + -- If we get an ending code immediately after a clear code + -- (Yet another unlikely case), then break out of the loop. + exit when C = EndingCode; + -- Finally, if the code is beyond the range of already set codes, + -- (This one had better NOT happen... I have no idea what will + -- result from this, but I doubt it will look good...) then set + -- it to color zero. + if C >= Slot then + C := 0; + end if; + Oc := C; + Fc := C; + -- And let us not forget to output the char... + Next_Pixel(C); + else -- C /= ClearCode + -- In this case, it's not a clear code or an ending code, so + -- it must be a code code... So we can now decode the code into + -- a stack of character codes. (Clear as mud, right?) + Code := C; + -- Here we go again with one of those off chances... If, on the + -- off chance, the code we got is beyond the range of those + -- already set up (Another thing which had better NOT happen...) + -- we trick the decoder into thinking it actually got the last + -- code read. (Hmmn... I'm not sure why this works... + -- But it does...) + if Code >= Slot then + if Code > Slot then + BadCodeCount := BadCodeCount + 1; + end if; + Code := Oc; + Stack (StackPtr) := Fc rem 256; + StackPtr := StackPtr + 1; + end if; + -- Here we scan back along the linked list of prefixes, pushing + -- helpless characters (ie. suffixes) onto the stack as we do so. + while Code >= FirstFree loop + Stack (StackPtr) := Suffix (Code); + StackPtr := StackPtr + 1; + Code := Prefix (Code); + end loop; + -- Push the last character on the stack, and set up the new + -- prefix and suffix, and if the required slot number is greater + -- than that allowed by the current bit size, increase the bit + -- size. (NOTE - If we are all full, we *don't* save the new + -- suffix and prefix... I'm not certain if this is correct... + -- it might be more proper to overwrite the last code... + Stack (StackPtr) := Code rem 256; + if Slot < TopSlot then + Suffix (Slot) := Code rem 256; + Fc := Code; + Prefix (Slot) := Oc; + Slot := Slot + 1; + Oc := C; + end if; + if Slot >= TopSlot then + if CurrSize < 12 then + TopSlot := TopSlot * 2; + CurrSize := CurrSize + 1; + end if; + end if; + -- Now that we've pushed the decoded string (in reverse order) + -- onto the stack, lets pop it off and output it... + loop + Next_Pixel(Stack (StackPtr)); + exit when StackPtr = 0; + StackPtr := StackPtr - 1; + end loop; + end if; + C := Read_Code; + end loop; + if full_trace and then BadCodeCount > 0 then + Ada.Text_IO.Put_Line( + "Found" & Integer'Image(BadCodeCount) & + " bad codes" + ); + end if; + end GIF_Decode; + + -- Here we have several specialized instances of GIF_Decode, + -- with parameters known at compile-time -> optimizing compilers + -- will do expensive tests about interlacing and transparency at compile-time, + -- not at run-time. + -- + procedure GIF_Decode_interlaced_transparent_8 is + new GIF_Decode(interlaced => True, transparency => True, pixel_mask => 255); + procedure GIF_Decode_straight_transparent_8 is + new GIF_Decode(interlaced => False, transparency => True, pixel_mask => 255); + procedure GIF_Decode_interlaced_opaque_8 is + new GIF_Decode(interlaced => True, transparency => False, pixel_mask => 255); + procedure GIF_Decode_straight_opaque_8 is + new GIF_Decode(interlaced => False, transparency => False, pixel_mask => 255); + -- + procedure Skip_sub_blocks is + temp: U8; + begin + sub_blocks_sequence: + loop + Get_Byte(image.buffer, temp ); -- load sub-block length byte + exit sub_blocks_sequence when temp = 0; + -- null sub-block = end of sub-block sequence + for i in 1..temp loop + Get_Byte(image.buffer, temp ); -- load sub-block byte + end loop; + end loop sub_blocks_sequence; + end Skip_sub_blocks; + + temp, temp2, label: U8; + delay_frame: U16; + c: Character; + frame_interlaced: Boolean; + frame_transparency: Boolean:= False; + local_palette : Boolean; + -- + separator : Character ; + -- Colour information + new_num_of_colours : Natural; + pixel_mask : U32; + BitsPerPixel : Natural; + + begin -- Load + next_frame:= 0.0; + -- Scan various GIF blocks, until finding an image + loop + Get_Byte(image.buffer, temp); + separator:= Character'Val(temp); + if full_trace then + Ada.Text_IO.Put( + "GIF separator [" & separator & + "][" & U8'Image(temp) & ']' + ); + end if; + case separator is + when ',' => -- 16#2C# + exit; + -- Image descriptor will begin + -- See: 20. Image Descriptor + when ';' => -- 16#3B# + if full_trace then + Ada.Text_IO.Put(" - End of GIF"); + end if; + image.next_frame:= 0.0; + next_frame:= image.next_frame; + return; -- End of GIF image + when '!' => -- 16#21# Extensions + if full_trace then + Ada.Text_IO.Put(" - Extension"); + end if; + Get_Byte(image.buffer, label ); + case label is + when 16#F9# => -- See: 23. Graphic Control Extension + if full_trace then + Ada.Text_IO.Put_Line(" - 16#F9#: Graphic Control Extension"); + end if; + Get_Byte(image.buffer, temp ); + if temp /= 4 then + raise error_in_image_data with "GIF: error in Graphic Control Extension"; + end if; + Get_Byte(image.buffer, temp ); + -- Reserved 3 Bits + -- Disposal Method 3 Bits + -- User Input Flag 1 Bit + -- Transparent Color Flag 1 Bit + frame_transparency:= (temp and 1) = 1; + Read_Intel(image.buffer, delay_frame); + image.next_frame:= + image.next_frame + Ada.Calendar.Day_Duration(delay_frame) / 100.0; + next_frame:= image.next_frame; + Get_Byte(image.buffer, temp ); + Transp_color:= Color_type(temp); + -- zero sub-block: + Get_Byte(image.buffer, temp ); + when 16#FE# => -- See: 24. Comment Extension + if full_trace then + Ada.Text_IO.Put_Line(" - 16#FE#: Comment Extension"); + sub_blocks_sequence: + loop + Get_Byte(image.buffer, temp ); -- load sub-block length byte + exit sub_blocks_sequence when temp = 0; + -- null sub-block = end of sub-block sequence + for i in 1..temp loop + Get_Byte(image.buffer, temp2); + c:= Character'Val(temp2); + Ada.Text_IO.Put(c); + end loop; + end loop sub_blocks_sequence; + Ada.Text_IO.New_Line; + else + Skip_sub_blocks; + end if; + when 16#01# => -- See: 25. Plain Text Extension + if full_trace then + Ada.Text_IO.Put_Line(" - 16#01#: Plain Text Extension"); + end if; + Skip_sub_blocks; + when 16#FF# => -- See: 26. Application Extension + if full_trace then + Ada.Text_IO.Put_Line(" - 16#FF#: Application Extension"); + end if; + Skip_sub_blocks; + when others => + if full_trace then + Ada.Text_IO.Put_Line(" - Unused extension:" & U8'Image(label)); + end if; + Skip_sub_blocks; + end case; + when ASCII.NUL => + -- Occurs in some buggy GIFs (2016). + -- Seems a 2nd zero, the 1st marking the end of sub-block list. + if full_trace then + Ada.Text_IO.Put_Line(" - Wrong separator, skip and hope for the better..."); + end if; + when others => + raise error_in_image_data with + "GIF: unknown separator: [" & separator & + "] code:" & Integer'Image(Character'Pos(separator)); + end case; + end loop; + + -- Load the image descriptor + Read_Intel(image.buffer, Descriptor.ImageLeft); + Read_Intel(image.buffer, Descriptor.ImageTop); + Read_Intel(image.buffer, Descriptor.ImageWidth); + Read_Intel(image.buffer, Descriptor.ImageHeight); + Get_Byte(image.buffer, Descriptor.Depth); + + -- Get image corner coordinates + tlX := Natural(Descriptor.ImageLeft); + tlY := Natural(Descriptor.ImageTop); + brX := tlX + Natural(Descriptor.ImageWidth); + brY := tlY + Natural(Descriptor.ImageHeight); + + -- Local Color Table Flag 1 Bit + -- Interlace Flag 1 Bit + -- Sort Flag 1 Bit + -- Reserved 2 Bits + -- Size of Local Color Table 3 Bits + -- + frame_interlaced:= (Descriptor.Depth and 64) = 64; + local_palette:= (Descriptor.Depth and 128) = 128; + local.format:= GIF; + local.stream:= image.stream; + local.buffer:= image.buffer; + if local_palette then + -- Get amount of colours in image + BitsPerPixel := 1 + Natural(Descriptor.Depth and 7); + new_num_of_colours:= 2 ** BitsPerPixel; + -- 21. Local Color Table + local.palette:= new Color_table(0..new_num_of_colours-1); + Color_tables.Load_palette(local); + image.buffer:= local.buffer; + elsif image.palette = null then + raise error_in_image_data with "GIF: neither local, nor global palette"; + else + -- Use global palette + new_num_of_colours:= 2 ** image.subformat_id; + -- usually <= 2** image.bits_per_pixel + -- Just copy main palette + local.palette:= new Color_table'(image.palette.all); + end if; + pixel_mask:= U32(new_num_of_colours - 1); + + if full_trace then + Ada.Text_IO.Put_Line( + " - Image, interlaced: " & Boolean'Image(frame_interlaced) & + "; local palette: " & Boolean'Image(local_palette) & + "; transparency: " & Boolean'Image(frame_transparency) & + "; transparency index:" & Color_type'Image(Transp_color) + ); + end if; + + -- Get initial code size + Get_Byte(image.buffer, temp ); + if Natural(temp) not in Code_size_range then + raise error_in_image_data with + "GIF: wrong LZW code size (must be in 2..12), is" & + U8'Image(temp); + end if; + CurrSize := Natural(temp); + + -- Start at top left of image + X := Natural(Descriptor.ImageLeft); + Y := Natural(Descriptor.ImageTop); + Set_X_Y(X, Integer (image.height) - Y - 1); + -- + if new_num_of_colours < 256 then + -- "Rare" formats -> no need of best speed + declare + -- We create an instance with dynamic parameters + procedure GIF_Decode_general is + new GIF_Decode(frame_interlaced, frame_transparency, pixel_mask); + begin + GIF_Decode_general; + end; + else + -- 8 bit, usual format: we try to make things + -- faster with specialized instanciations... + if frame_interlaced then + if frame_transparency then + GIF_Decode_interlaced_transparent_8; + else + GIF_Decode_interlaced_opaque_8; + end if; + else -- straight (non-interlaced) + if frame_transparency then + GIF_Decode_straight_transparent_8; + else + GIF_Decode_straight_opaque_8; + end if; + end if; + end if; + Feedback(100); + -- + Get_Byte(image.buffer, temp ); -- zero-size sub-block + end Load; + +end GID.Decoding_GIF; diff --git a/deps/gid/gid-decoding_gif.ads b/deps/gid/gid-decoding_gif.ads new file mode 100644 index 00000000..e4d0dbbe --- /dev/null +++ b/deps/gid/gid-decoding_gif.ads @@ -0,0 +1,22 @@ +private package GID.Decoding_GIF is + + -------------------- + -- Image decoding -- + -------------------- + + generic + type Primary_color_range is mod <>; + with procedure Set_X_Y (x, y: Natural); + with procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ); + with procedure Feedback (percents: Natural); + mode: Display_mode; + -- + procedure Load ( + image : in out Image_descriptor; + next_frame: out Ada.Calendar.Day_Duration + ); + +end GID.Decoding_GIF; diff --git a/deps/gid/gid-decoding_jpg.adb b/deps/gid/gid-decoding_jpg.adb new file mode 100644 index 00000000..084f0761 --- /dev/null +++ b/deps/gid/gid-decoding_jpg.adb @@ -0,0 +1,1049 @@ +-- Steps for decoding a JPEG image +-- +-- 1. Huffman decompression +-- 2. Inverse quantization +-- 3. Inverse cosine transform +-- 4. Upsampling +-- 5. Color transformation +-- 6. Image reconstruction +-- +-- The JPEG decoder is largely inspired +-- by the NanoJPEG code by Martin J. Fiedler. +-- With the author's permission. Many thanks! +-- +-- Other informations: +-- http://en.wikipedia.org/wiki/JPEG + +-- !! ** Some optimizations to consider ** +-- !! ssx, ssy ,ssxmax, ssymax +-- as generic parameters + specialized instances +-- !! consider only power-of-two upsampling factors ? +-- !! simplify upsampling loops in case of power-of-two upsampling factors +-- using Shift_Right +-- !! Col_IDCT output direct to "flat", or something similar to NanoJPEG + +with GID.Buffering; +with Ada.Text_IO, Ada.Integer_Text_IO, Ada.IO_Exceptions; + +package body GID.Decoding_JPG is + + use GID.Buffering; + use Ada.Text_IO; + + generic + type Number is mod <>; + procedure Big_endian_number( + from : in out Input_buffer; + n : out Number + ); + pragma Inline(Big_endian_number); + + procedure Big_endian_number( + from : in out Input_buffer; + n : out Number + ) + is + b: U8; + begin + n:= 0; + for i in 1..Number'Size/8 loop + Get_Byte(from, b); + n:= n * 256 + Number(b); + end loop; + end Big_endian_number; + + procedure Big_endian is new Big_endian_number( U16 ); + + procedure Read( image: in out Image_descriptor; sh: out Segment_head) is + b: U8; + id: constant array(JPEG_marker) of U8:= + ( SOI => 16#D8#, + -- + SOF_0 => 16#C0#, SOF_1 => 16#C1#, SOF_2 => 16#C2#, SOF_3 => 16#C3#, + SOF_5 => 16#C5#, SOF_6 => 16#C6#, SOF_7 => 16#C7#, SOF_8 => 16#C8#, + SOF_9 => 16#C9#, SOF_10 => 16#CA#, SOF_11 => 16#CB#, SOF_13 => 16#CD#, + SOF_14 => 16#CE#, SOF_15 => 16#CF#, + -- + DHT => 16#C4#, + DAC => 16#CC#, + DQT => 16#DB#, + DRI => 16#DD#, + -- + APP_0 => 16#E0#, APP_1 => 16#E1#, APP_2 => 16#E2#, APP_3 => 16#E3#, + APP_4 => 16#E4#, APP_5 => 16#E5#, APP_6 => 16#E6#, APP_7 => 16#E7#, + APP_8 => 16#E8#, APP_9 => 16#E9#, APP_10 => 16#EA#, APP_11 => 16#EB#, + APP_12 => 16#EC#, APP_13 => 16#ED#, APP_14 => 16#EE#, + -- + COM => 16#FE#, + SOS => 16#DA#, + EOI => 16#D9# + ); + begin + Get_Byte(image.buffer, b); + if b /= 16#FF# then + raise error_in_image_data with "JPEG: expected marker here"; + end if; + Get_Byte(image.buffer, b); + for m in id'Range loop + if id(m)= b then + sh.kind:= m; + Big_endian(image.buffer, sh.length); + sh.length:= sh.length - 2; + -- We consider length of contents, without the FFxx marker. + if some_trace then + Put_Line( + "Segment [" & JPEG_marker'Image(sh.kind) & + "], length:" & U16'Image(sh.length)); + end if; + return; + end if; + end loop; + raise error_in_image_data with "JPEG: unknown marker here: FF, " & U8'Image(b); + end Read; + + shift_arg: constant array(0..15) of Integer:= + (1 => 0, 2 => 1, 4 => 2, 8 => 3, others => -1); + + -- SOF - Start Of Frame (the real header) + procedure Read_SOF(image: in out Image_descriptor; sh: Segment_head) is + use Bounded_255; + b, bits_pp_primary, id_base: U8; + w, h: U16; + compo: JPEG_defs.Component; + begin + case sh.kind is + when SOF_0 => + image.detailed_format:= To_Bounded_String("JPEG, Baseline DCT (SOF_0)"); + when SOF_2 => + image.detailed_format:= To_Bounded_String("JPEG, Progressive DCT (SOF_2)"); + image.interlaced:= True; + when others => + raise unsupported_image_subformat with + "JPEG: image type not yet supported: " & JPEG_marker'Image(sh.kind); + end case; + Get_Byte(image.buffer, bits_pp_primary); + if bits_pp_primary /= 8 then + raise unsupported_image_subformat with + "JPEG: bits per primary color=" & U8'Image(bits_pp_primary) & " (not supported)"; + end if; + image.bits_per_pixel:= 3 * Positive(bits_pp_primary); + Big_endian(image.buffer, h); + Big_endian(image.buffer, w); + if w = 0 then + raise error_in_image_data with "JPEG: zero image width"; + end if; + if h = 0 then + raise error_in_image_data with "JPEG: zero image height"; + end if; + image.width := Positive_32 (w); + image.height := Positive_32 (h); + -- Number of components: + Get_Byte(image.buffer, b); + image.subformat_id:= Integer(b); + -- + image.JPEG_stuff.max_samples_hor:= 0; + image.JPEG_stuff.max_samples_ver:= 0; + id_base := 1; + -- For each component: 3 bytes information: ID, sampling factors, quantization table number + for i in 1..image.subformat_id loop + -- Component ID (1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q) + Get_Byte(image.buffer, b); + if b = 0 then + -- Workaround for a bug in some encoders, for instance Intel(R) JPEG Library, + -- version [2.0.18.50] as in some Photoshop versions : IDs are numbered 0, 1, 2. + id_base := 0; + end if; + if b - id_base > Component'Pos(Component'Last) then + raise error_in_image_data with "JPEG: SOF: invalid component ID: " & U8'Image(b); + end if; + compo:= JPEG_defs.Component'Val(b - id_base); + image.JPEG_stuff.components(compo):= True; + declare + stuff: JPEG_stuff_type renames image.JPEG_stuff; + info: JPEG_defs.Info_per_component_A renames stuff.info(compo); + begin + -- Sampling factors (bit 0-3 vert., 4-7 hor.) + Get_Byte(image.buffer, b); + info.samples_ver:= Natural(b mod 16); + info.samples_hor:= Natural(b / 16); + stuff.max_samples_hor:= + Integer'Max(stuff.max_samples_hor, info.samples_hor); + stuff.max_samples_ver:= + Integer'Max(stuff.max_samples_ver, info.samples_ver); + -- Quantization table number + Get_Byte(image.buffer, b); + info.qt_assoc:= Natural(b); + end; + end loop; + for c in Component loop + if image.JPEG_stuff.components(c) then + declare + stuff: JPEG_stuff_type renames image.JPEG_stuff; + info: JPEG_defs.Info_per_component_A renames stuff.info(c); + begin + info.up_factor_x:= stuff.max_samples_hor / info.samples_hor; + info.up_factor_y:= stuff.max_samples_ver / info.samples_ver; + info.shift_x:= shift_arg(info.up_factor_x); + info.shift_y:= shift_arg(info.up_factor_y); + end; + end if; + end loop; + if Natural(sh.length) < 6 + 3 * image.subformat_id then + raise error_in_image_data with "JPEG: SOF segment too short"; + end if; + if some_trace then + Put_Line("Frame has following components:"); + for c in JPEG_defs.Component loop + Put_Line( + JPEG_defs.Component'Image(c) & " -> " & + Boolean'Image(image.JPEG_stuff.components(c)) + ); + end loop; + end if; + if image.JPEG_stuff.components = YCbCr_set then + image.JPEG_stuff.color_space:= YCbCr; + elsif image.JPEG_stuff.components = Y_Grey_set then + image.JPEG_stuff.color_space:= Y_Grey; + image.greyscale:= True; + elsif image.JPEG_stuff.components = CMYK_set then + image.JPEG_stuff.color_space:= CMYK; + else + raise unsupported_image_subformat with + "JPEG: only YCbCr, Y_Grey and CMYK color spaces are currently supported"; + end if; + image.detailed_format:= image.detailed_format & ", " & + JPEG_defs.Supported_color_space'Image(image.JPEG_stuff.color_space); + if some_trace then + Put_Line( + "Color space: " & + JPEG_defs.Supported_color_space'Image(image.JPEG_stuff.color_space) + ); + end if; + if image.JPEG_stuff.color_space = CMYK then + raise unsupported_image_subformat with + "JPEG: CMYK color space is currently not properly decoded"; + end if; + end Read_SOF; + + procedure Read_DHT(image: in out Image_descriptor; data_length: Natural) is + remaining: Integer_M32:= Integer_M32(data_length); -- data remaining in segment + b: U8; + ht_idx: Natural; + kind: AC_DC; + counts: array(1..16) of Integer_M32; + idx: Natural; + currcnt, spread, remain_vlc: Integer_M32; + begin + multi_tables: + loop + Get_Byte(image.buffer, b); + remaining:= remaining - 1; + if b >= 8 then + kind:= AC; + else + kind:= DC; + end if; + ht_idx:= Natural(b and 7); + if some_trace then + Put_Line( + "Huffman Table (HT) #" & + Natural'Image(ht_idx) & ", " & AC_DC'Image(kind) + ); + end if; + if image.JPEG_stuff.vlc_defs(kind, ht_idx) = null then + image.JPEG_stuff.vlc_defs(kind, ht_idx):= new VLC_table; + end if; + for i in counts'Range loop + Get_Byte(image.buffer, b); + remaining:= remaining - 1; + counts(i):= Integer_M32(b); + end loop; + remain_vlc:= 65_536; + spread:= 65_536; + idx:= 0; + for codelen in counts'Range loop + spread:= spread / 2; + currcnt:= counts(codelen); + if currcnt > 0 then + if remaining < currcnt then + raise error_in_image_data with "JPEG: DHT data too short"; + end if; + remain_vlc:= remain_vlc - currcnt * spread; + if remain_vlc < 0 then + raise error_in_image_data with "JPEG: DHT table too short for data"; + end if; + for i in reverse 1..currcnt loop + Get_Byte(image.buffer, b); + for j in reverse 1..spread loop + image.JPEG_stuff.vlc_defs(kind, ht_idx)(idx):= + (bits => U8(codelen), code => b); + idx:= idx + 1; + end loop; + end loop; + remaining:= remaining - currcnt; + end if; + end loop; + while remain_vlc > 0 loop + remain_vlc:= remain_vlc - 1; + image.JPEG_stuff.vlc_defs(kind, ht_idx)(idx).bits:= 0; + idx:= idx + 1; + end loop; + exit multi_tables when remaining <= 0; + end loop multi_tables; + end Read_DHT; + + procedure Read_DQT(image: in out Image_descriptor; data_length: Natural) is + remaining: Integer:= data_length; -- data remaining in segment + b, q8: U8; q16: U16; + qt_idx: Natural; + high_prec: Boolean; + begin + multi_tables: + loop + Get_Byte(image.buffer, b); + remaining:= remaining - 1; + high_prec:= b >= 8; + qt_idx:= Natural(b and 7); + if some_trace then + Put_Line("Quantization Table (QT) #" & U8'Image(b)); + end if; + for i in QT'Range loop + if high_prec then + Big_endian(image.buffer, q16); + remaining:= remaining - 2; + image.JPEG_stuff.qt_list(qt_idx)(i):= Natural(q16); + else + Get_Byte(image.buffer, q8); + remaining:= remaining - 1; + image.JPEG_stuff.qt_list(qt_idx)(i):= Natural(q8); + end if; + end loop; + exit multi_tables when remaining <= 0; + end loop multi_tables; + end Read_DQT; + + procedure Read_DRI(image: in out Image_descriptor) is + ri: U16; + begin + Big_endian(image.buffer, ri); + if some_trace then + Put_Line(" Restart interval set to:" & U16'Image(ri)); + end if; + image.JPEG_stuff.restart_interval:= Natural(ri); + end Read_DRI; + + procedure Read_EXIF(image: in out Image_descriptor; data_length: Natural) is + b, orientation_value: U8; + x, ifd0_entries: Natural; + Exif_signature: constant String:= "Exif" & ASCII.NUL & ASCII.NUL; + signature: String(1..6); + IFD_tag: U16; + endianness: Character; + -- 'M' (Motorola) or 'I' (Intel): EXIF chunks may have different endiannesses, + -- even though the whole JPEG format has a fixed endianness! + begin + if some_trace then + Put_Line("APP1"); + end if; + if data_length < 6 then + -- Skip segment data + for i in 1..data_length loop + Get_Byte(image.buffer, b); + end loop; + else + for i in 1..6 loop + Get_Byte(image.buffer, b); + signature(i):= Character'Val(b); + end loop; + if signature /= Exif_signature then + for i in 7..data_length loop -- Skip remaining of APP1 data + Get_Byte(image.buffer, b); -- since we don't know how to use it. + end loop; + if some_trace then + Put_Line("APP1 is not Exif"); + end if; + return; + end if; + Get_Byte(image.buffer, b); -- TIFF 6.0 header (1st of 8 bytes) + endianness:= Character'Val(b); + if some_trace then + Put_Line("APP1 is Exif; endianness is " & endianness); + end if; + for i in 8..14 loop -- TIFF 6.0 header (2-8 of 8 bytes) + Get_Byte(image.buffer, b); + end loop; + -- Number of IFD0 entries (2 bytes) + ifd0_entries:= 0; + Get_Byte(image.buffer, b); + ifd0_entries:= Natural(b); + Get_Byte(image.buffer, b); + if endianness = 'I' then + ifd0_entries:= ifd0_entries + 16#100# * Natural(b); + else + ifd0_entries:= Natural(b) + 16#100# * ifd0_entries; + end if; + if some_trace then + Put_Line("EXIF's IFD0 has" & Natural'Image(ifd0_entries) & " entries."); + end if; + x:= 17; + while x <= data_length - 12 loop + Get_Byte(image.buffer, b); + IFD_tag:= U16(b); + Get_Byte(image.buffer, b); + if endianness = 'I' then + IFD_tag:= IFD_tag + 16#100# * U16(b); + else + IFD_tag:= U16(b) + 16#100# * IFD_tag; + end if; + if some_trace then + Put("IFD tag:"); Ada.Integer_Text_IO.Put(Natural(IFD_tag), Base => 16); New_Line; + end if; + for i in 3..8 loop + Get_Byte(image.buffer, b); + end loop; + if endianness = 'I' then + Get_Byte(image.buffer, orientation_value); + for i in 10..12 loop + Get_Byte(image.buffer, b); + end loop; + else + Get_Byte(image.buffer, b); + Get_Byte(image.buffer, orientation_value); + Get_Byte(image.buffer, b); + Get_Byte(image.buffer, b); + end if; + x:= x + 12; + if IFD_tag = 16#112# then + case orientation_value is + when 1 => + image.display_orientation:= Unchanged; + when 8 => + image.display_orientation:= Rotation_90; + when 3 => + image.display_orientation:= Rotation_180; + when 6 => + image.display_orientation:= Rotation_270; + when others => + image.display_orientation:= Unchanged; + end case; + if some_trace then + Put_Line( + "IFD tag 0112: Orientation set to: " & + Orientation'Image(image.display_orientation) + ); + end if; + exit; + end if; + end loop; + -- Skip rest of data + for i in x..data_length loop + Get_Byte(image.buffer, b); + end loop; + end if; + end Read_EXIF; + + -------------------- + -- Image decoding -- + -------------------- + + procedure Load ( + image : in out Image_descriptor; + next_frame: out Ada.Calendar.Day_Duration + ) + is + -- + -- Bit buffer + -- + buf: U32:= 0; + bufbits: Natural:= 0; + + function Show_bits(bits: Natural) return Natural is + newbyte, marker: U8; + begin + if bits=0 then + return 0; + end if; + while bufbits < bits loop + begin + Get_Byte(image.buffer, newbyte); + bufbits:= bufbits + 8; + buf:= buf * 256 + U32(newbyte); + if newbyte = 16#FF# then + Get_Byte(image.buffer, marker); + case marker is + when 0 => + null; + when 16#D8# => -- SOI here ? + null; + -- 2015-04-26: occured in one (of many) picture + -- taken by an Olympus VG120,D705. See test/img/bcase_1.jpg + when 16#D9# => -- EOI here ? + null; -- !! signal end + when 16#D0# .. 16#D7# => + bufbits:= bufbits + 8; + buf:= buf * 256 + U32(marker); + when others => + raise error_in_image_data with + "JPEG: Invalid code (bit buffer): " & U8'Image(marker); + end case; + end if; + exception + when Ada.IO_Exceptions.End_Error => + newbyte:= 16#FF#; + bufbits:= bufbits + 8; + buf:= buf * 256 + U32(newbyte); + end; + end loop; + return Natural( + Shift_Right(buf, bufbits - bits) + and + (Shift_Left(1, bits)-1) + ); + end Show_bits; + + procedure Skip_bits(bits: Natural) is + pragma Inline(Skip_bits); + dummy: Integer; + pragma Warnings(off, dummy); + begin + if bufbits < bits then + dummy:= Show_bits(bits); + end if; + bufbits:= bufbits - bits; + end Skip_bits; + + function Get_bits(bits: Natural) return Integer is + pragma Inline(Get_bits); + res: constant Integer:= Show_bits(bits); + begin + Skip_bits(bits); + return res; + end Get_bits; + + -- + + type Info_per_component_B is record + ht_idx_AC : Natural; + ht_idx_DC : Natural; + width, height, stride: Natural; + dcpred: Integer:= 0; + end record; + + info_A: Component_info_A renames image.JPEG_stuff.info; + info_B: array(Component) of Info_per_component_B; + + procedure Get_VLC( + vlc: VLC_table; + code: out U8; + value_ret: out Integer + ) + is + -- Step 1 happens here: Huffman decompression + value: Integer:= Show_bits(16); + bits : Natural:= Natural(vlc(value).bits); + begin + if bits = 0 then + raise error_in_image_data with "JPEG: VLC table: bits = 0"; + end if; + Skip_bits(bits); + value:= Integer(vlc(value).code); + code:= U8(value); + bits:= Natural(U32(value) and 15); + value_ret:= 0; + if bits /= 0 then + value:= Get_bits(bits); + if value < Integer(Shift_Left(U32'(1), bits - 1)) then + value:= value + 1 - Integer(Shift_Left(U32'(1), bits)); + end if; + value_ret:= value; + end if; + end Get_VLC; + + function Clip(x: Integer) return Integer is + pragma Inline(Clip); + begin + if x < 0 then + return 0; + elsif x > 255 then + return 255; + else + return x; + end if; + end Clip; + + type Block_8x8 is array(0..63) of Integer; + + -- Ordering within a 8x8 block, in zig-zag + zig_zag: constant Block_8x8:= + ( 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, + 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, + 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, + 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, + 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 ); + + procedure Decode_Block(c: Component; block: in out Block_8x8) is + value, coef: Integer; + code: U8; + qt: JPEG_defs.QT renames image.JPEG_stuff.qt_list(info_A(c).qt_assoc); + -- + W1: constant:= 2841; + W2: constant:= 2676; + W3: constant:= 2408; + W5: constant:= 1609; + W6: constant:= 1108; + W7: constant:= 565; + -- + procedure Row_IDCT(start: Integer) is + pragma Inline(Row_IDCT); + x0, x1, x2, x3, x4, x5, x6, x7, x8, val: Integer; + begin + x1:= block(start + 4) * 2**11; + x2:= block(start + 6); + x3:= block(start + 2); + x4:= block(start + 1); + x5:= block(start + 7); + x6:= block(start + 5); + x7:= block(start + 3); + if x1=0 and x2=0 and x3=0 and x4=0 and x5=0 and x6=0 and x7=0 then + val:= block(start + 0) * 8; + block(start + 0 .. start + 7):= (others => val); + else + x0:= (block(start + 0) * 2**11) + 128; + x8:= W7 * (x4 + x5); + x4:= x8 + (W1 - W7) * x4; + x5:= x8 - (W1 + W7) * x5; + x8:= W3 * (x6 + x7); + x6:= x8 - (W3 - W5) * x6; + x7:= x8 - (W3 + W5) * x7; + x8:= x0 + x1; + x0:= x0 - x1; + x1:= W6 * (x3 + x2); + x2:= x1 - (W2 + W6) * x2; + x3:= x1 + (W2 - W6) * x3; + x1:= x4 + x6; + x4:= x4 - x6; + x6:= x5 + x7; + x5:= x5 - x7; + x7:= x8 + x3; + x8:= x8 - x3; + x3:= x0 + x2; + x0:= x0 - x2; + x2:= (181 * (x4 + x5) + 128) / 256; + x4:= (181 * (x4 - x5) + 128) / 256; + block(start + 0):= (x7 + x1) / 256; + block(start + 1):= (x3 + x2) / 256; + block(start + 2):= (x0 + x4) / 256; + block(start + 3):= (x8 + x6) / 256; + block(start + 4):= (x8 - x6) / 256; + block(start + 5):= (x0 - x4) / 256; + block(start + 6):= (x3 - x2) / 256; + block(start + 7):= (x7 - x1) / 256; + end if; + end Row_IDCT; + + procedure Col_IDCT(start: Integer) is + pragma Inline(Col_IDCT); + x0, x1, x2, x3, x4, x5, x6, x7, x8, val: Integer; + begin + x1:= block(start + 8*4) * 256; + x2:= block(start + 8*6); + x3:= block(start + 8*2); + x4:= block(start + 8*1); + x5:= block(start + 8*7); + x6:= block(start + 8*5); + x7:= block(start + 8*3); + if x1=0 and x2=0 and x3=0 and x4=0 and x5=0 and x6=0 and x7=0 then + val:= Clip(((block(start) + 32) / 2**6) + 128); + for row in reverse 0..7 loop + block(start + row * 8):= val; + end loop; + else + x0:= (block(start) * 256) + 8192; + x8:= W7 * (x4 + x5) + 4; + x4:= (x8 + (W1 - W7) * x4) / 8; + x5:= (x8 - (W1 + W7) * x5) / 8; + x8:= W3 * (x6 + x7) + 4; + x6:= (x8 - (W3 - W5) * x6) / 8; + x7:= (x8 - (W3 + W5) * x7) / 8; + x8:= x0 + x1; + x0:= x0 - x1; + x1:= W6 * (x3 + x2) + 4; + x2:= (x1 - (W2 + W6) * x2) / 8; + x3:= (x1 + (W2 - W6) * x3) / 8; + x1:= x4 + x6; + x4:= x4 - x6; + x6:= x5 + x7; + x5:= x5 - x7; + x7:= x8 + x3; + x8:= x8 - x3; + x3:= x0 + x2; + x0:= x0 - x2; + x2:= (181 * (x4 + x5) + 128) / 256; + x4:= (181 * (x4 - x5) + 128) / 256; + block(start + 8*0):= Clip(((x7 + x1) / 2**14) + 128); + block(start + 8*1):= Clip(((x3 + x2) / 2**14) + 128); + block(start + 8*2):= Clip(((x0 + x4) / 2**14) + 128); + block(start + 8*3):= Clip(((x8 + x6) / 2**14) + 128); + block(start + 8*4):= Clip(((x8 - x6) / 2**14) + 128); + block(start + 8*5):= Clip(((x0 - x4) / 2**14) + 128); + block(start + 8*6):= Clip(((x3 - x2) / 2**14) + 128); + block(start + 8*7):= Clip(((x7 - x1) / 2**14) + 128); + end if; + end Col_IDCT; + + begin -- Decode_Block + -- + -- Step 2 happens here: Inverse quantization + Get_VLC(image.JPEG_stuff.vlc_defs(DC, info_B(c).ht_idx_DC).all, code, value); + -- First value in block (0: top left) uses a predictor. + info_B(c).dcpred:= info_B(c).dcpred + value; + block:= (0 => info_B(c).dcpred * qt(0), others => 0); + coef:= 0; + loop + Get_VLC(image.JPEG_stuff.vlc_defs(AC, info_B(c).ht_idx_AC).all, code, value); + exit when code = 0; -- EOB + if (code and 16#0F#) = 0 and code /= 16#F0# then + raise error_in_image_data with "JPEG: error in VLC AC code for de-quantization"; + end if; + coef:= coef + Integer(Shift_Right(code, 4)) + 1; + if coef > 63 then + raise error_in_image_data with "JPEG: coefficient for de-quantization is > 63"; + end if; + block(zig_zag(coef)):= value * qt(coef); + exit when coef = 63; + end loop; + -- Step 3 happens here: Inverse cosine transform + for row in 0..7 loop + Row_IDCT(row * 8); + end loop; + for col in 0..7 loop + Col_IDCT(col); + end loop; + end Decode_Block; + + type Macro_block is array( + Component range <>, -- component + Positive range <>, -- x sample range + Positive range <> -- y sample range + ) of Block_8x8; + + procedure Out_Pixel_8(br, bg, bb: U8) is + pragma Inline(Out_Pixel_8); + function Times_257(x: Primary_color_range) return Primary_color_range is + pragma Inline(Times_257); + begin + return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x + -- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8. + end Times_257; + full_opaque: constant Primary_color_range:= Primary_color_range'Last; + begin + case Primary_color_range'Modulus is + when 256 => + Put_Pixel( + Primary_color_range(br), + Primary_color_range(bg), + Primary_color_range(bb), + full_opaque + ); + when 65_536 => + Put_Pixel( + Times_257(Primary_color_range(br)), + Times_257(Primary_color_range(bg)), + Times_257(Primary_color_range(bb)), + full_opaque + -- Times_257 makes max intensity FF go to FFFF + ); + when others => + raise invalid_primary_color_range with "JPEG: color range not supported"; + end case; + end Out_Pixel_8; + + -- !! might be generic parameters + ssxmax: constant Natural:= image.JPEG_stuff.max_samples_hor; + ssymax: constant Natural:= image.JPEG_stuff.max_samples_ver; + + procedure Upsampling_and_output( + m: Macro_block; + x0, y0: Natural + ) + is + flat: array(Component, 0..8*ssxmax-1, 0..8*ssymax-1) of Integer; + + generic + color_space: Supported_color_space; + procedure Color_transformation_and_output; + -- + procedure Color_transformation_and_output is + y_val, cb_val, cr_val, c_val, m_val, w_val: Integer; + y_val_8: U8; + begin + for ymb in flat'Range(3) loop + exit when y0+ymb >= Integer (image.height); + Set_X_Y(x0, Integer (image.height) - 1 - (y0+ymb)); + for xmb in flat'Range(2) loop + exit when x0+xmb >= Integer (image.width); + case color_space is + when YCbCr => + y_val := flat(Y, xmb, ymb) * 256; + cb_val:= flat(Cb, xmb, ymb) - 128; + cr_val:= flat(Cr, xmb, ymb) - 128; + Out_Pixel_8( + br => U8(Clip((y_val + 359 * cr_val + 128) / 256)), + bg => U8(Clip((y_val - 88 * cb_val - 183 * cr_val + 128) / 256)), + bb => U8(Clip((y_val + 454 * cb_val + 128) / 256)) + ); + when Y_Grey => + y_val_8:= U8(flat(Y, xmb, ymb)); + Out_Pixel_8(y_val_8, y_val_8, y_val_8); + when CMYK => + -- !! find a working conversion formula. + -- perhaps it is more complicated (APP_2 + -- color profile must be used ?) + c_val:= flat(Y, xmb, ymb); + m_val:= flat(Cb, xmb, ymb); + y_val:= flat(Cr, xmb, ymb); + w_val:= flat(I, xmb, ymb)-255; + Out_Pixel_8( + br => U8(255-Clip(c_val+w_val)), + bg => U8(255-Clip(m_val+w_val)), + bb => U8(255-Clip(y_val+w_val)) + ); + end case; + end loop; + end loop; + end Color_transformation_and_output; + -- + procedure Ct_YCbCr is new Color_transformation_and_output(YCbCr); + procedure Ct_Y_Grey is new Color_transformation_and_output(Y_Grey); + procedure Ct_CMYK is new Color_transformation_and_output(CMYK); + + blk_idx: Integer; + upsx, upsy: Natural; + begin + -- Step 4 happens here: Upsampling + for c in Component loop + if image.JPEG_stuff.components(c) then + upsx:= info_A(c).up_factor_x; + upsy:= info_A(c).up_factor_y; + for x in reverse 1..info_A(c).samples_hor loop + for y in reverse 1..info_A(c).samples_ver loop + -- We are at the 8x8 block level + blk_idx:= 63; + for y8 in reverse 0..7 loop + for x8 in reverse 0..7 loop + declare + val: constant Integer:= m(c,x,y)(blk_idx); + big_pixel_x: constant Natural:= upsx * (x8 + 8*(x-1)); + big_pixel_y: constant Natural:= upsy * (y8 + 8*(y-1)); + begin + -- Repeat pixels for component c, sample (x,y), + -- position (x8,y8). + for rx in reverse 0..upsx-1 loop + for ry in reverse 0..upsy-1 loop + flat(c, rx + big_pixel_x, ry + big_pixel_y):= val; + end loop; + end loop; + end; + blk_idx:= blk_idx - 1; + end loop; + end loop; + end loop; + end loop; + end if; + end loop; + -- Step 5 and 6 happen here: Color transformation and output + case image.JPEG_stuff.color_space is + when YCbCr => + Ct_YCbCr; + when Y_Grey => + Ct_Y_Grey; + when CMYK => + Ct_CMYK; + end case; + end Upsampling_and_output; + + -- Start Of Scan (and image data which follow) + -- + procedure Read_SOS is + components, b, id_base: U8; + compo: Component:= Component'First; + mbx, mby: Natural:= 0; + mbsizex, mbsizey, mbwidth, mbheight: Natural; + rstcount: Natural:= image.JPEG_stuff.restart_interval; + nextrst: U16:= 0; + w: U16; + start_spectral_selection, + end_spectral_selection, + successive_approximation: U8; + begin + Get_Byte(image.buffer, components); + if some_trace then + Put_Line( + "Start of Scan (SOS), with" & U8'Image(components) & " components" + ); + end if; + if image.subformat_id /= Natural(components) then + raise error_in_image_data with "JPEG: components mismatch in Scan segment"; + end if; + id_base := 1; + for i in 1..components loop + Get_Byte(image.buffer, b); + if b = 0 then + -- Workaround for bugged encoder (see above) + id_base := 0; + end if; + if b - id_base > Component'Pos(Component'Last) then + raise error_in_image_data with "JPEG: Scan: invalid ID: " & U8'Image(b); + end if; + compo:= Component'Val(b - id_base); + if not image.JPEG_stuff.components(compo) then + raise error_in_image_data with + "JPEG: component " & Component'Image(compo) & + " has not been defined in the header (SOF) segment"; + end if; + -- Huffman table selection + Get_Byte(image.buffer, b); + info_B(compo).ht_idx_AC:= Natural(b mod 16); + info_B(compo).ht_idx_DC:= Natural(b / 16); + end loop; + -- Parameters for progressive display format (SOF_2) + Get_Byte(image.buffer, start_spectral_selection); + Get_Byte(image.buffer, end_spectral_selection); + Get_Byte(image.buffer, successive_approximation); + -- + -- End of SOS segment, image data follow. + -- + mbsizex:= ssxmax * 8; -- pixels in a row of a macro-block + mbsizey:= ssymax * 8; -- pixels in a column of a macro-block + mbwidth := (Integer (image.width) + mbsizex - 1) / mbsizex; + -- width in macro-blocks + mbheight := (Integer (image.height) + mbsizey - 1) / mbsizey; + -- height in macro-blocks + if some_trace then + Put_Line(" mbsizex = " & Integer'Image(mbsizex)); + Put_Line(" mbsizey = " & Integer'Image(mbsizey)); + Put_Line(" mbwidth = " & Integer'Image(mbwidth)); + Put_Line(" mbheight = " & Integer'Image(mbheight)); + end if; + for c in Component loop + if image.JPEG_stuff.components(c) then + info_B(c).width := (Integer (image.width) * info_A(c).samples_hor + ssxmax - 1) / ssxmax; + info_B(c).height:= (Integer (image.height) * info_A(c).samples_ver + ssymax - 1) / ssymax; + info_B(c).stride:= (mbwidth * mbsizex * info_A(c).samples_hor) / ssxmax; + if some_trace then + Put_Line(" Details for component " & Component'Image(c)); + Put_Line(" samples in x " & Integer'Image(info_A(c).samples_hor)); + Put_Line(" samples in y " & Integer'Image(info_A(c).samples_ver)); + Put_Line(" width " & Integer'Image(info_B(c).width)); + Put_Line(" height " & Integer'Image(info_B(c).height)); + Put_Line(" stride " & Integer'Image(info_B(c).stride)); + Put_Line( + " AC/DC table index " & + Integer'Image(info_B(compo).ht_idx_AC) & ", " & + Integer'Image(info_B(compo).ht_idx_DC) + ); + end if; + if (info_B(c).width < 3 and info_A(c).samples_hor /= ssxmax) or + (info_B(c).height < 3 and info_A(c).samples_ver /= ssymax) + then + raise error_in_image_data with + "JPEG: component " & Component'Image(c) & ": sample dimension mismatch"; + end if; + end if; + end loop; + -- + if image.interlaced then + raise unsupported_image_subformat with "JPEG: progressive format not yet functional"; + end if; + declare + mb: Macro_block(Component, 1..ssxmax, 1..ssymax); + x0, y0: Integer:= 0; + begin + macro_blocks_loop: + loop + components_loop: + for c in Component loop + if image.JPEG_stuff.components(c) then + samples_y_loop: + for sby in 1..info_A(c).samples_ver loop + samples_x_loop: + for sbx in 1..info_A(c).samples_hor loop + Decode_Block(c, mb(c, sbx, sby)); + end loop samples_x_loop; + end loop samples_y_loop; + end if; + end loop components_loop; + -- All components of the current macro-block are decoded. + -- Step 4, 5, 6 happen here: Upsampling, color transformation, output + Upsampling_and_output(mb, x0, y0); + -- + mbx:= mbx + 1; + x0:= x0 + ssxmax * 8; + if mbx >= mbwidth then + mbx:= 0; + x0:= 0; + mby:= mby + 1; + y0:= y0 + ssymax * 8; + Feedback((100*mby)/mbheight); + exit macro_blocks_loop when mby >= mbheight; + end if; + if image.JPEG_stuff.restart_interval > 0 then + rstcount:= rstcount - 1; + if rstcount = 0 then + -- Here begins the restart. + bufbits:= Natural(U32(bufbits) and 16#F8#); -- byte alignment + -- Now the restart marker. We expect a + w:= U16(Get_bits(16)); + if some_trace then + Put_Line( + " Restart #" & U16'Image(nextrst) & + " Code " & U16'Image(w) & + " after" & Natural'Image(image.JPEG_stuff.restart_interval) & + " macro blocks" + ); + end if; + if w not in 16#FFD0# .. 16#FFD7# or (w and 7) /= nextrst then + raise error_in_image_data with + "JPEG: expected RST (restart) marker Nb " & U16'Image(nextrst); + end if; + nextrst:= (nextrst + 1) and 7; + rstcount:= image.JPEG_stuff.restart_interval; + -- Block-to-block predictor variables are reset. + for c in Component loop + info_B(c).dcpred:= 0; + end loop; + end if; + end if; + end loop macro_blocks_loop; + end; + end Read_SOS; + + -- + sh: Segment_head; + b: U8; + begin -- Load + loop + Read(image, sh); + case sh.kind is + when DQT => -- Quantization Table + Read_DQT(image, Natural(sh.length)); + when DHT => -- Huffman Table + Read_DHT(image, Natural(sh.length)); + when DRI => -- Restart Interval + Read_DRI(image); + when EOI => -- End Of Input + exit; + when SOS => -- Start Of Scan + Read_SOS; + exit; + when others => + -- Skip segment data + for i in 1..sh.length loop + Get_Byte(image.buffer, b); + end loop; + end case; + end loop; + next_frame:= 0.0; -- still picture + end Load; + +end GID.Decoding_JPG; diff --git a/deps/gid/gid-decoding_jpg.ads b/deps/gid/gid-decoding_jpg.ads new file mode 100644 index 00000000..e78990a8 --- /dev/null +++ b/deps/gid/gid-decoding_jpg.ads @@ -0,0 +1,89 @@ +private package GID.Decoding_JPG is + + use JPEG_defs; + + type JPEG_marker is + ( + SOI , -- Start Of Image + -- + SOF_0 , -- Start Of Frame - Baseline DCT + SOF_1 , -- Extended sequential DCT + SOF_2 , -- Progressive DCT + SOF_3 , -- Lossless (sequential) + SOF_5 , -- Differential sequential DCT + SOF_6 , -- Differential progressive DCT + SOF_7 , -- Differential lossless (sequential) + SOF_8 , -- Reserved for JPEG extensions + SOF_9 , -- Extended sequential DCT + SOF_10 , -- Progressive DCT + SOF_11 , -- Lossless (sequential) + SOF_13 , -- Differential sequential DCT + SOF_14 , -- Differential progressive DCT + SOF_15 , -- Differential lossless (sequential) + -- + DHT , -- Define Huffman Table + DAC , -- Define Arithmetic Coding + DQT , -- Define Quantization Table + DRI , -- Define Restart Interval + -- + APP_0 , -- JFIF - JFIF JPEG image - AVI1 - Motion JPEG (MJPG) + APP_1 , -- EXIF Metadata, TIFF IFD format, JPEG Thumbnail (160x120) + APP_2 , -- ICC color profile, FlashPix + APP_3 , + APP_4 , + APP_5 , + APP_6 , + APP_7 , + APP_8 , + APP_9 , + APP_10 , + APP_11 , + APP_12 , -- Picture Info + APP_13 , -- Photoshop Save As: IRB, 8BIM, IPTC + APP_14 , -- Copyright Entries + -- + COM , -- Comments + SOS , -- Start of Scan + EOI -- End of Image + ); + + YCbCr_set : constant Compo_set:= (Y|Cb|Cr => True, others => False); + Y_Grey_set: constant Compo_set:= (Y => True, others => False); + CMYK_set : constant Compo_set:= (Y|Cb|Cr|I => True, others => False); + + type Segment_head is record + length : U16; + kind : JPEG_marker; + end record; + + procedure Read(image: in out Image_descriptor; sh: out Segment_head); + + -- SOF - Start Of Frame (the real header) + procedure Read_SOF(image: in out Image_descriptor; sh: Segment_head); + + procedure Read_DHT(image: in out Image_descriptor; data_length: Natural); + procedure Read_DQT(image: in out Image_descriptor; data_length: Natural); + procedure Read_DRI(image: in out Image_descriptor); + + procedure Read_EXIF(image: in out Image_descriptor; data_length: Natural); + + -------------------- + -- Image decoding -- + -------------------- + + generic + type Primary_color_range is mod <>; + with procedure Set_X_Y (x, y: Natural); + with procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ); + with procedure Feedback (percents: Natural); + -- mode: Display_mode; -- nice -> progressive nicely displayed + -- + procedure Load ( + image : in out Image_descriptor; + next_frame: out Ada.Calendar.Day_Duration + ); + +end GID.Decoding_JPG; diff --git a/deps/gid/gid-decoding_png-huffman.adb b/deps/gid/gid-decoding_png-huffman.adb new file mode 100644 index 00000000..7ffc4ef0 --- /dev/null +++ b/deps/gid/gid-decoding_png-huffman.adb @@ -0,0 +1,365 @@ +with Ada.Text_IO; +with Ada.Unchecked_Deallocation; + +package body GID.Decoding_PNG.Huffman is + + procedure Build(t: out Huff_tree; descr: in Huff_descriptor) is + curr, alloc: Natural; + code, mask: Unsigned_32; + begin + alloc:= root; + for i in descr'Range loop + if descr(i).length > 0 then + curr:= root; + code:= Unsigned_32(descr(i).code); + mask:= Shift_Left(Unsigned_32'(1), descr(i).length-1); + for j in 0..descr(i).length-1 loop + if (code and mask) /= 0 then + if t.node(curr).one = nil then + alloc:= alloc + 1; + t.node(curr).one:= alloc; + end if; + curr:= t.node(curr).one; + else + if t.node(curr).zero = nil then + alloc:= alloc + 1; + t.node(curr).zero:= alloc; + end if; + curr:= t.node(curr).zero; + end if; + mask:= Shift_Right(mask, 1); + end loop; + t.node(curr).n:= i; + end if; + end loop; + t.last:= alloc; + end Build; + + -- Free huffman tables starting with table where t points to + + procedure HufT_free ( tl: in out p_Table_list ) is + + procedure Dispose is new + Ada.Unchecked_Deallocation( HufT_table, p_HufT_table ); + procedure Dispose is new + Ada.Unchecked_Deallocation( Table_list, p_Table_list ); + + current: p_Table_list; + tcount : Natural:= 0; -- just a stat. Idea: replace table_list with an array + tot_length: Natural:= 0; + + begin + if full_trace then + Ada.Text_IO.Put("[HufT_Free... "); + end if; + while tl /= null loop + if full_trace then + tcount:= tcount+1; + tot_length:= tot_length + tl.table'Length; + end if; + Dispose( tl.table ); -- destroy the Huffman table + current:= tl; + tl := tl.next; + Dispose( current ); -- destroy the current node + end loop; + if full_trace then + Ada.Text_IO.Put_Line( + Integer'Image(tcount)& " tables, of" & + Integer'Image(tot_length)& " tot. length]" + ); + end if; + end HufT_free; + + -- Build huffman table from code lengths given by array b + + procedure HufT_build ( b : Length_array; + s : Integer; + d, e : Length_array; + tl : out p_Table_list; + m : in out Integer; + huft_incomplete : out Boolean) + is + b_max : constant:= 16; + b_maxp1: constant:= b_max + 1; + + -- bit length count table + count : array( 0 .. b_maxp1 ) of Integer:= (others=> 0); + + f : Integer; -- i repeats in table every f entries + g : Integer; -- max. code length + i, -- counter, current code + j : Integer; -- counter + kcc : Integer; -- number of bits in current code + + c_idx, v_idx: Natural; -- array indices + + current_table_ptr : p_HufT_table:= null; + current_node_ptr : p_Table_list:= null; -- curr. node for the curr. table + new_node_ptr : p_Table_list; -- new node for the new table + + new_entry: HufT; -- table entry for structure assignment + + u : array( 0..b_max ) of p_HufT_table; -- table stack + + n_max : constant:= 288; + -- values in order of bit length + v : array( 0..n_max ) of Integer:= (others=> 0); + el_v, el_v_m_s: Integer; + + w : Natural:= 0; -- bits before this table + + offset, code_stack : array( 0..b_maxp1 ) of Integer; + + table_level : Integer:= -1; + bits : array( Integer'(-1)..b_maxp1 ) of Integer; + -- ^bits(table_level) = # bits in table of level table_level + + y : Integer; -- number of dummy codes added + z : Natural:= 0; -- number of entries in current table + el : Integer; -- length of eob code=code 256 + + no_copy_length_array: constant Boolean:= d'Length=0 or e'Length=0; + + begin + if full_trace then + Ada.Text_IO.Put("[HufT_Build..."); + end if; + tl:= null; + + if b'Length > 256 then -- set length of EOB code, if any + el := Natural(b(256)); + else + el := b_max; + end if; + + -- Generate counts for each bit length + + for k in b'Range loop + if b(k) > b_max then + -- m := 0; -- GNAT 2005 doesn't like it (warning). + raise huft_error; + end if; + count( Natural(b(k)) ):= count( Natural(b(k)) ) + 1; + end loop; + + if count(0) = b'Length then + m := 0; + huft_incomplete:= False; -- spotted by Tucker Taft, 19-Aug-2004 + return; -- complete + end if; + + -- Find minimum and maximum length, bound m by those + + j := 1; + while j <= b_max and then count(j) = 0 loop + j:= j + 1; + end loop; + kcc := j; + if m < j then + m := j; + end if; + i := b_max; + while i > 0 and then count(i) = 0 loop + i:= i - 1; + end loop; + g := i; + if m > i then + m := i; + end if; + + -- Adjust last length count to fill out codes, if needed + + y := Integer( Shift_Left(Unsigned_32'(1), j) ); -- y:= 2 ** j; + while j < i loop + y := y - count(j); + if y < 0 then + raise huft_error; + end if; + y:= y * 2; + j:= j + 1; + end loop; + + y:= y - count(i); + if y < 0 then + raise huft_error; + end if; + count(i):= count(i) + y; + + -- Generate starting offsets into the value table for each length + + offset(1) := 0; + j:= 0; + for idx in 2..i loop + j:= j + count( idx-1 ); + offset( idx ) := j; + end loop; + + -- Make table of values in order of bit length + + for idx in b'Range loop + j := Natural(b(idx)); + if j /= 0 then + v( offset(j) ) := idx-b'First; + offset(j):= offset(j) + 1; + end if; + end loop; + + -- Generate huffman codes and for each, make the table entries + + code_stack(0) := 0; + i := 0; + v_idx:= v'First; + bits(-1) := 0; + + -- go through the bit lengths (kcc already is bits in shortest code) + for k in kcc .. g loop + + for am1 in reverse 0 .. count(k)-1 loop -- a counts codes of length k + + -- here i is the huffman code of length k bits for value v(v_idx) + while k > w + bits(table_level) loop + + w:= w + bits(table_level); -- Length of tables to this position + table_level:= table_level+ 1; + z:= g - w; -- Compute min size table <= m bits + if z > m then + z := m; + end if; + j := k - w; + f := Integer(Shift_Left(Unsigned_32'(1), j)); -- f:= 2 ** j; + if f > am1 + 2 then -- Try a k-w bit table + f:= f - (am1 + 2); + c_idx:= k; + loop -- Try smaller tables up to z bits + j:= j + 1; + exit when j >= z; + f := f * 2; + c_idx:= c_idx + 1; + exit when f - count(c_idx) <= 0; + f:= f - count(c_idx); + end loop; + end if; + + if w + j > el and then w < el then + j:= el - w; -- Make EOB code end at table + end if; + if w = 0 then + j := m; -- Fix: main table always m bits! + end if; + z:= Integer(Shift_Left(Unsigned_32'(1), j)); -- z:= 2 ** j; + bits(table_level) := j; + + -- Allocate and link new table + + begin + current_table_ptr := new HufT_table ( 0..z ); + new_node_ptr := new Table_list'( current_table_ptr, null ); + exception + when Storage_Error => + raise huft_out_of_memory; + end; + + if current_node_ptr = null then -- first table + tl:= new_node_ptr; + else + current_node_ptr.next:= new_node_ptr; -- not my first... + end if; + + current_node_ptr:= new_node_ptr; -- always non-Null from there + + u( table_level ):= current_table_ptr; + + -- Connect to last table, if there is one + + if table_level > 0 then + code_stack(table_level) := i; + new_entry.bits := bits(table_level-1); + new_entry.extra_bits := 16 + j; + new_entry.next_table := current_table_ptr; + + j := Integer( + Shift_Right( Unsigned_32(i) and + (Shift_Left(Unsigned_32'(1), w) - 1 ), + w - bits(table_level-1) ) + ); + + -- Test against bad input! + + if j > u( table_level - 1 )'Last then + raise huft_error; + end if; + u( table_level - 1 ) (j) := new_entry; + end if; + + end loop; + + -- Set up table entry in new_entry + + new_entry.bits := k - w; + new_entry.next_table:= null; -- Unused + + if v_idx >= b'Length then + new_entry.extra_bits := invalid; + else + el_v:= v(v_idx); + el_v_m_s:= el_v - s; + if el_v_m_s < 0 then -- Simple code, raw value + if el_v < 256 then + new_entry.extra_bits:= 16; + else + new_entry.extra_bits:= 15; + end if; + new_entry.n := el_v; + else -- Non-simple -> lookup in lists + if no_copy_length_array then + raise huft_error; + end if; + new_entry.extra_bits := Natural(e( el_v_m_s )); + new_entry.n := Natural(d( el_v_m_s )); + end if; + v_idx:= v_idx + 1; + end if; + + -- fill code-like entries with new_entry + f := Integer( Shift_Left( Unsigned_32'(1) , k - w )); + -- i.e. f := 2 ** (k-w); + j := Integer( Shift_Right( Unsigned_32(i), w ) ); + while j < z loop + current_table_ptr(j) := new_entry; + j:= j + f; + end loop; + + -- backwards increment the k-bit code i + j := Integer( Shift_Left( Unsigned_32'(1) , k - 1 )); + -- i.e.: j:= 2 ** (k-1) + while ( Unsigned_32(i) and Unsigned_32(j) ) /= 0 loop + i := Integer( Unsigned_32(i) xor Unsigned_32(j) ); + j := j / 2; + end loop; + i := Integer( Unsigned_32(i) xor Unsigned_32(j) ); + + -- backup over finished tables + while + Integer(Unsigned_32(i) and (Shift_Left(1, w)-1)) /= + code_stack(table_level) + loop + table_level:= table_level - 1; + w:= w - bits(table_level); -- Size of previous table! + end loop; + + end loop; -- am1 + end loop; -- k + + if full_trace then + Ada.Text_IO.Put_Line("finished]"); + end if; + + huft_incomplete:= y /= 0 and g /= 1; + + exception + when others => + HufT_free( tl ); + raise; + end HufT_build; + +end GID.Decoding_PNG.Huffman; diff --git a/deps/gid/gid-decoding_png-huffman.ads b/deps/gid/gid-decoding_png-huffman.ads new file mode 100644 index 00000000..b66a3411 --- /dev/null +++ b/deps/gid/gid-decoding_png-huffman.ads @@ -0,0 +1,86 @@ +-- GID.Decoding_PNG.Huffman +---------------------------- +-- Huffman tree generation and deletion. +-- Copy of UnZip.Decompress.Huffman + +private package GID.Decoding_PNG.Huffman is + + -- Variants A and B. + + -- A/ Simplistic huffman trees, pointerless + + type Length_code_pair is record + length: Natural; + code : Natural; + end record; + + type Huff_descriptor is array(Natural range <>) of Length_code_pair; + + nil: constant:= 0; + root: constant:= 1; + + type Huff_node is record + n: Natural; -- value + zero, one: Natural:= nil; -- index of next node, if any + end record; + + max_size: constant:= 800; + + type Huff_node_list is array(1..max_size) of Huff_node; + + type Huff_tree is record + last: Natural:= nil; + node: Huff_node_list; + end record; + + procedure Build(t: out Huff_tree; descr: in Huff_descriptor); + + -- B/ Huffman tables: several steps in the binary tree + -- in one jump. + -- Pro: probably faster + -- Contra: complicated, relies on pointers, large data. + + type HufT_table; + type p_HufT_table is access HufT_table; + + invalid: constant:= 99; -- invalid value for extra bits + + type HufT is record + extra_bits : Natural:= invalid; + bits : Natural; + n : Natural; + next_table : p_HufT_table:= null; + end record; + + type HufT_table is array( Integer range <> ) of HufT; + + -- Linked list just for destroying Huffman tables + + type Table_list; + type p_Table_list is access Table_list; + + type Table_list is record + table: p_HufT_table; + next : p_Table_list; + end record; + + type Length_array is array(Integer range <>) of Natural_M32; + + empty : constant Length_array( 1..0 ):= ( others=> 0 ); + + -- Free huffman tables starting with table where t points to + procedure HufT_free ( tl: in out p_Table_list ); + + -- Build huffman table from code lengths given by array b.all + procedure HufT_build ( b : Length_array; + s : Integer; + d, e : Length_array; + tl : out p_Table_list; + m : in out Integer; + huft_incomplete : out Boolean); + + -- Possible exceptions occuring in huft_build + huft_error, -- bad tree constructed + huft_out_of_memory: exception; -- not enough memory + +end GID.Decoding_PNG.Huffman; diff --git a/deps/gid/gid-decoding_png.adb b/deps/gid/gid-decoding_png.adb new file mode 100644 index 00000000..8d8a4666 --- /dev/null +++ b/deps/gid/gid-decoding_png.adb @@ -0,0 +1,1546 @@ +-- A PNG stream is made of several "chunks" (see type PNG_Chunk_tag). +-- The image itself is contained in the IDAT chunk(s). +-- +-- Steps for decoding an image (step numbers are from the ISO standard): +-- +-- 10: Inflate deflated data; at each output buffer (slide), +-- process with step 9. +-- 9: Read filter code (row begin), or unfilter bytes, go with step 8 +-- 8: Display pixels these bytes represent; +-- eventually, locate the interlaced image current point +-- +-- Reference: Portable Network Graphics (PNG) Specification (Second Edition) +-- ISO/IEC 15948:2003 (E) +-- W3C Recommendation 10 November 2003 +-- http://www.w3.org/TR/PNG/ +-- +with GID.Buffering, GID.Decoding_PNG.Huffman; + +with Ada.Text_IO; + +package body GID.Decoding_PNG is + + generic + type Number is mod <>; + procedure Big_endian_number( + from : in out Input_buffer; + n : out Number + ); + pragma Inline(Big_endian_number); + + procedure Big_endian_number( + from : in out Input_buffer; + n : out Number + ) + is + b: U8; + begin + n:= 0; + for i in 1..Number'Size/8 loop + Buffering.Get_Byte(from, b); + n:= n * 256 + Number(b); + end loop; + end Big_endian_number; + + procedure Big_endian is new Big_endian_number( U32 ); + + ---------- + -- Read -- + ---------- + + procedure Read (image: in out Image_descriptor; ch: out Chunk_head) is + str4: String(1..4); + b: U8; + begin + Big_endian(image.buffer, ch.length); + for i in str4'Range loop + Buffering.Get_Byte(image.buffer, b); + str4(i):= Character'Val(b); + end loop; + begin + ch.kind:= PNG_Chunk_tag'Value(str4); + if some_trace then + Ada.Text_IO.Put_Line( + "Chunk [" & str4 & + "], length:" & U32'Image(ch.length) + ); + end if; + exception + when Constraint_Error => + raise error_in_image_data with + "PNG chunk unknown: " & + Integer'Image(Character'Pos(str4(1))) & + Integer'Image(Character'Pos(str4(2))) & + Integer'Image(Character'Pos(str4(3))) & + Integer'Image(Character'Pos(str4(4))) & + " (" & str4 & ')'; + end; + end Read; + + package CRC32 is + + procedure Init( CRC: out Unsigned_32 ); + + function Final( CRC: Unsigned_32 ) return Unsigned_32; + + procedure Update( CRC: in out Unsigned_32; InBuf: Byte_array ); + pragma Inline( Update ); + + end CRC32; + + package body CRC32 is + + CRC32_Table : array( Unsigned_32'(0)..255 ) of Unsigned_32; + + procedure Prepare_table is + -- CRC-32 algorithm, ISO-3309 + Seed: constant:= 16#EDB88320#; + l: Unsigned_32; + begin + for i in CRC32_Table'Range loop + l:= i; + for bit in 0..7 loop + if (l and 1) = 0 then + l:= Shift_Right(l,1); + else + l:= Shift_Right(l,1) xor Seed; + end if; + end loop; + CRC32_Table(i):= l; + end loop; + end Prepare_table; + + procedure Update( CRC: in out Unsigned_32; InBuf: Byte_array ) is + local_CRC: Unsigned_32; + begin + local_CRC:= CRC ; + for i in InBuf'Range loop + local_CRC := + CRC32_Table( 16#FF# and ( local_CRC xor Unsigned_32( InBuf(i) ) ) ) + xor + Shift_Right( local_CRC , 8 ); + end loop; + CRC:= local_CRC; + end Update; + + table_empty: Boolean:= True; + + procedure Init( CRC: out Unsigned_32 ) is + begin + if table_empty then + Prepare_table; + table_empty:= False; + end if; + CRC:= 16#FFFF_FFFF#; + end Init; + + function Final( CRC: Unsigned_32 ) return Unsigned_32 is + begin + return not CRC; + end Final; + + end CRC32; + + ---------- + -- Load -- + ---------- + + procedure Load (image: in out Image_descriptor) is + + ---------------------- + -- Load_specialized -- + ---------------------- + + generic + -- These values are invariant through the whole picture, + -- so we can make them generic parameters. As a result, all + -- "if", "case", etc. using them at the center of the decoding + -- are optimized out at compile-time. + interlaced : Boolean; + bits_per_pixel : Positive; + bytes_to_unfilter : Positive; + -- ^ amount of bytes to unfilter at a time + -- = Integer'Max(1, bits_per_pixel / 8); + subformat_id : Natural; + procedure Load_specialized; + -- + procedure Load_specialized is + + use GID.Buffering; + + subtype Mem_row_bytes_array is Byte_array (0 .. Integer (image.width) * 8); + -- + mem_row_bytes: array(0..1) of Mem_row_bytes_array; + -- We need to memorize two image rows, for un-filtering + curr_row: Natural:= 1; + -- either current is 1 and old is 0, or the reverse + + subtype X_range is Integer range -1 .. Integer (image.width) - 1; + subtype Y_range is Integer range 0 .. Integer (image.height) - 1; + -- X position -1 is for the row's filter methode code + + x: X_range:= X_range'First; + y: Y_range:= Y_range'First; + + x_max: X_range; -- for non-interlaced images: = X_range'Last + y_max: Y_range; -- for non-interlaced images: = Y_range'Last + + pass: Positive range 1..7:= 1; + + -------------------------- + -- ** 9: Unfiltering ** -- + -------------------------- + -- http://www.w3.org/TR/PNG/#9Filters + + type Filter_method_0 is (None, Sub, Up, Average, Paeth); + + current_filter: Filter_method_0; + + procedure Unfilter_bytes( + f: in Byte_array; -- filtered + u: out Byte_array -- unfiltered + ) + is + pragma Inline(Unfilter_bytes); + -- Byte positions (f is the byte to be unfiltered): + -- + -- c b + -- a f + a,b,c, p,pa,pb,pc,pr: Integer; + j: Integer:= 0; + begin + if full_trace and then x = 0 then + if y = 0 then + Ada.Text_IO.New_Line; + end if; + Ada.Text_IO.Put_Line( + "row" & Integer'Image(y) & ": filter= " & + Filter_method_0'Image(current_filter) + ); + end if; + -- + -- !! find a way to have f99n0g04.png decoded correctly... + -- seems a filter issue. + -- + case current_filter is + when None => + -- Recon(x) = Filt(x) + u:= f; + when Sub => + -- Recon(x) = Filt(x) + Recon(a) + if x > 0 then + for i in f'Range loop + u(u'First+j):= f(i) + mem_row_bytes(curr_row)((x-1)*bytes_to_unfilter+j); + j:= j + 1; + end loop; + else + u:= f; + end if; + when Up => + -- Recon(x) = Filt(x) + Recon(b) + if y > 0 then + for i in f'Range loop + u(u'First+j):= f(i) + mem_row_bytes(1-curr_row)(x*bytes_to_unfilter+j); + j:= j + 1; + end loop; + else + u:= f; + end if; + when Average => + -- Recon(x) = Filt(x) + floor((Recon(a) + Recon(b)) / 2) + for i in f'Range loop + if x > 0 then + a:= Integer(mem_row_bytes(curr_row)((x-1)*bytes_to_unfilter+j)); + else + a:= 0; + end if; + if y > 0 then + b:= Integer(mem_row_bytes(1-curr_row)(x*bytes_to_unfilter+j)); + else + b:= 0; + end if; + u(u'First+j):= U8((Integer(f(i)) + (a+b)/2) mod 256); + j:= j + 1; + end loop; + when Paeth => + -- Recon(x) = Filt(x) + PaethPredictor(Recon(a), Recon(b), Recon(c)) + for i in f'Range loop + if x > 0 then + a:= Integer(mem_row_bytes(curr_row)((x-1)*bytes_to_unfilter+j)); + else + a:= 0; + end if; + if y > 0 then + b:= Integer(mem_row_bytes(1-curr_row)(x*bytes_to_unfilter+j)); + else + b:= 0; + end if; + if x > 0 and y > 0 then + c:= Integer(mem_row_bytes(1-curr_row)((x-1)*bytes_to_unfilter+j)); + else + c:= 0; + end if; + p := a + b - c; + pa:= abs(p - a); + pb:= abs(p - b); + pc:= abs(p - c); + if pa <= pb and then pa <= pc then + pr:= a; + elsif pb <= pc then + pr:= b; + else + pr:= c; + end if; + u(u'First+j):= f(i) + U8(pr); + j:= j + 1; + end loop; + end case; + j:= 0; + for i in u'Range loop + mem_row_bytes(curr_row)(x*bytes_to_unfilter+j):= u(i); + j:= j + 1; + end loop; + -- if u'Length /= bytes_to_unfilter then + -- raise Constraint_Error; + -- end if; + end Unfilter_bytes; + + filter_stat: array(Filter_method_0) of Natural:= (others => 0); + + ---------------------------------------------- + -- ** 8: Interlacing and pass extraction ** -- + ---------------------------------------------- + -- http://www.w3.org/TR/PNG/#8Interlace + + -- Output bytes from decompression + -- + procedure Output_uncompressed( + data : in Byte_array; + reject: out Natural + -- amount of bytes to be resent here next time, + -- in order to have a full multi-byte pixel + ) + is + -- Display of pixels coded on 8 bits per channel in the PNG stream + procedure Out_Pixel_8(br, bg, bb, ba: U8) is + pragma Inline(Out_Pixel_8); + function Times_257(x: Primary_color_range) return Primary_color_range is + pragma Inline(Times_257); + begin + return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x + -- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8. + end Times_257; + begin + case Primary_color_range'Modulus is + when 256 => + Put_Pixel( + Primary_color_range(br), + Primary_color_range(bg), + Primary_color_range(bb), + Primary_color_range(ba) + ); + when 65_536 => + Put_Pixel( + Times_257(Primary_color_range(br)), + Times_257(Primary_color_range(bg)), + Times_257(Primary_color_range(bb)), + Times_257(Primary_color_range(ba)) + -- Times_257 makes max intensity FF go to FFFF + ); + when others => + raise invalid_primary_color_range with "PNG: color range not supported"; + end case; + end Out_Pixel_8; + + procedure Out_Pixel_Palette(ix: U8) is + pragma Inline(Out_Pixel_Palette); + color_idx: constant Natural:= Integer(ix); + begin + Out_Pixel_8( + image.palette(color_idx).red, + image.palette(color_idx).green, + image.palette(color_idx).blue, + 255 + ); + end Out_Pixel_Palette; + + -- Display of pixels coded on 16 bits per channel in the PNG stream + procedure Out_Pixel_16(br, bg, bb, ba: U16) is + pragma Inline(Out_Pixel_16); + begin + case Primary_color_range'Modulus is + when 256 => + Put_Pixel( + Primary_color_range(br / 256), + Primary_color_range(bg / 256), + Primary_color_range(bb / 256), + Primary_color_range(ba / 256) + ); + when 65_536 => + Put_Pixel( + Primary_color_range(br), + Primary_color_range(bg), + Primary_color_range(bb), + Primary_color_range(ba) + ); + when others => + raise invalid_primary_color_range with "PNG: color range not supported"; + end case; + end Out_Pixel_16; + + procedure Inc_XY is + pragma Inline(Inc_XY); + xm, ym: Integer; + begin + if x < x_max then + x:= x + 1; + if interlaced then + -- Position of pixels depending on pass: + -- + -- 1 6 4 6 2 6 4 6 + -- 7 7 7 7 7 7 7 7 + -- 5 6 5 6 5 6 5 6 + -- 7 7 7 7 7 7 7 7 + -- 3 6 4 6 3 6 4 6 + -- 7 7 7 7 7 7 7 7 + -- 5 6 5 6 5 6 5 6 + -- 7 7 7 7 7 7 7 7 + case pass is + when 1 => + Set_X_Y( x*8, Y_range'Last - y*8); + when 2 => + Set_X_Y(4 + x*8, Y_range'Last - y*8); + when 3 => + Set_X_Y( x*4, Y_range'Last - 4 - y*8); + when 4 => + Set_X_Y(2 + x*4, Y_range'Last - y*4); + when 5 => + Set_X_Y( x*2, Y_range'Last - 2 - y*4); + when 6 => + Set_X_Y(1 + x*2, Y_range'Last - y*2); + when 7 => + null; -- nothing to to, pixel are contiguous + end case; + end if; + else + x:= X_range'First; -- New row + if y < y_max then + y:= y + 1; + curr_row:= 1-curr_row; -- swap row index for filtering + if not interlaced then + Feedback((y*100) / Integer (image.height)); + end if; + elsif interlaced then -- last row has beed displayed + while pass < 7 loop + pass:= pass + 1; + y:= 0; + case pass is + when 1 => + null; + when 2 => + xm:= (Integer (image.width) + 3)/8 - 1; + ym:= (Integer (image.height) + 7)/8 - 1; + when 3 => + xm:= (Integer (image.width) + 3)/4 - 1; + ym:= (Integer (image.height) + 3)/8 - 1; + when 4 => + xm:= (Integer (image.width) + 1)/4 - 1; + ym:= (Integer (image.height) + 3)/4 - 1; + when 5 => + xm:= (Integer (image.width) + 1)/2 - 1; + ym:= (Integer (image.height) + 1)/4 - 1; + when 6 => + xm:= (Integer (image.width) )/2 - 1; + ym:= (Integer (image.height) + 1)/2 - 1; + when 7 => + xm:= Integer (image.width) - 1; + ym:= Integer (image.height) / 2 - 1; + end case; + if xm >=0 and xm <= X_range'Last and ym in Y_range then + -- This pass is not empty (otherwise, we will continue + -- to the next one, if any). + x_max:= xm; + y_max:= ym; + exit; + end if; + end loop; + end if; + end if; + end Inc_XY; + + uf: Byte_array(0..15); -- unfiltered bytes for a pixel + w1, w2: U16; + i: Integer; + + begin + if some_trace then + Ada.Text_IO.Put("[UO]"); + end if; + -- Depending on the row size, bpp, etc., we can have + -- several rows, or less than one, being displayed + -- with the present uncompressed data batch. + -- + i:= data'First; + if i > data'Last then + reject:= 0; + return; -- data is empty, do nothing + end if; + -- + -- Main loop over data + -- + loop + if x = X_range'First then -- pseudo-column for filter method + exit when i > data'Last; + begin + current_filter:= Filter_method_0'Val(data(i)); + if some_trace then + filter_stat(current_filter):= filter_stat(current_filter) + 1; + end if; + exception + when Constraint_Error => + raise error_in_image_data with + "PNG: wrong filter code, row #" & + Integer'Image(y) & " code:" & U8'Image(data(i)); + end; + if interlaced then + case pass is + when 1..6 => + null; -- Set_X_Y for each pixel + when 7 => + Set_X_Y(0, Y_range'Last - 1 - y*2); + end case; + else + Set_X_Y(0, Y_range'Last - y); + end if; + i:= i + 1; + else -- normal pixel + -- + -- We quit the loop if all data has been used (except for an + -- eventual incomplete pixel) + exit when i > data'Last - (bytes_to_unfilter - 1); + -- NB, for per-channel bpp < 8: + -- 7.2 Scanlines - some low-order bits of the + -- last byte of a scanline may go unused. + case subformat_id is + when 0 => + ----------------------- + -- Type 0: Greyscale -- + ----------------------- + case bits_per_pixel is + when 1 | 2 | 4 => + Unfilter_bytes(data(i..i), uf(0..0)); + i:= i + 1; + declare + b: U8; + shift: Integer:= 8 - bits_per_pixel; + max: constant U8:= U8(Shift_Left(Unsigned_32'(1), bits_per_pixel)-1); + -- Scaling factor to obtain the correct color value on a 0..255 range. + -- The division is exact in all cases (bpp=8,4,2,1), + -- since 255 = 3 * 5 * 17 and max = 255, 15, 3 or 1. + -- This factor ensures: 0 -> 0, max -> 255 + factor: constant U8:= 255 / max; + begin + -- loop through the number of pixels in this byte: + for k in reverse 1..8/bits_per_pixel loop + b:= (max and U8(Shift_Right(Unsigned_8(uf(0)), shift))) * factor; + shift:= shift - bits_per_pixel; + Out_Pixel_8(b, b, b, 255); + exit when x >= x_max or k = 1; + Inc_XY; + end loop; + end; + when 8 => + -- NB: with bpp as generic param, this case could be merged + -- into the general 1,2,4[,8] case without loss of performance + -- if the compiler is smart enough to simplify the code, given + -- the value of bits_per_pixel. + -- But we let it here for two reasons: + -- 1) a compiler might be not smart enough + -- 2) it is a very simple case, perhaps helpful for + -- understanding the algorithm. + Unfilter_bytes(data(i..i), uf(0..0)); + i:= i + 1; + Out_Pixel_8(uf(0), uf(0), uf(0), 255); + when 16 => + Unfilter_bytes(data(i..i+1), uf(0..1)); + i:= i + 2; + w1:= U16(uf(0)) * 256 + U16(uf(1)); + Out_Pixel_16(w1, w1, w1, 65535); + when others => + null; -- undefined in PNG standard + end case; + when 2 => + ----------------- + -- Type 2: RGB -- + ----------------- + case bits_per_pixel is + when 24 => + Unfilter_bytes(data(i..i+2), uf(0..2)); + i:= i + 3; + Out_Pixel_8(uf(0), uf(1), uf(2), 255); + when 48 => + Unfilter_bytes(data(i..i+5), uf(0..5)); + i:= i + 6; + Out_Pixel_16( + U16(uf(0)) * 256 + U16(uf(1)), + U16(uf(2)) * 256 + U16(uf(3)), + U16(uf(4)) * 256 + U16(uf(5)), + 65_535 + ); + when others => + null; + end case; + when 3 => + ------------------------------ + -- Type 3: RGB with palette -- + ------------------------------ + Unfilter_bytes(data(i..i), uf(0..0)); + i:= i + 1; + case bits_per_pixel is + when 1 | 2 | 4 => + declare + shift: Integer:= 8 - bits_per_pixel; + max: constant U8:= U8(Shift_Left(Unsigned_32'(1), bits_per_pixel)-1); + begin + -- loop through the number of pixels in this byte: + for k in reverse 1..8/bits_per_pixel loop + Out_Pixel_Palette(max and U8(Shift_Right(Unsigned_8(uf(0)), shift))); + shift:= shift - bits_per_pixel; + exit when x >= x_max or k = 1; + Inc_XY; + end loop; + end; + when 8 => + -- Same remark for this case (8bpp) as + -- within Image Type 0 / Greyscale above + Out_Pixel_Palette(uf(0)); + when others => + null; + end case; + when 4 => + ------------------------------- + -- Type 4: Greyscale & Alpha -- + ------------------------------- + case bits_per_pixel is + when 16 => + Unfilter_bytes(data(i..i+1), uf(0..1)); + i:= i + 2; + Out_Pixel_8(uf(0), uf(0), uf(0), uf(1)); + when 32 => + Unfilter_bytes(data(i..i+3), uf(0..3)); + i:= i + 4; + w1:= U16(uf(0)) * 256 + U16(uf(1)); + w2:= U16(uf(2)) * 256 + U16(uf(3)); + Out_Pixel_16(w1, w1, w1, w2); + when others => + null; -- undefined in PNG standard + end case; + when 6 => + ------------------ + -- Type 6: RGBA -- + ------------------ + case bits_per_pixel is + when 32 => + Unfilter_bytes(data(i..i+3), uf(0..3)); + i:= i + 4; + Out_Pixel_8(uf(0), uf(1), uf(2), uf(3)); + when 64 => + Unfilter_bytes(data(i..i+7), uf(0..7)); + i:= i + 8; + Out_Pixel_16( + U16(uf(0)) * 256 + U16(uf(1)), + U16(uf(2)) * 256 + U16(uf(3)), + U16(uf(4)) * 256 + U16(uf(5)), + U16(uf(6)) * 256 + U16(uf(7)) + ); + when others => + null; + end case; + when others => + null; -- Unknown - exception already raised at header level + end case; + end if; + Inc_XY; + end loop; + -- i is between data'Last-(bytes_to_unfilter-2) and data'Last+1 + reject:= (data'Last + 1) - i; + if reject > 0 then + if some_trace then + Ada.Text_IO.Put("[rj" & Integer'Image(reject) & ']'); + end if; + end if; + end Output_uncompressed; + + ch: Chunk_head; + + -- Out of some intelligent design, there might be an IDAT chunk + -- boundary anywhere inside the zlib compressed block... + procedure Jump_IDAT is + dummy: U32; + begin + Big_endian(image.buffer, dummy); -- ending chunk's CRC + -- New chunk begins here. + loop + Read(image, ch); + exit when ch.kind /= IDAT or ch.length > 0; + end loop; + if ch.kind /= IDAT then + raise error_in_image_data with "PNG: additional data chunk must be an IDAT"; + end if; + end Jump_IDAT; + + --------------------------------------------------------------------- + -- ** 10: Decompression ** -- + -- Excerpt and simplification from UnZip.Decompress (Inflate only) -- + --------------------------------------------------------------------- + -- http://www.w3.org/TR/PNG/#10Compression + + -- Size of sliding dictionary and circular output buffer + wsize: constant:= 16#10000#; + + -------------------------------------- + -- Specifications of UnZ_* packages -- + -------------------------------------- + + package UnZ_Glob is + -- I/O Buffers + -- > Sliding dictionary for unzipping, and output buffer as well + slide: Byte_array( 0..wsize ); + slide_index: Integer:= 0; -- Current Position in slide + Zip_EOF : constant Boolean:= False; + crc32val : Unsigned_32; -- crc calculated from data + end UnZ_Glob; + + package UnZ_IO is + + procedure Init_Buffers; + + procedure Read_raw_byte ( bt : out U8 ); + pragma Inline(Read_raw_byte); + + package Bit_buffer is + procedure Init; + -- Read at least n bits into the bit buffer, returns the n first bits + function Read ( n: Natural ) return Integer; + pragma Inline(Read); + function Read_U32 ( n: Natural ) return Unsigned_32; + pragma Inline(Read_U32); + -- Dump n bits no longer needed from the bit buffer + procedure Dump ( n: Natural ); + pragma Inline(Dump); + procedure Dump_to_byte_boundary; + function Read_and_dump( n: Natural ) return Integer; + pragma Inline(Read_and_dump); + function Read_and_dump_U32( n: Natural ) return Unsigned_32; + pragma Inline(Read_and_dump_U32); + end Bit_buffer; + + procedure Flush ( x: Natural ); -- directly from slide to output stream + + procedure Flush_if_full(W: in out Integer); + pragma Inline(Flush_if_full); + + procedure Copy( + distance, length: Natural; + index : in out Natural ); + pragma Inline(Copy); + + end UnZ_IO; + + package UnZ_Meth is + deflate_e_mode: constant Boolean:= False; + procedure Inflate; + end UnZ_Meth; + + ------------------------------ + -- Bodies of UnZ_* packages -- + ------------------------------ + package body UnZ_IO is + + procedure Init_Buffers is + begin + UnZ_Glob.slide_index := 0; + Bit_buffer.Init; + CRC32.Init( UnZ_Glob.crc32val ); + end Init_Buffers; + + procedure Read_raw_byte ( bt : out U8 ) is + begin + if ch.length = 0 then + -- We hit the end of a PNG 'IDAT' chunk, so we go to the next one + -- - in petto, it's strange design, but well... + -- This "feature" has taken some time (and nerves) to be addressed. + -- Incidentally, to solve the mystery, I have reprogrammed the + -- whole Huffman decoding, and looked at many other wrong places! + Jump_IDAT; + end if; + Buffering.Get_Byte(image.buffer, bt); + ch.length:= ch.length - 1; + end Read_raw_byte; + + package body Bit_buffer is + B : Unsigned_32; + K : Integer; + + procedure Init is + begin + B := 0; + K := 0; + end Init; + + procedure Need( n : Natural ) is + pragma Inline(Need); + bt: U8; + begin + while K < n loop + Read_raw_byte( bt ); + B:= B or Shift_Left( Unsigned_32( bt ), K ); + K:= K + 8; + end loop; + end Need; + + procedure Dump ( n : Natural ) is + begin + B := Shift_Right(B, n ); + K := K - n; + end Dump; + + procedure Dump_to_byte_boundary is + begin + Dump ( K mod 8 ); + end Dump_to_byte_boundary; + + function Read_U32 ( n: Natural ) return Unsigned_32 is + begin + Need(n); + return B and (Shift_Left(1,n) - 1); + end Read_U32; + + function Read ( n: Natural ) return Integer is + begin + return Integer(Read_U32(n)); + end Read; + + function Read_and_dump( n: Natural ) return Integer is + res: Integer; + begin + res:= Read(n); + Dump(n); + return res; + end Read_and_dump; + + function Read_and_dump_U32( n: Natural ) return Unsigned_32 is + res: Unsigned_32; + begin + res:= Read_U32(n); + Dump(n); + return res; + end Read_and_dump_U32; + + end Bit_buffer; + + old_bytes: Natural:= 0; + -- how many bytes to be resent from last Inflate output + byte_mem: Byte_array(1..8); + + procedure Flush ( x: Natural ) is + begin + if full_trace then + Ada.Text_IO.Put("[Flush..." & Integer'Image(x)); + end if; + CRC32.Update( UnZ_Glob.crc32val, UnZ_Glob.slide( 0..x-1 ) ); + if old_bytes > 0 then + declare + app: constant Byte_array:= + byte_mem(1..old_bytes) & UnZ_Glob.slide(0..x-1); + begin + Output_uncompressed(app, old_bytes); + -- In extreme cases (x very small), we might have some of + -- the rejected bytes from byte_mem. + if old_bytes > 0 then + byte_mem(1..old_bytes):= app(app'Last-(old_bytes-1)..app'Last); + end if; + end; + else + Output_uncompressed(UnZ_Glob.slide(0..x-1), old_bytes); + if old_bytes > 0 then + byte_mem(1..old_bytes):= UnZ_Glob.slide(x-old_bytes..x-1); + end if; + end if; + if full_trace then + Ada.Text_IO.Put_Line("finished]"); + end if; + end Flush; + + procedure Flush_if_full(W: in out Integer) is + begin + if W = wsize then + Flush(wsize); + W:= 0; + end if; + end Flush_if_full; + + ---------------------------------------------------- + -- Reproduction of sequences in the output slide. -- + ---------------------------------------------------- + + -- Internal: + + procedure Adjust_to_Slide( + source : in out Integer; + remain : in out Natural; + part : out Integer; + index: Integer) + is + pragma Inline(Adjust_to_Slide); + begin + source:= source mod wsize; + -- source and index are now in 0..WSize-1 + if source > index then + part:= wsize-source; + else + part:= wsize-index; + end if; + -- NB: part is in 1..WSize (part cannot be 0) + if part > remain then + part:= remain; + end if; + -- Now part <= remain + remain:= remain - part; + -- NB: remain cannot be < 0 + end Adjust_to_Slide; + + procedure Copy_range(source, index: in out Natural; amount: Positive) is + pragma Inline(Copy_range); + begin + if abs (index - source) < amount then + -- if source >= index, the effect of copy is + -- just like the non-overlapping case + for count in reverse 1..amount loop + UnZ_Glob.slide(index):= UnZ_Glob.slide(source); + index := index + 1; + source:= source + 1; + end loop; + else -- non-overlapping -> copy slice + UnZ_Glob.slide( index .. index+amount-1 ):= + UnZ_Glob.slide( source..source+amount-1 ); + index := index + amount; + source:= source + amount; + end if; + end Copy_range; + + -- The copying routines: + + procedure Copy( + distance, length: Natural; + index : in out Natural ) + is + source,part,remain: Integer; + begin + source:= index - distance; + remain:= length; + loop + Adjust_to_Slide(source,remain,part, index); + Copy_range(source, index, part); + Flush_if_full(index); + exit when remain = 0; + end loop; + end Copy; + + end UnZ_IO; + + package body UnZ_Meth is + + use GID.Decoding_PNG.Huffman; + + --------[ Method: Inflate ]-------- + + procedure Inflate_Codes ( Tl, Td: p_Table_list; Bl, Bd: Integer ) is + CT : p_HufT_table; -- current table + CT_idx : Integer; -- current table index + length : Natural; + E : Integer; -- table entry flag/number of extra bits + W : Integer:= UnZ_Glob.slide_index; + -- more local variable for slide index + begin + if full_trace then + Ada.Text_IO.Put_Line("Begin Inflate_codes"); + end if; + + -- inflate the coded data + main_loop: + while not UnZ_Glob.Zip_EOF loop + CT:= Tl.table; + CT_idx:= UnZ_IO.Bit_buffer.Read(Bl); + + loop + E := CT(CT_idx).extra_bits; + exit when E <= 16; + if E = invalid then + raise error_in_image_data with "PNG: invalid code in Deflate compression"; + end if; + + -- then it's a literal + UnZ_IO.Bit_buffer.Dump( CT(CT_idx).bits ); + E:= E - 16; + CT:= CT(CT_idx).next_table; + CT_idx := UnZ_IO.Bit_buffer.Read(E); + end loop; + + UnZ_IO.Bit_buffer.Dump ( CT(CT_idx).bits ); + + case E is + when 16 => -- CTE.N is a Litteral + UnZ_Glob.slide ( W ) := U8( CT(CT_idx).n ); + W:= W + 1; + UnZ_IO.Flush_if_full(W); + + when 15 => -- End of block (EOB) + if full_trace then + Ada.Text_IO.Put_Line("Exit Inflate_codes, e=15 EOB"); + end if; + exit main_loop; + + when others => -- We have a length/distance + + -- Get length of block to copy: + length:= CT(CT_idx).n + UnZ_IO.Bit_buffer.Read_and_dump(E); + + -- Decode distance of block to copy: + CT:= Td.table; + CT_idx := UnZ_IO.Bit_buffer.Read(Bd); + loop + E := CT(CT_idx).extra_bits; + exit when E <= 16; + if E = invalid then + raise error_in_image_data + with "PNG: invalid code in Deflate compression (LZ distance)"; + end if; + UnZ_IO.Bit_buffer.Dump( CT(CT_idx).bits ); + E:= E - 16; + CT:= CT(CT_idx).next_table; + CT_idx := UnZ_IO.Bit_buffer.Read(E); + end loop; + UnZ_IO.Bit_buffer.Dump( CT(CT_idx).bits ); + + UnZ_IO.Copy( + distance => CT(CT_idx).n + UnZ_IO.Bit_buffer.Read_and_dump(E), + length => length, + index => W + ); + end case; + end loop main_loop; + + UnZ_Glob.slide_index:= W; + + if full_trace then + Ada.Text_IO.Put_Line("End Inflate_codes"); + end if; + end Inflate_Codes; + + procedure Inflate_stored_block is -- Actually, nothing to inflate + N : Integer; + begin + if full_trace then + Ada.Text_IO.Put_Line("Begin Inflate_stored_block"); + end if; + UnZ_IO.Bit_buffer.Dump_to_byte_boundary; + + -- Get the block length and its complement + N:= UnZ_IO.Bit_buffer.Read_and_dump( 16 ); + if N /= Integer( + (not UnZ_IO.Bit_buffer.Read_and_dump_U32(16)) + and 16#ffff#) + then + raise error_in_image_data with "PNG: invalid check code in Deflate stored block"; + end if; + while N > 0 and then not UnZ_Glob.Zip_EOF loop + -- Read and output the non-compressed data + N:= N - 1; + UnZ_Glob.slide ( UnZ_Glob.slide_index ) := + U8( UnZ_IO.Bit_buffer.Read_and_dump(8) ); + UnZ_Glob.slide_index:= UnZ_Glob.slide_index + 1; + UnZ_IO.Flush_if_full(UnZ_Glob.slide_index); + end loop; + if full_trace then + Ada.Text_IO.Put_Line("End Inflate_stored_block"); + end if; + end Inflate_stored_block; + + -- Copy lengths for literal codes 257..285 + + copy_lengths_literal : Length_array( 0..30 ) := + ( 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ); + + -- Extra bits for literal codes 257..285 + + extra_bits_literal : Length_array( 0..30 ) := + ( 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, invalid, invalid ); + + -- Copy offsets for distance codes 0..29 (30..31: deflate_e) + + copy_offset_distance : constant Length_array( 0..31 ) := + ( 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577, 32769, 49153 ); + + -- Extra bits for distance codes + + extra_bits_distance : constant Length_array( 0..31 ) := + ( 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14 ); + + max_dist: Integer:= 29; -- changed to 31 for deflate_e + + procedure Inflate_fixed_block is + Tl, -- literal/length code table + Td : p_Table_list; -- distance code table + Bl, Bd : Integer; -- lookup bits for tl/bd + huft_incomplete : Boolean; + + -- length list for HufT_build (literal table) + L: constant Length_array( 0..287 ):= + ( 0..143=> 8, 144..255=> 9, 256..279=> 7, 280..287=> 8); + + begin + if full_trace then + Ada.Text_IO.Put_Line("Begin Inflate_fixed_block"); + end if; + + -- make a complete, but wrong code set + Bl := 7; + HufT_build( + L, 257, copy_lengths_literal, extra_bits_literal, + Tl, Bl, huft_incomplete + ); + + -- Make an incomplete code set + Bd := 5; + begin + HufT_build( + (0..max_dist => 5), 0, + copy_offset_distance, extra_bits_distance, + Td, Bd, huft_incomplete + ); + if huft_incomplete then + if full_trace then + Ada.Text_IO.Put_Line( + "td is incomplete, pointer=null: " & + Boolean'Image(Td=null) + ); + end if; + end if; + exception + when huft_out_of_memory | huft_error => + HufT_free( Tl ); + raise error_in_image_data + with "PNG: error in Deflate compression (Huffman #1)"; + end; + + Inflate_Codes ( Tl, Td, Bl, Bd ); + + HufT_free ( Tl ); + HufT_free ( Td ); + + if full_trace then + Ada.Text_IO.Put_Line("End Inflate_fixed_block"); + end if; + end Inflate_fixed_block; + + procedure Inflate_dynamic_block is + bit_order : constant array ( 0..18 ) of Natural := + ( 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ); + + Lbits : constant:= 9; + Dbits : constant:= 6; + + current_length: Natural:= 0; + defined, number_of_lengths: Natural; + + Tl, -- literal/length code tables + Td : p_Table_list; -- distance code tables + + CT_dyn_idx : Integer; -- current table element + + Bl, Bd : Integer; -- lookup bits for tl/bd + Nb : Natural; -- number of bit length codes + Nl : Natural; -- number of literal length codes + Nd : Natural; -- number of distance codes + + -- literal/length and distance code lengths + Ll: Length_array( 0 .. 288+32-1 ):= (others=> 0); + + huft_incomplete : Boolean; + + procedure Repeat_length_code( amount: Natural ) is + begin + if defined + amount > number_of_lengths then + raise error_in_image_data + with "PNG: invalid data in Deflate dynamic compression structure (#1)"; + end if; + for c in reverse 1..amount loop + Ll ( defined ) := Natural_M32(current_length); + defined:= defined + 1; + end loop; + end Repeat_length_code; + + begin + if full_trace then + Ada.Text_IO.Put_Line("Begin Inflate_dynamic_block"); + end if; + + -- Read in table lengths + Nl := 257 + UnZ_IO.Bit_buffer.Read_and_dump(5); + Nd := 1 + UnZ_IO.Bit_buffer.Read_and_dump(5); + Nb := 4 + UnZ_IO.Bit_buffer.Read_and_dump(4); + + if Nl > 288 or else Nd > 32 then + raise error_in_image_data + with "PNG: invalid data in Deflate dynamic compression structure (#2)"; + end if; + + -- Read in bit-length-code lengths. + -- The rest, Ll( Bit_Order( Nb .. 18 ) ), is already = 0 + for J in 0 .. Nb - 1 loop + Ll ( bit_order( J ) ) := Natural_M32(UnZ_IO.Bit_buffer.Read_and_dump(3)); + end loop; + + -- Build decoding table for trees--single level, 7 bit lookup + Bl := 7; + begin + HufT_build ( + Ll( 0..18 ), 19, empty, empty, Tl, Bl, huft_incomplete + ); + if huft_incomplete then + HufT_free(Tl); + raise error_in_image_data + with "PNG: error in Deflate compression (Huffman #2)"; + end if; + exception + when others => + raise error_in_image_data + with "PNG: error in Deflate compression (Huffman #3)"; + end; + + -- Read in literal and distance code lengths + number_of_lengths := Nl + Nd; + defined := 0; + current_length := 0; + + while defined < number_of_lengths loop + CT_dyn_idx:= UnZ_IO.Bit_buffer.Read(Bl); + UnZ_IO.Bit_buffer.Dump( Tl.table(CT_dyn_idx).bits ); + + case Tl.table(CT_dyn_idx).n is + when 0..15 => -- length of code in bits (0..15) + current_length:= Tl.table(CT_dyn_idx).n; + Ll (defined) := Natural_M32(current_length); + defined:= defined + 1; + + when 16 => -- repeat last length 3 to 6 times + Repeat_length_code(3 + UnZ_IO.Bit_buffer.Read_and_dump(2)); + + when 17 => -- 3 to 10 zero length codes + current_length:= 0; + Repeat_length_code(3 + UnZ_IO.Bit_buffer.Read_and_dump(3)); + + when 18 => -- 11 to 138 zero length codes + current_length:= 0; + Repeat_length_code(11 + UnZ_IO.Bit_buffer.Read_and_dump(7)); + + when others => + if full_trace then + Ada.Text_IO.Put_Line( + "Illegal length code: " & + Integer'Image(Tl.table(CT_dyn_idx).n) + ); + end if; + + end case; + end loop; + + HufT_free ( Tl ); -- free decoding table for trees + + -- Build the decoding tables for literal/length codes + Bl := Lbits; + begin + HufT_build ( + Ll( 0..Nl-1 ), 257, + copy_lengths_literal, extra_bits_literal, + Tl, Bl, huft_incomplete + ); + if huft_incomplete then + HufT_free(Tl); + raise error_in_image_data + with "PNG: error in Deflate compression (Huffman #4)"; + end if; + exception + when others => + raise error_in_image_data + with "PNG: error in Deflate compression (Huffman #5)"; + end; + + -- Build the decoding tables for distance codes + Bd := Dbits; + begin + HufT_build ( + Ll( Nl..Nl+Nd-1 ), 0, + copy_offset_distance, extra_bits_distance, + Td, Bd, huft_incomplete + ); + if huft_incomplete then -- do nothing! + if full_trace then + Ada.Text_IO.Put_Line("PKZIP 1.93a bug workaround"); + end if; + end if; + exception + when huft_out_of_memory | huft_error => + HufT_free(Tl); + raise error_in_image_data + with "PNG: error in Deflate compression (Huffman #6)"; + end; + + -- Decompress until an end-of-block code + + Inflate_Codes ( Tl, Td, Bl, Bd ); + HufT_free ( Tl ); + HufT_free ( Td ); + + if full_trace then + Ada.Text_IO.Put_Line("End Inflate_dynamic_block"); + end if; + end Inflate_dynamic_block; + + procedure Inflate_Block( last_block: out Boolean ) is + begin + last_block:= Boolean'Val(UnZ_IO.Bit_buffer.Read_and_dump(1)); + case UnZ_IO.Bit_buffer.Read_and_dump(2) is -- Block type = 0,1,2,3 + when 0 => Inflate_stored_block; + when 1 => Inflate_fixed_block; + when 2 => Inflate_dynamic_block; + when others => + raise error_in_image_data with + "PNG: error in Deflate compression: bad block type (3)"; + end case; + end Inflate_Block; + + procedure Inflate is + is_last_block: Boolean; + blocks: Positive:= 1; + begin + if deflate_e_mode then + copy_lengths_literal(28):= 3; -- instead of 258 + extra_bits_literal(28):= 16; -- instead of 0 + max_dist:= 31; + end if; + loop + Inflate_Block ( is_last_block ); + exit when is_last_block; + blocks:= blocks+1; + end loop; + UnZ_IO.Flush( UnZ_Glob.slide_index ); + UnZ_Glob.slide_index:= 0; + if some_trace then + Ada.Text_IO.Put("# blocks:" & Integer'Image(blocks)); + end if; + UnZ_Glob.crc32val := CRC32.Final( UnZ_Glob.crc32val ); + end Inflate; + + end UnZ_Meth; + + -------------------------------------------------------------------- + -- End of the Decompression part, and of UnZip.Decompress excerpt -- + -------------------------------------------------------------------- + + b: U8; + z_crc, dummy: U32; + + begin -- Load_specialized + -- + -- For optimization reasons, bytes_to_unfilter is passed as a + -- generic parameter but should be always as below right to "/=" : + -- + if bytes_to_unfilter /= Integer'Max(1, bits_per_pixel / 8) then + raise Program_Error; + end if; + if interlaced then + x_max:= (Integer (image.width) + 7)/8 - 1; + y_max:= (Integer (image.height) + 7)/8 - 1; + else + x_max:= X_range'Last; + y_max:= Y_range'Last; + end if; + main_chunk_loop: + loop + loop + Read(image, ch); + exit when ch.kind = IEND or ch.length > 0; + end loop; + case ch.kind is + when IEND => -- 11.2.5 IEND Image trailer + exit main_chunk_loop; + when IDAT => -- 11.2.4 IDAT Image data + -- + -- NB: the compressed data may hold on several IDAT chunks. + -- It means that right in the middle of compressed data, you + -- can have a chunk crc, and a new IDAT header!... + -- + UnZ_IO.Read_raw_byte(b); -- zlib compression method/flags code + UnZ_IO.Read_raw_byte(b); -- Additional flags/check bits + -- + UnZ_IO.Init_Buffers; + -- ^ we indicate that we have a byte reserve of chunk's length, + -- minus both zlib header bytes. + UnZ_Meth.Inflate; + z_crc:= 0; + for i in 1..4 loop + begin + UnZ_IO.Read_raw_byte(b); + exception + when error_in_image_data => + -- vicious IEND at the wrong place + -- basi4a08.png test image (corrupt, imho) + exit main_chunk_loop; + end; + z_crc:= z_crc * 256 + U32(b); + end loop; + -- z_crc : zlib Check value + -- if z_crc /= U32(UnZ_Glob.crc32val) then + -- ada.text_io.put(z_crc 'img & UnZ_Glob.crc32val'img); + -- raise + -- error_in_image_data with + -- "PNG: deflate stream corrupt"; + -- end if; + -- ** Mystery: this check fails even with images which decompress perfectly + -- ** Is CRC init value different between zip and zlib ? Is it Adler32 ? + Big_endian(image.buffer, dummy); -- chunk's CRC + -- last IDAT chunk's CRC (then, on compressed data) + -- + when tEXt => -- 11.3.4.3 tEXt Textual data + for i in 1..ch.length loop + Get_Byte(image.buffer, b); + if some_trace then + if b=0 then -- separates keyword from message + Ada.Text_IO.New_Line; + else + Ada.Text_IO.Put(Character'Val(b)); + end if; + end if; + end loop; + Big_endian(image.buffer, dummy); -- chunk's CRC + when others => + -- Skip chunk data and CRC + for i in 1..ch.length + 4 loop + Get_Byte(image.buffer, b); + end loop; + end case; + end loop main_chunk_loop; + if some_trace then + for f in Filter_method_0 loop + Ada.Text_IO.Put_Line( + "Filter: " & + Filter_method_0'Image(f) & + Integer'Image(filter_stat(f)) + ); + end loop; + end if; + Feedback(100); + end Load_specialized; + + -- Instances of Load_specialized, with hard-coded parameters. + -- They may take an insane amount of time to compile, and bloat the + -- .o code , but are significantly faster since they make the + -- compiler skip corresponding tests at pixel level. + -- These instances are for most current PNG sub-formats. + + procedure Load_interlaced_1pal is new Load_specialized(True, 1, 1, 3); + procedure Load_interlaced_2pal is new Load_specialized(True, 2, 1 ,3); + procedure Load_interlaced_4pal is new Load_specialized(True, 4, 1, 3); + procedure Load_interlaced_8pal is new Load_specialized(True, 8, 1, 3); + procedure Load_interlaced_24 is new Load_specialized(True, 24, 3, 2); + procedure Load_interlaced_32 is new Load_specialized(True, 32, 4, 6); + -- + procedure Load_straight_1pal is new Load_specialized(False, 1, 1, 3); + procedure Load_straight_2pal is new Load_specialized(False, 2, 1, 3); + procedure Load_straight_4pal is new Load_specialized(False, 4, 1, 3); + procedure Load_straight_8pal is new Load_specialized(False, 8, 1, 3); + procedure Load_straight_24 is new Load_specialized(False, 24, 3, 2); + procedure Load_straight_32 is new Load_specialized(False, 32, 4, 6); + -- + -- For unusual sub-formats, we prefer to fall back to the + -- slightly slower, general version, where parameters values + -- are not known at compile-time: + -- + procedure Load_general is new + Load_specialized( + interlaced => image.interlaced, + bits_per_pixel => image.bits_per_pixel, + bytes_to_unfilter => Integer'Max(1, image.bits_per_pixel / 8), + subformat_id => image.subformat_id + ); + + begin -- Load + -- + -- All these case tests are better done at the picture + -- level than at the pixel level. + -- + case image.subformat_id is + when 2 => -- RGB + case image.bits_per_pixel is + when 24 => + if image.interlaced then + Load_interlaced_24; + else + Load_straight_24; + end if; + when others => + Load_general; + end case; + when 3 => -- Palette + case image.bits_per_pixel is + when 1 => + if image.interlaced then + Load_interlaced_1pal; + else + Load_straight_1pal; + end if; + when 2 => + if image.interlaced then + Load_interlaced_2pal; + else + Load_straight_2pal; + end if; + when 4 => + if image.interlaced then + Load_interlaced_4pal; + else + Load_straight_4pal; + end if; + when 8 => + if image.interlaced then + Load_interlaced_8pal; + else + Load_straight_8pal; + end if; + when others => + Load_general; + end case; + when 6 => -- RGBA + case image.bits_per_pixel is + when 32 => + if image.interlaced then + Load_interlaced_32; + else + Load_straight_32; + end if; + when others => + Load_general; + end case; + when others => + Load_general; + end case; + end Load; + +end GID.Decoding_PNG; diff --git a/deps/gid/gid-decoding_png.ads b/deps/gid/gid-decoding_png.ads new file mode 100644 index 00000000..4ef6502a --- /dev/null +++ b/deps/gid/gid-decoding_png.ads @@ -0,0 +1,77 @@ +private package GID.Decoding_PNG is + + type PNG_Chunk_tag is ( + -- + -- Critical chunks + -- + IHDR, -- must be the first chunk; it contains the header. + PLTE, -- contains the palette; list of colors. + IDAT, -- contains the image, which may be split among multiple IDAT chunks. + IEND, -- marks the image end. + -- + -- Ancillary chunks + -- + bKGD, -- gives the default background color. + cHRM, -- gives the chromaticity coordinates of the display primaries and white point. + gAMA, -- specifies gamma. + hIST, -- can store the histogram, or total amount of each color in the image. + iCCP, -- is an ICC color profile. + iTXt, -- contains UTF-8 text, compressed or not, with an optional language tag. + pHYs, -- holds the intended pixel size and/or aspect ratio of the image. + sBIT, -- (significant bits) indicates the color-accuracy of the source data. + sPLT, -- suggests a palette to use if the full range of colors is unavailable. + sRGB, -- indicates that the standard sRGB color space is used. + tEXt, -- can store text that can be represented in ISO/IEC 8859-1. + tIME, -- stores the time that the image was last changed. + tRNS, -- contains transparency information. + zTXt, -- contains compressed text with the same limits as tEXt. + -- + -- Public extentions + -- PNG Extensions and Register of Public Chunks and Keywords + -- + oFFs, -- image offset from frame or page origin + pCAL, -- physical calibration of pixel values + sCAL, -- physical scale of image subject + sTER, -- stereographic subimage layout + gIFg, -- GIF Graphic Control Extension + gIFx, -- GIF Application Extension + fRAc, -- fractal image parameters + -- + -- Private chunks (not defined in the ISO standard) + -- + vpAg, -- used in ImageMagick to store "virtual page" size + spAL, + prVW, + cmOD, + cmPP, + cpIp, + mkBF, + mkBS, + mkBT, + mkTS, + pcLb + ); + + type Chunk_head is record + length: U32; + kind : PNG_Chunk_tag; + end record; + + procedure Read( image: in out Image_descriptor; ch: out Chunk_head); + + -------------------- + -- Image decoding -- + -------------------- + + generic + type Primary_color_range is mod <>; + with procedure Set_X_Y (x, y: Natural); + with procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ); + with procedure Feedback (percents: Natural); + -- + procedure Load (image: in out Image_descriptor); + +end GID.Decoding_PNG; diff --git a/deps/gid/gid-decoding_pnm.adb b/deps/gid/gid-decoding_pnm.adb new file mode 100644 index 00000000..6fa69380 --- /dev/null +++ b/deps/gid/gid-decoding_pnm.adb @@ -0,0 +1,255 @@ +with GID.Buffering; use GID.Buffering; + +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; + +package body GID.Decoding_PNM is + + ---------- + -- Load -- + ---------- + + procedure Load (image: in out Image_descriptor) is + + procedure Row_start(y: Natural) is + begin + Set_X_Y(0, Integer (image.height) - 1 - y); + end Row_start; + + type Pixel is record + color: RGB_color; + alpha: U8; + end record; + + pix: Pixel; + + procedure Output_Pixel is + pragma Inline(Output_Pixel); + function Times_257(x: Primary_color_range) return Primary_color_range is + pragma Inline(Times_257); + begin + return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x + -- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8. + end Times_257; + begin + case Primary_color_range'Modulus is + when 256 => + Put_Pixel( + Primary_color_range(pix.color.red), + Primary_color_range(pix.color.green), + Primary_color_range(pix.color.blue), + Primary_color_range(pix.alpha) + ); + when 65_536 => + Put_Pixel( + Times_257(Primary_color_range(pix.color.red)), + Times_257(Primary_color_range(pix.color.green)), + Times_257(Primary_color_range(pix.color.blue)), + Times_257(Primary_color_range(pix.alpha)) + -- Times_257 makes max intensity FF go to FFFF + ); + when others => + raise invalid_primary_color_range with "PNM: color range not supported"; + end case; + end Output_Pixel; + + ---------- + -- P1 -- + ---------- + + procedure Get_Mono_Text_Picture is + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + pix.color.red := U8((1-Get_Integer(image.stream, single_char => True)) * 255); + pix.color.green := pix.color.red; + pix.color.blue := pix.color.red; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_Mono_Text_Picture; + + ---------- + -- P2 -- + ---------- + + procedure Get_Grey_Text_Picture is + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + pix.color.red := U8(Get_Integer(image.stream)); + pix.color.green := pix.color.red; + pix.color.blue := pix.color.red; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_Grey_Text_Picture; + + ---------- + -- P3 -- + ---------- + + procedure Get_RGB_Text_Picture is + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + pix.color.red := U8(Get_Integer(image.stream)); + pix.color.green := U8(Get_Integer(image.stream)); + pix.color.blue := U8(Get_Integer(image.stream)); + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_RGB_Text_Picture; + + ---------- + -- P4 -- + ---------- + + procedure Get_Mono_Binary_Picture is + bbf: U8; -- Bit buffer + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + if x mod 8 = 0 then + Get_Byte(image.buffer, bbf); + end if; + pix.color.red := 255 * (1-Shift_Right(bbf,7)); + bbf:= bbf * 2; + pix.color.green := pix.color.red; + pix.color.blue := pix.color.red; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_Mono_Binary_Picture; + + ---------- + -- P5 -- + ---------- + + procedure Get_Grey_Binary_Picture is + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + Get_Byte(image.buffer, pix.color.red); + pix.color.green := pix.color.red; + pix.color.blue := pix.color.red; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer(image.height)); + end loop; + end Get_Grey_Binary_Picture; + + ---------- + -- P6 -- + ---------- + + procedure Get_RGB_Binary_Picture is + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0.. Integer (image.width) - 1 loop + Get_Byte(image.buffer, pix.color.red); + Get_Byte(image.buffer, pix.color.green); + Get_Byte(image.buffer, pix.color.blue); + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_RGB_Binary_Picture; + + begin + pix.alpha:= 255; -- opaque is default + if image.subformat_id >= 4 then -- Binary + Attach_Stream(image.buffer, image.stream); + end if; + -- + case image.subformat_id is + when 1 => + Get_Mono_Text_Picture; + when 2 => + Get_Grey_Text_Picture; + when 3 => + Get_RGB_Text_Picture; + when 4 => + Get_Mono_Binary_Picture; + when 5 => + Get_Grey_Binary_Picture; + when 6 => + Get_RGB_Binary_Picture; + when others => null; + end case; + end Load; + + function Get_Token( + stream : Stream_Access; + needs_EOL : Boolean:= False; + single_char : Boolean:= False + ) + return String + is + c: Character; + res: Unbounded_String; + procedure Skip_comment is + begin + if c = '#' then + loop + Character'Read(stream, c); + exit when c = ASCII.LF; + end loop; + end if; + end Skip_comment; + begin + loop + Character'Read(stream, c); + Skip_comment; + exit when c > ' '; + end loop; + loop + if c > ' ' then + res:= res & c; + end if; + if single_char then + exit when Length(res) = 1; + end if; + Character'Read(stream, c); + Skip_comment; + if needs_EOL then + exit when c = ASCII.LF; + else + exit when c <= ' '; + end if; + end loop; + return To_String(res); + end Get_Token; + + function Get_Integer( + stream : Stream_Access; + needs_EOL : Boolean:= False; + single_char : Boolean:= False + ) + return Integer + is + begin + return Integer'Value(Get_Token(stream, needs_EOL, single_char)); + end Get_Integer; + + function Get_Positive_32( + stream : Stream_Access; + needs_EOL : Boolean:= False; + single_char : Boolean:= False + ) + return Positive_32 + is + begin + return Positive_32'Value(Get_Token(stream, needs_EOL, single_char)); + end Get_Positive_32; + +end GID.Decoding_PNM; diff --git a/deps/gid/gid-decoding_pnm.ads b/deps/gid/gid-decoding_pnm.ads new file mode 100644 index 00000000..58ae207e --- /dev/null +++ b/deps/gid/gid-decoding_pnm.ads @@ -0,0 +1,43 @@ +-- Portable pixmap format (PPM) +-- Portable graymap format (PGM) +-- Portable bitmap format (PBM) + +private package GID.Decoding_PNM is + + -------------------- + -- Image decoding -- + -------------------- + + generic + type Primary_color_range is mod <>; + with procedure Set_X_Y (x, y: Natural); + with procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ); + with procedure Feedback (percents: Natural); + -- + procedure Load (image: in out Image_descriptor); + + function Get_Token( + stream : Stream_Access; + needs_EOL : Boolean:= False; + single_char : Boolean:= False + ) + return String; + + function Get_Integer( + stream : Stream_Access; + needs_EOL : Boolean:= False; + single_char : Boolean:= False + ) + return Integer; + + function Get_Positive_32( + stream : Stream_Access; + needs_EOL : Boolean:= False; + single_char : Boolean:= False + ) + return Positive_32; + +end GID.Decoding_PNM; diff --git a/deps/gid/gid-decoding_tga.adb b/deps/gid/gid-decoding_tga.adb new file mode 100644 index 00000000..8c9501b3 --- /dev/null +++ b/deps/gid/gid-decoding_tga.adb @@ -0,0 +1,289 @@ +with GID.Buffering; use GID.Buffering; +with GID.Color_tables; + +package body GID.Decoding_TGA is + + ---------- + -- Load -- + ---------- + + procedure Load (image: in out Image_descriptor) is + + procedure Row_start(y: Natural) is + begin + if image.top_first then + Set_X_Y(0, Integer (image.height) - 1 - y); + else + Set_X_Y(0, y); + end if; + end Row_start; + + -- Run Length Encoding -- + RLE_pixels_remaining: Natural:= 0; + is_run_packet: Boolean; + + type Pixel is record + color: RGB_color; + alpha: U8; + end record; + + pix, pix_mem: Pixel; + + generic + bpp: Positive; + pal: Boolean; + procedure Get_pixel; + pragma Inline(Get_pixel); + -- + procedure Get_pixel is + idx: Natural; + p1, p2, c, d: U8; + begin + if pal then + if image.palette'Length <= 256 then + Get_Byte(image.buffer, p1); + idx:= Natural(p1); + else + Get_Byte(image.buffer, p1); + Get_Byte(image.buffer, p2); + idx:= Natural(p1) + Natural(p2) * 256; + end if; + idx:= idx + image.palette'First; + pix.color:= image.palette(idx); + else + case bpp is + when 32 => -- BGRA + Get_Byte(image.buffer, pix.color.blue); + Get_Byte(image.buffer, pix.color.green); + Get_Byte(image.buffer, pix.color.red); + Get_Byte(image.buffer, pix.alpha); + when 24 => -- BGR + Get_Byte(image.buffer, pix.color.blue); + Get_Byte(image.buffer, pix.color.green); + Get_Byte(image.buffer, pix.color.red); + when 16 | 15 => -- 5 bit per channel + Get_Byte(image.buffer, c); + Get_Byte(image.buffer, d); + Color_tables.Convert(c, d, pix.color); + if bpp=16 then + pix.alpha:= U8((U16(c and 128) * 255)/128); + end if; + when 8 => -- Gray + Get_Byte(image.buffer, pix.color.green); + pix.color.red:= pix.color.green; + pix.color.blue:= pix.color.green; + when others => + null; + end case; + end if; + end Get_pixel; + + generic + bpp: Positive; + pal: Boolean; + procedure RLE_Pixel; + pragma Inline(RLE_Pixel); + -- + procedure RLE_Pixel is + tmp: U8; + procedure Get_pixel_for_RLE is new Get_pixel(bpp, pal); + begin + if RLE_pixels_remaining = 0 then -- load RLE code + Get_Byte(image.buffer, tmp ); + Get_pixel_for_RLE; + RLE_pixels_remaining:= U8'Pos(tmp and 16#7F#); + is_run_packet:= (tmp and 16#80#) /= 0; + if is_run_packet then + pix_mem:= pix; + end if; + else + if is_run_packet then + pix:= pix_mem; + else + Get_pixel_for_RLE; + end if; + RLE_pixels_remaining:= RLE_pixels_remaining - 1; + end if; + end RLE_Pixel; + + procedure RLE_pixel_32 is new RLE_Pixel(32, False); + procedure RLE_pixel_24 is new RLE_Pixel(24, False); + procedure RLE_pixel_16 is new RLE_Pixel(16, False); + procedure RLE_pixel_15 is new RLE_Pixel(15, False); + procedure RLE_pixel_8 is new RLE_Pixel(8, False); + procedure RLE_pixel_palette is new RLE_Pixel(1, True); -- 1: dummy + + procedure Output_Pixel is + pragma Inline(Output_Pixel); + function Times_257(x: Primary_color_range) return Primary_color_range is + pragma Inline(Times_257); + begin + return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x + -- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8. + end Times_257; + begin + case Primary_color_range'Modulus is + when 256 => + Put_Pixel( + Primary_color_range(pix.color.red), + Primary_color_range(pix.color.green), + Primary_color_range(pix.color.blue), + Primary_color_range(pix.alpha) + ); + when 65_536 => + Put_Pixel( + Times_257(Primary_color_range(pix.color.red)), + Times_257(Primary_color_range(pix.color.green)), + Times_257(Primary_color_range(pix.color.blue)), + Times_257(Primary_color_range(pix.alpha)) + -- Times_257 makes max intensity FF go to FFFF + ); + when others => + raise invalid_primary_color_range with "TGA: color range not supported"; + end case; + end Output_Pixel; + + procedure Get_RGBA is -- 32 bits : R, G, B, A use 8 bits each. + procedure Get_pixel_32 is new Get_pixel(32, False); + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + Get_pixel_32; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_RGBA; + + procedure Get_RGB is -- 24 bits : R, G, B use 8 bits each. + procedure Get_pixel_24 is new Get_pixel(24, False); + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + Get_pixel_24; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_RGB; + + procedure Get_16 is -- 16 bits + procedure Get_pixel_16 is new Get_pixel(16, False); + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + Get_pixel_16; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_16; + + procedure Get_15 is -- 15 bits + procedure Get_pixel_15 is new Get_pixel(15, False); + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + Get_pixel_15; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_15; + + procedure Get_Gray is + procedure Get_pixel_8 is new Get_pixel(8, False); + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + Get_pixel_8; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_Gray; + + procedure Get_with_palette is + procedure Get_pixel_palette is new Get_pixel(1, True); -- 1: dummy + begin + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + for x in 0 .. Integer (image.width) - 1 loop + Get_pixel_palette; + Output_Pixel; + end loop; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + end Get_with_palette; + + begin + pix.alpha:= 255; -- opaque is default + Attach_Stream(image.buffer, image.stream); + -- + if image.RLE_encoded then + -- One format check per row + RLE_pixels_remaining:= 0; + for y in 0 .. Integer (image.height) - 1 loop + Row_start(y); + if image.palette /= null then + for x in 0 .. Integer (image.width) - 1 loop + RLE_pixel_palette; + Output_Pixel; + end loop; + else + case image.bits_per_pixel is + when 32 => + for x in 0..image.width-1 loop + RLE_pixel_32; + Output_Pixel; + end loop; + when 24 => + for x in 0..image.width-1 loop + RLE_pixel_24; + Output_Pixel; + end loop; + when 16 => + for x in 0..image.width-1 loop + RLE_pixel_16; + Output_Pixel; + end loop; + when 15 => + for x in 0..image.width-1 loop + RLE_pixel_15; + Output_Pixel; + end loop; + when 8 => + for x in 0..image.width-1 loop + RLE_pixel_8; + Output_Pixel; + end loop; + when others => null; + end case; + end if; + Feedback(((y+1)*100) / Integer (image.height)); + end loop; + elsif image.palette /= null then + Get_with_palette; + else + case image.bits_per_pixel is + when 32 => + Get_RGBA; + when 24 => + Get_RGB; + when 16 => + Get_16; + when 15 => + Get_15; + when 8 => + Get_Gray; + when others => null; + end case; + end if; + end Load; + +end GID.Decoding_TGA; diff --git a/deps/gid/gid-decoding_tga.ads b/deps/gid/gid-decoding_tga.ads new file mode 100644 index 00000000..b039bac2 --- /dev/null +++ b/deps/gid/gid-decoding_tga.ads @@ -0,0 +1,18 @@ +private package GID.Decoding_TGA is + + -------------------- + -- Image decoding -- + -------------------- + + generic + type Primary_color_range is mod <>; + with procedure Set_X_Y (x, y: Natural); + with procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ); + with procedure Feedback (percents: Natural); + -- + procedure Load (image: in out Image_descriptor); + +end GID.Decoding_TGA; diff --git a/deps/gid/gid-headers.adb b/deps/gid/gid-headers.adb new file mode 100644 index 00000000..a5550c62 --- /dev/null +++ b/deps/gid/gid-headers.adb @@ -0,0 +1,677 @@ +--------------------------------- +-- GID - Generic Image Decoder -- +--------------------------------- +-- +-- Private child of GID, with helpers for identifying +-- image formats and reading header informations. +-- + +with GID.Buffering, + GID.Color_tables, + GID.Decoding_JPG, + GID.Decoding_PNG, + GID.Decoding_PNM; + +with Ada.Unchecked_Deallocation; + +package body GID.Headers is + + ------------------------------------------------------- + -- The very first: read signature to identify format -- + ------------------------------------------------------- + + procedure Load_signature ( + image : in out Image_descriptor; + try_tga : Boolean:= False + + ) + is + use Bounded_255; + c: Character; + FITS_challenge : String(1..5); -- without the initial + GIF_challenge : String(1..5); -- without the initial + PNG_challenge : String(1..7); -- without the initial + PNG_signature : constant String:= "PNG" & ASCII.CR & ASCII.LF & ASCII.SUB & ASCII.LF; + PNM_challenge : Character; + TIFF_challenge : String(1..3); -- without the initial + TIFF_signature : String(1..2); + procedure Dispose is + new Ada.Unchecked_Deallocation(Color_table, p_Color_table); + begin + -- Some cleanup + Dispose(image.palette); + image.next_frame:= 0.0; + image.display_orientation:= Unchanged; + -- + Character'Read(image.stream, c); + image.first_byte:= Character'Pos(c); + case c is + when 'B' => + Character'Read(image.stream, c); + if c='M' then + image.detailed_format:= To_Bounded_String("BMP"); + image.format:= BMP; + return; + end if; + when 'S' => + String'Read(image.stream, FITS_challenge); + if FITS_challenge = "IMPLE" then + image.detailed_format:= To_Bounded_String("FITS"); + image.format:= FITS; + return; + end if; + when 'G' => + String'Read(image.stream, GIF_challenge); + if GIF_challenge = "IF87a" or GIF_challenge = "IF89a" then + image.detailed_format:= To_Bounded_String('G' & GIF_challenge & ", "); + image.format:= GIF; + return; + end if; + when 'I' | 'M' => + String'Read(image.stream, TIFF_challenge); + if c = TIFF_challenge(1) then + -- TIFF begins either with II (Intel) or MM (Motorola) - TIFF 6.0 Specification p.13 + if c = 'I' then + image.detailed_format:= To_Bounded_String("TIFF, little-endian"); + image.endianess:= little; + TIFF_signature:= '*' & ASCII.NUL; -- 42 (The Answer) on 16 bits + else + image.detailed_format:= To_Bounded_String("TIFF, big-endian"); + image.endianess:= big; + TIFF_signature:= ASCII.NUL & '*'; -- 42 (The Answer) on 16 bits + end if; + if TIFF_challenge(2..3) = TIFF_signature then + image.format:= TIFF; + return; + end if; + end if; + when Character'Val(16#FF#) => + Character'Read(image.stream, c); + if c=Character'Val(16#D8#) then + -- SOI (Start of Image) segment marker (FFD8) + image.detailed_format:= To_Bounded_String("JPEG"); + image.format:= JPEG; + return; + end if; + when Character'Val(16#89#) => + String'Read(image.stream, PNG_challenge); + if PNG_challenge = PNG_signature then + image.detailed_format:= To_Bounded_String("PNG"); + image.format:= PNG; + return; + end if; + when 'P' => + Character'Read(image.stream, PNM_challenge); + if PNM_challenge in '1'..'6' then + image.detailed_format:= To_Bounded_String("PNM (PBM, PGM or PPM)"); + image.format:= PNM; + image.subformat_id:= Integer'Value((1 => PNM_challenge)); + return; + end if; + + when others => + if try_tga then + image.detailed_format:= To_Bounded_String("TGA"); + image.format:= TGA; + return; + else + raise unknown_image_format; + end if; + end case; + raise unknown_image_format; + end Load_signature; + + -- Define reading of unsigned numbers from a byte stream + + -- Little-endian + generic + type Number is mod <>; + procedure Read_Intel_x86_number( + from : in Stream_Access; + n : out Number + ); + pragma Inline(Read_Intel_x86_number); + + generic + type Number is mod <>; + procedure Big_endian_number( + from : in Stream_Access; + n : out Number + ); + pragma Inline(Big_endian_number); + + generic + type Number is mod <>; + procedure Big_endian_number_buffered( + from : in out Input_buffer; + n : out Number + ); + pragma Inline(Big_endian_number_buffered); + + generic + type Number is mod <>; + procedure Read_any_endian_number( + from : in Stream_Access; + n : out Number; + endi : in Endianess_type + ); + pragma Inline(Read_any_endian_number); + + -- Implementations + + procedure Read_Intel_x86_number( + from : in Stream_Access; + n : out Number + ) + is + b: U8; + m: Number:= 1; + begin + n:= 0; + for i in 1..Number'Size/8 loop + U8'Read(from, b); + n:= n + m * Number(b); + m:= m * 256; + end loop; + end Read_Intel_x86_number; + + procedure Big_endian_number( + from : in Stream_Access; + n : out Number + ) + is + b: U8; + begin + n:= 0; + for i in 1..Number'Size/8 loop + U8'Read(from, b); + n:= n * 256 + Number(b); + end loop; + end Big_endian_number; + + procedure Big_endian_number_buffered( + from : in out Input_buffer; + n : out Number + ) + is + b: U8; + begin + n:= 0; + for i in 1..Number'Size/8 loop + Buffering.Get_Byte(from, b); + n:= n * 256 + Number(b); + end loop; + end Big_endian_number_buffered; + + procedure Read_any_endian_number( + from : in Stream_Access; + n : out Number; + endi : in Endianess_type + ) + is + procedure Read_Intel is new Read_Intel_x86_number(Number); + procedure Big_endian is new Big_endian_number(Number); + begin + case endi is + when little => Read_Intel(from, n); + when big => Big_endian(from, n); + end case; + end Read_any_endian_number; + + -- Instantiations + + procedure Read_Intel is new Read_Intel_x86_number( U16 ); + procedure Read_Intel is new Read_Intel_x86_number( U32 ); + procedure Big_endian_buffered is new Big_endian_number_buffered( U32 ); + procedure Read_any_endian is new Read_any_endian_number( U32 ); + + ---------------------------------------------------------- + -- Loading of various format's headers (past signature) -- + ---------------------------------------------------------- + + ---------------- + -- BMP header -- + ---------------- + + procedure Load_BMP_header (image: in out Image_descriptor) is + n, dummy: U32; + pragma Warnings(off, dummy); + w, dummy16: U16; + pragma Warnings(off, dummy16); + begin + -- Pos= 3, read the file size + Read_Intel(image.stream, dummy); + -- Pos= 7, read four bytes, unknown + Read_Intel(image.stream, dummy); + -- Pos= 11, read four bytes offset, file top to bitmap data. + -- For 256 colors, this is usually 36 04 00 00 + Read_Intel(image.stream, dummy); + -- Pos= 15. The beginning of Bitmap information header. + -- Data expected: 28H, denoting 40 byte header + Read_Intel(image.stream, dummy); + -- Pos= 19. Bitmap width, in pixels. Four bytes + Read_Intel(image.stream, n); + image.width:= Positive_32 (n); + -- Pos= 23. Bitmap height, in pixels. Four bytes + Read_Intel(image.stream, n); + image.height:= Positive_32 (n); + -- Pos= 27, skip two bytes. Data is number of Bitmap planes. + Read_Intel(image.stream, dummy16); -- perform the skip + -- Pos= 29, Number of bits per pixel + -- Value 8, denoting 256 color, is expected + Read_Intel(image.stream, w); + case w is + when 1 | 4 | 8 | 24 => + null; + when others => + raise unsupported_image_subformat with "BMP bit depth =" & U16'Image(w); + end case; + image.bits_per_pixel:= Integer(w); + -- Pos= 31, read four bytes + Read_Intel(image.stream, n); -- Type of compression used + -- BI_RLE8 = 1 + -- BI_RLE4 = 2 + if n /= 0 then + raise unsupported_image_subformat with "BMP: RLE compression"; + end if; + -- + Read_Intel(image.stream, dummy); -- Pos= 35, image size + Read_Intel(image.stream, dummy); -- Pos= 39, horizontal resolution + Read_Intel(image.stream, dummy); -- Pos= 43, vertical resolution + Read_Intel(image.stream, n); -- Pos= 47, number of palette colors + if image.bits_per_pixel <= 8 then + if n = 0 then + image.palette:= new Color_table(0..2**image.bits_per_pixel-1); + else + image.palette:= new Color_table(0..Natural(n)-1); + end if; + end if; + Read_Intel(image.stream, dummy); -- Pos= 51, number of important colors + -- Pos= 55 (36H), - start of palette + Color_tables.Load_palette(image); + end Load_BMP_header; + + procedure Load_FITS_header (image: in out Image_descriptor) is + begin + raise known_but_unsupported_image_format; + end Load_FITS_header; + + ---------------- + -- GIF header -- + ---------------- + + procedure Load_GIF_header (image: in out Image_descriptor) is + -- GIF - logical screen descriptor + screen_width, screen_height : U16; + packed, background, aspect_ratio_code : U8; + global_palette: Boolean; + begin + Read_Intel(image.stream, screen_width); + Read_Intel(image.stream, screen_height); + if screen_width = 0 then + raise error_in_image_data with "GIF image: zero width"; + end if; + if screen_height = 0 then + raise error_in_image_data with "GIF image: zero height"; + end if; + image.width:= Positive_32 (screen_width); + image.height:= Positive_32 (screen_height); + image.transparency:= True; -- cannot exclude transparency at this level. + U8'Read(image.stream, packed); + -- Global Color Table Flag 1 Bit + -- Color Resolution 3 Bits + -- Sort Flag 1 Bit + -- Size of Global Color Table 3 Bits + global_palette:= (packed and 16#80#) /= 0; + image.bits_per_pixel:= Natural((packed and 16#7F#)/16#10#) + 1; + -- Indicative: + -- iv) [...] This value should be set to indicate the + -- richness of the original palette + U8'Read(image.stream, background); + U8'Read(image.stream, aspect_ratio_code); + Buffering.Attach_Stream(image.buffer, image.stream); + if global_palette then + image.subformat_id:= 1+(Natural(packed and 16#07#)); + -- palette's bits per pixels, usually <= image's + -- + -- if image.subformat_id > image.bits_per_pixel then + -- raise + -- error_in_image_data with + -- "GIF: global palette has more colors than the image" & + -- image.subformat_id'img & image.bits_per_pixel'img; + -- end if; + image.palette:= new Color_table(0..2**(image.subformat_id)-1); + Color_tables.Load_palette(image); + end if; + end Load_GIF_header; + + ----------------- + -- JPEG header -- + ----------------- + + procedure Load_JPEG_header (image: in out Image_descriptor) is + -- http://en.wikipedia.org/wiki/JPEG + use GID.Decoding_JPG, GID.Buffering; + sh: Segment_head; + b: U8; + begin + -- We have already passed the SOI (Start of Image) segment marker (FFD8). + image.JPEG_stuff.restart_interval:= 0; + Attach_Stream(image.buffer, image.stream); + loop + Read(image, sh); + case sh.kind is + when DHT => -- Huffman Table + Read_DHT(image, Natural(sh.length)); + when DQT => + Read_DQT(image, Natural(sh.length)); + when DRI => -- Restart Interval + Read_DRI(image); + when SOF_0 .. SOF_15 => + Read_SOF(image, sh); + exit; -- we've got header-style informations, then it's time to quit + when APP_1 => + Read_EXIF(image, Natural(sh.length)); + when others => + -- Skip segment data + for i in 1..sh.length loop + Get_Byte(image.buffer, b); + end loop; + end case; + end loop; + end Load_JPEG_header; + + ---------------- + -- PNG header -- + ---------------- + + procedure Load_PNG_header (image: in out Image_descriptor) is + use Decoding_PNG, Buffering; + ch: Chunk_head; + n, dummy: U32; + pragma Warnings(off, dummy); + b, color_type: U8; + palette: Boolean:= False; + begin + Buffering.Attach_Stream(image.buffer, image.stream); + Read(image, ch); + if ch.kind /= IHDR then + raise error_in_image_data with "PNG: expected 'IHDR' chunk as first chunk in PNG stream"; + end if; + Big_endian_buffered(image.buffer, n); + if n = 0 then + raise error_in_image_data with "PNG image with zero width"; + end if; + if n > U32 (Positive_32'Last) then + raise error_in_image_data with "PNG image: width value too large:" & U32'Image (n); + end if; + image.width:= Positive_32 (n); + Big_endian_buffered(image.buffer, n); + if n = 0 then + raise error_in_image_data with "PNG image with zero height"; + end if; + if n > U32 (Positive_32'Last) then + raise error_in_image_data with "PNG image: height value too large:" & U32'Image (n); + end if; + image.height:= Positive_32 (n); + Get_Byte(image.buffer, b); + if b = 0 then + raise error_in_image_data with "PNG image: zero bit-per-pixel"; + end if; + image.bits_per_pixel:= Integer(b); + Get_Byte(image.buffer, color_type); + image.subformat_id:= Integer(color_type); + case color_type is + when 0 => -- Greyscale + image.greyscale:= True; + case image.bits_per_pixel is + when 1 | 2 | 4 | 8 | 16 => + null; + when others => + raise error_in_image_data with + "PNG, type 0 (greyscale): wrong bit-per-channel depth"; + end case; + when 2 => -- RGB TrueColor + case image.bits_per_pixel is + when 8 | 16 => + image.bits_per_pixel:= 3 * image.bits_per_pixel; + when others => + raise error_in_image_data with + "PNG, type 2 (RGB): wrong bit-per-channel depth"; + end case; + when 3 => -- RGB with palette + palette:= True; + case image.bits_per_pixel is + when 1 | 2 | 4 | 8 => + null; + when others => + raise error_in_image_data with + "PNG, type 3: wrong bit-per-channel depth"; + end case; + when 4 => -- Grey & Alpha + image.greyscale:= True; + image.transparency:= True; + case image.bits_per_pixel is + when 8 | 16 => + image.bits_per_pixel:= 2 * image.bits_per_pixel; + when others => + raise error_in_image_data with + "PNG, type 4 (Greyscale & Alpha): wrong bit-per-channel depth"; + end case; + when 6 => -- RGBA + image.transparency:= True; + case image.bits_per_pixel is + when 8 | 16 => + image.bits_per_pixel:= 4 * image.bits_per_pixel; + when others => + raise error_in_image_data with + "PNG, type 6 (RGBA): wrong bit-per-channel depth"; + end case; + when others => + raise error_in_image_data with "PNG: unknown color type"; + end case; + Get_Byte(image.buffer, b); + if b /= 0 then + raise error_in_image_data with + "PNG: unknown compression format; ISO/IEC 15948:2003" & + " knows only 'method 0' (Deflate)"; + end if; + Get_Byte(image.buffer, b); + if b /= 0 then + raise error_in_image_data with + "PNG: unknown filtering; ISO/IEC 15948:2003 knows only 'method 0'"; + end if; + Get_Byte(image.buffer, b); + image.interlaced:= b = 1; -- Adam7 + Big_endian_buffered(image.buffer, dummy); -- Chunk's CRC + if palette then + loop + Read(image, ch); + case ch.kind is + when IEND => + raise error_in_image_data with + "PNG: a palette (PLTE) is expected here, found IEND"; + when PLTE => + if ch.length rem 3 /= 0 then + raise error_in_image_data with + "PNG: palette chunk byte length must be a multiple of 3"; + end if; + image.palette:= new Color_table(0..Integer(ch.length/3)-1); + Color_tables.Load_palette(image); + Big_endian_buffered(image.buffer, dummy); -- Chunk's CRC + exit; + when others => + -- Skip chunk data and CRC + for i in 1..ch.length + 4 loop + Get_Byte(image.buffer, b); + end loop; + end case; + end loop; + end if; + end Load_PNG_header; + + -------------------------------- + -- PNM (PBM, PGM, PPM) header -- + -------------------------------- + + procedure Load_PNM_header (image: in out Image_descriptor) is + use Decoding_PNM; + depth_val: Integer; + begin + image.width := Get_Positive_32 (image.stream); + case image.subformat_id is + when 1 | 4 => + image.height := Get_Positive_32 (image.stream, needs_EOL => True); + image.greyscale:= True; + image.bits_per_pixel:= 3; + when 2..3 | 5..6 => + image.height := Get_Positive_32 (image.stream); + depth_val := Get_Integer(image.stream, needs_EOL => True); + if depth_val /= 255 then + raise unsupported_image_subformat with + "PNM: maximum depth value" & Integer'Image(depth_val) & + "; only 255 is supported"; + end if; + image.greyscale:= image.subformat_id = 2 or image.subformat_id = 5; + image.bits_per_pixel:= 24; + when others => + raise unsupported_image_subformat with + "PNM: P" & Integer'Image(image.subformat_id) & " not supported"; + end case; + exception + when Constraint_Error => + raise error_in_image_data with "PNM: invalid numeric value in PNM header"; + end Load_PNM_header; + + ------------------------ + -- TGA (Targa) header -- + ------------------------ + + procedure Load_TGA_header (image: in out Image_descriptor) is + -- TGA FILE HEADER, p.6 + -- + image_ID_length: U8; -- Field 1 + color_map_type : U8; -- Field 2 + image_type : U8; -- Field 3 + -- Color Map Specification - Field 4 + first_entry_index : U16; -- Field 4.1 + color_map_length : U16; -- Field 4.2 + color_map_entry_size: U8; -- Field 4.3 + -- Image Specification - Field 5 + x_origin: U16; + y_origin: U16; + image_width: U16; + image_height: U16; + pixel_depth: U8; + tga_image_descriptor: U8; + -- + dummy: U8; + base_image_type: Integer; + begin + -- Read the header + image_ID_length:= image.first_byte; + U8'Read(image.stream, color_map_type); + U8'Read(image.stream, image_type); + -- Color Map Specification - Field 4 + Read_Intel(image.stream, first_entry_index); + Read_Intel(image.stream, color_map_length); + U8'Read(image.stream, color_map_entry_size); + -- Image Specification - Field 5 + Read_Intel(image.stream, x_origin); + Read_Intel(image.stream, y_origin); + Read_Intel(image.stream, image_width); + Read_Intel(image.stream, image_height); + U8'Read(image.stream, pixel_depth); + U8'Read(image.stream, tga_image_descriptor); + -- Done. + -- + -- Image type: + -- 1 = 8-bit palette style + -- 2 = Direct [A]RGB image + -- 3 = grayscale + -- 9 = RLE version of Type 1 + -- 10 = RLE version of Type 2 + -- 11 = RLE version of Type 3 + -- + base_image_type:= U8'Pos(image_type and 7); + image.RLE_encoded:= (image_type and 8) /= 0; + -- + if color_map_type /= 0 then + image.palette:= new Color_table( + Integer(first_entry_index).. + Integer(first_entry_index)+Integer(color_map_length)-1 + ); + image.subformat_id:= Integer(color_map_entry_size); + case image.subformat_id is -- = palette's bit depth + when 8 => -- Grey + null; + when 15 => -- RGB 3*5 bit + null; + when 16 => -- RGBA 3*5+1 bit + image.transparency:= True; + when 24 => -- RGB 3*8 bit + null; + when 32 => -- RGBA 4*8 bit + image.transparency:= True; + when others => + raise error_in_image_data with + "TGA color map (palette): wrong bit depth:" & + Integer'Image(image.subformat_id); + end case; + end if; + -- + image.greyscale:= False; -- ev. overridden later + case base_image_type is + when 1 => + image.greyscale:= color_map_entry_size = 8; + when 2 => + null; + when 3 => + image.greyscale:= True; + when others => + raise unsupported_image_subformat with + "TGA type =" & Integer'Image(base_image_type); + end case; + + image.width := U16'Pos(image_width); + image.height := U16'Pos(image_height); + image.bits_per_pixel := U8'Pos(pixel_depth); + + -- Make sure we are loading a supported TGA_type + case image.bits_per_pixel is + when 24 | 15 | 8 => + null; + when 32 | 16 => + image.transparency:= True; + when others => + raise unsupported_image_subformat with + "TGA bits per pixels =" & Integer'Image(image.bits_per_pixel) & + "; supported bpp are: 8, 15, 16, 24, 32"; + end case; + image.top_first:= (tga_image_descriptor and 32) /= 0; + -- *** Image and color map data + -- * Image ID + for i in 1..image_ID_length loop + U8'Read( image.stream, dummy ); + end loop; + -- * Color map data (palette) + Color_tables.Load_palette(image); + -- * Image data: Read by Load_image_contents. + end Load_TGA_header; + + procedure Load_TIFF_header (image: in out Image_descriptor) is + first_IFD_offset: U32; + -- + -- IFD: Image File Directory. Basically, the image header. + -- Issue with TIFF: often the image header is stored after the image data. + -- This would need streams with Set_Index instead of a general stream + -- (e.g. a file, not an HTTP stream), or to store the full image data + -- in a temp buffer. Perhaps we'll do that one day. + begin + Read_any_endian(image.stream, first_IFD_offset, image.endianess); + raise known_but_unsupported_image_format with + "TIFF is not appropriate for streaming. Use PNG, BMP (lossless) or JPEG instead." & + "Info: IFD Offset=" & U32'Image(first_IFD_offset); + end Load_TIFF_header; + +end GID.Headers; diff --git a/deps/gid/gid-headers.ads b/deps/gid/gid-headers.ads new file mode 100644 index 00000000..416ce6f8 --- /dev/null +++ b/deps/gid/gid-headers.ads @@ -0,0 +1,31 @@ +--------------------------------- +-- GID - Generic Image Decoder -- +--------------------------------- +-- +-- Private child of GID, with helpers for identifying +-- image formats and reading header informations. +-- +private package GID.Headers is + + -- + -- Crude image signature detection + -- + procedure Load_signature ( + image : in out Image_descriptor; + try_tga : Boolean:= False + ); + + -- + -- Loading of various format's headers (past signature) + -- + + procedure Load_BMP_header (image: in out Image_descriptor); + procedure Load_FITS_header (image: in out Image_descriptor); + procedure Load_GIF_header (image: in out Image_descriptor); + procedure Load_JPEG_header (image: in out Image_descriptor); + procedure Load_PNG_header (image: in out Image_descriptor); + procedure Load_PNM_header (image: in out Image_descriptor); + procedure Load_TGA_header (image: in out Image_descriptor); + procedure Load_TIFF_header (image: in out Image_descriptor); + +end GID.Headers; diff --git a/deps/gid/gid.adb b/deps/gid/gid.adb new file mode 100644 index 00000000..5770cea3 --- /dev/null +++ b/deps/gid/gid.adb @@ -0,0 +1,248 @@ +--------------------------------- +-- GID - Generic Image Decoder -- +--------------------------------- +-- +-- Copyright (c) Gautier de Montmollin 2010 .. 2019 +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- +-- NB: this is the MIT License, as found 2-May-2010 on the site +-- http://www.opensource.org/licenses/mit-license.php + +with GID.Headers, + GID.Decoding_BMP, + GID.Decoding_GIF, + GID.Decoding_JPG, + GID.Decoding_PNG, + GID.Decoding_PNM, + GID.Decoding_TGA; + +with Ada.Unchecked_Deallocation; + +package body GID is + + -- Internal: a few header items (palette, some large JPEG tables) + -- are heap allocated; we need to release them upon finalization + -- or descriptor reuse. + + procedure Clear_heap_allocated_memory (Object : in out Image_descriptor) is + procedure Dispose is + new Ada.Unchecked_Deallocation(Color_table, p_Color_table); + procedure Dispose is + new Ada.Unchecked_Deallocation( + JPEG_defs.VLC_table, + JPEG_defs.p_VLC_table + ); + begin + -- Deterministic garbage collection of heap allocated objects. + -- -> Palette + Dispose (Object.palette); + -- -> JPEG tables + for ad in JPEG_defs.VLC_defs_type'Range(1) loop + for idx in JPEG_defs.VLC_defs_type'Range(2) loop + Dispose (Object.JPEG_stuff.vlc_defs (ad, idx)); + end loop; + end loop; + end Clear_heap_allocated_memory; + + ----------------------- + -- Load_image_header -- + ----------------------- + + procedure Load_image_header ( + image : out Image_descriptor; + from : in out Ada.Streams.Root_Stream_Type'Class; + try_tga : Boolean:= False + ) + is + begin + Clear_heap_allocated_memory (image); + image.stream:= from'Unchecked_Access; + -- + -- Load the very first symbols of the header, + -- this identifies the image format. + -- + Headers.Load_signature(image, try_tga); + -- + case image.format is + when BMP => + Headers.Load_BMP_header(image); + when FITS => + Headers.Load_FITS_header(image); + when GIF => + Headers.Load_GIF_header(image); + when JPEG => + Headers.Load_JPEG_header(image); + when PNG => + Headers.Load_PNG_header(image); + when PNM => + Headers.Load_PNM_header(image); + when TGA => + Headers.Load_TGA_header(image); + when TIFF => + Headers.Load_TIFF_header(image); + end case; + end Load_image_header; + + ----------------- + -- Pixel_width -- + ----------------- + + function Pixel_width (image: Image_descriptor) return Positive is + begin + return Positive (image.width); + end Pixel_width; + + ------------------ + -- Pixel_height -- + ------------------ + + function Pixel_height (image: Image_descriptor) return Positive is + begin + return Positive (image.height); + end Pixel_height; + + function Display_orientation (image: Image_descriptor) return Orientation is + begin + return image.display_orientation; + end Display_orientation; + + ------------------------- + -- Load_image_contents -- + ------------------------- + + procedure Load_image_contents ( + image : in out Image_descriptor; + next_frame: out Ada.Calendar.Day_Duration + ) + is + procedure BMP_Load is + new Decoding_BMP.Load( Primary_color_range, Set_X_Y, Put_Pixel, Feedback ); + + procedure GIF_Load is + new Decoding_GIF.Load( Primary_color_range, Set_X_Y, Put_Pixel, Feedback, mode ); + + procedure JPG_Load is + new Decoding_JPG.Load( Primary_color_range, Set_X_Y, Put_Pixel, Feedback ); + + procedure PNG_Load is + new Decoding_PNG.Load( Primary_color_range, Set_X_Y, Put_Pixel, Feedback ); + + procedure PNM_Load is + new Decoding_PNM.Load( Primary_color_range, Set_X_Y, Put_Pixel, Feedback ); + + procedure TGA_Load is + new Decoding_TGA.Load( Primary_color_range, Set_X_Y, Put_Pixel, Feedback ); + + begin + next_frame:= 0.0; + -- ^ value updated in case of animation and when + -- current frame is not the last frame + case image.format is + when BMP => + BMP_Load(image); + when GIF => + GIF_Load(image, next_frame); + when JPEG => + JPG_Load(image, next_frame); + when PNG => + PNG_Load(image); + when PNM => + PNM_Load(image); + when TGA => + TGA_Load(image); + when others => + raise known_but_unsupported_image_format; + end case; + end Load_image_contents; + + --------------------------------------- + -- Some informations about the image -- + --------------------------------------- + + function Format (image: Image_descriptor) return Image_format_type is + begin + return image.format; + end Format; + + function Detailed_format (image: Image_descriptor) return String is + begin + return Bounded_255.To_String(image.detailed_format); + end Detailed_format; + + function Subformat (image: Image_descriptor) return Integer is + begin + return image.subformat_id; + end Subformat; + + function Bits_per_pixel (image: Image_descriptor) return Positive is + begin + return image.bits_per_pixel; + end Bits_per_pixel; + + function RLE_encoded (image: Image_descriptor) return Boolean is + begin + return image.RLE_encoded; + end RLE_encoded; + + function Interlaced (image: Image_descriptor) return Boolean is + begin + return image.interlaced; + end Interlaced; + + function Greyscale (image: Image_descriptor) return Boolean is + begin + return image.greyscale; + end Greyscale; + + function Has_palette (image: Image_descriptor) return Boolean is + begin + return image.palette /= null; + end Has_palette; + + function Expect_transparency (image: Image_descriptor) return Boolean is + begin + return image.transparency; + end Expect_transparency; + + overriding procedure Adjust (Object : in out Image_descriptor) is + use JPEG_defs; + begin + -- Clone heap allocated objects, if any. + -- -> Palette + if Object.palette /= null then + Object.palette := new Color_table'(Object.palette.all); + end if; + -- -> JPEG tables + for ad in JPEG_defs.VLC_defs_type'Range(1) loop + for idx in JPEG_defs.VLC_defs_type'Range(2) loop + if Object.JPEG_stuff.vlc_defs (ad, idx) /= null then + Object.JPEG_stuff.vlc_defs (ad, idx) := + new VLC_table'(Object.JPEG_stuff.vlc_defs (ad, idx).all); + end if; + end loop; + end loop; + end Adjust; + + overriding procedure Finalize (Object : in out Image_descriptor) is + begin + Clear_heap_allocated_memory (Object); + end Finalize; + +end GID; diff --git a/deps/gid/gid.ads b/deps/gid/gid.ads new file mode 100644 index 00000000..52fc1845 --- /dev/null +++ b/deps/gid/gid.ads @@ -0,0 +1,323 @@ +--------------------------------- +-- GID - Generic Image Decoder -- +--------------------------------- +-- +-- Purpose: +-- +-- The Generic Image Decoder is a package for decoding a broad +-- variety of image formats, from any data stream, to any kind +-- of medium, be it an in-memory bitmap, a GUI object, +-- some other stream, arrays of floating-point initial data +-- for scientific calculations, a browser element, a device,... +-- Animations are supported. +-- +-- The code is unconditionally portable, independent of the +-- choice of operating system, processor, endianess and compiler. +-- +-- Image types currently supported: +-- +-- BMP, GIF, JPEG, PNG, PNM, TGA +-- +-- Credits: +-- +-- - André van Splunter: GIF's LZW decoder in Ada +-- - Martin J. Fiedler: most of the JPEG decoder (from NanoJPEG) +-- +-- More credits in gid_work.xls, sheet "credits". +-- +-- Copyright (c) Gautier de Montmollin 2010 .. 2019 +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- +-- NB: this is the MIT License, as found 2-May-2010 on the site +-- http://www.opensource.org/licenses/mit-license.php + +with Ada.Calendar, Ada.Streams, Ada.Strings.Bounded, Ada.Finalization; +with Interfaces; +with System; + +package GID is + + type Image_descriptor is private; + + --------------------------------------------------- + -- 1) Load the image header from the data stream -- + --------------------------------------------------- + + procedure Load_image_header ( + image : out Image_descriptor; + from : in out Ada.Streams.Root_Stream_Type'Class; + try_tga : Boolean:= False + ); + + -- try_tga: if no known signature is found, assume it might be + -- the TGA format (which hasn't a signature) and try to load an + -- image of this format + + unknown_image_format, + known_but_unsupported_image_format, + unsupported_image_subformat, + error_in_image_data, + invalid_primary_color_range: exception; + + ---------------------------------------------------------------------- + -- 2) If needed, use dimensions to prepare the retrieval of the -- + -- image, for instance: reserving an in-memory bitmap, sizing a -- + -- GUI object, defining a browser element, setting up a device -- + ---------------------------------------------------------------------- + + function Pixel_width (image: Image_descriptor) return Positive; + function Pixel_height (image: Image_descriptor) return Positive; + + -- "Unchanged" orientation has origin at top left + + type Orientation is ( + Unchanged, + Rotation_90, Rotation_180, Rotation_270 + ); + + function Display_orientation (image: Image_descriptor) return Orientation; + + -------------------------------------------------------------------- + -- 3) Load and decode the image itself. If the image is animated, -- + -- call Load_image_contents until next_frame is 0.0 -- + -------------------------------------------------------------------- + + type Display_mode is (fast, nice); + -- For bitmap pictures, the result is exactly the same, but + -- interlaced images' larger pixels are drawn in full during decoding. + + generic + type Primary_color_range is mod <>; + -- Coding of primary colors (red, green or blue) + -- and of opacity (also known as alpha channel), on the target "device". + -- Currently, only 8-bit and 16-bit are admitted. + -- 8-bit coding is usual: TrueColor, PC graphics, etc.; + -- 16-bit coding is seen in some high-end apps/devices/formats. + -- + with procedure Set_X_Y (x, y: Natural); + -- After Set_X_Y, next pixel is meant to be displayed at position (x,y) + with procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ); + -- When Put_Pixel is called twice without a Set_X_Y inbetween, + -- the pixel must be displayed on the next X position after the last one. + -- [ Rationale: if the image lands into an array with contiguous pixels + -- on the X axis, this approach allows full address calculation to be + -- made only at the beginning of each row, which is much faster ] + -- + with procedure Feedback (percents: Natural); + -- + mode: Display_mode; + -- + procedure Load_image_contents ( + image : in out Image_descriptor; + next_frame: out Ada.Calendar.Day_Duration + -- ^ animation: real time lapse foreseen between the first image + -- and the image right after this one; 0.0 if no next frame + ); + + ------------------------------------------------------------------- + -- Some informations about the image, not necessary for decoding -- + ------------------------------------------------------------------- + + type Image_format_type is + ( -- Bitmap formats + BMP, FITS, GIF, JPEG, PNG, PNM, TGA, TIFF + ); + + function Format (image: Image_descriptor) return Image_format_type; + function Detailed_format (image: Image_descriptor) return String; + -- example: "GIF89a, interlaced" + function Subformat (image: Image_descriptor) return Integer; + -- example the 'color type' in PNG + + function Bits_per_pixel (image: Image_descriptor) return Positive; + function RLE_encoded (image: Image_descriptor) return Boolean; + function Interlaced (image: Image_descriptor) return Boolean; + function Greyscale (image: Image_descriptor) return Boolean; + function Has_palette (image: Image_descriptor) return Boolean; + function Expect_transparency (image: Image_descriptor) return Boolean; + + ---------------------------------------------------------------- + -- Information about this package - e.g. for an "about" box -- + ---------------------------------------------------------------- + + version : constant String:= "009"; + reference : constant String:= "03-Sep-2019"; + web: constant String:= "http://gen-img-dec.sf.net/"; + -- Hopefully the latest version is at that URL..^ + +private + + use Interfaces; + + subtype U8 is Unsigned_8; + subtype U16 is Unsigned_16; + subtype U32 is Unsigned_32; + + package Bounded_255 is + new Ada.Strings.Bounded.Generic_Bounded_Length(255); + + type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; + + type RGB_color is record + red, green, blue : U8; + end record; + + type Color_table is array (Integer range <>) of RGB_color; + + type p_Color_table is access Color_table; + + min_bits: constant:= Integer'Max(32, System.Word_Size); + -- 13.3(8): A word is the largest amount of storage that can be + -- conveniently and efficiently manipulated by the hardware, + -- given the implementation's run-time model. + + type Integer_M32 is range -2**(min_bits-1) .. 2**(min_bits-1) - 1; + -- We define an Integer type which is at least 32 bits, but n bits + -- on a native n > 32 bits architecture (no performance hit on 64+ + -- bits architectures). + + subtype Natural_M32 is Integer_M32 range 0..Integer_M32'Last; + subtype Positive_M32 is Integer_M32 range 1..Integer_M32'Last; + + type Byte_array is array(Integer range <>) of U8; + + type Input_buffer is record + data : Byte_array(1..1024); + stream : Stream_Access:= null; + InBufIdx : Positive:= 1; -- Points to next char in buffer to be read + MaxInBufIdx: Natural := 0; -- Count of valid chars in input buffer + InputEoF : Boolean; -- End of file indicator + end record; + -- Initial values ensure call to Fill_Buffer on first Get_Byte + + -- JPEG may store data _before_ any image header (SOF), then we have + -- to make the image descriptor store that information, alas... + + package JPEG_defs is + + type Component is + (Y, -- brightness + Cb, -- hue + Cr, -- saturation + I, -- ?? + Q -- ?? + ); + + type QT is array(0..63) of Natural; + type QT_list is array(0..7) of QT; + + type Compo_set is array(Component) of Boolean; + + type Info_per_component_A is record -- B is defined inside the decoder + qt_assoc : Natural; + samples_hor : Natural; + samples_ver : Natural; + up_factor_x : Natural; -- how much we must repeat horizontally + up_factor_y : Natural; -- how much we must repeat vertically + shift_x : Natural; -- shift for repeating pixels horizontally + shift_y : Natural; -- shift for repeating pixels vertically + end record; + + type Component_info_A is array(Component) of Info_per_component_A; + + type Supported_color_space is ( + YCbCr, -- 3-dim color space + Y_Grey, -- 1-dim greyscale + CMYK -- 4-dim Cyan, Magenta, Yellow, blacK + ); + + type AC_DC is (AC, DC); + + type VLC_code is record + bits, code: U8; + end record; + + type VLC_table is array(0..65_535) of VLC_code; + + type p_VLC_table is access VLC_table; + + type VLC_defs_type is array(AC_DC, 0..7) of p_VLC_table; + + end JPEG_defs; + + type JPEG_stuff_type is record + components : JPEG_defs.Compo_set:= (others => False); + color_space : JPEG_defs.Supported_color_space; + info : JPEG_defs.Component_info_A; + max_samples_hor : Natural; + max_samples_ver : Natural; + qt_list : JPEG_defs.QT_list; + vlc_defs : JPEG_defs.VLC_defs_type:= (others => (others => null)); + restart_interval : Natural; -- predictor restarts every... (0: never) + end record; + + type Endianess_type is (little, big); -- for TIFF images + + subtype Positive_32 is Interfaces.Integer_32 range 1 .. Interfaces.Integer_32'Last; + + type Image_descriptor is new Ada.Finalization.Controlled with record + format : Image_format_type; + detailed_format : Bounded_255.Bounded_String; -- for humans only! + subformat_id : Integer:= 0; + width, height : Positive_32; + display_orientation: Orientation; + top_first : Boolean; -- data orientation in TGA + bits_per_pixel : Positive; + RLE_encoded : Boolean:= False; + transparency : Boolean:= False; + greyscale : Boolean:= False; + interlaced : Boolean:= False; -- GIF or PNG + endianess : Endianess_type; -- TIFF + JPEG_stuff : JPEG_stuff_type; + stream : Stream_Access; + buffer : Input_buffer; + palette : p_Color_table:= null; + first_byte : U8; + next_frame : Ada.Calendar.Day_Duration; + end record; + + overriding procedure Adjust (Object : in out Image_descriptor); + overriding procedure Finalize (Object : in out Image_descriptor); + + to_be_done: exception; + -- this exception should not happen, even with malformed files + -- its role is to pop up when a feature is set as implemented + -- but one aspect (e.g. palette) was forgotten. + + -- + -- Primitive tracing using Ada.Text_IO, for debugging, + -- or explaining internals. + -- + type Trace_type is ( + none, -- No trace at all, no use of console from the library + some_t, -- Image / frame technical informations + full -- Byte / pixel / compressed block details + ); + + trace: constant Trace_type:= none; -- <== Choice here + + no_trace : constant Boolean:= trace=none; + full_trace: constant Boolean:= trace=full; + some_trace: constant Boolean:= trace>=some_t; + +end GID; diff --git a/deps/gid/gid.gpr b/deps/gid/gid.gpr new file mode 100644 index 00000000..784500ef --- /dev/null +++ b/deps/gid/gid.gpr @@ -0,0 +1,41 @@ +-- This file has been modified for OpenGLAda to be a library project and +-- exclude the tests. +-- +-- Build_Mode has been removed and the compiler configuration originally given +-- for Build_Mode == "Fast" is used. +-------------------------------------------------------------------------------- +-- +-- This is a GNAT, GCC or GNAT Programming Studio (GPS) project file +-- for the Generic Image Decoder project: +-- +-- home page: http://gen-img-dec.sf.net/ +-- project page: http://sf.net/projects/gen-img-dec/ +-- mirror: https://github.com/svn2github/gid +-- +-- Build me with "gprbuild -p -P gid", or "gnatmake -p -P gid", +-- or open me with GPS. +-- +library project GID is + for Source_Dirs use ("."); + for Object_Dir use "obj"; + for Library_Dir use "lib"; + for Library_Name use "GID"; + + package Compiler is + for Default_Switches ("ada") use ("-O2", "-gnatpn", "-ffunction-sections", + "-funroll-loops", "-fpeel-loops", "-ftracer", "-funswitch-loops", + "-fweb", "-frename-registers", "-ftree-vectorize", "-fipa-cp-clone", + "-fgcse-after-reload"); + end Compiler; + + package Binder is + -- -Es: Store tracebacks in exception occurrences, and enable symbolic tracebacks + for Default_Switches ("ada") use ("-Es"); + end Binder; + + package Builder is + -- "If -j0 is used, then the maximum number of simultaneous compilation + -- jobs is the number of core processors on the platform." + for Default_Switches ("ada") use ("-j0"); + end Builder; +end GID; diff --git a/deps/gid/gid.txt b/deps/gid/gid.txt new file mode 100644 index 00000000..12c3124a --- /dev/null +++ b/deps/gid/gid.txt @@ -0,0 +1,193 @@ +GID - the Generic Image Decoder +=============================== + +The Generic Image Decoder (GID) is an Ada package for decoding a +broad variety of image formats, from any data stream, to any kind +of medium, be it an in-memory bitmap, a GUI object, +some other stream, arrays of floating-point initial data +for scientific calculations, a browser element, a device,... + +Animations are supported. + +Some features: + + - Standalone (no dependency on other libraires, bindings,...) + - Unconditionally portable code: OS-, CPU-, compiler- independent code. + - Multi-platform, but native code + - Task safe + - Endian-neutral + - Free, open-source + - pure Ada 2005 (compiled by Ada 2005, and compilers for later versions) + +Some existing or possible applications: + + - image processing (interactive or not) + - image analysis, text recognition + - a drawing program + - a web browser + - use of images as data for simulations + - thumbnail generation for a file manager + +Through the genericity and the use of the Inline pragma at multiple +nesting levels (see it like macros inside macros), the package is +able to deliver a decent decoding performance, keep a reasonably +compact and readable source code, and avoid tediously copied +pieces of code with almost the same contents corresponding to +different subformats. + +Licensing, warranty, copyright, supported formats, authors, credits, history +============================================================================ + +There is NO WARRANTY in the GID software. +GID is licensed under the MIT License. +You find the full license and copyright notice in gid.ads. +Further details (especially, credits and history) can be found in gid_work.xls. + +Files +===== + gid.ads GID package specification + gid.adb GID package body + gid-*.ad* private packages for decoding specific + formats, reading headers,... + +To summarize, the gid*.ad* files are the whole GID source files. +For example, you can have a copy of those in a gid/ subdirectory +in your project. + + gid.gpr AdaCore GNAT/GCC project file - to be opened with + GNAT Programming Studio (GPS) or used with the + command: gnatmake -p -P gid + + gid_objectada.prj ObjectAda (7.2.2+) project file + + gid_work.xls this workbook contains GID's history, a list of open + bugs, technical informations about formats, etc. + + test/mini.adb small-size command-line demo, recommended for beginning. + Decodes images of any supported type and writes PPM + (Portable PixMap) files. File names are given as + arguments (also works from a GUI file explorer + with drag & drop). Typically, you put plenty of + images into the test folder and launch "mini *" to + convert them all. + + test/to_bmp.adb middle-size command-line demo which converts all image + files given as argument into BMP image files with + the .dib extension. Contrary to mini.adb, it + handles transparency (GIF, PNG, TGA), orientation + (JPEG) and animation (GIF) as well, but of course + it is more difficult to understand than mini.adb. + + test/steg.adb steganography tool: hides an image into a data. + + test/recurve.adb image processing demo: recovers curves from a chart. + + +How to use GID in your programs +=============================== +Hopefully the package specification (in the file gid.ads) is self +explanatory enough. There are three steps needed: + +1) Load the image header from a data stream +2) If needed, use dimensions to prepare the retrieval of the image +3) Load and decode the image itself. If the image is animated, + call Load_image_contents until next_frame is 0.0 + +The subprograms corresponding to these steps are +1) Load_image_header +2) Pixel_width and Pixel_height +3) Load_image_contents + +Load_image_contents is generic. You provide the following: + * Primary_color_range: the type of primary colors. + Usually it is a byte (E.g. Unsigned_8) + * procedure Set_X_Y: setting a "cursor" (an array index, for instance) + * procedure Put_Pixel: set a color (and transparency) on + the "cursor" place; the cursor is meant to move one pixel + to te right, then + * procedure Feedback: display progress (if you want or need it; + otherwise, you can always provide an empty procedure) + * mode: Display_mode: here you tell if you want the decoding rather + nicer or faster, when the decoder is processing "progressive" + (JPEG) or "interlaced" (GIF, PNG) pictures. Note: the end + result is exactly the same. The visual difference appears only + during the decoding. + +This generic construction allows you a total freedom on where and +how to use GID in your programs. In addition, your Set_X_Y and +Put_Pixel procedures are inserted at compile-time, (no call instruction), +right in the heart of the decoding procedures, for each image format, +which should deliver a decent performance as soon as you set the right +compiler options (optimization, inlined or macro-expanded generics, +suppression of all checks, loop unrolling). + +*Important note*: the performance of GID is mostly dependant of the code +you provide in Put_Pixel. If it is much more that inserting a byte into +a buffer and advancing an index or a pointer, you will get an important +performance penalty. Remember that Put_Pixel is called... for each pixel. + +How to build GID +================ +- From GPS (GNAT Programming Studio - see below for installation), press F4. + The main test's (to_bmp) executable is built in the /test folder. +- From ObjectAda's IDE, press F7. to_bmp.exe is in the folder + created by ObjectAda upon first project opening. +- From the command line, with GNAT (see below for GNAT installation): + - default build mode: gprbuild -p -P gid + - other build mode (e.g. Fast for producing fast executables): + gprbuild -p -P gid -XBuild_Mode=Fast + +We assume here you have GID unpacked "out of the box", with directories. + +Installing the free GNAT Ada compiler +===================================== + - Linux: apt install gnat (or an equivalent command like yum) + - Other systems: download GNAT @ https://www.adacore.com/community + +Memory requirements and usage +============================= +GID uses only memory for decoding purposes (e.g. decompression +structures, color tables) and doesn't store the image itself. +As a result, memory will be reserved for at most only one copy of +the output bitmap, and this under the format you want or need to have. +As an example, the to_bmp demo stores the image as a packed +RBG byte array with a 4-byte padding which is the appropriate +format for dumping a BMP file in the end. But there are many +other possible storage formats, and GID lets you the total +freedom about it. It can be even the case that the bitmap +storage is more appropriate through an operating system or +a specific library; in such a case you would not store the +bitmap within the Ada progam at all and Put_Pixel would be used +to transmit the pixels further. +All memory used by GID is taken on the stack, with the exception +of palettes and JPEG's DHT tables. Those are dynamically allocated +on the heap and deallocated upon scope end of a variable of the +Image_descriptor type. It means there is no possible memory leak. +The use of heap allocation is justified there because of the +relatively large size of those objects. They could very well +be also part of the descriptor record, with a maximal size for +palette (2**16, for the TGA format). + +Where to find the latest version +================================ +Please check the "web" constant in gid.ads. + +Note on the construction of GID. +================================ +All image formats decoded by GID have similarities in their structure. + +- Most streams begin with a signature, followed by a header + containing dimensions and the color depth. Then the image contents + follow. This is obvious to have such a data organisation, + since the header details are needed to calibrate the recipient + of the image. + +- Streams are structured in blocks of data which are given different + names depending on the format: + - PNG : chunks + - GIF : blocks + - JPEG: segments + - TGA : areas + - TIFF: tags + etc. + diff --git a/deps/gid/gid_objectada.prj b/deps/gid/gid_objectada.prj new file mode 100644 index 00000000..942f8ddf Binary files /dev/null and b/deps/gid/gid_objectada.prj differ diff --git a/deps/gid/gid_work.xls b/deps/gid/gid_work.xls new file mode 100644 index 00000000..1e2cd980 Binary files /dev/null and b/deps/gid/gid_work.xls differ diff --git a/deps/gid/readme.txt b/deps/gid/readme.txt new file mode 100644 index 00000000..0d77db5b --- /dev/null +++ b/deps/gid/readme.txt @@ -0,0 +1,12 @@ +GID - the Generic Image Decoder +------------------------------- + +The Generic Image Decoder (GID) is an Ada package for decoding a +broad variety of image formats, from any data stream, to any kind +of medium, be it an in-memory bitmap, a GUI object, +some other stream, arrays of floating-point initial data +for scientific calculations, a browser element, a device,... + + +==== +Full description in: gid.txt \ No newline at end of file diff --git a/deps/gid/svn_diff.cmd b/deps/gid/svn_diff.cmd new file mode 100644 index 00000000..53ce49e5 --- /dev/null +++ b/deps/gid/svn_diff.cmd @@ -0,0 +1,3 @@ +svn diff --diff-cmd diff -x "-i -b -B" %1 + +echo Command used was... svn diff --diff-cmd diff -x "-i -b -B" %1 diff --git a/deps/gid/test/CMD_Here.cmd b/deps/gid/test/CMD_Here.cmd new file mode 100644 index 00000000..911dc380 --- /dev/null +++ b/deps/gid/test/CMD_Here.cmd @@ -0,0 +1 @@ +cmd \ No newline at end of file diff --git a/deps/gid/test/asm.cmd b/deps/gid/test/asm.cmd new file mode 100644 index 00000000..79b474ae --- /dev/null +++ b/deps/gid/test/asm.cmd @@ -0,0 +1,7 @@ +gcc -S -gnatpn -O2 -I.. to_bmp.adb +ren to_bmp.s to_bmp_O2.s + +gcc -S -gnatpn -O0 -I.. to_bmp.adb +ren to_bmp.s to_bmp_O0.s + +del to_bmp.ali diff --git a/deps/gid/test/car_mask_breaks_1024_stack_top.gif b/deps/gid/test/car_mask_breaks_1024_stack_top.gif new file mode 100644 index 00000000..261dbae1 Binary files /dev/null and b/deps/gid/test/car_mask_breaks_1024_stack_top.gif differ diff --git a/deps/gid/test/gid.gif b/deps/gid/test/gid.gif new file mode 100644 index 00000000..eedc4dc2 Binary files /dev/null and b/deps/gid/test/gid.gif differ diff --git a/deps/gid/test/is_opaque.adb b/deps/gid/test/is_opaque.adb new file mode 100644 index 00000000..b6f44921 --- /dev/null +++ b/deps/gid/test/is_opaque.adb @@ -0,0 +1,125 @@ +-- +-- Check if an image is opaque (fully non-transparent). +-- +-- Small-size demo for the GID (Generic Image Decoder) package. +-- For a larger example, look for to_bmp.adb . +-- + +with GID; + +with Ada.Calendar; +with Ada.Characters.Handling; use Ada.Characters.Handling; +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; +with Ada.Text_IO; use Ada.Text_IO; + +with Interfaces; + +procedure Is_opaque is + + procedure Blurb is + begin + Put_Line(Current_Error, "Is_opaque * check if an image is opaque (fully non-transparent)"); + Put_Line(Current_Error, "GID (Generic Image Decoder) package version " & + GID.version & " dated " & GID.reference); + Put_Line(Current_Error, "URL: " & GID.web); + New_Line(Current_Error); + Put_Line(Current_Error, "Syntax:"); + Put_Line(Current_Error, "is_opaque [...]"); + New_Line(Current_Error); + end Blurb; + + procedure Check_raw_image( + image : in out GID.Image_descriptor; + next_frame: out Ada.Calendar.Day_Duration; + opaque : out Boolean + ) + is + use Interfaces; + subtype Primary_color_range is Unsigned_8; + -- + procedure Set_X_Y (x, y: Natural) is + begin + null; + end Set_X_Y; + -- + procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ) + is + pragma Unreferenced (blue, green, red); + begin + opaque:= opaque and alpha = Primary_color_range'Last; + end Put_Pixel; + + stars: Natural:= 0; + procedure Feedback(percents: Natural) is + so_far: constant Natural:= percents / 5; + begin + for i in stars+1..so_far loop + Put( Current_Error, '*'); + end loop; + stars:= so_far; + end Feedback; + + procedure Load_image is + new GID.Load_image_contents( + Primary_color_range, Set_X_Y, + Put_Pixel, Feedback, GID.fast + ); + + begin + opaque:= True; + Load_image(image, next_frame); + end Check_raw_image; + + procedure Process(name: String) is + f: Ada.Streams.Stream_IO.File_Type; + i: GID.Image_descriptor; + up_name: constant String:= To_Upper(name); + -- + next_frame: Ada.Calendar.Day_Duration:= 0.0; + opaque_frame: Boolean; + begin + -- + -- Load the image in its original format + -- + Open(f, In_File, name); + Put_Line(Current_Error, "Checking " & name & "..."); + -- + GID.Load_image_header( + i, + Stream(f).all, + try_tga => + name'Length >= 4 and then + up_name(up_name'Last-3..up_name'Last) = ".TGA" + ); + if GID.Expect_transparency(i) then + Put_Line(Current_Error, ".........v.........v"); + -- + loop + Check_raw_image(i, next_frame, opaque_frame); + New_Line(Current_Error); + exit when next_frame = 0.0 or not opaque_frame; + end loop; + if opaque_frame then + Put_Line(Current_Error, " Opaque: all pixels of all frames are opaque."); + else + Put_Line(Current_Error, " Not opaque: at least one pixel of one frame is not opaque."); + end if; + else + Put_Line(Current_Error, " Opaque: no transparency information."); + end if; + Close(f); + end Process; + +begin + if Argument_Count=0 then + Blurb; + return; + end if; + for i in 1..Argument_Count loop + Process(Argument(i)); + end loop; +end Is_opaque; diff --git a/deps/gid/test/mini.adb b/deps/gid/test/mini.adb new file mode 100644 index 00000000..d41d8cbf --- /dev/null +++ b/deps/gid/test/mini.adb @@ -0,0 +1,149 @@ +-- +-- Convert any image or animation file to PPM file(s). +-- +-- Small-size demo for the GID (Generic Image Decoder) package. +-- For a larger example, look for to_bmp.adb . +-- + +with GID; + +with Ada.Calendar; +with Ada.Characters.Handling; use Ada.Characters.Handling; +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Unchecked_Deallocation; + +with Interfaces; + +procedure Mini is + + procedure Blurb is + begin + Put_Line(Standard_Error, "Mini * Converts any image file to a PPM file"); + Put_Line(Standard_Error, "Simple test for the GID (Generic Image Decoder) package"); + Put_Line(Standard_Error, "Package version " & GID.version & " dated " & GID.reference); + Put_Line(Standard_Error, "URL: " & GID.web); + New_Line(Standard_Error); + Put_Line(Standard_Error, "Syntax:"); + Put_Line(Standard_Error, "mini [...]"); + New_Line(Standard_Error); + end Blurb; + + use Interfaces; + + type Byte_Array is array(Integer range <>) of Unsigned_8; + type p_Byte_Array is access Byte_Array; + procedure Dispose is new Ada.Unchecked_Deallocation(Byte_Array, p_Byte_Array); + + img_buf: p_Byte_Array:= null; + + -- Load image into a 24-bit truecolor RGB raw bitmap (for a PPM output) + procedure Load_raw_image( + image : in out GID.Image_descriptor; + buffer: in out p_Byte_Array; + next_frame: out Ada.Calendar.Day_Duration + ) + is + subtype Primary_color_range is Unsigned_8; + image_width : constant Positive:= GID.Pixel_width(image); + image_height: constant Positive:= GID.Pixel_height(image); + idx: Natural; + -- + procedure Set_X_Y (x, y: Natural) is + begin + idx:= 3 * (x + image_width * (image_height - 1 - y)); + end Set_X_Y; + -- + procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ) + is + pragma Warnings(off, alpha); -- alpha is just ignored + begin + buffer(idx..idx+2):= (red, green, blue); + idx:= idx + 3; + -- ^ GID requires us to look to next pixel on the right for next time. + end Put_Pixel; + + stars: Natural:= 0; + procedure Feedback(percents: Natural) is + so_far: constant Natural:= percents / 5; + begin + for i in stars+1..so_far loop + Put( Standard_Error, '*'); + end loop; + stars:= so_far; + end Feedback; + + procedure Load_image is + new GID.Load_image_contents( + Primary_color_range, Set_X_Y, + Put_Pixel, Feedback, GID.fast + ); + + begin + Dispose(buffer); + buffer:= new Byte_Array(0..3 * image_width * image_height - 1); + Load_image(image, next_frame); + end Load_raw_image; + + procedure Dump_PPM(name: String; i: GID.Image_descriptor) is + f: Ada.Streams.Stream_IO.File_Type; + begin + Create(f, Out_File, name & ".ppm"); + -- PPM Header: + String'Write( + Stream(f), + "P6 " & + Integer'Image(GID.Pixel_width(i)) & + Integer'Image(GID.Pixel_height(i)) & " 255" & ASCII.LF + ); + -- PPM raw BGR image: + Byte_Array'Write(Stream(f), img_buf.all); + -- ^ slow on some Ada systems, see to_bmp to have a faster version + Close(f); + end Dump_PPM; + + procedure Process(name: String) is + f: Ada.Streams.Stream_IO.File_Type; + i: GID.Image_descriptor; + up_name: constant String:= To_Upper(name); + -- + next_frame, current_frame: Ada.Calendar.Day_Duration:= 0.0; + begin + -- + -- Load the image in its original format + -- + Open(f, In_File, name); + Put_Line(Standard_Error, "Processing " & name & "..."); + -- + GID.Load_image_header( + i, + Stream(f).all, + try_tga => + name'Length >= 4 and then + up_name(up_name'Last-3..up_name'Last) = ".TGA" + ); + Put_Line(Standard_Error, ".........v.........v"); + -- + loop + Load_raw_image(i, img_buf, next_frame); + Dump_PPM(name & Duration'Image(current_frame), i); + New_Line(Standard_Error); + exit when next_frame = 0.0; + current_frame:= next_frame; + end loop; + Close(f); + end Process; + +begin + if Argument_Count=0 then + Blurb; + return; + end if; + for i in 1..Argument_Count loop + Process(Argument(i)); + end loop; +end Mini; diff --git a/deps/gid/test/nasa.cmd b/deps/gid/test/nasa.cmd new file mode 100644 index 00000000..01d45c3a --- /dev/null +++ b/deps/gid/test/nasa.cmd @@ -0,0 +1,26 @@ +echo Convert large high-res images from the NASA + +copy nasa4.jpg r: +copy nasa8.jpg r: +copy nj*.exe r: +copy to_bmp.exe r: + +r: +del *.dib +del *.ppm + +to_bmp - nasa*.jpg + +for /l %%i in (1,1,7) do timeit -s -f c:gid.dat -k jpg_rev91 to_bmp.exe nasa*.jpg + + +rem for /l %%i in (1,1,7) do timeit -f gid.dat -k png001 to_bmp.exe - nasa*.png +rem for /l %%i in (1,1,7) do timeit -f c:gid.dat -k nj_0_1.1 nj0.exe nasa6.jpg +rem for /l %%i in (1,1,7) do timeit -f c:gid.dat -k nj_bicub_1.1 nj.exe nasa6.jpg +rem for /l %%i in (1,1,8) do timeit -s -f c:gid.dat -k nj0.no_out nj0.no_out.exe nasa7.jpg + +c: + +timeit -f gid.dat + +pause diff --git a/deps/gid/test/recurve.adb b/deps/gid/test/recurve.adb new file mode 100644 index 00000000..3a41c62c --- /dev/null +++ b/deps/gid/test/recurve.adb @@ -0,0 +1,418 @@ +-- Recurve - recover curves from a chart (in JPEG, PNG, or other image format) +-- +-- Currently supports only charts on a white background +-- +-- By David Malinge and Gautier de Montmollin +-- +-- Started 28-Jun-2016 + +with GID; + +with Ada.Calendar; +with Ada.Characters.Handling; use Ada.Characters.Handling; +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Streams.Stream_IO; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Unchecked_Deallocation; + +with Interfaces; + +procedure Recurve is + + -- Parameters + + thres_grid : constant := 0.925; -- avg intensity below thres_grid => grid line + thres_curve : constant := 0.8; -- intensity below thres_curve => curve + thres_simil_2 : constant := 0.16 ** 2; -- similarity within curve + thres_simil_start_2 : constant := 0.40 ** 2; -- similarity when scanning for curves + radius : constant := 0.08; -- in proportion of image width + full_disc_radius : constant := 0.003; + full_disc_radius_pix : constant := 3; + interval_verticals : constant := 15; + start_verticals : constant := 0; -- > 0 for more vertical initial scans + + sep: constant Character:= ';'; + + procedure Blurb is + begin + Put_Line(Standard_Error, "Recurve * Recover from a chart in any image format"); + New_Line(Standard_Error); + Put_Line(Standard_Error, "GID version " & GID.version & " dated " & GID.reference); + Put_Line(Standard_Error, "URL: " & GID.web); + New_Line(Standard_Error); + Put_Line(Standard_Error, "Syntax:"); + Put_Line(Standard_Error, " recurve "); + New_Line(Standard_Error); + Put_Line(Standard_Error, "Output:"); + Put_Line(Standard_Error, " .csv"); + New_Line(Standard_Error); + end Blurb; + + use Interfaces; + + subtype Primary_color_range is Unsigned_8; + + subtype Real is Long_Float; + + type RGB is record + r,g,b: Real; + end record; + + function Grey(c: RGB) return Real is + begin + return (c.r + c.g + c.b) / 3.0; + end Grey; + + function Dist2(c1,c2: RGB) return Real is + begin + return + (c1.r - c2.r) ** 2 + + (c1.g - c2.g) ** 2 + + (c1.b - c2.b) ** 2; + end Dist2; + + function Img(c: RGB) return String is + begin + return " R:" & Integer'Image(Integer(c.r * 255.0)) & + " G:" & Integer'Image(Integer(c.g * 255.0)) & + " B:" & Integer'Image(Integer(c.b * 255.0)); + end Img; + + -- Bidimensional array. Slower than unidimensional, but fits our purpose. + type Bitmap is array(Integer range <>, Integer range <>) of RGB; + type p_Bitmap is access Bitmap; + procedure Dispose is new Ada.Unchecked_Deallocation(Bitmap, p_Bitmap); + + -- Load image + procedure Load_raw_image( + image : in out GID.Image_descriptor; + bmp : in out p_Bitmap; + next_frame: out Ada.Calendar.Day_Duration + ) + is + image_width : constant Positive:= GID.Pixel_width(image); + image_height: constant Positive:= GID.Pixel_height(image); + pos_x, pos_y: Natural; + -- + -- Generic parameters to feed GID.Load_image_contents with. + -- + procedure Set_X_Y (x, y: Natural) is + begin + pos_x:= x; + pos_y:= y; + end Set_X_Y; + -- + procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ) + is + pragma Warnings(off, alpha); -- alpha is just ignored + begin + bmp(pos_x, bmp'Last(2) - pos_y):= + (Real(red) / 255.0, + Real(green) / 255.0, + Real(blue) / 255.0 + ); + pos_x:= pos_x + 1; + -- ^ GID requires us to look to next pixel on the right for next time. + end Put_Pixel; + -- + stars: Natural:= 0; + procedure Feedback(percents: Natural) is + so_far: constant Natural:= percents / 5; + begin + for i in stars+1..so_far loop + Put( Standard_Error, '*'); + end loop; + stars:= so_far; + end Feedback; + -- + -- Instantiation of GID.Load_image_contents. + -- + procedure Load_image is + new GID.Load_image_contents( + Primary_color_range, Set_X_Y, + Put_Pixel, Feedback, GID.fast + ); + -- + begin + Dispose(bmp); + bmp:= new Bitmap(0..image_width-1, 0..image_height-1); + Load_image(image, next_frame); + end Load_raw_image; + + bmp: p_Bitmap:= null; + + -------------------------------------------------------------------------------- + -- Identify curves in an image file; write a .csv file with the data points -- + -------------------------------------------------------------------------------- + + procedure Detect_curves(file_name: String) is + grid_hor: array(bmp'Range(2)) of Boolean:= (others => False); + grid_ver: array(bmp'Range(1)) of Boolean:= (others => False); + v: Real; + done: array(bmp'Range(1), bmp'Range(2)) of Boolean:= (others => (others => False)); + -- color_scanned: array(0..255, 0..255, 0..255) of Boolean:= ... mmmh too big + + type Curve_ys is array(bmp'Range(1)) of Real; + type Curve_descr is record + ys: Curve_ys:= (others => -1.0); -- Convention: undefined y-value is < 0 + min_x: Integer:= Integer'Last; + max_x: Integer:= Integer'First; + color: RGB; + end record; + + procedure Interpolate(c: in out Curve_descr) is + -- We will interpolate between (x1, c.ys(x1)) and (x2, c.ys(x2)). + -- + -- y1 none [...] y2 + -- + -- x1 x1+1 [...] x2 + y1, y2: Real; + begin + for x1 in c.min_x .. c.max_x loop + y1:= c.ys(x1); + if y1 >= 0.0 and then x1+1 <= c.max_x and then c.ys(x1+1) < 0.0 then + for x2 in x1+2 .. c.max_x loop + y2:= c.ys(x2); + if y2 >= 0.0 then + -- Linear interpolation is happening here. + for x in x1+1 .. x2-1 loop + c.ys(x):= (Real(x-x1) / Real(x2-x1)) * (y2-y1) + y1; + end loop; + exit; + end if; + end loop; + end if; + end loop; + end Interpolate; + + Curve_Stack: array(1..bmp'Length(2)) of Curve_descr; + curve_top: Natural:= 0; + + procedure Scan_curve(x0, y0, xd: Integer) is + curv: Curve_descr renames Curve_Stack(curve_top); + c: RGB renames curv.color; + -- + procedure Mark_point(x, y: Integer) is + begin + done(x,y):= True; + curv.min_x:= Integer'Min(curv.min_x, x); + curv.max_x:= Integer'Max(curv.max_x, x); + end Mark_point; + -- + x_sum, y_sum: Natural; + found: Natural; + procedure Test_point(xt, yt: Integer) is + begin + if xt in bmp'Range(1) + and then yt in bmp'Range(2) + and then (not done(xt, yt)) + and then Dist2(bmp(xt,yt), c) < thres_simil_2 + then + x_sum:= x_sum + xt; + y_sum:= y_sum + yt; + Mark_point(xt, yt); + found:= found + 1; + end if; + end Test_point; + -- + x: Integer:= x0; + y: Integer:= y0; + -- + procedure Check_single_radius(r: Positive) is + begin + for xs in 1..r loop + for ys in 0..r loop + if xs**2 + ys**2 in (r-1)**2 .. r**2 then + Test_point( + x + xs * xd, -- xd = direction, left or right + y - ys -- Below + ); + Test_point( + x + xs * xd, -- xd = direction, left or right + y + ys -- Above + ); + end if; + end loop; + end loop; + end Check_single_radius; + -- + ring_rad: constant Integer:= Integer(radius*Real(bmp'Length(1))); + disc_rad: constant Integer:= + Integer'Max ( + full_disc_radius_pix, + Integer (full_disc_radius * Real(bmp'Length(1))) + ); + y_subpixel : Real := Real (y); + begin + Mark_point (x,y); + Scan: loop + -- We register (x, y) into the curve information. + -- It is either the starting point, or the average + -- matching point of previous iteration. + curv.ys (x):= Real(bmp'Last(2)) - y_subpixel; + -- Now, try to find the next point of the curve in the direction xd. + found := 0; + x_sum := 0; + y_sum := 0; + -- Explore a half-disc + for rad in 1 .. disc_rad loop + Check_single_radius (rad); + end loop; + if found = 0 then + -- Continue searching, but stop when one half-ring is successful + for rad in disc_rad+1 .. ring_rad loop + Check_single_radius (rad); + exit when found > 0; + end loop; + end if; + exit Scan when found = 0; -- No matching point anywhere in search half-disc. + -- Next (x,y) point will be the average of near matching points found + x := x_sum / found; + y := y_sum / found; + y_subpixel := Real (y_sum) / Real (found); -- Non-rounded average y value. + -- At this point, we are ready to scan next pixel (x, y) of the curve. + exit Scan when x not in bmp'Range(1); + end loop Scan; + end Scan_curve; + + x0: Integer; + color0: RGB; + f: File_Type; + min_min_x: Integer:= Integer'Last; + max_max_x: Integer:= Integer'First; + mid: constant Integer:= bmp'Last(1) / 2; + begin + New_Line; + -- + -- Detect vertical gridlines - and some noise... + -- + for x in bmp'Range(1) loop + v:= 0.0; + for y in bmp'Range(2) loop + v:= v + Grey(bmp(x,y)); + end loop; + v:= v / Real(bmp'Length(2)); + if v < thres_grid then + grid_ver(x):= True; + Put_Line("Vertical: " & Integer'Image(x)); + end if; + end loop; + -- + -- Detect horizontal gridlines - and some noise... + -- + for y in bmp'Range(2) loop + v:= 0.0; + for x in bmp'Range(1) loop + v:= v + Grey(bmp(x,y)); + end loop; + v:= v / Real(bmp'Length(1)); + if v < thres_grid then + grid_hor(y):= True; + Put_Line("Horizontal: " & Integer'Image(y)); + end if; + end loop; + -- + -- Main scan for curves, start in a band in the middle + -- Why not just a single vertical line ? + -- A curve could be hidden by another one just in that place. + -- + for sv in -start_verticals/2 .. start_verticals/2 loop + x0:= mid + sv * interval_verticals; + if x0 in bmp'Range(1) and then not grid_ver(x0) then + for y in bmp'Range(2) loop + color0:= bmp(x0,y); + if (not grid_hor(y)) and then Grey(color0) < thres_curve and then not done(x0,y) then + if y > 0 and then done(x0,y-1) and then Dist2(bmp(x0,y-1), color0) < thres_simil_start_2 then + done(x0,y):= True; -- Actually the same, fat curve as one pixel above + -- elsif x0 > 0 and then done(x0-1,y) and then Dist2(bmp(x0-1,y), color0) < thres_simil_start_2 then + -- done(x0,y):= True; -- Actually the same curve as one pixel left + else + Put_Line("curve: " & Integer'Image(x0) & Integer'Image(y)); + curve_top:= curve_top + 1; + Curve_Stack(curve_top).color:= color0; + -- Following idea is from a humanitarian star who used to send + -- two camera teams in opposite directions in conflict areas: + Scan_curve(x0, y, -1); + Scan_curve(x0, y, +1); + end if; + end if; + end loop; + end if; + end loop; + -- + -- Finalization + -- + for i in 1..curve_top loop + min_min_x:= Integer'Min(min_min_x, Curve_Stack(i).min_x); + max_max_x:= Integer'Max(max_max_x, Curve_Stack(i).max_x); + Interpolate(Curve_Stack(i)); + end loop; + -- + -- Output curves + -- + Create(f, Out_File, file_name & ".csv"); + Put_Line(f, "Recurve output"); + Put(f, "Color"); + for i in 1..curve_top loop + Put(f, sep & Img(Curve_Stack(i).color)); + end loop; + New_Line(f); + Put(f, 'x'); + for i in 1..curve_top loop + Put(f, sep & 'y' & Integer'Image(i)); + end loop; + New_Line(f); + for x in min_min_x .. max_max_x loop + Put(f, Integer'Image(x)); + for i in 1..curve_top loop + Put(f, sep); + if x in Curve_Stack(i).min_x .. Curve_Stack(i).max_x and then Curve_Stack(i).ys(x) >= 0.0 then + Put(f, Real'Image(Curve_Stack(i).ys(x))); + end if; + end loop; + New_Line(f); + end loop; + Close(f); + end Detect_curves; + + procedure Process(file_name: String) is + use Ada.Streams.Stream_IO; + f: Ada.Streams.Stream_IO.File_Type; + i: GID.Image_descriptor; + up_name: constant String:= To_Upper(file_name); + -- + next_frame: Ada.Calendar.Day_Duration:= 0.0; + begin + -- + -- Load the image in its original format + -- + Open(f, In_File, file_name); + Put_Line(Standard_Error, "Processing " & file_name & "..."); + -- + GID.Load_image_header( + i, + Stream(f).all, + try_tga => + file_name'Length >= 4 and then + up_name(up_name'Last-3..up_name'Last) = ".TGA" + ); + Put_Line(Standard_Error, ".........v.........v"); + -- + Load_raw_image(i, bmp, next_frame); + Detect_curves(file_name); + New_Line(Standard_Error); + Close(f); + end Process; + +begin + if Argument_Count=0 then + Blurb; + return; + end if; + for i in 1..Argument_Count loop + Process(Argument(i)); + end loop; +end Recurve; diff --git a/deps/gid/test/recurve_test_01.png b/deps/gid/test/recurve_test_01.png new file mode 100644 index 00000000..dfd35ff0 Binary files /dev/null and b/deps/gid/test/recurve_test_01.png differ diff --git a/deps/gid/test/recurve_test_02.png b/deps/gid/test/recurve_test_02.png new file mode 100644 index 00000000..838095e3 Binary files /dev/null and b/deps/gid/test/recurve_test_02.png differ diff --git a/deps/gid/test/recurve_test_03.png b/deps/gid/test/recurve_test_03.png new file mode 100644 index 00000000..64485722 Binary files /dev/null and b/deps/gid/test/recurve_test_03.png differ diff --git a/deps/gid/test/recurve_test_04.png b/deps/gid/test/recurve_test_04.png new file mode 100644 index 00000000..37fb1ae1 Binary files /dev/null and b/deps/gid/test/recurve_test_04.png differ diff --git a/deps/gid/test/steg.adb b/deps/gid/test/steg.adb new file mode 100644 index 00000000..a18eed40 --- /dev/null +++ b/deps/gid/test/steg.adb @@ -0,0 +1,247 @@ +-- +-- Minimal steganography tool. +-- +-- This demo is derived from mini.adb. +-- + +-- To do: +-- - encryption + +with GID; + +with Ada.Calendar; +with Ada.Characters.Handling; use Ada.Characters.Handling; +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; +with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Unchecked_Deallocation; + +with Interfaces; + +procedure Steg is + + procedure Blurb is + begin + Put_Line(Standard_Error, "Steg * Minimal steganography tool"); + New_Line(Standard_Error); + Put_Line(Standard_Error, " Encoding: converts any image file to a PPM image file, with"); + Put_Line(Standard_Error, " inclusion of a hidden data file. The PPM image can then"); + Put_Line(Standard_Error, " be converted to a lossless-compressed format like PNG."); + New_Line(Standard_Error); + Put_Line(Standard_Error, " Decoding: extracts a hidden file from an image."); + New_Line(Standard_Error); + Put_Line(Standard_Error, "GID version " & GID.version & " dated " & GID.reference); + Put_Line(Standard_Error, "URL: " & GID.web); + New_Line(Standard_Error); + Put_Line(Standard_Error, "Syntax:"); + Put_Line(Standard_Error, " steg [e|d] "); + New_Line(Standard_Error); + end Blurb; + + use Interfaces; + + type Byte_Array is array(Integer range <>) of Unsigned_8; + type p_Byte_Array is access Byte_Array; + procedure Dispose is new Ada.Unchecked_Deallocation(Byte_Array, p_Byte_Array); + + img_buf: p_Byte_Array:= null; + + -- Load image into a 24-bit truecolor RGB raw bitmap (for a PPM output) + procedure Load_raw_image( + image : in out GID.Image_descriptor; + buffer: in out p_Byte_Array; + next_frame: out Ada.Calendar.Day_Duration + ) + is + subtype Primary_color_range is Unsigned_8; + image_width : constant Positive:= GID.Pixel_width(image); + image_height: constant Positive:= GID.Pixel_height(image); + idx: Natural; + -- + procedure Set_X_Y (x, y: Natural) is + begin + idx:= 3 * (x + image_width * (image_height - 1 - y)); + end Set_X_Y; + -- + procedure Put_Pixel ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ) + is + pragma Warnings(off, alpha); -- alpha is just ignored + begin + buffer(idx..idx+2):= (red, green, blue); + idx:= idx + 3; + -- ^ GID requires us to look to next pixel on the right for next time. + end Put_Pixel; + + stars: Natural:= 0; + procedure Feedback(percents: Natural) is + so_far: constant Natural:= percents / 5; + begin + for i in stars+1..so_far loop + Put( Standard_Error, '*'); + end loop; + stars:= so_far; + end Feedback; + + procedure Load_image is + new GID.Load_image_contents( + Primary_color_range, Set_X_Y, + Put_Pixel, Feedback, GID.fast + ); + + begin + Dispose(buffer); + buffer:= new Byte_Array(0..3 * image_width * image_height - 1); + Load_image(image, next_frame); + end Load_raw_image; + + procedure Dump_PPM(name: String; i: GID.Image_descriptor) is + f: Ada.Streams.Stream_IO.File_Type; + ppm_name: constant String:= name & ".ppm"; + begin + Create(f, Out_File, ppm_name); + Put_Line(Standard_Error, "Creating PPM image, name = " & ppm_name & " ..."); + -- PPM Header: + String'Write( + Stream(f), + "P6 " & + Integer'Image(GID.Pixel_width(i)) & + Integer'Image(GID.Pixel_height(i)) & " 255" & ASCII.LF + ); + -- PPM raw BGR image: + Byte_Array'Write(Stream(f), img_buf.all); + -- ^ slow on some Ada systems, see to_bmp to have a faster version + Close(f); + end Dump_PPM; + + type Operation is (encoding, decoding); + + Data_too_large: exception; + + procedure Process(image_name, data_name: String; op: Operation) is + f_im, f_dt: Ada.Streams.Stream_IO.File_Type; + -- + procedure Encode is + idx: Natural:= img_buf'Last; + -- Start with buffer's end (image's bottom), with the hope it is "noisier": + -- often there is a blue sky or something like that on the top... + procedure Encode_byte(b: Unsigned_8) is + begin + img_buf(idx):= (img_buf(idx) and 2#1111_1100#) or (b and 2#0000_0011#); -- B + idx:= idx - 1; + img_buf(idx):= (img_buf(idx) and 2#1111_1000#) or Shift_Right(b and 2#0001_1100#, 2); -- G + idx:= idx - 1; + img_buf(idx):= (img_buf(idx) and 2#1111_1000#) or Shift_Right(b, 5); -- R + idx:= idx - 1; + end Encode_byte; + b: Unsigned_8; + data_size: Unsigned_64; + needed_size: Unsigned_64; + available_size: constant Unsigned_64:= img_buf'Length / 3; -- 1 byte per pixel; + factor: Float; + begin + Open(f_dt, In_File, data_name); + data_size:= Unsigned_64(Size(f_dt)); + needed_size:= data_size + 8; + factor:= Float(needed_size) / Float(available_size); + if needed_size > available_size then + raise Data_too_large with + "Needs a" & Integer'Image(1 + Integer(100.0 * factor)) & + "% raw size scaling, i.e. a" & + Integer'Image(1 + Integer(100.0 * Sqrt(factor))) & + "% image scaling in both dimensions"; + end if; + Put_Line(Standard_Error, + "Data size:" & Unsigned_64'Image(data_size) & + ", using" & Integer'Image(Integer(100.0 * factor)) & + "% of image data" + ); + for i in 1..8 loop + Encode_byte(Unsigned_8(data_size and 16#FF#)); + data_size:= Shift_Right(data_size, 8); + end loop; + while not End_Of_File(f_dt) loop + Unsigned_8'Read(Stream(f_dt), b); + Encode_byte(b); + end loop; + Close(f_dt); + end Encode; + -- + procedure Decode is + idx: Natural:= img_buf'Last; + procedure Decode_byte(b: out Unsigned_8) is + begin + b:= img_buf(idx) and 2#0000_0011#; -- B + idx:= idx - 1; + b:= b + Shift_Left(img_buf(idx) and 2#0000_0111#, 2); -- G + idx:= idx - 1; + b:= b + Shift_Left(img_buf(idx) and 2#0000_0111#, 5); -- R + idx:= idx - 1; + end Decode_byte; + b: Unsigned_8; + data_size: Unsigned_64:= 0; + begin + for i in 0..7 loop + Decode_byte(b); + data_size:= data_size + Shift_Left(Unsigned_64(b), i * 8); + end loop; + Create(f_dt, Out_File, data_name); + for i in 1..data_size loop + Decode_byte(b); + Unsigned_8'Write(Stream(f_dt), b); + end loop; + Close(f_dt); + end Decode; + -- + i: GID.Image_descriptor; + up_name: constant String:= To_Upper(image_name); + -- + next_frame: Ada.Calendar.Day_Duration; + begin + -- + -- Load the image in its original format + -- + Open(f_im, In_File, image_name); + Put_Line(Standard_Error, "Processing " & image_name & "..."); + -- + GID.Load_image_header( + i, + Stream(f_im).all, + try_tga => + image_name'Length >= 4 and then + up_name(up_name'Last-3..up_name'Last) = ".TGA" + ); + Put_Line(Standard_Error, ".........v.........v"); + -- + Load_raw_image(i, img_buf, next_frame); + New_Line(Standard_Error); + Close(f_im); + case op is + when encoding => + Encode; + Dump_PPM(image_name, i); -- Output encoded image + when decoding => + Decode; + end case; + end Process; + + op: Operation; + +begin + if Argument_Count /= 3 then + Blurb; + return; + end if; + if To_Lower(Argument(1))="e" then + op:= encoding; + elsif To_Lower(Argument(1))="d" then + op:= decoding; + else + Blurb; + return; + end if; + Process(Argument(2), Argument(3), op); +end Steg; diff --git a/deps/gid/test/to_bmp.adb b/deps/gid/test/to_bmp.adb new file mode 100644 index 00000000..ddd46e41 --- /dev/null +++ b/deps/gid/test/to_bmp.adb @@ -0,0 +1,552 @@ +-- +-- Convert any image or animation file to BMP file(s). +-- +-- Middle-size test/demo for the GID (Generic Image Decoder) package. +-- +-- Supports: +-- - Transparency (blends transparent or partially opaque areas with a +-- background image, gid.gif, or a fixed, predefined colour) +-- - Display orientation (JPEG EXIF informations from digital cameras) +-- +-- For a smaller and simpler example, look for mini.adb . +-- + +with GID; + +with Ada.Calendar; +with Ada.Characters.Handling; use Ada.Characters.Handling; +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Unchecked_Deallocation; + +with Interfaces; + +procedure To_BMP is + + default_bkg_name: constant String:= "gid.gif"; + + procedure Blurb is + begin + Put_Line(Standard_Error, "To_BMP * Converts any image file to a BMP file"); + Put_Line(Standard_Error, "Simple test for the GID (Generic Image Decoder) package"); + Put_Line(Standard_Error, "Package version " & GID.version & " dated " & GID.reference); + Put_Line(Standard_Error, "URL: " & GID.web); + New_Line(Standard_Error); + Put_Line(Standard_Error, "Syntax:"); + Put_Line(Standard_Error, "to_bmp [-] [-] [...]"); + New_Line(Standard_Error); + Put_Line(Standard_Error, "Options:"); + Put_Line(Standard_Error, " '-': don't output image (testing only)"); + Put_Line(Standard_Error, " '-':"); + Put_Line(Standard_Error, " use specifed background to mix with transparent images"); + Put_Line(Standard_Error, " (otherwise, trying with '"& default_bkg_name &"' or single color)"); + New_Line(Standard_Error); + Put_Line(Standard_Error, "Output: "".dib"" is added the full input name(s)"); + Put_Line(Standard_Error, " Reason of "".dib"": unknown synonym of "".bmp"";"); + Put_Line(Standard_Error, " just do ""del *.dib"" for cleanup"); + New_Line(Standard_Error); + end Blurb; + + -- Image used as background for displaying images having transparency + background_image_name: Unbounded_String:= Null_Unbounded_String; + + use Interfaces; + + type Byte_Array is array(Integer range <>) of Unsigned_8; + type p_Byte_Array is access Byte_Array; + procedure Dispose is new Ada.Unchecked_Deallocation(Byte_Array, p_Byte_Array); + + forgive_errors: constant Boolean:= False; + error: Boolean; + + img_buf, bkg_buf: p_Byte_Array:= null; + bkg: GID.Image_descriptor; + + generic + correct_orientation: GID.Orientation; + -- Load image into a 24-bit truecolor BGR raw bitmap (for a BMP output) + procedure Load_raw_image( + image : in out GID.Image_descriptor; + buffer: in out p_Byte_Array; + next_frame: out Ada.Calendar.Day_Duration + ); + -- + procedure Load_raw_image( + image : in out GID.Image_descriptor; + buffer: in out p_Byte_Array; + next_frame: out Ada.Calendar.Day_Duration + ) + is + subtype Primary_color_range is Unsigned_8; + subtype U16 is Unsigned_16; + image_width: constant Positive:= GID.Pixel_width(image); + image_height: constant Positive:= GID.Pixel_height(image); + padded_line_size_x: constant Positive:= + 4 * Integer(Float'Ceiling(Float(image_width) * 3.0 / 4.0)); + padded_line_size_y: constant Positive:= + 4 * Integer(Float'Ceiling(Float(image_height) * 3.0 / 4.0)); + -- (in bytes) + idx: Integer; + mem_x, mem_y: Natural; + bkg_padded_line_size: Positive; + bkg_width, bkg_height: Natural; + -- + procedure Set_X_Y (x, y: Natural) is + pragma Inline(Set_X_Y); + use GID; + rev_x: constant Natural:= image_width - (x+1); + rev_y: constant Natural:= image_height - (y+1); + begin + case correct_orientation is + when Unchanged => + idx:= 3 * x + padded_line_size_x * y; + when Rotation_90 => + idx:= 3 * rev_y + padded_line_size_y * x; + when Rotation_180 => + idx:= 3 * rev_x + padded_line_size_x * rev_y; + when Rotation_270 => + idx:= 3 * y + padded_line_size_y * rev_x; + end case; + mem_x:= x; + mem_y:= y; + end Set_X_Y; + -- + -- No background version of Put_Pixel + -- + procedure Put_Pixel_without_bkg ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ) + is + pragma Inline(Put_Pixel_without_bkg); + pragma Warnings(off, alpha); -- alpha is just ignored + use GID; + begin + buffer(idx..idx+2):= (blue, green, red); + -- GID requires us to look to next pixel for next time: + case correct_orientation is + when Unchanged => + idx:= idx + 3; + when Rotation_90 => + idx:= idx + padded_line_size_y; + when Rotation_180 => + idx:= idx - 3; + when Rotation_270 => + idx:= idx - padded_line_size_y; + end case; + end Put_Pixel_without_bkg; + -- + -- Unicolor background version of Put_Pixel + -- + procedure Put_Pixel_with_unicolor_bkg ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ) + is + pragma Inline(Put_Pixel_with_unicolor_bkg); + u_red : constant:= 200; + u_green: constant:= 133; + u_blue : constant:= 32; + begin + if alpha = 255 then + buffer(idx..idx+2):= (blue, green, red); + else -- blend with bckground color + buffer(idx) := Primary_color_range((U16(alpha) * U16(blue) + U16(255-alpha) * u_blue )/255); + buffer(idx+1):= Primary_color_range((U16(alpha) * U16(green) + U16(255-alpha) * u_green)/255); + buffer(idx+2):= Primary_color_range((U16(alpha) * U16(red) + U16(255-alpha) * u_red )/255); + end if; + idx:= idx + 3; + -- ^ GID requires us to look to next pixel on the right for next time. + end Put_Pixel_with_unicolor_bkg; + -- + -- Background image version of Put_Pixel + -- + procedure Put_Pixel_with_image_bkg ( + red, green, blue : Primary_color_range; + alpha : Primary_color_range + ) + is + pragma Inline(Put_Pixel_with_image_bkg); + b_red, + b_green, + b_blue : Primary_color_range; + bkg_idx: Natural; + begin + if alpha = 255 then + buffer(idx..idx+2):= (blue, green, red); + else -- blend with background image + bkg_idx:= 3 * (mem_x mod bkg_width) + bkg_padded_line_size * (mem_y mod bkg_height); + b_blue := bkg_buf(bkg_idx); + b_green:= bkg_buf(bkg_idx+1); + b_red := bkg_buf(bkg_idx+2); + buffer(idx) := Primary_color_range((U16(alpha) * U16(blue) + U16(255-alpha) * U16(b_blue) )/255); + buffer(idx+1):= Primary_color_range((U16(alpha) * U16(green) + U16(255-alpha) * U16(b_green))/255); + buffer(idx+2):= Primary_color_range((U16(alpha) * U16(red) + U16(255-alpha) * U16(b_red) )/255); + end if; + idx:= idx + 3; + -- ^ GID requires us to look to next pixel on the right for next time. + mem_x:= mem_x + 1; + end Put_Pixel_with_image_bkg; + + stars: Natural:= 0; + procedure Feedback(percents: Natural) is + so_far: constant Natural:= percents / 5; + begin + for i in stars+1..so_far loop + Put( Standard_Error, '*'); + end loop; + stars:= so_far; + end Feedback; + + -- Here, the exciting thing: the instanciation of + -- GID.Load_image_contents. In our case, we load the image + -- into a 24-bit bitmap (because we provide a Put_Pixel + -- that does that with the pixels), but we could do plenty + -- of other things instead, like display the image live on a GUI. + + -- More exciting: for tuning performance, we have 3 different + -- instances of GID.Load_image_contents (each of them with the full + -- decoders for all formats, own specialized generic instances, inlines, + -- etc.) depending on the transparency features. + + procedure BMP24_Load_without_bkg is + new GID.Load_image_contents( + Primary_color_range, + Set_X_Y, + Put_Pixel_without_bkg, + Feedback, + GID.fast + ); + + procedure BMP24_Load_with_unicolor_bkg is + new GID.Load_image_contents( + Primary_color_range, + Set_X_Y, + Put_Pixel_with_unicolor_bkg, + Feedback, + GID.fast + ); + + procedure BMP24_Load_with_image_bkg is + new GID.Load_image_contents( + Primary_color_range, + Set_X_Y, + Put_Pixel_with_image_bkg, + Feedback, + GID.fast + ); + + begin + error:= False; + Dispose(buffer); + case correct_orientation is + when GID.Unchanged | GID.Rotation_180 => + buffer:= new Byte_Array(0..padded_line_size_x * GID.Pixel_height(image) - 1); + when GID.Rotation_90 | GID.Rotation_270 => + buffer:= new Byte_Array(0..padded_line_size_y * GID.Pixel_width(image) - 1); + end case; + if GID.Expect_transparency(image) then + if background_image_name = Null_Unbounded_String then + BMP24_Load_with_unicolor_bkg(image, next_frame); + else + bkg_width:= GID.Pixel_width(bkg); + bkg_height:= GID.Pixel_height(bkg); + bkg_padded_line_size:= + 4 * Integer(Float'Ceiling(Float(bkg_width) * 3.0 / 4.0)); + BMP24_Load_with_image_bkg(image, next_frame); + end if; + else + BMP24_Load_without_bkg(image, next_frame); + end if; + -- -- For testing: white rectangle with a red half-frame. + -- buffer.all:= (others => 255); + -- for x in 0..GID.Pixel_width(image)-1 loop + -- Put_Pixel_with_unicolor_bkg(x,0,255,0,0,255); + -- end loop; + -- for y in 0..GID.Pixel_height(image)-1 loop + -- Put_Pixel_with_unicolor_bkg(0,y,255,0,0,255); + -- end loop; + exception + when others => + if forgive_errors then + error:= True; + next_frame:= 0.0; + else + raise; + end if; + end Load_raw_image; + + procedure Load_raw_image_0 is new Load_raw_image(GID.Unchanged); + procedure Load_raw_image_90 is new Load_raw_image(GID.Rotation_90); + procedure Load_raw_image_180 is new Load_raw_image(GID.Rotation_180); + procedure Load_raw_image_270 is new Load_raw_image(GID.Rotation_270); + + procedure Dump_BMP_24(name: String; i: GID.Image_descriptor) is + f: Ada.Streams.Stream_IO.File_Type; + type BITMAPFILEHEADER is record + bfType : Unsigned_16; + bfSize : Unsigned_32; + bfReserved1: Unsigned_16:= 0; + bfReserved2: Unsigned_16:= 0; + bfOffBits : Unsigned_32; + end record; + -- ^ No packing needed + BITMAPFILEHEADER_Bytes: constant:= 14; + + type BITMAPINFOHEADER is record + biSize : Unsigned_32; + biWidth : Unsigned_32; + biHeight : Unsigned_32; + biPlanes : Unsigned_16:= 1; + biBitCount : Unsigned_16; + biCompression : Unsigned_32:= 0; + biSizeImage : Unsigned_32; + biXPelsPerMeter: Unsigned_32:= 0; + biYPelsPerMeter: Unsigned_32:= 0; + biClrUsed : Unsigned_32:= 0; + biClrImportant : Unsigned_32:= 0; + end record; + -- ^ No packing needed + BITMAPINFOHEADER_Bytes: constant:= 40; + + FileInfo : BITMAPINFOHEADER; + FileHeader: BITMAPFILEHEADER; + -- + generic + type Number is mod <>; + procedure Write_Intel_x86_number(n: in Number); + + procedure Write_Intel_x86_number(n: in Number) is + m: Number:= n; + bytes: constant Integer:= Number'Size/8; + begin + for i in 1..bytes loop + Unsigned_8'Write(Stream(f), Unsigned_8(m and 255)); + m:= m / 256; + end loop; + end Write_Intel_x86_number; + procedure Write_Intel is new Write_Intel_x86_number( Unsigned_16 ); + procedure Write_Intel is new Write_Intel_x86_number( Unsigned_32 ); + begin + FileHeader.bfType := 16#4D42#; -- 'BM' + FileHeader.bfOffBits := BITMAPINFOHEADER_Bytes + BITMAPFILEHEADER_Bytes; + FileInfo.biSize := BITMAPINFOHEADER_Bytes; + case GID.Display_orientation(i) is + when GID.Unchanged | GID.Rotation_180 => + FileInfo.biWidth := Unsigned_32(GID.Pixel_width(i)); + FileInfo.biHeight := Unsigned_32(GID.Pixel_height(i)); + when GID.Rotation_90 | GID.Rotation_270 => + FileInfo.biWidth := Unsigned_32(GID.Pixel_height(i)); + FileInfo.biHeight := Unsigned_32(GID.Pixel_width(i)); + end case; + FileInfo.biBitCount := 24; + FileInfo.biSizeImage := Unsigned_32(img_buf.all'Length); + + FileHeader.bfSize := FileHeader.bfOffBits + FileInfo.biSizeImage; + + Create(f, Out_File, name & ".dib"); + -- BMP Header, endian-safe: + Write_Intel(FileHeader.bfType); + Write_Intel(FileHeader.bfSize); + Write_Intel(FileHeader.bfReserved1); + Write_Intel(FileHeader.bfReserved2); + Write_Intel(FileHeader.bfOffBits); + -- + Write_Intel(FileInfo.biSize); + Write_Intel(FileInfo.biWidth); + Write_Intel(FileInfo.biHeight); + Write_Intel(FileInfo.biPlanes); + Write_Intel(FileInfo.biBitCount); + Write_Intel(FileInfo.biCompression); + Write_Intel(FileInfo.biSizeImage); + Write_Intel(FileInfo.biXPelsPerMeter); + Write_Intel(FileInfo.biYPelsPerMeter); + Write_Intel(FileInfo.biClrUsed); + Write_Intel(FileInfo.biClrImportant); + -- BMP raw BGR image: + declare + -- Workaround for the severe xxx'Read xxx'Write performance + -- problems in the GNAT and ObjectAda compilers (as in 2009) + -- This is possible if and only if Byte = Stream_Element and + -- arrays types are both packed the same way. + -- + subtype Size_test_a is Byte_Array(1..19); + subtype Size_test_b is Ada.Streams.Stream_Element_Array(1..19); + workaround_possible: constant Boolean:= + Size_test_a'Size = Size_test_b'Size and then + Size_test_a'Alignment = Size_test_b'Alignment; + -- + begin + if workaround_possible then + declare + use Ada.Streams; + SE_Buffer : Stream_Element_Array (0..Stream_Element_Offset(img_buf'Length-1)); + for SE_Buffer'Address use img_buf.all'Address; + pragma Import (Ada, SE_Buffer); + begin + Ada.Streams.Write(Stream(f).all, SE_Buffer(0..Stream_Element_Offset(img_buf'Length-1))); + end; + else + Byte_Array'Write(Stream(f), img_buf.all); -- the workaround is about this line... + end if; + end; + Close(f); + end Dump_BMP_24; + + procedure Process(name: String; as_background, test_only: Boolean) is + f: Ada.Streams.Stream_IO.File_Type; + i: GID.Image_descriptor; + up_name: constant String:= To_Upper(name); + -- + next_frame, current_frame: Ada.Calendar.Day_Duration:= 0.0; + begin + -- + -- Load the image in its original format + -- + Open(f, In_File, name); + Put_Line(Standard_Error, "Processing " & name & "..."); + -- + GID.Load_image_header( + i, + Stream(f).all, + try_tga => + name'Length >= 4 and then + up_name(up_name'Last-3..up_name'Last) = ".TGA" + ); + Put_Line(Standard_Error, + " Image format: " & GID.Image_format_type'Image(GID.Format(i)) + ); + Put_Line(Standard_Error, + " Image detailed format: " & GID.Detailed_format(i) + ); + Put_Line(Standard_Error, + " Image sub-format ID (if any): " & Integer'Image(GID.Subformat(i)) + ); + Put_Line(Standard_Error, + " Dimensions in pixels: " & + Integer'Image(GID.Pixel_width(i)) & " x" & + Integer'Image(GID.Pixel_height(i)) + ); + Put_Line(Standard_Error, + " Display orientation: " & + GID.Orientation'Image(GID.Display_orientation(i)) + ); + Put(Standard_Error, + " Color depth: " & + Integer'Image(GID.Bits_per_pixel(i)) & " bits" + ); + if GID.Bits_per_pixel(i) <= 24 then + Put_Line(Standard_Error, + ',' & + Integer'Image(2**GID.Bits_per_pixel(i)) & " colors" + ); + else + New_Line(Standard_Error); + end if; + Put_Line(Standard_Error, + " Palette: " & Boolean'Image(GID.Has_palette(i)) + ); + Put_Line(Standard_Error, + " Greyscale: " & Boolean'Image(GID.Greyscale(i)) + ); + Put_Line(Standard_Error, + " RLE encoding (if any): " & Boolean'Image(GID.RLE_encoded(i)) + ); + Put_Line(Standard_Error, + " Interlaced (GIF: each frame's choice): " & Boolean'Image(GID.Interlaced(i)) + ); + Put_Line(Standard_Error, + " Expect transparency: " & Boolean'Image(GID.Expect_transparency(i)) + ); + Put_Line(Standard_Error, "1........10........20"); + Put_Line(Standard_Error, " | | "); + -- + if as_background then + case GID.Display_orientation(i) is + when GID.Unchanged => + Load_raw_image_0(i, bkg_buf, next_frame); + when GID.Rotation_90 => + Load_raw_image_90(i, bkg_buf, next_frame); + when GID.Rotation_180 => + Load_raw_image_180(i, bkg_buf, next_frame); + when GID.Rotation_270 => + Load_raw_image_270(i, bkg_buf, next_frame); + end case; + bkg:= i; + New_Line(Standard_Error); + Close(f); + return; + end if; + loop + case GID.Display_orientation(i) is + when GID.Unchanged => + Load_raw_image_0(i, img_buf, next_frame); + when GID.Rotation_90 => + Load_raw_image_90(i, img_buf, next_frame); + when GID.Rotation_180 => + Load_raw_image_180(i, img_buf, next_frame); + when GID.Rotation_270 => + Load_raw_image_270(i, img_buf, next_frame); + end case; + if not test_only then + Dump_BMP_24(name & Duration'Image(current_frame), i); + end if; + New_Line(Standard_Error); + if error then + Put_Line(Standard_Error, "Error!"); + end if; + exit when next_frame = 0.0; + current_frame:= next_frame; + end loop; + Close(f); + exception + when GID.unknown_image_format => + Put_Line(Standard_Error, " Image format is unknown!"); + if Is_Open(f) then + Close(f); + end if; + end Process; + + test_only: Boolean:= False; + +begin + if Argument_Count=0 then + Blurb; + return; + end if; + Put_Line(Standard_Error, "To_BMP, using GID version " & GID.version & " dated " & GID.reference); + begin + Process(default_bkg_name, True, False); + -- if success: + background_image_name:= To_Unbounded_String(default_bkg_name); + exception + when Ada.Text_IO.Name_Error => + null; -- nothing bad, just couldn't find default background + end; + for i in 1..Argument_Count loop + declare + arg: constant String:= Argument(i); + begin + if arg /= "" and then arg(arg'First)='-' then + declare + opt: constant String:= arg(arg'First+1..arg'Last); + begin + if opt = "" then + test_only:= True; + else + Put_Line(Standard_Error, "Background image is " & opt); + Process(opt, True, False); + -- define this only after processing, otherwise + -- a transparent background will try to use + -- an undefined background + background_image_name:= To_Unbounded_String(opt); + end if; + end; + else + Process(arg, False, test_only); + end if; + end; + end loop; +end To_BMP; diff --git a/examples/all_examples.gpr b/examples/all_examples.gpr deleted file mode 100644 index 0877efa8..00000000 --- a/examples/all_examples.gpr +++ /dev/null @@ -1,37 +0,0 @@ -aggregate project All_Examples is - -- this is mainly used to ensure that all examples are still compiling - - for Project_Files use - ("durian/buffers_and_textures/buffers_and_textures.gpr", - "durian/hello/hello_durian.gpr", - "freetype_gl/single_character/render_a_character.gpr", - "freetype_gl/text_rendering/text_rendering.gpr", - "freetype_gl/text_rendering_2/text_rendering_2.gpr", - "ogl_tutorials/02_red_triangle/tutorial_02.gpr", - "ogl_tutorials/03_matrices/tutorial_03.gpr", - "ogl_tutorials/04_coloured_cube/tutorial_04.gpr", - "ogl_tutorials/05_textured_cube/tutorial_05.gpr", - "ogl_tutorials/06_keyboard_mouse/tutorial_06.gpr", - "ogl_tutorials/07_model_loading/tutorial_07.gpr", - "ogl_tutorials/08_basic_shading/tutorial_08.gpr", - "ogl_tutorials/09_vbo_indexing/tutorial_09.gpr", - "ogl_tutorials/external_wave/wave.gpr", - "ogl_tutorials/indexed_model_loading/indexing.gpr", - "ogl_tutorials/misc05_picking_easy/misc_05.gpr", - "open_gl/coloured_elements/element_buffers.gpr", - "open_gl/simple_uniform/simple_uniform.gpr", - "open_gl/square/coloured_square.gpr", - "open_gl/very_simple/simple_triangle.gpr", - "redbook/03_draw_commands/draw_commands.gpr", - "redbook/03_instancing/instancing_example.gpr", - "superbible/fragment_colouring/fragment_colouring.gpr", - "superbible/moving_triangle/moving_triangle.gpr", - "superbible/rotating_squares/rotating_squares.gpr", - "superbible/simple_texture/simple_texture.gpr", - "superbible/simplest/just_a_dot.gpr", - "superbible/spinning_cubes/spinning_cubes.gpr", - "superbible/tess/simple_tessellation.gpr", - "superbible/tessellation_with_geometry/simple_tessellation_with_geometry.gpr", - "superbible/tumbling_squares/tumbling_squares.gpr", - "superbible/vertex_colouring/vertex_colouring.gpr"); -end All_Examples; \ No newline at end of file diff --git a/examples/common/.gitignore b/examples/common/.gitignore deleted file mode 100644 index 41f2e534..00000000 --- a/examples/common/.gitignore +++ /dev/null @@ -1 +0,0 @@ -libcommon.a diff --git a/examples/common/common.gpr b/examples/common/common.gpr deleted file mode 100644 index f8fe0bf9..00000000 --- a/examples/common/common.gpr +++ /dev/null @@ -1,16 +0,0 @@ -with "../../opengl-glfw.gpr"; -with "../../opengl-text.gpr"; -with "../../opengl.gpr"; - -project Common is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Library_Name use "common"; - for Library_Dir use "."; - for Library_Ali_Dir use "lib"; - - package Compiler renames Opengl.Compiler; - -end Common; - diff --git a/examples/common/src/controls.adb b/examples/common/src/controls.adb deleted file mode 100644 index 054f133f..00000000 --- a/examples/common/src/controls.adb +++ /dev/null @@ -1,97 +0,0 @@ - -with Ada.Numerics; - -with GL.Types; use GL.Types; - -with Glfw.Input.Keys; -with Glfw.Input.Mouse; - -with Maths; - -package body Controls is - Half_Pi : constant Single := 0.5 * Ada.Numerics.Pi; - -- Position, position of camera. - Position : GL.Types.Singles.Vector3 := (0.0, 0.0, 5.0); - Horizontal_Angle : Single := Ada.Numerics.Pi; - Vertical_Angle : Single := 0.0; - Initial_View_Angle : constant Maths.Degree := 45.0; - Speed : constant Single := 3.0; -- units per second - Mouse_Speed : constant Single := 0.5; -- orig: 0.005 - Last_Time : Double := Double (Glfw.Time); - - -- ------------------------------------------------------------------------ - - Procedure Compute_Matrices_From_Inputs (Window : in out Glfw.Windows.Window; - Projection_Matrix, View_Matrix : in out GL.Types.Singles.Matrix4) is - use GL.Types.Singles; - use Glfw.Input; - use Maths.Single_Math_Functions; - - Current_Time : constant GL.Types.Double := GL.Types.Double (Glfw.Time); - Delta_Time : constant Single := Single (Current_Time - Last_Time); - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - Half_Window_Width : Single; - Half_Window_Height : Single; - -- GLFW 3 requires setting up a callback for setting - -- View_Angle to Initial_View_Angle - 5.0 * glfwGetMouseWheel(); - -- But this is a bit too complicated for a beginner's tutorial, - -- so it's not implemented in this Tutorial 14. - View_Angle : constant Maths.Degree := Initial_View_Angle; - X_Position : Mouse.Coordinate := 0.00001; - Y_Position : Mouse.Coordinate := 0.00002; - -- Direction, the position of the target with respect to camera. - Direction : Vector3; - Right : Vector3; - Up : Vector3; - begin - Window'Access.Get_Cursor_Pos (X_Position, Y_Position); - Window'Access.Get_Size (Window_Width, Window_Height); - Half_Window_Width := 0.5 * Single (Window_Width); - Half_Window_Height := 0.5 * Single (Window_Height); - - -- Reset the cursor to the center of the screen - -- otherwise it will soon go outside the window. - - Window'Access.Set_Cursor_Pos (Mouse.Coordinate (Half_Window_Width), - Mouse.Coordinate (Half_Window_Height)); - -- For the horizontal angle, Half_Window_Width - xpos means: - -- How far is the mouse from the centre of the window ? - -- The further it is from the centre, the more we want to turn. - -- mouseSpeed is speeds up or slows down the rotations. Fine-tune this at will. - -- If the mouse isn't moved, Half_Window_Width - xpos will be 0, - -- and Horizontal_Angle won't change. - Horizontal_Angle := Horizontal_Angle + - Mouse_Speed * Delta_Time * (Half_Window_Width - Single (X_Position)); - Vertical_Angle := Vertical_Angle + - Mouse_Speed * Delta_Time * (Half_Window_Height - Single (Y_Position)); - - Direction := (Cos (Vertical_Angle) * Sin (Horizontal_Angle), - Sin (Vertical_Angle), - Cos (Vertical_Angle) * Cos (Horizontal_Angle)); - Right := (Sin (Horizontal_Angle - Half_Pi), 0.0, - Cos (Horizontal_Angle - Half_Pi)); - Up := Singles.Cross_Product (Right, Direction); - - if Window'Access.Key_State (Keys.Up) = Pressed then - Position := Position + Direction * Delta_Time * Speed; - elsif Window'Access.Key_State (Keys.Down) = Pressed then - Position := Position - Direction * Delta_Time * Speed; - elsif Window'Access.Key_State (Keys.Right) = Pressed then - Position := Position - Right * Delta_Time * Speed; - elsif Window'Access.Key_State (Keys.Left) = Pressed then - Position := Position + Right * Delta_Time * Speed; - end if; - - Maths.Init_Perspective_Transform (View_Angle, Single (Window_Width), - Single (Window_Height), 0.1, 100.0, - Projection_Matrix); - Maths.Init_Lookat_Transform (Position, Direction, Up, - View_Matrix); - - Last_Time := Current_Time; - end Compute_Matrices_From_Inputs; - - -- ------------------------------------------------------------------------ - -end Controls; diff --git a/examples/common/src/controls.ads b/examples/common/src/controls.ads deleted file mode 100644 index 5a3c375f..00000000 --- a/examples/common/src/controls.ads +++ /dev/null @@ -1,9 +0,0 @@ - -with GL.Types; - -with Glfw.Windows; - -package Controls is - Procedure Compute_Matrices_From_Inputs (Window : in out Glfw.Windows.Window; - Projection_Matrix, View_Matrix : in out GL.Types.Singles.Matrix4); -end Controls; diff --git a/examples/common/src/initialize.adb b/examples/common/src/initialize.adb deleted file mode 100644 index 37f25a89..00000000 --- a/examples/common/src/initialize.adb +++ /dev/null @@ -1,62 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Toggles; - -with Glfw; -with Glfw.Input.Mouse; -with Glfw.Windows; -with Glfw.Windows.Context; -with Glfw.Windows.Hints; - -with Utilities; - -procedure Initialize (Main_Window : in out Glfw.Windows.Window; - Window_Title : String; Show_Data : Boolean := True) is - - procedure Enable_Callbacks is - begin - Main_Window.Enable_Callback (Glfw.Windows.Callbacks.Size); - Main_Window.Enable_Callback (Glfw.Windows.Callbacks.Key); - end Enable_Callbacks; - - -- ------------------------------------------------------------------------ - - procedure Set_Window_Hints is - Min_Major_Version : constant Integer := 3; - Minor_Version : constant Integer := 2; - begin - Glfw.Windows.Hints.Set_Minimum_OpenGL_Version - (Min_Major_Version, Minor_Version); - Glfw.Windows.Hints.Set_Forward_Compat (True); - Glfw.Windows.Hints.Set_Profile (Glfw.Windows.Context.Core_Profile); - Glfw.Windows.Hints.Set_Debug_Context (True); - -- Set samples to 16 before taking screen shots. - Glfw.Windows.Hints.Set_Samples (4); - end Set_Window_Hints; - - -- ------------------------------------------------------------------------ - - Window_Width : constant Glfw.Size := 800; - Window_Height : constant Glfw.Size := 600; - Cursor : constant Glfw.Input.Mouse.Cursor_Mode := - Glfw.Input.Mouse.Hidden; -begin - Set_Window_Hints; - Main_Window.Init (Window_Width, Window_Height, Window_Title); - Glfw.Windows.Context.Make_Current (Main_Window'Access); - Enable_Callbacks; - -- The following default settings can be overriden by th user's - -- setup code if necessary - Main_Window.Set_Cursor_Mode (Cursor); - GL.Toggles.Disable (GL.Toggles.Blend); - if Show_Data then - Utilities.Show_GL_Data; - end if; - -exception - when others => - Put_Line ("An exception occurred in Initialize."); - raise; - -end Initialize; diff --git a/examples/common/src/initialize.ads b/examples/common/src/initialize.ads deleted file mode 100644 index eb1e35bc..00000000 --- a/examples/common/src/initialize.ads +++ /dev/null @@ -1,4 +0,0 @@ -with Glfw.Windows; - -procedure Initialize (Main_Window : in out Glfw.Windows.Window; - Window_Title : String; Show_Data : Boolean := True); diff --git a/examples/common/src/load_dds.adb b/examples/common/src/load_dds.adb deleted file mode 100644 index 818be630..00000000 --- a/examples/common/src/load_dds.adb +++ /dev/null @@ -1,210 +0,0 @@ - --- This version of DDS loading procedure only supports compressed --- DDS files. - -with Ada.IO_Exceptions; -with Ada.Streams.Stream_IO; -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Types; -with GL.Objects.Textures.Targets; -with GL.Pixels; - --- Based on SOIL.adb Direct_Load_DDS -procedure Load_DDS (File_Name : String; - theTexture : out GL.Objects.Textures.Texture) is - - type DDS_Data is array (GL.Types.UInt range <>) of GL.Types.UByte; - - type DDS_Header is record - Magic : String (1 .. 4); - Height : GL.Types.UInt; - Width : GL.Types.UInt; - Linear_Size : GL.Types.UInt; - Mip_Map_Count : GL.Types.UInt; - Four_CC : String (1 .. 4); - Byte_Size : GL.Types.UInt := 128; -- bytes - end record; - - -- ------------------------------------------------------------------------- - - Header_Error : exception; - Image_Error : exception; - - -- ------------------------------------------------------------------------- - - procedure Load_DDS_Header (File_ID : Ada.Streams.Stream_IO.File_Type; - Header : out DDS_Header); - procedure Load_DDS_Data (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : DDS_Header; - theTexture : out GL.Objects.Textures.Texture); - - procedure Load_Mipmaps (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : DDS_Header; - Block_Size : GL.Types.UInt; - Format : GL.Pixels.Internal_Format); - function Test_DW_Four_CC (DW_Four_CC : String) return boolean; - - -- ------------------------------------------------------------------------ - - procedure Load_DDS_Data (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : DDS_Header; - theTexture : out GL.Objects.Textures.Texture) is - use GL.Objects.Textures; - use GL.Pixels; - use GL.Types; - - Block_Size : UInt; - Format : GL.Pixels.Internal_Format; - begin - if Header.Four_CC = "DXT1" then - Format := Compressed_RGBA_S3TC_DXT1; - elsif Header.Four_CC = "DXT3" then - Format := Compressed_RGBA_S3TC_DXT3; - elsif Header.Four_CC = "DXT5" then - Format := Compressed_RGBA_S3TC_DXT5; - else - Put_Line ("Load_DSS_Data; Invalid S3TC_Type. Four_CC: " - & Header.Four_CC); - raise Image_Error; - end if; - - theTexture.Initialize_Id; - Targets.Texture_2D.Bind (theTexture); - GL.Pixels.Set_Pack_Alignment (GL.Pixels.Bytes); - - if Format = GL.Pixels.Compressed_RGBA_S3TC_DXT1 then - Block_Size := 8; - else - Block_Size := 16; - end if; - - Load_Mipmaps (Data_Stream, Header, Block_Size, Format); - - exception - when others => - Put_Line ("An exception occurred in Load_DDS_Data."); - raise; - end Load_DDS_Data; - - -- ------------------------------------------------------------------------ - - procedure Load_DDS_Header (File_ID : Ada.Streams.Stream_IO.File_Type; - Header : out DDS_Header) is - use Ada.Streams.Stream_IO; - use GL.Types; - - Header_Stream : constant Stream_Access := Stream (File_ID); - begin - String'Read (Header_Stream, Header.Magic); - Set_Index (File_ID, Index (File_ID) + 8); - UInt'Read (Header_Stream, Header.Height); - UInt'Read (Header_Stream, Header.Width); - UInt'Read (Header_Stream, Header.Linear_Size); - Set_Index (File_ID, Index (File_ID) + 4); - UInt'Read (Header_Stream, Header.Mip_Map_Count); - Set_Index (File_ID, Index (File_ID) + 52); - String'Read (Header_Stream, Header.Four_CC); - - if Header.Magic /= "DDS " then - Put_Line ("Load_DSS_Header; File is not a DDS file"); - raise Header_Error; - end if; - - if not Test_DW_Four_CC (Header.Four_CC) then - Put_Line ("Load_DSS_Header; invalid FourCC: " & Header.Four_CC); - raise Header_Error; - end if; - - exception - when others => - Put_Line ("An exception occurred in Load_DDS_Header."); - raise; - end Load_DDS_Header; - - -- ------------------------------------------------------------------------ - - procedure Load_Mipmaps (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : DDS_Header; - Block_Size : GL.Types.UInt; - Format : GL.Pixels.Internal_Format) is - use Ada.Streams.Stream_IO; - use GL.Objects.Textures; - use GL.Types; - - Width : Int := Int (Header.Width); - Height : Int := Int (Header.Height); - Mip_Size : UInt := UInt (((Width + 3) / 4) * ((Height + 3) / 4)) * Block_Size; - Level : Int := 0; - Continue : Boolean := Width > 1 and then Height > 1; - begin - while Continue and then Level < Int (Header.Mip_Map_Count) loop - Mip_Size := UInt (((Width + 3) / 4) * ((Height + 3) / 4)) * Block_Size; - -- Load Compressed_Tex_Image_2D into the 2D texture - declare - Mip_Data : DDS_Data (1 .. Mip_Size); - begin - DDS_Data'Read (Data_Stream, Mip_Data); - Targets.Texture_2D.Load_Compressed (Level, Format, Width, Height, - Int (Mip_Size), - Image_Source (Mip_Data'Address)); - end; - - Continue := Width > 1 and then Height > 1; - if Continue then - Level := Level + 1; - Width := Width / 2; - Height := Height / 2; - -- Deal with Non-Power-Of-Two textures. - if Width < 1 then - Width := 1; - end if; - if Height < 1 then - Height := 1; - end if; - end if; - end loop; - exception - when others => - Put_Line ("An exception occurred in Load_Mipmaps."); - raise; - end Load_Mipmaps; - - -- ------------------------------------------------------------------------ - - function Test_DW_Four_CC (DW_Four_CC : String) return boolean is - begin - return DW_Four_CC = "DXT1" or else - DW_Four_CC = "DXT3" or else - DW_Four_CC = "DXT5"; - end Test_DW_Four_CC; - - -- ------------------------------------------------------------------------ - - use GL.Types; - use Ada.Streams.Stream_IO; - - File_ID : Ada.Streams.Stream_IO.File_Type; - Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : DDS_Header; -begin - Open (File_ID, In_File, File_Name); - Load_DDS_Header (File_ID, Header); - if UInt (Ada.Streams.Stream_IO.Size (File_ID)) <= Header'Size then - Put_Line ("Load_DDS; The file " & File_Name & " is too small."); - raise Header_Error; - else - Set_Index (File_ID, Ada.Streams.Stream_IO.Count (Header.Byte_Size) + 1); - Data_Stream := Stream (File_ID); - Load_DDS_Data (Data_Stream, Header, theTexture); - end if; - -exception - when Ada.IO_Exceptions.Name_Error => - -- File not found - Put_Line ("Load_DDS can't find the file " & File_Name & "!"); - raise; - when others => - Put_Line ("An exception occurred in Load_DDS."); - raise; -end Load_DDS; diff --git a/examples/common/src/load_dds.ads b/examples/common/src/load_dds.ads deleted file mode 100644 index 1adde4f3..00000000 --- a/examples/common/src/load_dds.ads +++ /dev/null @@ -1,8 +0,0 @@ - --- This version of DDS loading procedure only supports compressed --- DDS files. - -with GL.Objects.Textures; - - procedure Load_DDS (File_Name : String; - theTexture : out GL.Objects.Textures.Texture); diff --git a/examples/common/src/load_object_file.adb b/examples/common/src/load_object_file.adb deleted file mode 100644 index 69f27d28..00000000 --- a/examples/common/src/load_object_file.adb +++ /dev/null @@ -1,320 +0,0 @@ - -with Ada.IO_Exceptions; -with Ada.Float_Text_IO; -with Ada.Integer_Text_IO; -with Ada.Strings.Unbounded; -with Ada.Text_IO; use Ada.Text_IO; -with Ada.Text_IO.Unbounded_IO; - -package body Load_Object_File is - - procedure Parse (Mesh_String : Ada.Strings.Unbounded.Unbounded_String; - Vertex_Index, UV_Index, Normal_Index : out GL.Types.Ints.Vector3); - procedure Parse (UV_String : Ada.Strings.Unbounded.Unbounded_String; - UV : out GL.Types.Singles.Vector2; DDS_Format : Boolean := True); - procedure Parse (Vertex_String : Ada.Strings.Unbounded.Unbounded_String; - Vertex : out GL.Types.Singles.Vector3); - procedure Read_Index (Data : Ada.Strings.Unbounded.Unbounded_String; - Start : in out Positive; Index : out GL.Types.Int); - - -- ------------------------------------------------------------------------- - - procedure Data_From_Faces (Raw_Vertices : GL.Types.Singles.Vector3_Array; - Raw_UVs : GL.Types.Singles.Vector2_Array; - Raw_Normals : GL.Types.Singles.Vector3_Array; - Vertex_Indices, UV_Indices, Normal_Indices : - GL.Types.Ints.Vector3_Array; - Mesh_Vertices : out GL.Types.Singles.Vector3_Array; - Mesh_UVs : out GL.Types.Singles.Vector2_Array; - Mesh_Normals : out GL.Types.Singles.Vector3_Array) is - use GL; - use GL.Types; - -- The three elements of a Vertex_Index refer to the three vertices - -- of a triangle - Raw_Vertex_Indices : Ints.Vector3; - Raw_UVs_Indices : Ints.Vector3; - Raw_Normals_Indices : Ints.Vector3; - Raw_Vertex_Index : Int; - Raw_UVs_Index : Int; - Raw_Normal_Index : Int; - Mesh_Index : Int := 0; - begin - for Index in UV_Indices'Range loop - -- Get vector of three indices, one for each vertex of a triangle - Raw_Vertex_Indices := Vertex_Indices (Index); - Raw_UVs_Indices := UV_Indices (Index); - Raw_Normals_Indices := Normal_Indices (Index); - for elem in Index_3D'Range loop - Mesh_Index := Mesh_Index + 1; - -- for each vertex of a triangle, get the vertex index - Raw_Vertex_Index := Raw_Vertex_Indices (elem); - Raw_UVs_Index := Raw_UVs_Indices (elem); - Raw_Normal_Index := Raw_Normals_Indices (elem); - -- for each vertex of a triangle, get the vertex components (x, y, z) - Mesh_Vertices (Mesh_Index) := Raw_Vertices (Raw_Vertex_Index); - Mesh_UVs (Mesh_Index) := Raw_UVs (Raw_UVs_Index); - Mesh_Normals (Mesh_Index) := Raw_Normals (Raw_Normal_Index); - end loop; - end loop; - end Data_From_Faces; - - -- ------------------------------------------------------------------------- - - procedure Get_Array_Sizes (File_Name : String; Vertex_Count, UV_Count, - Normal_Count, Indices_Count : out GL.Types.Int; - Mesh_Count, Usemtl_Count : out Integer) is - use Ada.Strings.Unbounded; - use GL.Types; - File_ID : Ada.Text_IO.File_Type; - Text : Unbounded_String; - Label : String (1 .. 2); - begin - Vertex_Count := 0; - UV_Count := 0; - Normal_Count := 0; - Indices_Count := 0; - Mesh_Count := 0; - Usemtl_Count := 0; - Open (File_ID, In_File, File_Name); - while not End_Of_File (File_ID) loop - Text := To_Unbounded_String (Get_Line (File_ID)); - Label := To_String (Text) (1 .. 2); - case Label (1) is - when 'v' => - case Label (2) is - when ' ' => Vertex_Count := Vertex_Count + 1; - when 't' => UV_Count := UV_Count + 1; - when 'n' => Normal_Count := Normal_Count + 1; - when others => null; - end case; - when 's' => Mesh_Count := Mesh_Count + 3; - when 'u' => Usemtl_Count := Usemtl_Count + 1; - when 'f' => Indices_Count := Indices_Count + 1; - when others => null; - end case; - end loop; - Close (File_ID); - - exception - when Ada.IO_Exceptions.Name_Error => - -- File not found - Put_Line ("Get_Array_Sizes can't find the file " & File_Name & "!"); - raise; - when others => - Put_Line ("An exception occurred in Get_Array_Sizes."); - raise; - end Get_Array_Sizes; - - -- ------------------------------------------------------------------------- - - procedure Load_Data (File_ID : Ada.Text_IO.File_Type; - Vertices : in out GL.Types.Singles.Vector3_Array; - UVs : in out GL.Types.Singles.Vector2_Array; - Normals : in out GL.Types.Singles.Vector3_Array; - Vertex_Indicies, UV_Indicies, Normal_Indicies : - in out GL.Types.Ints.Vector3_Array) is - use Ada.Strings.Unbounded; - use GL.Types; - Line : Unbounded_String; - Data : Unbounded_String; - Label : String (1 .. 2); - Vertex_Index : Int := 0; - UV_Index : Int := 0; - Normal_Index : Int := 0; - Mesh_Vertice_Index : Int := 0; - begin - while not End_Of_File (File_ID) loop - Ada.Text_IO.Unbounded_IO.Get_Line (File_ID, Line); - Label := To_String (Line) (1 .. 2); - Data := Unbounded_Slice (Line, 2, To_String (Line)'Length); - case Label (1) is - when 'v' => - case Label (2) is - when ' ' => Vertex_Index := Vertex_Index + 1; - Parse (Data, Vertices (Vertex_Index)); - when 't' => UV_Index := UV_Index + 1; - Data := Unbounded_Slice (Line, 3, To_String (Line)'Length); - Parse (Data, UVs (UV_Index)); - when 'n' => Normal_Index := Normal_Index + 1; - Data := Unbounded_Slice (Line, 3, To_String (Line)'Length); - Parse (Data, Normals (Normal_Index)); - when others => null; - end case; - when 's' => null; - when 'u' => null; - when 'f' => Mesh_Vertice_Index := Mesh_Vertice_Index + 1; - Parse (Data, Vertex_Indicies (Mesh_Vertice_Index), - UV_Indicies (Mesh_Vertice_Index), - Normal_Indicies (Mesh_Vertice_Index)); - when others => null; - end case; - end loop; - end Load_Data; - - -- ------------------------------------------------------------------------- - - procedure Load_Object (File_Name : String; - Vertices : out GL.Types.Singles.Vector3_Array; - UVs : out GL.Types.Singles.Vector2_Array; - Normals : out GL.Types.Singles.Vector3_Array) is - Text_File_ID : Ada.Text_IO.File_Type; - Num_Vertices : GL.Types.Int; - UV_Count : GL.Types.Int; - Normal_Count : GL.Types.Int; - Mesh_Count : Integer; - Usemtl_Count : Integer; - Vertex_Count : GL.Types.Int; - begin - Get_Array_Sizes (File_Name, Num_Vertices, UV_Count, Normal_Count, - Vertex_Count, Mesh_Count, Usemtl_Count); - declare - use GL.Types; - Raw_Vertices : Singles.Vector3_Array (1 .. Num_Vertices); - Raw_UVs : Singles.Vector2_Array (1 .. UV_Count); - Raw_Normals : Singles.Vector3_Array (1 .. Normal_Count); - Vertex_Indices : Ints.Vector3_Array (1 .. Vertex_Count); - UV_Indices : Ints.Vector3_Array (1 .. Vertex_Count); - Normal_Indices : Ints.Vector3_Array (1 .. Vertex_Count); - begin - Open (Text_File_ID, In_File, File_Name); - Load_Data (Text_File_ID, Raw_Vertices, Raw_UVs, Raw_Normals, - Vertex_Indices, UV_Indices, Normal_Indices); - Close (Text_File_ID); - - if Vertex_Count > 0 then - Data_From_Faces (Raw_Vertices, Raw_UVs, Raw_Normals, - Vertex_Indices, UV_Indices, Normal_Indices, - Vertices, UVs, Normals); - end if; - end; - - exception - when Ada.IO_Exceptions.Name_Error => - -- File not found - Put_Line ("Load_Object can't find the file " & File_Name & "!"); - raise; - when others => - Put_Line ("An exception occurred in Load_Object."); - raise; - end Load_Object; - - -- ------------------------------------------------------------------------- - - procedure Load_Object (File_Name : String; - Vertices : out GL.Types.Singles.Vector3_Array; - UVs : out GL.Types.Singles.Vector2_Array) is - begin - declare - Normals : GL.Types.Singles.Vector3_Array (1 .. Mesh_Size (File_Name)); - begin - Load_Object (File_Name, Vertices, UVs, Normals); - end; - end Load_Object; - - -- ------------------------------------------------------------------------- - - function Mesh_Size (File_Name : String) return GL.Types.Int is - use Ada.Strings.Unbounded; - use GL.Types; - File_ID : Ada.Text_IO.File_Type; - Mesh_Vertex_Count : Int := 0; - Text : Unbounded_String; - Label : String (1 .. 2); - begin - Open (File_ID, In_File, File_Name); - while not End_Of_File (File_ID) loop - Text := To_Unbounded_String (Get_Line (File_ID)); - Label := To_String (Text) (1 .. 2); - if Label (1) = 'f' then - Mesh_Vertex_Count := Mesh_Vertex_Count + 3; - end if; - end loop; - Close (File_ID); - return Mesh_Vertex_Count; - - exception - when Ada.IO_Exceptions.Name_Error => - -- File not found - Put_Line ("Mesh_Size can't find the file " & File_Name & "!"); - raise; - when others => - Put_Line ("An exception occurred in Mesh_Size."); - raise; - end Mesh_Size; - - -- ------------------------------------------------------------------------- - - procedure Parse (Mesh_String : Ada.Strings.Unbounded.Unbounded_String; - Vertex_Index, UV_Index, Normal_Index : out GL.Types.Ints.Vector3) is - Start : Positive := 1; - begin - for indice in GL.Index_3D loop - Read_Index (Mesh_String, Start, Vertex_Index (indice)); - Read_Index (Mesh_String, Start, UV_Index (indice)); - Read_Index (Mesh_String, Start, Normal_Index (indice)); - end loop; - end Parse; - - -- ------------------------------------------------------------------------- - - procedure Parse (UV_String : Ada.Strings.Unbounded.Unbounded_String; - UV : out GL.Types.Singles.Vector2; DDS_Format : Boolean := True) is - use Ada.Strings.Unbounded; - use GL.Types; - Next : Natural := 1; - Size : constant Natural := Length (UV_String); - Value : Float; - begin - Ada.Float_Text_IO.Get (To_String (UV_String) (Next .. Size), Value, Next); - UV (GL.X) := Single (Value); - Next := Next + 1; - Ada.Float_Text_IO.Get (To_String (UV_String)(Next .. Size), Value, Next); - UV (GL.Y) := Single (Value); - -- Invert V coordinate since we will only use DDS texture which are inverted. - -- Remove if you want to use TGA or BMP loaders. - if DDS_Format then - UV (GL.Y) := -UV (GL.Y); - end if; - end Parse; - - -- ------------------------------------------------------------------------- - - procedure Parse (Vertex_String : Ada.Strings.Unbounded.Unbounded_String; - Vertex : out GL.Types.Singles.Vector3) is - use Ada.Strings.Unbounded; - Next : Natural := 1; - Size : constant Natural := Length (Vertex_String); - Value : float; - begin - Ada.Float_Text_IO.Get (To_String (Vertex_String) (Next .. Size), Value, Next); - Vertex (GL.X) := GL.Types.Single (Value); - Next := Next + 1; - Ada.Float_Text_IO.Get (To_String (Vertex_String) (Next .. Size), Value, Next); - Next := Next + 1; - Vertex (GL.Y) := GL.Types.Single (Value); - Ada.Float_Text_IO.Get (To_String (Vertex_String) (Next .. Size), Value, Next); - Vertex (GL.Z) := GL.Types.Single (Value); - end Parse; - - -- ------------------------------------------------------------------------- - - Procedure Read_Index (Data : Ada.Strings.Unbounded.Unbounded_String; - Start : in out Positive; Index : out GL.Types.Int) is - use Ada.Strings.Unbounded; - Size : constant Natural := Length (Data); - Pos : Positive := Start; - Last_Pos : Positive; - Value : Integer; - begin - if Element (Data, Start) = '/' then - Pos := Pos + 1; - end if; - - Ada.Integer_Text_IO.Get (To_String (Data)(Pos .. Size), Value, Last_Pos); - Index := GL.Types.Int (Value); - Start := Last_Pos + 1; - end Read_Index; - - -- ------------------------------------------------------------------------- - -end Load_Object_File; diff --git a/examples/common/src/load_object_file.ads b/examples/common/src/load_object_file.ads deleted file mode 100644 index 26670eff..00000000 --- a/examples/common/src/load_object_file.ads +++ /dev/null @@ -1,15 +0,0 @@ - -with GL.Types; - -package Load_Object_File is - - procedure Load_Object (File_Name : String; - Vertices : out GL.Types.Singles.Vector3_Array; - UVs : out GL.Types.Singles.Vector2_Array; - Normals : out GL.Types.Singles.Vector3_Array); - procedure Load_Object (File_Name : String; - Vertices : out GL.Types.Singles.Vector3_Array; - UVs : out GL.Types.Singles.Vector2_Array); - function Mesh_Size (File_Name : String) return GL.Types.Int; - -end Load_Object_File; diff --git a/examples/common/src/load_vb_object.adb b/examples/common/src/load_vb_object.adb deleted file mode 100644 index aa184b7c..00000000 --- a/examples/common/src/load_vb_object.adb +++ /dev/null @@ -1,452 +0,0 @@ - -with Interfaces.C.Pointers; - -with Ada.IO_Exceptions; -with Ada.Streams.Stream_IO; -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; - -package body Load_VB_Object is - - type Image_Data is array (UInt range <>) of aliased UByte; - package Image_Data_Pointers is new - Interfaces.C.Pointers (UInt, UByte, Image_Data, UByte'Last); - - procedure Load_Image_Data is new - GL.Objects.Buffers.Load_To_Buffer (Image_Data_Pointers); - - UInt_Size : constant UInt := UInt'Size / 8; - Single_Size : constant UInt := Single'Size / 8; -- GLfloat - UShort_Size : constant UInt := UShort'Size / 8; - - procedure Load_Indices (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : VBM_Header; - Object : in out VB_Object); - procedure Load_Materials (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : VBM_Header; - Object : in out VB_Object); - procedure Load_Textures (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : VBM_Header; - Object : in out VB_Object); - procedure Load_VBM_Header (Header_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : out VBM_Header; - Byte_Count : in out UInt); - procedure Set_Attribute_Pointers (VBM_Object : VB_Object; - Vertex_Index, Normal_Index, Tex_Coord0_Index : Int); --- function To_Vector4_Array (Raw_Data : Image_Data; Num_Vertices : UInt) --- return GL.Types.Singles.Vector4_Array; - - -- ------------------------------------------------------------------------ - - function Get_Vertex_Count (Object : VB_Object; Frame_Index : UInt := 1) return Int is - Count : UInt := 0; - Frame : VBM_Frame_Header; - begin - if Object.Header.Num_Frames > 0 then - if Frame_Index > 0 and then - Frame_Index <= Object.Header.Num_Frames then - Frame := Object.Frame_Headers.Element (Integer (Frame_Index)); - Count := Frame.Num_Vertices; - else - Put_Line ("Load_VB_Object.Get_Vertex_Count, invalid frame index: " & - UInt'Image (Frame_Index)); - end if; - else - Put_Line ("Load_VB_Object.Get_Vertex_Count, no frames are available."); - end if; - return Int (Count); - - exception - when others => - Put_Line ("An exception occurred in Load_VB_Object.Get_Vertex_Count."); - raise; - end Get_Vertex_Count; - - -- ------------------------------------------------------------------------ - - procedure Load_From_VBM (File_Name : String; VBM_Object : in out VB_Object; - Vertex_Index, Normal_Index, Tex_Coord0_Index : Int; - Result : out Boolean) is - use Ada.Streams.Stream_IO; - use GL.Objects; - use GL.Objects.Buffers; - - File_ID : Ada.Streams.Stream_IO.File_Type; - Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : VBM_Header; - Attributes_Header : VBM_Attributes_Header; - Frame_Header : VBM_Frame_Header; - Total_Data_Size : UInt := 0; - Byte_Count : UInt := 0; - begin - Result := False; - VBM_Object.Vertex_Array.Initialize_Id; - VBM_Object.Vertex_Array.Bind; - VBM_Object.Attribute_Buffer.Initialize_Id; - Array_Buffer.Bind (VBM_Object.Attribute_Buffer); - - Open (File_ID, In_File, File_Name); - Data_Stream := Stream (File_ID); - --- VBM_Header'Read (Data_Stream, VBM_Object.Header); - Load_VBM_Header (Data_Stream, Header, Byte_Count); - VBM_Object.Header := Header; - -- Load attribute headers - for count in 1 .. VBM_Object.Header.Num_Attributes loop - VBM_Attributes_Header'Read (Data_Stream, Attributes_Header); - VBM_Object.Attribute_Headers.Append (Attributes_Header); - Total_Data_Size := Total_Data_Size + - Attributes_Header.Components * VBM_Object.Header.Num_Vertices * Single_Size; - end loop; - - -- Load frame headers - for count in 1 .. VBM_Object.Header.Num_Frames loop - VBM_Frame_Header'Read (Data_Stream, Frame_Header); - VBM_Object.Frame_Headers.Append (Frame_Header); - end loop; - - Print_VBM_Object_Data ("VBM_Object", VBM_Object); - declare - Raw_Data : Image_Data (1 .. Total_Data_Size); - -- Image_Data is an array of bytes - begin - -- Read rest of file. - Image_Data'Read (Data_Stream, Raw_Data); - VBM_Object.Attribute_Buffer.Initialize_Id; - Array_Buffer.Bind (VBM_Object.Attribute_Buffer); - Load_Image_Data (Array_Buffer, Raw_Data, Static_Draw); - - Set_Attribute_Pointers (VBM_Object, Vertex_Index, Normal_Index, - Tex_Coord0_Index); - Load_Indices (Data_Stream, VBM_Object.Header, VBM_Object); - - -- unbind the current array object - GL.Objects.Vertex_Arrays.Null_Array_Object.Bind; - - Load_Materials (Data_Stream, VBM_Object.Header, VBM_Object); - end; -- declare block - Close (File_ID); - Result := True; - - exception - when Ada.IO_Exceptions.Name_Error => - -- File not found - Put_Line ("Load_From_VBM can't find the file " & File_Name & "!"); - raise; - when others => - Put_Line ("An exception occurred in Load_VB_Object.Load_From_VBM."); - raise; - end Load_From_VBM; - - -- ------------------------------------------------------------------------ - - procedure Load_Indices (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : VBM_Header; - Object : in out VB_Object) is - use GL.Objects.Buffers; - Element_Size : UInt; - Element_Data_Size : UInt; - begin - if Header.Num_Indices > 0 then - case Header.Index_Type is - when UShort_Type => Element_Size := UShort_Size; - when UInt_Type => Element_Size := UInt_Size; - when others => - Put_Line ("Load_VB_Object.Load_Indices, invalid Index_Type."); - end case; - - Element_Data_Size := Header.Num_Indices * Element_Size; - Object.Index_Buffer.Initialize_Id; - Element_Array_Buffer.Bind (Object.Index_Buffer); - declare - Indices_Array : Image_Data (1 .. Element_Data_Size); - begin - Image_Data'Read (Data_Stream, Indices_Array); - Load_Image_Data (Element_Array_Buffer, Indices_Array, Static_Draw); - end; -- declare block - end if; - - exception - when others => - Put_Line ("An exception occurred in Load_VB_Object.Load_Indices."); - raise; - end Load_Indices; - - -- ------------------------------------------------------------------------ - - procedure Load_Materials (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : VBM_Header; - Object : in out VB_Object) is Material_Record : VBM_Material; - Record_Count : UInt := 0; - Materials_Data_Size : UInt; - begin - if Header.Num_Materials > 0 then - Materials_Data_Size := Header.Num_Materials * VBM_Material'Size / 8; - while Record_Count < Materials_Data_Size loop - Record_Count := Record_Count + 1; - if not End_Of_File then - VBM_Material'Read (Data_Stream, Material_Record); - Object.Materials.Append (Material_Record); - else - Put_Line ("Load_Materials; EOF reached before Materials loading completed."); - end if; - end loop; - Load_Textures (Data_Stream, Header, Object); - end if; - - exception - when others => - Put_Line ("An exception occurred in Load_VB_Object.Load_Materials."); - raise; - end Load_Materials; - - -- ------------------------------------------------------------------------ - - procedure Load_Textures (Data_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : VBM_Header; - Object : in out VB_Object) is - Texture_Record : Material_Texture; - Record_Count : UInt := 0; - Textures_Data_Size : UInt; - begin - Textures_Data_Size := Header.Num_Materials * Material_Texture'Size / 8; - while Record_Count < Textures_Data_Size loop - Record_Count := Record_Count + 1; - if not End_Of_File then - Material_Texture'Read (Data_Stream, Texture_Record); - Object.Material_Textures.Append (Texture_Record); - else - Put_Line ("Load_Textures; EOF reached before Materials completed."); - end if; - end loop; - - if not End_Of_File then - Put_Line ("Load_Textures, Materials filled before EOF."); - end if; - - exception - when others => - Put_Line ("An exception occurred in Load_VB_Object.Load_Textures."); - raise; - end Load_Textures; - - -- ------------------------------------------------------------------------ - - procedure Load_VBM_Header (Header_Stream : Ada.Streams.Stream_IO.Stream_Access; - Header : out VBM_Header; - Byte_Count : in out UInt) is - use Ada.Streams.Stream_IO; - Magic : UInt; - Index_Type : UInt := 0; - begin - UInt'Read (Header_Stream, Magic); - Byte_Count := Byte_Count + UInt_Size; - declare - Head : VBM_Header (Magic); - begin - UInt'Read (Header_Stream, Head.Size); - Byte_Count := Byte_Count + UInt_Size; - String'Read (Header_Stream, Head.Name); - Byte_Count := Byte_Count + 64; - UInt'Read (Header_Stream, Head.Num_Attributes); - Byte_Count := Byte_Count + UInt_Size; - UInt'Read (Header_Stream, Head.Num_Frames); - Byte_Count := Byte_Count + UInt_Size; - if Header.Magic /= New_Header_Magic then - UInt'Read (Header_Stream, Head.Num_Chunks); - Byte_Count := Byte_Count + UInt_Size; - end if; - UInt'Read (Header_Stream, Head.Num_Vertices); - Byte_Count := Byte_Count + UInt_Size; - UInt'Read (Header_Stream, Head.Num_Indices); - Byte_Count := Byte_Count + UInt_Size; - UInt'Read (Header_Stream, Index_Type); - if Index_Type /= 0 then - Head.Index_Type := Numeric_Type'Enum_Val (Index_Type); - end if; - Byte_Count := Byte_Count + UInt_Size; - if Byte_Count < Head.Size then - UInt'Read (Header_Stream, Head.Num_Materials); - Byte_Count := Byte_Count + UInt_Size; - if Byte_Count < Head.Size then - UInt'Read (Header_Stream, Head.Flags); - Byte_Count := Byte_Count + UInt_Size; - end if; - end if; - Header := Head; - end; - - exception - when others => - Put_Line ("An exception occurred in Load_VB_Object.Load_VBM_Header."); - raise; - end Load_VBM_Header; - --- -- ------------------------------------------------------------------------ - - procedure Print_Attributes_Header (Message : String; Object : VB_Object; - Attributes_Index : UInt) is - Attributes : VBM_Attributes_Header; - begin - if Attributes_Index < Object.Header.Num_Attributes then - Attributes := Object.Attribute_Headers.Element (Natural (Attributes_Index)); - Put_Line (Message); - Put_Line ("Name: " & Attributes.Name); - Put_Line ("Type: " & Numeric_Type'Image (Attributes.Attribute_Type)); - Put_Line ("Components: " & UInt'Image (Attributes.Components)); - Put_Line ("Flags: " & UInt'Image (Attributes.Flags)); - else - Put_Line ("Load_VB_Object.Print_Attributes_Header, invalid attribute index: " & - UInt'Image (Attributes_Index)); - end if; - New_Line; - end Print_Attributes_Header; - - -- ------------------------------------------------------------------------ - - procedure Print_VBM_Frame_Data (Message : String; Object : VB_Object; - Frame_Index : UInt) is - Frame : VBM_Frame_Header; - begin - if Frame_Index > 0 and then Frame_Index <= Object.Header.Num_Frames then - Frame := Object.Frame_Headers.Element (Natural (Frame_Index)); - Put_Line (Message); - Put_Line ("First: " & UInt'Image (Frame.First)); - Put_Line ("Vertices: " & UInt'Image (Frame.Num_Vertices)); - Put_Line ("Flags: " & UInt'Image (Frame.Flags)); - else - Put_Line ("Load_VB_Object.Print_VBM_Frame_Data, invalid frame index: " & - UInt'Image (Frame_Index)); - end if; - New_Line; - end Print_VBM_Frame_Data; - - -- ------------------------------------------------------------------------ - - procedure Print_VBM_Object_Data (Message : String; Object : VB_Object) is - begin - Put_Line (Message); - - Put_Line ("Header.Size: " & UInt'Image (Object.Header.Size)); - Put_Line ("Number of attributes: " & UInt'Image (Object.Header.Num_Attributes)); - Put_Line ("Number of frames: " & UInt'Image (Object.Header.Num_Frames)); - Put_Line ("Number of vertices: " & UInt'Image (Object.Header.Num_Vertices)); - Put_Line ("Number of indices: " & UInt'Image (Object.Header.Num_Indices)); - Put_Line ("Index type: " & Numeric_Type'Image (Object.Header.Index_Type)); - Put_Line ("Number of Materials: " & UInt'Image (Object.Header.Num_Materials)); - Put_Line ("Flags: " & UInt'Image (Object.Header.Flags)); - New_Line; - - end Print_VBM_Object_Data; - - -- ------------------------------------------------------------------------ - - procedure Render (VBM_Object : VB_Object; - Frame_Index : UInt := 1; Instances : UInt := 0) is - use GL.Objects.Buffers; - use GL.Objects; - Frame : VBM_Frame_Header; - begin - if Frame_Index > 0 and then Frame_Index <= VBM_Object.Header.Num_Frames then - VBM_Object.Vertex_Array.Bind; - Frame := VBM_Object.Frame_Headers.Element (Natural (Frame_Index)); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - if Instances > 0 then - if VBM_Object.Header.Num_Indices > 0 then - Draw_Elements_Instanced (Triangles, Frame.Num_Vertices, - GL.Types.UInt_Type, Frame.First); - else - Vertex_Arrays.Draw_Arrays_Instanced - (Triangles, Int (Frame.First), Int (Frame.Num_Vertices), - Int (Instances)); - end if; - else - if VBM_Object.Header.Num_Indices > 0 then - Put_Line ("Load_VB_Object.Render Num_Indices > 0"); - null; - else - GL.Attributes.Set_Vertex_Attrib_Pointer (0, 4, Single_Type, - False, 0, 0); - Vertex_Arrays.Draw_Arrays (Triangles, 0, Int (Frame.Num_Vertices)); - GL.Attributes.Disable_Vertex_Attrib_Array (0); - end if; - end if; - Vertex_Arrays.Null_Array_Object.Bind; - else - Put_Line ("Load_VB_Object.Render, invalid frame index: " & - UInt'Image (Frame_Index)); - end if; - - exception - when others => - Put_Line ("An exception occurred in Load_VB_Object.Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Set_Attribute_Pointers (VBM_Object : VB_Object; - Vertex_Index, Normal_Index, Tex_Coord0_Index : Int) is - use GL.Attributes; - Attribute_Index : Attribute; -- UInt - Attribute_Data : VBM_Attributes_Header; - Data_Offset : Int := 0; -- Offset into buffer - begin - for Index in 0 .. VBM_Object.Header.Num_Attributes - 1 loop - Attribute_Data := VBM_Object.Attribute_Headers.Element (Natural (Index)); - case Index is - when 0 => Attribute_Index := Attribute (Vertex_Index); -- Vertices - when 1 => Attribute_Index := Attribute (Normal_Index); -- Indices - when 2 => Attribute_Index := Attribute (Tex_Coord0_Index); -- Texture coordinates - when others => - Put_Line ("Load_VB_Object.Set_Attributes, invalid attribute index."); - end case; - - GL.Attributes.Set_Vertex_Attrib_Pointer - (Index => Attribute_Index, - Count => Int (Attribute_Data.Components), - Kind => Attribute_Data.Attribute_Type, - Normalized => False, - Stride => 0, Offset => Data_Offset); - GL.Attributes.Enable_Vertex_Attrib_Array (Attribute_Index); - Data_Offset := Data_Offset + - Int (Attribute_Data.Components * VBM_Object.Header.Num_Vertices * Single_Size); - end loop; - - exception - when others => - Put_Line ("An exception occurred in Load_VB_Object.Set_Attribute_Pointers."); - raise; - end Set_Attribute_Pointers; - - -- ------------------------------------------------------------------------ - --- function To_Vector4_Array (Raw_Data : Image_Data; Num_Vertices : UInt) --- return GL.Types.Singles.Vector4_Array is --- use GL; --- Vertices : GL.Types.Singles.Vector4_Array (1 .. Int (Num_Vertices)); --- aVertex : GL.Types.Singles.Vector4; --- Raw_Index : UInt := 1; --- begin --- for index in Vertices'Range loop --- for v_index in GL.X .. GL.W loop --- aVertex (v_index) := 0.0; --- for i in 1 .. Single_Size loop --- aVertex (v_index) := aVertex (v_index) + --- Single (Raw_Data (Raw_Index) * 8 ** Natural (i - 1)); --- Raw_Index := Raw_Index + 1; --- end loop; --- if v_index = GL.W then --- aVertex (v_index) := 1.0; --- end if; --- end loop; --- Vertices (index) := aVertex; --- end loop; --- return Vertices; --- --- end To_Vector4_Array; - - -- ------------------------------------------------------------------------ - -end Load_VB_Object; diff --git a/examples/common/src/load_vb_object.ads b/examples/common/src/load_vb_object.ads deleted file mode 100644 index 9e77ff76..00000000 --- a/examples/common/src/load_vb_object.ads +++ /dev/null @@ -1,149 +0,0 @@ - -with Ada.Containers.Doubly_Linked_Lists; -with Ada.Containers.Vectors; - -with GL.Objects.Buffers; -with GL.Objects.Vertex_Arrays; -with GL.Types; use GL.Types; - -package Load_VB_Object is - - type VBM_Flags is (VBM_Has_Vertices, VBM_Has_Indices, VBM_Has_Frames, - VBM_Has_Materials); - for VBM_Flags use - (VBM_Has_Vertices => 1, VBM_Has_Indices => 2, - VBM_Has_Frames => 4, VBM_Has_Materials => 8); - - type Material_Texture is private; - type VB_Object is private; - - function Get_Vertex_Count (Object : VB_Object; Frame_Index : UInt := 1) return Int; - procedure Load_From_VBM (File_Name : String; VBM_Object : in out VB_Object; - Vertex_Index, Normal_Index, Tex_Coord0_Index : Int; - Result : out Boolean); - procedure Print_Attributes_Header (Message : String; Object : VB_Object; - Attributes_Index : UInt); - procedure Print_VBM_Object_Data (Message : String; Object : VB_Object); - procedure Print_VBM_Frame_Data (Message : String; Object : VB_Object; - Frame_Index : UInt); - procedure Render (VBM_Object : VB_Object; - Frame_Index : UInt := 1; Instances : UInt := 0); - -private - New_Header_Magic : UInt := 16#314d4253#; -- 1MBS - - type VBM_Header (Magic : UInt := New_Header_Magic) is record - Size : UInt := 0; - Name : String (1 .. 64); - Num_Attributes : UInt := 0; - Num_Frames : UInt := 0; - Num_Vertices : UInt := 0; - Num_Indices : UInt := 0; - Index_Type : Numeric_Type := UByte_Type; - Num_Materials : UInt := 0; - Flags : UInt := 0; - case Magic is - when others => - Num_Chunks : UInt; - end case; - end record; - - type VBM_Attributes_Header is record - Name : String (1 .. 64); - Attribute_Type : Numeric_Type := UByte_Type; - Components : UInt := 0; - Flags : UInt := 0; - end record; - - package Attribute_Package is new Ada.Containers.Vectors - (Natural, VBM_Attributes_Header); - type Attribute_Headers_List is new Attribute_Package.Vector with null record; - - type VBM_Frame_Header is record - First : UInt := 0; - Num_Vertices : UInt := 0; - Flags : UInt := 0; - end record; - - type VBM_Render_Chunk is record - Material_Index : UInt := 0; - First : UInt := 0; - Count : UInt := 0; - end record; - - package Chunk_Package is new - Ada.Containers.Vectors (Positive, VBM_Render_Chunk); - type Render_Chunk_List is new Chunk_Package.Vector with null record; - - type VBM_Vec2F is record - X : Float := 0.0; - Y : Float := 0.0; - end record; - - type VBM_Vec3F is record - X : Float := 0.0; - Y : Float := 0.0; - Z : Float := 0.0; - end record; - - type VBM_Vec4F is record - X : Float := 0.0; - Y : Float := 0.0; - Z : Float := 0.0; - W : Float := 0.0; - end record; - - type VBM_Material is record - Name : String (1 .. 32); - Ambient : VBM_Vec3F; - Diffuse : VBM_Vec3F; - Specular : VBM_Vec3F; - Specular_Exponent : VBM_Vec3F; - Transmission : VBM_Vec3F; - Shininess : Float := 0.0; - Alpha : Float := 0.0; - Ambient_Map : String (1 .. 64); - Diffuse_Map : String (1 .. 64); - Specular_Map : String (1 .. 64); - Normal_Map : String (1 .. 64); - end record; - - package Materials_Package is new - Ada.Containers.Vectors (Positive, VBM_Material); - type Materials_List is new Materials_Package.Vector with null record; - - type Material_Texture is record - Diffuse : UInt := 0; - Specular : UInt := 0; - Normal : UInt := 0; - end record; - package Material_Textures_Package is new - Ada.Containers.Doubly_Linked_Lists (Material_Texture); - type Material_Texture_List is new Material_Textures_Package.List with null record; - - package Frame_Headers_Package is new - Ada.Containers.Vectors (Positive, VBM_Frame_Header); - type Frame_Headers_List is new Frame_Headers_Package.Vector with null record; - - Max_Frames : Positive := 10000; - subtype Num_Frames_Range is Positive range 1 .. Max_Frames; - type VAO_List is array (Num_Frames_Range range <>) of - GL.Objects.Vertex_Arrays.Vertex_Array_Object; - type Buffer_List is array (Num_Frames_Range range <>) of - GL.Objects.Buffers.Buffer; - - type VB_Object is record - -- One Vertex_Array_Object - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Attribute_Buffer : GL.Objects.Buffers.Buffer; -- One Attribute_Buffer - Index_Buffer : GL.Objects.Buffers.Buffer; -- Index_Buffer - Header : VBM_Header; - Num_Frames : Positive := 1; - Attribute_Headers : Attribute_Headers_List; -- Array of attribute records - Frame_Headers : Frame_Headers_List; -- Array of frame records - Materials : Materials_List; -- Array of material records - Chunks : Render_Chunk_List; -- Array of chunk records - Material_Textures : Material_Texture_List; - end record; - -end Load_VB_Object; diff --git a/examples/common/src/maths.adb b/examples/common/src/maths.adb deleted file mode 100644 index b28a77b2..00000000 --- a/examples/common/src/maths.adb +++ /dev/null @@ -1,255 +0,0 @@ - -with Ada.Numerics; - -with Quaternions; - -package body Maths is - use type GL.Types.Singles.Vector3; - - package Single_Quaternion is new Quaternions (GL.Types.Single); - - Radians_Per_Degree : constant Radian := Ada.Numerics.Pi / 180.0; - Degrees_Per_Radian : constant Degree := 180.0 / Ada.Numerics.Pi; - - Zero_Matrix4 : constant GL.Types.Singles.Matrix4 := - (others => (others => 0.0)); - - -- ------------------------------------------------------------------------ - - function Cube_Root (Value : Single) return Single is - begin - return Maths.Single_Math_Functions.Exp (Maths.Single_Math_Functions.Log (Value) / 3.0); - end Cube_Root; - - -- ------------------------------------------------------------------------ - - function Degrees (Angle : Radian) return Degree is - begin - return Degree (Angle) * Degrees_Per_Radian; - end Degrees; - - -- ------------------------------------------------------------------------ - -- Init_Lookat_Transform is derived from - -- Computer Graphics Using OpenGL, Chapter 7, transpose of equation 7.2 - -- except, (W, W) = 1 (not 0) - procedure Init_Lookat_Transform - (Position, Target, Up : Singles.Vector3; - Look_At : out GL.Types.Singles.Matrix4) is - use GL; - -- Reference co-ordinate frame (u, v, n) - -- Forward (n): camera axis - -- Side (u): axis through side of camera, perpendicular to Forward - -- Up_New (v): vertical axis of camera, perpendicular to Forward and Side - Forward : Singles.Vector3 := Position - Target; -- n - Side : Singles.Vector3 - := GL.Types.Singles.Cross_Product (Up, Forward); -- u = Up x n - Up_New : Singles.Vector3 - := GL.Types.Singles.Cross_Product (Forward, Side); -- v = n x u - begin - Forward := Normalized (Forward); -- n / |n| - Side := Normalized (Side); -- u / |u| - Up_New := Normalized (Up_New); -- v / |v| - - Look_At := GL.Types.Singles.Identity4; - Look_At (X, X) := Side (X); -- u.x - Look_At (Y, X) := Side (Y); -- u.y - Look_At (Z, X) := Side (Z); -- u.z - - Look_At (X, Y) := Up_New (X); -- v.x - Look_At (Y, Y) := Up_New (Y); -- v.y - Look_At (Z, Y) := Up_New (Z); -- v.z - - Look_At (X, Z) := Forward (X); -- n.x; - Look_At (Y, Z) := Forward (Y); -- n.y - Look_At (Z, Z) := Forward (Z); -- n.z - - Look_At (W, X) := -GL.Types.Singles.Dot_Product (Position, Side); - Look_At (W, Y) := -GL.Types.Singles.Dot_Product (Position, Up_New); - Look_At (W, Z) := -GL.Types.Singles.Dot_Product (Position, Forward); - end Init_Lookat_Transform; - - -- ------------------------------------------------------------------------ - -- Init_Orthographic_Transform is derived from - -- Computer Graphics Using OpenGL, Chapter 7, transpose of equation 7.18 - - procedure Init_Orthographic_Transform (Top, Bottom, Left, Right, - Z_Near, Z_Far : Single; - Transform : out GL.Types.Singles.Matrix4) is - use GL; - dX : constant Single := Right - Left; - dY : constant Single := Top - Bottom; - dZ : constant Single := Z_Far - Z_Near; - begin - Transform := GL.Types.Singles.Identity4; - Transform (X, X) := 2.0 / dX; - Transform (W, X) := -(Right + Left) / dX; - Transform (Y, Y) := 2.0 / dY; - Transform (W, Y) := -(Top + Bottom) / dY; - Transform (Z, Z) := 2.0 / dZ; - Transform (W, Z) := -(Z_Far + Z_Near) / dZ; - end Init_Orthographic_Transform; - - -- ------------------------------------------------------------------------ - - procedure Init_Perspective_Transform (View_Angle : Degree; - Width, Height, Z_Near, Z_Far : Single; - Transform : out GL.Types.Singles.Matrix4) is - begin - Transform := Perspective_Matrix (View_Angle, Width / Height, - Z_Near, Z_Far); - end Init_Perspective_Transform; - - -- ------------------------------------------------------------------------ - - function Length (V : GL.Types.Singles.Vector3) return GL.Types.Single is - use Single_Math_Functions; - use GL; - begin - return Sqrt (V (X) * V (X) + V (Y) * V (Y) + V (Z) * V (Z)); - end Length; - - -- ------------------------------------------------------------------------ - - function New_Quaternion (Angle : Radian; Axis : GL.Types.Singles.Vector3) - return Single_Quaternion.Quaternion is - use Maths.Single_Math_Functions; - Half_Angle : constant Single := 0.5 * Single (Angle); - Sine : constant Single := Sin (Half_Angle); - begin - return (Cos (Half_Angle), Axis (GL.X) * Sine, - Axis (GL.Y) * Sine, Axis (GL.Z) * Sine); - end New_Quaternion; - - -- ------------------------------------------------------------------------ - - function Normalized (V : Singles.Vector3) return Singles.Vector3 is - use GL; - L : constant Single := Length (V); - begin - return (V (X) / L, V (Y) / L, V (Z) / L); - end Normalized; - - -- ------------------------------------------------------------------------ - -- Perspective_Matrix is derived from Computer Graphics Using OpenGL - -- Chapter 7, transpose of equation 7.13 - function Perspective_Matrix (Top, Bottom, Left, Right, Near, Far : Single) - return GL.Types.Singles.Matrix4 is - use GL; - dX : constant Single := Right - Left; - dY : constant Single := Top - Bottom; - dZ : constant Single := Far - Near; - Matrix : GL.Types.Singles.Matrix4 := Zero_Matrix4; - begin - Matrix (X, X) := 2.0 * Near / dX; - Matrix (Z, X) := (Right + Left) / dX; - Matrix (Y, Y) := 2.0 * Near / dY; - Matrix (Z, Y) := (Top + Bottom) / dY; - Matrix (Z, Z) := -(Far + Near) / dZ; - Matrix (W, Z) := -2.0 * Far * Near / dZ; - Matrix (Z, W) := -1.0; - return Matrix; - end Perspective_Matrix; - - -- ------------------------------------------------------------------------ - -- Perspective_Matrix is derived from Computer Graphics Using OpenGL - -- Chapter 7, top, bottom, left and right equations following equation 7.13 - function Perspective_Matrix (View_Angle : Degree; Aspect, Near, Far : Single) - return GL.Types.Singles.Matrix4 is - use Single_Math_Functions; - - Top : Single; - Bottom : Single; - Right : Single; - Left : Single; - begin - Top := Near * Tan (Single (0.5 * Radians (View_Angle))); - Bottom := -Top; - Right := Top * Aspect; - Left := -Right; - return Perspective_Matrix (Top, Bottom, Left, Right, Near, Far); - end Perspective_Matrix; - - -- ------------------------------------------------------------------------ - - function Radians (Angle : Degree) return Radian is - begin - return Radian (Angle) * Radians_Per_Degree; - end Radians; - - -- ------------------------------------------------------------------------ - -- Rotation_Matrix is based on "Quaternians and spatial rotation" by - -- en.m.wikipedia.org, with the matrix transposed - - function Rotation_Matrix (Angle : Radian; Axis : GL.Types.Singles.Vector3) - return GL.Types.Singles.Matrix4 is - use GL; - use Single_Quaternion; - - aQuaternion : Single_Quaternion.Quaternion; - theMatrix : GL.Types.Singles.Matrix4 := GL.Types.Singles.Identity4; - NQ : Single_Quaternion.Quaternion; - begin - aQuaternion := New_Quaternion (Angle, Axis); - NQ := Normalized (aQuaternion); - - theMatrix (X, X) := 1.0 - 2.0 * (NQ.C * NQ.C + NQ.D * NQ.D); - theMatrix (Y, X) := 2.0 * (NQ.B * NQ.C - NQ.A * NQ.D); - theMatrix (Z, X) := 2.0 * (NQ.B * NQ.D + NQ.A * NQ.C); - - theMatrix (X, Y) := 2.0 * (NQ.B * NQ.C + NQ.A * NQ.D); - theMatrix (Y, Y) := 1.0 - 2.0 * (NQ.B * NQ.B + NQ.D * NQ.D); - theMatrix (Z, Y) := 2.0 * (NQ.C * NQ.D - NQ.A * NQ.B); - - theMatrix (X, Z) := 2.0 * (NQ.B * NQ.D - NQ.A * NQ.C); - theMatrix (Y, Z) := 2.0 * (NQ.C * NQ.D + NQ.A * NQ.B); - theMatrix (Z, Z) := 1.0 - 2.0 * (NQ.B * NQ.B + NQ.C * NQ.C); - return theMatrix; - end Rotation_Matrix; - - -- ------------------------------------------------------------------------ - - function Rotation_Matrix (Angle : Degree; Axis : GL.Types.Singles.Vector3) - return GL.Types.Singles.Matrix4 is - begin - return Rotation_Matrix (Radians (Angle), Axis); - end Rotation_Matrix; - - -- ------------------------------------------------------------------------ - -- Scaling_Matrix is derived from Computer Graphics Using OpenGL - -- Chapter 5, matrix equation (5.25) - - function Scaling_Matrix (Scale_Factor : Singles.Vector3) return Singles.Matrix4 is - use GL; - theMatrix : Singles.Matrix4 := Singles.Identity4; - begin - theMatrix (X, X) := Scale_Factor (X); - theMatrix (Y, Y) := Scale_Factor (Y); - theMatrix (Z, Z) := Scale_Factor (Z); - return theMatrix; - end Scaling_Matrix; - - -- ------------------------------------------------------------------------ - - function Scaling_Matrix (Scale_Factor : Single) return Singles.Matrix4 is - begin - return Scaling_Matrix ((Scale_Factor, Scale_Factor, Scale_Factor)); - end Scaling_Matrix; - - -- ------------------------------------------------------------------------ - -- Translation_Matrix is derived from Computer Graphics Using OpenGL - -- Chapter 5, transpose of equation preceding (5.25) - - function Translation_Matrix (Change : Singles.Vector3) - return Singles.Matrix4 is - use GL; - theMatrix : Singles.Matrix4 := Singles.Identity4; - begin - theMatrix (W, X) := Change (X); - theMatrix (W, Y) := Change (Y); - theMatrix (W, Z) := Change (Z); - return theMatrix; - end Translation_Matrix; - - -- ------------------------------------------------------------------------ - -end Maths; diff --git a/examples/common/src/maths.ads b/examples/common/src/maths.ads deleted file mode 100644 index e0270ce3..00000000 --- a/examples/common/src/maths.ads +++ /dev/null @@ -1,60 +0,0 @@ - -with Interfaces.C.Pointers; - -with Ada.Numerics.Generic_Elementary_Functions; - -with GL.Types; use GL.Types; - -package Maths is - - type Degree is new Single; - type Radian is new Single; - - type Index_5 is (X, Y, Z, U, V); - type Index_6 is (X, Y, Z, R, G, B); - - type Vector5 is array (Index_5) of aliased Single; - pragma Convention (C, Vector5); - type Vector6 is array (Index_6) of aliased Single; - pragma Convention (C, Vector6); - - type Vector5_Array is array (Size range <>) of aliased Vector5; - pragma Convention (C, Vector5_Array); - type Vector6_Array is array (Size range <>) of aliased Vector6; - pragma Convention (C, Vector6_Array); - - package Single_Math_Functions is new - Ada.Numerics.Generic_Elementary_Functions (GL.Types.Single); - - package Vector5_Pointers is new Interfaces.C.Pointers - (Size, Vector5, Vector5_Array, Vector5'(others => <>)); - package Vector6_Pointers is new Interfaces.C.Pointers - (Size, Vector6, Vector6_Array, Vector6'(others => <>)); - - function Cube_Root (Value : Single) return Single; - function Degrees (Angle : Radian) return Degree; - procedure Init_Lookat_Transform - (Position, Target, Up : Singles.Vector3; Look_At : out Singles.Matrix4); - procedure Init_Orthographic_Transform (Top, Bottom, Left, Right, - Z_Near, Z_Far : Single; - Transform : out Singles.Matrix4); - procedure Init_Perspective_Transform - (View_Angle : Degree; Width, Height, Z_Near, Z_Far : Single; - Transform : out Singles.Matrix4); - function Length (V : Singles.Vector3) return Single; - function Normalized (V : Singles.Vector3) return Singles.Vector3; - function Perspective_Matrix (View_Angle : Degree; Aspect, Near, Far : Single) - return Singles.Matrix4; - function Perspective_Matrix (Top, Bottom, Left, Right, Near, Far : Single) - return GL.Types.Singles.Matrix4; - function Radians (Angle : Degree) return Radian; - function Rotation_Matrix (Angle : Degree; Axis : Singles.Vector3) - return Singles.Matrix4; - - function Rotation_Matrix (Angle : Radian; Axis : Singles.Vector3) - return Singles.Matrix4; - function Scaling_Matrix (Scale_Factor : Single) return Singles.Matrix4; - function Scaling_Matrix (Scale_Factor : Singles.Vector3) return Singles.Matrix4; - function Translation_Matrix (Change : Singles.Vector3) - return Singles.Matrix4; -end Maths; diff --git a/examples/common/src/program_loader.adb b/examples/common/src/program_loader.adb deleted file mode 100644 index 27603649..00000000 --- a/examples/common/src/program_loader.adb +++ /dev/null @@ -1,80 +0,0 @@ - -with Ada.Directories; -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Files; - -package body Program_Loader is - - procedure Compile_Shader (Shader : GL.Objects.Shaders.Shader) is - begin - Shader.Compile; - if not Shader.Compile_Status then - Put_Line ("Shader compilation failed."); - Put_Line ("Log:"); - Put_Line (Shader.Info_Log); - raise Shader_Loading_Error; - end if; - end Compile_Shader; - - -- ------------------------------------------------------------------------ - - function Program_From (List : Shader_Sources) - return GL.Objects.Programs.Program is - Shader_Program : GL.Objects.Programs.Program; - begin - Shader_Program.Initialize_Id; - - for I in List'Range loop - declare - My_Shader : GL.Objects.Shaders.Shader (List (I).Kind); - File_Path : constant String := - Ada.Strings.Unbounded.To_String (List (I).Path); - begin - if Ada.Directories.Exists (File_Path) then - My_Shader.Initialize_Id; - GL.Files.Load_Shader_Source_From_File (My_Shader, File_Path); - Compile_Shader (My_Shader); - Shader_Program.Attach (My_Shader); - else - Put_Line ("File " & File_Path & " not found."); - raise Shader_Loading_Error; - - end if; - end; - end loop; - - Shader_Program.Link; - if not Shader_Program.Link_Status then - Put_Line ("Shader linking failed."); - Put_Line ("Log:"); - Put_Line (GL.Objects.Programs.Info_Log (Shader_Program)); - raise Shader_Loading_Error; - end if; - - GL.Objects.Shaders.Release_Shader_Compiler; - return Shader_Program; - - exception - when others => - Put_Line ("An exception occurred in Program_From."); - raise Shader_Loading_Error; - end Program_From; - - -- ------------------------------------------------------------------------ - - function Src (Path : String; Kind : GL.Objects.Shaders.Shader_Type) - return Shader_Source is - begin - return Shader_Source'( - Path => Ada.Strings.Unbounded.To_Unbounded_String (Path), - Kind => Kind); - exception - when others => - Put_Line ("An exception occurred in Program_Loader.Src."); - raise; - end Src; - - -- ------------------------------------------------------------------------ - -end Program_Loader; diff --git a/examples/common/src/program_loader.ads b/examples/common/src/program_loader.ads deleted file mode 100644 index 4312da00..00000000 --- a/examples/common/src/program_loader.ads +++ /dev/null @@ -1,23 +0,0 @@ -with Ada.Strings.Unbounded; - -with GL.Objects.Shaders; -with GL.Objects.Programs; - -package Program_Loader is - type Shader_Source is private; - - type Shader_Sources is array (Positive range <>) of Shader_Source; - - Shader_Loading_Error : exception; - - function Src (Path : String; Kind : GL.Objects.Shaders.Shader_Type) - return Shader_Source; - - function Program_From (List : Shader_Sources) - return GL.Objects.Programs.Program; -private - type Shader_Source is record - Path : Ada.Strings.Unbounded.Unbounded_String; - Kind : GL.Objects.Shaders.Shader_Type; - end record; -end Program_Loader; diff --git a/examples/common/src/quaternions.adb b/examples/common/src/quaternions.adb deleted file mode 100644 index f52e78d3..00000000 --- a/examples/common/src/quaternions.adb +++ /dev/null @@ -1,81 +0,0 @@ - -with Ada.Numerics.Generic_Elementary_Functions; - -package body Quaternions is - package Elementary_Functions is - new Ada.Numerics.Generic_Elementary_Functions (Real); - use Elementary_Functions; - - function "abs" (Left : Quaternion) return Real is - begin - return Sqrt (Left.A ** 2 + Left.B ** 2 + Left.C ** 2 + Left.D ** 2); - end "abs"; - - function Conj (Left : Quaternion) return Quaternion is - begin - return (A => Left.A, B => -Left.B, C => -Left.C, D => -Left.D); - end Conj; - - function "-" (Left : Quaternion) return Quaternion is - begin - return (A => -Left.A, B => -Left.B, C => -Left.C, D => -Left.D); - end "-"; - - function "+" (Left, Right : Quaternion) return Quaternion is - begin - return - (A => Left.A + Right.A, B => Left.B + Right.B, - C => Left.C + Right.C, D => Left.D + Right.D); - end "+"; - - function "-" (Left, Right : Quaternion) return Quaternion is - begin - return - (A => Left.A - Right.A, B => Left.B - Right.B, - C => Left.C - Right.C, D => Left.D - Right.D); - end "-"; - - function "*" (Left : Quaternion; Right : Real) return Quaternion is - begin - return - (A => Left.A * Right, B => Left.B * Right, - C => Left.C * Right, D => Left.D * Right); - end "*"; - - function "*" (Left : Real; Right : Quaternion) return Quaternion is - begin - return Right * Left; - end "*"; - - function "*" (Left, Right : Quaternion) return Quaternion is - begin - return - (A => Left.A * Right.A - Left.B * Right.B - Left.C * Right.C - Left.D * Right.D, - B => Left.A * Right.B + Left.B * Right.A + Left.C * Right.D - Left.D * Right.C, - C => Left.A * Right.C - Left.B * Right.D + Left.C * Right.A + Left.D * Right.B, - D => Left.A * Right.D + Left.B * Right.C - Left.C * Right.B + Left.D * Right.A); - end "*"; - - function Image (Left : Quaternion) return String is - begin - return Real'Image (Left.A) & " +" & - Real'Image (Left.B) & "i +" & - Real'Image (Left.C) & "j +" & - Real'Image (Left.D) & "k"; - end Image; - - function Normalized (Left : Quaternion) return Quaternion is - Norm : Real; - NQ : Quaternion; - begin - Norm := Sqrt (Left.A * Left.A + Left.B * Left.B + - Left.C * Left.C + Left.D * Left.D); - NQ.A := Left.A / Norm; - NQ.B := Left.B / Norm; - NQ.C := Left.C / Norm; - NQ.D := Left.D / Norm; - - return NQ; - end Normalized; - -end Quaternions; diff --git a/examples/common/src/quaternions.ads b/examples/common/src/quaternions.ads deleted file mode 100644 index 6d911922..00000000 --- a/examples/common/src/quaternions.ads +++ /dev/null @@ -1,23 +0,0 @@ - -generic - type Real is digits <>; - -package Quaternions is - pragma Elaborate_Body; - - type Quaternion is record - A, B, C, D : Real; - end record; - - function "abs" (Left : Quaternion) return Real; - function Conj (Left : Quaternion) return Quaternion; - function "-" (Left : Quaternion) return Quaternion; - function "+" (Left, Right : Quaternion) return Quaternion; - function "-" (Left, Right : Quaternion) return Quaternion; - function "*" (Left : Quaternion; Right : Real) return Quaternion; - function "*" (Left : Real; Right : Quaternion) return Quaternion; - function "*" (Left, Right : Quaternion) return Quaternion; - function Image (Left : Quaternion) return String; - function Normalized (Left : Quaternion) return Quaternion; - -end Quaternions; diff --git a/examples/common/src/text_management.adb b/examples/common/src/text_management.adb deleted file mode 100644 index b38fd98e..00000000 --- a/examples/common/src/text_management.adb +++ /dev/null @@ -1,142 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Blending; -with GL.Objects.Buffers; -with GL.Objects.Vertex_Arrays; -with GL.Objects.Textures.Targets; -with GL.Text; -with GL.Toggles; - -with Maths; - -package body Text_Management is - - procedure Load_Vertex_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Singles.Vector2_Pointers); - - Rendering_Program : GL.Text.Shader_Program_Reference; - Renderer : GL.Text.Renderer_Reference; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - - -- ------------------------------------------------------------------------ - - procedure Load_Data (Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Data_Buffer : GL.Objects.Buffers.Buffer) is - use GL.Objects.Buffers; - - Square : constant GL.Types.Singles.Vector2_Array - := ((0.0, 0.0), - (1.0, 0.0), - (0.0, 1.0), - (1.0, 1.0)); - begin - Vertex_Array.Bind; - Array_Buffer.Bind (Data_Buffer); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Load_Vertex_Buffer (Array_Buffer, Square, Static_Draw); - GL.Attributes.Set_Vertex_Attrib_Pointer (0, 2, GL.Types.Single_Type, - False, 0, 0); - exception - when others => - Put_Line ("An exception occurred in Texture_Management.Load_Data."); - raise; - end Load_Data; - - -- ------------------------------------------------------------------------ - - procedure Render_Text (Render_Program : GL.Objects.Programs.Program; - Text : String; X, Y, Scale : GL.Types.Single; - Colour : GL.Types.Colors.Color; - Texture_ID, MVP_Matrix_ID, Dimensions_ID, - Colour_ID : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4) is - use GL.Objects.Textures.Targets; - use GL.Text; - use GL.Types.Colors; - use GL.Types; - use GL.Types.Singles; - - Blend_State : constant GL.Toggles.Toggle_State := - GL.Toggles.State (GL.Toggles.Blend); - Src_Alpha_Blend : constant GL.Blending.Blend_Factor := - GL.Blending.Blend_Func_Src_Alpha; - One_Minus_Src_Alpha_Blend : constant GL.Blending.Blend_Factor := - GL.Blending.One_Minus_Src_Alpha; - - Height : Single; - Width : Pixel_Difference; - Y_Min, Y_Max : Pixel_Difference; - Text_Image : GL.Objects.Textures.Texture; - MVP : Matrix4; - begin - Renderer.Calculate_Dimensions (Text, Width, Y_Min, Y_Max); - if Width > 0 then - Height := Single (Y_Max - Y_Min); - Text_Image := Renderer.To_Texture (Text, Width, Y_Min, Y_Max, Colour); - GL.Objects.Textures.Set_Active_Unit (0); - GL.Objects.Textures.Targets.Texture_2D.Bind (Text_Image); - - MVP := (MVP_Matrix * Maths.Translation_Matrix ((X, Y, 0.0)) * - Maths.Scaling_Matrix ((Scale, Scale, 1.0))); - - GL.Objects.Programs.Use_Program (Render_Program); - GL.Uniforms.Set_Int (Texture_ID, 0); - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP); - GL.Uniforms.Set_Single (Dimensions_ID, Single (Width), Height); - GL.Uniforms.Set_Single (Colour_ID, Colour (R), Colour (G), Colour (B)); - - -- Blending allows a fragment colour's alpha value to control the resulting - -- colour which will be transparent for all the glyph's background colours and - -- non-transparent for the actual character pixels. - GL.Toggles.Enable (GL.Toggles.Blend); - GL.Blending.Set_Blend_Func (Src_Factor => GL.Blending.Src_Alpha, - Dst_Factor => GL.Blending.One_Minus_Src_Alpha); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Load_Data (Vertex_Array, Vertex_Buffer); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangle_Strip, 0, 4); - GL.Attributes.Disable_Vertex_Attrib_Array (0); - end if; - GL.Toggles.Set (GL.Toggles.Blend, Blend_State); - GL.Blending.Set_Blend_Func (Src_Alpha_Blend, One_Minus_Src_Alpha_Blend); - - exception - when others => - Put_Line ("An exception occurred in Texture_Management.Render_Text."); - raise; - end Render_Text; - - -- ------------------------------------------------------------------------ - - procedure Render_Text (Render_Program : GL.Objects.Programs.Program; - Text_Data : Text_Array; - Texture_ID, MVP_Matrix_ID, Dimensions_ID, - Colour_ID : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4) is - begin - for Index in Text_Data'Range loop - Render_Text (Render_Program, - Ada.Strings.Unbounded.To_String (Text_Data (Index).Text), - Text_Data (Index).Pos_X, Text_Data (Index).Pos_Y, - Text_Data (Index).Scale, Text_Data (Index).Colour, - Texture_ID, MVP_Matrix_ID, Dimensions_ID, - Colour_ID, MVP_Matrix); - end loop; - end Render_Text; - - -- ------------------------------------------------------------------------ - - procedure Setup (Font_File : String) is - begin - Vertex_Array.Initialize_Id; - Vertex_Buffer.Initialize_Id; - GL.Text.Create (Rendering_Program); - Renderer.Create (Rendering_Program, Font_File, 0, 96); - end Setup; - - -- ------------------------------------------------------------------------ - -end Text_Management; diff --git a/examples/common/src/text_management.ads b/examples/common/src/text_management.ads deleted file mode 100644 index f91ae65b..00000000 --- a/examples/common/src/text_management.ads +++ /dev/null @@ -1,32 +0,0 @@ - -with Ada.Strings.Unbounded; - -with GL.Objects.Programs; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; - -package Text_Management is - - type Text_Record is record - Text : Ada.Strings.Unbounded.Unbounded_String; - Pos_X : GL.Types.Single; - Pos_Y : GL.Types.Single; - Scale : GL.Types.Single; - Colour : GL.Types.Colors.Color; - end record; - type Text_Array is array (Positive range <>) of Text_Record; - - procedure Setup (Font_File : String); - procedure Render_Text (Render_Program : GL.Objects.Programs.Program; - Text : String; X, Y, Scale : GL.Types.Single; - Colour : GL.Types.Colors.Color; - Texture_ID, MVP_Matrix_ID, Dimensions_ID, - Colour_ID : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4); - procedure Render_Text (Render_Program : GL.Objects.Programs.Program; - Text_Data : Text_Array; - Texture_ID, MVP_Matrix_ID, Dimensions_ID, - Colour_ID : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4); -end Text_Management; diff --git a/examples/common/src/utilities.adb b/examples/common/src/utilities.adb deleted file mode 100644 index 9b7a838f..00000000 --- a/examples/common/src/utilities.adb +++ /dev/null @@ -1,400 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; -with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; - -with GL.Buffers; -with GL.Context; -with GL.Objects.Shaders.Lists; - -package body Utilities is - - generic - type Index_Type is (<>); - type Vector_Type is array (Index_Type) of aliased GL.Types.Single; - procedure Print_Singles_Vector (Name : String; aVector : Vector_Type); - - procedure Print_Singles_Vector (Name : String; aVector : Vector_Type) is - begin - if Name = "" then - Put (" "); - else - Put (Name & ": "); - end if; - for Index in aVector'Range loop - Put (GL.Types.Single'Image (aVector (Index)) & " "); - end loop; - New_Line; - end Print_Singles_Vector; - - -- ------------------------------------------------------------------- - - generic - type Index_Type is (<>); - type Vector_Type is array (Index_Type) of aliased GL.Types.Int; - procedure Print_Int_Vector (Name : String; aVector : Vector_Type); - - procedure Print_Int_Vector (Name : String; aVector : Vector_Type) is - begin - if Name = "" then - Put (" "); - else - Put (Name & ": "); - end if; - for Index in aVector'Range loop - Put (GL.Types.Int'Image (aVector (Index)) & " "); - end loop; - New_Line; - end Print_Int_Vector; - - -- ------------------------------------------------------------------- - - procedure Print_Ints_Vector2 is - new Print_Int_Vector (GL.Index_2D, GL.Types.Ints.Vector2); - procedure Print_Singles_Vector2 is - new Print_Singles_Vector (GL.Index_2D, GL.Types.Singles.Vector2); - procedure Print_Ints_Vector3 is - new Print_Int_Vector (GL.Index_3D, GL.Types.Ints.Vector3); - procedure Print_Singles_Vector3 is - new Print_Singles_Vector (GL.Index_3D, GL.Types.Singles.Vector3); - procedure Print_Singles_Vector4 is - new Print_Singles_Vector (GL.Index_Homogeneous, GL.Types.Singles.Vector4); - procedure Print_Singles_Vector6 is - new Print_Singles_Vector (Maths.Index_6, Maths.Vector6); - - -- --------------------------------------------------------------- - - -- Set_Color_Clear_Value sets the value to which a buffer should be set - -- when cleared. - -- Clear "clears" selected values to the previously selected value set by - -- Set_Color_Clear_Value . - procedure Clear_All (Colour : GL.Types.Colors.Color) is - begin - GL.Buffers.Set_Color_Clear_Value (Colour); - GL.Buffers.Clear ((True, True, True, True)); - end Clear_All; - - -- ------------------------------------------------------------------------ - - procedure Clear_Background_Colour (Colour : GL.Types.Colors.Color) is - begin - GL.Buffers.Set_Color_Clear_Value (Colour); - GL.Buffers.Clear ((False, False, False, True)); - end Clear_Background_Colour; - - -- ------------------------------------------------------------------------ - - procedure Clear_Background_Colour_And_Depth (Colour : GL.Types.Colors.Color) is - begin - GL.Buffers.Set_Color_Clear_Value (Colour); - GL.Buffers.Clear ((True, False, False, True)); - end Clear_Background_Colour_And_Depth; - - -- ------------------------------------------------------------------------ - - procedure Clear_Colour_Buffer_And_Depth is - begin - GL.Buffers.Clear ((True, False, False, True)); - end Clear_Colour_Buffer_And_Depth; - - -- ------------------------------------------------------------------------ - - - procedure Enable_Mouse_Callbacks (Window : in out Glfw.Windows.Window; Enable : Boolean) is - begin - if Enable then - Window.Enable_Callback (Glfw.Windows.Callbacks.Mouse_Position); - Window.Enable_Callback (Glfw.Windows.Callbacks.Mouse_Enter); - Window.Enable_Callback (Glfw.Windows.Callbacks.Mouse_Button); - Window.Enable_Callback (Glfw.Windows.Callbacks.Mouse_Scroll); - else - Window.Disable_Callback (Glfw.Windows.Callbacks.Mouse_Position); - Window.Disable_Callback (Glfw.Windows.Callbacks.Mouse_Enter); - Window.Disable_Callback (Glfw.Windows.Callbacks.Mouse_Button); - Window.Disable_Callback (Glfw.Windows.Callbacks.Mouse_Scroll); - end if; - end; - - -- ------------------------------------------------------------------------ - - procedure Print_Array6 (Name : String; anArray : Maths.Vector6_Array) is - begin - Put_Line (Name & ": "); - for Index in anArray'First .. anArray'Last loop - Print_Singles_Vector6 ("", anArray (Index)); - end loop; - New_Line; - end Print_Array6; - - -- ------------------------------------------------------------------------- - - procedure Print_Byte_Array (Name : String; anArray : Byte_Array; - Start, Finish : GL.Types.UInt) is - use GL.Types; - Count : Integer := 1; - begin - Put_Line (Name & ": "); - if Int (Start) >= anArray'First and then Int (Finish) <= anArray'Last then - for Index in Start .. Finish loop - Put (UInt'Image (Index) & ": " & - UByte'Image (anArray (Int (Index))) & " "); - Count := Count + 1; - if Count > 5 then - New_Line; - Count := 1; - end if; - end loop; - else - Put_Line ("Print_Byte_Array called with invalid start or finish index."); - end if; - New_Line; - end Print_Byte_Array; - - -- ------------------------------------------------------------------------ - - procedure Print_GL_Array2 (Name : String; anArray : GL.Types.Singles.Vector2_Array) is - begin - Put_Line (Name & ": "); - for Index in anArray'First .. anArray'Last loop - Print_Singles_Vector2 ("", anArray (Index)); - end loop; - New_Line; - end Print_GL_Array2; - - -- ------------------------------------------------------------------------ - - procedure Print_GL_Array2 (Name : String; anArray : GL.Types.Ints.Vector2_Array) is - begin - Put_Line (Name & ": "); - for Index in anArray'First .. anArray'Last loop - Print_Ints_Vector2 ("", anArray (Index)); - end loop; - New_Line; - end Print_GL_Array2; - - -- ------------------------------------------------------------------------ - - procedure Print_GL_Array3 (Name : String; anArray : GL.Types.Ints.Vector3_Array) is - begin - Put_Line (Name & ": "); - for Index in anArray'First .. anArray'Last loop - Print_Ints_Vector3 ("", anArray (Index)); - end loop; - New_Line; - end Print_GL_Array3; - - -- ------------------------------------------------------------------------ - - procedure Print_GL_Array3 (Name : String; anArray : GL.Types.Singles.Vector3_Array) is - begin - Put_Line (Name & ": "); - for Index in anArray'First .. anArray'Last loop - Print_Singles_Vector3 ("", anArray (Index)); - end loop; - New_Line; - end Print_GL_Array3; - - -- ------------------------------------------------------------------------ - - procedure Print_GL_Array4 (Name : String; anArray : GL.Types.Singles.Vector4_Array) is - begin - Put_Line (Name & ": "); - for Index in anArray'First .. anArray'Last loop - Print_Singles_Vector4 ("", anArray (Index)); - end loop; - New_Line; - end Print_GL_Array4; - - -- ------------------------------------------------------------------------ - - procedure Print_GL_Int_Array (Name : String; anArray : GL.Types.Int_Array) is - use GL.Types; - begin - Put_Line (Name & ": "); - for Index in anArray'First .. anArray'Last loop - Put_Line (Int'Image (Index) & ": " & Int'Image (anArray (Index))); - end loop; - New_Line; - end Print_GL_Int_Array; - - -- ------------------------------------------------------------------------ - - procedure Print_GL_UInt_Array (Name : String; anArray : GL.Types.UInt_Array) is - use GL.Types; - begin - Put_Line (Name & ": "); - for Index in anArray'First .. anArray'Last loop - Put_Line (Int'Image (Index) & ": " & UInt'Image (anArray (Index))); - end loop; - New_Line; - end Print_GL_UInt_Array; - - -- ------------------------------------------------------------------------ - - procedure Print_Matrix (Name : String; - aMatrix : GL.Types.Singles.Matrix3) is - begin - Put_Line (Name & ":"); - for Row in GL.Index_3D'Range loop - for Column in GL.Index_3D'Range loop - Put (GL.Types.Single'Image (aMatrix (Row, Column)) & " "); - end loop; - New_Line; - end loop; - New_Line; - end Print_Matrix; - - -- ------------------------------------------------------------------------ - - procedure Print_Matrix (Name : String; - aMatrix : GL.Types.Singles.Matrix4) is - begin - Put_Line (Name & ":"); - for Row in GL.Index_Homogeneous'Range loop - for Column in GL.Index_Homogeneous'Range loop - Put (GL.Types.Single'Image (aMatrix (Row, Column)) & " "); - end loop; - New_Line; - end loop; - New_Line; - end Print_Matrix; - - -- ------------------------------------------------------------------------ - - procedure Print_Singles_Array (Name : String; anArray : Singles_Array; - Start, Finish : GL.Types.Int) is - use GL.Types; - Count : Integer := 1; - begin - Put_Line (Name & ": "); - if Start >= anArray'First and then Finish <= anArray'Last then - for Index in Start .. Finish loop - Put (Int'Image (Index) & ": " & Single'Image (anArray (Index)) & - " "); - Count := Count + 1; - if Count > 4 then - New_Line; - Count := 1; - end if; - end loop; - else - Put_Line ("Print_Singles_Array called with invalid start or finish index."); - end if; - New_Line; - end Print_Singles_Array; - - -- ------------------------------------------------------------------------ - - procedure Print_Vector (Name : String; aVector : GL.Types.Singles.Vector2) is - begin - Print_Singles_Vector2 (Name, aVector); - end Print_Vector; - - -- ------------------------------------------------------------------------ - - procedure Print_Vector (Name : String; aVector : GL.Types.Ints.Vector3) is - begin - Print_Ints_Vector3 (Name, aVector); - end Print_Vector; - - -- ------------------------------------------------------------------------ - - procedure Print_Vector (Name : String; aVector : GL.Types.Singles.Vector3) is - begin - Print_Singles_Vector3 (Name, aVector); - end Print_Vector; - - -- ------------------------------------------------------------------------ - - procedure Print_Vector (Name : String; aVector : GL.Types.Singles.Vector4) is - begin - Print_Singles_Vector4 (Name, aVector); - end Print_Vector; - - -- ------------------------------------------------------------------------ - - procedure Show_GL_Data is - GL_Version : Unbounded_String; - Renderer : Unbounded_String; - Shading_Language_Version : Unbounded_String; - begin - GL_Version := To_Unbounded_String (GL.Types.Int'image (GL.Context.Major_Version) & "." & - GL.Types.Int'image (GL.Context.Minor_Version)); - Renderer := To_Unbounded_String (GL.Context.Renderer); - Shading_Language_Version := - To_Unbounded_String (GL.Context.Primary_Shading_Language_Version); - New_Line; - Put_Line ("OpenGL version supported: " & To_String (GL_Version)); - Put_Line ("Renderer: " & To_String (Renderer)); - Put_Line ("Primary_Shading_Language_Version: " & To_String (Shading_Language_Version)); - New_Line; - end Show_GL_Data; - - -- ------------------------------------------------------------------------ - - procedure Show_Shader_Program_Data (aProgram : GL.Objects.Programs.Program) is - use GL.Objects; - Shaders_List : constant Shaders.Lists.List := - Programs.Attached_Shaders (aProgram); - List_Cursor : Shaders.Lists.Cursor := Shaders_List.First; - Shader1 : constant Shaders.Shader := - Shaders.Lists.Element (List_Cursor); - Shader_Count : Positive := 1; - begin - Put_Line ("Shader: " & Positive'Image (Shader_Count)); - Put_Line (Shaders.Source (Shader1)); - - while Shaders.Lists.Has_Next (List_Cursor) loop - List_Cursor := Shaders.Lists.Next (List_Cursor); - declare - ShaderN : constant Shaders.Shader := - Shaders.Lists.Element (List_Cursor); - begin - Shader_Count := Shader_Count + 1; - Put_Line ("Shader: " & Positive'Image (Shader_Count)); - Put_Line (Shaders.Source (ShaderN)); - end; - end loop; - New_Line; - - exception - when others => - Put_Line ("An exception occurred in Show_Shader_Program_Data."); - raise; - end Show_Shader_Program_Data; - - -- ------------------------------------------------------------------------ - - procedure Show_Shader_Info_Log (aProgram : GL.Objects.Programs.Program) is - use GL.Objects; - Shaders_List : constant Shaders.Lists.List := - Programs.Attached_Shaders (aProgram); - List_Cursor : Shaders.Lists.Cursor := Shaders_List.First; - Shader_Count : Positive := 1; - begin - Put_Line ("Shader: " & Positive'Image (Shader_Count) & " log:"); - while Shaders.Lists.Has_Next (List_Cursor) loop - List_Cursor := Shaders.Lists.Next (List_Cursor); - declare - ShaderN : constant Shaders.Shader := - Shaders.Lists.Element (List_Cursor); - begin - Shader_Count := Shader_Count + 1; - Put_Line ("Shader: " & Positive'Image (Shader_Count) & " log:"); - declare - Shader_Log : constant String := - GL.Objects.Shaders.Info_Log (ShaderN); - begin - Put_Line (Shader_Log); - end; - end; - end loop; - New_Line; - exception - when others => - Put_Line ("An exception occurred in Show_Shader_Info_Log."); - raise; - end Show_Shader_Info_Log; - - -- ------------------------------------------------------------------------ - -end Utilities; diff --git a/examples/common/src/utilities.ads b/examples/common/src/utilities.ads deleted file mode 100644 index 8864f5e0..00000000 --- a/examples/common/src/utilities.ads +++ /dev/null @@ -1,64 +0,0 @@ - -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Types; -with GL.Types.Colors; - -with Glfw.Windows; - -with Maths; - -package Utilities is - - type Byte_Array is array (GL.Types.Int range <>) of aliased GL.Types.UByte; - type Singles_Array is array (GL.Types.Int range <>) of aliased GL.Types.Single; - - procedure Clear_All (Colour : GL.Types.Colors.Color); - procedure Clear_Background_Colour (Colour : GL.Types.Colors.Color); - procedure Clear_Background_Colour_And_Depth (Colour : GL.Types.Colors.Color); - procedure Clear_Colour_Buffer_And_Depth; - procedure Enable_Mouse_Callbacks (Window : in out Glfw.Windows.Window; Enable : Boolean); - procedure Load_Element_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Int_Pointers); - procedure Load_Element_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.UInt_Pointers); - procedure Load_Vertex_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Singles.Vector2_Pointers); - procedure Load_Vertex_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Singles.Vector3_Pointers); - procedure Load_Vertex_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Singles.Vector4_Pointers); - procedure Load_Texture_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Singles.Matrix4_Pointers); - procedure Load_Vector5_Buffer is new GL.Objects.Buffers.Load_To_Buffer - (Maths.Vector5_Pointers); - procedure Load_Vector6_Buffer is new GL.Objects.Buffers.Load_To_Buffer - (Maths.Vector6_Pointers); - procedure Load_Vertex_Sub_Buffer is new - GL.Objects.Buffers.Set_Sub_Data (GL.Types.Singles.Vector3_Pointers); - procedure Load_Vertex_Sub_Buffer is new - GL.Objects.Buffers.Set_Sub_Data (GL.Types.Singles.Vector4_Pointers); - - procedure Print_Array6 (Name : String; anArray : Maths.Vector6_Array); - procedure Print_Byte_Array (Name : String; anArray : Byte_Array; - Start, Finish : GL.Types.UInt); - procedure Print_GL_Array2 (Name : String; anArray : GL.Types.Ints.Vector2_Array); - procedure Print_GL_Array2 (Name : String; anArray : GL.Types.Singles.Vector2_Array); - procedure Print_GL_Array3 (Name : String; anArray : GL.Types.Ints.Vector3_Array); - procedure Print_GL_Array3 (Name : String; anArray : GL.Types.Singles.Vector3_Array); - procedure Print_GL_Array4 (Name : String; anArray : GL.Types.Singles.Vector4_Array); - procedure Print_GL_Int_Array (Name : String; anArray : GL.Types.Int_Array); - procedure Print_GL_UInt_Array (Name : String; anArray : GL.Types.UInt_Array); - procedure Print_Matrix (Name : String; aMatrix : GL.Types.Singles.Matrix3); - procedure Print_Matrix (Name : String; aMatrix : GL.Types.Singles.Matrix4); - procedure Print_Singles_Array (Name : String; anArray : Singles_Array; - Start, Finish : GL.Types.Int); - procedure Print_Vector (Name : String; aVector : GL.Types.Singles.Vector2); - procedure Print_Vector (Name : String; aVector : GL.Types.Ints.Vector3); - procedure Print_Vector (Name : String; aVector : GL.Types.Singles.Vector3); - procedure Print_Vector (Name : String; aVector : GL.Types.Singles.Vector4); - procedure Show_Shader_Info_Log (aProgram : GL.Objects.Programs.Program); - procedure Show_Shader_Program_Data (aProgram : GL.Objects.Programs.Program); - procedure Show_GL_Data; - -end Utilities; diff --git a/examples/common/src/vbo_indexer.adb b/examples/common/src/vbo_indexer.adb deleted file mode 100644 index 205a8a85..00000000 --- a/examples/common/src/vbo_indexer.adb +++ /dev/null @@ -1,183 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -package body VBO_Indexer is - - function Is_Near (V1, V2 : GL.Types.Single) return Boolean; - - -- ------------------------------------------------------------------------- - - procedure Get_Similar_Vertex_Index - (Vertices_In : GL.Types.Singles.Vector3; - UVs_In : GL.Types.Singles.Vector2; - Normals_In : GL.Types.Singles.Vector3; - Vertices_Out : GL.Types.Singles.Vector3_Array; - UVs_Out : GL.Types.Singles.Vector2_Array; - Normals_Out : GL.Types.Singles.Vector3_Array; - Result : out GL.Types.UInt; Found : out Boolean) is - use GL.Types; - begin - Found := False; - Result := 0; - - for Index in Vertices_Out'Range loop - Found := Is_Near (Vertices_In (GL.X), Vertices_Out (Index) (GL.X)) and then - Is_Near (Vertices_In (GL.Y), Vertices_Out (Index) (GL.Y)) and then - Is_Near (Vertices_In (GL.Z), Vertices_Out (Index) (GL.Z)) and then - Is_Near (UVs_In (GL.X), UVs_Out (Index) (GL.X)) and then - Is_Near (UVs_In (GL.Y), UVs_Out (Index) (GL.Y)) and then - Is_Near (Normals_In (GL.X), Normals_Out (Index) (GL.X)) and then - Is_Near (Normals_In (GL.Y), Normals_Out (Index) (GL.Y)) and then - Is_Near (Normals_In (GL.Z), Normals_Out (Index) (GL.Z)); - if Found then - Result := GL.Types.UInt (Index - 1); - exit; - end if; - end loop; - - end Get_Similar_Vertex_Index; - - -- ------------------------------------------------------------------------- - - procedure Get_Similar_Vertex_Index - (Vertices_In : GL.Types.Singles.Vector3; - UVs_In : GL.Types.Singles.Vector2; - Vertices_Out : GL.Types.Singles.Vector3_Array; - UVs_Out : GL.Types.Singles.Vector2_Array; - Result : out GL.Types.UInt; Found : out Boolean) is - use GL.Types; - begin - Found := False; - Result := 0; - - for Index in Vertices_Out'Range loop - Found := Is_Near (Vertices_In (GL.X), Vertices_Out (Index) (GL.X)) and then - Is_Near (Vertices_In (GL.Y), Vertices_Out (Index) (GL.Y)) and then - Is_Near (Vertices_In (GL.Z), Vertices_Out (Index) (GL.Z)) and then - Is_Near (UVs_In (GL.X), UVs_Out (Index) (GL.X)) and then - Is_Near (UVs_In (GL.Y), UVs_Out (Index) (GL.Y)); - if Found then - Result := GL.Types.UInt (Index - 1); - exit; - end if; - end loop; - - end Get_Similar_Vertex_Index; - - -- ------------------------------------------------------------------------- - - procedure Index_VBO (Vertices_In : GL.Types.Singles.Vector3_Array; - UVs_In : GL.Types.Singles.Vector2_Array; - Normals_In : GL.Types.Singles.Vector3_Array; - Vertices_Out : out GL.Types.Singles.Vector3_Array; - UVs_Out : out GL.Types.Singles.Vector2_Array; - Normals_Out : out GL.Types.Singles.Vector3_Array; - VBO_Indices : out GL.Types.UInt_Array; - Last_VBO_Index : out GL.Types.Size; - Last_Vertex : out GL.Types.Int) is - use GL; - use GL.Types; - In_Size : constant Int := Vertices_In'Length; - Index : UInt := 0; - VBO_Indices_Index : Size := 0; - Out_Index : UInt := 0; - Found : Boolean; - begin - for Vert in 1 .. Int (Vertices_Out'Length) loop - for elem in Singles.Vector3'Range loop - Vertices_Out (Vert) (elem) := 0.0; - if elem /= GL.Z then - UVs_Out (Vert) (elem) := 0.0; - end if; - Normals_Out (Vert) (elem) := 0.0; - end loop; - end loop; - - for Vert in 1 .. In_Size loop - Get_Similar_Vertex_Index (Vertices_In (Vert), UVs_In (Vert), Normals_In (Vert), - Vertices_Out, UVs_Out, Normals_Out, - Index, Found); - VBO_Indices_Index := VBO_Indices_Index + 1; - if Found then - -- A similar vertex is already in the VBO so use it instead - VBO_Indices (VBO_Indices_Index) := Index; - else - -- No other vertex can be used instead so add it to the VBO. - Out_Index := Out_Index + 1; - Vertices_Out (Int (Out_Index)) := Vertices_In (Vert); - UVs_Out (Int (Out_Index)) := UVs_In (Vert); - Normals_Out (Int (Out_Index)) := Normals_In (Vert); - VBO_Indices (VBO_Indices_Index) := Out_Index - 1; - end if; - end loop; - Last_Vertex := Int (Out_Index); - Last_VBO_Index := VBO_Indices_Index; - - exception - when others => - Put_Line ("An exception occurred in Index_VBO."); - raise; - end Index_VBO; - - -- ------------------------------------------------------------------------- - - procedure Index_VBO (Vertices_In : GL.Types.Singles.Vector3_Array; - UVs_In : GL.Types.Singles.Vector2_Array; - Vertices_Out : out GL.Types.Singles.Vector3_Array; - UVs_Out : out GL.Types.Singles.Vector2_Array; - VBO_Indices : out GL.Types.UInt_Array; - Last_VBO_Index : out GL.Types.Size; - Last_Vertex : out GL.Types.Int) is - use GL; - use GL.Types; - In_Size : constant Int := Vertices_In'Length; - Index : UInt := 0; - VBO_Indices_Index : Size := 0; - Out_Index : UInt := 0; - Found : Boolean; - begin - -- Initialize output arrays - for Vert in 1 .. Int (Vertices_Out'Length) loop - for elem in Singles.Vector3'Range loop - Vertices_Out (Vert) (elem) := 0.0; - if elem /= GL.Z then - UVs_Out (Vert) (elem) := 0.0; - end if; - end loop; - end loop; - - for Vert in 1 .. In_Size loop - Get_Similar_Vertex_Index (Vertices_In (Vert), UVs_In (Vert), - Vertices_Out, UVs_Out, Index, Found); - VBO_Indices_Index := VBO_Indices_Index + 1; - if Found then - -- A similar vertex is already in the VBO so use it instead - VBO_Indices (VBO_Indices_Index) := Index; - else - -- No other vertex can be used instead so add it to the VBO. - Out_Index := Out_Index + 1; - Vertices_Out (Int (Out_Index)) := Vertices_In (Vert); - UVs_Out (Int (Out_Index)) := UVs_In (Vert); - VBO_Indices (VBO_Indices_Index) := Out_Index - 1; - end if; - end loop; - Last_Vertex := Int (Out_Index); - Last_VBO_Index := VBO_Indices_Index; - - exception - when others => - Put_Line ("An exception occurred in Index_VBO."); - raise; - end Index_VBO; - - -- ------------------------------------------------------------------------- - - function Is_Near (V1, V2 : GL.Types.Single) return Boolean is - use GL.Types; - begin - return Abs (V2 - V1) < 0.01; - end Is_Near; - - -- ------------------------------------------------------------------------- - -end VBO_Indexer; diff --git a/examples/common/src/vbo_indexer.ads b/examples/common/src/vbo_indexer.ads deleted file mode 100644 index 5afb1728..00000000 --- a/examples/common/src/vbo_indexer.ads +++ /dev/null @@ -1,25 +0,0 @@ - -with GL.Types; - -package VBO_Indexer is - - type Indices_Array is array (GL.Types.Int range <>) of GL.Types.Int; - - procedure Index_VBO (Vertices_In : GL.Types.Singles.Vector3_Array; - UVs_In : GL.Types.Singles.Vector2_Array; - Normals_In : GL.Types.Singles.Vector3_Array; - Vertices_Out : out GL.Types.Singles.Vector3_Array; - UVs_Out : out GL.Types.Singles.Vector2_Array; - Normals_Out : out GL.Types.Singles.Vector3_Array; - VBO_Indices : out GL.Types.UInt_Array; - Last_VBO_Index : out GL.Types.Size; - Last_Vertex : out GL.Types.Int); - - procedure Index_VBO (Vertices_In : GL.Types.Singles.Vector3_Array; - UVs_In : GL.Types.Singles.Vector2_Array; - Vertices_Out : out GL.Types.Singles.Vector3_Array; - UVs_Out : out GL.Types.Singles.Vector2_Array; - VBO_Indices : out GL.Types.UInt_Array; - Last_VBO_Index : out GL.Types.Size; - Last_Vertex : out GL.Types.Int); -end VBO_Indexer; diff --git a/examples/durian/Readme.md b/examples/durian/Readme.md deleted file mode 100644 index 65d02ea2..00000000 --- a/examples/durian/Readme.md +++ /dev/null @@ -1,15 +0,0 @@ -Author: Roger Mc Murtrie -These examples are based on the tutorials available at http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html using Glfw version 3. -The version numbers in the shader programs may need modification depending on your -platform. -For Mac users, note that the Glfw provided with OSX is incompatible with OpenGLAda as it does not contain libglfw.a. -A compatible version can be obtained from Homebrew: brew install glfw. - -GNAT Programming Studio (GPS) Considerations -Use Tools->Views->Scenarios to display the Scenario panel. -In the Scenario panel set GLFW Version to 3. -For Mac, in the Scenario panel set Windowing System to quartz. -In Preferences, ensure that Editor->Fonts & Colors->Default is set to a fixed size font. -In Preferences->Editor->Ada set appropriate format selectors. - - diff --git a/examples/durian/buffers_and_textures/.gitignore b/examples/durian/buffers_and_textures/.gitignore deleted file mode 100644 index 3928cbbf..00000000 --- a/examples/durian/buffers_and_textures/.gitignore +++ /dev/null @@ -1 +0,0 @@ -hello_textures diff --git a/examples/durian/buffers_and_textures/buffers_and_textures.gpr b/examples/durian/buffers_and_textures/buffers_and_textures.gpr deleted file mode 100644 index 9c08fa25..00000000 --- a/examples/durian/buffers_and_textures/buffers_and_textures.gpr +++ /dev/null @@ -1,16 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-soil.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Buffers_And_Textures is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Main use ("hello_textures.adb"); - for Exec_Dir use "."; - - package Compiler renames OpenGL.Compiler; - -end Buffers_And_Textures; - diff --git a/examples/durian/buffers_and_textures/src/hello1.tga b/examples/durian/buffers_and_textures/src/hello1.tga deleted file mode 100755 index 1b24ead6..00000000 Binary files a/examples/durian/buffers_and_textures/src/hello1.tga and /dev/null differ diff --git a/examples/durian/buffers_and_textures/src/hello2.tga b/examples/durian/buffers_and_textures/src/hello2.tga deleted file mode 100755 index 585b906e..00000000 Binary files a/examples/durian/buffers_and_textures/src/hello2.tga and /dev/null differ diff --git a/examples/durian/buffers_and_textures/src/hello_textures.adb b/examples/durian/buffers_and_textures/src/hello_textures.adb deleted file mode 100644 index cc533db2..00000000 --- a/examples/durian/buffers_and_textures/src/hello_textures.adb +++ /dev/null @@ -1,32 +0,0 @@ --- Program Hello_Textures --- Author Roger Mc Murtrie --- Created 13 February 2017 --- Based on Durian Software's --- An intro to modern OpenGL. Chapter 2.1: Buffers and Textures - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Hello_Textures is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Durian - Buffers And Textures Example"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Hello_Textures returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Hello_Textures."); - Put_Line (Exception_Information (anError)); -end Hello_Textures; diff --git a/examples/durian/buffers_and_textures/src/main_loop.adb b/examples/durian/buffers_and_textures/src/main_loop.adb deleted file mode 100644 index 910198a3..00000000 --- a/examples/durian/buffers_and_textures/src/main_loop.adb +++ /dev/null @@ -1,136 +0,0 @@ - -with Ada.Strings.Unbounded; -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Vertex_Arrays; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Program_Loader; -with Utilities; - -with Maths; -with My_Buffers; - - -- ------------------------------------------------------------------------ - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : My_Buffers.tBuffer; - Element_Buffer : My_Buffers.tBuffer; - Textures : My_Buffers.tTexture_List (0 .. 1); - Fade_Factor : GL.Types.Single := 1.0; - Fade_Factor_Location : GL.Uniforms.Uniform; - Texture_Location : array (0 .. 1) of GL.Uniforms.Uniform; - Position_Location : GL.Attributes.Attribute; - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types; - use GL.Objects.Textures.Targets; - use Maths.Single_Math_Functions; - - Back_Colour : constant Colors.Color := (1.0, 1.0, 1.0, 1.0); - Stride_Bytes : constant Size := 8; - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - Fade_Factor := 0.5 * (1.0 + Sin (Single (Glfw.Time))); - - GL.Objects.Programs.Use_Program (Rendering_Program); - - GL.Uniforms.Set_Single (Fade_Factor_Location, Fade_Factor); - - GL.Objects.Textures.Set_Active_Unit (0); - Texture_2D.Bind (Textures (0)); - GL.Uniforms.Set_Int (Texture_Location (0), 0); - - GL.Objects.Textures.Set_Active_Unit (1); - Texture_2D.Bind (Textures (1)); - GL.Uniforms.Set_Int (Texture_Location (1), 1); - - GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (Position_Location, 2, GL.Types.Single_Type, False, Stride_Bytes, 0); - GL.Attributes.Enable_Vertex_Attrib_Array (Position_Location); - - GL.Objects.Buffers.Element_Array_Buffer.Bind (Element_Buffer); - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangle_Strip, 0, 4); - - exception - when others => - Put_Line ("An exceptiom occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic is - use Ada.Strings.Unbounded; - use GL.Objects.Shaders; - use Program_Loader; - Images : constant My_Buffers.tImage_Sources (1 .. 2) := - (To_Unbounded_String ("src/hello1.tga"), - To_Unbounded_String ("src/hello2.tga")); - begin - Rendering_Program := Program_From - ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - My_Buffers.Setup_Buffers (Vertex_Buffer, Element_Buffer); - My_Buffers.Setup_Textures (Textures, Images); - - Fade_Factor_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "fade_factor"); - Texture_Location (0) := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "textures[0]"); - Texture_Location (1) := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "textures[1]"); - Position_Location := - GL.Objects.Programs.Attrib_Location (Rendering_Program, "position"); - - Utilities.Show_Shader_Program_Data (Rendering_Program); - - exception - when others => - Put_Line ("An exception occurred in Setup_Graphic."); - raise; - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when Program_Loader.Shader_Loading_Error => - -- message has already been written to stdout - raise; - when others => - Put_Line ("An exceptiom occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/durian/buffers_and_textures/src/main_loop.ads b/examples/durian/buffers_and_textures/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/durian/buffers_and_textures/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/durian/buffers_and_textures/src/my_buffers.adb b/examples/durian/buffers_and_textures/src/my_buffers.adb deleted file mode 100644 index f8768a85..00000000 --- a/examples/durian/buffers_and_textures/src/my_buffers.adb +++ /dev/null @@ -1,111 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Textures.Targets; -with GL.Pixels; -with GL.Types; use GL.Types; - -with SOIL; -with SOIL.Images; - -with Utilities; -with Vertex_Data; - -package body My_Buffers is - - Image_Error : exception; - - -- ------------------------------------------------------------------------ - - procedure Make_Texture (Texture : in out GL.Objects.Textures.Texture; - Image_File_Name : String) is - use GL.Objects.Textures.Targets; - use GL.Pixels; - Width : GL.Types.Size; - Height : GL.Types.Size; - Image : SOIL.Images.Image; - begin - Image.Load (Image_File_Name); - Width := SOIL.Images.Width (Image); - Height := SOIL.Images.Height (Image); - if not SOIL.Images.Loaded (Image) then - Put_Line ("Load_Image; " & Image_File_Name & " failed to load."); - raise Image_Error; - end if; - - Texture.Initialize_Id; - Texture_2D.Bind (Texture); - Texture_2D.Set_Minifying_Filter (GL.Objects.Textures.Linear); - Texture_2D.Set_Magnifying_Filter (GL.Objects.Textures.Linear); - Texture_2D.Set_X_Wrapping (GL.Objects.Textures.Clamp_To_Edge); -- Wrap_S - Texture_2D.Set_Y_Wrapping (GL.Objects.Textures.Clamp_To_Edge); -- Wrap_T - - Texture_2D.Load_From_Data (0, RGB, Width, Height, RGB, Unsigned_Byte, - Image.Data); - exception - when others => - Put_Line ("An exceptiom occurred in Make_Texture."); - raise; - end Make_Texture; - - -- ------------------------------------------------------------------------ - - procedure Make_Buffer (Target : GL.Objects.Buffers.Buffer_Target; - Buffer : in out tBuffer) is - begin - Buffer.Initialize_Id; - Target.Bind (Buffer); - end Make_Buffer; - - -- ------------------------------------------------------------------------ - - procedure Setup_Buffers (Vertex_Buffer : in out tBuffer; - Element_Buffer : in out tBuffer) is - use GL.Objects.Buffers; - - Stride : constant GL.Types.Size := - GL.Types.Size (Vertex_Data.Vertex_Array_Size) * 4; - begin - Make_Buffer (GL.Objects.Buffers.Array_Buffer, Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertex_Data.Vertices, Static_Draw); - - Make_Buffer (GL.Objects.Buffers.Element_Array_Buffer, Element_Buffer); - Vertex_Data.Load_Element_Buffer (Element_Array_Buffer, - Vertex_Data.Elements, Static_Draw); - - GL.Attributes.Set_Vertex_Attrib_Pointer (Index => 0, Count => 3, - Kind => GL.Types.Single_Type, - Normalized => False, - Stride => Stride, Offset => 0); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - - GL.Attributes.Set_Vertex_Attrib_Pointer (1, 2, GL.Types.Single_Type, - False, Stride, 3); - GL.Attributes.Enable_Vertex_Attrib_Array (1); - - exception - when others => - Put_Line ("An exception occurred in Setup_Buffers."); - raise; - end Setup_Buffers; - - -- ------------------------------------------------------------------------ - - procedure Setup_Textures (Textures : in out tTexture_List; - Images : tImage_Sources) is - use Ada.Strings.Unbounded; - Image_Index : Positive := 1; - begin - for Index in Textures'Range loop - Make_Texture (Textures (Index), To_String (Images (Image_Index))); - Put_Line ("Setup_Textures; image " & To_String (Images (Image_Index)) & " loaded."); - Image_Index := Image_Index + 1; - end loop; - exception - when others => - Put_Line ("An exception occurred in Setup_Textures."); - raise; - end Setup_Textures; - -end My_Buffers; diff --git a/examples/durian/buffers_and_textures/src/my_buffers.ads b/examples/durian/buffers_and_textures/src/my_buffers.ads deleted file mode 100644 index bbee2e78..00000000 --- a/examples/durian/buffers_and_textures/src/my_buffers.ads +++ /dev/null @@ -1,19 +0,0 @@ - -with Ada.Strings.Unbounded; -with GL.Buffers; -with GL.Objects.Buffers; -with GL.Objects.Textures; - -package My_Buffers is - - subtype tBuffer is GL.Objects.Buffers.Buffer; - subtype tBuffer_List is GL.Buffers.Explicit_Color_Buffer_List; - - type tTexture_List is array (Natural range <>) of GL.Objects.Textures.Texture; - type tImage_Sources is array (Positive range <>) of Ada.Strings.Unbounded.Unbounded_String; - - procedure Setup_Buffers (Vertex_Buffer : in out tBuffer; - Element_Buffer : in out tBuffer); - procedure Setup_Textures (Textures : in out tTexture_List; - Images : tImage_Sources); -end My_Buffers; diff --git a/examples/durian/buffers_and_textures/src/shaders/fragment_shader.glsl b/examples/durian/buffers_and_textures/src/shaders/fragment_shader.glsl deleted file mode 100755 index 8f6189c3..00000000 --- a/examples/durian/buffers_and_textures/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,17 +0,0 @@ -#version 410 - -uniform float fade_factor; -uniform sampler2D textures[2]; - -in vec2 texcoord; - -out vec4 Frag_Colour; - -void main() -{ - vec2 flipped_texcoord = vec2(texcoord.x, 1.0 - texcoord.y); - Frag_Colour = mix( - texture(textures[0], flipped_texcoord), - texture(textures[1], flipped_texcoord), - fade_factor); -} diff --git a/examples/durian/buffers_and_textures/src/shaders/vertex_shader.glsl b/examples/durian/buffers_and_textures/src/shaders/vertex_shader.glsl deleted file mode 100755 index a84fa70d..00000000 --- a/examples/durian/buffers_and_textures/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,11 +0,0 @@ -#version 410 - -in vec2 position; - -out vec2 texcoord; - -void main() -{ - gl_Position = vec4(position, 0.0, 1.0); - texcoord = position * vec2(0.5) + vec2(0.5); -} diff --git a/examples/durian/buffers_and_textures/src/vertex_data.ads b/examples/durian/buffers_and_textures/src/vertex_data.ads deleted file mode 100644 index 9f456f2b..00000000 --- a/examples/durian/buffers_and_textures/src/vertex_data.ads +++ /dev/null @@ -1,26 +0,0 @@ - -with Interfaces.C.Pointers; - -with GL.Objects.Buffers; -with GL.Types; - -package Vertex_Data is - use GL.Types; - - type Elements_Array is array (GL.Types.Int range <>) of aliased GL.Types.Int; - - package Element_Pointers is new Interfaces.C.Pointers - (GL.Types.Int, GL.Types.Int, Elements_Array, 0); - - procedure Load_Element_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (Element_Pointers); - - Vertex_Array_Size : GL.Types.Int := 4 * 2; - Vertices : constant Singles.Vector2_Array (1 .. 4) := - ((-1.0, -1.0), - (1.0, -1.0), - (-1.0, 1.0), - (1.0, 1.0)); - - Elements : Elements_Array (1 .. 4) := (0, 1, 2, 3); -end Vertex_Data; diff --git a/examples/durian/hello/.gitignore b/examples/durian/hello/.gitignore deleted file mode 100644 index 1a9d2add..00000000 --- a/examples/durian/hello/.gitignore +++ /dev/null @@ -1 +0,0 @@ -trivial diff --git a/examples/durian/hello/hello_durian.gpr b/examples/durian/hello/hello_durian.gpr deleted file mode 100644 index 77a26e2a..00000000 --- a/examples/durian/hello/hello_durian.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -limited with "../../../opengl-glfw.gpr"; -with "../../../opengl.gpr"; - -project Hello_Durian is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("trivial.adb"); - - package Compiler renames OpenGL.Compiler; - -end Hello_Durian; - diff --git a/examples/durian/hello/src/main_loop.adb b/examples/durian/hello/src/main_loop.adb deleted file mode 100644 index 7e140c60..00000000 --- a/examples/durian/hello/src/main_loop.adb +++ /dev/null @@ -1,44 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Types.Colors; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Utilities; - --- ------------------------------------------------------------------------ - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - procedure Render is - Back_Colour : constant GL.Types.Colors.Color := (1.0, 1.0, 1.0, 1.0); - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/durian/hello/src/main_loop.ads b/examples/durian/hello/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/durian/hello/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/durian/hello/src/trivial.adb b/examples/durian/hello/src/trivial.adb deleted file mode 100644 index 043910ef..00000000 --- a/examples/durian/hello/src/trivial.adb +++ /dev/null @@ -1,33 +0,0 @@ --- Program Trivial --- Author Roger Mc Murtrie --- Created 13 Febuary 2017 --- Based on Durian Software's --- An intro to modern OpenGL. Chapter 2: Hello World --- Extremely trivial. Just displays a window. - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Trivial is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Durian Software - Hello"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Trivial returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Trivial."); - Put_Line (Exception_Information (anError)); -end Trivial; diff --git a/examples/freetype_gl/.gitignore b/examples/freetype_gl/.gitignore deleted file mode 100644 index 365ac591..00000000 --- a/examples/freetype_gl/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -lib -obj -bin -.DS_Store -.#*# -hello_character -store_character -render_text - diff --git a/examples/freetype_gl/fonts/NotoColorEmoji.ttf b/examples/freetype_gl/fonts/NotoColorEmoji.ttf deleted file mode 100644 index ef7b7257..00000000 Binary files a/examples/freetype_gl/fonts/NotoColorEmoji.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoEmoji-Regular.ttf b/examples/freetype_gl/fonts/NotoEmoji-Regular.ttf deleted file mode 100644 index 19b7badf..00000000 Binary files a/examples/freetype_gl/fonts/NotoEmoji-Regular.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoMono-Regular.ttf b/examples/freetype_gl/fonts/NotoMono-Regular.ttf deleted file mode 100644 index 3560a3a0..00000000 Binary files a/examples/freetype_gl/fonts/NotoMono-Regular.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoSans-Bold.ttf b/examples/freetype_gl/fonts/NotoSans-Bold.ttf deleted file mode 100644 index ab4cdeed..00000000 Binary files a/examples/freetype_gl/fonts/NotoSans-Bold.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoSans-BoldItalic.ttf b/examples/freetype_gl/fonts/NotoSans-BoldItalic.ttf deleted file mode 100644 index c10e146c..00000000 Binary files a/examples/freetype_gl/fonts/NotoSans-BoldItalic.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoSans-Italic.ttf b/examples/freetype_gl/fonts/NotoSans-Italic.ttf deleted file mode 100644 index 1aa2a520..00000000 Binary files a/examples/freetype_gl/fonts/NotoSans-Italic.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoSans-Regular.ttf b/examples/freetype_gl/fonts/NotoSans-Regular.ttf deleted file mode 100644 index ebd7703f..00000000 Binary files a/examples/freetype_gl/fonts/NotoSans-Regular.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoSerif-Bold.ttf b/examples/freetype_gl/fonts/NotoSerif-Bold.ttf deleted file mode 100644 index 50b12d3f..00000000 Binary files a/examples/freetype_gl/fonts/NotoSerif-Bold.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoSerif-BoldItalic.ttf b/examples/freetype_gl/fonts/NotoSerif-BoldItalic.ttf deleted file mode 100644 index 741402e9..00000000 Binary files a/examples/freetype_gl/fonts/NotoSerif-BoldItalic.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoSerif-Italic.ttf b/examples/freetype_gl/fonts/NotoSerif-Italic.ttf deleted file mode 100644 index 84349fb1..00000000 Binary files a/examples/freetype_gl/fonts/NotoSerif-Italic.ttf and /dev/null differ diff --git a/examples/freetype_gl/fonts/NotoSerif-Regular.ttf b/examples/freetype_gl/fonts/NotoSerif-Regular.ttf deleted file mode 100644 index ec8afe61..00000000 Binary files a/examples/freetype_gl/fonts/NotoSerif-Regular.ttf and /dev/null differ diff --git a/examples/freetype_gl/readme.md b/examples/freetype_gl/readme.md deleted file mode 100644 index 633aee59..00000000 --- a/examples/freetype_gl/readme.md +++ /dev/null @@ -1,15 +0,0 @@ -Author: Roger Mc Murtrie -These examples are loosely based on text rendering code that uses shaders from various sources. -Most text rendering tutorials and examples that I could find do not use shaders but use the now-deprecated immediate pipeline. -A useful tutorial is Learn OpenGL>In Practice>Text Rendering at https://learnopengl.com/#!In-Practice/Text-Rendering. This tutorial uses FreeType directly to load fonts. -The version numbers in the shader programs may need modification depending on your -platform. - -GNAT Programming Studio (GPS) Considerations -Use Tools->Views->Scenarios to display the Scenario panel. -In the Scenario panel set GLFW Version to 3. -For Mac, in the Scenario panel set Windowing System to quartz. -In Preferences, ensure that Editor->Fonts & Colors->Default is set to a fixed size font. -In Preferences->Editor->Ada set appropriate format selectors. - - diff --git a/examples/freetype_gl/single_character/.gitignore b/examples/freetype_gl/single_character/.gitignore deleted file mode 100644 index ad527c8c..00000000 --- a/examples/freetype_gl/single_character/.gitignore +++ /dev/null @@ -1 +0,0 @@ -hello_character diff --git a/examples/freetype_gl/single_character/render_a_character.gpr b/examples/freetype_gl/single_character/render_a_character.gpr deleted file mode 100644 index b3bedeb1..00000000 --- a/examples/freetype_gl/single_character/render_a_character.gpr +++ /dev/null @@ -1,16 +0,0 @@ -with "../../common/common.gpr"; -with "../../../FreeTypeAda/freetype.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Render_A_Character is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Main use ("hello_character.adb"); - for Exec_Dir use "."; - - package Compiler renames OpenGL.Compiler; - -end Render_A_Character; - diff --git a/examples/freetype_gl/single_character/src/hello_character.adb b/examples/freetype_gl/single_character/src/hello_character.adb deleted file mode 100644 index 41861ccf..00000000 --- a/examples/freetype_gl/single_character/src/hello_character.adb +++ /dev/null @@ -1,32 +0,0 @@ --- Program Hello_Character --- Author Roger Mc Murtrie --- Created 25 August 2017 --- Based on Durian Software's --- An intro to modern OpenGL. Chapter 2.1: Buffers and Textures - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Hello_Character is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Single Freetype Character Example"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Hello_Character returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Hello_Character."); - Put_Line (Exception_Information (anError)); -end Hello_Character; diff --git a/examples/freetype_gl/single_character/src/main_loop.adb b/examples/freetype_gl/single_character/src/main_loop.adb deleted file mode 100644 index ac4afc9f..00000000 --- a/examples/freetype_gl/single_character/src/main_loop.adb +++ /dev/null @@ -1,152 +0,0 @@ - -with Ada.Command_Line; -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Blending; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Vertex_Arrays; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Toggles; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; -with GL.Window; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; - -with Texture_Manager; - --- ------------------------------------------------------------------------ - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - use GL.Types; - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : Texture_Manager.V_Buffer; - Char_Texture : GL.Objects.Textures.Texture; - Colour_Location : GL.Uniforms.Uniform; - Projection_Location : GL.Uniforms.Uniform; - Texture_Location : GL.Uniforms.Uniform; - Projection_Matrix : Singles.Matrix4; - - Back_Colour : constant GL.Types.Colors.Color := (0.3, 0.6, 0.6, 1.0); - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types.Colors; - use GL.Objects.Buffers; - use GL.Objects.Textures.Targets; - Num_Vertices : constant GL.Types.Int := 2 * 3; -- Two triangles - Num_Components : constant GL.Types.Int := 4; -- Coords vector size; - Text_Colour : constant Basic_Color := (0.5, 0.2, 0.6); - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - Vertex_Array.Bind; - - GL.Objects.Programs.Use_Program (Rendering_Program); - - GL.Objects.Textures.Set_Active_Unit (0); - Texture_2D.Bind (Char_Texture); - GL.Uniforms.Set_Int (Texture_Location, 0); - GL.Uniforms.Set_Single (Colour_Location, Text_Colour (R), Text_Colour (G), Text_Colour (B)); - GL.Uniforms.Set_Single (Projection_Location, Projection_Matrix); - - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer (Index => 0, Count => Num_Components, - Kind => Single_Type, - Normalized => False, - Stride => 0, Offset => 0); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, Num_Vertices); - GL.Attributes.Disable_Vertex_Attrib_Array (0); - exception - when others => - Put_Line ("An exception occurred in Main_Loop.Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window; - Test_Character : Character) is - use GL.Objects.Shaders; - use Program_Loader; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - begin - Window.Get_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (0, 0, GL.Types.Int (Window_Width), - GL.Types.Int (Window_Height)); - -- Blending allows a fragment colour's alpha value to control the resulting - -- colour which will be transparent for all the glyph's background colours and - -- non-transparent for the actual character pixels. - GL.Toggles.Enable (GL.Toggles.Blend); - GL.Blending.Set_Blend_Func (GL.Blending.Src_Alpha, GL.Blending.One_Minus_Src_Alpha); - - Maths.Init_Orthographic_Transform (Single (Window_Height), 0.0, 0.0, - Single (Window_Width), 0.1, -100.0, Projection_Matrix); - - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Rendering_Program := Program_From - ((Src ("src/shaders/gl1_vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/gl1_fragment_shader.glsl", Fragment_Shader))); - -- Character position must be within window bounds. - Texture_Manager.Setup_Graphic (Vertex_Buffer, Char_Texture, 50.0, 50.0, 4.0, Test_Character); - - Projection_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "projection_matrix"); - Texture_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "bitmap_image"); - Colour_Location := GL.Objects.Programs.Uniform_Location - (Rendering_Program, "text_colour"); - exception - when others => - Put_Line ("An exception occurred in Main_Loop.Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; - Test_Character : Character := 'x'; -begin - if Ada.Command_Line.Argument_Count /= 1 then - Ada.Text_IO.Put_Line ("No character entered, so displaying the default character."); - else - Test_Character := Ada.Command_Line.Argument (1) (1); - end if; - - Setup (Main_Window, Test_Character); - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when Program_Loader.Shader_Loading_Error => - -- message has been written to stdout - raise; - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; - -end Main_Loop; diff --git a/examples/freetype_gl/single_character/src/main_loop.ads b/examples/freetype_gl/single_character/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/freetype_gl/single_character/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/freetype_gl/single_character/src/shaders/gl1_fragment_shader.glsl b/examples/freetype_gl/single_character/src/shaders/gl1_fragment_shader.glsl deleted file mode 100755 index a21dd7e7..00000000 --- a/examples/freetype_gl/single_character/src/shaders/gl1_fragment_shader.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 410 core - -in vec2 texture_coords; -out vec4 frag_colour; - -uniform sampler2D bitmap_image; // Mono-colored bitmap image -uniform vec3 text_colour; - -void main() -{ - vec2 flipped_coords = vec2(texture_coords.x, 1.0 - texture_coords.y); - vec4 sampled = vec4 (1.0, 1.0, 1.0, texture(bitmap_image, flipped_coords).r); - frag_colour = vec4(text_colour, 1.0) * sampled; -} diff --git a/examples/freetype_gl/single_character/src/shaders/gl1_vertex_shader.glsl b/examples/freetype_gl/single_character/src/shaders/gl1_vertex_shader.glsl deleted file mode 100755 index 0b828b59..00000000 --- a/examples/freetype_gl/single_character/src/shaders/gl1_vertex_shader.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 410 core - -layout(location = 0) in vec4 vertices; // - -out vec2 texture_coords; -uniform mat4 projection_matrix; - -void main() -{ - gl_Position = projection_matrix * vec4(vertices.xy, 0.0, 1.0); - texture_coords = vec2(vertices.zw); -} diff --git a/examples/freetype_gl/single_character/src/texture_manager.adb b/examples/freetype_gl/single_character/src/texture_manager.adb deleted file mode 100644 index 2d16438f..00000000 --- a/examples/freetype_gl/single_character/src/texture_manager.adb +++ /dev/null @@ -1,122 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Textures.Targets; -with GL.Pixels; - -with FT; -with FT.Faces; -with FT.Glyphs; -with FT.Utilities; - -with Utilities; - -package body Texture_Manager is - - Face_Ptr : FT.Faces.Face_Reference; - Vertex_Data : Vertex_Array; - - procedure Setup_Buffer (Vertex_Buffer : in out V_Buffer; - X, Y, Scale : GL.Types.Single); - procedure Setup_Font (My_Library : FT.Library_Reference); - procedure Setup_Texture (aTexture : in out GL.Objects.Textures.Texture); - - -- ------------------------------------------------------------------------ - - procedure Setup_Buffer (Vertex_Buffer : in out V_Buffer; - X, Y, Scale : GL.Types.Single) is - use GL.Objects.Buffers; - use GL.Types; - Num_Triangles : constant Int := 2; - Stride : constant Int := 4 * 4; - X_Pos : constant Single := X; - Y_Pos : constant Single := Y; - Width : Single; - Height : Single; - Bitmap : constant FT.Bitmap_Record := - FT.Glyphs.Bitmap (Face_Ptr.Glyph_Slot); - begin - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Width := Single (Bitmap.Width) * Scale; - Height := Single (Bitmap.Rows) * Scale; - Vertex_Data := ( - (X_Pos, Y_Pos, 0.0, 0.0), -- Lower left - (X_Pos + Width, Y_Pos, 1.0, 0.0), -- Lower right - (X_Pos, Y_Pos + Height, 0.0, 1.0), -- Upper left - - (X_Pos, Y_Pos + Height, 0.0, 1.0), -- Upper left - (X_Pos + Width, Y_Pos + Height, 1.0, 1.0), -- Upper Right - (X_Pos + Width, Y_Pos, 1.0, 0.0)); -- Lower right - - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertex_Data, Static_Draw); - GL.Attributes.Set_Vertex_Attrib_Pointer (Index => 0, Count => Num_Triangles, - Kind => GL.Types.Single_Type, - Normalized => False, - Stride => Stride, Offset => 0); - end Setup_Buffer; - - -- ------------------------------------------------------------------------ - - procedure Setup_Font (My_Library : FT.Library_Reference) is - Font_File : constant String := "../fonts/NotoSerif-Regular.ttf"; - begin - FT.Faces.New_Face (My_Library, Font_File, 0, Face_Ptr); - -- Set pixel size to 48 x 48 - FT.Faces.Set_Pixel_Sizes (Face_Ptr, 0, 48); - GL.Pixels.Set_Unpack_Alignment (GL.Pixels.Bytes); -- Disable byte-alignment restriction - end Setup_Font; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic (Vertex_Buffer : in out V_Buffer; - aTexture : in out GL.Objects.Textures.Texture; - X, Y : GL.Types.Single; Scale : GL.Types.Single; - Char : Character := 'g') is - - My_Library : FT.Library_Reference; - begin - My_Library.Init; - Setup_Font (My_Library); - FT.Faces.Load_Character - (Face_Ptr, Character'Pos (Char), FT.Faces.Load_Render); - - -- Ensure that the glyph image is an anti-aliased bitmap - FT.Glyphs.Render_Glyph (Face_Ptr.Glyph_Slot, FT.Faces.Render_Mode_Mono); - FT.Utilities.Print_Character_Metadata (Face_Ptr, Char); - - Setup_Buffer (Vertex_Buffer, X, Y, Scale); - Setup_Texture (aTexture); - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - procedure Setup_Texture (aTexture : in out GL.Objects.Textures.Texture) is - use GL.Objects.Textures.Targets; - use GL.Pixels; - use GL.Types; - - Bitmap : constant FT.Bitmap_Record := - FT.Glyphs.Bitmap (Face_Ptr.Glyph_Slot); - Width : constant Size := Size (Bitmap.Width); - Height : constant Size := Size (Bitmap.Rows); - begin - aTexture.Initialize_Id; - Texture_2D.Bind (aTexture); - Texture_2D.Set_Minifying_Filter (GL.Objects.Textures.Linear); - Texture_2D.Set_Magnifying_Filter (GL.Objects.Textures.Linear); - Texture_2D.Set_X_Wrapping (GL.Objects.Textures.Clamp_To_Edge); -- Wrap_S - Texture_2D.Set_Y_Wrapping (GL.Objects.Textures.Clamp_To_Edge); -- Wrap_T - Texture_2D.Load_From_Data - (0, Red, Width, Height, Red, Unsigned_Byte, - GL.Objects.Textures.Image_Source (Bitmap.Buffer)); - exception - when others => - Put_Line ("An exception occurred in Texture_Manager.Setup_Texture."); - raise; - end Setup_Texture; - - -- ------------------------------------------------------------------------ - -end Texture_Manager; diff --git a/examples/freetype_gl/single_character/src/texture_manager.ads b/examples/freetype_gl/single_character/src/texture_manager.ads deleted file mode 100644 index 6e32c991..00000000 --- a/examples/freetype_gl/single_character/src/texture_manager.ads +++ /dev/null @@ -1,17 +0,0 @@ - -with GL.Objects.Buffers; -with GL.Objects.Textures; -with GL.Types; - -package Texture_Manager is - - subtype V_Buffer is GL.Objects.Buffers.Buffer; - -- 2D quad as two triangles requires 2 * 3 vertices of 4 floats - subtype Vertex_Array is GL.Types.Singles.Vector4_Array (1 .. 6); - - procedure Setup_Graphic (Vertex_Buffer : in out V_Buffer; - aTexture : in out GL.Objects.Textures.Texture; - X, Y : GL.Types.Single; - Scale : GL.Types.Single; - Char : Character := 'g'); -end Texture_Manager; diff --git a/examples/freetype_gl/text_rendering/.gitignore b/examples/freetype_gl/text_rendering/.gitignore deleted file mode 100644 index 4a657b04..00000000 --- a/examples/freetype_gl/text_rendering/.gitignore +++ /dev/null @@ -1 +0,0 @@ -render_text diff --git a/examples/freetype_gl/text_rendering/src/main_loop.adb b/examples/freetype_gl/text_rendering/src/main_loop.adb deleted file mode 100644 index 62a57096..00000000 --- a/examples/freetype_gl/text_rendering/src/main_loop.adb +++ /dev/null @@ -1,125 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Toggles; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input; -with Glfw.Input.Keys; -with GL.Window; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; - -with Texture_Management; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Render_Program : GL.Objects.Programs.Program; - Texture_ID : GL.Uniforms.Uniform; - Projection_Matrix_ID : GL.Uniforms.Uniform; - Colour_ID : GL.Uniforms.Uniform; - Projection_Matrix : GL.Types.Singles.Matrix4; - - Background : constant GL.Types.Colors.Color := (0.4, 0.6, 0.6, 1.0); - Text_Colour : constant GL.Types.Colors.Basic_Color := (0.5, 0.2, 0.6); - Font_File_1 : constant String := "../fonts/NotoSerif-Regular.ttf"; - - -- ------------------------------------------------------------------------ - - procedure Render_The_Text (Text : String; X, Y, Scale : GL.Types.Single; - Colour : GL.Types.Colors.Basic_Color); - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window) is - use GL.Types; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - Pos_X : constant GL.Types.Single := 5.0; - Pos_Y : constant GL.Types.Single := 50.0; - Scale_1 : constant GL.Types.Single := 0.4; - Scale_2 : constant GL.Types.Single := 0.6; - begin - Window.Get_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (0, 0, GL.Types.Int (Window_Width), - GL.Types.Int (Window_Height)); - Utilities.Clear_Background_Colour_And_Depth (Background); - Maths.Init_Orthographic_Transform (Single (Window_Height), 0.0, 0.0, - Single (Window_Width), 0.1, -100.0, - Projection_Matrix); - Render_The_Text ("The Quick Brown Fox jumps over the zoo's Lazy Dog.", - Pos_X, Pos_Y, Scale_1, Text_Colour); - Render_The_Text ("1234567890 !@#$%^&*()_+=,./?;':""{}[]\|~`", - Pos_X + 20.0, Pos_Y + 150.0, Scale_2, Text_Colour); - end Render; - - -- ------------------------------------------------------------------------ - - procedure Render_The_Text (Text : String; X, Y, Scale : GL.Types.Single; - Colour : GL.Types.Colors.Basic_Color) is - begin - Texture_Management.Render_Text (Render_Program, Text, X, Y, Scale, Colour, - Texture_ID, Projection_Matrix_ID, Colour_ID, - Projection_Matrix); - end Render_The_Text; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window) is - use GL.Objects.Programs; - use GL.Objects.Shaders; - use Program_Loader; - - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - begin - Window.Get_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (0, 0, GL.Types.Int (Window_Width), - GL.Types.Int (Window_Height)); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - - Render_Program := Program_From - ((Src ("src/shaders/text_vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/text_fragment_shader.glsl", Fragment_Shader))); - Use_Program (Render_Program); - - Projection_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "projection_matrix"); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "text_sampler"); - Colour_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "text_colour"); - - GL.Uniforms.Set_Single (Projection_Matrix_ID, Projection_Matrix); - - Texture_Management.Initialize_Font_Data (Font_File_1); - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup (Main_Window); - while Running loop - Render (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - - Render_Program.Clear; -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/freetype_gl/text_rendering/src/main_loop.ads b/examples/freetype_gl/text_rendering/src/main_loop.ads deleted file mode 100755 index cc564482..00000000 --- a/examples/freetype_gl/text_rendering/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/freetype_gl/text_rendering/src/render_text.adb b/examples/freetype_gl/text_rendering/src/render_text.adb deleted file mode 100755 index afb73c29..00000000 --- a/examples/freetype_gl/text_rendering/src/render_text.adb +++ /dev/null @@ -1,34 +0,0 @@ --- Program Render Text Example --- Author: Roger Mc Murtrie --- 8 October 2017 --- This example is based on Learn OpenGL>In Practice>Text Rendering at --- https://learnopengl.com/#!In-Practice/Text-Rendering - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Render_Text is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Render Text Example"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put_Line ("Render_Text returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Render_Text."); - Put_Line (Exception_Information (anError)); - -end Render_Text; diff --git a/examples/freetype_gl/text_rendering/src/shaders/text_fragment_shader.glsl b/examples/freetype_gl/text_rendering/src/shaders/text_fragment_shader.glsl deleted file mode 100755 index 25188df4..00000000 --- a/examples/freetype_gl/text_rendering/src/shaders/text_fragment_shader.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 410 core - -in vec2 texture_coords; -out vec4 colour; - -uniform sampler2D text_sampler; // Mono-colored bitmap image -uniform vec3 text_colour; - -void main() -{ - vec4 sampled = vec4 (1.0, 1.0, 1.0, texture(text_sampler, texture_coords).r); - colour = vec4(text_colour, 1.0) * sampled; -} diff --git a/examples/freetype_gl/text_rendering/src/shaders/text_vertex_shader.glsl b/examples/freetype_gl/text_rendering/src/shaders/text_vertex_shader.glsl deleted file mode 100755 index c17b8177..00000000 --- a/examples/freetype_gl/text_rendering/src/shaders/text_vertex_shader.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 410 core - -layout(location = 0) in vec4 vertex; // -out vec2 texture_coords; - -uniform mat4 projection_matrix; - -void main() -{ - gl_Position = projection_matrix * vec4(vertex.xy, 0.0, 1.0); - texture_coords = vec2(vertex.zw); -} - diff --git a/examples/freetype_gl/text_rendering/src/texture_management.adb b/examples/freetype_gl/text_rendering/src/texture_management.adb deleted file mode 100644 index 121ce066..00000000 --- a/examples/freetype_gl/text_rendering/src/texture_management.adb +++ /dev/null @@ -1,267 +0,0 @@ --------------------------------------------------------------------------------- - -with Interfaces.C; - -with GL.Attributes; -with GL.Blending; -with GL.Objects.Buffers; -with GL.Objects.Vertex_Arrays; -with GL.Objects.Textures.Targets; -with GL.Pixels; -with GL.Toggles; - -with FT; -with FT.Faces; -with FT.Glyphs; - -package body Texture_Management is - use Interfaces.C; - - type Character_Record is record - Texture : GL.Objects.Textures.Texture; - Width : GL.Types.Int := 0; - Rows : GL.Types.Int := 0; - Left : GL.Types.Int := 0; - Top : GL.Types.Int := 0; - Advance_X : GL.Types.Int := 0; - end record; - - OGL_Exception : Exception; - - procedure Load_Vertex_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Singles.Vector4_Pointers); - - type Character_Data_Vector is array (Natural range <>) of Character_Record; - - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Extended_Ascii_Data : Character_Data_Vector (0 .. 255); - - procedure Setup_Character_Textures (Face_Ptr : FT.Faces.Face_Reference); - procedure Setup_Font (theLibrary : FT.Library_Reference; - Face_Ptr : out FT.Faces.Face_Reference; - Font_File : String); - - -- ------------------------------------------------------------------------ - - function Advance_X (Data : Character_Record) return GL.Types.Int is - begin - return Data.Advance_X; - end Advance_X; - - -- ------------------------------------------------------------------------ - - procedure Initialize_Font_Data (Font_File : String) is - theLibrary : FT.Library_Reference; - Face_Ptr : FT.Faces.Face_Reference; - begin - theLibrary.Init; - Setup_Font (theLibrary, Face_Ptr, Font_File); - Setup_Character_Textures (Face_Ptr); - end Initialize_Font_Data; - - -- ------------------------------------------------------------------------ - - procedure Load_Texture (Face_Ptr : FT.Faces.Face_Reference; - Char_Data : in out Character_Record; - Width, Height : GL.Types.Size; - X_Offset, Y_Offset : GL.Types.Int) is - use GL.Objects.Textures.Targets; - use GL.Pixels; - use GL.Types; - aTexture : GL.Objects.Textures.Texture; - Bitmap_Image_Ptr : GL.Objects.Textures.Image_Source; - Bitmap : constant FT.Bitmap_Record := - FT.Glyphs.Bitmap (Face_Ptr.Glyph_Slot); - Num_Levels : constant GL.Types.Size := 1; - Mip_Level_0 : constant GL.Objects.Textures.Mipmap_Level := 0; - begin - aTexture.Initialize_Id; - Texture_2D.Bind (aTexture); - Texture_2D.Set_Minifying_Filter (GL.Objects.Textures.Linear); - Texture_2D.Set_Magnifying_Filter (GL.Objects.Textures.Linear); - Texture_2D.Set_X_Wrapping (GL.Objects.Textures.Clamp_To_Edge); -- Wrap_S - Texture_2D.Set_Y_Wrapping (GL.Objects.Textures.Clamp_To_Edge); -- Wrap_T - - if Width > 0 and then Height > 0 then - Texture_2D.Storage (Num_Levels, RGBA8, Width, Height); - else - Texture_2D.Storage (Num_Levels, RGBA8, 1, 1); - end if; - - Bitmap_Image_Ptr := GL.Objects.Textures.Image_Source (Bitmap.Buffer); - if Width > 0 and Height > 0 then - Texture_2D.Load_Sub_Image_From_Data - (Mip_Level_0, X_Offset, Y_Offset, Width, Height, Red, Unsigned_Byte, - Bitmap_Image_Ptr); - end if; - Char_Data.Texture := aTexture; - end Load_Texture; - - -- -------------------------------------------------------------------------- - - procedure Render_Text (Render_Program : GL.Objects.Programs.Program; - Text : String; X, Y, Scale : GL.Types.Single; - Colour : GL.Types.Colors.Basic_Color; - Texture_ID, Projection_Matrix_ID, - Colour_ID : GL.Uniforms.Uniform; - Projection_Matrix : GL.Types.Singles.Matrix4) is - use GL.Objects.Buffers; - use GL.Objects.Textures.Targets; - use GL.Types.Colors; - use GL.Types; - - Num_Triangles : constant GL.Types.Int := 2; - Num_Vertices : constant GL.Types.Int := Num_Triangles * 3; -- Two triangles - Num_Components : constant GL.Types.Int := 4; -- Coords vector size; - Stride : constant GL.Types.Int := 0 * 4; - Blend_State : constant GL.Toggles.Toggle_State := - GL.Toggles.State (GL.Toggles.Blend); - Src_Alpha_Blend : constant GL.Blending.Blend_Factor := - GL.Blending.Blend_Func_Src_Alpha; - One_Minus_Src_Alpha_Blend : constant GL.Blending.Blend_Factor := - GL.Blending.One_Minus_Src_Alpha; - Char : Character; - Char_Data : Character_Record; - Char_Texture : GL.Objects.Textures.Texture; - X_Orig : Single := X; - Y_Orig : constant Single := Y; - X_Pos : Single; - Y_Pos : Single; - Char_Width : Single; - Height : Single; - -- 2D quad as two triangles requires 2 * 3 vertices of 4 floats - Vertex_Data : Singles.Vector4_Array (1 .. Num_Vertices); - begin - -- Blending allows a fragment colour's alpha value to control the resulting - -- colour which will be transparent for all the glyph's background colours and - -- non-transparent for the actual character pixels. - GL.Toggles.Enable (GL.Toggles.Blend); - GL.Blending.Set_Blend_Func (GL.Blending.Src_Alpha, - GL.Blending.One_Minus_Src_Alpha); - GL.Objects.Programs.Use_Program (Render_Program); - - GL.Uniforms.Set_Single (Projection_Matrix_ID, Projection_Matrix); - - for index in Text'Range loop - Char := Text (index); - Char_Data := Extended_Ascii_Data (Character'Pos (Char)); - X_Pos := X_Orig + Single (Char_Data.Left) * Scale; - Y_Pos := Y_Orig - Single (Char_Data.Rows - Char_Data.Top) * Scale; - Char_Width := Single (Char_Data.Width) * Scale; - Height := Single (Char_Data.Rows) * Scale; - - Vertex_Data := ((X_Pos, Y_Pos + Height, 0.0, 0.0), - (X_Pos, Y_Pos, 0.0, 1.0), - (X_Pos + Char_Width, Y_Pos, 1.0, 1.0), - - (X_Pos, Y_Pos + Height, 0.0, 0.0), - (X_Pos + Char_Width, Y_Pos, 1.0, 1.0), - (X_Pos + Char_Width, Y_Pos + Height, 1.0, 0.0)); - - Vertex_Array.Bind; - Array_Buffer.Bind (Vertex_Buffer); - Load_Vertex_Buffer (Array_Buffer, Vertex_Data, Dynamic_Draw); - - Char_Texture := Char_Data.Texture; - if not GL.Objects.Textures.Is_Texture (Char_Texture.Raw_Id) then - raise OGL_Exception with "FT.OGL.Render_Text, aTexture is invalid for character " & Char'Img & "."; - end if; - - GL.Objects.Textures.Set_Active_Unit (0); - Texture_2D.Bind (Char_Texture); - GL.Uniforms.Set_Int (Texture_ID, 0); - GL.Uniforms.Set_Single (Colour_ID, Colour (R), Colour (G), Colour (B)); - GL.Uniforms.Set_Single (Projection_Matrix_ID, Projection_Matrix); - - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer (Index => 0, Count => Num_Components, - Kind => GL.Types.Single_Type, - Normalized => False, - Stride => Stride, Offset => 0); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, Num_Vertices); - GL.Attributes.Disable_Vertex_Attrib_Array (0); - -- Bitshift by 6 to get value in pixels (2^6 = 64 - -- (divide amount of 1/64th pixels by 64 to get amount of pixels)) - X_Orig := X_Orig + Single (Advance_X (Char_Data)) / 64.0 * Scale; - end loop; - GL.Toggles.Set (GL.Toggles.Blend, Blend_State); - GL.Blending.Set_Blend_Func (Src_Alpha_Blend, One_Minus_Src_Alpha_Blend); - end Render_Text; - - -- ------------------------------------------------------------------------ - - procedure Set_Char_Data (Char_Data : in out Character_Record; - Width : GL.Types.Int; Height : GL.Types.Int; - Left : GL.Types.Int; Top : GL.Types.Int; - Advance_X : GL.Types.Int) is - begin - Char_Data.Width := Width; - Char_Data.Rows := Height; - Char_Data.Left := Left; - Char_Data.Top := Top; - Char_Data.Advance_X := Advance_X; - end Set_Char_Data; - - -- ------------------------------------------------------------------------- - - procedure Setup_Character_Textures (Face_Ptr : FT.Faces.Face_Reference) is - use GL.Objects.Buffers; - use GL.Types; - Glyph_Slot : constant FT.Glyph_Slot_Reference := Face_Ptr.Glyph_Slot; - Width : GL.Types.Size; - Height : GL.Types.Size; - X_Offset : constant GL.Types.Int := 0; - Y_Offset : constant GL.Types.Int := 0; - Char_Data : Character_Record; - begin - -- Blending allows a fragment colour's alpha value to control the resulting - -- colour which will be transparent for all the glyph's background colours and - -- non-transparent for the actual character pixels. - GL.Toggles.Enable (GL.Toggles.Blend); - GL.Blending.Set_Blend_Func (GL.Blending.Src_Alpha, - GL.Blending.One_Minus_Src_Alpha); - - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - for index in Extended_Ascii_Data'Range loop - -- Load_Render asks FreeType to create an 8-bit grayscale bitmap image - -- that can be accessed via face->glyph->bitmap. - FT.Faces.Load_Character (Face_Ptr, unsigned_long (index), - FT.Faces.Load_Render); - -- Ensure that the glyph image is an anti-aliased bitmap - FT.Glyphs.Render_Glyph (Glyph_Slot, FT.Faces.Render_Mode_Mono); - - Width := GL.Types.Int (FT.Glyphs.Bitmap (Glyph_Slot).Width); - Height := GL.Types.Int (FT.Glyphs.Bitmap (Glyph_Slot).Rows); - - Set_Char_Data (Char_Data, Width, Height, - GL.Types.Int (FT.Glyphs.Bitmap_Left (Glyph_Slot)), - GL.Types.Int (FT.Glyphs.Bitmap_Top (Glyph_Slot)), - GL.Types.Int (FT.Glyphs.Advance (Glyph_Slot).X)); - - Load_Texture (Face_Ptr, Char_Data, Width, Height, X_Offset, Y_Offset); - Extended_Ascii_Data (index) := Char_Data; - end loop; - end Setup_Character_Textures; - - -- ------------------------------------------------------------------------ - - procedure Setup_Font (theLibrary : FT.Library_Reference; - Face_Ptr : out FT.Faces.Face_Reference; Font_File : String) is - begin - FT.Faces.New_Face (theLibrary, Font_File, 0, Face_Ptr); - -- Set pixel size to 48 x 48 - FT.Faces.Set_Pixel_Sizes (Face_Ptr, 0, 48); - -- Disable byte-alignment restriction - GL.Pixels.Set_Unpack_Alignment (GL.Pixels.Bytes); - end Setup_Font; - - -- ------------------------------------------------------------------------ - -end Texture_Management; diff --git a/examples/freetype_gl/text_rendering/src/texture_management.ads b/examples/freetype_gl/text_rendering/src/texture_management.ads deleted file mode 100644 index 35af73a6..00000000 --- a/examples/freetype_gl/text_rendering/src/texture_management.ads +++ /dev/null @@ -1,15 +0,0 @@ - -with GL.Objects.Programs; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; - -package Texture_Management is - procedure Initialize_Font_Data (Font_File : String); - procedure Render_Text (Render_Program : GL.Objects.Programs.Program; - Text : String; X, Y, Scale : GL.Types.Single; - Colour : GL.Types.Colors.Basic_Color; - Texture_ID, Projection_Matrix_ID, - Colour_ID : GL.Uniforms.Uniform; - Projection_Matrix : GL.Types.Singles.Matrix4); -end Texture_Management; diff --git a/examples/freetype_gl/text_rendering/text_rendering.gpr b/examples/freetype_gl/text_rendering/text_rendering.gpr deleted file mode 100644 index 1ba9cb84..00000000 --- a/examples/freetype_gl/text_rendering/text_rendering.gpr +++ /dev/null @@ -1,16 +0,0 @@ -with "../../common/common.gpr"; -limited with "../../../FreeTypeAda/freetype.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Text_Rendering is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Exec_Dir use "."; - for Main use ("render_text.adb"); - - package Compiler renames OpenGL.Compiler; - -end Text_Rendering; - diff --git a/examples/freetype_gl/text_rendering_2/.gitignore b/examples/freetype_gl/text_rendering_2/.gitignore deleted file mode 100644 index 4a657b04..00000000 --- a/examples/freetype_gl/text_rendering_2/.gitignore +++ /dev/null @@ -1 +0,0 @@ -render_text diff --git a/examples/freetype_gl/text_rendering_2/src/main_loop.adb b/examples/freetype_gl/text_rendering_2/src/main_loop.adb deleted file mode 100644 index b95b5caa..00000000 --- a/examples/freetype_gl/text_rendering_2/src/main_loop.adb +++ /dev/null @@ -1,126 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; -with Ada.Strings.Unbounded; - -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Toggles; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input; -with Glfw.Input.Keys; -with GL.Window; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; - -with Text_Management; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Render_Text_Program : GL.Objects.Programs.Program; - Dimensions_ID : GL.Uniforms.Uniform; - Texture_ID : GL.Uniforms.Uniform; - MVP_Matrix_ID : GL.Uniforms.Uniform; - Colour_ID : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4; - - Background : constant GL.Types.Colors.Color := (0.4, 0.6, 0.6, 1.0); - Text_Colour : constant GL.Types.Colors.Color := (0.5, 0.2, 0.6, 1.0); - Font_File_1 : constant String := "../fonts/NotoSerif-Regular.ttf"; - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window) is - use Ada.Strings.Unbounded; - use GL.Types; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - Pos_X : constant GL.Types.Single := 10.0; - Pos_Y : constant GL.Types.Single := 150.0; - Scale_1 : constant GL.Types.Single := 0.4; - Scale_2 : constant GL.Types.Single := 0.2; - Scale_3 : constant GL.Types.Single := 0.3; - Text_List : Text_Management.Text_Array (1 .. 2); - begin - Window.Get_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (0, 0, GL.Types.Int (Window_Width), - GL.Types.Int (Window_Height)); - Maths.Init_Orthographic_Transform (Single (Window_Height), 0.0, 0.0, - Single (Window_Width), 0.1, -100.0, - MVP_Matrix); - Text_Management.Render_Text (Render_Text_Program, "Hello", 300.0, Pos_Y + 250.0, - Scale_1, Text_Colour, Texture_ID, MVP_Matrix_ID, - Dimensions_ID, Colour_ID, MVP_Matrix); - Text_List (1) := - (To_Unbounded_String ("1234567890 !@#$%^&*()_+=,./?;':""{}[]\|~`"), - Pos_X + 20.0, Pos_Y + 150.0, Scale_1, Text_Colour); - Text_List (2) := - (To_Unbounded_String ("The Quick Brown Fox jumps over the zoo's Lazy Dog."), - Pos_X, Pos_Y, Scale_3, Text_Colour); - Text_Management.Render_Text (Render_Text_Program, Text_List, Texture_ID, - MVP_Matrix_ID, Dimensions_ID, Colour_ID, MVP_Matrix); - Text_Management.Render_Text (Render_Text_Program, "Hello again!", 300.0, 50.0, - Scale_2, Text_Colour, Texture_ID, MVP_Matrix_ID, - Dimensions_ID, Colour_ID, MVP_Matrix); - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window) is - use GL.Objects.Programs; - use GL.Objects.Shaders; - use Program_Loader; - - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - begin - Window.Get_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (0, 0, GL.Types.Int (Window_Width), - GL.Types.Int (Window_Height)); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - - Render_Text_Program := Program_From - ((Src ("src/shaders/text_vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/text_fragment_shader.glsl", Fragment_Shader))); - Use_Program (Render_Text_Program); - - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Text_Program, "mvp_matrix"); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Text_Program, "text_sampler"); - Colour_ID := GL.Objects.Programs.Uniform_Location - (Render_Text_Program, "text_colour"); - Dimensions_ID := GL.Objects.Programs.Uniform_Location - (Render_Text_Program, "dimensions"); - - Text_Management.Setup (Font_File_1); - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup (Main_Window); - Utilities.Clear_Background_Colour_And_Depth (Background); - while Running loop - Render (Main_Window); - GL.Flush; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - Render_Text_Program.Clear; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/freetype_gl/text_rendering_2/src/main_loop.ads b/examples/freetype_gl/text_rendering_2/src/main_loop.ads deleted file mode 100755 index cc564482..00000000 --- a/examples/freetype_gl/text_rendering_2/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/freetype_gl/text_rendering_2/src/render_text.adb b/examples/freetype_gl/text_rendering_2/src/render_text.adb deleted file mode 100755 index a4d71021..00000000 --- a/examples/freetype_gl/text_rendering_2/src/render_text.adb +++ /dev/null @@ -1,33 +0,0 @@ --- Program Render Text Example --- Author: Roger Mc Murtrie --- 28 October 2017 --- This example demonstrates use of the OpenGL.Text API - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Render_Text is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Render Text Example"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put_Line ("Render_Text returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Render_Text."); - Put_Line (Exception_Information (anError)); - -end Render_Text; diff --git a/examples/freetype_gl/text_rendering_2/src/shaders/text_fragment_shader.glsl b/examples/freetype_gl/text_rendering_2/src/shaders/text_fragment_shader.glsl deleted file mode 100755 index 981c0541..00000000 --- a/examples/freetype_gl/text_rendering_2/src/shaders/text_fragment_shader.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 410 core - -in vec2 texture_coords; - -uniform sampler2D text_sampler; // Mono-colored bitmap image -uniform vec3 text_colour; - -out vec4 colour; - -void main() -{ - vec4 sampled = vec4 (1.0, 1.0, 1.0, texture(text_sampler, texture_coords).r); - colour = vec4(text_colour, 1.0) * sampled; -} diff --git a/examples/freetype_gl/text_rendering_2/src/shaders/text_vertex_shader.glsl b/examples/freetype_gl/text_rendering_2/src/shaders/text_vertex_shader.glsl deleted file mode 100755 index a41dc57c..00000000 --- a/examples/freetype_gl/text_rendering_2/src/shaders/text_vertex_shader.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 410 core - -layout(location = 0) in vec2 vertex; -uniform vec2 dimensions; -uniform mat4 mvp_matrix; -out vec2 texture_coords; - -void main() -{ - gl_Position = mvp_matrix * vec4(vertex.x * dimensions.x, vertex.y * dimensions.y, 0.0, 1.0); - texture_coords = vertex; -} - diff --git a/examples/freetype_gl/text_rendering_2/text_rendering_2.gpr b/examples/freetype_gl/text_rendering_2/text_rendering_2.gpr deleted file mode 100644 index a00fd41b..00000000 --- a/examples/freetype_gl/text_rendering_2/text_rendering_2.gpr +++ /dev/null @@ -1,16 +0,0 @@ -with "../../common/common.gpr"; -limited with "../../../opengl-text.gpr"; -limited with "../../../opengl-glfw.gpr"; -with "../../../opengl.gpr"; - -project Text_Rendering_2 is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Exec_Dir use "."; - for Main use ("render_text.adb"); - - package Compiler renames OpenGL.Compiler; - -end Text_Rendering_2; - diff --git a/examples/ogl_tutorials/02_red_triangle/.gitignore b/examples/ogl_tutorials/02_red_triangle/.gitignore deleted file mode 100644 index d13ca38b..00000000 --- a/examples/ogl_tutorials/02_red_triangle/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tutorial_02 diff --git a/examples/ogl_tutorials/02_red_triangle/src/main_loop.adb b/examples/ogl_tutorials/02_red_triangle/src/main_loop.adb deleted file mode 100644 index 153f29f7..00000000 --- a/examples/ogl_tutorials/02_red_triangle/src/main_loop.adb +++ /dev/null @@ -1,96 +0,0 @@ - - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Types; -with GL.Types.Colors; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Render_Program : GL.Objects.Programs.Program; - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types; - use GL.Objects.Buffers; - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 1.0); - begin - Utilities.Clear_Background_Colour (Dark_Blue); - GL.Objects.Programs.Use_Program (Render_Program); - - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Array_Buffer.Bind (Vertex_Buffer); - - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 3); - GL.Attributes.Disable_Vertex_Attrib_Array (0); - - exception - when others => - Put_Line ("An exceptiom occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use Program_Loader; - begin - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, - Vertex_Data.Vertex_Buffer_Data, Static_Draw); - - Render_Program := Program_From - ((Src ("src/shaders/simple_vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/simple_fragment_shader.glsl", Fragment_Shader))); - - exception - when others => - Put_Line ("An exceptiom occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup; - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exceptiom occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/02_red_triangle/src/main_loop.ads b/examples/ogl_tutorials/02_red_triangle/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/02_red_triangle/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/02_red_triangle/src/shaders/simple_fragment_shader.glsl b/examples/ogl_tutorials/02_red_triangle/src/shaders/simple_fragment_shader.glsl deleted file mode 100755 index d10e8c1f..00000000 --- a/examples/ogl_tutorials/02_red_triangle/src/shaders/simple_fragment_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 core - -// Ouput data -out vec4 colour; - -void main() -{ - // Output colour = red - colour = vec4 (1.0, 0.0, 0.0, 1.0); -} diff --git a/examples/ogl_tutorials/02_red_triangle/src/shaders/simple_vertex_shader.glsl b/examples/ogl_tutorials/02_red_triangle/src/shaders/simple_vertex_shader.glsl deleted file mode 100755 index 7b6d46f0..00000000 --- a/examples/ogl_tutorials/02_red_triangle/src/shaders/simple_vertex_shader.glsl +++ /dev/null @@ -1,11 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 vertexPosition_modelspace; - -void main() -{ - gl_Position.xyz = vertexPosition_modelspace; - gl_Position.w = 1.0; -} - diff --git a/examples/ogl_tutorials/02_red_triangle/src/tutorial_02.adb b/examples/ogl_tutorials/02_red_triangle/src/tutorial_02.adb deleted file mode 100644 index 21b9c47f..00000000 --- a/examples/ogl_tutorials/02_red_triangle/src/tutorial_02.adb +++ /dev/null @@ -1,29 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Tutorial_02 is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Tutorial 2 - Red Triangle"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Tutorial_02 returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Tutorial_02."); - Put_Line (Exception_Information (anError)); - -end Tutorial_02; diff --git a/examples/ogl_tutorials/02_red_triangle/src/vertex_data.ads b/examples/ogl_tutorials/02_red_triangle/src/vertex_data.ads deleted file mode 100644 index 7835b6e0..00000000 --- a/examples/ogl_tutorials/02_red_triangle/src/vertex_data.ads +++ /dev/null @@ -1,11 +0,0 @@ - -with GL.Types; - -package Vertex_Data is - use GL.Types; - - Vertex_Buffer_Data : Singles.Vector3_Array (1 .. 3) - := ((-1.0, -1.0, 0.0), - (1.0, -1.0, 0.0), - (0.0, 1.0, 0.0)); -end Vertex_Data; diff --git a/examples/ogl_tutorials/02_red_triangle/tutorial_02.gpr b/examples/ogl_tutorials/02_red_triangle/tutorial_02.gpr deleted file mode 100644 index bc757384..00000000 --- a/examples/ogl_tutorials/02_red_triangle/tutorial_02.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tutorial_02 is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Exec_Dir use "."; - for Main use ("tutorial_02.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tutorial_02; - diff --git a/examples/ogl_tutorials/03_matrices/.gitignore b/examples/ogl_tutorials/03_matrices/.gitignore deleted file mode 100644 index a39236b9..00000000 --- a/examples/ogl_tutorials/03_matrices/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tutorial_03 diff --git a/examples/ogl_tutorials/03_matrices/src/main_loop.adb b/examples/ogl_tutorials/03_matrices/src/main_loop.adb deleted file mode 100644 index 18f96a24..00000000 --- a/examples/ogl_tutorials/03_matrices/src/main_loop.adb +++ /dev/null @@ -1,135 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - procedure Load_Vertex_Buffer is new GL.Objects.Buffers.Load_To_Buffer - (GL.Types.Single_Pointers); - - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 1.0); - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Render_Program : GL.Objects.Programs.Program; - MVP_Location : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4; - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types; - use GL.Objects.Buffers; - begin - Utilities.Clear_Background_Colour (Dark_Blue); - GL.Objects.Programs.Use_Program (Render_Program); - - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Array_Buffer.Bind (Vertex_Buffer); - - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - GL.Uniforms.Set_Single (MVP_Location, MVP_Matrix); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 3); - GL.Attributes.Disable_Vertex_Attrib_Array (0); - - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Render_Program : GL.Objects.Programs.Program) is - use GL.Types; - use Maths; - use type GL.Types.Singles.Matrix4; - View_Width : constant Single := 1024.0; - View_Height : constant Single := 768.0; - Camera_Position : constant GL.Types.Singles.Vector3 := (4.0, 3.0, 3.0); - Look_At : constant GL.Types.Singles.Vector3 := (0.0, 0.0, 0.0); - Up : constant GL.Types.Singles.Vector3 := (0.0, 1.0, 0.0); - Model_Matrix : constant GL.Types.Singles.Matrix4 := Singles.Identity4; - Projection_Matrix : GL.Types.Singles.Matrix4; - View_Matrix : GL.Types.Singles.Matrix4; - begin - MVP_Location := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP"); - - Init_Perspective_Transform (45.0, View_Width, View_Height, - 0.1, 100.0, Projection_Matrix); - Init_Lookat_Transform (Camera_Position, Look_At, Up, View_Matrix); - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - Utilities.Print_Matrix ("MVP Matrix", MVP_Matrix); - exception - when others => - Put_Line ("An exception occurred in Set_MVP_Matrix."); - raise; - end Set_MVP_Matrix; - - -- ------------------------------------------------------------------------ - - procedure Setup (Main_Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use Glfw.Input; - use Program_Loader; - begin - Main_Window.Set_Input_Toggle (Sticky_Keys, True); - Utilities.Clear_Background_Colour (Dark_Blue); - - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Render_Program := Program_From - ((Src ("src/shaders/simple_transform_vertex.glsl", Vertex_Shader), - Src ("src/shaders/single_colour_fragment.glsl", Fragment_Shader))); - Set_MVP_Matrix (Render_Program); - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Load_Vertex_Buffer (Array_Buffer, Vertex_Data.Vertex_Buffer_Data, - Static_Draw); - Utilities.Show_Shader_Program_Data (Render_Program); - exception - when others => - Put_Line ("An exception occurred in Setup."); - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup (Main_Window); - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not (Main_Window.Key_State (Glfw.Input.Keys.Escape) - = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/03_matrices/src/main_loop.ads b/examples/ogl_tutorials/03_matrices/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/03_matrices/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/03_matrices/src/shaders/simple_transform_vertex.glsl b/examples/ogl_tutorials/03_matrices/src/shaders/simple_transform_vertex.glsl deleted file mode 100755 index e7daa526..00000000 --- a/examples/ogl_tutorials/03_matrices/src/shaders/simple_transform_vertex.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 vertexPosition_modelspace; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP; - -void main() -{ - // Output position of the vertex, in clip space : MVP * position - gl_Position = MVP * vec4(vertexPosition_modelspace,1); -} - diff --git a/examples/ogl_tutorials/03_matrices/src/shaders/single_colour_fragment.glsl b/examples/ogl_tutorials/03_matrices/src/shaders/single_colour_fragment.glsl deleted file mode 100755 index bc53e82b..00000000 --- a/examples/ogl_tutorials/03_matrices/src/shaders/single_colour_fragment.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#version 410 core - -out vec3 colour; - -void main() -{ - // Output color = red - colour = vec3(1.0, 0.0, 0.0); -} diff --git a/examples/ogl_tutorials/03_matrices/src/tutorial_03.adb b/examples/ogl_tutorials/03_matrices/src/tutorial_03.adb deleted file mode 100644 index 8c64677a..00000000 --- a/examples/ogl_tutorials/03_matrices/src/tutorial_03.adb +++ /dev/null @@ -1,28 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Tutorial_03 is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Tutorial 3 - Matrices"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Tutorial_03 returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Tutorial_03."); - Put_Line (Exception_Information (anError)); - -end Tutorial_03; diff --git a/examples/ogl_tutorials/03_matrices/src/vertex_data.ads b/examples/ogl_tutorials/03_matrices/src/vertex_data.ads deleted file mode 100644 index f758efdb..00000000 --- a/examples/ogl_tutorials/03_matrices/src/vertex_data.ads +++ /dev/null @@ -1,12 +0,0 @@ - -with GL.Types; - -package Vertex_Data is - use GL.Types; - Element_Buffer_Data : array (1 .. 3) of UShort := (0, 1, 2); - - Vertex_Buffer_Data : Single_Array (Int range 1 .. 9) - := (-1.0, -1.0, 0.0, - 1.0, -1.0, 0.0, - 0.0, 1.0, 0.0); -end Vertex_Data; diff --git a/examples/ogl_tutorials/03_matrices/tutorial_03.gpr b/examples/ogl_tutorials/03_matrices/tutorial_03.gpr deleted file mode 100644 index 540bc1f8..00000000 --- a/examples/ogl_tutorials/03_matrices/tutorial_03.gpr +++ /dev/null @@ -1,13 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tutorial_03 is -for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("tutorial_03.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tutorial_03; diff --git a/examples/ogl_tutorials/04_coloured_cube/.gitignore b/examples/ogl_tutorials/04_coloured_cube/.gitignore deleted file mode 100644 index fb62b9c5..00000000 --- a/examples/ogl_tutorials/04_coloured_cube/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tutorial_04 diff --git a/examples/ogl_tutorials/04_coloured_cube/src/cube_data.ads b/examples/ogl_tutorials/04_coloured_cube/src/cube_data.ads deleted file mode 100644 index e2bf651e..00000000 --- a/examples/ogl_tutorials/04_coloured_cube/src/cube_data.ads +++ /dev/null @@ -1,87 +0,0 @@ - -with GL.Types; use GL.Types; - -package Cube_Data is - - -- The vertices. Three consecutive floats give a 3D vertex; - -- Three consecutive vertices give a triangle. - -- A cube has 6 faces with 2 triangles each, - -- so this makes 6*2 = 12 triangles and 12*3 = 36 vertices - Vertex_Data : Singles.Vector3_Array (1 .. 36) := - ((-1.0, -1.0, -1.0), -- triangle 1 : begin - (-1.0, -1.0, 1.0), - (-1.0, 1.0, 1.0), -- triangle 1 : end - (1.0, 1.0, -1.0), -- triangle 2 : begin - (-1.0, -1.0, -1.0), - (-1.0, 1.0, -1.0), -- triangle 2 : end - (1.0, -1.0, 1.0), - (-1.0, -1.0, -1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, -1.0), - (1.0, -1.0, -1.0), - (-1.0, -1.0, -1.0), - (-1.0, -1.0, -1.0), - (-1.0, 1.0, 1.0), - (-1.0, 1.0, -1.0), - (1.0, -1.0, 1.0), - (-1.0, -1.0, 1.0), - (-1.0, -1.0, -1.0), - (-1.0, 1.0, 1.0), - (-1.0, -1.0, 1.0), - (1.0, -1.0, 1.0), - (1.0, 1.0, 1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, -1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, 1.0), - (1.0, -1.0, 1.0), - (1.0, 1.0, 1.0), - (1.0, 1.0, -1.0), - (-1.0, 1.0, -1.0), - (1.0, 1.0, 1.0), - (-1.0, 1.0, -1.0), - (-1.0, 1.0, 1.0), - (1.0, 1.0, 1.0), - (-1.0, 1.0, 1.0), - (1.0, -1.0, 1.0)); - - -- One colour for each vertex. These were generated randomly. - Colour_Data : Singles.Vector3_Array (1 .. 36) := - ((0.583, 0.771, 0.014), - (0.609, 0.115, 0.436), - (0.327, 0.483, 0.844), - (0.822, 0.569, 0.201), - (0.435, 0.602, 0.223), - (0.310, 0.747, 0.185), - (0.597, 0.770, 0.761), - (0.559, 0.436, 0.730), - (0.359, 0.583, 0.152), - (0.483, 0.596, 0.789), - (0.559, 0.861, 0.639), - (0.195, 0.548, 0.859), - (0.014, 0.184, 0.576), - (0.771, 0.328, 0.970), - (0.406, 0.615, 0.116), - (0.676, 0.977, 0.133), - (0.971, 0.572, 0.833), - (0.140, 0.616, 0.489), - (0.997, 0.513, 0.064), - (0.945, 0.719, 0.592), - (0.543, 0.021, 0.978), - (0.279, 0.317, 0.505), - (0.167, 0.620, 0.077), - (0.347, 0.857, 0.137), - (0.055, 0.953, 0.042), - (0.714, 0.505, 0.345), - (0.783, 0.290, 0.734), - (0.722, 0.645, 0.174), - (0.302, 0.455, 0.848), - (0.225, 0.587, 0.040), - (0.517, 0.713, 0.338), - (0.053, 0.959, 0.120), - (0.393, 0.621, 0.362), - (0.673, 0.211, 0.457), - (0.820, 0.883, 0.371), - (0.982, 0.099, 0.879)); - -end Cube_Data; diff --git a/examples/ogl_tutorials/04_coloured_cube/src/main_loop.adb b/examples/ogl_tutorials/04_coloured_cube/src/main_loop.adb deleted file mode 100644 index 1312c3a7..00000000 --- a/examples/ogl_tutorials/04_coloured_cube/src/main_loop.adb +++ /dev/null @@ -1,178 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types; use GL.Types; -with GL.Types.Colors; -with GL.Uniforms; -with GL.Window; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Cube_Data; -with Maths; -with Program_Loader; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Dark_Blue : constant Colors.Color := (0.0, 0.0, 0.4, 1.0); - - Vertices_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Colour_Buffer : GL.Objects.Buffers.Buffer; - Render_Program : GL.Objects.Programs.Program; - MVP_Matrix_ID : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program); - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - begin - Window.Get_Framebuffer_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (0, 0, GL.Types.Int (Window_Width), - GL.Types.Int (Window_Height)); - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - - GL.Objects.Programs.Use_Program (Render_Program); - Set_MVP_Matrix (Window, Render_Program); - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - - -- First attribute buffer : vertices - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - - -- Second attribute buffer : Colours - GL.Attributes.Enable_Vertex_Attrib_Array (1); - Array_Buffer.Bind (Colour_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (1, 3, Single_Type, False, 0, 0); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Triangles, - First => 0, - Count => 12 * 3); - - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Attributes.Disable_Vertex_Attrib_Array (1); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program) is - use GL.Types.Singles; - use Maths; - -- Camera position, Look_At and Up are world coordinates. - Camera_Position : constant Vector3 := (4.0, 3.0, -3.0); - Look_At : constant Vector3 := (0.0, 0.0, 0.0); - Up : constant Vector3 := (0.0, 1.0, 0.0); - -- The Model_Matrix operates in world coordinates. - Model_Matrix : constant Matrix4 := Singles.Identity4; - -- The Projection_Matrix projects the camera view in camera coordinates - -- onto the camera view's Near plane - Projection_Matrix : Matrix4; - -- The View_Matrix transforms the world_cordinates of the world view - -- into view (camera) coordinates. - View_Matrix : Matrix4; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - begin - Window.Get_Framebuffer_Size (Window_Width, Window_Height); - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP_Matrix"); - - Init_Lookat_Transform (Camera_Position, Look_At, Up, View_Matrix); - Init_Perspective_Transform (60.0, Single (Window_Width), - Single (Window_Height), - 0.1, 100.0, Projection_Matrix); - -- The View_Matrix transforms world_cordinates to view (camera) coordinates. - -- The Projection_Matrix transforms view (camera) coordinates. - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - exception - when others => - Put_Line ("An exception occurred in Set_MVP_Matrix."); - raise; - end Set_MVP_Matrix; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - begin - Window.Set_Input_Toggle (Glfw.Input.Sticky_Keys, True); - - GL.Toggles.Enable (GL.Toggles.Depth_Test); - -- Accept fragment if it closer to the camera than the former one. - GL.Buffers.Set_Depth_Function (GL.Types.Less); - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - - Vertices_Array_Object.Initialize_Id; - Vertices_Array_Object.Bind; - - Render_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/MVP_Vertex_Shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/Colour_Fragment_Shader.glsl", - Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Render_Program); - - Set_MVP_Matrix (Window, Render_Program); - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Cube_Data.Vertex_Data, Static_Draw); - - Colour_Buffer.Initialize_Id; - Array_Buffer.Bind (Colour_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Cube_Data.Colour_Data, Static_Draw); - - exception - when others => - Put_Line ("An exception occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup (Main_Window); - while Running loop - Render (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/04_coloured_cube/src/main_loop.ads b/examples/ogl_tutorials/04_coloured_cube/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/04_coloured_cube/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/04_coloured_cube/src/shaders/Colour_Fragment_Shader.glsl b/examples/ogl_tutorials/04_coloured_cube/src/shaders/Colour_Fragment_Shader.glsl deleted file mode 100755 index 50300ae6..00000000 --- a/examples/ogl_tutorials/04_coloured_cube/src/shaders/Colour_Fragment_Shader.glsl +++ /dev/null @@ -1,11 +0,0 @@ -#version 410 core - -// Interpolated values from the vertex shaders -in vec3 fragment_colour; - -out vec3 color; - -void main() -{ - color = fragment_colour; -} diff --git a/examples/ogl_tutorials/04_coloured_cube/src/shaders/MVP_Vertex_Shader.glsl b/examples/ogl_tutorials/04_coloured_cube/src/shaders/MVP_Vertex_Shader.glsl deleted file mode 100644 index 68730a89..00000000 --- a/examples/ogl_tutorials/04_coloured_cube/src/shaders/MVP_Vertex_Shader.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 410 core - -layout(location = 0) in vec3 vertex_model_position; -layout(location = 1) in vec3 vertex_colour; - -out vec3 fragment_colour; - -uniform mat4 MVP_Matrix; - -void main() -{ - gl_Position = MVP_Matrix * vec4(vertex_model_position,1.0); - fragment_colour = vertex_colour; -} diff --git a/examples/ogl_tutorials/04_coloured_cube/src/tutorial_04.adb b/examples/ogl_tutorials/04_coloured_cube/src/tutorial_04.adb deleted file mode 100644 index 4c0e3435..00000000 --- a/examples/ogl_tutorials/04_coloured_cube/src/tutorial_04.adb +++ /dev/null @@ -1,27 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Tutorial_04 is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Tutorial 4 - Coloured Cube"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Tutorial_4 returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Tutorial_4."); - Put_Line (Exception_Information (anError)); -end Tutorial_04; diff --git a/examples/ogl_tutorials/04_coloured_cube/tutorial_04.gpr b/examples/ogl_tutorials/04_coloured_cube/tutorial_04.gpr deleted file mode 100644 index 5a61c6dc..00000000 --- a/examples/ogl_tutorials/04_coloured_cube/tutorial_04.gpr +++ /dev/null @@ -1,13 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tutorial_04 is - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("tutorial_04.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tutorial_04; diff --git a/examples/ogl_tutorials/05_textured_cube/.gitignore b/examples/ogl_tutorials/05_textured_cube/.gitignore deleted file mode 100644 index 4e4acb08..00000000 --- a/examples/ogl_tutorials/05_textured_cube/.gitignore +++ /dev/null @@ -1 +0,0 @@ -textured_cube diff --git a/examples/ogl_tutorials/05_textured_cube/src/cube_data.ads b/examples/ogl_tutorials/05_textured_cube/src/cube_data.ads deleted file mode 100644 index 72be56b9..00000000 --- a/examples/ogl_tutorials/05_textured_cube/src/cube_data.ads +++ /dev/null @@ -1,86 +0,0 @@ - -with GL.Types; use GL.Types; - -package Cube_Data is - - -- The vertices. Three consecutive floats give a 3D vertex; - -- Three consecutive vertices give a triangle. - -- A cube has 6 faces with 2 triangles each, - -- so this makes 6*2 = 12 triangles and 12*3 = 36 vertices - Vertex_Data : Singles.Vector3_Array (1 .. 36) := - ((-1.0, -1.0, -1.0), -- triangle 1 : begin - (-1.0, -1.0, 1.0), - (-1.0, 1.0, 1.0), -- triangle 1 : end - (1.0, 1.0, -1.0), -- triangle 2 : begin - (-1.0, -1.0, -1.0), - (-1.0, 1.0, -1.0), -- triangle 2 : end - (1.0, -1.0, 1.0), - (-1.0, -1.0, -1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, -1.0), - (1.0, -1.0, -1.0), - (-1.0, -1.0, -1.0), - (-1.0, -1.0, -1.0), - (-1.0, 1.0, 1.0), - (-1.0, 1.0, -1.0), - (1.0, -1.0, 1.0), - (-1.0, -1.0, 1.0), - (-1.0, -1.0, -1.0), - (-1.0, 1.0, 1.0), - (-1.0, -1.0, 1.0), - (1.0, -1.0, 1.0), - (1.0, 1.0, 1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, -1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, 1.0), - (1.0, -1.0, 1.0), - (1.0, 1.0, 1.0), - (1.0, 1.0, -1.0), - (-1.0, 1.0, -1.0), - (1.0, 1.0, 1.0), - (-1.0, 1.0, -1.0), - (-1.0, 1.0, 1.0), - (1.0, 1.0, 1.0), - (-1.0, 1.0, 1.0), - (1.0, -1.0, 1.0)); - - -- Two UV coordinatesfor each vertex. These were generated randomly. - UV_Data : Singles.Vector2_Array (1 .. 36) := - ((0.000059, 0.000004), - (0.000103, 0.336048), - (0.335973, 0.335903), - (1.000023, 0.000013), - (0.667979, 0.335851), - (0.999958, 0.336064), - (0.667979, 0.335851), - (0.336024, 0.671877), - (0.667969, 0.671889), - (1.000023, 0.000013), - (0.668104, 0.000013), - (0.667979, 0.335851), - (0.000059, 0.000004), - (0.335973, 0.335903), - (0.336098, 0.000071), - (0.667979, 0.335851), - (0.335973, 0.335903), - (0.336024, 0.671877), - (1.000004, 0.671847), - (0.999958, 0.336064), - (0.667979, 0.335851), - (0.668104, 0.000013), - (0.335973, 0.335903), - (0.667979, 0.335851), - (0.335973, 0.335903), - (0.668104, 0.000013), - (0.336098, 0.000071), - (0.000103, 0.336048), - (0.000004, 0.671870), - (0.336024, 0.671877), - (0.000103, 0.336048), - (0.336024, 0.671877), - (0.335973, 0.335903), - (0.667969, 0.671889), - (1.000004, 0.671847), - (0.667979, 0.335851)); -end Cube_Data; diff --git a/examples/ogl_tutorials/05_textured_cube/src/main_loop.adb b/examples/ogl_tutorials/05_textured_cube/src/main_loop.adb deleted file mode 100644 index 5eabcb95..00000000 --- a/examples/ogl_tutorials/05_textured_cube/src/main_loop.adb +++ /dev/null @@ -1,182 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types; use GL.Types; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input.Keys; -with Glfw.Windows; -with Glfw.Windows.Context; - -with Cube_Data; -with Maths; -with Program_Loader; -with Load_DDS; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 1.0); - - Vertices_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - UVs_Buffer : GL.Objects.Buffers.Buffer; - Render_Program : GL.Objects.Programs.Program; - MVP_Matrix_ID : GL.Uniforms.Uniform; - Texture_ID : GL.Uniforms.Uniform; - Cube_Texture : GL.Objects.Textures.Texture; - MVP_Matrix : GL.Types.Singles.Matrix4; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program); - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Objects.Buffers; - - begin - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - - GL.Objects.Programs.Use_Program (Render_Program); - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - - GL.Objects.Textures.Set_Active_Unit (0); - GL.Objects.Textures.Targets.Texture_2D.Bind (Cube_Texture); - -- Set myTextureSampler sampler to use Texture Unit 0 - GL.Uniforms.Set_Int (Texture_ID, 0); - - -- First attribute buffer : vertices - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - - -- Second attribute buffer : UVs - GL.Attributes.Enable_Vertex_Attrib_Array (1); - Array_Buffer.Bind (UVs_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (1, 2, Single_Type, False, 0, 0); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Triangles, - First => 0, - Count => 12 * 3); - - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Attributes.Disable_Vertex_Attrib_Array (1); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program) is - use GL.Types.Singles; - use Maths; - -- Camera position, Look_At and Up are world coordinates. - Camera_Position : constant Vector3 := (4.0, 3.0, -3.0); - Look_At : constant Vector3 := (0.0, 0.0, 0.0); - Up : constant Vector3 := (0.0, 1.0, 0.0); - -- The Model_Matrix operates in world coordinates. - Model_Matrix : constant Matrix4 := Singles.Identity4; - -- The Projection_Matrix projects the camera view in camera coordinates - -- onto the camera view's Near plane - Projection_Matrix : Matrix4; - -- The View_Matrix transforms the world_cordinates of the world view - -- into view (camera) coordinates. - View_Matrix : Matrix4; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - begin - Window.Get_Framebuffer_Size (Window_Width, Window_Height); - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP_5"); - - Init_Lookat_Transform (Camera_Position, Look_At, Up, View_Matrix); - Init_Perspective_Transform (45.0, Single (Window_Width), - Single (Window_Height), - 0.1, 100.0, Projection_Matrix); - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - exception - when others => - Put_Line ("An exception occurred in Set_MVP_Matrix."); - raise; - end Set_MVP_Matrix; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - begin - Window.Set_Input_Toggle (Glfw.Input.Sticky_Keys, True); - Utilities.Clear_Background_Colour (Dark_Blue); - - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - - Vertices_Array_Object.Initialize_Id; - Vertices_Array_Object.Bind; - - Render_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/Transform_Vertex_Shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/Texture_Fragment_Shader.glsl", - Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Render_Program); - - Set_MVP_Matrix (Window, Render_Program); - - Load_DDS ("src/textures/uvtemplate.DDS", Cube_Texture); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "myTextureSampler"); - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Cube_Data.Vertex_Data, Static_Draw); - - UVs_Buffer.Initialize_Id; - Array_Buffer.Bind (UVs_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Cube_Data.UV_Data, Static_Draw); - - exception - when others => - Put_Line ("An exception occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup (Main_Window); - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/05_textured_cube/src/main_loop.ads b/examples/ogl_tutorials/05_textured_cube/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/05_textured_cube/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/05_textured_cube/src/shaders/Texture_Fragment_Shader.glsl b/examples/ogl_tutorials/05_textured_cube/src/shaders/Texture_Fragment_Shader.glsl deleted file mode 100755 index 646e6c1f..00000000 --- a/examples/ogl_tutorials/05_textured_cube/src/shaders/Texture_Fragment_Shader.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 410 core - -// Interpolated values from the vertex shaders -in vec2 UV; - -out vec3 colour; - -// Values that stay constant for the whole mesh. -uniform sampler2D myTextureSampler; - -void main() -{ - colour = texture(myTextureSampler, UV).rgb; -} diff --git a/examples/ogl_tutorials/05_textured_cube/src/shaders/Transform_Vertex_Shader.glsl b/examples/ogl_tutorials/05_textured_cube/src/shaders/Transform_Vertex_Shader.glsl deleted file mode 100755 index 78e395a2..00000000 --- a/examples/ogl_tutorials/05_textured_cube/src/shaders/Transform_Vertex_Shader.glsl +++ /dev/null @@ -1,18 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 vertexPosition_modelspace; -layout(location = 1) in vec2 vertexUV; - -// Output data ; will be interpolated for each fragment. -out vec2 UV; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP_5; - -void main() -{ - gl_Position = MVP_5 * vec4(vertexPosition_modelspace,1.0); - UV = vertexUV; -} - diff --git a/examples/ogl_tutorials/05_textured_cube/src/textured_cube.adb b/examples/ogl_tutorials/05_textured_cube/src/textured_cube.adb deleted file mode 100644 index a5bce6f4..00000000 --- a/examples/ogl_tutorials/05_textured_cube/src/textured_cube.adb +++ /dev/null @@ -1,27 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Textured_Cube is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Tutorial 5 - Textured Cube"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Tutorial_5 returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Tutorial_5."); - Put_Line (Exception_Information (anError)); -end Textured_Cube; diff --git a/examples/ogl_tutorials/05_textured_cube/src/textures/uvtemplate.DDS b/examples/ogl_tutorials/05_textured_cube/src/textures/uvtemplate.DDS deleted file mode 100755 index 3e9afee7..00000000 Binary files a/examples/ogl_tutorials/05_textured_cube/src/textures/uvtemplate.DDS and /dev/null differ diff --git a/examples/ogl_tutorials/05_textured_cube/tutorial_05.gpr b/examples/ogl_tutorials/05_textured_cube/tutorial_05.gpr deleted file mode 100644 index ecf70670..00000000 --- a/examples/ogl_tutorials/05_textured_cube/tutorial_05.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tutorial_05 is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("textured_cube.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tutorial_05; - diff --git a/examples/ogl_tutorials/06_keyboard_mouse/.gitignore b/examples/ogl_tutorials/06_keyboard_mouse/.gitignore deleted file mode 100644 index 158d3303..00000000 --- a/examples/ogl_tutorials/06_keyboard_mouse/.gitignore +++ /dev/null @@ -1 +0,0 @@ -keyboard_mouse diff --git a/examples/ogl_tutorials/06_keyboard_mouse/src/cube_data.ads b/examples/ogl_tutorials/06_keyboard_mouse/src/cube_data.ads deleted file mode 100644 index 72be56b9..00000000 --- a/examples/ogl_tutorials/06_keyboard_mouse/src/cube_data.ads +++ /dev/null @@ -1,86 +0,0 @@ - -with GL.Types; use GL.Types; - -package Cube_Data is - - -- The vertices. Three consecutive floats give a 3D vertex; - -- Three consecutive vertices give a triangle. - -- A cube has 6 faces with 2 triangles each, - -- so this makes 6*2 = 12 triangles and 12*3 = 36 vertices - Vertex_Data : Singles.Vector3_Array (1 .. 36) := - ((-1.0, -1.0, -1.0), -- triangle 1 : begin - (-1.0, -1.0, 1.0), - (-1.0, 1.0, 1.0), -- triangle 1 : end - (1.0, 1.0, -1.0), -- triangle 2 : begin - (-1.0, -1.0, -1.0), - (-1.0, 1.0, -1.0), -- triangle 2 : end - (1.0, -1.0, 1.0), - (-1.0, -1.0, -1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, -1.0), - (1.0, -1.0, -1.0), - (-1.0, -1.0, -1.0), - (-1.0, -1.0, -1.0), - (-1.0, 1.0, 1.0), - (-1.0, 1.0, -1.0), - (1.0, -1.0, 1.0), - (-1.0, -1.0, 1.0), - (-1.0, -1.0, -1.0), - (-1.0, 1.0, 1.0), - (-1.0, -1.0, 1.0), - (1.0, -1.0, 1.0), - (1.0, 1.0, 1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, -1.0), - (1.0, -1.0, -1.0), - (1.0, 1.0, 1.0), - (1.0, -1.0, 1.0), - (1.0, 1.0, 1.0), - (1.0, 1.0, -1.0), - (-1.0, 1.0, -1.0), - (1.0, 1.0, 1.0), - (-1.0, 1.0, -1.0), - (-1.0, 1.0, 1.0), - (1.0, 1.0, 1.0), - (-1.0, 1.0, 1.0), - (1.0, -1.0, 1.0)); - - -- Two UV coordinatesfor each vertex. These were generated randomly. - UV_Data : Singles.Vector2_Array (1 .. 36) := - ((0.000059, 0.000004), - (0.000103, 0.336048), - (0.335973, 0.335903), - (1.000023, 0.000013), - (0.667979, 0.335851), - (0.999958, 0.336064), - (0.667979, 0.335851), - (0.336024, 0.671877), - (0.667969, 0.671889), - (1.000023, 0.000013), - (0.668104, 0.000013), - (0.667979, 0.335851), - (0.000059, 0.000004), - (0.335973, 0.335903), - (0.336098, 0.000071), - (0.667979, 0.335851), - (0.335973, 0.335903), - (0.336024, 0.671877), - (1.000004, 0.671847), - (0.999958, 0.336064), - (0.667979, 0.335851), - (0.668104, 0.000013), - (0.335973, 0.335903), - (0.667979, 0.335851), - (0.335973, 0.335903), - (0.668104, 0.000013), - (0.336098, 0.000071), - (0.000103, 0.336048), - (0.000004, 0.671870), - (0.336024, 0.671877), - (0.000103, 0.336048), - (0.336024, 0.671877), - (0.335973, 0.335903), - (0.667969, 0.671889), - (1.000004, 0.671847), - (0.667979, 0.335851)); -end Cube_Data; diff --git a/examples/ogl_tutorials/06_keyboard_mouse/src/keyboard_mouse.adb b/examples/ogl_tutorials/06_keyboard_mouse/src/keyboard_mouse.adb deleted file mode 100644 index b4c8da8d..00000000 --- a/examples/ogl_tutorials/06_keyboard_mouse/src/keyboard_mouse.adb +++ /dev/null @@ -1,27 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Keyboard_Mouse is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Tutorial 6 - Keyboard_Mouse Cube"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Tutorial_6 returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Tutorial_6."); - Put_Line (Exception_Information (anError)); -end Keyboard_Mouse; diff --git a/examples/ogl_tutorials/06_keyboard_mouse/src/main_loop.adb b/examples/ogl_tutorials/06_keyboard_mouse/src/main_loop.adb deleted file mode 100644 index 833d8ae6..00000000 --- a/examples/ogl_tutorials/06_keyboard_mouse/src/main_loop.adb +++ /dev/null @@ -1,180 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types; use GL.Types; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input.Keys; -with Glfw.Input.Mouse; -with Glfw.Windows; -with Glfw.Windows.Context; - -with Controls; -with Cube_Data; -with Program_Loader; -with Load_DDS; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 1.0); - - Vertices_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - UVs_Buffer : GL.Objects.Buffers.Buffer; - Render_Program : GL.Objects.Programs.Program; - MVP_Matrix_ID : GL.Uniforms.Uniform; - Texture_ID : GL.Uniforms.Uniform; - Cube_Texture : GL.Objects.Textures.Texture; - MVP_Matrix : GL.Types.Singles.Matrix4; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program); - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - - begin - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - - GL.Objects.Programs.Use_Program (Render_Program); - Set_MVP_Matrix (Window, Render_Program); - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - - GL.Objects.Textures.Set_Active_Unit (0); - GL.Objects.Textures.Targets.Texture_2D.Bind (Cube_Texture); - GL.Uniforms.Set_Int (Texture_ID, 0); - - -- First attribute buffer : vertices - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - - -- Second attribute buffer : UVs - GL.Attributes.Enable_Vertex_Attrib_Array (1); - Array_Buffer.Bind (UVs_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (1, 2, Single_Type, False, 0, 0); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Triangles, - First => 0, - Count => 12 * 3); - - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Attributes.Disable_Vertex_Attrib_Array (1); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program) is - use GL.Types.Singles; - Model_Matrix : constant Matrix4 := Singles.Identity4; - Projection_Matrix : Matrix4; - View_Matrix : Matrix4; - begin - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP_5"); - - Controls.Compute_Matrices_From_Inputs (Window, Projection_Matrix, View_Matrix); - - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - exception - when others => - Put_Line ("An exception occurred in Set_MVP_Matrix."); - raise; - end Set_MVP_Matrix; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use Glfw.Input; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - begin - Window.Set_Input_Toggle (Sticky_Keys, True); - Window.Set_Cursor_Mode (Mouse.Disabled); - Glfw.Input.Poll_Events; - - Window'Access.Get_Size (Window_Width, Window_Height); - Window'Access.Set_Cursor_Pos (Mouse.Coordinate (0.5 * Single (Window_Width)), - Mouse.Coordinate (0.5 * Single (Window_Height))); - Utilities.Clear_Background_Colour (Dark_Blue); - - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - - Vertices_Array_Object.Initialize_Id; - Vertices_Array_Object.Bind; - - Render_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/Transform_Vertex_Shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/Texture_Fragment_Shader.glsl", - Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Render_Program); - - Set_MVP_Matrix (Window, Render_Program); - - Load_DDS ("src/textures/uvtemplate.DDS", Cube_Texture); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "myTextureSampler"); - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Cube_Data.Vertex_Data, Static_Draw); - - UVs_Buffer.Initialize_Id; - Array_Buffer.Bind (UVs_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Cube_Data.UV_Data, Static_Draw); - Utilities.Enable_Mouse_Callbacks (Window, True); - Window.Enable_Callback (Glfw.Windows.Callbacks.Char); - Window.Enable_Callback (Glfw.Windows.Callbacks.Position); - exception - when others => - Put_Line ("An exception occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup (Main_Window); - while Running loop - Render (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/06_keyboard_mouse/src/main_loop.ads b/examples/ogl_tutorials/06_keyboard_mouse/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/06_keyboard_mouse/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/06_keyboard_mouse/src/shaders/Texture_Fragment_Shader.glsl b/examples/ogl_tutorials/06_keyboard_mouse/src/shaders/Texture_Fragment_Shader.glsl deleted file mode 100755 index 646e6c1f..00000000 --- a/examples/ogl_tutorials/06_keyboard_mouse/src/shaders/Texture_Fragment_Shader.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 410 core - -// Interpolated values from the vertex shaders -in vec2 UV; - -out vec3 colour; - -// Values that stay constant for the whole mesh. -uniform sampler2D myTextureSampler; - -void main() -{ - colour = texture(myTextureSampler, UV).rgb; -} diff --git a/examples/ogl_tutorials/06_keyboard_mouse/src/shaders/Transform_Vertex_Shader.glsl b/examples/ogl_tutorials/06_keyboard_mouse/src/shaders/Transform_Vertex_Shader.glsl deleted file mode 100755 index 78e395a2..00000000 --- a/examples/ogl_tutorials/06_keyboard_mouse/src/shaders/Transform_Vertex_Shader.glsl +++ /dev/null @@ -1,18 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 vertexPosition_modelspace; -layout(location = 1) in vec2 vertexUV; - -// Output data ; will be interpolated for each fragment. -out vec2 UV; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP_5; - -void main() -{ - gl_Position = MVP_5 * vec4(vertexPosition_modelspace,1.0); - UV = vertexUV; -} - diff --git a/examples/ogl_tutorials/06_keyboard_mouse/src/textures/uvtemplate.DDS b/examples/ogl_tutorials/06_keyboard_mouse/src/textures/uvtemplate.DDS deleted file mode 100755 index 3e9afee7..00000000 Binary files a/examples/ogl_tutorials/06_keyboard_mouse/src/textures/uvtemplate.DDS and /dev/null differ diff --git a/examples/ogl_tutorials/06_keyboard_mouse/tutorial_06.gpr b/examples/ogl_tutorials/06_keyboard_mouse/tutorial_06.gpr deleted file mode 100644 index c0847941..00000000 --- a/examples/ogl_tutorials/06_keyboard_mouse/tutorial_06.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tutorial_06 is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("keyboard_mouse.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tutorial_06; - diff --git a/examples/ogl_tutorials/07_model_loading/.gitignore b/examples/ogl_tutorials/07_model_loading/.gitignore deleted file mode 100644 index 6ad83913..00000000 --- a/examples/ogl_tutorials/07_model_loading/.gitignore +++ /dev/null @@ -1 +0,0 @@ -model_loading diff --git a/examples/ogl_tutorials/07_model_loading/src/main_loop.adb b/examples/ogl_tutorials/07_model_loading/src/main_loop.adb deleted file mode 100644 index 8a380ab5..00000000 --- a/examples/ogl_tutorials/07_model_loading/src/main_loop.adb +++ /dev/null @@ -1,168 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input.Keys; -with Glfw.Input.Mouse; -with Glfw.Windows; -with Glfw.Windows.Context; - -with Controls; -with Program_Loader; -with Load_DDS; -with Load_Object_File; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 0.0); - - Vertices_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - UVs_Buffer : GL.Objects.Buffers.Buffer; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - MVP_Matrix_ID : GL.Uniforms.Uniform; - Texture_ID : GL.Uniforms.Uniform; - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program; - Num_Vertices : GL.Types.Int; - Sample_Texture : GL.Objects.Textures.Texture) is - use GL.Objects.Buffers; - use GL.Types; - use GL.Types.Singles; - Model_Matrix : constant Singles.Matrix4 := GL.Types.Singles.Identity4; - View_Matrix : Singles.Matrix4; - Projection_Matrix : Singles.Matrix4; - MVP_Matrix : Singles.Matrix4; - begin - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - GL.Objects.Programs.Use_Program (Render_Program); - Controls.Compute_Matrices_From_Inputs (Window, Projection_Matrix, View_Matrix); - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - -- Bind our texture in Texture Unit 0 - GL.Objects.Textures.Set_Active_Unit (0); - GL.Objects.Textures.Targets.Texture_2D.Bind (Sample_Texture); - GL.Uniforms.Set_Int (Texture_ID, 0); - - -- First attribute buffer : vertices - GL.Attributes.Enable_Vertex_Attrib_Array (0); - GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - -- Second attribute buffer : UVs - GL.Attributes.Enable_Vertex_Attrib_Array (1); - GL.Objects.Buffers.Array_Buffer.Bind (UVs_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (1, 2, Single_Type, False, 0, 0); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, Num_Vertices); - - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Attributes.Disable_Vertex_Attrib_Array (1); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window; - Render_Program : out GL.Objects.Programs.Program; - Array_Size : out GL.Types.Int; - Sample_Texture : out GL.Objects.Textures.Texture) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use GL.Types; - use Glfw.Input; - Window_Width : constant Glfw.Size := 1024; - Window_Height : constant Glfw.Size := 768; - begin - Utilities.Clear_Background_Colour (Dark_Blue); - Window.Set_Input_Toggle (Sticky_Keys, True); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - Window.Set_Cursor_Mode (Mouse.Disabled); - Glfw.Input.Poll_Events; - - Window'Access.Set_Size (Window_Width, Window_Height); - Window'Access.Set_Cursor_Pos (Mouse.Coordinate (0.5 * Single (Window_Width)), - Mouse.Coordinate (0.5 * Single (Window_Height))); - - Vertices_Array_Object.Initialize_Id; - Vertices_Array_Object.Bind; - - Render_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/Transform_Vertex_Shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/Texture_Fragment_Shader.glsl", - Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Render_Program); - - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP"); - - Load_DDS ("src/textures/uvmap.DDS", Sample_Texture); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "myTextureSampler"); - - Array_Size := Load_Object_File.Mesh_Size ("src/textures/cube.obj"); - declare - Vertices : GL.Types.Singles.Vector3_Array (1 .. Array_Size); - UVs : GL.Types.Singles.Vector2_Array (1 .. Array_Size); - begin - Load_Object_File.Load_Object ("src/textures/cube.obj", Vertices, UVs); - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertices, Static_Draw); - - UVs_Buffer.Initialize_Id; - Array_Buffer.Bind (UVs_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, UVs, Static_Draw); - end; - - exception - when others => - Put_Line ("An exception occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; - Render_Program : GL.Objects.Programs.Program; - Array_Size : GL.Types.Int; - Sample_Texture : GL.Objects.Textures.Texture; -begin - Setup (Main_Window, Render_Program, Array_Size, Sample_Texture); - while Running loop - Render (Main_Window, Render_Program, Array_Size, Sample_Texture); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/07_model_loading/src/main_loop.ads b/examples/ogl_tutorials/07_model_loading/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/07_model_loading/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/07_model_loading/src/model_loading.adb b/examples/ogl_tutorials/07_model_loading/src/model_loading.adb deleted file mode 100644 index bfebecb2..00000000 --- a/examples/ogl_tutorials/07_model_loading/src/model_loading.adb +++ /dev/null @@ -1,27 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Model_Loading is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Tutorial 7 - Model Loading"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Model_Loading returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Model_Loading."); - Put_Line (Exception_Information (anError)); -end Model_Loading; diff --git a/examples/ogl_tutorials/07_model_loading/src/shaders/Texture_Fragment_Shader.glsl b/examples/ogl_tutorials/07_model_loading/src/shaders/Texture_Fragment_Shader.glsl deleted file mode 100755 index 7800dfb8..00000000 --- a/examples/ogl_tutorials/07_model_loading/src/shaders/Texture_Fragment_Shader.glsl +++ /dev/null @@ -1,16 +0,0 @@ -#version 410 core - -// Interpolated values from the vertex shaders -in vec2 UV; - -// Ouput data -out vec3 colour; - -// Values that stay constant for the whole mesh. -uniform sampler2D myTextureSampler; - -void main() - { - // Output color = color of the texture at the specified UV - colour = texture( myTextureSampler, UV ).rgb; - } diff --git a/examples/ogl_tutorials/07_model_loading/src/shaders/Transform_Vertex_Shader.glsl b/examples/ogl_tutorials/07_model_loading/src/shaders/Transform_Vertex_Shader.glsl deleted file mode 100755 index b1a7fd6a..00000000 --- a/examples/ogl_tutorials/07_model_loading/src/shaders/Transform_Vertex_Shader.glsl +++ /dev/null @@ -1,21 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 vertexPosition_modelspace; -layout(location = 1) in vec2 vertexUV; - -// Output data ; will be interpolated for each fragment. -out vec2 UV; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP; - -void main() - { - // Output position of the vertex, in clip space : MVP * position - gl_Position = MVP * vec4(vertexPosition_modelspace, 1); - - // UV of the vertex. No special space for this one. - UV = vertexUV; - } - diff --git a/examples/ogl_tutorials/07_model_loading/src/textures/cube.obj b/examples/ogl_tutorials/07_model_loading/src/textures/cube.obj deleted file mode 100755 index 58fc484c..00000000 --- a/examples/ogl_tutorials/07_model_loading/src/textures/cube.obj +++ /dev/null @@ -1,47 +0,0 @@ -# Blender3D v249 OBJ File: untitled.blend -# www.blender3d.org -mtllib cube.mtl -v 1.000000 -1.000000 -1.000000 -v 1.000000 -1.000000 1.000000 -v -1.000000 -1.000000 1.000000 -v -1.000000 -1.000000 -1.000000 -v 1.000000 1.000000 -1.000000 -v 0.999999 1.000000 1.000001 -v -1.000000 1.000000 1.000000 -v -1.000000 1.000000 -1.000000 -vt 0.748573 0.750412 -vt 0.749279 0.501284 -vt 0.999110 0.501077 -vt 0.999455 0.750380 -vt 0.250471 0.500702 -vt 0.249682 0.749677 -vt 0.001085 0.750380 -vt 0.001517 0.499994 -vt 0.499422 0.500239 -vt 0.500149 0.750166 -vt 0.748355 0.998230 -vt 0.500193 0.998728 -vt 0.498993 0.250415 -vt 0.748953 0.250920 -vn 0.000000 0.000000 -1.000000 -vn -1.000000 -0.000000 -0.000000 -vn -0.000000 -0.000000 1.000000 -vn -0.000001 0.000000 1.000000 -vn 1.000000 -0.000000 0.000000 -vn 1.000000 0.000000 0.000001 -vn 0.000000 1.000000 -0.000000 -vn -0.000000 -1.000000 0.000000 -usemtl Material_ray.png -s off -f 5/1/1 1/2/1 4/3/1 -f 5/1/1 4/3/1 8/4/1 -f 3/5/2 7/6/2 8/7/2 -f 3/5/2 8/7/2 4/8/2 -f 2/9/3 6/10/3 3/5/3 -f 6/10/4 7/6/4 3/5/4 -f 1/2/5 5/1/5 2/9/5 -f 5/1/6 6/10/6 2/9/6 -f 5/1/7 8/11/7 6/10/7 -f 8/11/7 7/12/7 6/10/7 -f 1/2/8 2/9/8 3/13/8 -f 1/2/8 3/13/8 4/14/8 diff --git a/examples/ogl_tutorials/07_model_loading/src/textures/uvmap.DDS b/examples/ogl_tutorials/07_model_loading/src/textures/uvmap.DDS deleted file mode 100755 index 90ed4c7e..00000000 Binary files a/examples/ogl_tutorials/07_model_loading/src/textures/uvmap.DDS and /dev/null differ diff --git a/examples/ogl_tutorials/07_model_loading/tutorial_07.gpr b/examples/ogl_tutorials/07_model_loading/tutorial_07.gpr deleted file mode 100644 index e376f30d..00000000 --- a/examples/ogl_tutorials/07_model_loading/tutorial_07.gpr +++ /dev/null @@ -1,14 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tutorial_07 is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("model_loading.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tutorial_07; diff --git a/examples/ogl_tutorials/08_basic_shading/.gitignore b/examples/ogl_tutorials/08_basic_shading/.gitignore deleted file mode 100644 index 549d4513..00000000 --- a/examples/ogl_tutorials/08_basic_shading/.gitignore +++ /dev/null @@ -1 +0,0 @@ -shading diff --git a/examples/ogl_tutorials/08_basic_shading/src/main_loop.adb b/examples/ogl_tutorials/08_basic_shading/src/main_loop.adb deleted file mode 100644 index 5ee8928c..00000000 --- a/examples/ogl_tutorials/08_basic_shading/src/main_loop.adb +++ /dev/null @@ -1,207 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input.Keys; -with Glfw.Input.Mouse; -with Glfw.Windows; -with Glfw.Windows.Context; - -with Controls; -with Program_Loader; -with Load_DDS; -with Load_Object_File; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 0.0); - - Vertices_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Normals_Buffer : GL.Objects.Buffers.Buffer; - UVs_Buffer : GL.Objects.Buffers.Buffer; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Light_Position_ID : GL.Uniforms.Uniform; - MVP_Matrix_ID : GL.Uniforms.Uniform; - Model_Matrix_ID : GL.Uniforms.Uniform; - View_Matrix_ID : GL.Uniforms.Uniform; - Texture_ID : GL.Uniforms.Uniform; - - -- ------------------------------------------------------------------------ - - procedure Load_Texture (Window : in out Glfw.Windows.Window; - UV_Map : GL.Objects.Textures.Texture) is - use GL.Types; - use GL.Types.Singles; - Model_Matrix : constant Singles.Matrix4 := GL.Types.Singles.Identity4; - View_Matrix : Singles.Matrix4; - Projection_Matrix : Singles.Matrix4; - MVP_Matrix : Singles.Matrix4; - begin - Controls.Compute_Matrices_From_Inputs (Window, Projection_Matrix, View_Matrix); - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - GL.Uniforms.Set_Single (Model_Matrix_ID, Model_Matrix); - GL.Uniforms.Set_Single (View_Matrix_ID, View_Matrix); - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - - GL.Uniforms.Set_Single (Light_Position_ID, 4.0, 4.0, 4.0); - - -- Bind our texture in Texture Unit 0 - GL.Objects.Textures.Set_Active_Unit (0); - GL.Objects.Textures.Targets.Texture_2D.Bind (UV_Map); - GL.Uniforms.Set_Int (Texture_ID, 0); - - exception - when others => - Put_Line ("An exception occurred in Load_Texture."); - raise; - end Load_Texture; - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program; - Vertex_Count : GL.Types.Int; - UV_Map : GL.Objects.Textures.Texture) is - use GL.Objects.Buffers; - use GL.Types; - begin - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - GL.Objects.Programs.Use_Program (Render_Program); - Load_Texture (Window, UV_Map); - - -- First attribute buffer : vertices - GL.Attributes.Enable_Vertex_Attrib_Array (0); - GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - -- Second attribute buffer : UVs - GL.Attributes.Enable_Vertex_Attrib_Array (1); - GL.Objects.Buffers.Array_Buffer.Bind (UVs_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (1, 2, Single_Type, False, 0, 0); - -- Third attribute buffer : Normals - GL.Attributes.Enable_Vertex_Attrib_Array (2); - GL.Objects.Buffers.Array_Buffer.Bind (Normals_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (2, 3, Single_Type, False, 0, 0); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, Vertex_Count); - - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Attributes.Disable_Vertex_Attrib_Array (1); - GL.Attributes.Disable_Vertex_Attrib_Array (2); - - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window; - Render_Program : out GL.Objects.Programs.Program; - Vertex_Count : out GL.Types.Int; - UV_Map : out GL.Objects.Textures.Texture) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use GL.Types; - use Glfw.Input; - Window_Width : constant Glfw.Size := 1024; - Window_Height : constant Glfw.Size := 768; - begin - Window.Set_Input_Toggle (Sticky_Keys, True); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - Window.Set_Cursor_Mode (Mouse.Disabled); - Glfw.Input.Poll_Events; - - Window'Access.Set_Size (Window_Width, Window_Height); - Window'Access.Set_Cursor_Pos (Mouse.Coordinate (0.5 * Single (Window_Width)), - Mouse.Coordinate (0.5 * Single (Window_Height))); - - Vertices_Array_Object.Initialize_Id; - Vertices_Array_Object.Bind; - - Render_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/standard_vertex_shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/standard_fragment_shader.glsl", - Fragment_Shader))); - - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP"); - Model_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "M"); - View_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "V"); - Light_Position_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "Light_Position_Worldspace"); - - Load_DDS ("src/textures/uvmap.DDS", UV_Map); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "myTextureSampler"); - - Vertex_Count := Load_Object_File.Mesh_Size ("src/textures/suzanne.obj"); - declare - Vertices : Singles.Vector3_Array (1 .. Vertex_Count); - UVs : Singles.Vector2_Array (1 .. Vertex_Count); - Normals : Singles.Vector3_Array (1 .. Vertex_Count); - begin - Load_Object_File.Load_Object ("src/textures/suzanne.obj", Vertices, UVs, Normals); - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertices, Static_Draw); - - UVs_Buffer.Initialize_Id; - Array_Buffer.Bind (UVs_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, UVs, Static_Draw); - - Normals_Buffer.Initialize_Id; - Array_Buffer.Bind (Normals_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Normals, Static_Draw); - end; - - exception - when others => - Put_Line ("An exception occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Render_Program : GL.Objects.Programs.Program; - Running : Boolean := True; - Vertex_Count : GL.Types.Int; - UV_Map : GL.Objects.Textures.Texture; -begin - Setup (Main_Window, Render_Program, Vertex_Count, UV_Map); - while Running loop - Render (Main_Window, Render_Program, Vertex_Count, UV_Map); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/08_basic_shading/src/main_loop.ads b/examples/ogl_tutorials/08_basic_shading/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/08_basic_shading/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/08_basic_shading/src/shaders/standard_fragment_shader.glsl b/examples/ogl_tutorials/08_basic_shading/src/shaders/standard_fragment_shader.glsl deleted file mode 100755 index 0f55aa00..00000000 --- a/examples/ogl_tutorials/08_basic_shading/src/shaders/standard_fragment_shader.glsl +++ /dev/null @@ -1,61 +0,0 @@ -#version 410 core - -// Interpolated values from the vertex shaders -in vec2 UV; -in vec3 Position_Worldspace; -in vec3 Normal_Camera_Space; -in vec3 Eye_Direction_Camera_Space; -in vec3 Light_Direction_Camera_Space; - -// Ouput data -out vec3 color; - -// Values that stay constant for the whole mesh. -uniform sampler2D myTextureSampler; -uniform mat4 MV; -uniform vec3 Light_Position_Worldspace; - -void main() - { - // Light emission properties - // You probably want to put them as uniforms - vec3 LightColor = vec3(1,1,1); - float LightPower = 50.0f; - - // Material properties - vec3 MaterialDiffuseColor = texture( myTextureSampler, UV ).rgb; - vec3 MaterialAmbientColor = vec3(0.1,0.1,0.1) * MaterialDiffuseColor; - vec3 MaterialSpecularColor = vec3(0.3,0.3,0.3); - - // Distance to the light - float distance = length( Light_Position_Worldspace - Position_Worldspace ); - - // Normal of the computed fragment, in camera space - vec3 n = normalize( Normal_Camera_Space ); - // Direction of the light (from the fragment to the light) - vec3 l = normalize( Light_Direction_Camera_Space ); - // Cosine of the angle between the normal and the light direction, - // clamped above 0 - // - light is at the vertical of the triangle -> 1 - // - light is perpendicular to the triangle -> 0 - // - light is behind the triangle -> 0 - float cosTheta = clamp( dot( n,l ), 0,1 ); - - // Eye vector (towards the camera) - vec3 E = normalize(Eye_Direction_Camera_Space); - // Direction in which the triangle reflects the light - vec3 R = reflect(-l,n); - // Cosine of the angle between the Eye vector and the Reflect vector, - // clamped to 0 - // - Looking into the reflection -> 1 - // - Looking elsewhere -> < 1 - float cosAlpha = clamp( dot( E,R ), 0,1 ); - - color = - // Ambient : simulates indirect lighting - MaterialAmbientColor + - // Diffuse : "color" of the object - MaterialDiffuseColor * LightColor * LightPower * cosTheta / (distance*distance) + - // Specular : reflective highlight, like a mirror - MaterialSpecularColor * LightColor * LightPower * pow(cosAlpha,5) / (distance*distance); - } diff --git a/examples/ogl_tutorials/08_basic_shading/src/shaders/standard_vertex_shader.glsl b/examples/ogl_tutorials/08_basic_shading/src/shaders/standard_vertex_shader.glsl deleted file mode 100755 index b11828cc..00000000 --- a/examples/ogl_tutorials/08_basic_shading/src/shaders/standard_vertex_shader.glsl +++ /dev/null @@ -1,44 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 Vertex_Position_Modelspace; -layout(location = 1) in vec2 Vertex_UV; -layout(location = 2) in vec3 Vertex_Normal_Modelspace; - -// Output data ; will be interpolated for each fragment. -out vec2 UV; -out vec3 Position_Worldspace; -out vec3 Normal_Camera_Space; -out vec3 Eye_Direction_Camera_Space; -out vec3 Light_Direction_Camera_Space; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP; -uniform mat4 V; -uniform mat4 M; -uniform vec3 Light_Position_Worldspace; - -void main() - { - // Output position of the vertex, in clip space : MVP * position - gl_Position = MVP * vec4(Vertex_Position_Modelspace, 1); - - // Position of the vertex, in worldspace : M * position - Position_Worldspace = (M * vec4(Vertex_Position_Modelspace, 1)).xyz; - - // Vector that goes from the vertex to the camera, in camera space. - // In camera space, the camera is at the origin (0,0,0). - vec3 Vertex_Position_Camera_Space = ( V * M * vec4(Vertex_Position_Modelspace,1)).xyz; - Eye_Direction_Camera_Space = vec3(0, 0, 0) - Vertex_Position_Camera_Space; - - // Vector that goes from the vertex to the light, in camera space. M is ommited because it's identity. - vec3 LightPosition_cameraspace = ( V * vec4(Light_Position_Worldspace, 1)).xyz; - Light_Direction_Camera_Space = Light_Direction_Camera_Space + Eye_Direction_Camera_Space; - - // Normal of the the vertex, in camera space - Normal_Camera_Space = ( V * M * vec4(Vertex_Normal_Modelspace, 0)).xyz; // Only correct if ModelMatrix does not scale the model ! Use its inverse transpose if not. - - // UV of the vertex. No special space for this one. - UV = Vertex_UV; - } - diff --git a/examples/ogl_tutorials/08_basic_shading/src/shading.adb b/examples/ogl_tutorials/08_basic_shading/src/shading.adb deleted file mode 100644 index 950e00ac..00000000 --- a/examples/ogl_tutorials/08_basic_shading/src/shading.adb +++ /dev/null @@ -1,27 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Shading is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Tutorial 8 - Basic Shading"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Shading returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Shading."); - Put_Line (Exception_Information (anError)); -end Shading; diff --git a/examples/ogl_tutorials/08_basic_shading/src/textures/suzanne.obj b/examples/ogl_tutorials/08_basic_shading/src/textures/suzanne.obj deleted file mode 100755 index 14e9bbe4..00000000 --- a/examples/ogl_tutorials/08_basic_shading/src/textures/suzanne.obj +++ /dev/null @@ -1,2580 +0,0 @@ -# Blender3D v249 OBJ File: suzanne.blend -# www.blender3d.org -v 0.437500 0.164063 0.765625 -v -0.437500 0.164063 0.765625 -v 0.500000 0.093750 0.687500 -v -0.500000 0.093750 0.687500 -v 0.546875 0.054688 0.578125 -v -0.546875 0.054688 0.578125 -v 0.351563 -0.023438 0.617188 -v -0.351563 -0.023438 0.617188 -v 0.351563 0.031250 0.718750 -v -0.351563 0.031250 0.718750 -v 0.351563 0.132813 0.781250 -v -0.351563 0.132813 0.781250 -v 0.273438 0.164063 0.796875 -v -0.273438 0.164063 0.796875 -v 0.203125 0.093750 0.742188 -v -0.203125 0.093750 0.742188 -v 0.156250 0.054688 0.648438 -v -0.156250 0.054688 0.648438 -v 0.078125 0.242188 0.656250 -v -0.078125 0.242188 0.656250 -v 0.140625 0.242188 0.742188 -v -0.140625 0.242188 0.742188 -v 0.242188 0.242188 0.796875 -v -0.242188 0.242188 0.796875 -v 0.273438 0.328125 0.796875 -v -0.273438 0.328125 0.796875 -v 0.203125 0.390625 0.742188 -v -0.203125 0.390625 0.742188 -v 0.156250 0.437500 0.648438 -v -0.156250 0.437500 0.648438 -v 0.351563 0.515625 0.617188 -v -0.351563 0.515625 0.617188 -v 0.351563 0.453125 0.718750 -v -0.351563 0.453125 0.718750 -v 0.351563 0.359375 0.781250 -v -0.351563 0.359375 0.781250 -v 0.437500 0.328125 0.765625 -v -0.437500 0.328125 0.765625 -v 0.500000 0.390625 0.687500 -v -0.500000 0.390625 0.687500 -v 0.546875 0.437500 0.578125 -v -0.546875 0.437500 0.578125 -v 0.625000 0.242188 0.562500 -v -0.625000 0.242188 0.562500 -v 0.562500 0.242188 0.671875 -v -0.562500 0.242188 0.671875 -v 0.468750 0.242188 0.757813 -v -0.468750 0.242188 0.757813 -v 0.476563 0.242188 0.773438 -v -0.476563 0.242188 0.773438 -v 0.445313 0.335938 0.781250 -v -0.445313 0.335938 0.781250 -v 0.351563 0.375000 0.804688 -v -0.351563 0.375000 0.804688 -v 0.265625 0.335938 0.820313 -v -0.265625 0.335938 0.820313 -v 0.226563 0.242188 0.820313 -v -0.226563 0.242188 0.820313 -v 0.265625 0.156250 0.820313 -v -0.265625 0.156250 0.820313 -v 0.351563 0.242188 0.828125 -v -0.351563 0.242188 0.828125 -v 0.351563 0.117188 0.804688 -v -0.351563 0.117188 0.804688 -v 0.445313 0.156250 0.781250 -v -0.445313 0.156250 0.781250 -v 0.000000 0.429688 0.742188 -v 0.000000 0.351563 0.820313 -v 0.000000 -0.679688 0.734375 -v 0.000000 -0.320313 0.781250 -v 0.000000 -0.187500 0.796875 -v 0.000000 -0.773438 0.718750 -v 0.000000 0.406250 0.601563 -v 0.000000 0.570313 0.570313 -v 0.000000 0.898438 -0.546875 -v 0.000000 0.562500 -0.851563 -v 0.000000 0.070313 -0.828125 -v 0.000000 -0.382813 -0.351563 -v 0.203125 -0.187500 0.562500 -v -0.203125 -0.187500 0.562500 -v 0.312500 -0.437500 0.570313 -v -0.312500 -0.437500 0.570313 -v 0.351563 -0.695313 0.570313 -v -0.351563 -0.695313 0.570313 -v 0.367188 -0.890625 0.531250 -v -0.367188 -0.890625 0.531250 -v 0.328125 -0.945313 0.523438 -v -0.328125 -0.945313 0.523438 -v 0.179688 -0.968750 0.554688 -v -0.179688 -0.968750 0.554688 -v 0.000000 -0.984375 0.578125 -v 0.437500 -0.140625 0.531250 -v -0.437500 -0.140625 0.531250 -v 0.632813 -0.039063 0.539063 -v -0.632813 -0.039063 0.539063 -v 0.828125 0.148438 0.445313 -v -0.828125 0.148438 0.445313 -v 0.859375 0.429688 0.593750 -v -0.859375 0.429688 0.593750 -v 0.710938 0.484375 0.625000 -v -0.710938 0.484375 0.625000 -v 0.492188 0.601563 0.687500 -v -0.492188 0.601563 0.687500 -v 0.320313 0.757813 0.734375 -v -0.320313 0.757813 0.734375 -v 0.156250 0.718750 0.757813 -v -0.156250 0.718750 0.757813 -v 0.062500 0.492188 0.750000 -v -0.062500 0.492188 0.750000 -v 0.164063 0.414063 0.773438 -v -0.164063 0.414063 0.773438 -v 0.125000 0.304688 0.765625 -v -0.125000 0.304688 0.765625 -v 0.203125 0.093750 0.742188 -v -0.203125 0.093750 0.742188 -v 0.375000 0.015625 0.703125 -v -0.375000 0.015625 0.703125 -v 0.492188 0.062500 0.671875 -v -0.492188 0.062500 0.671875 -v 0.625000 0.187500 0.648438 -v -0.625000 0.187500 0.648438 -v 0.640625 0.296875 0.648438 -v -0.640625 0.296875 0.648438 -v 0.601563 0.375000 0.664063 -v -0.601563 0.375000 0.664063 -v 0.429688 0.437500 0.718750 -v -0.429688 0.437500 0.718750 -v 0.250000 0.468750 0.757813 -v -0.250000 0.468750 0.757813 -v 0.000000 -0.765625 0.734375 -v 0.109375 -0.718750 0.734375 -v -0.109375 -0.718750 0.734375 -v 0.117188 -0.835938 0.710938 -v -0.117188 -0.835938 0.710938 -v 0.062500 -0.882813 0.695313 -v -0.062500 -0.882813 0.695313 -v 0.000000 -0.890625 0.687500 -v 0.000000 -0.195313 0.750000 -v 0.000000 -0.140625 0.742188 -v 0.101563 -0.148438 0.742188 -v -0.101563 -0.148438 0.742188 -v 0.125000 -0.226563 0.750000 -v -0.125000 -0.226563 0.750000 -v 0.085938 -0.289063 0.742188 -v -0.085938 -0.289063 0.742188 -v 0.398438 -0.046875 0.671875 -v -0.398438 -0.046875 0.671875 -v 0.617188 0.054688 0.625000 -v -0.617188 0.054688 0.625000 -v 0.726563 0.203125 0.601563 -v -0.726563 0.203125 0.601563 -v 0.742188 0.375000 0.656250 -v -0.742188 0.375000 0.656250 -v 0.687500 0.414063 0.726563 -v -0.687500 0.414063 0.726563 -v 0.437500 0.546875 0.796875 -v -0.437500 0.546875 0.796875 -v 0.312500 0.640625 0.835938 -v -0.312500 0.640625 0.835938 -v 0.203125 0.617188 0.851563 -v -0.203125 0.617188 0.851563 -v 0.101563 0.429688 0.843750 -v -0.101563 0.429688 0.843750 -v 0.125000 -0.101563 0.812500 -v -0.125000 -0.101563 0.812500 -v 0.210938 -0.445313 0.710938 -v -0.210938 -0.445313 0.710938 -v 0.250000 -0.703125 0.687500 -v -0.250000 -0.703125 0.687500 -v 0.265625 -0.820313 0.664063 -v -0.265625 -0.820313 0.664063 -v 0.234375 -0.914063 0.632813 -v -0.234375 -0.914063 0.632813 -v 0.164063 -0.929688 0.632813 -v -0.164063 -0.929688 0.632813 -v 0.000000 -0.945313 0.640625 -v 0.000000 0.046875 0.726563 -v 0.000000 0.210938 0.765625 -v 0.328125 0.476563 0.742188 -v -0.328125 0.476563 0.742188 -v 0.164063 0.140625 0.750000 -v -0.164063 0.140625 0.750000 -v 0.132813 0.210938 0.757813 -v -0.132813 0.210938 0.757813 -v 0.117188 -0.687500 0.734375 -v -0.117188 -0.687500 0.734375 -v 0.078125 -0.445313 0.750000 -v -0.078125 -0.445313 0.750000 -v 0.000000 -0.445313 0.750000 -v 0.000000 -0.328125 0.742188 -v 0.093750 -0.273438 0.781250 -v -0.093750 -0.273438 0.781250 -v 0.132813 -0.226563 0.796875 -v -0.132813 -0.226563 0.796875 -v 0.109375 -0.132813 0.781250 -v -0.109375 -0.132813 0.781250 -v 0.039063 -0.125000 0.781250 -v -0.039063 -0.125000 0.781250 -v 0.000000 -0.203125 0.828125 -v 0.046875 -0.148438 0.812500 -v -0.046875 -0.148438 0.812500 -v 0.093750 -0.156250 0.812500 -v -0.093750 -0.156250 0.812500 -v 0.109375 -0.226563 0.828125 -v -0.109375 -0.226563 0.828125 -v 0.078125 -0.250000 0.804688 -v -0.078125 -0.250000 0.804688 -v 0.000000 -0.289063 0.804688 -v 0.257813 -0.312500 0.554688 -v -0.257813 -0.312500 0.554688 -v 0.164063 -0.242188 0.710938 -v -0.164063 -0.242188 0.710938 -v 0.179688 -0.312500 0.710938 -v -0.179688 -0.312500 0.710938 -v 0.234375 -0.250000 0.554688 -v -0.234375 -0.250000 0.554688 -v 0.000000 -0.875000 0.687500 -v 0.046875 -0.867188 0.687500 -v -0.046875 -0.867188 0.687500 -v 0.093750 -0.820313 0.710938 -v -0.093750 -0.820313 0.710938 -v 0.093750 -0.742188 0.726563 -v -0.093750 -0.742188 0.726563 -v 0.000000 -0.781250 0.656250 -v 0.093750 -0.750000 0.664063 -v -0.093750 -0.750000 0.664063 -v 0.093750 -0.812500 0.640625 -v -0.093750 -0.812500 0.640625 -v 0.046875 -0.851563 0.632813 -v -0.046875 -0.851563 0.632813 -v 0.000000 -0.859375 0.632813 -v 0.171875 0.218750 0.781250 -v -0.171875 0.218750 0.781250 -v 0.187500 0.156250 0.773438 -v -0.187500 0.156250 0.773438 -v 0.335938 0.429688 0.757813 -v -0.335938 0.429688 0.757813 -v 0.273438 0.421875 0.773438 -v -0.273438 0.421875 0.773438 -v 0.421875 0.398438 0.773438 -v -0.421875 0.398438 0.773438 -v 0.562500 0.351563 0.695313 -v -0.562500 0.351563 0.695313 -v 0.585938 0.289063 0.687500 -v -0.585938 0.289063 0.687500 -v 0.578125 0.195313 0.679688 -v -0.578125 0.195313 0.679688 -v 0.476563 0.101563 0.718750 -v -0.476563 0.101563 0.718750 -v 0.375000 0.062500 0.742188 -v -0.375000 0.062500 0.742188 -v 0.226563 0.109375 0.781250 -v -0.226563 0.109375 0.781250 -v 0.179688 0.296875 0.781250 -v -0.179688 0.296875 0.781250 -v 0.210938 0.375000 0.781250 -v -0.210938 0.375000 0.781250 -v 0.234375 0.359375 0.757813 -v -0.234375 0.359375 0.757813 -v 0.195313 0.296875 0.757813 -v -0.195313 0.296875 0.757813 -v 0.242188 0.125000 0.757813 -v -0.242188 0.125000 0.757813 -v 0.375000 0.085938 0.726563 -v -0.375000 0.085938 0.726563 -v 0.460938 0.117188 0.703125 -v -0.460938 0.117188 0.703125 -v 0.546875 0.210938 0.671875 -v -0.546875 0.210938 0.671875 -v 0.554688 0.281250 0.671875 -v -0.554688 0.281250 0.671875 -v 0.531250 0.335938 0.679688 -v -0.531250 0.335938 0.679688 -v 0.414063 0.390625 0.750000 -v -0.414063 0.390625 0.750000 -v 0.281250 0.398438 0.765625 -v -0.281250 0.398438 0.765625 -v 0.335938 0.406250 0.750000 -v -0.335938 0.406250 0.750000 -v 0.203125 0.171875 0.750000 -v -0.203125 0.171875 0.750000 -v 0.195313 0.226563 0.750000 -v -0.195313 0.226563 0.750000 -v 0.109375 0.460938 0.609375 -v -0.109375 0.460938 0.609375 -v 0.195313 0.664063 0.617188 -v -0.195313 0.664063 0.617188 -v 0.335938 0.687500 0.593750 -v -0.335938 0.687500 0.593750 -v 0.484375 0.554688 0.554688 -v -0.484375 0.554688 0.554688 -v 0.679688 0.453125 0.492188 -v -0.679688 0.453125 0.492188 -v 0.796875 0.406250 0.460938 -v -0.796875 0.406250 0.460938 -v 0.773438 0.164063 0.375000 -v -0.773438 0.164063 0.375000 -v 0.601563 0.000000 0.414063 -v -0.601563 0.000000 0.414063 -v 0.437500 -0.093750 0.468750 -v -0.437500 -0.093750 0.468750 -v 0.000000 0.898438 0.289063 -v 0.000000 0.984375 -0.078125 -v 0.000000 -0.195313 -0.671875 -v 0.000000 -0.460938 0.187500 -v 0.000000 -0.976563 0.460938 -v 0.000000 -0.804688 0.343750 -v 0.000000 -0.570313 0.320313 -v 0.000000 -0.484375 0.281250 -v 0.851563 0.234375 0.054688 -v -0.851563 0.234375 0.054688 -v 0.859375 0.320313 -0.046875 -v -0.859375 0.320313 -0.046875 -v 0.773438 0.265625 -0.437500 -v -0.773438 0.265625 -0.437500 -v 0.460938 0.437500 -0.703125 -v -0.460938 0.437500 -0.703125 -v 0.734375 -0.046875 0.070313 -v -0.734375 -0.046875 0.070313 -v 0.593750 -0.125000 -0.164063 -v -0.593750 -0.125000 -0.164063 -v 0.640625 -0.007813 -0.429688 -v -0.640625 -0.007813 -0.429688 -v 0.335938 0.054688 -0.664063 -v -0.335938 0.054688 -0.664063 -v 0.234375 -0.351563 0.406250 -v -0.234375 -0.351563 0.406250 -v 0.179688 -0.414063 0.257813 -v -0.179688 -0.414063 0.257813 -v 0.289063 -0.710938 0.382813 -v -0.289063 -0.710938 0.382813 -v 0.250000 -0.500000 0.390625 -v -0.250000 -0.500000 0.390625 -v 0.328125 -0.914063 0.398438 -v -0.328125 -0.914063 0.398438 -v 0.140625 -0.757813 0.367188 -v -0.140625 -0.757813 0.367188 -v 0.125000 -0.539063 0.359375 -v -0.125000 -0.539063 0.359375 -v 0.164063 -0.945313 0.437500 -v -0.164063 -0.945313 0.437500 -v 0.218750 -0.281250 0.429688 -v -0.218750 -0.281250 0.429688 -v 0.210938 -0.226563 0.468750 -v -0.210938 -0.226563 0.468750 -v 0.203125 -0.171875 0.500000 -v -0.203125 -0.171875 0.500000 -v 0.210938 -0.390625 0.164063 -v -0.210938 -0.390625 0.164063 -v 0.296875 -0.312500 -0.265625 -v -0.296875 -0.312500 -0.265625 -v 0.343750 -0.148438 -0.539063 -v -0.343750 -0.148438 -0.539063 -v 0.453125 0.867188 -0.382813 -v -0.453125 0.867188 -0.382813 -v 0.453125 0.929688 -0.070313 -v -0.453125 0.929688 -0.070313 -v 0.453125 0.851563 0.234375 -v -0.453125 0.851563 0.234375 -v 0.460938 0.523438 0.429688 -v -0.460938 0.523438 0.429688 -v 0.726563 0.406250 0.335938 -v -0.726563 0.406250 0.335938 -v 0.632813 0.453125 0.281250 -v -0.632813 0.453125 0.281250 -v 0.640625 0.703125 0.054688 -v -0.640625 0.703125 0.054688 -v 0.796875 0.562500 0.125000 -v -0.796875 0.562500 0.125000 -v 0.796875 0.617188 -0.117188 -v -0.796875 0.617188 -0.117188 -v 0.640625 0.750000 -0.195313 -v -0.640625 0.750000 -0.195313 -v 0.640625 0.679688 -0.445313 -v -0.640625 0.679688 -0.445313 -v 0.796875 0.539063 -0.359375 -v -0.796875 0.539063 -0.359375 -v 0.617188 0.328125 -0.585938 -v -0.617188 0.328125 -0.585938 -v 0.484375 0.023438 -0.546875 -v -0.484375 0.023438 -0.546875 -v 0.820313 0.328125 -0.203125 -v -0.820313 0.328125 -0.203125 -v 0.406250 -0.171875 0.148438 -v -0.406250 -0.171875 0.148438 -v 0.429688 -0.195313 -0.210938 -v -0.429688 -0.195313 -0.210938 -v 0.890625 0.406250 -0.234375 -v -0.890625 0.406250 -0.234375 -v 0.773438 -0.140625 -0.125000 -v -0.773438 -0.140625 -0.125000 -v 1.039063 -0.101563 -0.328125 -v -1.039063 -0.101563 -0.328125 -v 1.281250 0.054688 -0.429688 -v -1.281250 0.054688 -0.429688 -v 1.351563 0.320313 -0.421875 -v -1.351563 0.320313 -0.421875 -v 1.234375 0.507813 -0.421875 -v -1.234375 0.507813 -0.421875 -v 1.023438 0.476563 -0.312500 -v -1.023438 0.476563 -0.312500 -v 1.015625 0.414063 -0.289063 -v -1.015625 0.414063 -0.289063 -v 1.187500 0.437500 -0.390625 -v -1.187500 0.437500 -0.390625 -v 1.265625 0.289063 -0.406250 -v -1.265625 0.289063 -0.406250 -v 1.210938 0.078125 -0.406250 -v -1.210938 0.078125 -0.406250 -v 1.031250 -0.039063 -0.304688 -v -1.031250 -0.039063 -0.304688 -v 0.828125 -0.070313 -0.132813 -v -0.828125 -0.070313 -0.132813 -v 0.921875 0.359375 -0.218750 -v -0.921875 0.359375 -0.218750 -v 0.945313 0.304688 -0.289063 -v -0.945313 0.304688 -0.289063 -v 0.882813 -0.023438 -0.210938 -v -0.882813 -0.023438 -0.210938 -v 1.039063 0.000000 -0.367188 -v -1.039063 0.000000 -0.367188 -v 1.187500 0.093750 -0.445313 -v -1.187500 0.093750 -0.445313 -v 1.234375 0.250000 -0.445313 -v -1.234375 0.250000 -0.445313 -v 1.171875 0.359375 -0.437500 -v -1.171875 0.359375 -0.437500 -v 1.023438 0.343750 -0.359375 -v -1.023438 0.343750 -0.359375 -v 0.843750 0.289063 -0.210938 -v -0.843750 0.289063 -0.210938 -v 0.835938 0.171875 -0.273438 -v -0.835938 0.171875 -0.273438 -v 0.757813 0.093750 -0.273438 -v -0.757813 0.093750 -0.273438 -v 0.820313 0.085938 -0.273438 -v -0.820313 0.085938 -0.273438 -v 0.843750 0.015625 -0.273438 -v -0.843750 0.015625 -0.273438 -v 0.812500 -0.015625 -0.273438 -v -0.812500 -0.015625 -0.273438 -v 0.726563 0.000000 -0.070313 -v -0.726563 0.000000 -0.070313 -v 0.718750 -0.023438 -0.171875 -v -0.718750 -0.023438 -0.171875 -v 0.718750 0.039063 -0.187500 -v -0.718750 0.039063 -0.187500 -v 0.796875 0.203125 -0.210938 -v -0.796875 0.203125 -0.210938 -v 0.890625 0.242188 -0.265625 -v -0.890625 0.242188 -0.265625 -v 0.890625 0.234375 -0.320313 -v -0.890625 0.234375 -0.320313 -v 0.812500 -0.015625 -0.320313 -v -0.812500 -0.015625 -0.320313 -v 0.851563 0.015625 -0.320313 -v -0.851563 0.015625 -0.320313 -v 0.828125 0.078125 -0.320313 -v -0.828125 0.078125 -0.320313 -v 0.765625 0.093750 -0.320313 -v -0.765625 0.093750 -0.320313 -v 0.843750 0.171875 -0.320313 -v -0.843750 0.171875 -0.320313 -v 1.039063 0.328125 -0.414063 -v -1.039063 0.328125 -0.414063 -v 1.187500 0.343750 -0.484375 -v -1.187500 0.343750 -0.484375 -v 1.257813 0.242188 -0.492188 -v -1.257813 0.242188 -0.492188 -v 1.210938 0.085938 -0.484375 -v -1.210938 0.085938 -0.484375 -v 1.046875 0.000000 -0.421875 -v -1.046875 0.000000 -0.421875 -v 0.882813 -0.015625 -0.265625 -v -0.882813 -0.015625 -0.265625 -v 0.953125 0.289063 -0.343750 -v -0.953125 0.289063 -0.343750 -v 0.890625 0.109375 -0.328125 -v -0.890625 0.109375 -0.328125 -v 0.937500 0.062500 -0.335938 -v -0.937500 0.062500 -0.335938 -v 1.000000 0.125000 -0.367188 -v -1.000000 0.125000 -0.367188 -v 0.960938 0.171875 -0.351563 -v -0.960938 0.171875 -0.351563 -v 1.015625 0.234375 -0.375000 -v -1.015625 0.234375 -0.375000 -v 1.054688 0.187500 -0.382813 -v -1.054688 0.187500 -0.382813 -v 1.109375 0.210938 -0.390625 -v -1.109375 0.210938 -0.390625 -v 1.085938 0.273438 -0.390625 -v -1.085938 0.273438 -0.390625 -v 1.023438 0.437500 -0.484375 -v -1.023438 0.437500 -0.484375 -v 1.250000 0.468750 -0.546875 -v -1.250000 0.468750 -0.546875 -v 1.367188 0.296875 -0.500000 -v -1.367188 0.296875 -0.500000 -v 1.312500 0.054688 -0.531250 -v -1.312500 0.054688 -0.531250 -v 1.039063 -0.085938 -0.492188 -v -1.039063 -0.085938 -0.492188 -v 0.789063 -0.125000 -0.328125 -v -0.789063 -0.125000 -0.328125 -v 0.859375 0.382813 -0.382813 -v -0.859375 0.382813 -0.382813 -v -1.023438 0.476563 -0.312500 -v -1.234375 0.507813 -0.421875 -v -0.890625 0.406250 -0.234375 -v -0.820313 0.328125 -0.203125 -vt 0.315596 0.792535 -vt 0.331462 0.787091 -vt 0.331944 0.799704 -vt 0.049262 0.798007 -vt 0.050304 0.785428 -vt 0.065913 0.791570 -vt 0.321453 0.778649 -vt 0.060677 0.777438 -vt 0.310368 0.778802 -vt 0.071744 0.778083 -vt 0.302416 0.786560 -vt 0.079345 0.786186 -vt 0.301514 0.798474 -vt 0.079717 0.798128 -vt 0.308740 0.806873 -vt 0.072125 0.806199 -vt 0.321648 0.808687 -vt 0.059149 0.807438 -vt 0.048462 0.201858 -vt 0.040084 0.207259 -vt 0.043232 0.202821 -vt 0.043249 0.220655 -vt 0.040093 0.216224 -vt 0.048480 0.221607 -vt 0.563710 0.649220 -vt 0.540594 0.657349 -vt 0.547067 0.627433 -vt 0.974643 0.218739 -vt 0.968169 0.188824 -vt 0.991286 0.196952 -vt 0.166564 0.702856 -vt 0.160061 0.635503 -vt 0.218800 0.643864 -vt 0.646379 0.202310 -vt 0.587641 0.210669 -vt 0.594146 0.143318 -vt 0.231653 0.710981 -vt 0.181122 0.727399 -vt 0.174315 0.716236 -vt 0.601897 0.129938 -vt 0.608704 0.118775 -vt 0.659234 0.135195 -vt 0.266169 0.503056 -vt 0.270502 0.531304 -vt 0.237927 0.525958 -vt 0.665505 0.320215 -vt 0.698081 0.314870 -vt 0.693747 0.343118 -vt 0.392095 0.783569 -vt 0.421339 0.774990 -vt 0.422693 0.793271 -vt 0.628129 0.465996 -vt 0.613733 0.456434 -vt 0.634389 0.436387 -vt 0.501778 0.870396 -vt 0.507486 0.857499 -vt 0.528577 0.865850 -vt 0.643384 0.583025 -vt 0.644052 0.562152 -vt 0.656465 0.561923 -vt 0.766386 0.787223 -vt 0.745292 0.810963 -vt 0.708792 0.802136 -vt 0.769147 0.634951 -vt 0.732033 0.641034 -vt 0.711181 0.618495 -vt 0.849461 0.545148 -vt 0.823375 0.497849 -vt 0.897469 0.500666 -vt 0.902318 0.546395 -vt 0.572425 0.679855 -vt 0.643837 0.668801 -vt 0.623443 0.718088 -vt 0.572425 0.724426 -vt 0.726607 0.540494 -vt 0.753364 0.518460 -vt 0.715449 0.680462 -vt 0.749227 0.698466 -vt 0.695922 0.534580 -vt 0.693526 0.510498 -vt 0.772837 0.655221 -vt 0.784620 0.679820 -vt 0.718163 0.580185 -vt 0.809389 0.599417 -vt 0.761761 0.743313 -vt 0.667750 0.767676 -vt 0.693110 0.564191 -vt 0.797155 0.722534 -vt 0.682009 0.616616 -vt 0.795802 0.787304 -vt 0.719538 0.655221 -vt 0.756895 0.826983 -vt 0.782765 0.655221 -vt 0.695179 0.821970 -vt 0.843059 0.610497 -vt 0.635588 0.780626 -vt 0.634422 0.561399 -vt 0.628274 0.581967 -vt 0.511020 0.847430 -vt 0.533908 0.850607 -vt 0.633815 0.551490 -vt 0.613046 0.571327 -vt 0.530368 0.831407 -vt 0.501394 0.842435 -vt 0.626589 0.538875 -vt 0.604527 0.544684 -vt 0.508929 0.810914 -vt 0.492547 0.829318 -vt 0.618247 0.522587 -vt 0.602583 0.501781 -vt 0.480939 0.813120 -vt 0.469234 0.787943 -vt 0.616652 0.502716 -vt 0.613925 0.497595 -vt 0.459358 0.796431 -vt 0.462840 0.801566 -vt 0.644899 0.511966 -vt 0.630336 0.517087 -vt 0.628893 0.504351 -vt 0.635735 0.498392 -vt 0.458270 0.813966 -vt 0.469630 0.821874 -vt 0.457144 0.833207 -vt 0.449054 0.817297 -vt 0.637359 0.534149 -vt 0.654293 0.524569 -vt 0.464258 0.849211 -vt 0.482600 0.837505 -vt 0.644187 0.548520 -vt 0.659377 0.540935 -vt 0.478087 0.863369 -vt 0.493557 0.851414 -vt 0.597230 0.539263 -vt 0.595257 0.495349 -vt 0.466971 0.777596 -vt 0.507407 0.801398 -vt 0.605628 0.572478 -vt 0.534801 0.825096 -vt 0.627145 0.592333 -vt 0.544318 0.853620 -vt 0.651887 0.586528 -vt 0.528822 0.875551 -vt 0.665532 0.557472 -vt 0.492878 0.878439 -vt 0.669345 0.535984 -vt 0.467321 0.871200 -vt 0.612569 0.491986 -vt 0.454710 0.792385 -vt 0.619277 0.495381 -vt 0.454636 0.800448 -vt 0.628580 0.496763 -vt 0.451294 0.809743 -vt 0.636682 0.490206 -vt 0.440853 0.813605 -vt 0.652342 0.504728 -vt 0.446182 0.836397 -vt 0.664409 0.519225 -vt 0.453285 0.856119 -vt 0.666191 0.492411 -vt 0.717596 0.474672 -vt 0.382398 0.879324 -vt 0.427166 0.842398 -vt 0.681733 0.511408 -vt 0.427493 0.877628 -vt 0.435523 0.867805 -vt 0.685777 0.532869 -vt 0.453231 0.887054 -vt 0.588528 0.478377 -vt 0.454313 0.762782 -vt 0.446975 0.900429 -vt 0.713425 0.237886 -vt 0.709019 0.215724 -vt 0.755152 0.224403 -vt 0.762923 0.242445 -vt 0.327574 0.621771 -vt 0.281440 0.630451 -vt 0.285847 0.608289 -vt 0.335345 0.603729 -vt 0.576794 0.465515 -vt 0.583867 0.423087 -vt 0.405805 0.730353 -vt 0.448347 0.745304 -vt 0.686035 0.253032 -vt 0.258456 0.593142 -vt 0.683851 0.556229 -vt 0.482266 0.899349 -vt 0.670531 0.597684 -vt 0.532990 0.898426 -vt 0.630909 0.604157 -vt 0.553941 0.861896 -vt 0.596864 0.576275 -vt 0.542184 0.818594 -vt 0.585561 0.529242 -vt 0.503791 0.785451 -vt 0.572425 0.529736 -vt 0.510638 0.773572 -vt 0.587548 0.588270 -vt 0.557294 0.815416 -vt 0.629961 0.623919 -vt 0.572425 0.868524 -vt 0.548104 0.914571 -vt 0.488130 0.914571 -vt 0.658830 0.266292 -vt 0.631691 0.281488 -vt 0.204112 0.564686 -vt 0.231252 0.579881 -vt 0.706402 0.288928 -vt 0.278823 0.557246 -vt 0.743528 0.317934 -vt 0.752264 0.346660 -vt 0.324686 0.499513 -vt 0.315950 0.528240 -vt 0.743309 0.289810 -vt 0.315731 0.556363 -vt 0.700326 0.147967 -vt 0.272746 0.698208 -vt 0.795874 0.266472 -vt 0.775660 0.289442 -vt 0.757507 0.263314 -vt 0.348083 0.556732 -vt 0.329929 0.582860 -vt 0.368297 0.579702 -vt 0.804056 0.232825 -vt 0.376478 0.613349 -vt 0.810124 0.179100 -vt 0.382547 0.667075 -vt 0.753847 0.157090 -vt 0.811201 0.146834 -vt 0.383624 0.699341 -vt 0.326269 0.689085 -vt 0.879685 0.183943 -vt 0.888071 0.157228 -vt 0.460496 0.688946 -vt 0.452109 0.662231 -vt 0.925222 0.140531 -vt 0.947451 0.149372 -vt 0.519876 0.696801 -vt 0.497647 0.705643 -vt 0.876420 0.258223 -vt 0.946138 0.286262 -vt 0.518561 0.559910 -vt 0.448843 0.587951 -vt 0.829953 0.196170 -vt 0.837053 0.152275 -vt 0.409477 0.693900 -vt 0.402377 0.650004 -vt 0.829888 0.255993 -vt 0.402311 0.590181 -vt 0.852096 0.297194 -vt 0.813695 0.289418 -vt 0.424519 0.548979 -vt 0.386117 0.556756 -vt 0.820842 0.328587 -vt 0.789451 0.311961 -vt 0.393264 0.517587 -vt 0.361873 0.534212 -vt 0.840465 0.403536 -vt 0.762603 0.423087 -vt 0.412887 0.442637 -vt 0.335024 0.423087 -vt 0.909248 0.345901 -vt 0.481670 0.500271 -vt 0.676670 0.402805 -vt 0.249092 0.443369 -vt 0.573469 0.193539 -vt 0.579214 0.151927 -vt 0.151632 0.694246 -vt 0.145888 0.652633 -vt 0.546919 0.227092 -vt 0.536510 0.214419 -vt 0.119340 0.619080 -vt 0.108931 0.631753 -vt 0.588792 0.317539 -vt 0.161214 0.528634 -vt 0.630429 0.371564 -vt 0.202851 0.474609 -vt 0.657494 0.118541 -vt 0.164237 0.319427 -vt 0.169464 0.304721 -vt 0.210459 0.345510 -vt 0.169574 0.118572 -vt 0.164356 0.103821 -vt 0.210731 0.077759 -vt 0.229913 0.727634 -vt 0.589956 0.115821 -vt 0.153468 0.300432 -vt 0.153526 0.122857 -vt 0.162374 0.730353 -vt 0.578472 0.119429 -vt 0.553653 0.120209 -vt 0.126070 0.725964 -vt 0.150890 0.726744 -vt 0.546510 0.159800 -vt 0.509384 0.119033 -vt 0.081800 0.727137 -vt 0.118929 0.686371 -vt 0.534072 0.185482 -vt 0.106492 0.660689 -vt 0.462352 0.161885 -vt 0.478174 0.145123 -vt 0.493641 0.175543 -vt 0.505521 0.150780 -vt 0.077939 0.695390 -vt 0.050592 0.701044 -vt 0.066060 0.670626 -vt 0.034770 0.684282 -vt 0.476706 0.124129 -vt 0.049122 0.722039 -vt 0.465324 0.131169 -vt 0.037741 0.714998 -vt 0.446348 0.149671 -vt 0.018765 0.696495 -vt 0.445483 0.184898 -vt 0.427581 0.175095 -vt 0.000000 0.671069 -vt 0.017903 0.661268 -vt 0.480167 0.198327 -vt 0.052588 0.647841 -vt 0.521714 0.207472 -vt 0.094135 0.638699 -vt 0.701979 0.120236 -vt 0.274400 0.725940 -vt 0.757541 0.138176 -vt 0.329963 0.708000 -vt 0.817327 0.117813 -vt 0.389751 0.728363 -vt 0.844767 0.126748 -vt 0.417191 0.719428 -vt 0.893893 0.126476 -vt 0.466319 0.719698 -vt 0.936543 0.115821 -vt 0.508970 0.730353 -vt 0.965717 0.128368 -vt 0.538144 0.717805 -vt 0.989276 0.166159 -vt 0.561701 0.680013 -vt 1.000000 0.175243 -vt 0.572425 0.670929 -vt 0.289028 0.269037 -vt 0.283878 0.263049 -vt 0.299187 0.258321 -vt 0.300964 0.267357 -vt 0.299421 0.165436 -vt 0.284101 0.160633 -vt 0.289287 0.154655 -vt 0.301244 0.156393 -vt 0.317793 0.260767 -vt 0.316733 0.267304 -vt 0.318078 0.163079 -vt 0.317052 0.156521 -vt 0.335398 0.269583 -vt 0.330421 0.276220 -vt 0.335777 0.154335 -vt 0.330824 0.147649 -vt 0.278552 0.277080 -vt 0.273734 0.272912 -vt 0.273975 0.150706 -vt 0.278818 0.146548 -vt 0.271078 0.306358 -vt 0.264864 0.305818 -vt 0.265194 0.117691 -vt 0.271427 0.117166 -vt 0.278613 0.324240 -vt 0.274006 0.327477 -vt 0.274436 0.095993 -vt 0.279049 0.099253 -vt 0.298062 0.342565 -vt 0.294660 0.349561 -vt 0.295240 0.073895 -vt 0.298634 0.080932 -vt 0.312476 0.342961 -vt 0.315033 0.350198 -vt 0.315702 0.073322 -vt 0.313108 0.080584 -vt 0.323281 0.337709 -vt 0.328696 0.344302 -vt 0.329405 0.079293 -vt 0.323940 0.085897 -vt 0.335361 0.313857 -vt 0.339396 0.315576 -vt 0.340031 0.108187 -vt 0.335968 0.109893 -vt 0.339920 0.298303 -vt 0.345292 0.298556 -vt 0.345869 0.125306 -vt 0.340471 0.125531 -vt 0.339277 0.286081 -vt 0.344398 0.284332 -vt 0.344895 0.139582 -vt 0.339764 0.137799 -vt 0.345671 0.260159 -vt 0.355483 0.280619 -vt 0.356003 0.143373 -vt 0.346021 0.163854 -vt 0.356162 0.297750 -vt 0.356783 0.126174 -vt 0.349494 0.319809 -vt 0.350195 0.103982 -vt 0.333524 0.354692 -vt 0.334295 0.068869 -vt 0.317323 0.364551 -vt 0.318050 0.058911 -vt 0.293154 0.361782 -vt 0.293765 0.061619 -vt 0.263750 0.335417 -vt 0.264168 0.087998 -vt 0.251373 0.309082 -vt 0.251676 0.114380 -vt 0.264926 0.265507 -vt 0.265122 0.158092 -vt 0.278030 0.255522 -vt 0.278212 0.168150 -vt 0.320744 0.246538 -vt 0.320956 0.177355 -vt 0.296570 0.247318 -vt 0.296748 0.176443 -vt 0.038845 0.211743 -vt 0.047440 0.211734 -vt 0.055230 0.211728 -vt 0.057303 0.228458 -vt 0.057278 0.194991 -vt 0.041287 0.229096 -vt 0.041253 0.194380 -vt 0.032564 0.220061 -vt 0.032546 0.203437 -vt 0.030743 0.211752 -vt 0.029931 0.223131 -vt 0.028053 0.211756 -vt 0.029906 0.200372 -vt 0.038587 0.233067 -vt 0.038544 0.190412 -vt 0.061533 0.231825 -vt 0.061505 0.191616 -vt 0.057382 0.211726 -vt 0.168191 0.258703 -vt 0.213958 0.246887 -vt 0.214040 0.176591 -vt 0.168236 0.164676 -vt 0.148297 0.258447 -vt 0.138777 0.299079 -vt 0.138791 0.124216 -vt 0.148319 0.164919 -vt 0.115455 0.259296 -vt 0.109657 0.296761 -vt 0.109611 0.126556 -vt 0.115440 0.164070 -vt 0.119233 0.228698 -vt 0.156540 0.233552 -vt 0.156556 0.189842 -vt 0.119230 0.194690 -vt 0.173998 0.244074 -vt 0.174035 0.179329 -vt 0.195860 0.238258 -vt 0.195909 0.185188 -vt 0.203534 0.211734 -vt 0.252997 0.211802 -vt 0.171285 0.225095 -vt 0.164455 0.211704 -vt 0.180017 0.211713 -vt 0.177113 0.227468 -vt 0.171300 0.198319 -vt 0.177134 0.195952 -vt 0.185539 0.227013 -vt 0.187516 0.221322 -vt 0.187531 0.202116 -vt 0.185563 0.196419 -vt 0.176585 0.232500 -vt 0.165993 0.229894 -vt 0.176611 0.190916 -vt 0.166011 0.193512 -vt 0.189406 0.230672 -vt 0.189438 0.192766 -vt 0.193574 0.221791 -vt 0.193592 0.201656 -vt 0.186479 0.211718 -vt 0.156919 0.211701 -vt 0.148476 0.211699 -vt 0.427853 0.115821 -vt 0.427581 0.104121 -vt 0.441185 0.104121 -vt 0.427581 0.011703 -vt 0.427581 0.000000 -vt 0.441181 0.011386 -vt 0.067509 0.234045 -vt 0.071465 0.211716 -vt 0.067479 0.189385 -vt 0.119764 0.211696 -vt 0.060932 0.261035 -vt 0.038121 0.261699 -vt 0.038025 0.161756 -vt 0.060860 0.162382 -vt 0.019864 0.255578 -vt 0.019760 0.167921 -vt 0.016617 0.242679 -vt 0.016537 0.180842 -vt 0.014466 0.211775 -vt 0.297831 0.211892 -vt 0.340508 0.212027 -vt 0.356498 0.241635 -vt 0.356742 0.182510 -vt 0.236517 0.317748 -vt 0.236802 0.105655 -vt 0.264789 0.363401 -vt 0.265286 0.059917 -vt 0.296951 0.385966 -vt 0.297650 0.037339 -vt 0.337996 0.385300 -vt 0.338890 0.038126 -vt 0.349401 0.368365 -vt 0.350300 0.055183 -vt 0.377282 0.319664 -vt 0.378129 0.104260 -vt 0.394788 0.292204 -vt 0.395576 0.131978 -vt 0.391029 0.270263 -vt 0.391643 0.154015 -vt 0.368661 0.212151 -vt 0.379482 0.228055 -vt 0.379686 0.196331 -vt 0.420379 0.261837 -vt 0.421104 0.162716 -vt 0.426533 0.298960 -vt 0.427581 0.125377 -vt 0.396664 0.342212 -vt 0.397734 0.081667 -vt 0.365156 0.387054 -vt 0.366203 0.036443 -vt 0.346744 0.416452 -vt 0.347768 0.006839 -vt 0.278009 0.423087 -vt 0.278714 0.000000 -vt 0.241964 0.376122 -vt 0.242399 0.047096 -vt 0.055563 0.291878 -vt 0.055443 0.131506 -vt 0.014495 0.288026 -vt 0.014318 0.135436 -vt 0.003828 0.279132 -vt 0.003650 0.144368 -vt 0.000113 0.248111 -vt 0.000000 0.175447 -vt 0.000000 0.211799 -vt 0.046962 0.798865 -vt 0.047306 0.784561 -vt 0.334495 0.786358 -vt 0.334204 0.800664 -vt 0.058429 0.773633 -vt 0.323868 0.774947 -vt 0.072992 0.774071 -vt 0.309301 0.774739 -vt 0.084403 0.784016 -vt 0.297459 0.784168 -vt 0.083417 0.800146 -vt 0.297728 0.800325 -vt 0.073091 0.810538 -vt 0.307582 0.811166 -vt 0.057505 0.810093 -vt 0.323173 0.811412 -vt 0.024988 0.807478 -vt 0.047717 0.829014 -vt 0.332112 0.830749 -vt 0.355774 0.810244 -vt 0.000000 0.817350 -vt 0.033121 0.852785 -vt 0.345638 0.855146 -vt 0.380299 0.821215 -vt 0.083391 0.855019 -vt 0.078555 0.829097 -vt 0.301299 0.829463 -vt 0.295318 0.855146 -vt 0.100718 0.807888 -vt 0.280100 0.807291 -vt 0.123146 0.821929 -vt 0.257070 0.820323 -vt 0.127501 0.768220 -vt 0.103229 0.776171 -vt 0.279000 0.775494 -vt 0.255105 0.766472 -vt 0.079351 0.756089 -vt 0.303746 0.756492 -vt 0.089008 0.730353 -vt 0.295241 0.730353 -vt 0.049398 0.755271 -vt 0.035422 0.733227 -vt 0.333706 0.757005 -vt 0.348646 0.735604 -vt 0.026877 0.776230 -vt 0.355274 0.778943 -vt 0.000000 0.770061 -vt 0.382398 0.773973 -vn 0.189764 -0.003571 0.981811 -vn 0.646809 -0.758202 0.082095 -vn 0.999573 -0.014496 -0.024445 -vn -0.999573 -0.014496 -0.024445 -vn -0.646809 -0.758202 0.082095 -vn -0.189764 -0.003571 0.981811 -vn -0.085788 -0.982971 0.162389 -vn 0.085788 -0.982971 0.162389 -vn -0.744835 -0.623768 0.236824 -vn 0.744835 -0.623768 0.236824 -vn -0.870968 -0.014710 0.491104 -vn 0.870968 -0.014710 0.491104 -vn -0.758354 0.606128 0.239692 -vn 0.758354 0.606128 0.239692 -vn -0.085788 0.982513 0.165105 -vn 0.085788 0.982513 0.165105 -vn 0.655141 0.750633 0.085574 -vn -0.655141 0.750633 0.085574 -vn -0.349284 -0.719932 0.599719 -vn -0.173681 0.215735 0.960845 -vn -0.809839 0.388287 0.439741 -vn 0.809839 0.388287 0.439741 -vn 0.173681 0.215735 0.960845 -vn 0.349284 -0.719932 0.599719 -vn 0.000000 0.794183 0.607654 -vn -0.508652 0.858119 -0.069887 -vn 0.000000 0.487075 0.873348 -vn 0.508652 0.858119 -0.069887 -vn 0.981414 -0.186682 0.043947 -vn 0.569811 -0.821711 0.007813 -vn 0.563463 -0.814570 0.137669 -vn -0.563463 -0.814570 0.137669 -vn -0.569811 -0.821711 0.007813 -vn -0.981414 -0.186682 0.043947 -vn 0.475845 -0.876247 0.075381 -vn 0.850520 -0.525529 -0.020692 -vn 0.876949 -0.163823 0.451766 -vn -0.876949 -0.163823 0.451766 -vn -0.850520 -0.525529 -0.020692 -vn -0.475845 -0.876247 0.075381 -vn 0.448286 -0.367870 -0.814661 -vn 0.530534 -0.539445 -0.653829 -vn 0.513077 -0.674673 -0.530595 -vn -0.513077 -0.674673 -0.530595 -vn -0.530534 -0.539445 -0.653829 -vn -0.448286 -0.367870 -0.814661 -vn 0.888180 -0.439955 -0.132389 -vn 0.588519 0.226966 0.775933 -vn 0.911527 -0.115268 0.394665 -vn -0.911527 -0.115268 0.394665 -vn -0.588519 0.226966 0.775933 -vn -0.888180 -0.439955 -0.132389 -vn 0.468886 -0.304727 0.829005 -vn 0.251564 0.260781 0.932005 -vn -0.003082 -0.330882 0.943632 -vn 0.003082 -0.330882 0.943632 -vn -0.251564 0.260781 0.932005 -vn -0.468886 -0.304727 0.829005 -vn 0.473067 0.578997 -0.664022 -vn 0.992462 0.028626 -0.118900 -vn 0.459975 -0.380261 -0.802362 -vn -0.459975 -0.380261 -0.802362 -vn -0.992462 0.028626 -0.118900 -vn -0.473067 0.578997 -0.664022 -vn -0.059908 -0.804712 -0.590594 -vn -0.346141 -0.637287 -0.688498 -vn -0.330546 -0.943236 0.031281 -vn -0.073672 -0.594989 0.800317 -vn 0.330546 -0.943236 0.031281 -vn 0.346141 -0.637287 -0.688498 -vn 0.059908 -0.804712 -0.590594 -vn 0.073672 -0.594989 0.800317 -vn 0.593738 0.595264 -0.541368 -vn -0.626057 -0.002686 -0.779748 -vn 0.626057 -0.002686 -0.779748 -vn -0.593738 0.595264 -0.541368 -vn 0.127689 0.703757 0.698843 -vn -0.713828 0.382183 0.586810 -vn 0.713828 0.382183 0.586810 -vn -0.127689 0.703757 0.698843 -vn 0.378063 0.560045 -0.737144 -vn 0.036805 -0.708457 -0.704764 -vn -0.378063 0.560045 -0.737144 -vn -0.036805 -0.708457 -0.704764 -vn -0.031556 0.838710 0.543626 -vn 0.031556 0.838710 0.543626 -vn -0.361156 0.848689 0.386303 -vn 0.361156 0.848689 0.386303 -vn -0.716392 0.204474 0.667043 -vn 0.716392 0.204474 0.667043 -vn -0.662038 -0.413770 0.624866 -vn 0.662038 -0.413770 0.624866 -vn -0.530229 -0.655751 0.537370 -vn 0.530229 -0.655751 0.537370 -vn -0.437483 0.001221 0.899197 -vn 0.550981 -0.138096 0.822993 -vn 0.437483 0.001221 0.899197 -vn -0.550981 -0.138096 0.822993 -vn -0.315958 -0.102298 0.943205 -vn 0.608539 0.296121 0.736167 -vn -0.608539 0.296121 0.736167 -vn 0.315958 -0.102298 0.943205 -vn -0.445479 -0.088778 0.890866 -vn -0.257698 0.600024 0.757317 -vn 0.257698 0.600024 0.757317 -vn 0.445479 -0.088778 0.890866 -vn -0.327799 0.169927 0.929319 -vn 0.041780 0.927213 0.372112 -vn 0.327799 0.169927 0.929319 -vn -0.041780 0.927213 0.372112 -vn -0.277932 0.260201 0.924680 -vn -0.750725 0.111545 0.651112 -vn 0.750725 0.111545 0.651112 -vn 0.277932 0.260201 0.924680 -vn -0.437910 -0.293985 0.849574 -vn -0.183782 0.036836 0.982269 -vn -0.554216 0.387219 0.736808 -vn -0.814325 0.253426 0.522111 -vn 0.554216 0.387219 0.736808 -vn 0.183782 0.036836 0.982269 -vn 0.437910 -0.293985 0.849574 -vn 0.814325 0.253426 0.522111 -vn -0.326670 -0.001617 0.945128 -vn -0.704337 -0.526872 0.475692 -vn 0.704337 -0.526872 0.475692 -vn 0.326670 -0.001617 0.945128 -vn -0.308786 0.134617 0.941527 -vn -0.629170 -0.371441 0.682730 -vn 0.629170 -0.371441 0.682730 -vn 0.308786 0.134617 0.941527 -vn 0.146184 0.948637 0.280465 -vn -0.137516 0.905820 0.400708 -vn 0.137516 0.905820 0.400708 -vn -0.146184 0.948637 0.280465 -vn 0.723746 0.690023 -0.005219 -vn -0.723746 0.690023 -0.005219 -vn 0.994690 -0.078005 0.067019 -vn -0.994690 -0.078005 0.067019 -vn 0.200934 -0.758141 0.620350 -vn -0.200934 -0.758141 0.620350 -vn -0.541246 -0.672658 0.504501 -vn 0.541246 -0.672658 0.504501 -vn -0.690054 -0.553209 0.466628 -vn 0.690054 -0.553209 0.466628 -vn -0.464003 0.686666 0.559557 -vn 0.464003 0.686666 0.559557 -vn -0.827448 -0.135899 0.544786 -vn 0.827448 -0.135899 0.544786 -vn -0.466231 0.808863 0.358196 -vn 0.466231 0.808863 0.358196 -vn -0.743980 -0.022919 0.667776 -vn 0.743980 -0.022919 0.667776 -vn -0.711295 -0.638325 0.294137 -vn 0.711295 -0.638325 0.294137 -vn -0.709769 -0.501999 0.494125 -vn 0.709769 -0.501999 0.494125 -vn -0.818903 -0.425520 0.385113 -vn -0.992523 -0.071444 -0.098758 -vn 0.992523 -0.071444 -0.098758 -vn 0.818903 -0.425520 0.385113 -vn -0.439192 -0.273568 0.855708 -vn 0.439192 -0.273568 0.855708 -vn -0.414686 -0.059877 0.907956 -vn 0.414686 -0.059877 0.907956 -vn -0.341563 0.452132 0.823939 -vn 0.341563 0.452132 0.823939 -vn -0.724509 -0.684927 0.076632 -vn -0.987548 -0.123020 0.097995 -vn 0.987548 -0.123020 0.097995 -vn 0.724509 -0.684927 0.076632 -vn -0.572741 -0.088443 0.814936 -vn 0.572741 -0.088443 0.814936 -vn -0.291818 -0.152104 0.944273 -vn 0.291818 -0.152104 0.944273 -vn 0.239662 -0.128605 0.962279 -vn -0.239662 -0.128605 0.962279 -vn 0.187017 0.370678 0.909696 -vn -0.187017 0.370678 0.909696 -vn -0.455794 0.423170 0.783044 -vn 0.455794 0.423170 0.783044 -vn -0.543504 -0.813379 -0.207343 -vn -0.560045 -0.814417 -0.151738 -vn 0.560045 -0.814417 -0.151738 -vn 0.543504 -0.813379 -0.207343 -vn -0.615375 -0.087649 -0.783319 -vn -0.447310 0.229530 -0.864406 -vn 0.447310 0.229530 -0.864406 -vn 0.615375 -0.087649 -0.783319 -vn -0.547166 -0.832179 -0.089785 -vn 0.547166 -0.832179 -0.089785 -vn -0.873135 0.486984 -0.020264 -vn -0.865352 0.331217 -0.376049 -vn 0.865352 0.331217 -0.376049 -vn 0.873135 0.486984 -0.020264 -vn -0.748741 0.518387 0.413038 -vn 0.748741 0.518387 0.413038 -vn -0.766167 0.634816 0.099612 -vn 0.766167 0.634816 0.099612 -vn -0.953185 -0.248299 -0.172430 -vn -0.665639 0.602496 -0.440321 -vn 0.665639 0.602496 -0.440321 -vn 0.953185 -0.248299 -0.172430 -vn -0.322642 0.847713 0.421033 -vn -0.188574 0.788934 -0.584765 -vn 0.188574 0.788934 -0.584765 -vn 0.322642 0.847713 0.421033 -vn -0.239784 0.745262 -0.622120 -vn 0.494247 0.520585 -0.696158 -vn -0.494247 0.520585 -0.696158 -vn 0.239784 0.745262 -0.622120 -vn -0.480697 0.731223 0.483932 -vn 0.000000 0.758690 0.651418 -vn 0.480697 0.731223 0.483932 -vn -0.489242 0.762963 0.422498 -vn -0.363109 0.908567 -0.206458 -vn 0.363109 0.908567 -0.206458 -vn 0.489242 0.762963 0.422498 -vn -0.645039 0.694540 0.318613 -vn 0.645039 0.694540 0.318613 -vn -0.492843 0.869015 0.043062 -vn -0.679434 0.728965 -0.083468 -vn 0.492843 0.869015 0.043062 -vn 0.679434 0.728965 -0.083468 -vn -0.391736 0.826014 -0.405225 -vn -0.644398 0.527207 -0.553880 -vn 0.391736 0.826014 -0.405225 -vn 0.644398 0.527207 -0.553880 -vn 0.000000 0.800714 -0.599017 -vn 0.000000 0.330729 -0.943693 -vn 0.000000 0.999664 0.025636 -vn 0.000000 -0.271462 -0.962432 -vn -0.685293 -0.583148 -0.436232 -vn -0.907224 0.252602 -0.336253 -vn 0.907224 0.252602 -0.336253 -vn 0.685293 -0.583148 -0.436232 -vn 0.000000 -0.984344 -0.176214 -vn 0.000000 -0.736351 -0.676565 -vn 0.000000 -0.948759 -0.315928 -vn 0.000000 -0.648244 -0.761406 -vn -0.317362 -0.946959 -0.049959 -vn -0.838282 -0.408155 0.361461 -vn 0.838282 -0.408155 0.361461 -vn 0.317362 -0.946959 -0.049959 -vn -0.939360 0.325999 0.106113 -vn 0.939360 0.325999 0.106113 -vn -0.930631 0.340159 0.134770 -vn -0.960143 0.231361 0.156774 -vn 0.960143 0.231361 0.156774 -vn 0.930631 0.340159 0.134770 -vn -0.812555 -0.001068 -0.582842 -vn -0.979583 0.093387 0.177862 -vn 0.979583 0.093387 0.177862 -vn 0.812555 -0.001068 -0.582842 -vn -0.272530 -0.301157 -0.913785 -vn 0.272530 -0.301157 -0.913785 -vn -0.090915 -0.776330 -0.623707 -vn -0.506851 -0.488144 -0.710471 -vn -0.142521 -0.147282 -0.978759 -vn -0.637257 0.093326 -0.764946 -vn 0.637257 0.093326 -0.764946 -vn 0.506851 -0.488144 -0.710471 -vn 0.142521 -0.147282 -0.978759 -vn 0.090915 -0.776330 -0.623707 -vn -0.937284 -0.254250 0.238350 -vn 0.937284 -0.254250 0.238350 -vn -0.430525 -0.895260 0.114597 -vn 0.430525 -0.895260 0.114597 -vn -0.158391 -0.974822 0.156774 -vn 0.158391 -0.974822 0.156774 -vn 0.000000 -0.915860 -0.401440 -vn 0.000000 -0.946440 0.322855 -vn 0.000000 -0.336802 -0.941557 -vn 0.000000 -0.175726 -0.984436 -vn -0.599231 -0.773980 0.204566 -vn 0.599231 -0.773980 0.204566 -vn -0.890988 -0.423261 -0.164037 -vn 0.890988 -0.423261 -0.164037 -vn -0.851985 0.219275 0.475387 -vn 0.851985 0.219275 0.475387 -vn -0.509171 0.852229 0.119999 -vn 0.509171 0.852229 0.119999 -vn -0.610431 0.759148 0.225867 -vn 0.610431 0.759148 0.225867 -vn -0.182470 0.981780 0.052492 -vn 0.182470 0.981780 0.052492 -vn 0.520371 0.770348 0.368389 -vn -0.520371 0.770348 0.368389 -vn 0.852718 0.504257 0.136204 -vn -0.852718 0.504257 0.136204 -vn 0.000000 0.970214 0.242164 -vn -0.709647 0.261818 0.654042 -vn 0.067293 -0.064272 0.995636 -vn -0.246590 -0.034089 0.968505 -vn -0.809717 -0.010224 0.586688 -vn 0.246590 -0.034089 0.968505 -vn -0.067293 -0.064272 0.995636 -vn 0.709647 0.261818 0.654042 -vn 0.809717 -0.010224 0.586688 -vn -0.465835 -0.080325 0.881191 -vn -0.737114 -0.244179 0.630085 -vn 0.465835 -0.080325 0.881191 -vn 0.737114 -0.244179 0.630085 -vn -0.211951 -0.085971 0.973479 -vn -0.367504 -0.376476 0.850398 -vn 0.211951 -0.085971 0.973479 -vn 0.367504 -0.376476 0.850398 -vn -0.430280 0.556597 0.710624 -vn -0.020081 -0.072939 0.997131 -vn 0.020081 -0.072939 0.997131 -vn 0.430280 0.556597 0.710624 -vn -0.090976 0.597339 0.796777 -vn -0.187933 -0.091617 0.977874 -vn 0.187933 -0.091617 0.977874 -vn 0.090976 0.597339 0.796777 -vn 0.165929 0.609363 0.775292 -vn -0.203314 0.092532 0.974700 -vn 0.203314 0.092532 0.974700 -vn -0.165929 0.609363 0.775292 -vn 0.269295 0.241676 0.932218 -vn -0.314219 -0.132420 0.940062 -vn 0.314219 -0.132420 0.940062 -vn -0.269295 0.241676 0.932218 -vn 0.420057 -0.118992 0.899625 -vn -0.119755 -0.070925 0.990234 -vn 0.119755 -0.070925 0.990234 -vn -0.420057 -0.118992 0.899625 -vn 0.226142 -0.606586 0.762139 -vn -0.320841 0.040712 0.946226 -vn 0.320841 0.040712 0.946226 -vn -0.226142 -0.606586 0.762139 -vn 0.232612 -0.746055 0.623890 -vn -0.074557 -0.391644 0.917081 -vn 0.074557 -0.391644 0.917081 -vn -0.232612 -0.746055 0.623890 -vn -0.121250 -0.313883 0.941679 -vn -0.146702 -0.035707 0.988525 -vn 0.146702 -0.035707 0.988525 -vn 0.121250 -0.313883 0.941679 -vn -0.216834 -0.273721 0.937010 -vn -0.187445 0.001160 0.982269 -vn 0.187445 0.001160 0.982269 -vn 0.216834 -0.273721 0.937010 -vn -0.303018 -0.201941 0.931333 -vn -0.253090 -0.161809 0.953795 -vn 0.253090 -0.161809 0.953795 -vn 0.303018 -0.201941 0.931333 -vn -0.140110 -0.091189 0.985900 -vn 0.140110 -0.091189 0.985900 -vn -0.237983 0.050172 0.969939 -vn 0.237983 0.050172 0.969939 -vn -0.312662 -0.237922 0.919553 -vn 0.312662 -0.237922 0.919553 -vn -0.373791 -0.105197 0.921506 -vn 0.373791 -0.105197 0.921506 -vn -0.470595 -0.164647 0.866817 -vn 0.470595 -0.164647 0.866817 -vn -0.439222 -0.376141 0.815821 -vn 0.439222 -0.376141 0.815821 -vn -0.219611 -0.540635 0.812037 -vn 0.219611 -0.540635 0.812037 -vn 0.166967 -0.374828 0.911893 -vn -0.166967 -0.374828 0.911893 -vn 0.201849 -0.277596 0.939238 -vn -0.201849 -0.277596 0.939238 -vn 0.001160 -0.165563 0.986175 -vn -0.001160 -0.165563 0.986175 -vn 0.292917 -0.174108 0.940123 -vn -0.292917 -0.174108 0.940123 -vn 0.000000 0.732200 0.681051 -vn 0.000000 -0.603626 0.797266 -vn 0.000000 -0.971740 0.235908 -vn 0.131779 -0.608295 0.782678 -vn -0.131779 -0.608295 0.782678 -vn 0.759117 0.068392 0.647298 -vn -0.759117 0.068392 0.647298 -vn 0.405957 0.643605 0.648793 -vn -0.405957 0.643605 0.648793 -vn 0.000000 0.598346 0.801202 -vn 0.073855 -0.330546 0.940855 -vn 0.000000 -0.124516 0.992187 -vn -0.073855 -0.330546 0.940855 -vn -0.085116 -0.339244 0.936827 -vn 0.085116 -0.339244 0.936827 -vn -0.141881 -0.148350 0.978698 -vn 0.141881 -0.148350 0.978698 -vn 0.000000 -0.482803 0.875698 -vn -0.692984 -0.001343 0.720908 -vn -0.095523 -0.326090 0.940489 -vn 0.095523 -0.326090 0.940489 -vn 0.692984 -0.001343 0.720908 -vn -0.646687 0.162603 0.745201 -vn 0.646687 0.162603 0.745201 -vn -0.593463 0.121860 0.795556 -vn 0.593463 0.121860 0.795556 -vn -0.124363 0.009674 0.992187 -vn -0.509995 -0.457717 0.728233 -vn 0.509995 -0.457717 0.728233 -vn 0.124363 0.009674 0.992187 -vn -0.972137 -0.167882 0.163549 -vn 0.972137 -0.167882 0.163549 -vn -0.715995 0.572161 0.399945 -vn 0.715995 0.572161 0.399945 -vn 0.000000 0.430525 0.902554 -vn 0.000000 0.010865 0.999939 -vn -0.221839 -0.606037 0.763848 -vn 0.000000 -0.492935 0.870022 -vn 0.000000 0.010315 0.999939 -vn -0.294320 -0.184484 0.937712 -vn 0.221839 -0.606037 0.763848 -vn 0.294320 -0.184484 0.937712 -vn -0.396924 0.534989 0.745781 -vn 0.247780 0.568224 0.784661 -vn -0.247780 0.568224 0.784661 -vn 0.396924 0.534989 0.745781 -vn -0.868221 -0.261330 0.421735 -vn -0.555986 -0.690695 0.462355 -vn 0.868221 -0.261330 0.421735 -vn 0.555986 -0.690695 0.462355 -vn -0.753075 0.649892 0.102298 -vn 0.753075 0.649892 0.102298 -vn 0.194189 0.935697 0.294473 -vn -0.194189 0.935697 0.294473 -vn 0.000000 0.788965 0.614399 -vn 0.000000 -0.888638 0.458571 -vn 0.000000 -0.336772 0.941557 -vn 0.000000 -0.251991 0.967711 -vn -0.188360 -0.040132 0.981262 -vn 0.000000 -0.032899 0.999451 -vn 0.188360 -0.040132 0.981262 -vn 0.000000 0.000000 1.000000 -vn -0.572039 -0.018708 0.820002 -vn -0.536332 -0.212409 0.816828 -vn 0.536332 -0.212409 0.816828 -vn 0.572039 -0.018708 0.820002 -vn -0.357707 -0.638325 0.681570 -vn 0.357707 -0.638325 0.681570 -vn -0.154302 -0.754112 0.638325 -vn 0.154302 -0.754112 0.638325 -vn 0.000000 -0.743461 0.668752 -vn 0.000000 -0.189123 0.981933 -vn 0.000000 -0.114475 0.993408 -vn 0.001404 -0.055635 0.998444 -vn -0.001404 -0.055635 0.998444 -vn -0.336283 -0.512833 0.789850 -vn 0.336283 -0.512833 0.789850 -vn -0.454543 -0.337077 0.824458 -vn 0.454543 -0.337077 0.824458 -vn -0.543474 -0.308603 0.780602 -vn 0.543474 -0.308603 0.780602 -vn -0.387158 -0.187811 0.902646 -vn 0.387158 -0.187811 0.902646 -vn -0.430647 -0.144902 0.890805 -vn 0.430647 -0.144902 0.890805 -vn -0.234016 -0.120548 0.964721 -vn 0.234016 -0.120548 0.964721 -vn -0.263833 0.168798 0.949675 -vn 0.263833 0.168798 0.949675 -vn 0.196722 0.141881 0.970122 -vn -0.196722 0.141881 0.970122 -vn -0.906766 -0.008332 0.421522 -vn -0.744133 -0.640919 0.188269 -vn 0.744133 -0.640919 0.188269 -vn 0.906766 -0.008332 0.421522 -vn -0.044191 -0.974395 0.220313 -vn 0.044191 -0.974395 0.220313 -vn 0.639943 -0.761498 0.102786 -vn -0.639943 -0.761498 0.102786 -vn 0.955504 -0.011444 0.294717 -vn -0.955504 -0.011444 0.294717 -vn 0.649678 0.754387 0.093570 -vn -0.649678 0.754387 0.093570 -vn -0.037049 0.978881 0.200903 -vn 0.037049 0.978881 0.200903 -vn -0.752342 0.635395 0.173742 -vn 0.752342 0.635395 0.173742 -vn -0.811792 -0.002777 0.583880 -vn -0.596942 0.486770 0.637684 -vn 0.596942 0.486770 0.637684 -vn 0.811792 -0.002777 0.583880 -vn -0.868221 -0.005829 0.496109 -vn -0.719504 0.473006 0.508469 -vn 0.719504 0.473006 0.508469 -vn 0.868221 -0.005829 0.496109 -vn -0.204260 0.828761 0.520951 -vn -0.095767 0.717277 0.690146 -vn 0.095767 0.717277 0.690146 -vn 0.204260 0.828761 0.520951 -vn 0.451704 0.459883 0.764458 -vn -0.451704 0.459883 0.764458 -vn 0.450362 0.693899 0.561815 -vn -0.450362 0.693899 0.561815 -vn 0.805536 0.109409 0.582324 -vn 0.691488 -0.074099 0.718558 -vn -0.691488 -0.074099 0.718558 -vn -0.805536 0.109409 0.582324 -vn 0.386212 -0.474685 0.790857 -vn -0.386212 -0.474685 0.790857 -vn 0.557756 -0.629109 0.541368 -vn -0.557756 -0.629109 0.541368 -vn -0.091159 -0.723716 0.684011 -vn -0.199744 -0.858058 0.473067 -vn 0.091159 -0.723716 0.684011 -vn 0.199744 -0.858058 0.473067 -vn -0.597949 -0.496475 0.629231 -vn 0.597949 -0.496475 0.629231 -vn -0.723197 -0.488907 0.487747 -vn 0.723197 -0.488907 0.487747 -usemtl Material_ray.png -s 1 -f 61/1/1 65/2/2 49/3/3 -f 50/4/4 66/5/5 62/6/6 -f 63/7/7 65/2/2 61/1/1 -f 62/6/6 66/5/5 64/8/8 -f 61/1/1 59/9/9 63/7/7 -f 64/8/8 60/10/10 62/6/6 -f 61/1/1 57/11/11 59/9/9 -f 60/10/10 58/12/12 62/6/6 -f 61/1/1 55/13/13 57/11/11 -f 58/12/12 56/14/14 62/6/6 -f 61/1/1 53/15/15 55/13/13 -f 56/14/14 54/16/16 62/6/6 -f 61/1/1 51/17/17 53/15/15 -f 54/16/16 52/18/18 62/6/6 -f 61/1/1 49/3/3 51/17/17 -f 52/18/18 50/4/4 62/6/6 -f 225/19/19 229/20/20 227/21/21 -f 228/22/22 230/23/23 226/24/24 -f 73/25/25 284/26/26 74/27/27 -f 74/28/27 285/29/28 73/30/25 -f 342/31/29 348/32/30 384/33/31 -f 385/34/32 349/35/33 343/36/34 -f 300/37/35 346/38/36 344/39/37 -f 345/40/38 347/41/39 301/42/40 -f 324/43/41 380/44/42 352/45/43 -f 353/46/44 381/47/45 325/48/46 -f 442/49/47 444/50/48 446/51/49 -f 447/52/50 445/53/51 443/54/52 -f 464/55/53 492/56/54 466/57/55 -f 467/58/56 493/59/57 465/60/58 -f 496/61/59 498/62/60 500/63/61 -f 501/64/62 499/65/63 497/66/64 -f 505/67/65 323/68/66 321/69/67 -f 505/67/65 321/69/67 391/70/68 -f 320/71/69 322/72/70 504/73/71 -f 320/71/69 504/73/71 390/74/72 -f 505/67/65 507/75/73 315/76/74 -f 505/67/65 315/76/74 323/68/66 -f 314/77/75 506/78/76 504/73/71 -f 314/77/75 504/73/71 322/72/70 -f 389/79/77 383/80/78 507/75/73 -f 383/80/78 315/76/74 507/75/73 -f 314/77/75 382/81/79 506/78/76 -f 382/81/79 388/82/80 506/78/76 -f 501/64/62 497/66/64 495/83/81 -f 501/64/62 495/83/81 503/84/82 -f 494/85/83 496/61/59 500/63/61 -f 494/85/83 500/63/61 502/86/84 -f 505/67/65 503/84/82 507/75/73 -f 503/84/82 495/83/81 507/75/73 -f 494/85/83 502/86/84 506/78/76 -f 502/86/84 504/73/71 506/78/76 -f 495/83/81 401/87/85 507/75/73 -f 401/87/85 389/79/77 507/75/73 -f 388/82/80 400/88/86 506/78/76 -f 400/88/86 494/85/83 506/78/76 -f 497/66/64 399/89/87 495/83/81 -f 399/89/87 401/87/85 495/83/81 -f 400/88/86 398/90/88 494/85/83 -f 398/90/88 496/61/59 494/85/83 -f 499/65/63 397/91/89 497/66/64 -f 397/91/89 399/89/87 497/66/64 -f 398/90/88 396/92/90 496/61/59 -f 396/92/90 498/62/60 496/61/59 -f 501/64/62 395/93/91 499/65/63 -f 395/93/91 397/91/89 499/65/63 -f 396/92/90 394/94/92 498/62/60 -f 394/94/92 500/63/61 498/62/60 -f 503/84/82 393/95/93 395/93/91 -f 503/84/82 395/93/91 501/64/62 -f 394/94/92 392/96/94 502/86/84 -f 394/94/92 502/86/84 500/63/61 -f 505/67/65 391/70/68 393/95/93 -f 505/67/65 393/95/93 503/84/82 -f 392/96/94 390/74/72 504/73/71 -f 392/96/94 504/73/71 502/86/84 -f 491/97/95 493/59/57 467/58/56 -f 491/97/95 467/58/56 469/98/96 -f 466/57/55 492/56/54 490/99/97 -f 466/57/55 490/99/97 468/100/98 -f 489/101/99 491/97/95 471/102/100 -f 491/97/95 469/98/96 471/102/100 -f 468/100/98 490/99/97 470/103/101 -f 490/99/97 488/104/102 470/103/101 -f 483/105/103 489/101/99 473/106/104 -f 489/101/99 471/102/100 473/106/104 -f 470/103/101 488/104/102 472/107/105 -f 488/104/102 482/108/106 472/107/105 -f 481/109/107 483/105/103 473/106/104 -f 481/109/107 473/106/104 475/110/108 -f 472/107/105 482/108/106 480/111/109 -f 472/107/105 480/111/109 474/112/110 -f 481/109/107 475/110/108 457/113/111 -f 475/110/108 455/114/112 457/113/111 -f 454/115/113 474/112/110 456/116/114 -f 474/112/110 480/111/109 456/116/114 -f 463/117/115 479/118/116 459/119/117 -f 463/117/115 459/119/117 461/120/118 -f 458/121/119 478/122/120 462/123/121 -f 458/121/119 462/123/121 460/124/122 -f 479/118/116 463/117/115 485/125/123 -f 463/117/115 453/126/124 485/125/123 -f 452/127/125 462/123/121 484/128/126 -f 462/123/121 478/122/120 484/128/126 -f 487/129/127 485/125/123 477/130/128 -f 485/125/123 453/126/124 477/130/128 -f 452/127/125 484/128/126 476/131/129 -f 484/128/126 486/132/130 476/131/129 -f 487/129/127 477/130/128 465/60/58 -f 487/129/127 465/60/58 493/59/57 -f 464/55/53 476/131/129 486/132/130 -f 464/55/53 486/132/130 492/56/54 -f 491/97/95 489/101/99 493/59/57 -f 489/101/99 487/129/127 493/59/57 -f 486/132/130 488/104/102 492/56/54 -f 488/104/102 490/99/97 492/56/54 -f 489/101/99 483/105/103 485/125/123 -f 489/101/99 485/125/123 487/129/127 -f 484/128/126 482/108/106 488/104/102 -f 484/128/126 488/104/102 486/132/130 -f 483/105/103 481/109/107 485/125/123 -f 481/109/107 479/118/116 485/125/123 -f 478/122/120 480/111/109 484/128/126 -f 480/111/109 482/108/106 484/128/126 -f 481/109/107 457/113/111 479/118/116 -f 457/113/111 459/119/117 479/118/116 -f 458/121/119 456/116/114 478/122/120 -f 456/116/114 480/111/109 478/122/120 -f 473/106/104 421/133/131 475/110/108 -f 421/133/131 419/134/132 475/110/108 -f 418/135/133 420/136/134 474/112/110 -f 420/136/134 472/107/105 474/112/110 -f 471/102/100 423/137/135 473/106/104 -f 423/137/135 421/133/131 473/106/104 -f 420/136/134 422/138/136 472/107/105 -f 422/138/136 470/103/101 472/107/105 -f 469/98/96 425/139/137 471/102/100 -f 425/139/137 423/137/135 471/102/100 -f 422/138/136 424/140/138 470/103/101 -f 424/140/138 468/100/98 470/103/101 -f 467/58/56 427/141/139 425/139/137 -f 467/58/56 425/139/137 469/98/96 -f 424/140/138 426/142/140 466/57/55 -f 424/140/138 466/57/55 468/100/98 -f 465/60/58 429/143/141 427/141/139 -f 465/60/58 427/141/139 467/58/56 -f 426/142/140 428/144/142 464/55/53 -f 426/142/140 464/55/53 466/57/55 -f 477/130/128 417/145/143 429/143/141 -f 477/130/128 429/143/141 465/60/58 -f 428/144/142 416/146/144 476/131/129 -f 428/144/142 476/131/129 464/55/53 -f 475/110/108 419/134/132 441/147/145 -f 475/110/108 441/147/145 455/114/112 -f 440/148/146 418/135/133 474/112/110 -f 440/148/146 474/112/110 454/115/113 -f 455/114/112 441/147/145 439/149/147 -f 455/114/112 439/149/147 457/113/111 -f 438/150/148 440/148/146 454/115/113 -f 438/150/148 454/115/113 456/116/114 -f 457/113/111 439/149/147 459/119/117 -f 439/149/147 437/151/149 459/119/117 -f 436/152/150 438/150/148 458/121/119 -f 438/150/148 456/116/114 458/121/119 -f 459/119/117 437/151/149 461/120/118 -f 437/151/149 435/153/151 461/120/118 -f 434/154/152 436/152/150 460/124/122 -f 436/152/150 458/121/119 460/124/122 -f 461/120/118 435/153/151 433/155/153 -f 461/120/118 433/155/153 463/117/115 -f 432/156/154 434/154/152 460/124/122 -f 432/156/154 460/124/122 462/123/121 -f 463/117/115 433/155/153 453/126/124 -f 433/155/153 451/157/155 453/126/124 -f 450/158/156 432/156/154 452/127/125 -f 432/156/154 462/123/121 452/127/125 -f 453/126/124 451/157/155 417/145/143 -f 453/126/124 417/145/143 477/130/128 -f 416/146/144 450/158/156 452/127/125 -f 416/146/144 452/127/125 476/131/129 -f 447/52/50 443/54/52 449/159/157 -f 443/54/52 313/160/158 449/159/157 -f 312/161/159 442/49/47 448/162/160 -f 442/49/47 446/51/49 448/162/160 -f 431/163/161 449/159/157 383/80/78 -f 449/159/157 313/160/158 383/80/78 -f 312/161/159 448/162/160 382/164/79 -f 448/162/160 430/165/162 382/164/79 -f 451/157/155 431/163/161 417/145/143 -f 431/163/161 415/166/163 417/145/143 -f 414/167/164 430/165/162 416/146/144 -f 430/165/162 450/158/156 416/146/144 -f 433/155/153 449/159/157 451/157/155 -f 449/159/157 431/163/161 451/157/155 -f 430/165/162 448/162/160 450/158/156 -f 448/162/160 432/156/154 450/158/156 -f 447/52/50 449/159/157 435/153/151 -f 449/159/157 433/155/153 435/153/151 -f 432/156/154 448/162/160 434/154/152 -f 448/162/160 446/51/49 434/154/152 -f 439/149/147 447/52/50 435/153/151 -f 439/149/147 435/153/151 437/151/149 -f 434/154/152 446/51/49 438/150/148 -f 434/154/152 438/150/148 436/152/150 -f 445/53/51 447/52/50 441/147/145 -f 447/52/50 439/149/147 441/147/145 -f 438/150/148 446/51/49 440/148/146 -f 446/51/49 444/50/48 440/148/146 -f 441/147/145 419/134/132 413/168/165 -f 441/147/145 413/168/165 445/53/51 -f 412/169/166 418/135/133 440/148/146 -f 412/169/166 440/148/146 444/50/48 -f 415/166/163 431/163/161 383/80/78 -f 415/166/163 383/80/78 389/79/77 -f 382/164/79 430/165/162 414/167/164 -f 382/164/79 414/167/164 388/170/80 -f 443/171/52 319/172/167 311/173/168 -f 443/171/52 311/173/168 313/174/158 -f 310/175/169 318/176/170 442/177/47 -f 310/175/169 442/177/47 312/178/159 -f 413/168/165 391/179/68 445/53/51 -f 391/179/68 321/180/67 445/53/51 -f 320/181/69 390/182/72 444/50/48 -f 390/182/72 412/169/166 444/50/48 -f 445/53/51 321/180/67 443/54/52 -f 321/183/67 319/172/167 443/171/52 -f 318/176/170 320/184/69 442/177/47 -f 320/181/69 444/50/48 442/49/47 -f 417/145/143 415/166/163 403/185/171 -f 417/145/143 403/185/171 429/143/141 -f 402/186/172 414/167/164 416/146/144 -f 402/186/172 416/146/144 428/144/142 -f 427/141/139 429/143/141 405/187/173 -f 429/143/141 403/185/171 405/187/173 -f 402/186/172 428/144/142 404/188/174 -f 428/144/142 426/142/140 404/188/174 -f 425/139/137 427/141/139 407/189/175 -f 427/141/139 405/187/173 407/189/175 -f 404/188/174 426/142/140 406/190/176 -f 426/142/140 424/140/138 406/190/176 -f 423/137/135 425/139/137 409/191/177 -f 425/139/137 407/189/175 409/191/177 -f 406/190/176 424/140/138 408/192/178 -f 424/140/138 422/138/136 408/192/178 -f 421/133/131 423/137/135 409/191/177 -f 421/133/131 409/191/177 411/193/179 -f 408/192/178 422/138/136 420/136/134 -f 408/192/178 420/136/134 410/194/180 -f 419/134/132 421/133/131 411/193/179 -f 419/134/132 411/193/179 413/168/165 -f 410/194/180 420/136/134 418/135/133 -f 410/194/180 418/135/133 412/169/166 -f 413/168/165 411/193/179 393/195/93 -f 413/168/165 393/195/93 391/179/68 -f 392/196/94 410/194/180 412/169/166 -f 392/196/94 412/169/166 390/182/72 -f 411/193/179 409/191/177 393/195/93 -f 409/191/177 395/197/91 393/195/93 -f 394/198/92 408/192/178 392/196/94 -f 408/192/178 410/194/180 392/196/94 -f 409/191/177 407/189/175 395/197/91 -f 407/189/175 397/199/89 395/197/91 -f 396/200/90 406/190/176 394/198/92 -f 406/190/176 408/192/178 394/198/92 -f 407/189/175 405/187/173 397/199/89 -f 405/187/173 399/89/87 397/199/89 -f 398/201/88 404/188/174 396/200/90 -f 404/188/174 406/190/176 396/200/90 -f 405/187/173 403/185/171 401/87/85 -f 405/187/173 401/87/85 399/89/87 -f 400/202/86 402/186/172 404/188/174 -f 400/202/86 404/188/174 398/201/88 -f 415/166/163 389/79/77 403/185/171 -f 389/79/77 401/87/85 403/185/171 -f 400/202/86 388/170/80 402/186/172 -f 388/170/80 414/167/164 402/186/172 -f 381/47/45 353/46/44 387/203/181 -f 353/46/44 351/204/182 387/203/181 -f 350/205/183 352/45/43 386/206/184 -f 352/45/43 380/44/42 386/206/184 -f 381/47/45 387/203/181 323/207/66 -f 387/203/181 321/183/67 323/207/66 -f 320/184/69 386/206/184 322/208/70 -f 386/206/184 380/44/42 322/208/70 -f 381/47/45 379/209/185 325/48/46 -f 379/209/185 317/210/186 325/48/46 -f 316/211/187 378/212/188 324/43/41 -f 378/212/188 380/44/42 324/43/41 -f 381/47/45 323/207/66 379/209/185 -f 323/207/66 315/213/74 379/209/185 -f 314/214/75 322/208/70 378/212/188 -f 322/208/70 380/44/42 378/212/188 -f 343/36/34 345/40/38 301/42/40 -f 343/36/34 301/42/40 385/34/32 -f 300/37/35 344/39/37 342/31/29 -f 300/37/35 342/31/29 384/33/31 -f 385/34/32 301/42/40 299/215/189 -f 385/34/32 299/215/189 319/172/167 -f 298/216/190 300/37/35 384/33/31 -f 298/216/190 384/33/31 318/176/170 -f 387/203/181 385/34/32 321/183/67 -f 385/34/32 319/172/167 321/183/67 -f 318/176/170 384/33/31 320/184/69 -f 384/33/31 386/206/184 320/184/69 -f 387/203/181 351/204/182 385/34/32 -f 351/204/182 349/35/33 385/34/32 -f 348/32/30 350/205/183 384/33/31 -f 350/205/183 386/206/184 384/33/31 -f 371/217/191 377/218/192 383/219/78 -f 377/218/192 315/213/74 383/219/78 -f 314/214/75 376/220/193 382/221/79 -f 376/220/193 370/222/194 382/221/79 -f 371/217/191 383/219/78 313/174/158 -f 371/217/191 313/174/158 369/223/195 -f 312/178/159 382/221/79 370/222/194 -f 312/178/159 370/222/194 368/224/196 -f 369/223/195 313/174/158 311/173/168 -f 369/223/195 311/173/168 363/225/197 -f 310/175/169 312/178/159 368/224/196 -f 310/175/169 368/224/196 362/226/198 -f 311/173/168 297/227/199 363/225/197 -f 297/227/199 295/228/200 363/225/197 -f 294/229/201 296/230/202 362/226/198 -f 296/230/202 310/175/169 362/226/198 -f 361/231/203 291/232/204 285/29/28 -f 361/231/203 285/29/28 74/28/27 -f 284/26/26 290/233/205 360/234/206 -f 284/26/26 360/234/206 74/27/27 -f 289/235/207 287/236/208 291/232/204 -f 287/236/208 285/29/28 291/232/204 -f 284/26/26 286/237/209 290/233/205 -f 286/237/209 288/238/210 290/233/205 -f 359/239/211 361/231/203 302/240/212 -f 361/231/203 74/28/27 302/240/212 -f 74/27/27 360/234/206 302/241/212 -f 360/234/206 358/242/213 302/241/212 -f 365/243/214 293/244/215 361/231/203 -f 293/244/215 291/232/204 361/231/203 -f 290/233/205 292/245/216 360/234/206 -f 292/245/216 364/246/217 360/234/206 -f 365/243/214 361/231/203 359/239/211 -f 365/243/214 359/239/211 367/247/218 -f 358/242/213 360/234/206 364/246/217 -f 358/242/213 364/246/217 366/248/219 -f 367/247/218 359/239/211 357/249/220 -f 367/247/218 357/249/220 373/250/221 -f 356/251/222 358/242/213 366/248/219 -f 356/251/222 366/248/219 372/252/223 -f 373/250/221 357/249/220 355/253/224 -f 373/250/221 355/253/224 375/254/225 -f 354/255/226 356/251/222 372/252/223 -f 354/255/226 372/252/223 374/256/227 -f 375/254/225 355/253/224 317/210/186 -f 375/254/225 317/210/186 379/209/185 -f 316/211/187 354/255/226 374/256/227 -f 316/211/187 374/256/227 378/212/188 -f 375/254/225 379/209/185 377/218/192 -f 379/209/185 315/213/74 377/218/192 -f 314/214/75 378/212/188 376/220/193 -f 378/212/188 374/256/227 376/220/193 -f 377/218/192 371/217/191 373/250/221 -f 377/218/192 373/250/221 375/254/225 -f 372/252/223 370/222/194 376/220/193 -f 372/252/223 376/220/193 374/256/227 -f 371/217/191 369/223/195 367/247/218 -f 371/217/191 367/247/218 373/250/221 -f 366/248/219 368/224/196 370/222/194 -f 366/248/219 370/222/194 372/252/223 -f 369/223/195 363/225/197 365/243/214 -f 369/223/195 365/243/214 367/247/218 -f 364/246/217 362/226/198 368/224/196 -f 364/246/217 368/224/196 366/248/219 -f 363/225/197 295/228/200 293/244/215 -f 363/225/197 293/244/215 365/243/214 -f 292/245/216 294/229/201 362/226/198 -f 292/245/216 362/226/198 364/246/217 -f 317/210/186 355/253/224 75/257/228 -f 317/210/186 75/257/228 76/258/229 -f 75/259/228 354/255/226 316/211/187 -f 75/259/228 316/211/187 76/260/229 -f 355/253/224 357/249/220 303/261/230 -f 355/253/224 303/261/230 75/257/228 -f 303/262/230 356/251/222 354/255/226 -f 303/262/230 354/255/226 75/259/228 -f 357/249/220 359/239/211 303/261/230 -f 359/239/211 302/240/212 303/261/230 -f 302/241/212 358/242/213 303/262/230 -f 358/242/213 356/251/222 303/262/230 -f 325/48/46 317/210/186 77/263/231 -f 317/210/186 76/258/229 77/263/231 -f 76/260/229 316/211/187 77/264/231 -f 316/211/187 324/43/41 77/264/231 -f 319/172/167 299/215/189 297/227/199 -f 319/172/167 297/227/199 311/173/168 -f 296/230/202 298/216/190 318/176/170 -f 296/230/202 318/176/170 310/175/169 -f 349/35/33 329/265/232 343/36/34 -f 329/265/232 327/266/233 343/36/34 -f 326/267/234 328/268/235 342/31/29 -f 328/268/235 348/32/30 342/31/29 -f 329/265/232 349/35/33 305/269/236 -f 329/265/232 305/269/236 309/270/237 -f 305/271/236 348/32/30 328/268/235 -f 305/271/236 328/268/235 309/272/237 -f 349/35/33 351/204/182 78/273/238 -f 349/35/33 78/273/238 305/269/236 -f 78/274/238 350/205/183 348/32/30 -f 78/274/238 348/32/30 305/271/236 -f 351/204/182 353/46/44 78/273/238 -f 353/46/44 304/275/239 78/273/238 -f 304/276/239 352/45/43 78/274/238 -f 352/45/43 350/205/183 78/274/238 -f 353/46/44 325/48/46 304/275/239 -f 325/48/46 77/263/231 304/275/239 -f 77/264/231 324/43/41 304/276/239 -f 324/43/41 352/45/43 304/276/239 -f 301/42/40 347/41/39 93/277/240 -f 347/278/39 80/279/241 93/280/240 -f 79/281/242 346/282/36 92/283/243 -f 346/38/36 300/37/35 92/284/243 -f 345/40/38 216/285/244 347/41/39 -f 216/286/244 80/279/241 347/278/39 -f 79/281/242 215/287/245 346/282/36 -f 215/288/245 344/39/37 346/38/36 -f 343/36/34 327/266/233 210/289/246 -f 327/266/233 82/290/247 210/289/246 -f 81/291/248 326/267/234 209/292/249 -f 326/267/234 342/31/29 209/292/249 -f 345/40/38 343/36/34 216/285/244 -f 343/36/34 210/289/246 216/285/244 -f 209/292/249 342/31/29 215/288/245 -f 342/31/29 344/39/37 215/288/245 -f 333/293/250 84/294/251 82/290/247 -f 333/293/250 82/290/247 327/266/233 -f 81/291/248 83/295/252 332/296/253 -f 81/291/248 332/296/253 326/267/234 -f 339/297/254 333/293/250 329/265/232 -f 333/293/250 327/266/233 329/265/232 -f 326/267/234 332/296/253 328/268/235 -f 332/296/253 338/298/255 328/268/235 -f 341/299/256 335/300/257 337/301/258 -f 335/300/257 331/302/259 337/301/258 -f 330/303/260 334/304/261 336/305/262 -f 334/304/261 340/306/263 336/305/262 -f 339/297/254 337/301/258 331/302/259 -f 339/297/254 331/302/259 333/293/250 -f 330/303/260 336/305/262 338/298/255 -f 330/303/260 338/298/255 332/296/253 -f 331/302/259 86/307/264 84/294/251 -f 331/302/259 84/294/251 333/293/250 -f 83/295/252 85/308/265 330/303/260 -f 83/295/252 330/303/260 332/296/253 -f 335/300/257 88/309/266 86/307/264 -f 335/300/257 86/307/264 331/302/259 -f 85/308/265 87/310/267 334/304/261 -f 85/308/265 334/304/261 330/303/260 -f 341/299/256 90/311/268 88/309/266 -f 341/299/256 88/309/266 335/300/257 -f 87/310/267 89/312/269 340/306/263 -f 87/310/267 340/306/263 334/304/261 -f 306/313/270 91/314/271 90/311/268 -f 306/313/270 90/311/268 341/299/256 -f 89/312/269 91/315/271 306/316/270 -f 89/312/269 306/316/270 340/306/263 -f 337/301/258 307/317/272 341/299/256 -f 307/317/272 306/313/270 341/299/256 -f 306/316/270 307/318/272 340/306/263 -f 307/318/272 336/305/262 340/306/263 -f 339/297/254 308/319/273 337/301/258 -f 308/319/273 307/317/272 337/301/258 -f 307/318/272 308/320/273 336/305/262 -f 308/320/273 338/298/255 336/305/262 -f 329/265/232 309/270/237 339/297/254 -f 309/270/237 308/319/273 339/297/254 -f 308/320/273 309/272/237 338/298/255 -f 309/272/237 328/268/235 338/298/255 -f 301/42/40 93/277/240 95/321/274 -f 301/42/40 95/321/274 299/215/189 -f 94/322/275 92/284/243 300/37/35 -f 94/322/275 300/37/35 298/216/190 -f 299/215/189 95/321/274 97/323/276 -f 299/215/189 97/323/276 297/227/199 -f 96/324/277 94/322/275 298/216/190 -f 96/324/277 298/216/190 296/230/202 -f 297/227/199 97/323/276 295/228/200 -f 97/323/276 99/325/278 295/228/200 -f 98/326/279 96/324/277 294/229/201 -f 96/324/277 296/230/202 294/229/201 -f 295/228/200 99/325/278 101/327/280 -f 295/228/200 101/327/280 293/244/215 -f 100/328/281 98/326/279 294/229/201 -f 100/328/281 294/229/201 292/245/216 -f 293/244/215 101/327/280 291/232/204 -f 101/327/280 103/329/282 291/232/204 -f 102/330/283 100/328/281 290/233/205 -f 100/328/281 292/245/216 290/233/205 -f 291/232/204 103/329/282 289/235/207 -f 103/329/282 105/331/284 289/235/207 -f 104/332/285 102/330/283 288/238/210 -f 102/330/283 290/233/205 288/238/210 -f 289/235/207 105/331/284 287/236/208 -f 105/331/284 107/333/286 287/236/208 -f 106/334/287 104/332/285 286/237/209 -f 104/332/285 288/238/210 286/237/209 -f 287/236/208 107/333/286 109/335/288 -f 287/236/208 109/335/288 285/29/28 -f 108/336/289 106/334/287 286/237/209 -f 108/336/289 286/237/209 284/26/26 -f 285/29/28 109/335/288 67/337/290 -f 285/29/28 67/337/290 73/30/25 -f 67/338/290 108/336/289 284/26/26 -f 67/338/290 284/26/26 73/25/25 -f 281/339/291 235/340/292 233/341/293 -f 281/339/291 233/341/293 283/342/294 -f 232/343/295 234/344/296 280/345/297 -f 232/343/295 280/345/297 282/346/298 -f 283/342/294 233/341/293 255/347/299 -f 283/342/294 255/347/299 261/348/300 -f 254/349/301 232/343/295 282/346/298 -f 254/349/301 282/346/298 260/350/302 -f 261/348/300 255/347/299 257/351/303 -f 261/348/300 257/351/303 259/352/304 -f 256/353/305 254/349/301 260/350/302 -f 256/353/305 260/350/302 258/354/306 -f 263/355/307 253/356/308 235/340/292 -f 263/355/307 235/340/292 281/339/291 -f 234/344/296 252/357/309 262/358/310 -f 234/344/296 262/358/310 280/345/297 -f 265/359/311 251/360/312 263/355/307 -f 251/360/312 253/356/308 263/355/307 -f 252/357/309 250/361/313 262/358/310 -f 250/361/313 264/362/314 262/358/310 -f 267/363/315 249/364/316 265/359/311 -f 249/364/316 251/360/312 265/359/311 -f 250/361/313 248/365/317 264/362/314 -f 248/365/317 266/366/318 264/362/314 -f 269/367/319 247/368/320 249/364/316 -f 269/367/319 249/364/316 267/363/315 -f 248/365/317 246/369/321 268/370/322 -f 248/365/317 268/370/322 266/366/318 -f 271/371/323 245/372/324 269/367/319 -f 245/372/324 247/368/320 269/367/319 -f 246/369/321 244/373/325 268/370/322 -f 244/373/325 270/374/326 268/370/322 -f 273/375/327 243/376/328 245/372/324 -f 273/375/327 245/372/324 271/371/323 -f 244/373/325 242/377/329 272/378/330 -f 244/373/325 272/378/330 270/374/326 -f 275/379/331 241/380/332 273/375/327 -f 241/380/332 243/376/328 273/375/327 -f 242/377/329 240/381/333 272/378/330 -f 240/381/333 274/382/334 272/378/330 -f 279/383/335 237/384/336 275/379/331 -f 237/384/336 241/380/332 275/379/331 -f 240/381/333 236/385/337 274/382/334 -f 236/385/337 278/386/338 274/382/334 -f 277/387/339 239/388/340 237/384/336 -f 277/387/339 237/384/336 279/383/335 -f 236/385/337 238/389/341 276/390/342 -f 236/385/337 276/390/342 278/386/338 -f 259/352/304 257/351/303 239/388/340 -f 259/352/304 239/388/340 277/387/339 -f 238/389/341 256/353/305 258/354/306 -f 238/389/341 258/354/306 276/390/342 -f 257/351/303 111/391/343 129/392/344 -f 257/351/303 129/392/344 239/388/340 -f 128/393/345 110/394/346 256/353/305 -f 128/393/345 256/353/305 238/389/341 -f 239/388/340 129/392/344 180/395/347 -f 239/388/340 180/395/347 237/384/336 -f 179/396/348 128/393/345 238/389/341 -f 179/396/348 238/389/341 236/385/337 -f 237/384/336 180/395/347 127/397/349 -f 237/384/336 127/397/349 241/380/332 -f 126/398/350 179/396/348 236/385/337 -f 126/398/350 236/385/337 240/381/333 -f 241/380/332 127/397/349 243/376/328 -f 127/397/349 125/399/351 243/376/328 -f 124/400/352 126/398/350 242/377/329 -f 126/398/350 240/381/333 242/377/329 -f 243/376/328 125/399/351 245/372/324 -f 125/399/351 123/401/353 245/372/324 -f 122/402/354 124/400/352 244/373/325 -f 124/400/352 242/377/329 244/373/325 -f 245/372/324 123/401/353 121/403/355 -f 245/372/324 121/403/355 247/368/320 -f 120/404/356 122/402/354 244/373/325 -f 120/404/356 244/373/325 246/369/321 -f 247/368/320 121/403/355 119/405/357 -f 247/368/320 119/405/357 249/364/316 -f 118/406/358 120/404/356 246/369/321 -f 118/406/358 246/369/321 248/365/317 -f 249/364/316 119/405/357 117/407/359 -f 249/364/316 117/407/359 251/360/312 -f 116/408/360 118/406/358 248/365/317 -f 116/408/360 248/365/317 250/361/313 -f 251/360/312 117/407/359 115/409/361 -f 251/360/312 115/409/361 253/356/308 -f 114/410/362 116/408/360 250/361/313 -f 114/410/362 250/361/313 252/357/309 -f 253/356/308 115/409/361 235/340/292 -f 115/409/361 182/411/363 235/340/292 -f 181/412/364 114/410/362 234/344/296 -f 114/410/362 252/357/309 234/344/296 -f 255/347/299 113/413/365 257/351/303 -f 113/413/365 111/391/343 257/351/303 -f 110/394/346 112/414/366 256/353/305 -f 112/414/366 254/349/301 256/353/305 -f 233/341/293 184/415/367 113/413/365 -f 233/341/293 113/413/365 255/347/299 -f 112/414/366 183/416/368 232/343/295 -f 112/414/366 232/343/295 254/349/301 -f 235/340/292 182/411/363 184/415/367 -f 235/340/292 184/415/367 233/341/293 -f 183/416/368 181/412/364 234/344/296 -f 183/416/368 234/344/296 232/343/295 -f 230/23/23 231/417/369 224/418/370 -f 230/23/23 224/418/370 226/24/24 -f 224/418/370 231/417/369 229/20/20 -f 224/418/370 229/20/20 225/19/19 -f 224/418/370 72/419/371 226/24/24 -f 72/419/371 223/420/372 226/24/24 -f 222/421/373 72/419/371 225/19/19 -f 72/419/371 224/418/370 225/19/19 -f 226/24/24 223/420/372 221/422/374 -f 226/24/24 221/422/374 228/22/22 -f 220/423/375 222/421/373 225/19/19 -f 220/423/375 225/19/19 227/21/21 -f 228/22/22 221/422/374 219/424/376 -f 228/22/22 219/424/376 230/23/23 -f 218/425/377 220/423/375 227/21/21 -f 218/425/377 227/21/21 229/20/20 -f 230/23/23 219/424/376 231/417/369 -f 219/424/376 217/426/378 231/417/369 -f 217/426/378 218/425/377 231/417/369 -f 218/425/377 229/20/20 231/417/369 -f 219/424/376 136/427/379 137/428/380 -f 219/424/376 137/428/380 217/426/378 -f 137/428/380 135/429/381 218/425/377 -f 137/428/380 218/425/377 217/426/378 -f 221/422/374 134/430/382 136/427/379 -f 221/422/374 136/427/379 219/424/376 -f 135/429/381 133/431/383 220/423/375 -f 135/429/381 220/423/375 218/425/377 -f 223/420/372 132/432/384 134/430/382 -f 223/420/372 134/430/382 221/422/374 -f 133/431/383 131/433/385 222/421/373 -f 133/431/383 222/421/373 220/423/375 -f 72/419/371 130/434/386 223/420/372 -f 130/434/386 132/432/384 223/420/372 -f 131/433/385 130/434/386 222/421/373 -f 130/434/386 72/419/371 222/421/373 -f 212/435/387 165/436/388 80/279/241 -f 212/435/387 80/279/241 216/286/244 -f 79/281/242 164/437/389 211/438/390 -f 79/281/242 211/438/390 215/287/245 -f 212/435/387 216/286/244 214/439/391 -f 216/286/244 210/440/246 214/439/391 -f 209/441/249 215/287/245 213/442/392 -f 215/287/245 211/438/390 213/442/392 -f 214/439/391 210/440/246 167/443/393 -f 210/440/246 82/444/247 167/443/393 -f 81/445/248 209/441/249 166/446/394 -f 209/441/249 213/442/392 166/446/394 -f 167/443/393 188/447/395 214/439/391 -f 188/447/395 145/448/396 214/439/391 -f 144/449/397 187/450/398 213/442/392 -f 187/450/398 166/446/394 213/442/392 -f 214/439/391 145/448/396 212/435/387 -f 145/448/396 143/451/399 212/435/387 -f 142/452/400 144/449/397 211/438/390 -f 144/449/397 213/442/392 211/438/390 -f 212/435/387 143/451/399 141/453/401 -f 212/435/387 141/453/401 165/436/388 -f 140/454/402 142/452/400 211/438/390 -f 140/454/402 211/438/390 164/437/389 -f 165/436/388 141/453/401 139/455/403 -f 165/436/388 139/455/403 177/456/404 -f 139/455/403 140/454/402 164/437/389 -f 139/455/403 164/437/389 177/456/404 -f 207/457/405 208/458/406 199/459/407 -f 207/457/405 199/459/407 205/460/408 -f 199/459/407 208/458/406 206/461/409 -f 199/459/407 206/461/409 204/462/410 -f 203/463/411 205/460/408 201/464/412 -f 205/460/408 199/459/407 201/464/412 -f 199/459/407 204/462/410 200/465/413 -f 204/462/410 202/466/414 200/465/413 -f 207/457/405 205/460/408 194/467/415 -f 207/457/405 194/467/415 192/468/416 -f 193/469/417 204/462/410 206/461/409 -f 193/469/417 206/461/409 191/470/418 -f 205/460/408 203/463/411 194/467/415 -f 203/463/411 196/471/419 194/467/415 -f 195/472/420 202/466/414 193/469/417 -f 202/466/414 204/462/410 193/469/417 -f 203/463/411 201/464/412 198/473/421 -f 203/463/411 198/473/421 196/471/419 -f 197/474/422 200/465/413 202/466/414 -f 197/474/422 202/466/414 195/472/420 -f 201/464/412 199/459/407 71/475/423 -f 201/464/412 71/475/423 198/473/421 -f 71/475/423 199/459/407 200/465/413 -f 71/475/423 200/465/413 197/474/422 -f 207/457/405 192/468/416 208/458/406 -f 192/468/416 70/476/424 208/458/406 -f 70/476/424 191/470/418 208/458/406 -f 191/470/418 206/461/409 208/458/406 -f 192/468/416 145/448/396 70/476/424 -f 145/448/396 190/477/425 70/476/424 -f 190/477/425 144/449/397 70/476/424 -f 144/449/397 191/470/418 70/476/424 -f 198/473/421 71/475/423 139/455/403 -f 71/478/423 138/479/426 139/480/403 -f 138/481/426 71/482/423 139/483/403 -f 71/475/423 197/474/422 139/455/403 -f 196/471/419 198/473/421 141/453/401 -f 198/473/421 139/455/403 141/453/401 -f 139/455/403 197/474/422 140/454/402 -f 197/474/422 195/472/420 140/454/402 -f 194/467/415 196/471/419 143/451/399 -f 196/471/419 141/453/401 143/451/399 -f 140/454/402 195/472/420 142/452/400 -f 195/472/420 193/469/417 142/452/400 -f 192/468/416 194/467/415 143/451/399 -f 192/468/416 143/451/399 145/448/396 -f 142/452/400 193/469/417 191/470/418 -f 142/452/400 191/470/418 144/449/397 -f 186/484/427 132/432/384 69/485/428 -f 132/432/384 130/434/386 69/485/428 -f 130/434/386 131/433/385 69/485/428 -f 131/433/385 185/486/429 69/485/428 -f 189/487/430 188/447/395 69/485/428 -f 188/447/395 186/484/427 69/485/428 -f 185/486/429 187/450/398 69/485/428 -f 187/450/398 189/487/430 69/485/428 -f 189/487/430 190/477/425 188/447/395 -f 190/477/425 145/448/396 188/447/395 -f 144/449/397 190/477/425 187/450/398 -f 190/477/425 189/487/430 187/450/398 -f 169/488/431 171/489/432 132/432/384 -f 169/488/431 132/432/384 186/484/427 -f 131/433/385 170/490/433 168/491/434 -f 131/433/385 168/491/434 185/486/429 -f 186/484/427 188/447/395 167/443/393 -f 186/484/427 167/443/393 169/488/431 -f 166/446/394 187/450/398 185/486/429 -f 166/446/394 185/486/429 168/491/434 -f 173/492/435 134/430/382 171/489/432 -f 134/430/382 132/432/384 171/489/432 -f 131/433/385 133/431/383 170/490/433 -f 133/431/383 172/493/436 170/490/433 -f 175/494/437 136/427/379 134/430/382 -f 175/494/437 134/430/382 173/492/435 -f 133/431/383 135/429/381 174/495/438 -f 133/431/383 174/495/438 172/493/436 -f 176/496/439 137/428/380 136/427/379 -f 176/496/439 136/427/379 175/494/437 -f 135/429/381 137/428/380 176/496/439 -f 135/429/381 176/496/439 174/495/438 -f 184/415/367 182/411/363 178/497/440 -f 182/411/363 177/456/404 178/497/440 -f 177/456/404 181/412/364 178/497/440 -f 181/412/364 183/416/368 178/497/440 -f 178/497/440 68/498/441 113/413/365 -f 178/497/440 113/413/365 184/415/367 -f 112/414/366 68/498/441 178/497/440 -f 112/414/366 178/497/440 183/416/368 -f 68/498/441 163/499/442 113/413/365 -f 163/499/442 111/391/343 113/413/365 -f 110/394/346 162/500/443 112/414/366 -f 162/500/443 68/498/441 112/414/366 -f 177/456/404 182/411/363 115/409/361 -f 177/456/404 115/409/361 165/436/388 -f 114/410/362 181/412/364 177/456/404 -f 114/410/362 177/456/404 164/437/389 -f 147/501/444 165/436/388 115/409/361 -f 147/501/444 115/409/361 117/407/359 -f 114/410/362 164/437/389 146/502/445 -f 114/410/362 146/502/445 116/408/360 -f 149/503/446 147/501/444 119/405/357 -f 147/501/444 117/407/359 119/405/357 -f 116/408/360 146/502/445 118/406/358 -f 146/502/445 148/504/447 118/406/358 -f 151/505/448 149/503/446 121/403/355 -f 149/503/446 119/405/357 121/403/355 -f 118/406/358 148/504/447 120/404/356 -f 148/504/447 150/506/449 120/404/356 -f 153/507/450 151/505/448 123/401/353 -f 151/505/448 121/403/355 123/401/353 -f 120/404/356 150/506/449 122/402/354 -f 150/506/449 152/508/451 122/402/354 -f 155/509/452 153/507/450 125/399/351 -f 153/507/450 123/401/353 125/399/351 -f 122/402/354 152/508/451 124/400/352 -f 152/508/451 154/510/453 124/400/352 -f 157/511/454 155/509/452 127/397/349 -f 155/509/452 125/399/351 127/397/349 -f 124/400/352 154/510/453 126/398/350 -f 154/510/453 156/512/455 126/398/350 -f 159/513/456 157/511/454 180/395/347 -f 157/511/454 127/397/349 180/395/347 -f 126/398/350 156/512/455 179/396/348 -f 156/512/455 158/514/457 179/396/348 -f 159/513/456 180/395/347 129/392/344 -f 159/513/456 129/392/344 161/515/458 -f 128/393/345 179/396/348 158/514/457 -f 128/393/345 158/514/457 160/516/459 -f 161/515/458 129/392/344 163/499/442 -f 129/392/344 111/391/343 163/499/442 -f 110/394/346 128/393/345 162/500/443 -f 128/393/345 160/516/459 162/500/443 -f 68/498/441 67/517/290 163/499/442 -f 67/517/290 109/518/288 163/499/442 -f 108/519/289 67/517/290 162/500/443 -f 67/517/290 68/498/441 162/500/443 -f 163/499/442 109/518/288 161/515/458 -f 109/518/288 107/520/286 161/515/458 -f 106/521/287 108/519/289 160/516/459 -f 108/519/289 162/500/443 160/516/459 -f 161/515/458 107/520/286 159/513/456 -f 107/520/286 105/522/284 159/513/456 -f 104/523/285 106/521/287 158/514/457 -f 106/521/287 160/516/459 158/514/457 -f 159/513/456 105/522/284 103/524/282 -f 159/513/456 103/524/282 157/511/454 -f 102/525/283 104/523/285 158/514/457 -f 102/525/283 158/514/457 156/512/455 -f 157/511/454 103/524/282 155/509/452 -f 103/524/282 101/526/280 155/509/452 -f 100/527/281 102/525/283 154/510/453 -f 102/525/283 156/512/455 154/510/453 -f 155/509/452 101/526/280 153/507/450 -f 101/526/280 99/528/278 153/507/450 -f 98/529/279 100/527/281 152/508/451 -f 100/527/281 154/510/453 152/508/451 -f 153/507/450 99/528/278 151/505/448 -f 99/528/278 97/530/276 151/505/448 -f 96/531/277 98/529/279 150/506/449 -f 98/529/279 152/508/451 150/506/449 -f 151/505/448 97/530/276 95/532/274 -f 151/505/448 95/532/274 149/503/446 -f 94/533/275 96/531/277 150/506/449 -f 94/533/275 150/506/449 148/504/447 -f 149/503/446 95/532/274 147/501/444 -f 95/532/274 93/280/240 147/501/444 -f 92/283/243 94/533/275 146/502/445 -f 94/533/275 148/504/447 146/502/445 -f 147/501/444 93/280/240 80/279/241 -f 147/501/444 80/279/241 165/436/388 -f 79/281/242 92/283/243 146/502/445 -f 79/281/242 146/502/445 164/437/389 -f 169/488/431 167/443/393 82/444/247 -f 169/488/431 82/444/247 84/534/251 -f 81/445/248 166/446/394 168/491/434 -f 81/445/248 168/491/434 83/535/252 -f 171/489/432 169/488/431 84/534/251 -f 171/489/432 84/534/251 86/536/264 -f 83/535/252 168/491/434 170/490/433 -f 83/535/252 170/490/433 85/537/265 -f 173/492/435 171/489/432 86/536/264 -f 173/492/435 86/536/264 88/538/266 -f 85/537/265 170/490/433 172/493/436 -f 85/537/265 172/493/436 87/539/267 -f 175/494/437 173/492/435 90/540/268 -f 173/492/435 88/538/266 90/540/268 -f 87/539/267 172/493/436 89/541/269 -f 172/493/436 174/495/438 89/541/269 -f 176/496/439 175/494/437 91/542/271 -f 175/494/437 90/540/268 91/542/271 -f 89/541/269 174/495/438 91/542/271 -f 174/495/438 176/496/439 91/542/271 -f 50/4/4 48/543/460 2/544/461 -f 50/4/4 2/544/461 66/5/5 -f 1/545/462 47/546/463 49/3/3 -f 1/545/462 49/3/3 65/2/2 -f 66/5/5 2/544/461 12/547/464 -f 66/5/5 12/547/464 64/8/8 -f 11/548/465 1/545/462 65/2/2 -f 11/548/465 65/2/2 63/7/7 -f 64/8/8 12/547/464 14/549/466 -f 64/8/8 14/549/466 60/10/10 -f 13/550/467 11/548/465 63/7/7 -f 13/550/467 63/7/7 59/9/9 -f 60/10/10 14/549/466 24/551/468 -f 60/10/10 24/551/468 58/12/12 -f 23/552/469 13/550/467 59/9/9 -f 23/552/469 59/9/9 57/11/11 -f 58/12/12 24/551/468 56/14/14 -f 24/551/468 26/553/470 56/14/14 -f 25/554/471 23/552/469 55/13/13 -f 23/552/469 57/11/11 55/13/13 -f 56/14/14 26/553/470 54/16/16 -f 26/553/470 36/555/472 54/16/16 -f 35/556/473 25/554/471 53/15/15 -f 25/554/471 55/13/13 53/15/15 -f 54/16/16 36/555/472 52/18/18 -f 36/555/472 38/557/474 52/18/18 -f 37/558/475 35/556/473 51/17/17 -f 35/556/473 53/15/15 51/17/17 -f 52/18/18 38/557/474 50/4/4 -f 38/557/474 48/543/460 50/4/4 -f 47/546/463 37/558/475 49/3/3 -f 37/558/475 51/17/17 49/3/3 -f 46/559/476 48/543/460 40/560/477 -f 48/543/460 38/557/474 40/560/477 -f 37/558/475 47/546/463 39/561/478 -f 47/546/463 45/562/479 39/561/478 -f 44/563/480 46/559/476 42/564/481 -f 46/559/476 40/560/477 42/564/481 -f 39/561/478 45/562/479 41/565/482 -f 45/562/479 43/566/483 41/565/482 -f 42/564/481 40/560/477 32/567/484 -f 40/560/477 34/568/485 32/567/484 -f 33/569/486 39/561/478 31/570/487 -f 39/561/478 41/565/482 31/570/487 -f 40/560/477 38/557/474 34/568/485 -f 38/557/474 36/555/472 34/568/485 -f 35/556/473 37/558/475 33/569/486 -f 37/558/475 39/561/478 33/569/486 -f 34/568/485 36/555/472 28/571/488 -f 36/555/472 26/553/470 28/571/488 -f 25/554/471 35/556/473 27/572/489 -f 35/556/473 33/569/486 27/572/489 -f 32/567/484 34/568/485 30/573/490 -f 34/568/485 28/571/488 30/573/490 -f 27/572/489 33/569/486 29/574/491 -f 33/569/486 31/570/487 29/574/491 -f 30/573/490 28/571/488 20/575/492 -f 28/571/488 22/576/493 20/575/492 -f 21/577/494 27/572/489 19/578/495 -f 27/572/489 29/574/491 19/578/495 -f 28/571/488 26/553/470 24/551/468 -f 28/571/488 24/551/468 22/576/493 -f 23/552/469 25/554/471 27/572/489 -f 23/552/469 27/572/489 21/577/494 -f 22/576/493 24/551/468 16/579/496 -f 24/551/468 14/549/466 16/579/496 -f 13/550/467 23/552/469 15/580/497 -f 23/552/469 21/577/494 15/580/497 -f 20/575/492 22/576/493 18/581/498 -f 22/576/493 16/579/496 18/581/498 -f 15/580/497 21/577/494 17/582/499 -f 21/577/494 19/578/495 17/582/499 -f 18/581/498 16/579/496 10/583/500 -f 18/581/498 10/583/500 8/584/501 -f 9/585/502 15/580/497 17/582/499 -f 9/585/502 17/582/499 7/586/503 -f 16/579/496 14/549/466 12/547/464 -f 16/579/496 12/547/464 10/583/500 -f 11/548/465 13/550/467 15/580/497 -f 11/548/465 15/580/497 9/585/502 -f 10/583/500 12/547/464 2/544/461 -f 10/583/500 2/544/461 4/587/504 -f 1/545/462 11/548/465 9/585/502 -f 1/545/462 9/585/502 3/588/505 -f 8/584/501 10/583/500 4/587/504 -f 8/584/501 4/587/504 6/589/506 -f 3/588/505 9/585/502 7/586/503 -f 3/588/505 7/586/503 5/590/507 -f 6/589/506 4/587/504 46/559/476 -f 6/589/506 46/559/476 44/563/480 -f 45/562/479 3/588/505 5/590/507 -f 45/562/479 5/590/507 43/566/483 -f 4/587/504 2/544/461 48/543/460 -f 4/587/504 48/543/460 46/559/476 -f 47/546/463 1/545/462 3/588/505 -f 47/546/463 3/588/505 45/562/479 diff --git a/examples/ogl_tutorials/08_basic_shading/src/textures/uvmap.DDS b/examples/ogl_tutorials/08_basic_shading/src/textures/uvmap.DDS deleted file mode 100755 index 70cb2db1..00000000 Binary files a/examples/ogl_tutorials/08_basic_shading/src/textures/uvmap.DDS and /dev/null differ diff --git a/examples/ogl_tutorials/08_basic_shading/tutorial_08.gpr b/examples/ogl_tutorials/08_basic_shading/tutorial_08.gpr deleted file mode 100644 index 17da1db5..00000000 --- a/examples/ogl_tutorials/08_basic_shading/tutorial_08.gpr +++ /dev/null @@ -1,14 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tutorial_08 is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("shading.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tutorial_08; diff --git a/examples/ogl_tutorials/09_vbo_indexing/.gitignore b/examples/ogl_tutorials/09_vbo_indexing/.gitignore deleted file mode 100644 index 59841962..00000000 --- a/examples/ogl_tutorials/09_vbo_indexing/.gitignore +++ /dev/null @@ -1 +0,0 @@ -indexing diff --git a/examples/ogl_tutorials/09_vbo_indexing/src/indexing.adb b/examples/ogl_tutorials/09_vbo_indexing/src/indexing.adb deleted file mode 100644 index c6869e6e..00000000 --- a/examples/ogl_tutorials/09_vbo_indexing/src/indexing.adb +++ /dev/null @@ -1,27 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Indexing is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Tutorial 9 - VBO Indexing"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Indexing returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Indexing."); - Put_Line (Exception_Information (anError)); -end Indexing; diff --git a/examples/ogl_tutorials/09_vbo_indexing/src/main_loop.adb b/examples/ogl_tutorials/09_vbo_indexing/src/main_loop.adb deleted file mode 100644 index 91005d5f..00000000 --- a/examples/ogl_tutorials/09_vbo_indexing/src/main_loop.adb +++ /dev/null @@ -1,269 +0,0 @@ - -with Interfaces.C; - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input.Keys; -with Glfw.Input.Mouse; -with Glfw.Windows; -with Glfw.Windows.Context; - -with Controls; -with Program_Loader; -with Load_DDS; -with Load_Object_File; -with Utilities; -with VBO_Indexer; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 0.0); - White : constant GL.Types.Colors.Color := (1.0, 1.0, 1.0, 1.0); - - Vertices_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Element_Buffer : GL.Objects.Buffers.Buffer; - - Normals_Buffer : GL.Objects.Buffers.Buffer; - UVs_Buffer : GL.Objects.Buffers.Buffer; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - MVP_Matrix_ID : GL.Uniforms.Uniform; - Model_Matrix_ID : GL.Uniforms.Uniform; - View_Matrix_ID : GL.Uniforms.Uniform; - Light_Position_ID : GL.Uniforms.Uniform; - Texture_ID : GL.Uniforms.Uniform; - - Last_Time : Glfw.Seconds; - Number_Of_Frames : Integer := 0; - - -- ------------------------------------------------------------------------ - - Procedure Load_Buffers (Indices_Size : out GL.Types.Int) is - use GL.Objects.Buffers; - use GL.Types; - Vertex_Count : Int; - Vertices_Size : Int; - begin - Vertex_Count := Load_Object_File.Mesh_Size ("src/textures/suzanne.obj"); - declare - Vertices : Singles.Vector3_Array (1 .. Vertex_Count); - UVs : Singles.Vector2_Array (1 .. Vertex_Count); - Normals : Singles.Vector3_Array (1 .. Vertex_Count); - Indexed_Vertices : Singles.Vector3_Array (1 .. Vertex_Count); - Indexed_UVs : Singles.Vector2_Array (1 .. Vertex_Count); - Indexed_Normals : Singles.Vector3_Array (1 .. Vertex_Count); - Temp_Indices : UInt_Array (1 .. Vertex_Count); - - begin - Load_Object_File.Load_Object ("src/textures/suzanne.obj", Vertices, UVs, Normals); - VBO_Indexer.Index_VBO (Vertices, UVs, Normals, - Indexed_Vertices, Indexed_UVs, Indexed_Normals, - Temp_Indices, Indices_Size, Vertices_Size); - declare - Vertices_Indexed : constant Singles.Vector3_Array (1 .. Vertices_Size) - := Indexed_Vertices (1 .. Vertices_Size); - UVs_Indexed : constant Singles.Vector2_Array (1 .. Vertices_Size) - := Indexed_UVs (1 .. Vertices_Size); - Normals_Indexed : constant Singles.Vector3_Array (1 .. Vertices_Size) - := Indexed_Normals (1 .. Vertices_Size); - Indices : constant GL.Types.UInt_Array (1 .. Indices_Size) - := Temp_Indices (1 .. Indices_Size); - begin - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertices_Indexed, Static_Draw); - - UVs_Buffer.Initialize_Id; - Array_Buffer.Bind (UVs_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, UVs_Indexed, Static_Draw); - - Normals_Buffer.Initialize_Id; - Array_Buffer.Bind (Normals_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Normals_Indexed, Static_Draw); - - Element_Buffer.Initialize_Id; - Element_Array_Buffer.Bind (Element_Buffer); - Utilities.Load_Element_Buffer (Element_Array_Buffer, Indices, Static_Draw); - end; - end; - - exception - when others => - Put_Line ("An exception occurred in Load_Buffers."); - raise; - end Load_Buffers; - - -- ------------------------------------------------------------------------ - - procedure Load_Matrices (Window : in out Glfw.Windows.Window) is - use GL.Types; - use GL.Types.Singles; - Model_Matrix : constant Matrix4 := Identity4; - View_Matrix : Matrix4; - Projection_Matrix : Matrix4; - MVP_Matrix : Matrix4; - begin - Controls.Compute_Matrices_From_Inputs (Window, Projection_Matrix, View_Matrix); - Utilities.Clear_Background_Colour_And_Depth (White); - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - - GL.Uniforms.Set_Single (Model_Matrix_ID, Model_Matrix); - GL.Uniforms.Set_Single (View_Matrix_ID, View_Matrix); - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - GL.Uniforms.Set_Single (Light_Position_ID, 4.0, 4.0, 4.0); - - exception - when others => - Put_Line ("An exception occurred in Load_Matrices."); - raise; - end Load_Matrices; - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program; - Indices_Size : GL.Types.Int; - UV_Map : GL.Objects.Textures.Texture) is - use Interfaces.C; - use GL.Objects.Buffers; - use GL.Types; - Current_Time : constant Glfw.Seconds := Glfw.Time; - begin - Number_Of_Frames := Number_Of_Frames + 1; - if Current_Time - Last_Time >= 1.0 then - Put_Line (Integer'Image (1000 * Number_Of_Frames) & " ms/frame"); - Number_Of_Frames := 0; - Last_Time := Last_Time + 1.0; - end if; - - Utilities.Clear_Colour_Buffer_And_Depth; - GL.Objects.Programs.Use_Program (Render_Program); - Load_Matrices (Window); - - -- First attribute buffer : vertices - GL.Attributes.Enable_Vertex_Attrib_Array (0); - GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - -- Second attribute buffer : UVs - GL.Attributes.Enable_Vertex_Attrib_Array (1); - GL.Objects.Buffers.Array_Buffer.Bind (UVs_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (1, 2, Single_Type, False, 0, 0); - -- Third attribute buffer : normals - GL.Attributes.Enable_Vertex_Attrib_Array (2); - GL.Objects.Buffers.Array_Buffer.Bind (Normals_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (2, 3, Single_Type, False, 0, 0); - - -- Index Buffer - GL.Objects.Buffers.Element_Array_Buffer.Bind (Element_Buffer); - - -- Bind the texture in Texture Unit 0 - GL.Objects.Textures.Set_Active_Unit (0); - GL.Objects.Textures.Targets.Texture_2D.Bind (UV_Map); - GL.Uniforms.Set_Int (Texture_ID, 0); - - GL.Objects.Buffers.Draw_Elements (Triangles, Indices_Size, UInt_Type, 0); - - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Attributes.Disable_Vertex_Attrib_Array (1); - GL.Attributes.Disable_Vertex_Attrib_Array (2); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window; - Render_Program : out GL.Objects.Programs.Program; - Indices_Size : out GL.Types.Size; - UV_Map : out GL.Objects.Textures.Texture) is - use GL.Objects.Shaders; - use GL.Types; - use Glfw.Input; - Window_Width : constant Glfw.Size := 1024; - Window_Height : constant Glfw.Size := 768; - - begin - Window.Set_Input_Toggle (Sticky_Keys, True); - Window.Set_Cursor_Mode (Mouse.Disabled); - Glfw.Input.Poll_Events; - - Window'Access.Set_Size (Window_Width, Window_Height); - Window'Access.Set_Cursor_Pos (Mouse.Coordinate (0.5 * Single (Window_Width)), - Mouse.Coordinate (0.5 * Single (Window_Height))); - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - - Vertices_Array_Object.Initialize_Id; - Vertices_Array_Object.Bind; - - Render_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/standard_vertex_shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/standard_fragment_shader.glsl", - Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Render_Program); - - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP"); - Model_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "M"); - View_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "V"); - - Load_DDS ("src/textures/uvmap.DDS", UV_Map); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "myTextureSampler"); - - Load_Buffers (Indices_Size); - - Light_Position_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "LightPosition_worldspace"); - Last_Time := Glfw.Time; - exception - when others => - Put_Line ("An exception occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Render_Program : GL.Objects.Programs.Program; - Running : Boolean := True; - Vertex_Count : GL.Types.Int; - UV_Map : GL.Objects.Textures.Texture; -begin - Setup (Main_Window, Render_Program, Vertex_Count, UV_Map); - while Running loop - Render (Main_Window, Render_Program, Vertex_Count, UV_Map); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/09_vbo_indexing/src/main_loop.ads b/examples/ogl_tutorials/09_vbo_indexing/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/09_vbo_indexing/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/09_vbo_indexing/src/shaders/standard_fragment_shader.glsl b/examples/ogl_tutorials/09_vbo_indexing/src/shaders/standard_fragment_shader.glsl deleted file mode 100755 index 873c3e90..00000000 --- a/examples/ogl_tutorials/09_vbo_indexing/src/shaders/standard_fragment_shader.glsl +++ /dev/null @@ -1,62 +0,0 @@ -#version 410 core - -// Interpolated values from the vertex shaders -in vec2 UV; -in vec3 Position_worldspace; -in vec3 Normal_cameraspace; -in vec3 EyeDirection_cameraspace; -in vec3 LightDirection_cameraspace; - -// Ouput data -out vec3 color; - -// Values that stay constant for the whole mesh. -uniform sampler2D myTextureSampler; -uniform mat4 MV; -uniform vec3 LightPosition_worldspace; - -void main(){ - - // Light emission properties - // You probably want to put them as uniforms - vec3 LightColor = vec3(1,1,1); - float LightPower = 50.0f; - - // Material properties - vec3 MaterialDiffuseColor = texture( myTextureSampler, UV ).rgb; - vec3 MaterialAmbientColor = vec3(0.1,0.1,0.1) * MaterialDiffuseColor; - vec3 MaterialSpecularColor = vec3(0.3,0.3,0.3); - - // Distance to the light - float distance = length( LightPosition_worldspace - Position_worldspace ); - - // Normal of the computed fragment, in camera space - vec3 n = normalize( Normal_cameraspace ); - // Direction of the light (from the fragment to the light) - vec3 l = normalize( LightDirection_cameraspace ); - // Cosine of the angle between the normal and the light direction, - // clamped above 0 - // - light is at the vertical of the triangle -> 1 - // - light is perpendicular to the triangle -> 0 - // - light is behind the triangle -> 0 - float cosTheta = clamp( dot( n,l ), 0,1 ); - - // Eye vector (towards the camera) - vec3 E = normalize(EyeDirection_cameraspace); - // Direction in which the triangle reflects the light - vec3 R = reflect(-l,n); - // Cosine of the angle between the Eye vector and the Reflect vector, - // clamped to 0 - // - Looking into the reflection -> 1 - // - Looking elsewhere -> < 1 - float cosAlpha = clamp( dot( E,R ), 0,1 ); - - color = - // Ambient : simulates indirect lighting - MaterialAmbientColor + - // Diffuse : "color" of the object - MaterialDiffuseColor * LightColor * LightPower * cosTheta / (distance*distance) + - // Specular : reflective highlight, like a mirror - MaterialSpecularColor * LightColor * LightPower * pow(cosAlpha,5) / (distance*distance); - -} diff --git a/examples/ogl_tutorials/09_vbo_indexing/src/shaders/standard_vertex_shader.glsl b/examples/ogl_tutorials/09_vbo_indexing/src/shaders/standard_vertex_shader.glsl deleted file mode 100755 index 8cda0898..00000000 --- a/examples/ogl_tutorials/09_vbo_indexing/src/shaders/standard_vertex_shader.glsl +++ /dev/null @@ -1,44 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 vertexPosition_modelspace; -layout(location = 1) in vec2 vertexUV; -layout(location = 2) in vec3 vertexNormal_modelspace; - -// Output data ; will be interpolated for each fragment. -out vec2 UV; -out vec3 Position_worldspace; -out vec3 Normal_cameraspace; -out vec3 EyeDirection_cameraspace; -out vec3 LightDirection_cameraspace; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP; -uniform mat4 V; -uniform mat4 M; -uniform vec3 LightPosition_worldspace; - -void main(){ - - // Output position of the vertex, in clip space : MVP * position - gl_Position = MVP * vec4(vertexPosition_modelspace,1); - - // Position of the vertex, in worldspace : M * position - Position_worldspace = (M * vec4(vertexPosition_modelspace,1)).xyz; - - // Vector that goes from the vertex to the camera, in camera space. - // In camera space, the camera is at the origin (0,0,0). - vec3 vertexPosition_cameraspace = ( V * M * vec4(vertexPosition_modelspace,1)).xyz; - EyeDirection_cameraspace = vec3(0,0,0) - vertexPosition_cameraspace; - - // Vector that goes from the vertex to the light, in camera space. M is ommited because it's identity. - vec3 LightPosition_cameraspace = ( V * vec4(LightPosition_worldspace,1)).xyz; - LightDirection_cameraspace = LightPosition_cameraspace + EyeDirection_cameraspace; - - // Normal of the the vertex, in camera space - Normal_cameraspace = ( V * M * vec4(vertexNormal_modelspace,0)).xyz; // Only correct if ModelMatrix does not scale the model ! Use its inverse transpose if not. - - // UV of the vertex. No special space for this one. - UV = vertexUV; -} - diff --git a/examples/ogl_tutorials/09_vbo_indexing/src/textures/suzanne.obj b/examples/ogl_tutorials/09_vbo_indexing/src/textures/suzanne.obj deleted file mode 100755 index 14e9bbe4..00000000 --- a/examples/ogl_tutorials/09_vbo_indexing/src/textures/suzanne.obj +++ /dev/null @@ -1,2580 +0,0 @@ -# Blender3D v249 OBJ File: suzanne.blend -# www.blender3d.org -v 0.437500 0.164063 0.765625 -v -0.437500 0.164063 0.765625 -v 0.500000 0.093750 0.687500 -v -0.500000 0.093750 0.687500 -v 0.546875 0.054688 0.578125 -v -0.546875 0.054688 0.578125 -v 0.351563 -0.023438 0.617188 -v -0.351563 -0.023438 0.617188 -v 0.351563 0.031250 0.718750 -v -0.351563 0.031250 0.718750 -v 0.351563 0.132813 0.781250 -v -0.351563 0.132813 0.781250 -v 0.273438 0.164063 0.796875 -v -0.273438 0.164063 0.796875 -v 0.203125 0.093750 0.742188 -v -0.203125 0.093750 0.742188 -v 0.156250 0.054688 0.648438 -v -0.156250 0.054688 0.648438 -v 0.078125 0.242188 0.656250 -v -0.078125 0.242188 0.656250 -v 0.140625 0.242188 0.742188 -v -0.140625 0.242188 0.742188 -v 0.242188 0.242188 0.796875 -v -0.242188 0.242188 0.796875 -v 0.273438 0.328125 0.796875 -v -0.273438 0.328125 0.796875 -v 0.203125 0.390625 0.742188 -v -0.203125 0.390625 0.742188 -v 0.156250 0.437500 0.648438 -v -0.156250 0.437500 0.648438 -v 0.351563 0.515625 0.617188 -v -0.351563 0.515625 0.617188 -v 0.351563 0.453125 0.718750 -v -0.351563 0.453125 0.718750 -v 0.351563 0.359375 0.781250 -v -0.351563 0.359375 0.781250 -v 0.437500 0.328125 0.765625 -v -0.437500 0.328125 0.765625 -v 0.500000 0.390625 0.687500 -v -0.500000 0.390625 0.687500 -v 0.546875 0.437500 0.578125 -v -0.546875 0.437500 0.578125 -v 0.625000 0.242188 0.562500 -v -0.625000 0.242188 0.562500 -v 0.562500 0.242188 0.671875 -v -0.562500 0.242188 0.671875 -v 0.468750 0.242188 0.757813 -v -0.468750 0.242188 0.757813 -v 0.476563 0.242188 0.773438 -v -0.476563 0.242188 0.773438 -v 0.445313 0.335938 0.781250 -v -0.445313 0.335938 0.781250 -v 0.351563 0.375000 0.804688 -v -0.351563 0.375000 0.804688 -v 0.265625 0.335938 0.820313 -v -0.265625 0.335938 0.820313 -v 0.226563 0.242188 0.820313 -v -0.226563 0.242188 0.820313 -v 0.265625 0.156250 0.820313 -v -0.265625 0.156250 0.820313 -v 0.351563 0.242188 0.828125 -v -0.351563 0.242188 0.828125 -v 0.351563 0.117188 0.804688 -v -0.351563 0.117188 0.804688 -v 0.445313 0.156250 0.781250 -v -0.445313 0.156250 0.781250 -v 0.000000 0.429688 0.742188 -v 0.000000 0.351563 0.820313 -v 0.000000 -0.679688 0.734375 -v 0.000000 -0.320313 0.781250 -v 0.000000 -0.187500 0.796875 -v 0.000000 -0.773438 0.718750 -v 0.000000 0.406250 0.601563 -v 0.000000 0.570313 0.570313 -v 0.000000 0.898438 -0.546875 -v 0.000000 0.562500 -0.851563 -v 0.000000 0.070313 -0.828125 -v 0.000000 -0.382813 -0.351563 -v 0.203125 -0.187500 0.562500 -v -0.203125 -0.187500 0.562500 -v 0.312500 -0.437500 0.570313 -v -0.312500 -0.437500 0.570313 -v 0.351563 -0.695313 0.570313 -v -0.351563 -0.695313 0.570313 -v 0.367188 -0.890625 0.531250 -v -0.367188 -0.890625 0.531250 -v 0.328125 -0.945313 0.523438 -v -0.328125 -0.945313 0.523438 -v 0.179688 -0.968750 0.554688 -v -0.179688 -0.968750 0.554688 -v 0.000000 -0.984375 0.578125 -v 0.437500 -0.140625 0.531250 -v -0.437500 -0.140625 0.531250 -v 0.632813 -0.039063 0.539063 -v -0.632813 -0.039063 0.539063 -v 0.828125 0.148438 0.445313 -v -0.828125 0.148438 0.445313 -v 0.859375 0.429688 0.593750 -v -0.859375 0.429688 0.593750 -v 0.710938 0.484375 0.625000 -v -0.710938 0.484375 0.625000 -v 0.492188 0.601563 0.687500 -v -0.492188 0.601563 0.687500 -v 0.320313 0.757813 0.734375 -v -0.320313 0.757813 0.734375 -v 0.156250 0.718750 0.757813 -v -0.156250 0.718750 0.757813 -v 0.062500 0.492188 0.750000 -v -0.062500 0.492188 0.750000 -v 0.164063 0.414063 0.773438 -v -0.164063 0.414063 0.773438 -v 0.125000 0.304688 0.765625 -v -0.125000 0.304688 0.765625 -v 0.203125 0.093750 0.742188 -v -0.203125 0.093750 0.742188 -v 0.375000 0.015625 0.703125 -v -0.375000 0.015625 0.703125 -v 0.492188 0.062500 0.671875 -v -0.492188 0.062500 0.671875 -v 0.625000 0.187500 0.648438 -v -0.625000 0.187500 0.648438 -v 0.640625 0.296875 0.648438 -v -0.640625 0.296875 0.648438 -v 0.601563 0.375000 0.664063 -v -0.601563 0.375000 0.664063 -v 0.429688 0.437500 0.718750 -v -0.429688 0.437500 0.718750 -v 0.250000 0.468750 0.757813 -v -0.250000 0.468750 0.757813 -v 0.000000 -0.765625 0.734375 -v 0.109375 -0.718750 0.734375 -v -0.109375 -0.718750 0.734375 -v 0.117188 -0.835938 0.710938 -v -0.117188 -0.835938 0.710938 -v 0.062500 -0.882813 0.695313 -v -0.062500 -0.882813 0.695313 -v 0.000000 -0.890625 0.687500 -v 0.000000 -0.195313 0.750000 -v 0.000000 -0.140625 0.742188 -v 0.101563 -0.148438 0.742188 -v -0.101563 -0.148438 0.742188 -v 0.125000 -0.226563 0.750000 -v -0.125000 -0.226563 0.750000 -v 0.085938 -0.289063 0.742188 -v -0.085938 -0.289063 0.742188 -v 0.398438 -0.046875 0.671875 -v -0.398438 -0.046875 0.671875 -v 0.617188 0.054688 0.625000 -v -0.617188 0.054688 0.625000 -v 0.726563 0.203125 0.601563 -v -0.726563 0.203125 0.601563 -v 0.742188 0.375000 0.656250 -v -0.742188 0.375000 0.656250 -v 0.687500 0.414063 0.726563 -v -0.687500 0.414063 0.726563 -v 0.437500 0.546875 0.796875 -v -0.437500 0.546875 0.796875 -v 0.312500 0.640625 0.835938 -v -0.312500 0.640625 0.835938 -v 0.203125 0.617188 0.851563 -v -0.203125 0.617188 0.851563 -v 0.101563 0.429688 0.843750 -v -0.101563 0.429688 0.843750 -v 0.125000 -0.101563 0.812500 -v -0.125000 -0.101563 0.812500 -v 0.210938 -0.445313 0.710938 -v -0.210938 -0.445313 0.710938 -v 0.250000 -0.703125 0.687500 -v -0.250000 -0.703125 0.687500 -v 0.265625 -0.820313 0.664063 -v -0.265625 -0.820313 0.664063 -v 0.234375 -0.914063 0.632813 -v -0.234375 -0.914063 0.632813 -v 0.164063 -0.929688 0.632813 -v -0.164063 -0.929688 0.632813 -v 0.000000 -0.945313 0.640625 -v 0.000000 0.046875 0.726563 -v 0.000000 0.210938 0.765625 -v 0.328125 0.476563 0.742188 -v -0.328125 0.476563 0.742188 -v 0.164063 0.140625 0.750000 -v -0.164063 0.140625 0.750000 -v 0.132813 0.210938 0.757813 -v -0.132813 0.210938 0.757813 -v 0.117188 -0.687500 0.734375 -v -0.117188 -0.687500 0.734375 -v 0.078125 -0.445313 0.750000 -v -0.078125 -0.445313 0.750000 -v 0.000000 -0.445313 0.750000 -v 0.000000 -0.328125 0.742188 -v 0.093750 -0.273438 0.781250 -v -0.093750 -0.273438 0.781250 -v 0.132813 -0.226563 0.796875 -v -0.132813 -0.226563 0.796875 -v 0.109375 -0.132813 0.781250 -v -0.109375 -0.132813 0.781250 -v 0.039063 -0.125000 0.781250 -v -0.039063 -0.125000 0.781250 -v 0.000000 -0.203125 0.828125 -v 0.046875 -0.148438 0.812500 -v -0.046875 -0.148438 0.812500 -v 0.093750 -0.156250 0.812500 -v -0.093750 -0.156250 0.812500 -v 0.109375 -0.226563 0.828125 -v -0.109375 -0.226563 0.828125 -v 0.078125 -0.250000 0.804688 -v -0.078125 -0.250000 0.804688 -v 0.000000 -0.289063 0.804688 -v 0.257813 -0.312500 0.554688 -v -0.257813 -0.312500 0.554688 -v 0.164063 -0.242188 0.710938 -v -0.164063 -0.242188 0.710938 -v 0.179688 -0.312500 0.710938 -v -0.179688 -0.312500 0.710938 -v 0.234375 -0.250000 0.554688 -v -0.234375 -0.250000 0.554688 -v 0.000000 -0.875000 0.687500 -v 0.046875 -0.867188 0.687500 -v -0.046875 -0.867188 0.687500 -v 0.093750 -0.820313 0.710938 -v -0.093750 -0.820313 0.710938 -v 0.093750 -0.742188 0.726563 -v -0.093750 -0.742188 0.726563 -v 0.000000 -0.781250 0.656250 -v 0.093750 -0.750000 0.664063 -v -0.093750 -0.750000 0.664063 -v 0.093750 -0.812500 0.640625 -v -0.093750 -0.812500 0.640625 -v 0.046875 -0.851563 0.632813 -v -0.046875 -0.851563 0.632813 -v 0.000000 -0.859375 0.632813 -v 0.171875 0.218750 0.781250 -v -0.171875 0.218750 0.781250 -v 0.187500 0.156250 0.773438 -v -0.187500 0.156250 0.773438 -v 0.335938 0.429688 0.757813 -v -0.335938 0.429688 0.757813 -v 0.273438 0.421875 0.773438 -v -0.273438 0.421875 0.773438 -v 0.421875 0.398438 0.773438 -v -0.421875 0.398438 0.773438 -v 0.562500 0.351563 0.695313 -v -0.562500 0.351563 0.695313 -v 0.585938 0.289063 0.687500 -v -0.585938 0.289063 0.687500 -v 0.578125 0.195313 0.679688 -v -0.578125 0.195313 0.679688 -v 0.476563 0.101563 0.718750 -v -0.476563 0.101563 0.718750 -v 0.375000 0.062500 0.742188 -v -0.375000 0.062500 0.742188 -v 0.226563 0.109375 0.781250 -v -0.226563 0.109375 0.781250 -v 0.179688 0.296875 0.781250 -v -0.179688 0.296875 0.781250 -v 0.210938 0.375000 0.781250 -v -0.210938 0.375000 0.781250 -v 0.234375 0.359375 0.757813 -v -0.234375 0.359375 0.757813 -v 0.195313 0.296875 0.757813 -v -0.195313 0.296875 0.757813 -v 0.242188 0.125000 0.757813 -v -0.242188 0.125000 0.757813 -v 0.375000 0.085938 0.726563 -v -0.375000 0.085938 0.726563 -v 0.460938 0.117188 0.703125 -v -0.460938 0.117188 0.703125 -v 0.546875 0.210938 0.671875 -v -0.546875 0.210938 0.671875 -v 0.554688 0.281250 0.671875 -v -0.554688 0.281250 0.671875 -v 0.531250 0.335938 0.679688 -v -0.531250 0.335938 0.679688 -v 0.414063 0.390625 0.750000 -v -0.414063 0.390625 0.750000 -v 0.281250 0.398438 0.765625 -v -0.281250 0.398438 0.765625 -v 0.335938 0.406250 0.750000 -v -0.335938 0.406250 0.750000 -v 0.203125 0.171875 0.750000 -v -0.203125 0.171875 0.750000 -v 0.195313 0.226563 0.750000 -v -0.195313 0.226563 0.750000 -v 0.109375 0.460938 0.609375 -v -0.109375 0.460938 0.609375 -v 0.195313 0.664063 0.617188 -v -0.195313 0.664063 0.617188 -v 0.335938 0.687500 0.593750 -v -0.335938 0.687500 0.593750 -v 0.484375 0.554688 0.554688 -v -0.484375 0.554688 0.554688 -v 0.679688 0.453125 0.492188 -v -0.679688 0.453125 0.492188 -v 0.796875 0.406250 0.460938 -v -0.796875 0.406250 0.460938 -v 0.773438 0.164063 0.375000 -v -0.773438 0.164063 0.375000 -v 0.601563 0.000000 0.414063 -v -0.601563 0.000000 0.414063 -v 0.437500 -0.093750 0.468750 -v -0.437500 -0.093750 0.468750 -v 0.000000 0.898438 0.289063 -v 0.000000 0.984375 -0.078125 -v 0.000000 -0.195313 -0.671875 -v 0.000000 -0.460938 0.187500 -v 0.000000 -0.976563 0.460938 -v 0.000000 -0.804688 0.343750 -v 0.000000 -0.570313 0.320313 -v 0.000000 -0.484375 0.281250 -v 0.851563 0.234375 0.054688 -v -0.851563 0.234375 0.054688 -v 0.859375 0.320313 -0.046875 -v -0.859375 0.320313 -0.046875 -v 0.773438 0.265625 -0.437500 -v -0.773438 0.265625 -0.437500 -v 0.460938 0.437500 -0.703125 -v -0.460938 0.437500 -0.703125 -v 0.734375 -0.046875 0.070313 -v -0.734375 -0.046875 0.070313 -v 0.593750 -0.125000 -0.164063 -v -0.593750 -0.125000 -0.164063 -v 0.640625 -0.007813 -0.429688 -v -0.640625 -0.007813 -0.429688 -v 0.335938 0.054688 -0.664063 -v -0.335938 0.054688 -0.664063 -v 0.234375 -0.351563 0.406250 -v -0.234375 -0.351563 0.406250 -v 0.179688 -0.414063 0.257813 -v -0.179688 -0.414063 0.257813 -v 0.289063 -0.710938 0.382813 -v -0.289063 -0.710938 0.382813 -v 0.250000 -0.500000 0.390625 -v -0.250000 -0.500000 0.390625 -v 0.328125 -0.914063 0.398438 -v -0.328125 -0.914063 0.398438 -v 0.140625 -0.757813 0.367188 -v -0.140625 -0.757813 0.367188 -v 0.125000 -0.539063 0.359375 -v -0.125000 -0.539063 0.359375 -v 0.164063 -0.945313 0.437500 -v -0.164063 -0.945313 0.437500 -v 0.218750 -0.281250 0.429688 -v -0.218750 -0.281250 0.429688 -v 0.210938 -0.226563 0.468750 -v -0.210938 -0.226563 0.468750 -v 0.203125 -0.171875 0.500000 -v -0.203125 -0.171875 0.500000 -v 0.210938 -0.390625 0.164063 -v -0.210938 -0.390625 0.164063 -v 0.296875 -0.312500 -0.265625 -v -0.296875 -0.312500 -0.265625 -v 0.343750 -0.148438 -0.539063 -v -0.343750 -0.148438 -0.539063 -v 0.453125 0.867188 -0.382813 -v -0.453125 0.867188 -0.382813 -v 0.453125 0.929688 -0.070313 -v -0.453125 0.929688 -0.070313 -v 0.453125 0.851563 0.234375 -v -0.453125 0.851563 0.234375 -v 0.460938 0.523438 0.429688 -v -0.460938 0.523438 0.429688 -v 0.726563 0.406250 0.335938 -v -0.726563 0.406250 0.335938 -v 0.632813 0.453125 0.281250 -v -0.632813 0.453125 0.281250 -v 0.640625 0.703125 0.054688 -v -0.640625 0.703125 0.054688 -v 0.796875 0.562500 0.125000 -v -0.796875 0.562500 0.125000 -v 0.796875 0.617188 -0.117188 -v -0.796875 0.617188 -0.117188 -v 0.640625 0.750000 -0.195313 -v -0.640625 0.750000 -0.195313 -v 0.640625 0.679688 -0.445313 -v -0.640625 0.679688 -0.445313 -v 0.796875 0.539063 -0.359375 -v -0.796875 0.539063 -0.359375 -v 0.617188 0.328125 -0.585938 -v -0.617188 0.328125 -0.585938 -v 0.484375 0.023438 -0.546875 -v -0.484375 0.023438 -0.546875 -v 0.820313 0.328125 -0.203125 -v -0.820313 0.328125 -0.203125 -v 0.406250 -0.171875 0.148438 -v -0.406250 -0.171875 0.148438 -v 0.429688 -0.195313 -0.210938 -v -0.429688 -0.195313 -0.210938 -v 0.890625 0.406250 -0.234375 -v -0.890625 0.406250 -0.234375 -v 0.773438 -0.140625 -0.125000 -v -0.773438 -0.140625 -0.125000 -v 1.039063 -0.101563 -0.328125 -v -1.039063 -0.101563 -0.328125 -v 1.281250 0.054688 -0.429688 -v -1.281250 0.054688 -0.429688 -v 1.351563 0.320313 -0.421875 -v -1.351563 0.320313 -0.421875 -v 1.234375 0.507813 -0.421875 -v -1.234375 0.507813 -0.421875 -v 1.023438 0.476563 -0.312500 -v -1.023438 0.476563 -0.312500 -v 1.015625 0.414063 -0.289063 -v -1.015625 0.414063 -0.289063 -v 1.187500 0.437500 -0.390625 -v -1.187500 0.437500 -0.390625 -v 1.265625 0.289063 -0.406250 -v -1.265625 0.289063 -0.406250 -v 1.210938 0.078125 -0.406250 -v -1.210938 0.078125 -0.406250 -v 1.031250 -0.039063 -0.304688 -v -1.031250 -0.039063 -0.304688 -v 0.828125 -0.070313 -0.132813 -v -0.828125 -0.070313 -0.132813 -v 0.921875 0.359375 -0.218750 -v -0.921875 0.359375 -0.218750 -v 0.945313 0.304688 -0.289063 -v -0.945313 0.304688 -0.289063 -v 0.882813 -0.023438 -0.210938 -v -0.882813 -0.023438 -0.210938 -v 1.039063 0.000000 -0.367188 -v -1.039063 0.000000 -0.367188 -v 1.187500 0.093750 -0.445313 -v -1.187500 0.093750 -0.445313 -v 1.234375 0.250000 -0.445313 -v -1.234375 0.250000 -0.445313 -v 1.171875 0.359375 -0.437500 -v -1.171875 0.359375 -0.437500 -v 1.023438 0.343750 -0.359375 -v -1.023438 0.343750 -0.359375 -v 0.843750 0.289063 -0.210938 -v -0.843750 0.289063 -0.210938 -v 0.835938 0.171875 -0.273438 -v -0.835938 0.171875 -0.273438 -v 0.757813 0.093750 -0.273438 -v -0.757813 0.093750 -0.273438 -v 0.820313 0.085938 -0.273438 -v -0.820313 0.085938 -0.273438 -v 0.843750 0.015625 -0.273438 -v -0.843750 0.015625 -0.273438 -v 0.812500 -0.015625 -0.273438 -v -0.812500 -0.015625 -0.273438 -v 0.726563 0.000000 -0.070313 -v -0.726563 0.000000 -0.070313 -v 0.718750 -0.023438 -0.171875 -v -0.718750 -0.023438 -0.171875 -v 0.718750 0.039063 -0.187500 -v -0.718750 0.039063 -0.187500 -v 0.796875 0.203125 -0.210938 -v -0.796875 0.203125 -0.210938 -v 0.890625 0.242188 -0.265625 -v -0.890625 0.242188 -0.265625 -v 0.890625 0.234375 -0.320313 -v -0.890625 0.234375 -0.320313 -v 0.812500 -0.015625 -0.320313 -v -0.812500 -0.015625 -0.320313 -v 0.851563 0.015625 -0.320313 -v -0.851563 0.015625 -0.320313 -v 0.828125 0.078125 -0.320313 -v -0.828125 0.078125 -0.320313 -v 0.765625 0.093750 -0.320313 -v -0.765625 0.093750 -0.320313 -v 0.843750 0.171875 -0.320313 -v -0.843750 0.171875 -0.320313 -v 1.039063 0.328125 -0.414063 -v -1.039063 0.328125 -0.414063 -v 1.187500 0.343750 -0.484375 -v -1.187500 0.343750 -0.484375 -v 1.257813 0.242188 -0.492188 -v -1.257813 0.242188 -0.492188 -v 1.210938 0.085938 -0.484375 -v -1.210938 0.085938 -0.484375 -v 1.046875 0.000000 -0.421875 -v -1.046875 0.000000 -0.421875 -v 0.882813 -0.015625 -0.265625 -v -0.882813 -0.015625 -0.265625 -v 0.953125 0.289063 -0.343750 -v -0.953125 0.289063 -0.343750 -v 0.890625 0.109375 -0.328125 -v -0.890625 0.109375 -0.328125 -v 0.937500 0.062500 -0.335938 -v -0.937500 0.062500 -0.335938 -v 1.000000 0.125000 -0.367188 -v -1.000000 0.125000 -0.367188 -v 0.960938 0.171875 -0.351563 -v -0.960938 0.171875 -0.351563 -v 1.015625 0.234375 -0.375000 -v -1.015625 0.234375 -0.375000 -v 1.054688 0.187500 -0.382813 -v -1.054688 0.187500 -0.382813 -v 1.109375 0.210938 -0.390625 -v -1.109375 0.210938 -0.390625 -v 1.085938 0.273438 -0.390625 -v -1.085938 0.273438 -0.390625 -v 1.023438 0.437500 -0.484375 -v -1.023438 0.437500 -0.484375 -v 1.250000 0.468750 -0.546875 -v -1.250000 0.468750 -0.546875 -v 1.367188 0.296875 -0.500000 -v -1.367188 0.296875 -0.500000 -v 1.312500 0.054688 -0.531250 -v -1.312500 0.054688 -0.531250 -v 1.039063 -0.085938 -0.492188 -v -1.039063 -0.085938 -0.492188 -v 0.789063 -0.125000 -0.328125 -v -0.789063 -0.125000 -0.328125 -v 0.859375 0.382813 -0.382813 -v -0.859375 0.382813 -0.382813 -v -1.023438 0.476563 -0.312500 -v -1.234375 0.507813 -0.421875 -v -0.890625 0.406250 -0.234375 -v -0.820313 0.328125 -0.203125 -vt 0.315596 0.792535 -vt 0.331462 0.787091 -vt 0.331944 0.799704 -vt 0.049262 0.798007 -vt 0.050304 0.785428 -vt 0.065913 0.791570 -vt 0.321453 0.778649 -vt 0.060677 0.777438 -vt 0.310368 0.778802 -vt 0.071744 0.778083 -vt 0.302416 0.786560 -vt 0.079345 0.786186 -vt 0.301514 0.798474 -vt 0.079717 0.798128 -vt 0.308740 0.806873 -vt 0.072125 0.806199 -vt 0.321648 0.808687 -vt 0.059149 0.807438 -vt 0.048462 0.201858 -vt 0.040084 0.207259 -vt 0.043232 0.202821 -vt 0.043249 0.220655 -vt 0.040093 0.216224 -vt 0.048480 0.221607 -vt 0.563710 0.649220 -vt 0.540594 0.657349 -vt 0.547067 0.627433 -vt 0.974643 0.218739 -vt 0.968169 0.188824 -vt 0.991286 0.196952 -vt 0.166564 0.702856 -vt 0.160061 0.635503 -vt 0.218800 0.643864 -vt 0.646379 0.202310 -vt 0.587641 0.210669 -vt 0.594146 0.143318 -vt 0.231653 0.710981 -vt 0.181122 0.727399 -vt 0.174315 0.716236 -vt 0.601897 0.129938 -vt 0.608704 0.118775 -vt 0.659234 0.135195 -vt 0.266169 0.503056 -vt 0.270502 0.531304 -vt 0.237927 0.525958 -vt 0.665505 0.320215 -vt 0.698081 0.314870 -vt 0.693747 0.343118 -vt 0.392095 0.783569 -vt 0.421339 0.774990 -vt 0.422693 0.793271 -vt 0.628129 0.465996 -vt 0.613733 0.456434 -vt 0.634389 0.436387 -vt 0.501778 0.870396 -vt 0.507486 0.857499 -vt 0.528577 0.865850 -vt 0.643384 0.583025 -vt 0.644052 0.562152 -vt 0.656465 0.561923 -vt 0.766386 0.787223 -vt 0.745292 0.810963 -vt 0.708792 0.802136 -vt 0.769147 0.634951 -vt 0.732033 0.641034 -vt 0.711181 0.618495 -vt 0.849461 0.545148 -vt 0.823375 0.497849 -vt 0.897469 0.500666 -vt 0.902318 0.546395 -vt 0.572425 0.679855 -vt 0.643837 0.668801 -vt 0.623443 0.718088 -vt 0.572425 0.724426 -vt 0.726607 0.540494 -vt 0.753364 0.518460 -vt 0.715449 0.680462 -vt 0.749227 0.698466 -vt 0.695922 0.534580 -vt 0.693526 0.510498 -vt 0.772837 0.655221 -vt 0.784620 0.679820 -vt 0.718163 0.580185 -vt 0.809389 0.599417 -vt 0.761761 0.743313 -vt 0.667750 0.767676 -vt 0.693110 0.564191 -vt 0.797155 0.722534 -vt 0.682009 0.616616 -vt 0.795802 0.787304 -vt 0.719538 0.655221 -vt 0.756895 0.826983 -vt 0.782765 0.655221 -vt 0.695179 0.821970 -vt 0.843059 0.610497 -vt 0.635588 0.780626 -vt 0.634422 0.561399 -vt 0.628274 0.581967 -vt 0.511020 0.847430 -vt 0.533908 0.850607 -vt 0.633815 0.551490 -vt 0.613046 0.571327 -vt 0.530368 0.831407 -vt 0.501394 0.842435 -vt 0.626589 0.538875 -vt 0.604527 0.544684 -vt 0.508929 0.810914 -vt 0.492547 0.829318 -vt 0.618247 0.522587 -vt 0.602583 0.501781 -vt 0.480939 0.813120 -vt 0.469234 0.787943 -vt 0.616652 0.502716 -vt 0.613925 0.497595 -vt 0.459358 0.796431 -vt 0.462840 0.801566 -vt 0.644899 0.511966 -vt 0.630336 0.517087 -vt 0.628893 0.504351 -vt 0.635735 0.498392 -vt 0.458270 0.813966 -vt 0.469630 0.821874 -vt 0.457144 0.833207 -vt 0.449054 0.817297 -vt 0.637359 0.534149 -vt 0.654293 0.524569 -vt 0.464258 0.849211 -vt 0.482600 0.837505 -vt 0.644187 0.548520 -vt 0.659377 0.540935 -vt 0.478087 0.863369 -vt 0.493557 0.851414 -vt 0.597230 0.539263 -vt 0.595257 0.495349 -vt 0.466971 0.777596 -vt 0.507407 0.801398 -vt 0.605628 0.572478 -vt 0.534801 0.825096 -vt 0.627145 0.592333 -vt 0.544318 0.853620 -vt 0.651887 0.586528 -vt 0.528822 0.875551 -vt 0.665532 0.557472 -vt 0.492878 0.878439 -vt 0.669345 0.535984 -vt 0.467321 0.871200 -vt 0.612569 0.491986 -vt 0.454710 0.792385 -vt 0.619277 0.495381 -vt 0.454636 0.800448 -vt 0.628580 0.496763 -vt 0.451294 0.809743 -vt 0.636682 0.490206 -vt 0.440853 0.813605 -vt 0.652342 0.504728 -vt 0.446182 0.836397 -vt 0.664409 0.519225 -vt 0.453285 0.856119 -vt 0.666191 0.492411 -vt 0.717596 0.474672 -vt 0.382398 0.879324 -vt 0.427166 0.842398 -vt 0.681733 0.511408 -vt 0.427493 0.877628 -vt 0.435523 0.867805 -vt 0.685777 0.532869 -vt 0.453231 0.887054 -vt 0.588528 0.478377 -vt 0.454313 0.762782 -vt 0.446975 0.900429 -vt 0.713425 0.237886 -vt 0.709019 0.215724 -vt 0.755152 0.224403 -vt 0.762923 0.242445 -vt 0.327574 0.621771 -vt 0.281440 0.630451 -vt 0.285847 0.608289 -vt 0.335345 0.603729 -vt 0.576794 0.465515 -vt 0.583867 0.423087 -vt 0.405805 0.730353 -vt 0.448347 0.745304 -vt 0.686035 0.253032 -vt 0.258456 0.593142 -vt 0.683851 0.556229 -vt 0.482266 0.899349 -vt 0.670531 0.597684 -vt 0.532990 0.898426 -vt 0.630909 0.604157 -vt 0.553941 0.861896 -vt 0.596864 0.576275 -vt 0.542184 0.818594 -vt 0.585561 0.529242 -vt 0.503791 0.785451 -vt 0.572425 0.529736 -vt 0.510638 0.773572 -vt 0.587548 0.588270 -vt 0.557294 0.815416 -vt 0.629961 0.623919 -vt 0.572425 0.868524 -vt 0.548104 0.914571 -vt 0.488130 0.914571 -vt 0.658830 0.266292 -vt 0.631691 0.281488 -vt 0.204112 0.564686 -vt 0.231252 0.579881 -vt 0.706402 0.288928 -vt 0.278823 0.557246 -vt 0.743528 0.317934 -vt 0.752264 0.346660 -vt 0.324686 0.499513 -vt 0.315950 0.528240 -vt 0.743309 0.289810 -vt 0.315731 0.556363 -vt 0.700326 0.147967 -vt 0.272746 0.698208 -vt 0.795874 0.266472 -vt 0.775660 0.289442 -vt 0.757507 0.263314 -vt 0.348083 0.556732 -vt 0.329929 0.582860 -vt 0.368297 0.579702 -vt 0.804056 0.232825 -vt 0.376478 0.613349 -vt 0.810124 0.179100 -vt 0.382547 0.667075 -vt 0.753847 0.157090 -vt 0.811201 0.146834 -vt 0.383624 0.699341 -vt 0.326269 0.689085 -vt 0.879685 0.183943 -vt 0.888071 0.157228 -vt 0.460496 0.688946 -vt 0.452109 0.662231 -vt 0.925222 0.140531 -vt 0.947451 0.149372 -vt 0.519876 0.696801 -vt 0.497647 0.705643 -vt 0.876420 0.258223 -vt 0.946138 0.286262 -vt 0.518561 0.559910 -vt 0.448843 0.587951 -vt 0.829953 0.196170 -vt 0.837053 0.152275 -vt 0.409477 0.693900 -vt 0.402377 0.650004 -vt 0.829888 0.255993 -vt 0.402311 0.590181 -vt 0.852096 0.297194 -vt 0.813695 0.289418 -vt 0.424519 0.548979 -vt 0.386117 0.556756 -vt 0.820842 0.328587 -vt 0.789451 0.311961 -vt 0.393264 0.517587 -vt 0.361873 0.534212 -vt 0.840465 0.403536 -vt 0.762603 0.423087 -vt 0.412887 0.442637 -vt 0.335024 0.423087 -vt 0.909248 0.345901 -vt 0.481670 0.500271 -vt 0.676670 0.402805 -vt 0.249092 0.443369 -vt 0.573469 0.193539 -vt 0.579214 0.151927 -vt 0.151632 0.694246 -vt 0.145888 0.652633 -vt 0.546919 0.227092 -vt 0.536510 0.214419 -vt 0.119340 0.619080 -vt 0.108931 0.631753 -vt 0.588792 0.317539 -vt 0.161214 0.528634 -vt 0.630429 0.371564 -vt 0.202851 0.474609 -vt 0.657494 0.118541 -vt 0.164237 0.319427 -vt 0.169464 0.304721 -vt 0.210459 0.345510 -vt 0.169574 0.118572 -vt 0.164356 0.103821 -vt 0.210731 0.077759 -vt 0.229913 0.727634 -vt 0.589956 0.115821 -vt 0.153468 0.300432 -vt 0.153526 0.122857 -vt 0.162374 0.730353 -vt 0.578472 0.119429 -vt 0.553653 0.120209 -vt 0.126070 0.725964 -vt 0.150890 0.726744 -vt 0.546510 0.159800 -vt 0.509384 0.119033 -vt 0.081800 0.727137 -vt 0.118929 0.686371 -vt 0.534072 0.185482 -vt 0.106492 0.660689 -vt 0.462352 0.161885 -vt 0.478174 0.145123 -vt 0.493641 0.175543 -vt 0.505521 0.150780 -vt 0.077939 0.695390 -vt 0.050592 0.701044 -vt 0.066060 0.670626 -vt 0.034770 0.684282 -vt 0.476706 0.124129 -vt 0.049122 0.722039 -vt 0.465324 0.131169 -vt 0.037741 0.714998 -vt 0.446348 0.149671 -vt 0.018765 0.696495 -vt 0.445483 0.184898 -vt 0.427581 0.175095 -vt 0.000000 0.671069 -vt 0.017903 0.661268 -vt 0.480167 0.198327 -vt 0.052588 0.647841 -vt 0.521714 0.207472 -vt 0.094135 0.638699 -vt 0.701979 0.120236 -vt 0.274400 0.725940 -vt 0.757541 0.138176 -vt 0.329963 0.708000 -vt 0.817327 0.117813 -vt 0.389751 0.728363 -vt 0.844767 0.126748 -vt 0.417191 0.719428 -vt 0.893893 0.126476 -vt 0.466319 0.719698 -vt 0.936543 0.115821 -vt 0.508970 0.730353 -vt 0.965717 0.128368 -vt 0.538144 0.717805 -vt 0.989276 0.166159 -vt 0.561701 0.680013 -vt 1.000000 0.175243 -vt 0.572425 0.670929 -vt 0.289028 0.269037 -vt 0.283878 0.263049 -vt 0.299187 0.258321 -vt 0.300964 0.267357 -vt 0.299421 0.165436 -vt 0.284101 0.160633 -vt 0.289287 0.154655 -vt 0.301244 0.156393 -vt 0.317793 0.260767 -vt 0.316733 0.267304 -vt 0.318078 0.163079 -vt 0.317052 0.156521 -vt 0.335398 0.269583 -vt 0.330421 0.276220 -vt 0.335777 0.154335 -vt 0.330824 0.147649 -vt 0.278552 0.277080 -vt 0.273734 0.272912 -vt 0.273975 0.150706 -vt 0.278818 0.146548 -vt 0.271078 0.306358 -vt 0.264864 0.305818 -vt 0.265194 0.117691 -vt 0.271427 0.117166 -vt 0.278613 0.324240 -vt 0.274006 0.327477 -vt 0.274436 0.095993 -vt 0.279049 0.099253 -vt 0.298062 0.342565 -vt 0.294660 0.349561 -vt 0.295240 0.073895 -vt 0.298634 0.080932 -vt 0.312476 0.342961 -vt 0.315033 0.350198 -vt 0.315702 0.073322 -vt 0.313108 0.080584 -vt 0.323281 0.337709 -vt 0.328696 0.344302 -vt 0.329405 0.079293 -vt 0.323940 0.085897 -vt 0.335361 0.313857 -vt 0.339396 0.315576 -vt 0.340031 0.108187 -vt 0.335968 0.109893 -vt 0.339920 0.298303 -vt 0.345292 0.298556 -vt 0.345869 0.125306 -vt 0.340471 0.125531 -vt 0.339277 0.286081 -vt 0.344398 0.284332 -vt 0.344895 0.139582 -vt 0.339764 0.137799 -vt 0.345671 0.260159 -vt 0.355483 0.280619 -vt 0.356003 0.143373 -vt 0.346021 0.163854 -vt 0.356162 0.297750 -vt 0.356783 0.126174 -vt 0.349494 0.319809 -vt 0.350195 0.103982 -vt 0.333524 0.354692 -vt 0.334295 0.068869 -vt 0.317323 0.364551 -vt 0.318050 0.058911 -vt 0.293154 0.361782 -vt 0.293765 0.061619 -vt 0.263750 0.335417 -vt 0.264168 0.087998 -vt 0.251373 0.309082 -vt 0.251676 0.114380 -vt 0.264926 0.265507 -vt 0.265122 0.158092 -vt 0.278030 0.255522 -vt 0.278212 0.168150 -vt 0.320744 0.246538 -vt 0.320956 0.177355 -vt 0.296570 0.247318 -vt 0.296748 0.176443 -vt 0.038845 0.211743 -vt 0.047440 0.211734 -vt 0.055230 0.211728 -vt 0.057303 0.228458 -vt 0.057278 0.194991 -vt 0.041287 0.229096 -vt 0.041253 0.194380 -vt 0.032564 0.220061 -vt 0.032546 0.203437 -vt 0.030743 0.211752 -vt 0.029931 0.223131 -vt 0.028053 0.211756 -vt 0.029906 0.200372 -vt 0.038587 0.233067 -vt 0.038544 0.190412 -vt 0.061533 0.231825 -vt 0.061505 0.191616 -vt 0.057382 0.211726 -vt 0.168191 0.258703 -vt 0.213958 0.246887 -vt 0.214040 0.176591 -vt 0.168236 0.164676 -vt 0.148297 0.258447 -vt 0.138777 0.299079 -vt 0.138791 0.124216 -vt 0.148319 0.164919 -vt 0.115455 0.259296 -vt 0.109657 0.296761 -vt 0.109611 0.126556 -vt 0.115440 0.164070 -vt 0.119233 0.228698 -vt 0.156540 0.233552 -vt 0.156556 0.189842 -vt 0.119230 0.194690 -vt 0.173998 0.244074 -vt 0.174035 0.179329 -vt 0.195860 0.238258 -vt 0.195909 0.185188 -vt 0.203534 0.211734 -vt 0.252997 0.211802 -vt 0.171285 0.225095 -vt 0.164455 0.211704 -vt 0.180017 0.211713 -vt 0.177113 0.227468 -vt 0.171300 0.198319 -vt 0.177134 0.195952 -vt 0.185539 0.227013 -vt 0.187516 0.221322 -vt 0.187531 0.202116 -vt 0.185563 0.196419 -vt 0.176585 0.232500 -vt 0.165993 0.229894 -vt 0.176611 0.190916 -vt 0.166011 0.193512 -vt 0.189406 0.230672 -vt 0.189438 0.192766 -vt 0.193574 0.221791 -vt 0.193592 0.201656 -vt 0.186479 0.211718 -vt 0.156919 0.211701 -vt 0.148476 0.211699 -vt 0.427853 0.115821 -vt 0.427581 0.104121 -vt 0.441185 0.104121 -vt 0.427581 0.011703 -vt 0.427581 0.000000 -vt 0.441181 0.011386 -vt 0.067509 0.234045 -vt 0.071465 0.211716 -vt 0.067479 0.189385 -vt 0.119764 0.211696 -vt 0.060932 0.261035 -vt 0.038121 0.261699 -vt 0.038025 0.161756 -vt 0.060860 0.162382 -vt 0.019864 0.255578 -vt 0.019760 0.167921 -vt 0.016617 0.242679 -vt 0.016537 0.180842 -vt 0.014466 0.211775 -vt 0.297831 0.211892 -vt 0.340508 0.212027 -vt 0.356498 0.241635 -vt 0.356742 0.182510 -vt 0.236517 0.317748 -vt 0.236802 0.105655 -vt 0.264789 0.363401 -vt 0.265286 0.059917 -vt 0.296951 0.385966 -vt 0.297650 0.037339 -vt 0.337996 0.385300 -vt 0.338890 0.038126 -vt 0.349401 0.368365 -vt 0.350300 0.055183 -vt 0.377282 0.319664 -vt 0.378129 0.104260 -vt 0.394788 0.292204 -vt 0.395576 0.131978 -vt 0.391029 0.270263 -vt 0.391643 0.154015 -vt 0.368661 0.212151 -vt 0.379482 0.228055 -vt 0.379686 0.196331 -vt 0.420379 0.261837 -vt 0.421104 0.162716 -vt 0.426533 0.298960 -vt 0.427581 0.125377 -vt 0.396664 0.342212 -vt 0.397734 0.081667 -vt 0.365156 0.387054 -vt 0.366203 0.036443 -vt 0.346744 0.416452 -vt 0.347768 0.006839 -vt 0.278009 0.423087 -vt 0.278714 0.000000 -vt 0.241964 0.376122 -vt 0.242399 0.047096 -vt 0.055563 0.291878 -vt 0.055443 0.131506 -vt 0.014495 0.288026 -vt 0.014318 0.135436 -vt 0.003828 0.279132 -vt 0.003650 0.144368 -vt 0.000113 0.248111 -vt 0.000000 0.175447 -vt 0.000000 0.211799 -vt 0.046962 0.798865 -vt 0.047306 0.784561 -vt 0.334495 0.786358 -vt 0.334204 0.800664 -vt 0.058429 0.773633 -vt 0.323868 0.774947 -vt 0.072992 0.774071 -vt 0.309301 0.774739 -vt 0.084403 0.784016 -vt 0.297459 0.784168 -vt 0.083417 0.800146 -vt 0.297728 0.800325 -vt 0.073091 0.810538 -vt 0.307582 0.811166 -vt 0.057505 0.810093 -vt 0.323173 0.811412 -vt 0.024988 0.807478 -vt 0.047717 0.829014 -vt 0.332112 0.830749 -vt 0.355774 0.810244 -vt 0.000000 0.817350 -vt 0.033121 0.852785 -vt 0.345638 0.855146 -vt 0.380299 0.821215 -vt 0.083391 0.855019 -vt 0.078555 0.829097 -vt 0.301299 0.829463 -vt 0.295318 0.855146 -vt 0.100718 0.807888 -vt 0.280100 0.807291 -vt 0.123146 0.821929 -vt 0.257070 0.820323 -vt 0.127501 0.768220 -vt 0.103229 0.776171 -vt 0.279000 0.775494 -vt 0.255105 0.766472 -vt 0.079351 0.756089 -vt 0.303746 0.756492 -vt 0.089008 0.730353 -vt 0.295241 0.730353 -vt 0.049398 0.755271 -vt 0.035422 0.733227 -vt 0.333706 0.757005 -vt 0.348646 0.735604 -vt 0.026877 0.776230 -vt 0.355274 0.778943 -vt 0.000000 0.770061 -vt 0.382398 0.773973 -vn 0.189764 -0.003571 0.981811 -vn 0.646809 -0.758202 0.082095 -vn 0.999573 -0.014496 -0.024445 -vn -0.999573 -0.014496 -0.024445 -vn -0.646809 -0.758202 0.082095 -vn -0.189764 -0.003571 0.981811 -vn -0.085788 -0.982971 0.162389 -vn 0.085788 -0.982971 0.162389 -vn -0.744835 -0.623768 0.236824 -vn 0.744835 -0.623768 0.236824 -vn -0.870968 -0.014710 0.491104 -vn 0.870968 -0.014710 0.491104 -vn -0.758354 0.606128 0.239692 -vn 0.758354 0.606128 0.239692 -vn -0.085788 0.982513 0.165105 -vn 0.085788 0.982513 0.165105 -vn 0.655141 0.750633 0.085574 -vn -0.655141 0.750633 0.085574 -vn -0.349284 -0.719932 0.599719 -vn -0.173681 0.215735 0.960845 -vn -0.809839 0.388287 0.439741 -vn 0.809839 0.388287 0.439741 -vn 0.173681 0.215735 0.960845 -vn 0.349284 -0.719932 0.599719 -vn 0.000000 0.794183 0.607654 -vn -0.508652 0.858119 -0.069887 -vn 0.000000 0.487075 0.873348 -vn 0.508652 0.858119 -0.069887 -vn 0.981414 -0.186682 0.043947 -vn 0.569811 -0.821711 0.007813 -vn 0.563463 -0.814570 0.137669 -vn -0.563463 -0.814570 0.137669 -vn -0.569811 -0.821711 0.007813 -vn -0.981414 -0.186682 0.043947 -vn 0.475845 -0.876247 0.075381 -vn 0.850520 -0.525529 -0.020692 -vn 0.876949 -0.163823 0.451766 -vn -0.876949 -0.163823 0.451766 -vn -0.850520 -0.525529 -0.020692 -vn -0.475845 -0.876247 0.075381 -vn 0.448286 -0.367870 -0.814661 -vn 0.530534 -0.539445 -0.653829 -vn 0.513077 -0.674673 -0.530595 -vn -0.513077 -0.674673 -0.530595 -vn -0.530534 -0.539445 -0.653829 -vn -0.448286 -0.367870 -0.814661 -vn 0.888180 -0.439955 -0.132389 -vn 0.588519 0.226966 0.775933 -vn 0.911527 -0.115268 0.394665 -vn -0.911527 -0.115268 0.394665 -vn -0.588519 0.226966 0.775933 -vn -0.888180 -0.439955 -0.132389 -vn 0.468886 -0.304727 0.829005 -vn 0.251564 0.260781 0.932005 -vn -0.003082 -0.330882 0.943632 -vn 0.003082 -0.330882 0.943632 -vn -0.251564 0.260781 0.932005 -vn -0.468886 -0.304727 0.829005 -vn 0.473067 0.578997 -0.664022 -vn 0.992462 0.028626 -0.118900 -vn 0.459975 -0.380261 -0.802362 -vn -0.459975 -0.380261 -0.802362 -vn -0.992462 0.028626 -0.118900 -vn -0.473067 0.578997 -0.664022 -vn -0.059908 -0.804712 -0.590594 -vn -0.346141 -0.637287 -0.688498 -vn -0.330546 -0.943236 0.031281 -vn -0.073672 -0.594989 0.800317 -vn 0.330546 -0.943236 0.031281 -vn 0.346141 -0.637287 -0.688498 -vn 0.059908 -0.804712 -0.590594 -vn 0.073672 -0.594989 0.800317 -vn 0.593738 0.595264 -0.541368 -vn -0.626057 -0.002686 -0.779748 -vn 0.626057 -0.002686 -0.779748 -vn -0.593738 0.595264 -0.541368 -vn 0.127689 0.703757 0.698843 -vn -0.713828 0.382183 0.586810 -vn 0.713828 0.382183 0.586810 -vn -0.127689 0.703757 0.698843 -vn 0.378063 0.560045 -0.737144 -vn 0.036805 -0.708457 -0.704764 -vn -0.378063 0.560045 -0.737144 -vn -0.036805 -0.708457 -0.704764 -vn -0.031556 0.838710 0.543626 -vn 0.031556 0.838710 0.543626 -vn -0.361156 0.848689 0.386303 -vn 0.361156 0.848689 0.386303 -vn -0.716392 0.204474 0.667043 -vn 0.716392 0.204474 0.667043 -vn -0.662038 -0.413770 0.624866 -vn 0.662038 -0.413770 0.624866 -vn -0.530229 -0.655751 0.537370 -vn 0.530229 -0.655751 0.537370 -vn -0.437483 0.001221 0.899197 -vn 0.550981 -0.138096 0.822993 -vn 0.437483 0.001221 0.899197 -vn -0.550981 -0.138096 0.822993 -vn -0.315958 -0.102298 0.943205 -vn 0.608539 0.296121 0.736167 -vn -0.608539 0.296121 0.736167 -vn 0.315958 -0.102298 0.943205 -vn -0.445479 -0.088778 0.890866 -vn -0.257698 0.600024 0.757317 -vn 0.257698 0.600024 0.757317 -vn 0.445479 -0.088778 0.890866 -vn -0.327799 0.169927 0.929319 -vn 0.041780 0.927213 0.372112 -vn 0.327799 0.169927 0.929319 -vn -0.041780 0.927213 0.372112 -vn -0.277932 0.260201 0.924680 -vn -0.750725 0.111545 0.651112 -vn 0.750725 0.111545 0.651112 -vn 0.277932 0.260201 0.924680 -vn -0.437910 -0.293985 0.849574 -vn -0.183782 0.036836 0.982269 -vn -0.554216 0.387219 0.736808 -vn -0.814325 0.253426 0.522111 -vn 0.554216 0.387219 0.736808 -vn 0.183782 0.036836 0.982269 -vn 0.437910 -0.293985 0.849574 -vn 0.814325 0.253426 0.522111 -vn -0.326670 -0.001617 0.945128 -vn -0.704337 -0.526872 0.475692 -vn 0.704337 -0.526872 0.475692 -vn 0.326670 -0.001617 0.945128 -vn -0.308786 0.134617 0.941527 -vn -0.629170 -0.371441 0.682730 -vn 0.629170 -0.371441 0.682730 -vn 0.308786 0.134617 0.941527 -vn 0.146184 0.948637 0.280465 -vn -0.137516 0.905820 0.400708 -vn 0.137516 0.905820 0.400708 -vn -0.146184 0.948637 0.280465 -vn 0.723746 0.690023 -0.005219 -vn -0.723746 0.690023 -0.005219 -vn 0.994690 -0.078005 0.067019 -vn -0.994690 -0.078005 0.067019 -vn 0.200934 -0.758141 0.620350 -vn -0.200934 -0.758141 0.620350 -vn -0.541246 -0.672658 0.504501 -vn 0.541246 -0.672658 0.504501 -vn -0.690054 -0.553209 0.466628 -vn 0.690054 -0.553209 0.466628 -vn -0.464003 0.686666 0.559557 -vn 0.464003 0.686666 0.559557 -vn -0.827448 -0.135899 0.544786 -vn 0.827448 -0.135899 0.544786 -vn -0.466231 0.808863 0.358196 -vn 0.466231 0.808863 0.358196 -vn -0.743980 -0.022919 0.667776 -vn 0.743980 -0.022919 0.667776 -vn -0.711295 -0.638325 0.294137 -vn 0.711295 -0.638325 0.294137 -vn -0.709769 -0.501999 0.494125 -vn 0.709769 -0.501999 0.494125 -vn -0.818903 -0.425520 0.385113 -vn -0.992523 -0.071444 -0.098758 -vn 0.992523 -0.071444 -0.098758 -vn 0.818903 -0.425520 0.385113 -vn -0.439192 -0.273568 0.855708 -vn 0.439192 -0.273568 0.855708 -vn -0.414686 -0.059877 0.907956 -vn 0.414686 -0.059877 0.907956 -vn -0.341563 0.452132 0.823939 -vn 0.341563 0.452132 0.823939 -vn -0.724509 -0.684927 0.076632 -vn -0.987548 -0.123020 0.097995 -vn 0.987548 -0.123020 0.097995 -vn 0.724509 -0.684927 0.076632 -vn -0.572741 -0.088443 0.814936 -vn 0.572741 -0.088443 0.814936 -vn -0.291818 -0.152104 0.944273 -vn 0.291818 -0.152104 0.944273 -vn 0.239662 -0.128605 0.962279 -vn -0.239662 -0.128605 0.962279 -vn 0.187017 0.370678 0.909696 -vn -0.187017 0.370678 0.909696 -vn -0.455794 0.423170 0.783044 -vn 0.455794 0.423170 0.783044 -vn -0.543504 -0.813379 -0.207343 -vn -0.560045 -0.814417 -0.151738 -vn 0.560045 -0.814417 -0.151738 -vn 0.543504 -0.813379 -0.207343 -vn -0.615375 -0.087649 -0.783319 -vn -0.447310 0.229530 -0.864406 -vn 0.447310 0.229530 -0.864406 -vn 0.615375 -0.087649 -0.783319 -vn -0.547166 -0.832179 -0.089785 -vn 0.547166 -0.832179 -0.089785 -vn -0.873135 0.486984 -0.020264 -vn -0.865352 0.331217 -0.376049 -vn 0.865352 0.331217 -0.376049 -vn 0.873135 0.486984 -0.020264 -vn -0.748741 0.518387 0.413038 -vn 0.748741 0.518387 0.413038 -vn -0.766167 0.634816 0.099612 -vn 0.766167 0.634816 0.099612 -vn -0.953185 -0.248299 -0.172430 -vn -0.665639 0.602496 -0.440321 -vn 0.665639 0.602496 -0.440321 -vn 0.953185 -0.248299 -0.172430 -vn -0.322642 0.847713 0.421033 -vn -0.188574 0.788934 -0.584765 -vn 0.188574 0.788934 -0.584765 -vn 0.322642 0.847713 0.421033 -vn -0.239784 0.745262 -0.622120 -vn 0.494247 0.520585 -0.696158 -vn -0.494247 0.520585 -0.696158 -vn 0.239784 0.745262 -0.622120 -vn -0.480697 0.731223 0.483932 -vn 0.000000 0.758690 0.651418 -vn 0.480697 0.731223 0.483932 -vn -0.489242 0.762963 0.422498 -vn -0.363109 0.908567 -0.206458 -vn 0.363109 0.908567 -0.206458 -vn 0.489242 0.762963 0.422498 -vn -0.645039 0.694540 0.318613 -vn 0.645039 0.694540 0.318613 -vn -0.492843 0.869015 0.043062 -vn -0.679434 0.728965 -0.083468 -vn 0.492843 0.869015 0.043062 -vn 0.679434 0.728965 -0.083468 -vn -0.391736 0.826014 -0.405225 -vn -0.644398 0.527207 -0.553880 -vn 0.391736 0.826014 -0.405225 -vn 0.644398 0.527207 -0.553880 -vn 0.000000 0.800714 -0.599017 -vn 0.000000 0.330729 -0.943693 -vn 0.000000 0.999664 0.025636 -vn 0.000000 -0.271462 -0.962432 -vn -0.685293 -0.583148 -0.436232 -vn -0.907224 0.252602 -0.336253 -vn 0.907224 0.252602 -0.336253 -vn 0.685293 -0.583148 -0.436232 -vn 0.000000 -0.984344 -0.176214 -vn 0.000000 -0.736351 -0.676565 -vn 0.000000 -0.948759 -0.315928 -vn 0.000000 -0.648244 -0.761406 -vn -0.317362 -0.946959 -0.049959 -vn -0.838282 -0.408155 0.361461 -vn 0.838282 -0.408155 0.361461 -vn 0.317362 -0.946959 -0.049959 -vn -0.939360 0.325999 0.106113 -vn 0.939360 0.325999 0.106113 -vn -0.930631 0.340159 0.134770 -vn -0.960143 0.231361 0.156774 -vn 0.960143 0.231361 0.156774 -vn 0.930631 0.340159 0.134770 -vn -0.812555 -0.001068 -0.582842 -vn -0.979583 0.093387 0.177862 -vn 0.979583 0.093387 0.177862 -vn 0.812555 -0.001068 -0.582842 -vn -0.272530 -0.301157 -0.913785 -vn 0.272530 -0.301157 -0.913785 -vn -0.090915 -0.776330 -0.623707 -vn -0.506851 -0.488144 -0.710471 -vn -0.142521 -0.147282 -0.978759 -vn -0.637257 0.093326 -0.764946 -vn 0.637257 0.093326 -0.764946 -vn 0.506851 -0.488144 -0.710471 -vn 0.142521 -0.147282 -0.978759 -vn 0.090915 -0.776330 -0.623707 -vn -0.937284 -0.254250 0.238350 -vn 0.937284 -0.254250 0.238350 -vn -0.430525 -0.895260 0.114597 -vn 0.430525 -0.895260 0.114597 -vn -0.158391 -0.974822 0.156774 -vn 0.158391 -0.974822 0.156774 -vn 0.000000 -0.915860 -0.401440 -vn 0.000000 -0.946440 0.322855 -vn 0.000000 -0.336802 -0.941557 -vn 0.000000 -0.175726 -0.984436 -vn -0.599231 -0.773980 0.204566 -vn 0.599231 -0.773980 0.204566 -vn -0.890988 -0.423261 -0.164037 -vn 0.890988 -0.423261 -0.164037 -vn -0.851985 0.219275 0.475387 -vn 0.851985 0.219275 0.475387 -vn -0.509171 0.852229 0.119999 -vn 0.509171 0.852229 0.119999 -vn -0.610431 0.759148 0.225867 -vn 0.610431 0.759148 0.225867 -vn -0.182470 0.981780 0.052492 -vn 0.182470 0.981780 0.052492 -vn 0.520371 0.770348 0.368389 -vn -0.520371 0.770348 0.368389 -vn 0.852718 0.504257 0.136204 -vn -0.852718 0.504257 0.136204 -vn 0.000000 0.970214 0.242164 -vn -0.709647 0.261818 0.654042 -vn 0.067293 -0.064272 0.995636 -vn -0.246590 -0.034089 0.968505 -vn -0.809717 -0.010224 0.586688 -vn 0.246590 -0.034089 0.968505 -vn -0.067293 -0.064272 0.995636 -vn 0.709647 0.261818 0.654042 -vn 0.809717 -0.010224 0.586688 -vn -0.465835 -0.080325 0.881191 -vn -0.737114 -0.244179 0.630085 -vn 0.465835 -0.080325 0.881191 -vn 0.737114 -0.244179 0.630085 -vn -0.211951 -0.085971 0.973479 -vn -0.367504 -0.376476 0.850398 -vn 0.211951 -0.085971 0.973479 -vn 0.367504 -0.376476 0.850398 -vn -0.430280 0.556597 0.710624 -vn -0.020081 -0.072939 0.997131 -vn 0.020081 -0.072939 0.997131 -vn 0.430280 0.556597 0.710624 -vn -0.090976 0.597339 0.796777 -vn -0.187933 -0.091617 0.977874 -vn 0.187933 -0.091617 0.977874 -vn 0.090976 0.597339 0.796777 -vn 0.165929 0.609363 0.775292 -vn -0.203314 0.092532 0.974700 -vn 0.203314 0.092532 0.974700 -vn -0.165929 0.609363 0.775292 -vn 0.269295 0.241676 0.932218 -vn -0.314219 -0.132420 0.940062 -vn 0.314219 -0.132420 0.940062 -vn -0.269295 0.241676 0.932218 -vn 0.420057 -0.118992 0.899625 -vn -0.119755 -0.070925 0.990234 -vn 0.119755 -0.070925 0.990234 -vn -0.420057 -0.118992 0.899625 -vn 0.226142 -0.606586 0.762139 -vn -0.320841 0.040712 0.946226 -vn 0.320841 0.040712 0.946226 -vn -0.226142 -0.606586 0.762139 -vn 0.232612 -0.746055 0.623890 -vn -0.074557 -0.391644 0.917081 -vn 0.074557 -0.391644 0.917081 -vn -0.232612 -0.746055 0.623890 -vn -0.121250 -0.313883 0.941679 -vn -0.146702 -0.035707 0.988525 -vn 0.146702 -0.035707 0.988525 -vn 0.121250 -0.313883 0.941679 -vn -0.216834 -0.273721 0.937010 -vn -0.187445 0.001160 0.982269 -vn 0.187445 0.001160 0.982269 -vn 0.216834 -0.273721 0.937010 -vn -0.303018 -0.201941 0.931333 -vn -0.253090 -0.161809 0.953795 -vn 0.253090 -0.161809 0.953795 -vn 0.303018 -0.201941 0.931333 -vn -0.140110 -0.091189 0.985900 -vn 0.140110 -0.091189 0.985900 -vn -0.237983 0.050172 0.969939 -vn 0.237983 0.050172 0.969939 -vn -0.312662 -0.237922 0.919553 -vn 0.312662 -0.237922 0.919553 -vn -0.373791 -0.105197 0.921506 -vn 0.373791 -0.105197 0.921506 -vn -0.470595 -0.164647 0.866817 -vn 0.470595 -0.164647 0.866817 -vn -0.439222 -0.376141 0.815821 -vn 0.439222 -0.376141 0.815821 -vn -0.219611 -0.540635 0.812037 -vn 0.219611 -0.540635 0.812037 -vn 0.166967 -0.374828 0.911893 -vn -0.166967 -0.374828 0.911893 -vn 0.201849 -0.277596 0.939238 -vn -0.201849 -0.277596 0.939238 -vn 0.001160 -0.165563 0.986175 -vn -0.001160 -0.165563 0.986175 -vn 0.292917 -0.174108 0.940123 -vn -0.292917 -0.174108 0.940123 -vn 0.000000 0.732200 0.681051 -vn 0.000000 -0.603626 0.797266 -vn 0.000000 -0.971740 0.235908 -vn 0.131779 -0.608295 0.782678 -vn -0.131779 -0.608295 0.782678 -vn 0.759117 0.068392 0.647298 -vn -0.759117 0.068392 0.647298 -vn 0.405957 0.643605 0.648793 -vn -0.405957 0.643605 0.648793 -vn 0.000000 0.598346 0.801202 -vn 0.073855 -0.330546 0.940855 -vn 0.000000 -0.124516 0.992187 -vn -0.073855 -0.330546 0.940855 -vn -0.085116 -0.339244 0.936827 -vn 0.085116 -0.339244 0.936827 -vn -0.141881 -0.148350 0.978698 -vn 0.141881 -0.148350 0.978698 -vn 0.000000 -0.482803 0.875698 -vn -0.692984 -0.001343 0.720908 -vn -0.095523 -0.326090 0.940489 -vn 0.095523 -0.326090 0.940489 -vn 0.692984 -0.001343 0.720908 -vn -0.646687 0.162603 0.745201 -vn 0.646687 0.162603 0.745201 -vn -0.593463 0.121860 0.795556 -vn 0.593463 0.121860 0.795556 -vn -0.124363 0.009674 0.992187 -vn -0.509995 -0.457717 0.728233 -vn 0.509995 -0.457717 0.728233 -vn 0.124363 0.009674 0.992187 -vn -0.972137 -0.167882 0.163549 -vn 0.972137 -0.167882 0.163549 -vn -0.715995 0.572161 0.399945 -vn 0.715995 0.572161 0.399945 -vn 0.000000 0.430525 0.902554 -vn 0.000000 0.010865 0.999939 -vn -0.221839 -0.606037 0.763848 -vn 0.000000 -0.492935 0.870022 -vn 0.000000 0.010315 0.999939 -vn -0.294320 -0.184484 0.937712 -vn 0.221839 -0.606037 0.763848 -vn 0.294320 -0.184484 0.937712 -vn -0.396924 0.534989 0.745781 -vn 0.247780 0.568224 0.784661 -vn -0.247780 0.568224 0.784661 -vn 0.396924 0.534989 0.745781 -vn -0.868221 -0.261330 0.421735 -vn -0.555986 -0.690695 0.462355 -vn 0.868221 -0.261330 0.421735 -vn 0.555986 -0.690695 0.462355 -vn -0.753075 0.649892 0.102298 -vn 0.753075 0.649892 0.102298 -vn 0.194189 0.935697 0.294473 -vn -0.194189 0.935697 0.294473 -vn 0.000000 0.788965 0.614399 -vn 0.000000 -0.888638 0.458571 -vn 0.000000 -0.336772 0.941557 -vn 0.000000 -0.251991 0.967711 -vn -0.188360 -0.040132 0.981262 -vn 0.000000 -0.032899 0.999451 -vn 0.188360 -0.040132 0.981262 -vn 0.000000 0.000000 1.000000 -vn -0.572039 -0.018708 0.820002 -vn -0.536332 -0.212409 0.816828 -vn 0.536332 -0.212409 0.816828 -vn 0.572039 -0.018708 0.820002 -vn -0.357707 -0.638325 0.681570 -vn 0.357707 -0.638325 0.681570 -vn -0.154302 -0.754112 0.638325 -vn 0.154302 -0.754112 0.638325 -vn 0.000000 -0.743461 0.668752 -vn 0.000000 -0.189123 0.981933 -vn 0.000000 -0.114475 0.993408 -vn 0.001404 -0.055635 0.998444 -vn -0.001404 -0.055635 0.998444 -vn -0.336283 -0.512833 0.789850 -vn 0.336283 -0.512833 0.789850 -vn -0.454543 -0.337077 0.824458 -vn 0.454543 -0.337077 0.824458 -vn -0.543474 -0.308603 0.780602 -vn 0.543474 -0.308603 0.780602 -vn -0.387158 -0.187811 0.902646 -vn 0.387158 -0.187811 0.902646 -vn -0.430647 -0.144902 0.890805 -vn 0.430647 -0.144902 0.890805 -vn -0.234016 -0.120548 0.964721 -vn 0.234016 -0.120548 0.964721 -vn -0.263833 0.168798 0.949675 -vn 0.263833 0.168798 0.949675 -vn 0.196722 0.141881 0.970122 -vn -0.196722 0.141881 0.970122 -vn -0.906766 -0.008332 0.421522 -vn -0.744133 -0.640919 0.188269 -vn 0.744133 -0.640919 0.188269 -vn 0.906766 -0.008332 0.421522 -vn -0.044191 -0.974395 0.220313 -vn 0.044191 -0.974395 0.220313 -vn 0.639943 -0.761498 0.102786 -vn -0.639943 -0.761498 0.102786 -vn 0.955504 -0.011444 0.294717 -vn -0.955504 -0.011444 0.294717 -vn 0.649678 0.754387 0.093570 -vn -0.649678 0.754387 0.093570 -vn -0.037049 0.978881 0.200903 -vn 0.037049 0.978881 0.200903 -vn -0.752342 0.635395 0.173742 -vn 0.752342 0.635395 0.173742 -vn -0.811792 -0.002777 0.583880 -vn -0.596942 0.486770 0.637684 -vn 0.596942 0.486770 0.637684 -vn 0.811792 -0.002777 0.583880 -vn -0.868221 -0.005829 0.496109 -vn -0.719504 0.473006 0.508469 -vn 0.719504 0.473006 0.508469 -vn 0.868221 -0.005829 0.496109 -vn -0.204260 0.828761 0.520951 -vn -0.095767 0.717277 0.690146 -vn 0.095767 0.717277 0.690146 -vn 0.204260 0.828761 0.520951 -vn 0.451704 0.459883 0.764458 -vn -0.451704 0.459883 0.764458 -vn 0.450362 0.693899 0.561815 -vn -0.450362 0.693899 0.561815 -vn 0.805536 0.109409 0.582324 -vn 0.691488 -0.074099 0.718558 -vn -0.691488 -0.074099 0.718558 -vn -0.805536 0.109409 0.582324 -vn 0.386212 -0.474685 0.790857 -vn -0.386212 -0.474685 0.790857 -vn 0.557756 -0.629109 0.541368 -vn -0.557756 -0.629109 0.541368 -vn -0.091159 -0.723716 0.684011 -vn -0.199744 -0.858058 0.473067 -vn 0.091159 -0.723716 0.684011 -vn 0.199744 -0.858058 0.473067 -vn -0.597949 -0.496475 0.629231 -vn 0.597949 -0.496475 0.629231 -vn -0.723197 -0.488907 0.487747 -vn 0.723197 -0.488907 0.487747 -usemtl Material_ray.png -s 1 -f 61/1/1 65/2/2 49/3/3 -f 50/4/4 66/5/5 62/6/6 -f 63/7/7 65/2/2 61/1/1 -f 62/6/6 66/5/5 64/8/8 -f 61/1/1 59/9/9 63/7/7 -f 64/8/8 60/10/10 62/6/6 -f 61/1/1 57/11/11 59/9/9 -f 60/10/10 58/12/12 62/6/6 -f 61/1/1 55/13/13 57/11/11 -f 58/12/12 56/14/14 62/6/6 -f 61/1/1 53/15/15 55/13/13 -f 56/14/14 54/16/16 62/6/6 -f 61/1/1 51/17/17 53/15/15 -f 54/16/16 52/18/18 62/6/6 -f 61/1/1 49/3/3 51/17/17 -f 52/18/18 50/4/4 62/6/6 -f 225/19/19 229/20/20 227/21/21 -f 228/22/22 230/23/23 226/24/24 -f 73/25/25 284/26/26 74/27/27 -f 74/28/27 285/29/28 73/30/25 -f 342/31/29 348/32/30 384/33/31 -f 385/34/32 349/35/33 343/36/34 -f 300/37/35 346/38/36 344/39/37 -f 345/40/38 347/41/39 301/42/40 -f 324/43/41 380/44/42 352/45/43 -f 353/46/44 381/47/45 325/48/46 -f 442/49/47 444/50/48 446/51/49 -f 447/52/50 445/53/51 443/54/52 -f 464/55/53 492/56/54 466/57/55 -f 467/58/56 493/59/57 465/60/58 -f 496/61/59 498/62/60 500/63/61 -f 501/64/62 499/65/63 497/66/64 -f 505/67/65 323/68/66 321/69/67 -f 505/67/65 321/69/67 391/70/68 -f 320/71/69 322/72/70 504/73/71 -f 320/71/69 504/73/71 390/74/72 -f 505/67/65 507/75/73 315/76/74 -f 505/67/65 315/76/74 323/68/66 -f 314/77/75 506/78/76 504/73/71 -f 314/77/75 504/73/71 322/72/70 -f 389/79/77 383/80/78 507/75/73 -f 383/80/78 315/76/74 507/75/73 -f 314/77/75 382/81/79 506/78/76 -f 382/81/79 388/82/80 506/78/76 -f 501/64/62 497/66/64 495/83/81 -f 501/64/62 495/83/81 503/84/82 -f 494/85/83 496/61/59 500/63/61 -f 494/85/83 500/63/61 502/86/84 -f 505/67/65 503/84/82 507/75/73 -f 503/84/82 495/83/81 507/75/73 -f 494/85/83 502/86/84 506/78/76 -f 502/86/84 504/73/71 506/78/76 -f 495/83/81 401/87/85 507/75/73 -f 401/87/85 389/79/77 507/75/73 -f 388/82/80 400/88/86 506/78/76 -f 400/88/86 494/85/83 506/78/76 -f 497/66/64 399/89/87 495/83/81 -f 399/89/87 401/87/85 495/83/81 -f 400/88/86 398/90/88 494/85/83 -f 398/90/88 496/61/59 494/85/83 -f 499/65/63 397/91/89 497/66/64 -f 397/91/89 399/89/87 497/66/64 -f 398/90/88 396/92/90 496/61/59 -f 396/92/90 498/62/60 496/61/59 -f 501/64/62 395/93/91 499/65/63 -f 395/93/91 397/91/89 499/65/63 -f 396/92/90 394/94/92 498/62/60 -f 394/94/92 500/63/61 498/62/60 -f 503/84/82 393/95/93 395/93/91 -f 503/84/82 395/93/91 501/64/62 -f 394/94/92 392/96/94 502/86/84 -f 394/94/92 502/86/84 500/63/61 -f 505/67/65 391/70/68 393/95/93 -f 505/67/65 393/95/93 503/84/82 -f 392/96/94 390/74/72 504/73/71 -f 392/96/94 504/73/71 502/86/84 -f 491/97/95 493/59/57 467/58/56 -f 491/97/95 467/58/56 469/98/96 -f 466/57/55 492/56/54 490/99/97 -f 466/57/55 490/99/97 468/100/98 -f 489/101/99 491/97/95 471/102/100 -f 491/97/95 469/98/96 471/102/100 -f 468/100/98 490/99/97 470/103/101 -f 490/99/97 488/104/102 470/103/101 -f 483/105/103 489/101/99 473/106/104 -f 489/101/99 471/102/100 473/106/104 -f 470/103/101 488/104/102 472/107/105 -f 488/104/102 482/108/106 472/107/105 -f 481/109/107 483/105/103 473/106/104 -f 481/109/107 473/106/104 475/110/108 -f 472/107/105 482/108/106 480/111/109 -f 472/107/105 480/111/109 474/112/110 -f 481/109/107 475/110/108 457/113/111 -f 475/110/108 455/114/112 457/113/111 -f 454/115/113 474/112/110 456/116/114 -f 474/112/110 480/111/109 456/116/114 -f 463/117/115 479/118/116 459/119/117 -f 463/117/115 459/119/117 461/120/118 -f 458/121/119 478/122/120 462/123/121 -f 458/121/119 462/123/121 460/124/122 -f 479/118/116 463/117/115 485/125/123 -f 463/117/115 453/126/124 485/125/123 -f 452/127/125 462/123/121 484/128/126 -f 462/123/121 478/122/120 484/128/126 -f 487/129/127 485/125/123 477/130/128 -f 485/125/123 453/126/124 477/130/128 -f 452/127/125 484/128/126 476/131/129 -f 484/128/126 486/132/130 476/131/129 -f 487/129/127 477/130/128 465/60/58 -f 487/129/127 465/60/58 493/59/57 -f 464/55/53 476/131/129 486/132/130 -f 464/55/53 486/132/130 492/56/54 -f 491/97/95 489/101/99 493/59/57 -f 489/101/99 487/129/127 493/59/57 -f 486/132/130 488/104/102 492/56/54 -f 488/104/102 490/99/97 492/56/54 -f 489/101/99 483/105/103 485/125/123 -f 489/101/99 485/125/123 487/129/127 -f 484/128/126 482/108/106 488/104/102 -f 484/128/126 488/104/102 486/132/130 -f 483/105/103 481/109/107 485/125/123 -f 481/109/107 479/118/116 485/125/123 -f 478/122/120 480/111/109 484/128/126 -f 480/111/109 482/108/106 484/128/126 -f 481/109/107 457/113/111 479/118/116 -f 457/113/111 459/119/117 479/118/116 -f 458/121/119 456/116/114 478/122/120 -f 456/116/114 480/111/109 478/122/120 -f 473/106/104 421/133/131 475/110/108 -f 421/133/131 419/134/132 475/110/108 -f 418/135/133 420/136/134 474/112/110 -f 420/136/134 472/107/105 474/112/110 -f 471/102/100 423/137/135 473/106/104 -f 423/137/135 421/133/131 473/106/104 -f 420/136/134 422/138/136 472/107/105 -f 422/138/136 470/103/101 472/107/105 -f 469/98/96 425/139/137 471/102/100 -f 425/139/137 423/137/135 471/102/100 -f 422/138/136 424/140/138 470/103/101 -f 424/140/138 468/100/98 470/103/101 -f 467/58/56 427/141/139 425/139/137 -f 467/58/56 425/139/137 469/98/96 -f 424/140/138 426/142/140 466/57/55 -f 424/140/138 466/57/55 468/100/98 -f 465/60/58 429/143/141 427/141/139 -f 465/60/58 427/141/139 467/58/56 -f 426/142/140 428/144/142 464/55/53 -f 426/142/140 464/55/53 466/57/55 -f 477/130/128 417/145/143 429/143/141 -f 477/130/128 429/143/141 465/60/58 -f 428/144/142 416/146/144 476/131/129 -f 428/144/142 476/131/129 464/55/53 -f 475/110/108 419/134/132 441/147/145 -f 475/110/108 441/147/145 455/114/112 -f 440/148/146 418/135/133 474/112/110 -f 440/148/146 474/112/110 454/115/113 -f 455/114/112 441/147/145 439/149/147 -f 455/114/112 439/149/147 457/113/111 -f 438/150/148 440/148/146 454/115/113 -f 438/150/148 454/115/113 456/116/114 -f 457/113/111 439/149/147 459/119/117 -f 439/149/147 437/151/149 459/119/117 -f 436/152/150 438/150/148 458/121/119 -f 438/150/148 456/116/114 458/121/119 -f 459/119/117 437/151/149 461/120/118 -f 437/151/149 435/153/151 461/120/118 -f 434/154/152 436/152/150 460/124/122 -f 436/152/150 458/121/119 460/124/122 -f 461/120/118 435/153/151 433/155/153 -f 461/120/118 433/155/153 463/117/115 -f 432/156/154 434/154/152 460/124/122 -f 432/156/154 460/124/122 462/123/121 -f 463/117/115 433/155/153 453/126/124 -f 433/155/153 451/157/155 453/126/124 -f 450/158/156 432/156/154 452/127/125 -f 432/156/154 462/123/121 452/127/125 -f 453/126/124 451/157/155 417/145/143 -f 453/126/124 417/145/143 477/130/128 -f 416/146/144 450/158/156 452/127/125 -f 416/146/144 452/127/125 476/131/129 -f 447/52/50 443/54/52 449/159/157 -f 443/54/52 313/160/158 449/159/157 -f 312/161/159 442/49/47 448/162/160 -f 442/49/47 446/51/49 448/162/160 -f 431/163/161 449/159/157 383/80/78 -f 449/159/157 313/160/158 383/80/78 -f 312/161/159 448/162/160 382/164/79 -f 448/162/160 430/165/162 382/164/79 -f 451/157/155 431/163/161 417/145/143 -f 431/163/161 415/166/163 417/145/143 -f 414/167/164 430/165/162 416/146/144 -f 430/165/162 450/158/156 416/146/144 -f 433/155/153 449/159/157 451/157/155 -f 449/159/157 431/163/161 451/157/155 -f 430/165/162 448/162/160 450/158/156 -f 448/162/160 432/156/154 450/158/156 -f 447/52/50 449/159/157 435/153/151 -f 449/159/157 433/155/153 435/153/151 -f 432/156/154 448/162/160 434/154/152 -f 448/162/160 446/51/49 434/154/152 -f 439/149/147 447/52/50 435/153/151 -f 439/149/147 435/153/151 437/151/149 -f 434/154/152 446/51/49 438/150/148 -f 434/154/152 438/150/148 436/152/150 -f 445/53/51 447/52/50 441/147/145 -f 447/52/50 439/149/147 441/147/145 -f 438/150/148 446/51/49 440/148/146 -f 446/51/49 444/50/48 440/148/146 -f 441/147/145 419/134/132 413/168/165 -f 441/147/145 413/168/165 445/53/51 -f 412/169/166 418/135/133 440/148/146 -f 412/169/166 440/148/146 444/50/48 -f 415/166/163 431/163/161 383/80/78 -f 415/166/163 383/80/78 389/79/77 -f 382/164/79 430/165/162 414/167/164 -f 382/164/79 414/167/164 388/170/80 -f 443/171/52 319/172/167 311/173/168 -f 443/171/52 311/173/168 313/174/158 -f 310/175/169 318/176/170 442/177/47 -f 310/175/169 442/177/47 312/178/159 -f 413/168/165 391/179/68 445/53/51 -f 391/179/68 321/180/67 445/53/51 -f 320/181/69 390/182/72 444/50/48 -f 390/182/72 412/169/166 444/50/48 -f 445/53/51 321/180/67 443/54/52 -f 321/183/67 319/172/167 443/171/52 -f 318/176/170 320/184/69 442/177/47 -f 320/181/69 444/50/48 442/49/47 -f 417/145/143 415/166/163 403/185/171 -f 417/145/143 403/185/171 429/143/141 -f 402/186/172 414/167/164 416/146/144 -f 402/186/172 416/146/144 428/144/142 -f 427/141/139 429/143/141 405/187/173 -f 429/143/141 403/185/171 405/187/173 -f 402/186/172 428/144/142 404/188/174 -f 428/144/142 426/142/140 404/188/174 -f 425/139/137 427/141/139 407/189/175 -f 427/141/139 405/187/173 407/189/175 -f 404/188/174 426/142/140 406/190/176 -f 426/142/140 424/140/138 406/190/176 -f 423/137/135 425/139/137 409/191/177 -f 425/139/137 407/189/175 409/191/177 -f 406/190/176 424/140/138 408/192/178 -f 424/140/138 422/138/136 408/192/178 -f 421/133/131 423/137/135 409/191/177 -f 421/133/131 409/191/177 411/193/179 -f 408/192/178 422/138/136 420/136/134 -f 408/192/178 420/136/134 410/194/180 -f 419/134/132 421/133/131 411/193/179 -f 419/134/132 411/193/179 413/168/165 -f 410/194/180 420/136/134 418/135/133 -f 410/194/180 418/135/133 412/169/166 -f 413/168/165 411/193/179 393/195/93 -f 413/168/165 393/195/93 391/179/68 -f 392/196/94 410/194/180 412/169/166 -f 392/196/94 412/169/166 390/182/72 -f 411/193/179 409/191/177 393/195/93 -f 409/191/177 395/197/91 393/195/93 -f 394/198/92 408/192/178 392/196/94 -f 408/192/178 410/194/180 392/196/94 -f 409/191/177 407/189/175 395/197/91 -f 407/189/175 397/199/89 395/197/91 -f 396/200/90 406/190/176 394/198/92 -f 406/190/176 408/192/178 394/198/92 -f 407/189/175 405/187/173 397/199/89 -f 405/187/173 399/89/87 397/199/89 -f 398/201/88 404/188/174 396/200/90 -f 404/188/174 406/190/176 396/200/90 -f 405/187/173 403/185/171 401/87/85 -f 405/187/173 401/87/85 399/89/87 -f 400/202/86 402/186/172 404/188/174 -f 400/202/86 404/188/174 398/201/88 -f 415/166/163 389/79/77 403/185/171 -f 389/79/77 401/87/85 403/185/171 -f 400/202/86 388/170/80 402/186/172 -f 388/170/80 414/167/164 402/186/172 -f 381/47/45 353/46/44 387/203/181 -f 353/46/44 351/204/182 387/203/181 -f 350/205/183 352/45/43 386/206/184 -f 352/45/43 380/44/42 386/206/184 -f 381/47/45 387/203/181 323/207/66 -f 387/203/181 321/183/67 323/207/66 -f 320/184/69 386/206/184 322/208/70 -f 386/206/184 380/44/42 322/208/70 -f 381/47/45 379/209/185 325/48/46 -f 379/209/185 317/210/186 325/48/46 -f 316/211/187 378/212/188 324/43/41 -f 378/212/188 380/44/42 324/43/41 -f 381/47/45 323/207/66 379/209/185 -f 323/207/66 315/213/74 379/209/185 -f 314/214/75 322/208/70 378/212/188 -f 322/208/70 380/44/42 378/212/188 -f 343/36/34 345/40/38 301/42/40 -f 343/36/34 301/42/40 385/34/32 -f 300/37/35 344/39/37 342/31/29 -f 300/37/35 342/31/29 384/33/31 -f 385/34/32 301/42/40 299/215/189 -f 385/34/32 299/215/189 319/172/167 -f 298/216/190 300/37/35 384/33/31 -f 298/216/190 384/33/31 318/176/170 -f 387/203/181 385/34/32 321/183/67 -f 385/34/32 319/172/167 321/183/67 -f 318/176/170 384/33/31 320/184/69 -f 384/33/31 386/206/184 320/184/69 -f 387/203/181 351/204/182 385/34/32 -f 351/204/182 349/35/33 385/34/32 -f 348/32/30 350/205/183 384/33/31 -f 350/205/183 386/206/184 384/33/31 -f 371/217/191 377/218/192 383/219/78 -f 377/218/192 315/213/74 383/219/78 -f 314/214/75 376/220/193 382/221/79 -f 376/220/193 370/222/194 382/221/79 -f 371/217/191 383/219/78 313/174/158 -f 371/217/191 313/174/158 369/223/195 -f 312/178/159 382/221/79 370/222/194 -f 312/178/159 370/222/194 368/224/196 -f 369/223/195 313/174/158 311/173/168 -f 369/223/195 311/173/168 363/225/197 -f 310/175/169 312/178/159 368/224/196 -f 310/175/169 368/224/196 362/226/198 -f 311/173/168 297/227/199 363/225/197 -f 297/227/199 295/228/200 363/225/197 -f 294/229/201 296/230/202 362/226/198 -f 296/230/202 310/175/169 362/226/198 -f 361/231/203 291/232/204 285/29/28 -f 361/231/203 285/29/28 74/28/27 -f 284/26/26 290/233/205 360/234/206 -f 284/26/26 360/234/206 74/27/27 -f 289/235/207 287/236/208 291/232/204 -f 287/236/208 285/29/28 291/232/204 -f 284/26/26 286/237/209 290/233/205 -f 286/237/209 288/238/210 290/233/205 -f 359/239/211 361/231/203 302/240/212 -f 361/231/203 74/28/27 302/240/212 -f 74/27/27 360/234/206 302/241/212 -f 360/234/206 358/242/213 302/241/212 -f 365/243/214 293/244/215 361/231/203 -f 293/244/215 291/232/204 361/231/203 -f 290/233/205 292/245/216 360/234/206 -f 292/245/216 364/246/217 360/234/206 -f 365/243/214 361/231/203 359/239/211 -f 365/243/214 359/239/211 367/247/218 -f 358/242/213 360/234/206 364/246/217 -f 358/242/213 364/246/217 366/248/219 -f 367/247/218 359/239/211 357/249/220 -f 367/247/218 357/249/220 373/250/221 -f 356/251/222 358/242/213 366/248/219 -f 356/251/222 366/248/219 372/252/223 -f 373/250/221 357/249/220 355/253/224 -f 373/250/221 355/253/224 375/254/225 -f 354/255/226 356/251/222 372/252/223 -f 354/255/226 372/252/223 374/256/227 -f 375/254/225 355/253/224 317/210/186 -f 375/254/225 317/210/186 379/209/185 -f 316/211/187 354/255/226 374/256/227 -f 316/211/187 374/256/227 378/212/188 -f 375/254/225 379/209/185 377/218/192 -f 379/209/185 315/213/74 377/218/192 -f 314/214/75 378/212/188 376/220/193 -f 378/212/188 374/256/227 376/220/193 -f 377/218/192 371/217/191 373/250/221 -f 377/218/192 373/250/221 375/254/225 -f 372/252/223 370/222/194 376/220/193 -f 372/252/223 376/220/193 374/256/227 -f 371/217/191 369/223/195 367/247/218 -f 371/217/191 367/247/218 373/250/221 -f 366/248/219 368/224/196 370/222/194 -f 366/248/219 370/222/194 372/252/223 -f 369/223/195 363/225/197 365/243/214 -f 369/223/195 365/243/214 367/247/218 -f 364/246/217 362/226/198 368/224/196 -f 364/246/217 368/224/196 366/248/219 -f 363/225/197 295/228/200 293/244/215 -f 363/225/197 293/244/215 365/243/214 -f 292/245/216 294/229/201 362/226/198 -f 292/245/216 362/226/198 364/246/217 -f 317/210/186 355/253/224 75/257/228 -f 317/210/186 75/257/228 76/258/229 -f 75/259/228 354/255/226 316/211/187 -f 75/259/228 316/211/187 76/260/229 -f 355/253/224 357/249/220 303/261/230 -f 355/253/224 303/261/230 75/257/228 -f 303/262/230 356/251/222 354/255/226 -f 303/262/230 354/255/226 75/259/228 -f 357/249/220 359/239/211 303/261/230 -f 359/239/211 302/240/212 303/261/230 -f 302/241/212 358/242/213 303/262/230 -f 358/242/213 356/251/222 303/262/230 -f 325/48/46 317/210/186 77/263/231 -f 317/210/186 76/258/229 77/263/231 -f 76/260/229 316/211/187 77/264/231 -f 316/211/187 324/43/41 77/264/231 -f 319/172/167 299/215/189 297/227/199 -f 319/172/167 297/227/199 311/173/168 -f 296/230/202 298/216/190 318/176/170 -f 296/230/202 318/176/170 310/175/169 -f 349/35/33 329/265/232 343/36/34 -f 329/265/232 327/266/233 343/36/34 -f 326/267/234 328/268/235 342/31/29 -f 328/268/235 348/32/30 342/31/29 -f 329/265/232 349/35/33 305/269/236 -f 329/265/232 305/269/236 309/270/237 -f 305/271/236 348/32/30 328/268/235 -f 305/271/236 328/268/235 309/272/237 -f 349/35/33 351/204/182 78/273/238 -f 349/35/33 78/273/238 305/269/236 -f 78/274/238 350/205/183 348/32/30 -f 78/274/238 348/32/30 305/271/236 -f 351/204/182 353/46/44 78/273/238 -f 353/46/44 304/275/239 78/273/238 -f 304/276/239 352/45/43 78/274/238 -f 352/45/43 350/205/183 78/274/238 -f 353/46/44 325/48/46 304/275/239 -f 325/48/46 77/263/231 304/275/239 -f 77/264/231 324/43/41 304/276/239 -f 324/43/41 352/45/43 304/276/239 -f 301/42/40 347/41/39 93/277/240 -f 347/278/39 80/279/241 93/280/240 -f 79/281/242 346/282/36 92/283/243 -f 346/38/36 300/37/35 92/284/243 -f 345/40/38 216/285/244 347/41/39 -f 216/286/244 80/279/241 347/278/39 -f 79/281/242 215/287/245 346/282/36 -f 215/288/245 344/39/37 346/38/36 -f 343/36/34 327/266/233 210/289/246 -f 327/266/233 82/290/247 210/289/246 -f 81/291/248 326/267/234 209/292/249 -f 326/267/234 342/31/29 209/292/249 -f 345/40/38 343/36/34 216/285/244 -f 343/36/34 210/289/246 216/285/244 -f 209/292/249 342/31/29 215/288/245 -f 342/31/29 344/39/37 215/288/245 -f 333/293/250 84/294/251 82/290/247 -f 333/293/250 82/290/247 327/266/233 -f 81/291/248 83/295/252 332/296/253 -f 81/291/248 332/296/253 326/267/234 -f 339/297/254 333/293/250 329/265/232 -f 333/293/250 327/266/233 329/265/232 -f 326/267/234 332/296/253 328/268/235 -f 332/296/253 338/298/255 328/268/235 -f 341/299/256 335/300/257 337/301/258 -f 335/300/257 331/302/259 337/301/258 -f 330/303/260 334/304/261 336/305/262 -f 334/304/261 340/306/263 336/305/262 -f 339/297/254 337/301/258 331/302/259 -f 339/297/254 331/302/259 333/293/250 -f 330/303/260 336/305/262 338/298/255 -f 330/303/260 338/298/255 332/296/253 -f 331/302/259 86/307/264 84/294/251 -f 331/302/259 84/294/251 333/293/250 -f 83/295/252 85/308/265 330/303/260 -f 83/295/252 330/303/260 332/296/253 -f 335/300/257 88/309/266 86/307/264 -f 335/300/257 86/307/264 331/302/259 -f 85/308/265 87/310/267 334/304/261 -f 85/308/265 334/304/261 330/303/260 -f 341/299/256 90/311/268 88/309/266 -f 341/299/256 88/309/266 335/300/257 -f 87/310/267 89/312/269 340/306/263 -f 87/310/267 340/306/263 334/304/261 -f 306/313/270 91/314/271 90/311/268 -f 306/313/270 90/311/268 341/299/256 -f 89/312/269 91/315/271 306/316/270 -f 89/312/269 306/316/270 340/306/263 -f 337/301/258 307/317/272 341/299/256 -f 307/317/272 306/313/270 341/299/256 -f 306/316/270 307/318/272 340/306/263 -f 307/318/272 336/305/262 340/306/263 -f 339/297/254 308/319/273 337/301/258 -f 308/319/273 307/317/272 337/301/258 -f 307/318/272 308/320/273 336/305/262 -f 308/320/273 338/298/255 336/305/262 -f 329/265/232 309/270/237 339/297/254 -f 309/270/237 308/319/273 339/297/254 -f 308/320/273 309/272/237 338/298/255 -f 309/272/237 328/268/235 338/298/255 -f 301/42/40 93/277/240 95/321/274 -f 301/42/40 95/321/274 299/215/189 -f 94/322/275 92/284/243 300/37/35 -f 94/322/275 300/37/35 298/216/190 -f 299/215/189 95/321/274 97/323/276 -f 299/215/189 97/323/276 297/227/199 -f 96/324/277 94/322/275 298/216/190 -f 96/324/277 298/216/190 296/230/202 -f 297/227/199 97/323/276 295/228/200 -f 97/323/276 99/325/278 295/228/200 -f 98/326/279 96/324/277 294/229/201 -f 96/324/277 296/230/202 294/229/201 -f 295/228/200 99/325/278 101/327/280 -f 295/228/200 101/327/280 293/244/215 -f 100/328/281 98/326/279 294/229/201 -f 100/328/281 294/229/201 292/245/216 -f 293/244/215 101/327/280 291/232/204 -f 101/327/280 103/329/282 291/232/204 -f 102/330/283 100/328/281 290/233/205 -f 100/328/281 292/245/216 290/233/205 -f 291/232/204 103/329/282 289/235/207 -f 103/329/282 105/331/284 289/235/207 -f 104/332/285 102/330/283 288/238/210 -f 102/330/283 290/233/205 288/238/210 -f 289/235/207 105/331/284 287/236/208 -f 105/331/284 107/333/286 287/236/208 -f 106/334/287 104/332/285 286/237/209 -f 104/332/285 288/238/210 286/237/209 -f 287/236/208 107/333/286 109/335/288 -f 287/236/208 109/335/288 285/29/28 -f 108/336/289 106/334/287 286/237/209 -f 108/336/289 286/237/209 284/26/26 -f 285/29/28 109/335/288 67/337/290 -f 285/29/28 67/337/290 73/30/25 -f 67/338/290 108/336/289 284/26/26 -f 67/338/290 284/26/26 73/25/25 -f 281/339/291 235/340/292 233/341/293 -f 281/339/291 233/341/293 283/342/294 -f 232/343/295 234/344/296 280/345/297 -f 232/343/295 280/345/297 282/346/298 -f 283/342/294 233/341/293 255/347/299 -f 283/342/294 255/347/299 261/348/300 -f 254/349/301 232/343/295 282/346/298 -f 254/349/301 282/346/298 260/350/302 -f 261/348/300 255/347/299 257/351/303 -f 261/348/300 257/351/303 259/352/304 -f 256/353/305 254/349/301 260/350/302 -f 256/353/305 260/350/302 258/354/306 -f 263/355/307 253/356/308 235/340/292 -f 263/355/307 235/340/292 281/339/291 -f 234/344/296 252/357/309 262/358/310 -f 234/344/296 262/358/310 280/345/297 -f 265/359/311 251/360/312 263/355/307 -f 251/360/312 253/356/308 263/355/307 -f 252/357/309 250/361/313 262/358/310 -f 250/361/313 264/362/314 262/358/310 -f 267/363/315 249/364/316 265/359/311 -f 249/364/316 251/360/312 265/359/311 -f 250/361/313 248/365/317 264/362/314 -f 248/365/317 266/366/318 264/362/314 -f 269/367/319 247/368/320 249/364/316 -f 269/367/319 249/364/316 267/363/315 -f 248/365/317 246/369/321 268/370/322 -f 248/365/317 268/370/322 266/366/318 -f 271/371/323 245/372/324 269/367/319 -f 245/372/324 247/368/320 269/367/319 -f 246/369/321 244/373/325 268/370/322 -f 244/373/325 270/374/326 268/370/322 -f 273/375/327 243/376/328 245/372/324 -f 273/375/327 245/372/324 271/371/323 -f 244/373/325 242/377/329 272/378/330 -f 244/373/325 272/378/330 270/374/326 -f 275/379/331 241/380/332 273/375/327 -f 241/380/332 243/376/328 273/375/327 -f 242/377/329 240/381/333 272/378/330 -f 240/381/333 274/382/334 272/378/330 -f 279/383/335 237/384/336 275/379/331 -f 237/384/336 241/380/332 275/379/331 -f 240/381/333 236/385/337 274/382/334 -f 236/385/337 278/386/338 274/382/334 -f 277/387/339 239/388/340 237/384/336 -f 277/387/339 237/384/336 279/383/335 -f 236/385/337 238/389/341 276/390/342 -f 236/385/337 276/390/342 278/386/338 -f 259/352/304 257/351/303 239/388/340 -f 259/352/304 239/388/340 277/387/339 -f 238/389/341 256/353/305 258/354/306 -f 238/389/341 258/354/306 276/390/342 -f 257/351/303 111/391/343 129/392/344 -f 257/351/303 129/392/344 239/388/340 -f 128/393/345 110/394/346 256/353/305 -f 128/393/345 256/353/305 238/389/341 -f 239/388/340 129/392/344 180/395/347 -f 239/388/340 180/395/347 237/384/336 -f 179/396/348 128/393/345 238/389/341 -f 179/396/348 238/389/341 236/385/337 -f 237/384/336 180/395/347 127/397/349 -f 237/384/336 127/397/349 241/380/332 -f 126/398/350 179/396/348 236/385/337 -f 126/398/350 236/385/337 240/381/333 -f 241/380/332 127/397/349 243/376/328 -f 127/397/349 125/399/351 243/376/328 -f 124/400/352 126/398/350 242/377/329 -f 126/398/350 240/381/333 242/377/329 -f 243/376/328 125/399/351 245/372/324 -f 125/399/351 123/401/353 245/372/324 -f 122/402/354 124/400/352 244/373/325 -f 124/400/352 242/377/329 244/373/325 -f 245/372/324 123/401/353 121/403/355 -f 245/372/324 121/403/355 247/368/320 -f 120/404/356 122/402/354 244/373/325 -f 120/404/356 244/373/325 246/369/321 -f 247/368/320 121/403/355 119/405/357 -f 247/368/320 119/405/357 249/364/316 -f 118/406/358 120/404/356 246/369/321 -f 118/406/358 246/369/321 248/365/317 -f 249/364/316 119/405/357 117/407/359 -f 249/364/316 117/407/359 251/360/312 -f 116/408/360 118/406/358 248/365/317 -f 116/408/360 248/365/317 250/361/313 -f 251/360/312 117/407/359 115/409/361 -f 251/360/312 115/409/361 253/356/308 -f 114/410/362 116/408/360 250/361/313 -f 114/410/362 250/361/313 252/357/309 -f 253/356/308 115/409/361 235/340/292 -f 115/409/361 182/411/363 235/340/292 -f 181/412/364 114/410/362 234/344/296 -f 114/410/362 252/357/309 234/344/296 -f 255/347/299 113/413/365 257/351/303 -f 113/413/365 111/391/343 257/351/303 -f 110/394/346 112/414/366 256/353/305 -f 112/414/366 254/349/301 256/353/305 -f 233/341/293 184/415/367 113/413/365 -f 233/341/293 113/413/365 255/347/299 -f 112/414/366 183/416/368 232/343/295 -f 112/414/366 232/343/295 254/349/301 -f 235/340/292 182/411/363 184/415/367 -f 235/340/292 184/415/367 233/341/293 -f 183/416/368 181/412/364 234/344/296 -f 183/416/368 234/344/296 232/343/295 -f 230/23/23 231/417/369 224/418/370 -f 230/23/23 224/418/370 226/24/24 -f 224/418/370 231/417/369 229/20/20 -f 224/418/370 229/20/20 225/19/19 -f 224/418/370 72/419/371 226/24/24 -f 72/419/371 223/420/372 226/24/24 -f 222/421/373 72/419/371 225/19/19 -f 72/419/371 224/418/370 225/19/19 -f 226/24/24 223/420/372 221/422/374 -f 226/24/24 221/422/374 228/22/22 -f 220/423/375 222/421/373 225/19/19 -f 220/423/375 225/19/19 227/21/21 -f 228/22/22 221/422/374 219/424/376 -f 228/22/22 219/424/376 230/23/23 -f 218/425/377 220/423/375 227/21/21 -f 218/425/377 227/21/21 229/20/20 -f 230/23/23 219/424/376 231/417/369 -f 219/424/376 217/426/378 231/417/369 -f 217/426/378 218/425/377 231/417/369 -f 218/425/377 229/20/20 231/417/369 -f 219/424/376 136/427/379 137/428/380 -f 219/424/376 137/428/380 217/426/378 -f 137/428/380 135/429/381 218/425/377 -f 137/428/380 218/425/377 217/426/378 -f 221/422/374 134/430/382 136/427/379 -f 221/422/374 136/427/379 219/424/376 -f 135/429/381 133/431/383 220/423/375 -f 135/429/381 220/423/375 218/425/377 -f 223/420/372 132/432/384 134/430/382 -f 223/420/372 134/430/382 221/422/374 -f 133/431/383 131/433/385 222/421/373 -f 133/431/383 222/421/373 220/423/375 -f 72/419/371 130/434/386 223/420/372 -f 130/434/386 132/432/384 223/420/372 -f 131/433/385 130/434/386 222/421/373 -f 130/434/386 72/419/371 222/421/373 -f 212/435/387 165/436/388 80/279/241 -f 212/435/387 80/279/241 216/286/244 -f 79/281/242 164/437/389 211/438/390 -f 79/281/242 211/438/390 215/287/245 -f 212/435/387 216/286/244 214/439/391 -f 216/286/244 210/440/246 214/439/391 -f 209/441/249 215/287/245 213/442/392 -f 215/287/245 211/438/390 213/442/392 -f 214/439/391 210/440/246 167/443/393 -f 210/440/246 82/444/247 167/443/393 -f 81/445/248 209/441/249 166/446/394 -f 209/441/249 213/442/392 166/446/394 -f 167/443/393 188/447/395 214/439/391 -f 188/447/395 145/448/396 214/439/391 -f 144/449/397 187/450/398 213/442/392 -f 187/450/398 166/446/394 213/442/392 -f 214/439/391 145/448/396 212/435/387 -f 145/448/396 143/451/399 212/435/387 -f 142/452/400 144/449/397 211/438/390 -f 144/449/397 213/442/392 211/438/390 -f 212/435/387 143/451/399 141/453/401 -f 212/435/387 141/453/401 165/436/388 -f 140/454/402 142/452/400 211/438/390 -f 140/454/402 211/438/390 164/437/389 -f 165/436/388 141/453/401 139/455/403 -f 165/436/388 139/455/403 177/456/404 -f 139/455/403 140/454/402 164/437/389 -f 139/455/403 164/437/389 177/456/404 -f 207/457/405 208/458/406 199/459/407 -f 207/457/405 199/459/407 205/460/408 -f 199/459/407 208/458/406 206/461/409 -f 199/459/407 206/461/409 204/462/410 -f 203/463/411 205/460/408 201/464/412 -f 205/460/408 199/459/407 201/464/412 -f 199/459/407 204/462/410 200/465/413 -f 204/462/410 202/466/414 200/465/413 -f 207/457/405 205/460/408 194/467/415 -f 207/457/405 194/467/415 192/468/416 -f 193/469/417 204/462/410 206/461/409 -f 193/469/417 206/461/409 191/470/418 -f 205/460/408 203/463/411 194/467/415 -f 203/463/411 196/471/419 194/467/415 -f 195/472/420 202/466/414 193/469/417 -f 202/466/414 204/462/410 193/469/417 -f 203/463/411 201/464/412 198/473/421 -f 203/463/411 198/473/421 196/471/419 -f 197/474/422 200/465/413 202/466/414 -f 197/474/422 202/466/414 195/472/420 -f 201/464/412 199/459/407 71/475/423 -f 201/464/412 71/475/423 198/473/421 -f 71/475/423 199/459/407 200/465/413 -f 71/475/423 200/465/413 197/474/422 -f 207/457/405 192/468/416 208/458/406 -f 192/468/416 70/476/424 208/458/406 -f 70/476/424 191/470/418 208/458/406 -f 191/470/418 206/461/409 208/458/406 -f 192/468/416 145/448/396 70/476/424 -f 145/448/396 190/477/425 70/476/424 -f 190/477/425 144/449/397 70/476/424 -f 144/449/397 191/470/418 70/476/424 -f 198/473/421 71/475/423 139/455/403 -f 71/478/423 138/479/426 139/480/403 -f 138/481/426 71/482/423 139/483/403 -f 71/475/423 197/474/422 139/455/403 -f 196/471/419 198/473/421 141/453/401 -f 198/473/421 139/455/403 141/453/401 -f 139/455/403 197/474/422 140/454/402 -f 197/474/422 195/472/420 140/454/402 -f 194/467/415 196/471/419 143/451/399 -f 196/471/419 141/453/401 143/451/399 -f 140/454/402 195/472/420 142/452/400 -f 195/472/420 193/469/417 142/452/400 -f 192/468/416 194/467/415 143/451/399 -f 192/468/416 143/451/399 145/448/396 -f 142/452/400 193/469/417 191/470/418 -f 142/452/400 191/470/418 144/449/397 -f 186/484/427 132/432/384 69/485/428 -f 132/432/384 130/434/386 69/485/428 -f 130/434/386 131/433/385 69/485/428 -f 131/433/385 185/486/429 69/485/428 -f 189/487/430 188/447/395 69/485/428 -f 188/447/395 186/484/427 69/485/428 -f 185/486/429 187/450/398 69/485/428 -f 187/450/398 189/487/430 69/485/428 -f 189/487/430 190/477/425 188/447/395 -f 190/477/425 145/448/396 188/447/395 -f 144/449/397 190/477/425 187/450/398 -f 190/477/425 189/487/430 187/450/398 -f 169/488/431 171/489/432 132/432/384 -f 169/488/431 132/432/384 186/484/427 -f 131/433/385 170/490/433 168/491/434 -f 131/433/385 168/491/434 185/486/429 -f 186/484/427 188/447/395 167/443/393 -f 186/484/427 167/443/393 169/488/431 -f 166/446/394 187/450/398 185/486/429 -f 166/446/394 185/486/429 168/491/434 -f 173/492/435 134/430/382 171/489/432 -f 134/430/382 132/432/384 171/489/432 -f 131/433/385 133/431/383 170/490/433 -f 133/431/383 172/493/436 170/490/433 -f 175/494/437 136/427/379 134/430/382 -f 175/494/437 134/430/382 173/492/435 -f 133/431/383 135/429/381 174/495/438 -f 133/431/383 174/495/438 172/493/436 -f 176/496/439 137/428/380 136/427/379 -f 176/496/439 136/427/379 175/494/437 -f 135/429/381 137/428/380 176/496/439 -f 135/429/381 176/496/439 174/495/438 -f 184/415/367 182/411/363 178/497/440 -f 182/411/363 177/456/404 178/497/440 -f 177/456/404 181/412/364 178/497/440 -f 181/412/364 183/416/368 178/497/440 -f 178/497/440 68/498/441 113/413/365 -f 178/497/440 113/413/365 184/415/367 -f 112/414/366 68/498/441 178/497/440 -f 112/414/366 178/497/440 183/416/368 -f 68/498/441 163/499/442 113/413/365 -f 163/499/442 111/391/343 113/413/365 -f 110/394/346 162/500/443 112/414/366 -f 162/500/443 68/498/441 112/414/366 -f 177/456/404 182/411/363 115/409/361 -f 177/456/404 115/409/361 165/436/388 -f 114/410/362 181/412/364 177/456/404 -f 114/410/362 177/456/404 164/437/389 -f 147/501/444 165/436/388 115/409/361 -f 147/501/444 115/409/361 117/407/359 -f 114/410/362 164/437/389 146/502/445 -f 114/410/362 146/502/445 116/408/360 -f 149/503/446 147/501/444 119/405/357 -f 147/501/444 117/407/359 119/405/357 -f 116/408/360 146/502/445 118/406/358 -f 146/502/445 148/504/447 118/406/358 -f 151/505/448 149/503/446 121/403/355 -f 149/503/446 119/405/357 121/403/355 -f 118/406/358 148/504/447 120/404/356 -f 148/504/447 150/506/449 120/404/356 -f 153/507/450 151/505/448 123/401/353 -f 151/505/448 121/403/355 123/401/353 -f 120/404/356 150/506/449 122/402/354 -f 150/506/449 152/508/451 122/402/354 -f 155/509/452 153/507/450 125/399/351 -f 153/507/450 123/401/353 125/399/351 -f 122/402/354 152/508/451 124/400/352 -f 152/508/451 154/510/453 124/400/352 -f 157/511/454 155/509/452 127/397/349 -f 155/509/452 125/399/351 127/397/349 -f 124/400/352 154/510/453 126/398/350 -f 154/510/453 156/512/455 126/398/350 -f 159/513/456 157/511/454 180/395/347 -f 157/511/454 127/397/349 180/395/347 -f 126/398/350 156/512/455 179/396/348 -f 156/512/455 158/514/457 179/396/348 -f 159/513/456 180/395/347 129/392/344 -f 159/513/456 129/392/344 161/515/458 -f 128/393/345 179/396/348 158/514/457 -f 128/393/345 158/514/457 160/516/459 -f 161/515/458 129/392/344 163/499/442 -f 129/392/344 111/391/343 163/499/442 -f 110/394/346 128/393/345 162/500/443 -f 128/393/345 160/516/459 162/500/443 -f 68/498/441 67/517/290 163/499/442 -f 67/517/290 109/518/288 163/499/442 -f 108/519/289 67/517/290 162/500/443 -f 67/517/290 68/498/441 162/500/443 -f 163/499/442 109/518/288 161/515/458 -f 109/518/288 107/520/286 161/515/458 -f 106/521/287 108/519/289 160/516/459 -f 108/519/289 162/500/443 160/516/459 -f 161/515/458 107/520/286 159/513/456 -f 107/520/286 105/522/284 159/513/456 -f 104/523/285 106/521/287 158/514/457 -f 106/521/287 160/516/459 158/514/457 -f 159/513/456 105/522/284 103/524/282 -f 159/513/456 103/524/282 157/511/454 -f 102/525/283 104/523/285 158/514/457 -f 102/525/283 158/514/457 156/512/455 -f 157/511/454 103/524/282 155/509/452 -f 103/524/282 101/526/280 155/509/452 -f 100/527/281 102/525/283 154/510/453 -f 102/525/283 156/512/455 154/510/453 -f 155/509/452 101/526/280 153/507/450 -f 101/526/280 99/528/278 153/507/450 -f 98/529/279 100/527/281 152/508/451 -f 100/527/281 154/510/453 152/508/451 -f 153/507/450 99/528/278 151/505/448 -f 99/528/278 97/530/276 151/505/448 -f 96/531/277 98/529/279 150/506/449 -f 98/529/279 152/508/451 150/506/449 -f 151/505/448 97/530/276 95/532/274 -f 151/505/448 95/532/274 149/503/446 -f 94/533/275 96/531/277 150/506/449 -f 94/533/275 150/506/449 148/504/447 -f 149/503/446 95/532/274 147/501/444 -f 95/532/274 93/280/240 147/501/444 -f 92/283/243 94/533/275 146/502/445 -f 94/533/275 148/504/447 146/502/445 -f 147/501/444 93/280/240 80/279/241 -f 147/501/444 80/279/241 165/436/388 -f 79/281/242 92/283/243 146/502/445 -f 79/281/242 146/502/445 164/437/389 -f 169/488/431 167/443/393 82/444/247 -f 169/488/431 82/444/247 84/534/251 -f 81/445/248 166/446/394 168/491/434 -f 81/445/248 168/491/434 83/535/252 -f 171/489/432 169/488/431 84/534/251 -f 171/489/432 84/534/251 86/536/264 -f 83/535/252 168/491/434 170/490/433 -f 83/535/252 170/490/433 85/537/265 -f 173/492/435 171/489/432 86/536/264 -f 173/492/435 86/536/264 88/538/266 -f 85/537/265 170/490/433 172/493/436 -f 85/537/265 172/493/436 87/539/267 -f 175/494/437 173/492/435 90/540/268 -f 173/492/435 88/538/266 90/540/268 -f 87/539/267 172/493/436 89/541/269 -f 172/493/436 174/495/438 89/541/269 -f 176/496/439 175/494/437 91/542/271 -f 175/494/437 90/540/268 91/542/271 -f 89/541/269 174/495/438 91/542/271 -f 174/495/438 176/496/439 91/542/271 -f 50/4/4 48/543/460 2/544/461 -f 50/4/4 2/544/461 66/5/5 -f 1/545/462 47/546/463 49/3/3 -f 1/545/462 49/3/3 65/2/2 -f 66/5/5 2/544/461 12/547/464 -f 66/5/5 12/547/464 64/8/8 -f 11/548/465 1/545/462 65/2/2 -f 11/548/465 65/2/2 63/7/7 -f 64/8/8 12/547/464 14/549/466 -f 64/8/8 14/549/466 60/10/10 -f 13/550/467 11/548/465 63/7/7 -f 13/550/467 63/7/7 59/9/9 -f 60/10/10 14/549/466 24/551/468 -f 60/10/10 24/551/468 58/12/12 -f 23/552/469 13/550/467 59/9/9 -f 23/552/469 59/9/9 57/11/11 -f 58/12/12 24/551/468 56/14/14 -f 24/551/468 26/553/470 56/14/14 -f 25/554/471 23/552/469 55/13/13 -f 23/552/469 57/11/11 55/13/13 -f 56/14/14 26/553/470 54/16/16 -f 26/553/470 36/555/472 54/16/16 -f 35/556/473 25/554/471 53/15/15 -f 25/554/471 55/13/13 53/15/15 -f 54/16/16 36/555/472 52/18/18 -f 36/555/472 38/557/474 52/18/18 -f 37/558/475 35/556/473 51/17/17 -f 35/556/473 53/15/15 51/17/17 -f 52/18/18 38/557/474 50/4/4 -f 38/557/474 48/543/460 50/4/4 -f 47/546/463 37/558/475 49/3/3 -f 37/558/475 51/17/17 49/3/3 -f 46/559/476 48/543/460 40/560/477 -f 48/543/460 38/557/474 40/560/477 -f 37/558/475 47/546/463 39/561/478 -f 47/546/463 45/562/479 39/561/478 -f 44/563/480 46/559/476 42/564/481 -f 46/559/476 40/560/477 42/564/481 -f 39/561/478 45/562/479 41/565/482 -f 45/562/479 43/566/483 41/565/482 -f 42/564/481 40/560/477 32/567/484 -f 40/560/477 34/568/485 32/567/484 -f 33/569/486 39/561/478 31/570/487 -f 39/561/478 41/565/482 31/570/487 -f 40/560/477 38/557/474 34/568/485 -f 38/557/474 36/555/472 34/568/485 -f 35/556/473 37/558/475 33/569/486 -f 37/558/475 39/561/478 33/569/486 -f 34/568/485 36/555/472 28/571/488 -f 36/555/472 26/553/470 28/571/488 -f 25/554/471 35/556/473 27/572/489 -f 35/556/473 33/569/486 27/572/489 -f 32/567/484 34/568/485 30/573/490 -f 34/568/485 28/571/488 30/573/490 -f 27/572/489 33/569/486 29/574/491 -f 33/569/486 31/570/487 29/574/491 -f 30/573/490 28/571/488 20/575/492 -f 28/571/488 22/576/493 20/575/492 -f 21/577/494 27/572/489 19/578/495 -f 27/572/489 29/574/491 19/578/495 -f 28/571/488 26/553/470 24/551/468 -f 28/571/488 24/551/468 22/576/493 -f 23/552/469 25/554/471 27/572/489 -f 23/552/469 27/572/489 21/577/494 -f 22/576/493 24/551/468 16/579/496 -f 24/551/468 14/549/466 16/579/496 -f 13/550/467 23/552/469 15/580/497 -f 23/552/469 21/577/494 15/580/497 -f 20/575/492 22/576/493 18/581/498 -f 22/576/493 16/579/496 18/581/498 -f 15/580/497 21/577/494 17/582/499 -f 21/577/494 19/578/495 17/582/499 -f 18/581/498 16/579/496 10/583/500 -f 18/581/498 10/583/500 8/584/501 -f 9/585/502 15/580/497 17/582/499 -f 9/585/502 17/582/499 7/586/503 -f 16/579/496 14/549/466 12/547/464 -f 16/579/496 12/547/464 10/583/500 -f 11/548/465 13/550/467 15/580/497 -f 11/548/465 15/580/497 9/585/502 -f 10/583/500 12/547/464 2/544/461 -f 10/583/500 2/544/461 4/587/504 -f 1/545/462 11/548/465 9/585/502 -f 1/545/462 9/585/502 3/588/505 -f 8/584/501 10/583/500 4/587/504 -f 8/584/501 4/587/504 6/589/506 -f 3/588/505 9/585/502 7/586/503 -f 3/588/505 7/586/503 5/590/507 -f 6/589/506 4/587/504 46/559/476 -f 6/589/506 46/559/476 44/563/480 -f 45/562/479 3/588/505 5/590/507 -f 45/562/479 5/590/507 43/566/483 -f 4/587/504 2/544/461 48/543/460 -f 4/587/504 48/543/460 46/559/476 -f 47/546/463 1/545/462 3/588/505 -f 47/546/463 3/588/505 45/562/479 diff --git a/examples/ogl_tutorials/09_vbo_indexing/src/textures/uvmap.DDS b/examples/ogl_tutorials/09_vbo_indexing/src/textures/uvmap.DDS deleted file mode 100755 index 70cb2db1..00000000 Binary files a/examples/ogl_tutorials/09_vbo_indexing/src/textures/uvmap.DDS and /dev/null differ diff --git a/examples/ogl_tutorials/09_vbo_indexing/tutorial_09.gpr b/examples/ogl_tutorials/09_vbo_indexing/tutorial_09.gpr deleted file mode 100644 index 904b0757..00000000 --- a/examples/ogl_tutorials/09_vbo_indexing/tutorial_09.gpr +++ /dev/null @@ -1,14 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tutorial_09 is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Exec_Dir use "."; - for Main use ("indexing.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tutorial_09; diff --git a/examples/ogl_tutorials/Readme.md b/examples/ogl_tutorials/Readme.md deleted file mode 100644 index f067cf68..00000000 --- a/examples/ogl_tutorials/Readme.md +++ /dev/null @@ -1,15 +0,0 @@ -Author: Roger Mc Murtrie -These examples are based on the tutorials available at http://www.opengl-tutorial.org using Glfw version 3. -The version numbers in the shader programs may need modification depending on your -platform. -For Mac users, note that the Glfw provided with OSX is incompatible with OpenGLAda as it does not contain libglfw.a. -A compatible version can be obtained from Homebrew: brew install glfw. - -GNAT Programming Studio (GPS) Considerations -Use Tools->Views->Scenarios to display the Scenario panel. -In the Scenario panel set GLFW Version to 3. -For Mac, in the Scenario panel set Windowing System to quartz. -In Preferences, ensure that Editor->Fonts & Colors->Default is set to a fixed size font. -In Preferences->Editor->Ada set appropriate format selectors. - - diff --git a/examples/ogl_tutorials/external_wave/.gitignore b/examples/ogl_tutorials/external_wave/.gitignore deleted file mode 100644 index b773075f..00000000 --- a/examples/ogl_tutorials/external_wave/.gitignore +++ /dev/null @@ -1 +0,0 @@ -wave diff --git a/examples/ogl_tutorials/external_wave/src/control_wave.adb b/examples/ogl_tutorials/external_wave/src/control_wave.adb deleted file mode 100644 index f2aac03b..00000000 --- a/examples/ogl_tutorials/external_wave/src/control_wave.adb +++ /dev/null @@ -1,142 +0,0 @@ - -with Glfw.Input.Keys; -with Glfw.Input.Mouse; - -package body Control_Wave is - - Cursor_X : GL.Types.Single; - Cursor_Y : GL.Types.Single; - - Alpha : Degree := -210.0; - Beta : Degree := -70.0; - Zoom : GL.Types.Single := 2.0; - - Key_Pressed : Boolean := False; - - procedure Check_Keyboard (Window : in out Glfw.Windows.Window); - procedure Check_Mouse_Buttons (Window : in out Glfw.Windows.Window); - - -- ------------------------------------------------------------------------ - - procedure Check_Cursor (Window : in out Glfw.Windows.Window) is - use GL.Types; - use Glfw.Input.Mouse; - X_Coord : Coordinate; - Y_Coord : Coordinate; - X : Single; - Y : Single; - begin - if Window'Access.Get_Cursor_Mode = Disabled then - Window'Access.Get_Cursor_Pos (X_Coord, Y_Coord); - X := Single (X_Coord); - Y := Single (Y_Coord); - - Alpha := Alpha + Degree ((X - Cursor_X) / 10.0); - Beta := Beta + Degree ((Y - Cursor_Y) / 10.0); - Cursor_X := X; - Cursor_Y := Y; - end if; - end Check_Cursor; - - -- ------------------------------------------------------------------------ - - procedure Check_Input (Window : in out Glfw.Windows.Window) is - begin - Check_Keyboard (Window); - Check_Mouse_Buttons (Window); - Check_Cursor (Window); - -- Check_Scroll (Window); - end Check_Input; - - -- ------------------------------------------------------------------------ - - procedure Check_Keyboard (Window : in out Glfw.Windows.Window) is - use GL.Types; - use Glfw.Input; - begin - if Window'Access.Key_State (Keys.Space) = Pressed then - if not Key_Pressed then - Vertex_Data.Initialize_Grid; - Key_Pressed := True; - end if; - elsif Window'Access.Key_State (Keys.Left) = Pressed then - if not Key_Pressed then - Alpha := Alpha + 5.0; - Key_Pressed := True; - if Alpha > 360.0 then - Alpha := Alpha - 360.0; - end if; - end if; - elsif Window'Access.Key_State (Keys.Right) = Pressed then - if not Key_Pressed then - Alpha := Alpha - 5.0; - Key_Pressed := True; - if Alpha < 0.0 then - Alpha := Alpha + 360.0; - end if; - end if; - elsif Window'Access.Key_State (Keys.Up) = Pressed then - if not Key_Pressed then - Beta := Beta + 5.0; - Key_Pressed := True; - if Beta > 360.0 then - Beta := Beta - 360.0; - end if; - end if; - elsif Window'Access.Key_State (Keys.Down) = Pressed then - if not Key_Pressed then - Beta := Beta - 5.0; - Key_Pressed := True; - if Beta < 0.0 then - Beta := Beta + 360.0; - end if; - end if; - elsif Window'Access.Key_State (Keys.Page_Up) = Pressed then - if not Key_Pressed then - Zoom := Zoom - 0.25; - Key_Pressed := True; - if Zoom < 0.0 then - Zoom := 0.0; - end if; - end if; - elsif Window'Access.Key_State (Keys.Page_Down) = Pressed then - if not Key_Pressed then - Zoom := Zoom + 0.25; - Key_Pressed := True; - end if; - else - Key_Pressed := False; - end if; - - end Check_Keyboard; - - -- ------------------------------------------------------------------------ - - procedure Check_Mouse_Buttons (Window : in out Glfw.Windows.Window) is - use GL.Types; - use Glfw.Input; - X : Glfw.Input.Mouse.Coordinate; - Y : Glfw.Input.Mouse.Coordinate; - begin - if Window'Access.Mouse_Button_State (Mouse.Left_Button) = Pressed then - Window'Access.Set_Cursor_Mode (Mouse.Disabled); - Window'Access.Get_Cursor_Pos (X, Y); - Cursor_X := Single (X); - Cursor_Y := Single (Y); - else - Window.Set_Cursor_Mode (Mouse.Normal); - end if; - end Check_Mouse_Buttons; - - -- ------------------------------------------------------------------------ - - procedure Get_Settings (A, B : out Maths.Degree; Z : out GL.Types.Single) is - begin - A := Alpha; - B := Beta; - Z := Zoom; - end Get_Settings; - - -- ------------------------------------------------------------------------ - -end Control_Wave; diff --git a/examples/ogl_tutorials/external_wave/src/control_wave.ads b/examples/ogl_tutorials/external_wave/src/control_wave.ads deleted file mode 100644 index 28769365..00000000 --- a/examples/ogl_tutorials/external_wave/src/control_wave.ads +++ /dev/null @@ -1,31 +0,0 @@ - -with GL.Types; - -with Glfw.Windows; - -with Maths; -with Vertex_Data; - -package Control_Wave is - - type Settings is private; - type Data is private; - - procedure Check_Input (Window : in out Glfw.Windows.Window); - procedure Get_Settings (A, B : out Maths.Degree; Z : out GL.Types.Single); - -private - use Maths; - type Settings is record - Alpha : Degree := -Degrees (210.0); - Beta : Degree := -Degrees (70.0); - Zoom : GL.Types.Single := 2.0; - end record; - - type Data is record - Pressure : Vertex_Data.Grid_Array; - Vel_X : Vertex_Data.Grid_Array; - Vel_Y : Vertex_Data.Grid_Array; - end record; - -end Control_Wave; diff --git a/examples/ogl_tutorials/external_wave/src/main_loop.adb b/examples/ogl_tutorials/external_wave/src/main_loop.adb deleted file mode 100644 index bd1eb6ab..00000000 --- a/examples/ogl_tutorials/external_wave/src/main_loop.adb +++ /dev/null @@ -1,207 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Rasterization; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; -with GL.Window; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Input.Mouse; -with Glfw.Windows.Context; - -with Maths; use Maths; -with Program_Loader; -with Utilities; - -with Control_Wave; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Elements_Buffer : GL.Objects.Buffers.Buffer; - Vertices_Buffer : GL.Objects.Buffers.Buffer; - Render_Program : GL.Objects.Programs.Program; - MVP_Matrix_ID : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4; - Last_Time : GL.Types.Single := 0.0; - dt : GL.Types.Single := 0.0; - Running : Boolean := True; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Render_Program : GL.Objects.Programs.Program; - Window_Width, Window_Height : GL.Types.Single); - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window) is - use GL.Types; - use GL.Objects.Buffers; - - Black : constant GL.Types.Colors.Color := (0.0, 0.0, 0.0, 0.0); - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - Now : constant Single := Single (Glfw.Time); - dt_Total : Single := Now - Last_Time; - begin - Window.Get_Framebuffer_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (0, 0, Int (Window_Width), - GL.Types.Int (Window_Height)); - Utilities.Clear_Background_Colour_And_Depth (Black); - Glfw.Input.Poll_Events; - Control_Wave.Check_Input (Window); - - Last_Time := Now; - -- Iterate if dt_Total is too large - while dt_Total > 0.0 loop - if dt_Total > Vertex_Data.Max_dt then - dt := Vertex_Data.Max_dt; - else - dt := dt_Total; - end if; - dt_Total := dt_Total - dt; - Vertex_Data.Calculate_Grid (dt); - end loop; - Vertex_Data.Adjust_Grid; - - GL.Objects.Programs.Use_Program (Render_Program); - - Set_MVP_Matrix (Render_Program, Single (Window_Width), Single (Window_Height)); - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - - Vertices_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertices_Buffer); - Utilities.Load_Vector6_Buffer (Array_Buffer, - Vertex_Data.Vertex_Buffer_Data, Static_Draw); - - Elements_Buffer.Initialize_Id; - Element_Array_Buffer.Bind (Elements_Buffer); - Vertex_Data.Load_Element_Buffer (Element_Array_Buffer, - Vertex_Data.Quad_Element_Array, Static_Draw); - - GL.Attributes.Enable_Vertex_Attrib_Array (0); - GL.Attributes.Set_Vertex_Attrib_Pointer (Index => 0, Count => 3, - Kind => Single_Type, - Normalized => False, - Stride => Vertex_Data.Stride, - Offset => Vertex_Data.Vertex_Offset); - - GL.Attributes.Enable_Vertex_Attrib_Array (1); - GL.Attributes.Set_Vertex_Attrib_Pointer (1, 3, Single_Type, False, - Vertex_Data.Stride, - Vertex_Data.Colour_Offset); - - Draw_Elements (GL.Types.Triangles, GL.Types.Size (Vertex_Data.Num_Elements - 1), UInt_Type); - - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Attributes.Disable_Vertex_Attrib_Array (1); - - exception - when others => - Put_Line ("An exceptiom occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Set_MVP_Matrix (Render_Program : GL.Objects.Programs.Program; - Window_Width, Window_Height : GL.Types.Single) is - use GL.Types; - use GL.Types.Singles; - - Perspective : GL.Types.Singles.Matrix4 := Singles.Identity4; - Alpha : Degree; - Beta : Degree; - Zoom : Single; - begin - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP_Matrix"); - Control_Wave.Get_Settings (Alpha, Beta, Zoom); - - MVP_Matrix := GL.Types.Singles.Identity4; - -- Rotate view - MVP_Matrix := Maths.Rotation_Matrix (Beta, (1.0, 0.0, 0.0)) * MVP_Matrix; - MVP_Matrix := Maths.Rotation_Matrix (Alpha, (0.0, 0.0, 1.0)) * MVP_Matrix; - --- Move back - MVP_Matrix := Maths.Translation_Matrix ((0.0, 0.0, -Zoom)) * MVP_Matrix; - Maths.Init_Perspective_Transform (Maths.Degree (60.0), Window_Width, - Window_Height, 1.0, 1024.0, Perspective); - MVP_Matrix := Perspective * MVP_Matrix; - - exception - when others => - Put_Line ("An exception occurred in Set_MVP_Matrix."); - raise; - end Set_MVP_Matrix; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window) is - use GL.Objects.Shaders; - use GL.Types; - use Glfw.Input; - use Program_Loader; - - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - begin - Utilities.Enable_Mouse_Callbacks (Window, True); - Window.Enable_Callback (Glfw.Windows.Callbacks.Char); - Window.Enable_Callback (Glfw.Windows.Callbacks.Position); - Window.Enable_Callback (Glfw.Windows.Callbacks.Mouse_Scroll); - Window.Enable_Callback (Glfw.Windows.Callbacks.Framebuffer_Size); - - Window.Set_Input_Toggle (Sticky_Keys, True); - Window.Set_Cursor_Mode (Mouse.Disabled); - Glfw.Windows.Context.Set_Swap_Interval (1); - Glfw.Input.Poll_Events; - - Window'Access.Get_Size (Window_Width, Window_Height); - Window'Access.Set_Cursor_Pos (Mouse.Coordinate (0.5 * Single (Window_Width)), - Mouse.Coordinate (0.5 * Single (Window_Height))); - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - GL.Rasterization.Set_Point_Size (2.0); - - Vertex_Data.Initialize_Simulation; - Last_Time := Single (Glfw.Time) - 0.01; - - Render_Program := Program_From - ((Src ("src/shaders/simple_vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/simple_fragment_shader.glsl", Fragment_Shader))); - - exception - when others => - Put_Line ("An exceptiom occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; -begin - Setup (Main_Window); - while Running loop - Render (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exceptiom occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/external_wave/src/main_loop.ads b/examples/ogl_tutorials/external_wave/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/external_wave/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/external_wave/src/shaders/simple_fragment_shader.glsl b/examples/ogl_tutorials/external_wave/src/shaders/simple_fragment_shader.glsl deleted file mode 100755 index 24d37f55..00000000 --- a/examples/ogl_tutorials/external_wave/src/shaders/simple_fragment_shader.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#version 410 core - -in vec3 colour_vs; -out vec4 colour; - -void main() -{ - colour = vec4 (colour_vs, 1.0); -} diff --git a/examples/ogl_tutorials/external_wave/src/shaders/simple_vertex_shader.glsl b/examples/ogl_tutorials/external_wave/src/shaders/simple_vertex_shader.glsl deleted file mode 100755 index 34840774..00000000 --- a/examples/ogl_tutorials/external_wave/src/shaders/simple_vertex_shader.glsl +++ /dev/null @@ -1,15 +0,0 @@ -#version 410 core - -layout(location = 0) in vec3 vertex_Position; -layout(location = 1) in vec3 vertex_Colour; - -out vec3 colour_vs; - -uniform mat4 MVP_Matrix; - -void main() -{ - gl_Position = MVP_Matrix * vec4(vertex_Position, 1.0); - colour_vs = vertex_Colour; -} - diff --git a/examples/ogl_tutorials/external_wave/src/vertex_data.adb b/examples/ogl_tutorials/external_wave/src/vertex_data.adb deleted file mode 100644 index 701c2f12..00000000 --- a/examples/ogl_tutorials/external_wave/src/vertex_data.adb +++ /dev/null @@ -1,233 +0,0 @@ - -with Ada.Numerics; -with Ada.Text_IO; use Ada.Text_IO; - -package body Vertex_Data is - - Pressure : Vertex_Data.Grid_Array; - Vel_X : Vertex_Data.Grid_Array; - Vel_Y : Vertex_Data.Grid_Array; - - -- ------------------------------------------------------------------------- - - procedure Adjust_Grid is - use Maths; - Position : Int; - begin - for y_index in 1 .. Grid_Height loop - for x_index in 1 .. Grid_Width loop - Position := (y_index - 1) * Grid_Width + x_index; - Vertex_Buffer_Data (Position) (Z) := - Pressure (x_index, y_index) / 50.0; - end loop; - end loop; - - exception - when others => - Put_Line ("An exception occurred in Adjust_Grid."); - raise; - end Adjust_Grid; - - -- ------------------------------------------------------------------------- - - procedure Calculate_Grid (dt : Single) is - Acc_X : Grid_Array; - Acc_Y : Grid_Array; - X2 : Int; - Y2 : Int; - Time_Step : constant Single := dt * Animation_Speed; - begin - -- Acceleration - for X in 1 .. Grid_Width loop - X2 := X mod Grid_Width + 1; - for Y in 1 .. Grid_Height loop - Acc_X (X, Y) := Pressure (X, Y) - Pressure (X2, Y); - end loop; - end loop; - for Y in 1 .. Grid_Height loop - Y2 := Y mod Grid_Height + 1; - for X in 1 .. Grid_Width loop - Acc_Y (X, Y) := Pressure (X, Y) - Pressure (X, Y2); - end loop; - end loop; - -- Speed - for X in 1 .. Grid_Width loop - for Y in 1 .. Grid_Height loop - Vel_X (X, Y) := Vel_X (X, Y) + Acc_X (X, Y) * Time_Step; - Vel_Y (X, Y) := Vel_Y (X, Y) + Acc_Y (X, Y) * Time_Step; - end loop; - end loop; - -- Pressure - for X in 2 .. Grid_Width loop - X2 := X - 1; - for Y in 2 .. Grid_Height loop - Y2 := Y - 1; - Pressure (X, Y) := Pressure (X, Y) + (Vel_X (X2, Y) - Vel_X (X, Y) - + Vel_Y (X, Y2) - Vel_Y (X, Y)) * Time_Step; - end loop; - end loop; - exception - when others => - Put_Line ("An exception occurred in Calculate_Grid."); - raise; - end Calculate_Grid; - - -- ------------------------------------------------------------------------ - - procedure Get_Data (Press, VX, VY : out Grid_Array) is - begin - Press := Pressure; - VX := Vel_X; - VY := Vel_Y; - end Get_Data; - - -- ------------------------------------------------------------------------ - - procedure Initialize_Grid is - Half_Height : constant Single := Single (Grid_Height) / 2.0; - Half_Width : constant Single := Single (Grid_Width) / 2.0; - dx : Single; - dy : Single; - d : Single; - Angle_Step : constant Single := Ada.Numerics.Pi / Single (4 * Grid_Width); - begin - for y_index in 1 .. Grid_Height loop - for x_index in 1 .. Grid_Width loop - dx := Single (x_index) - Half_Width; - dy := Single (y_index) - Half_Height; - d := Single_Functions.Sqrt (dx * dx + dy * dy); - if d < 0.1 * Half_Width then - d := 10.0 * d; - Pressure (x_index, y_index) := -100.0 * - Single_Functions.Cos (d * Angle_Step); - else - Pressure (x_index, y_index) := 0.0; - end if; - Vel_X (x_index, y_index) := 0.0; - Vel_Y (x_index, y_index) := 0.0; - end loop; - end loop; - - exception - when others => - Put_Line ("An exception occurred in Initialize_Grid."); - raise; - end Initialize_Grid; - - -- ------------------------------------------------------------------------ - -- Iniialize_Vertices places the vertices in a grid - procedure Initialize_Vertices is - use Maths; - Half_Height : constant Single := Single (Grid_Height) / 2.0; - Half_Width : constant Single := Single (Grid_Width) / 2.0; - V_Point : Int; - Q_Point : Int := 0; - Vy_GW : Int; - Qym1_GW : Int; - Qy_GW : Int; - begin - for y_index in Int range 0 .. Grid_Height - 1 loop - Vy_GW := y_index * Grid_Width; - for x_index in Int range 0 .. Grid_Width - 1 loop - V_Point := Vy_GW + x_index + 1; - Vertex_Buffer_Data (V_Point) (X) := (Single (x_index) - - Half_Width) / Half_Width; - Vertex_Buffer_Data (V_Point) (Y) := (Single (y_index) - - Half_Height) / Half_Height; - Vertex_Buffer_Data (V_Point) (Z) := 0.0; - - if (x_index mod 4 < 2) xor (y_index mod 4 < 2) then - Vertex_Buffer_Data (V_Point) (R) := 0.0; - else - Vertex_Buffer_Data (V_Point) (R) := 1.0; - end if; - Vertex_Buffer_Data (V_Point) (G) := Single (y_index) / Single (Grid_Height); - Vertex_Buffer_Data (V_Point) (B) := 1.0 - - 0.5 * (Single (x_index) / Single (Grid_Width) + - Single (y_index) / Single (Grid_Height)); - end loop; - end loop; - - for y_index in Int range 1 .. Quad_Height loop - Qym1_GW := (y_index - 1) * Grid_Width; - Qy_GW := y_index * Grid_Width; - for x_index in Int range 1 .. Quad_Width loop - Q_Point := 6 * (Qym1_GW + x_index) - 5; - -- Four vertices of a quadralateral: - -- First triangle - Quad_Element_Array (Q_Point) := Qym1_GW + x_index; -- a point - Quad_Element_Array (Q_Point + 1) := Qym1_GW + x_index + 1; -- right side neighbour - Quad_Element_Array (Q_Point + 2) := Qy_GW + x_index; -- upper right neighbour - -- Second Triangle - Quad_Element_Array (Q_Point + 3) := Quad_Element_Array (Q_Point + 1); - Quad_Element_Array (Q_Point + 4) := Qy_GW + x_index + 1; - Quad_Element_Array (Q_Point + 5) := Qy_GW + x_index; -- upper neighbour - end loop; - end loop; - - exception - when others => - Put_Line ("An exception occurred in Initialize_Vertices."); - raise; - end Initialize_Vertices; - - -- ---------------------------------------------------------------------------- - - procedure Initialize_Simulation is - begin - Initialize_Vertices; - Initialize_Grid; - Adjust_Grid; - end Initialize_Simulation; - - -- ------------------------------------------------------------------------ - - procedure Propogate_Wave (dt : Single) is - Animation_Speed : constant Single := 10.0; - Time_Step : constant Single := dt * Animation_Speed; - Acc_X : Grid_Array; - Acc_Y : Grid_Array; - x2 : Int; - y2 : Int; - begin - for x_index in 0 .. Grid_Width - 1 loop - x2 := (x_index + 1) mod Grid_Width; - for y_index in 0 .. Grid_Height - 1 loop - Acc_X (x_index, y_index) := Pressure (x_index, y_index) - Pressure (x2, y_index); - end loop; - end loop; - - for y_index in 0 .. Grid_Height - 1 loop - y2 := (y_index + 1) mod Grid_Height; - for x_index in 0 .. Grid_Width - 1 loop - Acc_Y (x_index, y_index) := Pressure (x_index, y_index) - Pressure (x_index, y2); - end loop; - end loop; - - for x_index in 0 .. Grid_Width - 1 loop - x2 := (x_index + 1) mod Grid_Width; - for y_index in 0 .. Grid_Height - 1 loop - Vel_X (x_index, y_index) := Vel_X (x_index, y_index) + Acc_X (x_index, y_index) * Time_Step; - Vel_Y (x_index, y_index) := Vel_Y (x_index, y_index) + Acc_Y (x_index, y_index) * Time_Step; - end loop; - end loop; - - for x_index in 0 .. Grid_Width - 1 loop - x2 := x_index - 1; - for y_index in 0 .. Grid_Height - 1 loop - y2 := y_index - 1; - Pressure (x_index, y_index) := Pressure (x_index, y_index) + - (Vel_X (x2, y_index) - Vel_X (x_index, y_index) - - Vel_Y (x_index, y2) - Vel_Y (x_index, y_index)) * Time_Step; - end loop; - end loop; - - exception - when others => - Put_Line ("An exception occurred in Propogate_Wave."); - raise; - end Propogate_Wave; - - -- ---------------------------------------------------------------------------- - -end Vertex_Data; diff --git a/examples/ogl_tutorials/external_wave/src/vertex_data.ads b/examples/ogl_tutorials/external_wave/src/vertex_data.ads deleted file mode 100644 index e884b8c7..00000000 --- a/examples/ogl_tutorials/external_wave/src/vertex_data.ads +++ /dev/null @@ -1,65 +0,0 @@ - -with Ada.Numerics.Generic_Elementary_Functions; - -with GL.Types; -with GL.Objects.Buffers; - -with Maths; - -package Vertex_Data is - use GL.Types; - - package Single_Functions is new Ada.Numerics.Generic_Elementary_Functions (Single); - procedure Load_Element_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Int_Pointers); - - Grid_Height : constant Int := 50; - Grid_Width : constant Int := 50; - Num_Vertices : constant Int := Grid_Height * Grid_Width; - - Quad_Height : constant Int := Grid_Height - 1; - Quad_Width : constant Int := Grid_Width - 1; - Num_Quads : constant Int := Quad_Width * Quad_Height; - -- Each quad comprises two triangles, - -- thus six points of which two are identical pairs. - Num_Quad_Vertices : constant Int := 6 * Num_Quads; - - Animation_Speed : constant Single := 2.2; - Max_dt : constant Single := 0.1; - - type Grid_Array is array (1 .. Grid_Width, 1 .. Grid_Height) of Single; - - -- The grid will look like this: - -- - -- 4 5 6 - -- *---*---* - -- | | | - -- | 1 | 2 | - -- | | | - -- *---*---* - -- 1 2 3 - - type Vertex is record - X : Single; - Y : Single; - Z : Single; - Red : Single; - Green : Single; - Blue : Single; - end record; - - Stride : constant Int := 6 * 4; - Vertex_Offset : constant Int := 0 * 4; - Colour_Offset : constant Int := 3 * 4; - Num_Elements : constant Int := Num_Quad_Vertices + 48 * Stride; -- 192 = 48 * 4 - Vertex_Buffer_Data : Maths.Vector6_Array (1 .. Num_Vertices); - Quad_Element_Array : Int_Array (1 .. Num_Elements); - - procedure Adjust_Grid; - procedure Calculate_Grid (dt : Single); - procedure Get_Data (Press, VX, VY : out Grid_Array); - procedure Propogate_Wave (dt : Single); - procedure Initialize_Grid; - procedure Initialize_Simulation; - -end Vertex_Data; diff --git a/examples/ogl_tutorials/external_wave/src/wave.adb b/examples/ogl_tutorials/external_wave/src/wave.adb deleted file mode 100644 index 90af8b62..00000000 --- a/examples/ogl_tutorials/external_wave/src/wave.adb +++ /dev/null @@ -1,35 +0,0 @@ --- Program Hello_Textures --- Author Roger Mc Murtrie --- Created 2 June 2017 --- Based on OGL_Tutorials external wave.c --- modified, in particular, to use GLSL programmed shaders --- Quads, now deprecated, have been changed to triangle pairs - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Wave is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Wave Simulation"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Wave returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Wave."); - Put_Line (Exception_Information (anError)); - -end Wave; diff --git a/examples/ogl_tutorials/external_wave/wave.gpr b/examples/ogl_tutorials/external_wave/wave.gpr deleted file mode 100644 index afa27930..00000000 --- a/examples/ogl_tutorials/external_wave/wave.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Wave is - -for Source_Dirs use ("src"); -for Object_Dir use "obj/"; -for Exec_Dir use "."; -for Main use ("wave.adb"); - - package Compiler renames OpenGL.Compiler; - -end Wave; - diff --git a/examples/ogl_tutorials/indexed_model_loading/.gitignore b/examples/ogl_tutorials/indexed_model_loading/.gitignore deleted file mode 100644 index f2497036..00000000 --- a/examples/ogl_tutorials/indexed_model_loading/.gitignore +++ /dev/null @@ -1 +0,0 @@ -indexed_loading diff --git a/examples/ogl_tutorials/indexed_model_loading/indexing.gpr b/examples/ogl_tutorials/indexed_model_loading/indexing.gpr deleted file mode 100644 index ec57a020..00000000 --- a/examples/ogl_tutorials/indexed_model_loading/indexing.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Indexing is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("indexed_loading.adb"); - - package Compiler renames Opengl.Compiler; - -end Indexing; - diff --git a/examples/ogl_tutorials/indexed_model_loading/src/indexed_loading.adb b/examples/ogl_tutorials/indexed_model_loading/src/indexed_loading.adb deleted file mode 100644 index 5f4333d2..00000000 --- a/examples/ogl_tutorials/indexed_model_loading/src/indexed_loading.adb +++ /dev/null @@ -1,27 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Indexed_Loading is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Indexed Model Loading"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Indexed_Loading returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Indexed_Loading."); - Put_Line (Exception_Information (anError)); -end Indexed_Loading; diff --git a/examples/ogl_tutorials/indexed_model_loading/src/main_loop.adb b/examples/ogl_tutorials/indexed_model_loading/src/main_loop.adb deleted file mode 100644 index 3d7ba7f3..00000000 --- a/examples/ogl_tutorials/indexed_model_loading/src/main_loop.adb +++ /dev/null @@ -1,204 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input.Keys; -with Glfw.Input.Mouse; -with Glfw.Windows; -with Glfw.Windows.Context; - -with Controls; -with Program_Loader; -with Load_DDS; -with Load_Object_File; -with Utilities; -with VBO_Indexer; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 0.0); - - Vertices_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - UVs_Buffer : GL.Objects.Buffers.Buffer; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Element_Buffer : GL.Objects.Buffers.Buffer; - MVP_Matrix_ID : GL.Uniforms.Uniform; - Texture_ID : GL.Uniforms.Uniform; - - -- ------------------------------------------------------------------------ - - Procedure Load_Buffers (Indices_Size : out GL.Types.Int) is - use GL.Objects.Buffers; - use GL.Types; - Vertex_Count : Int; - Indexed_Vertices_Size : Int; - begin - Vertex_Count := Load_Object_File.Mesh_Size ("src/textures/cube.obj"); - declare - Vertices : Singles.Vector3_Array (1 .. Vertex_Count); - UVs : Singles.Vector2_Array (1 .. Vertex_Count); - Indexed_Vertices : Singles.Vector3_Array (1 .. Vertex_Count); - Indexed_UVs : Singles.Vector2_Array (1 .. Vertex_Count); - Temp_Indices : UInt_Array (1 .. Vertex_Count); - - begin - Load_Object_File.Load_Object ("src/textures/cube.obj", Vertices, UVs); - VBO_Indexer.Index_VBO (Vertices, UVs, Indexed_Vertices, Indexed_UVs, - Temp_Indices, Indices_Size, Indexed_Vertices_Size); - declare - Vertices_Indexed : constant Singles.Vector3_Array (1 .. Indexed_Vertices_Size) - := Indexed_Vertices (1 .. Indexed_Vertices_Size); - UVs_Indexed : constant Singles.Vector2_Array (1 .. Indexed_Vertices_Size) - := Indexed_UVs (1 .. Indexed_Vertices_Size); - Indices : constant GL.Types.UInt_Array (1 .. Indices_Size) - := Temp_Indices (1 .. Indices_Size); - begin - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertices_Indexed, Static_Draw); - - UVs_Buffer.Initialize_Id; - Array_Buffer.Bind (UVs_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, UVs_Indexed, Static_Draw); - - Element_Buffer.Initialize_Id; - Element_Array_Buffer.Bind (Element_Buffer); - Utilities.Load_Element_Buffer (Element_Array_Buffer, Indices, Static_Draw); - end; - end; - - exception - when others => - Put_Line ("An exception occurred in Load_Buffers."); - raise; - end Load_Buffers; - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program; - Indices_Size : GL.Types.Int; - Sample_Texture : GL.Objects.Textures.Texture) is - use GL.Objects.Buffers; - use GL.Types; - use GL.Types.Singles; - Model_Matrix : constant Singles.Matrix4 := GL.Types.Singles.Identity4; - View_Matrix : Singles.Matrix4; - Projection_Matrix : Singles.Matrix4; - MVP_Matrix : Singles.Matrix4; - begin - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - GL.Objects.Programs.Use_Program (Render_Program); - Controls.Compute_Matrices_From_Inputs (Window, Projection_Matrix, View_Matrix); - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - - -- First attribute buffer : vertices - GL.Attributes.Enable_Vertex_Attrib_Array (0); - GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, False, 0, 0); - -- Second attribute buffer : UVs - GL.Attributes.Enable_Vertex_Attrib_Array (1); - GL.Objects.Buffers.Array_Buffer.Bind (UVs_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer (1, 2, Single_Type, False, 0, 0); - - -- Bind the texture in Texture Unit 0 - GL.Objects.Textures.Set_Active_Unit (0); - GL.Objects.Textures.Targets.Texture_2D.Bind (Sample_Texture); - GL.Uniforms.Set_Int (Texture_ID, 0); - --- Put_Line ("Render, Indices_Size: " & Int'Image (Indices_Size)); --- GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 36 * 3); - GL.Objects.Buffers.Draw_Elements (Triangles, Indices_Size, UInt_Type); - - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Attributes.Disable_Vertex_Attrib_Array (1); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window; - Render_Program : out GL.Objects.Programs.Program; - Indices_Size : out GL.Types.Int; - Sample_Texture : out GL.Objects.Textures.Texture) is - use GL.Objects.Shaders; - use GL.Types; - use Glfw.Input; - Window_Width : constant Glfw.Size := 1024; - Window_Height : constant Glfw.Size := 768; - begin - Utilities.Clear_Background_Colour (Dark_Blue); - Window.Set_Input_Toggle (Sticky_Keys, True); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - Window.Set_Cursor_Mode (Mouse.Disabled); - Glfw.Input.Poll_Events; - - Window'Access.Set_Size (Window_Width, Window_Height); - Window'Access.Set_Cursor_Pos (Mouse.Coordinate (0.5 * Single (Window_Width)), - Mouse.Coordinate (0.5 * Single (Window_Height))); - - Vertices_Array_Object.Initialize_Id; - Vertices_Array_Object.Bind; - - Render_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/Transform_Vertex_Shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/Texture_Fragment_Shader.glsl", - Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Render_Program); - - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP"); - - Load_DDS ("src/textures/uvmap.DDS", Sample_Texture); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "myTextureSampler"); - - Load_Buffers (Indices_Size); - - exception - when others => - Put_Line ("An exception occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; - Render_Program : GL.Objects.Programs.Program; - Array_Size : GL.Types.Int; - Sample_Texture : GL.Objects.Textures.Texture; -begin - Setup (Main_Window, Render_Program, Array_Size, Sample_Texture); - while Running loop - Render (Main_Window, Render_Program, Array_Size, Sample_Texture); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/indexed_model_loading/src/main_loop.ads b/examples/ogl_tutorials/indexed_model_loading/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/indexed_model_loading/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/indexed_model_loading/src/shaders/Texture_Fragment_Shader.glsl b/examples/ogl_tutorials/indexed_model_loading/src/shaders/Texture_Fragment_Shader.glsl deleted file mode 100755 index 7800dfb8..00000000 --- a/examples/ogl_tutorials/indexed_model_loading/src/shaders/Texture_Fragment_Shader.glsl +++ /dev/null @@ -1,16 +0,0 @@ -#version 410 core - -// Interpolated values from the vertex shaders -in vec2 UV; - -// Ouput data -out vec3 colour; - -// Values that stay constant for the whole mesh. -uniform sampler2D myTextureSampler; - -void main() - { - // Output color = color of the texture at the specified UV - colour = texture( myTextureSampler, UV ).rgb; - } diff --git a/examples/ogl_tutorials/indexed_model_loading/src/shaders/Transform_Vertex_Shader.glsl b/examples/ogl_tutorials/indexed_model_loading/src/shaders/Transform_Vertex_Shader.glsl deleted file mode 100755 index b1a7fd6a..00000000 --- a/examples/ogl_tutorials/indexed_model_loading/src/shaders/Transform_Vertex_Shader.glsl +++ /dev/null @@ -1,21 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 vertexPosition_modelspace; -layout(location = 1) in vec2 vertexUV; - -// Output data ; will be interpolated for each fragment. -out vec2 UV; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP; - -void main() - { - // Output position of the vertex, in clip space : MVP * position - gl_Position = MVP * vec4(vertexPosition_modelspace, 1); - - // UV of the vertex. No special space for this one. - UV = vertexUV; - } - diff --git a/examples/ogl_tutorials/indexed_model_loading/src/textures/cube.obj b/examples/ogl_tutorials/indexed_model_loading/src/textures/cube.obj deleted file mode 100755 index 58fc484c..00000000 --- a/examples/ogl_tutorials/indexed_model_loading/src/textures/cube.obj +++ /dev/null @@ -1,47 +0,0 @@ -# Blender3D v249 OBJ File: untitled.blend -# www.blender3d.org -mtllib cube.mtl -v 1.000000 -1.000000 -1.000000 -v 1.000000 -1.000000 1.000000 -v -1.000000 -1.000000 1.000000 -v -1.000000 -1.000000 -1.000000 -v 1.000000 1.000000 -1.000000 -v 0.999999 1.000000 1.000001 -v -1.000000 1.000000 1.000000 -v -1.000000 1.000000 -1.000000 -vt 0.748573 0.750412 -vt 0.749279 0.501284 -vt 0.999110 0.501077 -vt 0.999455 0.750380 -vt 0.250471 0.500702 -vt 0.249682 0.749677 -vt 0.001085 0.750380 -vt 0.001517 0.499994 -vt 0.499422 0.500239 -vt 0.500149 0.750166 -vt 0.748355 0.998230 -vt 0.500193 0.998728 -vt 0.498993 0.250415 -vt 0.748953 0.250920 -vn 0.000000 0.000000 -1.000000 -vn -1.000000 -0.000000 -0.000000 -vn -0.000000 -0.000000 1.000000 -vn -0.000001 0.000000 1.000000 -vn 1.000000 -0.000000 0.000000 -vn 1.000000 0.000000 0.000001 -vn 0.000000 1.000000 -0.000000 -vn -0.000000 -1.000000 0.000000 -usemtl Material_ray.png -s off -f 5/1/1 1/2/1 4/3/1 -f 5/1/1 4/3/1 8/4/1 -f 3/5/2 7/6/2 8/7/2 -f 3/5/2 8/7/2 4/8/2 -f 2/9/3 6/10/3 3/5/3 -f 6/10/4 7/6/4 3/5/4 -f 1/2/5 5/1/5 2/9/5 -f 5/1/6 6/10/6 2/9/6 -f 5/1/7 8/11/7 6/10/7 -f 8/11/7 7/12/7 6/10/7 -f 1/2/8 2/9/8 3/13/8 -f 1/2/8 3/13/8 4/14/8 diff --git a/examples/ogl_tutorials/indexed_model_loading/src/textures/uvmap.DDS b/examples/ogl_tutorials/indexed_model_loading/src/textures/uvmap.DDS deleted file mode 100755 index 90ed4c7e..00000000 Binary files a/examples/ogl_tutorials/indexed_model_loading/src/textures/uvmap.DDS and /dev/null differ diff --git a/examples/ogl_tutorials/misc05_picking_easy/.gitignore b/examples/ogl_tutorials/misc05_picking_easy/.gitignore deleted file mode 100644 index bbd78088..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/.gitignore +++ /dev/null @@ -1 +0,0 @@ -picking diff --git a/examples/ogl_tutorials/misc05_picking_easy/misc_05.gpr b/examples/ogl_tutorials/misc05_picking_easy/misc_05.gpr deleted file mode 100644 index 84d5d1d0..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/misc_05.gpr +++ /dev/null @@ -1,14 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Misc_05 is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Exec_Dir use "."; - for Main use ("picking.adb"); - - package Compiler renames OpenGL.Compiler; - -end Misc_05; diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/main_loop.adb b/examples/ogl_tutorials/misc05_picking_easy/src/main_loop.adb deleted file mode 100644 index fd658699..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/src/main_loop.adb +++ /dev/null @@ -1,407 +0,0 @@ - -with Interfaces.C; - -with Ada.Numerics.Float_Random; -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Framebuffer; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Objects.Vertex_Arrays; -with GL.Pixels; -with GL.Toggles; -with GL.Types.Colors; -with GL.Uniforms; - -with Glfw.Input.Keys; -with Glfw.Input.Mouse; -with Glfw.Windows; -with Glfw.Windows.Context; - -with Controls; -with Program_Loader; -with Load_DDS; -with Load_Object_File; -with Maths; -with Utilities; -with VBO_Indexer; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - type Pixels_Array is array (Positive range <>) of aliased GL.Types.UByte; - procedure Read_Pix is new - GL.Framebuffer.Read_Pixels (Element_Type => GL.Types.UByte, - Index_Type => Positive, - Array_Type => Pixels_Array); - type Orientation is record - Angle : Maths.Radian; - Axis : GL.Types.Singles.Vector3; - end record; - type Orientation_Array is array (GL.Types.Int range <>) of Orientation; - - Dark_Blue : constant GL.Types.Colors.Color := (0.0, 0.0, 0.4, 0.0); - White : constant GL.Types.Colors.Color := (1.0, 1.0, 1.0, 1.0); - - Vertices_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Element_Buffer : GL.Objects.Buffers.Buffer; - Normals_Buffer : GL.Objects.Buffers.Buffer; - UVs_Buffer : GL.Objects.Buffers.Buffer; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - MVP_Matrix_ID : GL.Uniforms.Uniform; - Model_Matrix_ID : GL.Uniforms.Uniform; - View_Matrix_ID : GL.Uniforms.Uniform; - Light_Position_ID : GL.Uniforms.Uniform; - Picking_Colour_ID : GL.Uniforms.Uniform; - Picking_Matrix_ID : GL.Uniforms.Uniform; - Texture_ID : GL.Uniforms.Uniform; - MVP_Matrix : GL.Types.Singles.Matrix4; - - Last_Time : Glfw.Seconds; - Number_Of_Frames : Integer := 0; - Max_Items : constant GL.Types.Int := 100; - Orientations : Orientation_Array (1 .. Max_Items); - Positions : GL.Types.Singles.Vector3_Array (1 .. Max_Items); - - -- ------------------------------------------------------------------------ - - Procedure Load_Buffers (Indices_Size : out GL.Types.Int) is - use GL.Objects.Buffers; - use GL.Types; - Vertex_Count : Int; - Vertices_Size : Int; - begin - Vertex_Count := Load_Object_File.Mesh_Size ("src/textures/suzanne.obj"); - declare - Vertices : Singles.Vector3_Array (1 .. Vertex_Count); - UVs : Singles.Vector2_Array (1 .. Vertex_Count); - Normals : Singles.Vector3_Array (1 .. Vertex_Count); - Indexed_Vertices : Singles.Vector3_Array (1 .. Vertex_Count); - Indexed_UVs : Singles.Vector2_Array (1 .. Vertex_Count); - Indexed_Normals : Singles.Vector3_Array (1 .. Vertex_Count); - Temp_Indices : UInt_Array (1 .. Vertex_Count); - - begin - Load_Object_File.Load_Object ("src/textures/suzanne.obj", Vertices, UVs, Normals); - VBO_Indexer.Index_VBO (Vertices, UVs, Normals, - Indexed_Vertices, Indexed_UVs, Indexed_Normals, - Temp_Indices, Indices_Size, Vertices_Size); - declare - Vertices_Indexed : constant Singles.Vector3_Array (1 .. Vertices_Size) - := Indexed_Vertices (1 .. Vertices_Size); - UVs_Indexed : constant Singles.Vector2_Array (1 .. Vertices_Size) - := Indexed_UVs (1 .. Vertices_Size); - Normals_Indexed : constant Singles.Vector3_Array (1 .. Vertices_Size) - := Indexed_Normals (1 .. Vertices_Size); - Indices : constant GL.Types.UInt_Array (1 .. Indices_Size) - := Temp_Indices (1 .. Indices_Size); - begin - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertices_Indexed, Static_Draw); - - UVs_Buffer.Initialize_Id; - Array_Buffer.Bind (UVs_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, UVs_Indexed, Static_Draw); - - Normals_Buffer.Initialize_Id; - Array_Buffer.Bind (Normals_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Normals_Indexed, Static_Draw); - - Element_Buffer.Initialize_Id; - Element_Array_Buffer.Bind (Element_Buffer); - Utilities.Load_Element_Buffer (Element_Array_Buffer, Indices, Static_Draw); - end; - end; - - exception - when others => - Put_Line ("An exception occurred in Load_Buffers."); - raise; - end Load_Buffers; - - -- ------------------------------------------------------------------------ - - procedure Load_Texture (Window : in out Glfw.Windows.Window; - Vertex_Count : GL.Types.Int; - UV_Map : GL.Objects.Textures.Texture; - View_Matrix : out GL.Types.Singles.Matrix4; - Projection_Matrix : out GL.Types.Singles.Matrix4) is - use GL.Types; - use GL.Types.Singles; - Model_Matrix : Matrix4; - Rot_Matrix : Matrix4 := Singles.Identity4; - Trans_Matrix : Matrix4; - -- Light_Pos : constant Vector3 := (4.0, 4.0, 4.0); - Scale : constant Singles.Vector3 := (1.0, 1.0, 1.0); - begin - Controls.Compute_Matrices_From_Inputs (Window, Projection_Matrix, View_Matrix); - Utilities.Clear_Background_Colour_And_Depth (White); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - for count in GL.Types.Int range 1 .. Max_Items loop - Rot_Matrix := Maths.Rotation_Matrix (Orientations (count).Angle, - Orientations (count).Axis); - Trans_Matrix := Maths.Translation_Matrix (Positions (count) * 2.0 * Scale (GL.X)); - Model_Matrix := Trans_Matrix * Maths.Scaling_Matrix (Scale) * Rot_Matrix; - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - GL.Uniforms.Set_Single (Model_Matrix_ID, Model_Matrix); - GL.Uniforms.Set_Single (View_Matrix_ID, View_Matrix); - GL.Uniforms.Set_Single (MVP_Matrix_ID, MVP_Matrix); - GL.Uniforms.Set_Single (Light_Position_ID, 4.0, 4.0, 4.0); - -- GL.Uniforms.Set_Single (Light_Position_ID, Light_Pos); - - -- Bind the texture in Texture Unit 0 - GL.Objects.Textures.Set_Active_Unit (0); - GL.Objects.Textures.Targets.Texture_2D.Bind (UV_Map); - GL.Uniforms.Set_Int (Texture_ID, 0); - - -- First attribute buffer : vertices - GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - -- Index Buffer - GL.Objects.Buffers.Element_Array_Buffer.Bind (Element_Buffer); - GL.Objects.Buffers.Draw_Elements (Triangles, Vertex_Count, UInt_Type, 0); - end loop; - GL.Attributes.Disable_Vertex_Attrib_Array (0); - - exception - when others => - Put_Line ("An exception occurred in Load_Texture."); - raise; - end Load_Texture; - - -- ------------------------------------------------------------------------ - - procedure Pick (Window : in out Glfw.Windows.Window; - Picking_Program : GL.Objects.Programs.Program; - Positions : GL.Types.Singles.Vector3_Array; - Orientations : Orientation_Array; - Indices_Size : GL.Types.Int; - View_Matrix, Projection_Matrix : GL.Types.Singles.Matrix4) is - use Interfaces; - use GL.Types; - use GL.Types.Singles; - Model_Matrix : Matrix4; - Rot_Matrix : Matrix4; - Trans_Matrix : Matrix4; - R : Single; - G : Single; - B : Single; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - Pixel_Data : Pixels_Array (1 .. 4); - Picked_ID : Int; - -- Message : Ada.Strings.Unbounded.Unbounded_String; - begin - Utilities.Clear_Background_Colour_And_Depth (White); - GL.Objects.Programs.Use_Program (Picking_Program); - -- Only the positions are needed (not the UVs and normals) - GL.Attributes.Enable_Vertex_Attrib_Array (0); - for count in GL.Types.Int range 1 .. Max_Items loop - Rot_Matrix := Maths.Rotation_Matrix (Orientations (count).Angle, - Orientations (count).Axis); - Trans_Matrix := Maths.Translation_Matrix (Positions (count)); - Model_Matrix := Trans_Matrix * Rot_Matrix; - MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; - GL.Uniforms.Set_Single (Picking_Matrix_ID, MVP_Matrix); - - -- Convert count, the integer mesh ID, into an RGB color - R := Single (Unsigned_32 (count) and 16#FF#) / 255.0; - G := Single (Shift_Right (Unsigned_32 (count) and 16#FF00#, 8)) / 255.0; - B := Single (Shift_Right (Unsigned_32 (count) and 16#FF0000#, 16)) / 255.0; - GL.Uniforms.Set_Single (Picking_Colour_ID, R, G, B, 1.0); - - GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer); - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 3, Single_Type, False, 0, 0); - - GL.Objects.Buffers.Element_Array_Buffer.Bind (Element_Buffer); - GL.Objects.Buffers.Draw_Elements (Mode => Triangles, - Count => Indices_Size, - Index_Type => UInt_Type); - end loop; - GL.Attributes.Disable_Vertex_Attrib_Array (0); - GL.Flush; - - GL.Pixels.Set_Pack_Alignment (GL.Pixels.Unpack_Alignment); - Window'Access.Get_Size (Window_Width, Window_Height); - -- Read the pixel at the center of the screen - Read_Pix (Int (Window_Width) / 2, Int (Window_Height) / 2, 1, 1, - GL.Pixels.RGBA, GL.Pixels.Float, Pixel_Data); - Put_Line ("Pick R" & UByte'Image (Pixel_Data (1)) & UByte'Image (Pixel_Data (2)) - & UByte'Image (Pixel_Data (3))); - -- Convert the color back to an integer ID - Picked_ID := Int (Pixel_Data (1)) + 256 * Int (Pixel_Data (2)) + - 256 * 256 * Int (Pixel_Data (3)); - if Picked_ID = 16#00FFFFFF# then -- Full white, must be the background! - Put_Line ("Background " & Int'Image (Picked_ID)); - -- Message := Ada.Strings.Unbounded.To_Unbounded_String ("background"); - else - Put_Line ("Mesh " & Int'Image (Picked_ID)); - -- Message := Ada.Strings.Unbounded.To_Unbounded_String (""); - end if; - - exception - when others => - Put_Line ("An exception occurred in Pick."); - raise; - end Pick; - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window; - Render_Program : GL.Objects.Programs.Program; - Picking_Program : GL.Objects.Programs.Program; - Vertex_Count : GL.Types.Int; - UV_Map : GL.Objects.Textures.Texture) is - use Interfaces.C; - -- use GL.Objects.Shaders; - use Glfw.Input; - View_Matrix : GL.Types.Singles.Matrix4; - Projection_Matrix : GL.Types.Singles.Matrix4; - Current_Time : constant Glfw.Seconds := Glfw.Time; - begin - Utilities.Clear_Background_Colour_And_Depth (Dark_Blue); - Number_Of_Frames := Number_Of_Frames + 1; - if Current_Time - Last_Time >= 1.0 then - Put_Line (Integer'Image (1000 * Number_Of_Frames) & " ms/frame"); - Number_Of_Frames := 0; - Last_Time := Last_Time + 1.0; - end if; - - GL.Objects.Programs.Use_Program (Render_Program); - Load_Texture (Window, Vertex_Count, UV_Map, View_Matrix, Projection_Matrix); - - if Window.Mouse_Button_State (Mouse.Left_Button) = Glfw.Input.Pressed then - Pick (Window, Picking_Program, Positions, Orientations, Vertex_Count, - View_Matrix, Projection_Matrix); - end if; - - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup (Window : in out Glfw.Windows.Window; - Render_Program : out GL.Objects.Programs.Program; - Picking_Program : out GL.Objects.Programs.Program; - Indices_Size : out GL.Types.Int; - UV_Map : out GL.Objects.Textures.Texture) is - use GL.Objects.Shaders; - use GL.Types; - use Glfw.Input; - Window_Width : constant Glfw.Size := 1024; - Window_Height : constant Glfw.Size := 768; - Gen : Ada.Numerics.Float_Random.Generator; - - function Position return Single is - begin - return Single (20.0 * Ada.Numerics.Float_Random.Random (Gen) - 10.0); - end Position; - function Direction return Maths.Radian is - begin - return Maths.Radian (2.0 * Ada.Numerics.Pi * Ada.Numerics.Float_Random.Random (Gen)); - end Direction; - begin - Window.Set_Input_Toggle (Sticky_Keys, True); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - Window.Set_Cursor_Mode (Mouse.Disabled); - Glfw.Input.Poll_Events; - - Window'Access.Set_Size (Window_Width, Window_Height); - Window'Access.Set_Cursor_Pos (Mouse.Coordinate (0.5 * Single (Window_Width)), - Mouse.Coordinate (0.5 * Single (Window_Height))); - - Vertices_Array_Object.Initialize_Id; - Vertices_Array_Object.Bind; - - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - - Render_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/standard_vertex_shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/standard_fragment_shader.glsl", - Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Render_Program); - - Picking_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/picking_vertex_shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/picking_fragment_shader.glsl", - Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Picking_Program); - - MVP_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "MVP"); - Model_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "M"); - View_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "V"); - Light_Position_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "Light_Position_Worldspace"); - Picking_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Picking_Program, "MVP"); - - Load_DDS ("src/textures/uvmap.DDS", UV_Map); - Texture_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "myTextureSampler"); - - Load_Buffers (Indices_Size); - - Picking_Colour_ID := GL.Objects.Programs.Uniform_Location - (Picking_Program, "Picking_Colour"); - Light_Position_ID := GL.Objects.Programs.Uniform_Location - (Picking_Program, "Light_Position_Worldspace"); - Ada.Numerics.Float_Random.Reset (Gen); - for Index in 1 .. Max_Items loop - Positions (Index) := (Position, Position, Position); - Orientations (Index) := (Direction, (1.0, 1.0, 1.0)); - end loop; - -- Last_Time := Glfw.Time; - Utilities.Enable_Mouse_Callbacks (Window, True); - Window.Enable_Callback (Glfw.Windows.Callbacks.Char); - Window.Enable_Callback (Glfw.Windows.Callbacks.Position); - exception - when others => - Put_Line ("An exception occurred in Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Picking_Program : GL.Objects.Programs.Program; - Render_Program : GL.Objects.Programs.Program; - Running : Boolean := True; - Vertex_Count : GL.Types.Int; - UV_Map : GL.Objects.Textures.Texture; -begin --- Setup (Main_Window, Render_Program, Vertex_Count, UV_Map); - Setup (Main_Window, Render_Program, Picking_Program, Vertex_Count, UV_Map); - while Running loop --- Render (Main_Window, Render_Program, Vertex_Count, UV_Map); - Render (Main_Window, Render_Program, Picking_Program, Vertex_Count, UV_Map); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/main_loop.ads b/examples/ogl_tutorials/misc05_picking_easy/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/picking.adb b/examples/ogl_tutorials/misc05_picking_easy/src/picking.adb deleted file mode 100644 index 29f42637..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/src/picking.adb +++ /dev/null @@ -1,27 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Picking is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Miscellaneous 5 - Picking Slow Easy"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; -exception - when anError : Constraint_Error => - Put ("Picking returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Picking."); - Put_Line (Exception_Information (anError)); -end Picking; diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/shaders/picking_fragment_shader.glsl b/examples/ogl_tutorials/misc05_picking_easy/src/shaders/picking_fragment_shader.glsl deleted file mode 100755 index d2e44baa..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/src/shaders/picking_fragment_shader.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 410 core - -// Ouput data -out vec4 colour; - -// Values that stay constant for the whole mesh. -uniform vec4 Picking_Colour; - -void main() - { - colour = Picking_Colour; - } diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/shaders/picking_vertex_shader.glsl b/examples/ogl_tutorials/misc05_picking_easy/src/shaders/picking_vertex_shader.glsl deleted file mode 100755 index 982907ae..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/src/shaders/picking_vertex_shader.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 Vertex_Position_Modelspace; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP; - -void main() - { - // Output position of the vertex, in clip space : MVP * position - gl_Position = MVP * vec4(Vertex_Position_Modelspace, 1); - } - diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/shaders/standard_fragment_shader.glsl b/examples/ogl_tutorials/misc05_picking_easy/src/shaders/standard_fragment_shader.glsl deleted file mode 100755 index 0f55aa00..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/src/shaders/standard_fragment_shader.glsl +++ /dev/null @@ -1,61 +0,0 @@ -#version 410 core - -// Interpolated values from the vertex shaders -in vec2 UV; -in vec3 Position_Worldspace; -in vec3 Normal_Camera_Space; -in vec3 Eye_Direction_Camera_Space; -in vec3 Light_Direction_Camera_Space; - -// Ouput data -out vec3 color; - -// Values that stay constant for the whole mesh. -uniform sampler2D myTextureSampler; -uniform mat4 MV; -uniform vec3 Light_Position_Worldspace; - -void main() - { - // Light emission properties - // You probably want to put them as uniforms - vec3 LightColor = vec3(1,1,1); - float LightPower = 50.0f; - - // Material properties - vec3 MaterialDiffuseColor = texture( myTextureSampler, UV ).rgb; - vec3 MaterialAmbientColor = vec3(0.1,0.1,0.1) * MaterialDiffuseColor; - vec3 MaterialSpecularColor = vec3(0.3,0.3,0.3); - - // Distance to the light - float distance = length( Light_Position_Worldspace - Position_Worldspace ); - - // Normal of the computed fragment, in camera space - vec3 n = normalize( Normal_Camera_Space ); - // Direction of the light (from the fragment to the light) - vec3 l = normalize( Light_Direction_Camera_Space ); - // Cosine of the angle between the normal and the light direction, - // clamped above 0 - // - light is at the vertical of the triangle -> 1 - // - light is perpendicular to the triangle -> 0 - // - light is behind the triangle -> 0 - float cosTheta = clamp( dot( n,l ), 0,1 ); - - // Eye vector (towards the camera) - vec3 E = normalize(Eye_Direction_Camera_Space); - // Direction in which the triangle reflects the light - vec3 R = reflect(-l,n); - // Cosine of the angle between the Eye vector and the Reflect vector, - // clamped to 0 - // - Looking into the reflection -> 1 - // - Looking elsewhere -> < 1 - float cosAlpha = clamp( dot( E,R ), 0,1 ); - - color = - // Ambient : simulates indirect lighting - MaterialAmbientColor + - // Diffuse : "color" of the object - MaterialDiffuseColor * LightColor * LightPower * cosTheta / (distance*distance) + - // Specular : reflective highlight, like a mirror - MaterialSpecularColor * LightColor * LightPower * pow(cosAlpha,5) / (distance*distance); - } diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/shaders/standard_vertex_shader.glsl b/examples/ogl_tutorials/misc05_picking_easy/src/shaders/standard_vertex_shader.glsl deleted file mode 100755 index b11828cc..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/src/shaders/standard_vertex_shader.glsl +++ /dev/null @@ -1,44 +0,0 @@ -#version 410 core - -// Input vertex data, different for all executions of this shader. -layout(location = 0) in vec3 Vertex_Position_Modelspace; -layout(location = 1) in vec2 Vertex_UV; -layout(location = 2) in vec3 Vertex_Normal_Modelspace; - -// Output data ; will be interpolated for each fragment. -out vec2 UV; -out vec3 Position_Worldspace; -out vec3 Normal_Camera_Space; -out vec3 Eye_Direction_Camera_Space; -out vec3 Light_Direction_Camera_Space; - -// Values that stay constant for the whole mesh. -uniform mat4 MVP; -uniform mat4 V; -uniform mat4 M; -uniform vec3 Light_Position_Worldspace; - -void main() - { - // Output position of the vertex, in clip space : MVP * position - gl_Position = MVP * vec4(Vertex_Position_Modelspace, 1); - - // Position of the vertex, in worldspace : M * position - Position_Worldspace = (M * vec4(Vertex_Position_Modelspace, 1)).xyz; - - // Vector that goes from the vertex to the camera, in camera space. - // In camera space, the camera is at the origin (0,0,0). - vec3 Vertex_Position_Camera_Space = ( V * M * vec4(Vertex_Position_Modelspace,1)).xyz; - Eye_Direction_Camera_Space = vec3(0, 0, 0) - Vertex_Position_Camera_Space; - - // Vector that goes from the vertex to the light, in camera space. M is ommited because it's identity. - vec3 LightPosition_cameraspace = ( V * vec4(Light_Position_Worldspace, 1)).xyz; - Light_Direction_Camera_Space = Light_Direction_Camera_Space + Eye_Direction_Camera_Space; - - // Normal of the the vertex, in camera space - Normal_Camera_Space = ( V * M * vec4(Vertex_Normal_Modelspace, 0)).xyz; // Only correct if ModelMatrix does not scale the model ! Use its inverse transpose if not. - - // UV of the vertex. No special space for this one. - UV = Vertex_UV; - } - diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/textures/suzanne.obj b/examples/ogl_tutorials/misc05_picking_easy/src/textures/suzanne.obj deleted file mode 100755 index 14e9bbe4..00000000 --- a/examples/ogl_tutorials/misc05_picking_easy/src/textures/suzanne.obj +++ /dev/null @@ -1,2580 +0,0 @@ -# Blender3D v249 OBJ File: suzanne.blend -# www.blender3d.org -v 0.437500 0.164063 0.765625 -v -0.437500 0.164063 0.765625 -v 0.500000 0.093750 0.687500 -v -0.500000 0.093750 0.687500 -v 0.546875 0.054688 0.578125 -v -0.546875 0.054688 0.578125 -v 0.351563 -0.023438 0.617188 -v -0.351563 -0.023438 0.617188 -v 0.351563 0.031250 0.718750 -v -0.351563 0.031250 0.718750 -v 0.351563 0.132813 0.781250 -v -0.351563 0.132813 0.781250 -v 0.273438 0.164063 0.796875 -v -0.273438 0.164063 0.796875 -v 0.203125 0.093750 0.742188 -v -0.203125 0.093750 0.742188 -v 0.156250 0.054688 0.648438 -v -0.156250 0.054688 0.648438 -v 0.078125 0.242188 0.656250 -v -0.078125 0.242188 0.656250 -v 0.140625 0.242188 0.742188 -v -0.140625 0.242188 0.742188 -v 0.242188 0.242188 0.796875 -v -0.242188 0.242188 0.796875 -v 0.273438 0.328125 0.796875 -v -0.273438 0.328125 0.796875 -v 0.203125 0.390625 0.742188 -v -0.203125 0.390625 0.742188 -v 0.156250 0.437500 0.648438 -v -0.156250 0.437500 0.648438 -v 0.351563 0.515625 0.617188 -v -0.351563 0.515625 0.617188 -v 0.351563 0.453125 0.718750 -v -0.351563 0.453125 0.718750 -v 0.351563 0.359375 0.781250 -v -0.351563 0.359375 0.781250 -v 0.437500 0.328125 0.765625 -v -0.437500 0.328125 0.765625 -v 0.500000 0.390625 0.687500 -v -0.500000 0.390625 0.687500 -v 0.546875 0.437500 0.578125 -v -0.546875 0.437500 0.578125 -v 0.625000 0.242188 0.562500 -v -0.625000 0.242188 0.562500 -v 0.562500 0.242188 0.671875 -v -0.562500 0.242188 0.671875 -v 0.468750 0.242188 0.757813 -v -0.468750 0.242188 0.757813 -v 0.476563 0.242188 0.773438 -v -0.476563 0.242188 0.773438 -v 0.445313 0.335938 0.781250 -v -0.445313 0.335938 0.781250 -v 0.351563 0.375000 0.804688 -v -0.351563 0.375000 0.804688 -v 0.265625 0.335938 0.820313 -v -0.265625 0.335938 0.820313 -v 0.226563 0.242188 0.820313 -v -0.226563 0.242188 0.820313 -v 0.265625 0.156250 0.820313 -v -0.265625 0.156250 0.820313 -v 0.351563 0.242188 0.828125 -v -0.351563 0.242188 0.828125 -v 0.351563 0.117188 0.804688 -v -0.351563 0.117188 0.804688 -v 0.445313 0.156250 0.781250 -v -0.445313 0.156250 0.781250 -v 0.000000 0.429688 0.742188 -v 0.000000 0.351563 0.820313 -v 0.000000 -0.679688 0.734375 -v 0.000000 -0.320313 0.781250 -v 0.000000 -0.187500 0.796875 -v 0.000000 -0.773438 0.718750 -v 0.000000 0.406250 0.601563 -v 0.000000 0.570313 0.570313 -v 0.000000 0.898438 -0.546875 -v 0.000000 0.562500 -0.851563 -v 0.000000 0.070313 -0.828125 -v 0.000000 -0.382813 -0.351563 -v 0.203125 -0.187500 0.562500 -v -0.203125 -0.187500 0.562500 -v 0.312500 -0.437500 0.570313 -v -0.312500 -0.437500 0.570313 -v 0.351563 -0.695313 0.570313 -v -0.351563 -0.695313 0.570313 -v 0.367188 -0.890625 0.531250 -v -0.367188 -0.890625 0.531250 -v 0.328125 -0.945313 0.523438 -v -0.328125 -0.945313 0.523438 -v 0.179688 -0.968750 0.554688 -v -0.179688 -0.968750 0.554688 -v 0.000000 -0.984375 0.578125 -v 0.437500 -0.140625 0.531250 -v -0.437500 -0.140625 0.531250 -v 0.632813 -0.039063 0.539063 -v -0.632813 -0.039063 0.539063 -v 0.828125 0.148438 0.445313 -v -0.828125 0.148438 0.445313 -v 0.859375 0.429688 0.593750 -v -0.859375 0.429688 0.593750 -v 0.710938 0.484375 0.625000 -v -0.710938 0.484375 0.625000 -v 0.492188 0.601563 0.687500 -v -0.492188 0.601563 0.687500 -v 0.320313 0.757813 0.734375 -v -0.320313 0.757813 0.734375 -v 0.156250 0.718750 0.757813 -v -0.156250 0.718750 0.757813 -v 0.062500 0.492188 0.750000 -v -0.062500 0.492188 0.750000 -v 0.164063 0.414063 0.773438 -v -0.164063 0.414063 0.773438 -v 0.125000 0.304688 0.765625 -v -0.125000 0.304688 0.765625 -v 0.203125 0.093750 0.742188 -v -0.203125 0.093750 0.742188 -v 0.375000 0.015625 0.703125 -v -0.375000 0.015625 0.703125 -v 0.492188 0.062500 0.671875 -v -0.492188 0.062500 0.671875 -v 0.625000 0.187500 0.648438 -v -0.625000 0.187500 0.648438 -v 0.640625 0.296875 0.648438 -v -0.640625 0.296875 0.648438 -v 0.601563 0.375000 0.664063 -v -0.601563 0.375000 0.664063 -v 0.429688 0.437500 0.718750 -v -0.429688 0.437500 0.718750 -v 0.250000 0.468750 0.757813 -v -0.250000 0.468750 0.757813 -v 0.000000 -0.765625 0.734375 -v 0.109375 -0.718750 0.734375 -v -0.109375 -0.718750 0.734375 -v 0.117188 -0.835938 0.710938 -v -0.117188 -0.835938 0.710938 -v 0.062500 -0.882813 0.695313 -v -0.062500 -0.882813 0.695313 -v 0.000000 -0.890625 0.687500 -v 0.000000 -0.195313 0.750000 -v 0.000000 -0.140625 0.742188 -v 0.101563 -0.148438 0.742188 -v -0.101563 -0.148438 0.742188 -v 0.125000 -0.226563 0.750000 -v -0.125000 -0.226563 0.750000 -v 0.085938 -0.289063 0.742188 -v -0.085938 -0.289063 0.742188 -v 0.398438 -0.046875 0.671875 -v -0.398438 -0.046875 0.671875 -v 0.617188 0.054688 0.625000 -v -0.617188 0.054688 0.625000 -v 0.726563 0.203125 0.601563 -v -0.726563 0.203125 0.601563 -v 0.742188 0.375000 0.656250 -v -0.742188 0.375000 0.656250 -v 0.687500 0.414063 0.726563 -v -0.687500 0.414063 0.726563 -v 0.437500 0.546875 0.796875 -v -0.437500 0.546875 0.796875 -v 0.312500 0.640625 0.835938 -v -0.312500 0.640625 0.835938 -v 0.203125 0.617188 0.851563 -v -0.203125 0.617188 0.851563 -v 0.101563 0.429688 0.843750 -v -0.101563 0.429688 0.843750 -v 0.125000 -0.101563 0.812500 -v -0.125000 -0.101563 0.812500 -v 0.210938 -0.445313 0.710938 -v -0.210938 -0.445313 0.710938 -v 0.250000 -0.703125 0.687500 -v -0.250000 -0.703125 0.687500 -v 0.265625 -0.820313 0.664063 -v -0.265625 -0.820313 0.664063 -v 0.234375 -0.914063 0.632813 -v -0.234375 -0.914063 0.632813 -v 0.164063 -0.929688 0.632813 -v -0.164063 -0.929688 0.632813 -v 0.000000 -0.945313 0.640625 -v 0.000000 0.046875 0.726563 -v 0.000000 0.210938 0.765625 -v 0.328125 0.476563 0.742188 -v -0.328125 0.476563 0.742188 -v 0.164063 0.140625 0.750000 -v -0.164063 0.140625 0.750000 -v 0.132813 0.210938 0.757813 -v -0.132813 0.210938 0.757813 -v 0.117188 -0.687500 0.734375 -v -0.117188 -0.687500 0.734375 -v 0.078125 -0.445313 0.750000 -v -0.078125 -0.445313 0.750000 -v 0.000000 -0.445313 0.750000 -v 0.000000 -0.328125 0.742188 -v 0.093750 -0.273438 0.781250 -v -0.093750 -0.273438 0.781250 -v 0.132813 -0.226563 0.796875 -v -0.132813 -0.226563 0.796875 -v 0.109375 -0.132813 0.781250 -v -0.109375 -0.132813 0.781250 -v 0.039063 -0.125000 0.781250 -v -0.039063 -0.125000 0.781250 -v 0.000000 -0.203125 0.828125 -v 0.046875 -0.148438 0.812500 -v -0.046875 -0.148438 0.812500 -v 0.093750 -0.156250 0.812500 -v -0.093750 -0.156250 0.812500 -v 0.109375 -0.226563 0.828125 -v -0.109375 -0.226563 0.828125 -v 0.078125 -0.250000 0.804688 -v -0.078125 -0.250000 0.804688 -v 0.000000 -0.289063 0.804688 -v 0.257813 -0.312500 0.554688 -v -0.257813 -0.312500 0.554688 -v 0.164063 -0.242188 0.710938 -v -0.164063 -0.242188 0.710938 -v 0.179688 -0.312500 0.710938 -v -0.179688 -0.312500 0.710938 -v 0.234375 -0.250000 0.554688 -v -0.234375 -0.250000 0.554688 -v 0.000000 -0.875000 0.687500 -v 0.046875 -0.867188 0.687500 -v -0.046875 -0.867188 0.687500 -v 0.093750 -0.820313 0.710938 -v -0.093750 -0.820313 0.710938 -v 0.093750 -0.742188 0.726563 -v -0.093750 -0.742188 0.726563 -v 0.000000 -0.781250 0.656250 -v 0.093750 -0.750000 0.664063 -v -0.093750 -0.750000 0.664063 -v 0.093750 -0.812500 0.640625 -v -0.093750 -0.812500 0.640625 -v 0.046875 -0.851563 0.632813 -v -0.046875 -0.851563 0.632813 -v 0.000000 -0.859375 0.632813 -v 0.171875 0.218750 0.781250 -v -0.171875 0.218750 0.781250 -v 0.187500 0.156250 0.773438 -v -0.187500 0.156250 0.773438 -v 0.335938 0.429688 0.757813 -v -0.335938 0.429688 0.757813 -v 0.273438 0.421875 0.773438 -v -0.273438 0.421875 0.773438 -v 0.421875 0.398438 0.773438 -v -0.421875 0.398438 0.773438 -v 0.562500 0.351563 0.695313 -v -0.562500 0.351563 0.695313 -v 0.585938 0.289063 0.687500 -v -0.585938 0.289063 0.687500 -v 0.578125 0.195313 0.679688 -v -0.578125 0.195313 0.679688 -v 0.476563 0.101563 0.718750 -v -0.476563 0.101563 0.718750 -v 0.375000 0.062500 0.742188 -v -0.375000 0.062500 0.742188 -v 0.226563 0.109375 0.781250 -v -0.226563 0.109375 0.781250 -v 0.179688 0.296875 0.781250 -v -0.179688 0.296875 0.781250 -v 0.210938 0.375000 0.781250 -v -0.210938 0.375000 0.781250 -v 0.234375 0.359375 0.757813 -v -0.234375 0.359375 0.757813 -v 0.195313 0.296875 0.757813 -v -0.195313 0.296875 0.757813 -v 0.242188 0.125000 0.757813 -v -0.242188 0.125000 0.757813 -v 0.375000 0.085938 0.726563 -v -0.375000 0.085938 0.726563 -v 0.460938 0.117188 0.703125 -v -0.460938 0.117188 0.703125 -v 0.546875 0.210938 0.671875 -v -0.546875 0.210938 0.671875 -v 0.554688 0.281250 0.671875 -v -0.554688 0.281250 0.671875 -v 0.531250 0.335938 0.679688 -v -0.531250 0.335938 0.679688 -v 0.414063 0.390625 0.750000 -v -0.414063 0.390625 0.750000 -v 0.281250 0.398438 0.765625 -v -0.281250 0.398438 0.765625 -v 0.335938 0.406250 0.750000 -v -0.335938 0.406250 0.750000 -v 0.203125 0.171875 0.750000 -v -0.203125 0.171875 0.750000 -v 0.195313 0.226563 0.750000 -v -0.195313 0.226563 0.750000 -v 0.109375 0.460938 0.609375 -v -0.109375 0.460938 0.609375 -v 0.195313 0.664063 0.617188 -v -0.195313 0.664063 0.617188 -v 0.335938 0.687500 0.593750 -v -0.335938 0.687500 0.593750 -v 0.484375 0.554688 0.554688 -v -0.484375 0.554688 0.554688 -v 0.679688 0.453125 0.492188 -v -0.679688 0.453125 0.492188 -v 0.796875 0.406250 0.460938 -v -0.796875 0.406250 0.460938 -v 0.773438 0.164063 0.375000 -v -0.773438 0.164063 0.375000 -v 0.601563 0.000000 0.414063 -v -0.601563 0.000000 0.414063 -v 0.437500 -0.093750 0.468750 -v -0.437500 -0.093750 0.468750 -v 0.000000 0.898438 0.289063 -v 0.000000 0.984375 -0.078125 -v 0.000000 -0.195313 -0.671875 -v 0.000000 -0.460938 0.187500 -v 0.000000 -0.976563 0.460938 -v 0.000000 -0.804688 0.343750 -v 0.000000 -0.570313 0.320313 -v 0.000000 -0.484375 0.281250 -v 0.851563 0.234375 0.054688 -v -0.851563 0.234375 0.054688 -v 0.859375 0.320313 -0.046875 -v -0.859375 0.320313 -0.046875 -v 0.773438 0.265625 -0.437500 -v -0.773438 0.265625 -0.437500 -v 0.460938 0.437500 -0.703125 -v -0.460938 0.437500 -0.703125 -v 0.734375 -0.046875 0.070313 -v -0.734375 -0.046875 0.070313 -v 0.593750 -0.125000 -0.164063 -v -0.593750 -0.125000 -0.164063 -v 0.640625 -0.007813 -0.429688 -v -0.640625 -0.007813 -0.429688 -v 0.335938 0.054688 -0.664063 -v -0.335938 0.054688 -0.664063 -v 0.234375 -0.351563 0.406250 -v -0.234375 -0.351563 0.406250 -v 0.179688 -0.414063 0.257813 -v -0.179688 -0.414063 0.257813 -v 0.289063 -0.710938 0.382813 -v -0.289063 -0.710938 0.382813 -v 0.250000 -0.500000 0.390625 -v -0.250000 -0.500000 0.390625 -v 0.328125 -0.914063 0.398438 -v -0.328125 -0.914063 0.398438 -v 0.140625 -0.757813 0.367188 -v -0.140625 -0.757813 0.367188 -v 0.125000 -0.539063 0.359375 -v -0.125000 -0.539063 0.359375 -v 0.164063 -0.945313 0.437500 -v -0.164063 -0.945313 0.437500 -v 0.218750 -0.281250 0.429688 -v -0.218750 -0.281250 0.429688 -v 0.210938 -0.226563 0.468750 -v -0.210938 -0.226563 0.468750 -v 0.203125 -0.171875 0.500000 -v -0.203125 -0.171875 0.500000 -v 0.210938 -0.390625 0.164063 -v -0.210938 -0.390625 0.164063 -v 0.296875 -0.312500 -0.265625 -v -0.296875 -0.312500 -0.265625 -v 0.343750 -0.148438 -0.539063 -v -0.343750 -0.148438 -0.539063 -v 0.453125 0.867188 -0.382813 -v -0.453125 0.867188 -0.382813 -v 0.453125 0.929688 -0.070313 -v -0.453125 0.929688 -0.070313 -v 0.453125 0.851563 0.234375 -v -0.453125 0.851563 0.234375 -v 0.460938 0.523438 0.429688 -v -0.460938 0.523438 0.429688 -v 0.726563 0.406250 0.335938 -v -0.726563 0.406250 0.335938 -v 0.632813 0.453125 0.281250 -v -0.632813 0.453125 0.281250 -v 0.640625 0.703125 0.054688 -v -0.640625 0.703125 0.054688 -v 0.796875 0.562500 0.125000 -v -0.796875 0.562500 0.125000 -v 0.796875 0.617188 -0.117188 -v -0.796875 0.617188 -0.117188 -v 0.640625 0.750000 -0.195313 -v -0.640625 0.750000 -0.195313 -v 0.640625 0.679688 -0.445313 -v -0.640625 0.679688 -0.445313 -v 0.796875 0.539063 -0.359375 -v -0.796875 0.539063 -0.359375 -v 0.617188 0.328125 -0.585938 -v -0.617188 0.328125 -0.585938 -v 0.484375 0.023438 -0.546875 -v -0.484375 0.023438 -0.546875 -v 0.820313 0.328125 -0.203125 -v -0.820313 0.328125 -0.203125 -v 0.406250 -0.171875 0.148438 -v -0.406250 -0.171875 0.148438 -v 0.429688 -0.195313 -0.210938 -v -0.429688 -0.195313 -0.210938 -v 0.890625 0.406250 -0.234375 -v -0.890625 0.406250 -0.234375 -v 0.773438 -0.140625 -0.125000 -v -0.773438 -0.140625 -0.125000 -v 1.039063 -0.101563 -0.328125 -v -1.039063 -0.101563 -0.328125 -v 1.281250 0.054688 -0.429688 -v -1.281250 0.054688 -0.429688 -v 1.351563 0.320313 -0.421875 -v -1.351563 0.320313 -0.421875 -v 1.234375 0.507813 -0.421875 -v -1.234375 0.507813 -0.421875 -v 1.023438 0.476563 -0.312500 -v -1.023438 0.476563 -0.312500 -v 1.015625 0.414063 -0.289063 -v -1.015625 0.414063 -0.289063 -v 1.187500 0.437500 -0.390625 -v -1.187500 0.437500 -0.390625 -v 1.265625 0.289063 -0.406250 -v -1.265625 0.289063 -0.406250 -v 1.210938 0.078125 -0.406250 -v -1.210938 0.078125 -0.406250 -v 1.031250 -0.039063 -0.304688 -v -1.031250 -0.039063 -0.304688 -v 0.828125 -0.070313 -0.132813 -v -0.828125 -0.070313 -0.132813 -v 0.921875 0.359375 -0.218750 -v -0.921875 0.359375 -0.218750 -v 0.945313 0.304688 -0.289063 -v -0.945313 0.304688 -0.289063 -v 0.882813 -0.023438 -0.210938 -v -0.882813 -0.023438 -0.210938 -v 1.039063 0.000000 -0.367188 -v -1.039063 0.000000 -0.367188 -v 1.187500 0.093750 -0.445313 -v -1.187500 0.093750 -0.445313 -v 1.234375 0.250000 -0.445313 -v -1.234375 0.250000 -0.445313 -v 1.171875 0.359375 -0.437500 -v -1.171875 0.359375 -0.437500 -v 1.023438 0.343750 -0.359375 -v -1.023438 0.343750 -0.359375 -v 0.843750 0.289063 -0.210938 -v -0.843750 0.289063 -0.210938 -v 0.835938 0.171875 -0.273438 -v -0.835938 0.171875 -0.273438 -v 0.757813 0.093750 -0.273438 -v -0.757813 0.093750 -0.273438 -v 0.820313 0.085938 -0.273438 -v -0.820313 0.085938 -0.273438 -v 0.843750 0.015625 -0.273438 -v -0.843750 0.015625 -0.273438 -v 0.812500 -0.015625 -0.273438 -v -0.812500 -0.015625 -0.273438 -v 0.726563 0.000000 -0.070313 -v -0.726563 0.000000 -0.070313 -v 0.718750 -0.023438 -0.171875 -v -0.718750 -0.023438 -0.171875 -v 0.718750 0.039063 -0.187500 -v -0.718750 0.039063 -0.187500 -v 0.796875 0.203125 -0.210938 -v -0.796875 0.203125 -0.210938 -v 0.890625 0.242188 -0.265625 -v -0.890625 0.242188 -0.265625 -v 0.890625 0.234375 -0.320313 -v -0.890625 0.234375 -0.320313 -v 0.812500 -0.015625 -0.320313 -v -0.812500 -0.015625 -0.320313 -v 0.851563 0.015625 -0.320313 -v -0.851563 0.015625 -0.320313 -v 0.828125 0.078125 -0.320313 -v -0.828125 0.078125 -0.320313 -v 0.765625 0.093750 -0.320313 -v -0.765625 0.093750 -0.320313 -v 0.843750 0.171875 -0.320313 -v -0.843750 0.171875 -0.320313 -v 1.039063 0.328125 -0.414063 -v -1.039063 0.328125 -0.414063 -v 1.187500 0.343750 -0.484375 -v -1.187500 0.343750 -0.484375 -v 1.257813 0.242188 -0.492188 -v -1.257813 0.242188 -0.492188 -v 1.210938 0.085938 -0.484375 -v -1.210938 0.085938 -0.484375 -v 1.046875 0.000000 -0.421875 -v -1.046875 0.000000 -0.421875 -v 0.882813 -0.015625 -0.265625 -v -0.882813 -0.015625 -0.265625 -v 0.953125 0.289063 -0.343750 -v -0.953125 0.289063 -0.343750 -v 0.890625 0.109375 -0.328125 -v -0.890625 0.109375 -0.328125 -v 0.937500 0.062500 -0.335938 -v -0.937500 0.062500 -0.335938 -v 1.000000 0.125000 -0.367188 -v -1.000000 0.125000 -0.367188 -v 0.960938 0.171875 -0.351563 -v -0.960938 0.171875 -0.351563 -v 1.015625 0.234375 -0.375000 -v -1.015625 0.234375 -0.375000 -v 1.054688 0.187500 -0.382813 -v -1.054688 0.187500 -0.382813 -v 1.109375 0.210938 -0.390625 -v -1.109375 0.210938 -0.390625 -v 1.085938 0.273438 -0.390625 -v -1.085938 0.273438 -0.390625 -v 1.023438 0.437500 -0.484375 -v -1.023438 0.437500 -0.484375 -v 1.250000 0.468750 -0.546875 -v -1.250000 0.468750 -0.546875 -v 1.367188 0.296875 -0.500000 -v -1.367188 0.296875 -0.500000 -v 1.312500 0.054688 -0.531250 -v -1.312500 0.054688 -0.531250 -v 1.039063 -0.085938 -0.492188 -v -1.039063 -0.085938 -0.492188 -v 0.789063 -0.125000 -0.328125 -v -0.789063 -0.125000 -0.328125 -v 0.859375 0.382813 -0.382813 -v -0.859375 0.382813 -0.382813 -v -1.023438 0.476563 -0.312500 -v -1.234375 0.507813 -0.421875 -v -0.890625 0.406250 -0.234375 -v -0.820313 0.328125 -0.203125 -vt 0.315596 0.792535 -vt 0.331462 0.787091 -vt 0.331944 0.799704 -vt 0.049262 0.798007 -vt 0.050304 0.785428 -vt 0.065913 0.791570 -vt 0.321453 0.778649 -vt 0.060677 0.777438 -vt 0.310368 0.778802 -vt 0.071744 0.778083 -vt 0.302416 0.786560 -vt 0.079345 0.786186 -vt 0.301514 0.798474 -vt 0.079717 0.798128 -vt 0.308740 0.806873 -vt 0.072125 0.806199 -vt 0.321648 0.808687 -vt 0.059149 0.807438 -vt 0.048462 0.201858 -vt 0.040084 0.207259 -vt 0.043232 0.202821 -vt 0.043249 0.220655 -vt 0.040093 0.216224 -vt 0.048480 0.221607 -vt 0.563710 0.649220 -vt 0.540594 0.657349 -vt 0.547067 0.627433 -vt 0.974643 0.218739 -vt 0.968169 0.188824 -vt 0.991286 0.196952 -vt 0.166564 0.702856 -vt 0.160061 0.635503 -vt 0.218800 0.643864 -vt 0.646379 0.202310 -vt 0.587641 0.210669 -vt 0.594146 0.143318 -vt 0.231653 0.710981 -vt 0.181122 0.727399 -vt 0.174315 0.716236 -vt 0.601897 0.129938 -vt 0.608704 0.118775 -vt 0.659234 0.135195 -vt 0.266169 0.503056 -vt 0.270502 0.531304 -vt 0.237927 0.525958 -vt 0.665505 0.320215 -vt 0.698081 0.314870 -vt 0.693747 0.343118 -vt 0.392095 0.783569 -vt 0.421339 0.774990 -vt 0.422693 0.793271 -vt 0.628129 0.465996 -vt 0.613733 0.456434 -vt 0.634389 0.436387 -vt 0.501778 0.870396 -vt 0.507486 0.857499 -vt 0.528577 0.865850 -vt 0.643384 0.583025 -vt 0.644052 0.562152 -vt 0.656465 0.561923 -vt 0.766386 0.787223 -vt 0.745292 0.810963 -vt 0.708792 0.802136 -vt 0.769147 0.634951 -vt 0.732033 0.641034 -vt 0.711181 0.618495 -vt 0.849461 0.545148 -vt 0.823375 0.497849 -vt 0.897469 0.500666 -vt 0.902318 0.546395 -vt 0.572425 0.679855 -vt 0.643837 0.668801 -vt 0.623443 0.718088 -vt 0.572425 0.724426 -vt 0.726607 0.540494 -vt 0.753364 0.518460 -vt 0.715449 0.680462 -vt 0.749227 0.698466 -vt 0.695922 0.534580 -vt 0.693526 0.510498 -vt 0.772837 0.655221 -vt 0.784620 0.679820 -vt 0.718163 0.580185 -vt 0.809389 0.599417 -vt 0.761761 0.743313 -vt 0.667750 0.767676 -vt 0.693110 0.564191 -vt 0.797155 0.722534 -vt 0.682009 0.616616 -vt 0.795802 0.787304 -vt 0.719538 0.655221 -vt 0.756895 0.826983 -vt 0.782765 0.655221 -vt 0.695179 0.821970 -vt 0.843059 0.610497 -vt 0.635588 0.780626 -vt 0.634422 0.561399 -vt 0.628274 0.581967 -vt 0.511020 0.847430 -vt 0.533908 0.850607 -vt 0.633815 0.551490 -vt 0.613046 0.571327 -vt 0.530368 0.831407 -vt 0.501394 0.842435 -vt 0.626589 0.538875 -vt 0.604527 0.544684 -vt 0.508929 0.810914 -vt 0.492547 0.829318 -vt 0.618247 0.522587 -vt 0.602583 0.501781 -vt 0.480939 0.813120 -vt 0.469234 0.787943 -vt 0.616652 0.502716 -vt 0.613925 0.497595 -vt 0.459358 0.796431 -vt 0.462840 0.801566 -vt 0.644899 0.511966 -vt 0.630336 0.517087 -vt 0.628893 0.504351 -vt 0.635735 0.498392 -vt 0.458270 0.813966 -vt 0.469630 0.821874 -vt 0.457144 0.833207 -vt 0.449054 0.817297 -vt 0.637359 0.534149 -vt 0.654293 0.524569 -vt 0.464258 0.849211 -vt 0.482600 0.837505 -vt 0.644187 0.548520 -vt 0.659377 0.540935 -vt 0.478087 0.863369 -vt 0.493557 0.851414 -vt 0.597230 0.539263 -vt 0.595257 0.495349 -vt 0.466971 0.777596 -vt 0.507407 0.801398 -vt 0.605628 0.572478 -vt 0.534801 0.825096 -vt 0.627145 0.592333 -vt 0.544318 0.853620 -vt 0.651887 0.586528 -vt 0.528822 0.875551 -vt 0.665532 0.557472 -vt 0.492878 0.878439 -vt 0.669345 0.535984 -vt 0.467321 0.871200 -vt 0.612569 0.491986 -vt 0.454710 0.792385 -vt 0.619277 0.495381 -vt 0.454636 0.800448 -vt 0.628580 0.496763 -vt 0.451294 0.809743 -vt 0.636682 0.490206 -vt 0.440853 0.813605 -vt 0.652342 0.504728 -vt 0.446182 0.836397 -vt 0.664409 0.519225 -vt 0.453285 0.856119 -vt 0.666191 0.492411 -vt 0.717596 0.474672 -vt 0.382398 0.879324 -vt 0.427166 0.842398 -vt 0.681733 0.511408 -vt 0.427493 0.877628 -vt 0.435523 0.867805 -vt 0.685777 0.532869 -vt 0.453231 0.887054 -vt 0.588528 0.478377 -vt 0.454313 0.762782 -vt 0.446975 0.900429 -vt 0.713425 0.237886 -vt 0.709019 0.215724 -vt 0.755152 0.224403 -vt 0.762923 0.242445 -vt 0.327574 0.621771 -vt 0.281440 0.630451 -vt 0.285847 0.608289 -vt 0.335345 0.603729 -vt 0.576794 0.465515 -vt 0.583867 0.423087 -vt 0.405805 0.730353 -vt 0.448347 0.745304 -vt 0.686035 0.253032 -vt 0.258456 0.593142 -vt 0.683851 0.556229 -vt 0.482266 0.899349 -vt 0.670531 0.597684 -vt 0.532990 0.898426 -vt 0.630909 0.604157 -vt 0.553941 0.861896 -vt 0.596864 0.576275 -vt 0.542184 0.818594 -vt 0.585561 0.529242 -vt 0.503791 0.785451 -vt 0.572425 0.529736 -vt 0.510638 0.773572 -vt 0.587548 0.588270 -vt 0.557294 0.815416 -vt 0.629961 0.623919 -vt 0.572425 0.868524 -vt 0.548104 0.914571 -vt 0.488130 0.914571 -vt 0.658830 0.266292 -vt 0.631691 0.281488 -vt 0.204112 0.564686 -vt 0.231252 0.579881 -vt 0.706402 0.288928 -vt 0.278823 0.557246 -vt 0.743528 0.317934 -vt 0.752264 0.346660 -vt 0.324686 0.499513 -vt 0.315950 0.528240 -vt 0.743309 0.289810 -vt 0.315731 0.556363 -vt 0.700326 0.147967 -vt 0.272746 0.698208 -vt 0.795874 0.266472 -vt 0.775660 0.289442 -vt 0.757507 0.263314 -vt 0.348083 0.556732 -vt 0.329929 0.582860 -vt 0.368297 0.579702 -vt 0.804056 0.232825 -vt 0.376478 0.613349 -vt 0.810124 0.179100 -vt 0.382547 0.667075 -vt 0.753847 0.157090 -vt 0.811201 0.146834 -vt 0.383624 0.699341 -vt 0.326269 0.689085 -vt 0.879685 0.183943 -vt 0.888071 0.157228 -vt 0.460496 0.688946 -vt 0.452109 0.662231 -vt 0.925222 0.140531 -vt 0.947451 0.149372 -vt 0.519876 0.696801 -vt 0.497647 0.705643 -vt 0.876420 0.258223 -vt 0.946138 0.286262 -vt 0.518561 0.559910 -vt 0.448843 0.587951 -vt 0.829953 0.196170 -vt 0.837053 0.152275 -vt 0.409477 0.693900 -vt 0.402377 0.650004 -vt 0.829888 0.255993 -vt 0.402311 0.590181 -vt 0.852096 0.297194 -vt 0.813695 0.289418 -vt 0.424519 0.548979 -vt 0.386117 0.556756 -vt 0.820842 0.328587 -vt 0.789451 0.311961 -vt 0.393264 0.517587 -vt 0.361873 0.534212 -vt 0.840465 0.403536 -vt 0.762603 0.423087 -vt 0.412887 0.442637 -vt 0.335024 0.423087 -vt 0.909248 0.345901 -vt 0.481670 0.500271 -vt 0.676670 0.402805 -vt 0.249092 0.443369 -vt 0.573469 0.193539 -vt 0.579214 0.151927 -vt 0.151632 0.694246 -vt 0.145888 0.652633 -vt 0.546919 0.227092 -vt 0.536510 0.214419 -vt 0.119340 0.619080 -vt 0.108931 0.631753 -vt 0.588792 0.317539 -vt 0.161214 0.528634 -vt 0.630429 0.371564 -vt 0.202851 0.474609 -vt 0.657494 0.118541 -vt 0.164237 0.319427 -vt 0.169464 0.304721 -vt 0.210459 0.345510 -vt 0.169574 0.118572 -vt 0.164356 0.103821 -vt 0.210731 0.077759 -vt 0.229913 0.727634 -vt 0.589956 0.115821 -vt 0.153468 0.300432 -vt 0.153526 0.122857 -vt 0.162374 0.730353 -vt 0.578472 0.119429 -vt 0.553653 0.120209 -vt 0.126070 0.725964 -vt 0.150890 0.726744 -vt 0.546510 0.159800 -vt 0.509384 0.119033 -vt 0.081800 0.727137 -vt 0.118929 0.686371 -vt 0.534072 0.185482 -vt 0.106492 0.660689 -vt 0.462352 0.161885 -vt 0.478174 0.145123 -vt 0.493641 0.175543 -vt 0.505521 0.150780 -vt 0.077939 0.695390 -vt 0.050592 0.701044 -vt 0.066060 0.670626 -vt 0.034770 0.684282 -vt 0.476706 0.124129 -vt 0.049122 0.722039 -vt 0.465324 0.131169 -vt 0.037741 0.714998 -vt 0.446348 0.149671 -vt 0.018765 0.696495 -vt 0.445483 0.184898 -vt 0.427581 0.175095 -vt 0.000000 0.671069 -vt 0.017903 0.661268 -vt 0.480167 0.198327 -vt 0.052588 0.647841 -vt 0.521714 0.207472 -vt 0.094135 0.638699 -vt 0.701979 0.120236 -vt 0.274400 0.725940 -vt 0.757541 0.138176 -vt 0.329963 0.708000 -vt 0.817327 0.117813 -vt 0.389751 0.728363 -vt 0.844767 0.126748 -vt 0.417191 0.719428 -vt 0.893893 0.126476 -vt 0.466319 0.719698 -vt 0.936543 0.115821 -vt 0.508970 0.730353 -vt 0.965717 0.128368 -vt 0.538144 0.717805 -vt 0.989276 0.166159 -vt 0.561701 0.680013 -vt 1.000000 0.175243 -vt 0.572425 0.670929 -vt 0.289028 0.269037 -vt 0.283878 0.263049 -vt 0.299187 0.258321 -vt 0.300964 0.267357 -vt 0.299421 0.165436 -vt 0.284101 0.160633 -vt 0.289287 0.154655 -vt 0.301244 0.156393 -vt 0.317793 0.260767 -vt 0.316733 0.267304 -vt 0.318078 0.163079 -vt 0.317052 0.156521 -vt 0.335398 0.269583 -vt 0.330421 0.276220 -vt 0.335777 0.154335 -vt 0.330824 0.147649 -vt 0.278552 0.277080 -vt 0.273734 0.272912 -vt 0.273975 0.150706 -vt 0.278818 0.146548 -vt 0.271078 0.306358 -vt 0.264864 0.305818 -vt 0.265194 0.117691 -vt 0.271427 0.117166 -vt 0.278613 0.324240 -vt 0.274006 0.327477 -vt 0.274436 0.095993 -vt 0.279049 0.099253 -vt 0.298062 0.342565 -vt 0.294660 0.349561 -vt 0.295240 0.073895 -vt 0.298634 0.080932 -vt 0.312476 0.342961 -vt 0.315033 0.350198 -vt 0.315702 0.073322 -vt 0.313108 0.080584 -vt 0.323281 0.337709 -vt 0.328696 0.344302 -vt 0.329405 0.079293 -vt 0.323940 0.085897 -vt 0.335361 0.313857 -vt 0.339396 0.315576 -vt 0.340031 0.108187 -vt 0.335968 0.109893 -vt 0.339920 0.298303 -vt 0.345292 0.298556 -vt 0.345869 0.125306 -vt 0.340471 0.125531 -vt 0.339277 0.286081 -vt 0.344398 0.284332 -vt 0.344895 0.139582 -vt 0.339764 0.137799 -vt 0.345671 0.260159 -vt 0.355483 0.280619 -vt 0.356003 0.143373 -vt 0.346021 0.163854 -vt 0.356162 0.297750 -vt 0.356783 0.126174 -vt 0.349494 0.319809 -vt 0.350195 0.103982 -vt 0.333524 0.354692 -vt 0.334295 0.068869 -vt 0.317323 0.364551 -vt 0.318050 0.058911 -vt 0.293154 0.361782 -vt 0.293765 0.061619 -vt 0.263750 0.335417 -vt 0.264168 0.087998 -vt 0.251373 0.309082 -vt 0.251676 0.114380 -vt 0.264926 0.265507 -vt 0.265122 0.158092 -vt 0.278030 0.255522 -vt 0.278212 0.168150 -vt 0.320744 0.246538 -vt 0.320956 0.177355 -vt 0.296570 0.247318 -vt 0.296748 0.176443 -vt 0.038845 0.211743 -vt 0.047440 0.211734 -vt 0.055230 0.211728 -vt 0.057303 0.228458 -vt 0.057278 0.194991 -vt 0.041287 0.229096 -vt 0.041253 0.194380 -vt 0.032564 0.220061 -vt 0.032546 0.203437 -vt 0.030743 0.211752 -vt 0.029931 0.223131 -vt 0.028053 0.211756 -vt 0.029906 0.200372 -vt 0.038587 0.233067 -vt 0.038544 0.190412 -vt 0.061533 0.231825 -vt 0.061505 0.191616 -vt 0.057382 0.211726 -vt 0.168191 0.258703 -vt 0.213958 0.246887 -vt 0.214040 0.176591 -vt 0.168236 0.164676 -vt 0.148297 0.258447 -vt 0.138777 0.299079 -vt 0.138791 0.124216 -vt 0.148319 0.164919 -vt 0.115455 0.259296 -vt 0.109657 0.296761 -vt 0.109611 0.126556 -vt 0.115440 0.164070 -vt 0.119233 0.228698 -vt 0.156540 0.233552 -vt 0.156556 0.189842 -vt 0.119230 0.194690 -vt 0.173998 0.244074 -vt 0.174035 0.179329 -vt 0.195860 0.238258 -vt 0.195909 0.185188 -vt 0.203534 0.211734 -vt 0.252997 0.211802 -vt 0.171285 0.225095 -vt 0.164455 0.211704 -vt 0.180017 0.211713 -vt 0.177113 0.227468 -vt 0.171300 0.198319 -vt 0.177134 0.195952 -vt 0.185539 0.227013 -vt 0.187516 0.221322 -vt 0.187531 0.202116 -vt 0.185563 0.196419 -vt 0.176585 0.232500 -vt 0.165993 0.229894 -vt 0.176611 0.190916 -vt 0.166011 0.193512 -vt 0.189406 0.230672 -vt 0.189438 0.192766 -vt 0.193574 0.221791 -vt 0.193592 0.201656 -vt 0.186479 0.211718 -vt 0.156919 0.211701 -vt 0.148476 0.211699 -vt 0.427853 0.115821 -vt 0.427581 0.104121 -vt 0.441185 0.104121 -vt 0.427581 0.011703 -vt 0.427581 0.000000 -vt 0.441181 0.011386 -vt 0.067509 0.234045 -vt 0.071465 0.211716 -vt 0.067479 0.189385 -vt 0.119764 0.211696 -vt 0.060932 0.261035 -vt 0.038121 0.261699 -vt 0.038025 0.161756 -vt 0.060860 0.162382 -vt 0.019864 0.255578 -vt 0.019760 0.167921 -vt 0.016617 0.242679 -vt 0.016537 0.180842 -vt 0.014466 0.211775 -vt 0.297831 0.211892 -vt 0.340508 0.212027 -vt 0.356498 0.241635 -vt 0.356742 0.182510 -vt 0.236517 0.317748 -vt 0.236802 0.105655 -vt 0.264789 0.363401 -vt 0.265286 0.059917 -vt 0.296951 0.385966 -vt 0.297650 0.037339 -vt 0.337996 0.385300 -vt 0.338890 0.038126 -vt 0.349401 0.368365 -vt 0.350300 0.055183 -vt 0.377282 0.319664 -vt 0.378129 0.104260 -vt 0.394788 0.292204 -vt 0.395576 0.131978 -vt 0.391029 0.270263 -vt 0.391643 0.154015 -vt 0.368661 0.212151 -vt 0.379482 0.228055 -vt 0.379686 0.196331 -vt 0.420379 0.261837 -vt 0.421104 0.162716 -vt 0.426533 0.298960 -vt 0.427581 0.125377 -vt 0.396664 0.342212 -vt 0.397734 0.081667 -vt 0.365156 0.387054 -vt 0.366203 0.036443 -vt 0.346744 0.416452 -vt 0.347768 0.006839 -vt 0.278009 0.423087 -vt 0.278714 0.000000 -vt 0.241964 0.376122 -vt 0.242399 0.047096 -vt 0.055563 0.291878 -vt 0.055443 0.131506 -vt 0.014495 0.288026 -vt 0.014318 0.135436 -vt 0.003828 0.279132 -vt 0.003650 0.144368 -vt 0.000113 0.248111 -vt 0.000000 0.175447 -vt 0.000000 0.211799 -vt 0.046962 0.798865 -vt 0.047306 0.784561 -vt 0.334495 0.786358 -vt 0.334204 0.800664 -vt 0.058429 0.773633 -vt 0.323868 0.774947 -vt 0.072992 0.774071 -vt 0.309301 0.774739 -vt 0.084403 0.784016 -vt 0.297459 0.784168 -vt 0.083417 0.800146 -vt 0.297728 0.800325 -vt 0.073091 0.810538 -vt 0.307582 0.811166 -vt 0.057505 0.810093 -vt 0.323173 0.811412 -vt 0.024988 0.807478 -vt 0.047717 0.829014 -vt 0.332112 0.830749 -vt 0.355774 0.810244 -vt 0.000000 0.817350 -vt 0.033121 0.852785 -vt 0.345638 0.855146 -vt 0.380299 0.821215 -vt 0.083391 0.855019 -vt 0.078555 0.829097 -vt 0.301299 0.829463 -vt 0.295318 0.855146 -vt 0.100718 0.807888 -vt 0.280100 0.807291 -vt 0.123146 0.821929 -vt 0.257070 0.820323 -vt 0.127501 0.768220 -vt 0.103229 0.776171 -vt 0.279000 0.775494 -vt 0.255105 0.766472 -vt 0.079351 0.756089 -vt 0.303746 0.756492 -vt 0.089008 0.730353 -vt 0.295241 0.730353 -vt 0.049398 0.755271 -vt 0.035422 0.733227 -vt 0.333706 0.757005 -vt 0.348646 0.735604 -vt 0.026877 0.776230 -vt 0.355274 0.778943 -vt 0.000000 0.770061 -vt 0.382398 0.773973 -vn 0.189764 -0.003571 0.981811 -vn 0.646809 -0.758202 0.082095 -vn 0.999573 -0.014496 -0.024445 -vn -0.999573 -0.014496 -0.024445 -vn -0.646809 -0.758202 0.082095 -vn -0.189764 -0.003571 0.981811 -vn -0.085788 -0.982971 0.162389 -vn 0.085788 -0.982971 0.162389 -vn -0.744835 -0.623768 0.236824 -vn 0.744835 -0.623768 0.236824 -vn -0.870968 -0.014710 0.491104 -vn 0.870968 -0.014710 0.491104 -vn -0.758354 0.606128 0.239692 -vn 0.758354 0.606128 0.239692 -vn -0.085788 0.982513 0.165105 -vn 0.085788 0.982513 0.165105 -vn 0.655141 0.750633 0.085574 -vn -0.655141 0.750633 0.085574 -vn -0.349284 -0.719932 0.599719 -vn -0.173681 0.215735 0.960845 -vn -0.809839 0.388287 0.439741 -vn 0.809839 0.388287 0.439741 -vn 0.173681 0.215735 0.960845 -vn 0.349284 -0.719932 0.599719 -vn 0.000000 0.794183 0.607654 -vn -0.508652 0.858119 -0.069887 -vn 0.000000 0.487075 0.873348 -vn 0.508652 0.858119 -0.069887 -vn 0.981414 -0.186682 0.043947 -vn 0.569811 -0.821711 0.007813 -vn 0.563463 -0.814570 0.137669 -vn -0.563463 -0.814570 0.137669 -vn -0.569811 -0.821711 0.007813 -vn -0.981414 -0.186682 0.043947 -vn 0.475845 -0.876247 0.075381 -vn 0.850520 -0.525529 -0.020692 -vn 0.876949 -0.163823 0.451766 -vn -0.876949 -0.163823 0.451766 -vn -0.850520 -0.525529 -0.020692 -vn -0.475845 -0.876247 0.075381 -vn 0.448286 -0.367870 -0.814661 -vn 0.530534 -0.539445 -0.653829 -vn 0.513077 -0.674673 -0.530595 -vn -0.513077 -0.674673 -0.530595 -vn -0.530534 -0.539445 -0.653829 -vn -0.448286 -0.367870 -0.814661 -vn 0.888180 -0.439955 -0.132389 -vn 0.588519 0.226966 0.775933 -vn 0.911527 -0.115268 0.394665 -vn -0.911527 -0.115268 0.394665 -vn -0.588519 0.226966 0.775933 -vn -0.888180 -0.439955 -0.132389 -vn 0.468886 -0.304727 0.829005 -vn 0.251564 0.260781 0.932005 -vn -0.003082 -0.330882 0.943632 -vn 0.003082 -0.330882 0.943632 -vn -0.251564 0.260781 0.932005 -vn -0.468886 -0.304727 0.829005 -vn 0.473067 0.578997 -0.664022 -vn 0.992462 0.028626 -0.118900 -vn 0.459975 -0.380261 -0.802362 -vn -0.459975 -0.380261 -0.802362 -vn -0.992462 0.028626 -0.118900 -vn -0.473067 0.578997 -0.664022 -vn -0.059908 -0.804712 -0.590594 -vn -0.346141 -0.637287 -0.688498 -vn -0.330546 -0.943236 0.031281 -vn -0.073672 -0.594989 0.800317 -vn 0.330546 -0.943236 0.031281 -vn 0.346141 -0.637287 -0.688498 -vn 0.059908 -0.804712 -0.590594 -vn 0.073672 -0.594989 0.800317 -vn 0.593738 0.595264 -0.541368 -vn -0.626057 -0.002686 -0.779748 -vn 0.626057 -0.002686 -0.779748 -vn -0.593738 0.595264 -0.541368 -vn 0.127689 0.703757 0.698843 -vn -0.713828 0.382183 0.586810 -vn 0.713828 0.382183 0.586810 -vn -0.127689 0.703757 0.698843 -vn 0.378063 0.560045 -0.737144 -vn 0.036805 -0.708457 -0.704764 -vn -0.378063 0.560045 -0.737144 -vn -0.036805 -0.708457 -0.704764 -vn -0.031556 0.838710 0.543626 -vn 0.031556 0.838710 0.543626 -vn -0.361156 0.848689 0.386303 -vn 0.361156 0.848689 0.386303 -vn -0.716392 0.204474 0.667043 -vn 0.716392 0.204474 0.667043 -vn -0.662038 -0.413770 0.624866 -vn 0.662038 -0.413770 0.624866 -vn -0.530229 -0.655751 0.537370 -vn 0.530229 -0.655751 0.537370 -vn -0.437483 0.001221 0.899197 -vn 0.550981 -0.138096 0.822993 -vn 0.437483 0.001221 0.899197 -vn -0.550981 -0.138096 0.822993 -vn -0.315958 -0.102298 0.943205 -vn 0.608539 0.296121 0.736167 -vn -0.608539 0.296121 0.736167 -vn 0.315958 -0.102298 0.943205 -vn -0.445479 -0.088778 0.890866 -vn -0.257698 0.600024 0.757317 -vn 0.257698 0.600024 0.757317 -vn 0.445479 -0.088778 0.890866 -vn -0.327799 0.169927 0.929319 -vn 0.041780 0.927213 0.372112 -vn 0.327799 0.169927 0.929319 -vn -0.041780 0.927213 0.372112 -vn -0.277932 0.260201 0.924680 -vn -0.750725 0.111545 0.651112 -vn 0.750725 0.111545 0.651112 -vn 0.277932 0.260201 0.924680 -vn -0.437910 -0.293985 0.849574 -vn -0.183782 0.036836 0.982269 -vn -0.554216 0.387219 0.736808 -vn -0.814325 0.253426 0.522111 -vn 0.554216 0.387219 0.736808 -vn 0.183782 0.036836 0.982269 -vn 0.437910 -0.293985 0.849574 -vn 0.814325 0.253426 0.522111 -vn -0.326670 -0.001617 0.945128 -vn -0.704337 -0.526872 0.475692 -vn 0.704337 -0.526872 0.475692 -vn 0.326670 -0.001617 0.945128 -vn -0.308786 0.134617 0.941527 -vn -0.629170 -0.371441 0.682730 -vn 0.629170 -0.371441 0.682730 -vn 0.308786 0.134617 0.941527 -vn 0.146184 0.948637 0.280465 -vn -0.137516 0.905820 0.400708 -vn 0.137516 0.905820 0.400708 -vn -0.146184 0.948637 0.280465 -vn 0.723746 0.690023 -0.005219 -vn -0.723746 0.690023 -0.005219 -vn 0.994690 -0.078005 0.067019 -vn -0.994690 -0.078005 0.067019 -vn 0.200934 -0.758141 0.620350 -vn -0.200934 -0.758141 0.620350 -vn -0.541246 -0.672658 0.504501 -vn 0.541246 -0.672658 0.504501 -vn -0.690054 -0.553209 0.466628 -vn 0.690054 -0.553209 0.466628 -vn -0.464003 0.686666 0.559557 -vn 0.464003 0.686666 0.559557 -vn -0.827448 -0.135899 0.544786 -vn 0.827448 -0.135899 0.544786 -vn -0.466231 0.808863 0.358196 -vn 0.466231 0.808863 0.358196 -vn -0.743980 -0.022919 0.667776 -vn 0.743980 -0.022919 0.667776 -vn -0.711295 -0.638325 0.294137 -vn 0.711295 -0.638325 0.294137 -vn -0.709769 -0.501999 0.494125 -vn 0.709769 -0.501999 0.494125 -vn -0.818903 -0.425520 0.385113 -vn -0.992523 -0.071444 -0.098758 -vn 0.992523 -0.071444 -0.098758 -vn 0.818903 -0.425520 0.385113 -vn -0.439192 -0.273568 0.855708 -vn 0.439192 -0.273568 0.855708 -vn -0.414686 -0.059877 0.907956 -vn 0.414686 -0.059877 0.907956 -vn -0.341563 0.452132 0.823939 -vn 0.341563 0.452132 0.823939 -vn -0.724509 -0.684927 0.076632 -vn -0.987548 -0.123020 0.097995 -vn 0.987548 -0.123020 0.097995 -vn 0.724509 -0.684927 0.076632 -vn -0.572741 -0.088443 0.814936 -vn 0.572741 -0.088443 0.814936 -vn -0.291818 -0.152104 0.944273 -vn 0.291818 -0.152104 0.944273 -vn 0.239662 -0.128605 0.962279 -vn -0.239662 -0.128605 0.962279 -vn 0.187017 0.370678 0.909696 -vn -0.187017 0.370678 0.909696 -vn -0.455794 0.423170 0.783044 -vn 0.455794 0.423170 0.783044 -vn -0.543504 -0.813379 -0.207343 -vn -0.560045 -0.814417 -0.151738 -vn 0.560045 -0.814417 -0.151738 -vn 0.543504 -0.813379 -0.207343 -vn -0.615375 -0.087649 -0.783319 -vn -0.447310 0.229530 -0.864406 -vn 0.447310 0.229530 -0.864406 -vn 0.615375 -0.087649 -0.783319 -vn -0.547166 -0.832179 -0.089785 -vn 0.547166 -0.832179 -0.089785 -vn -0.873135 0.486984 -0.020264 -vn -0.865352 0.331217 -0.376049 -vn 0.865352 0.331217 -0.376049 -vn 0.873135 0.486984 -0.020264 -vn -0.748741 0.518387 0.413038 -vn 0.748741 0.518387 0.413038 -vn -0.766167 0.634816 0.099612 -vn 0.766167 0.634816 0.099612 -vn -0.953185 -0.248299 -0.172430 -vn -0.665639 0.602496 -0.440321 -vn 0.665639 0.602496 -0.440321 -vn 0.953185 -0.248299 -0.172430 -vn -0.322642 0.847713 0.421033 -vn -0.188574 0.788934 -0.584765 -vn 0.188574 0.788934 -0.584765 -vn 0.322642 0.847713 0.421033 -vn -0.239784 0.745262 -0.622120 -vn 0.494247 0.520585 -0.696158 -vn -0.494247 0.520585 -0.696158 -vn 0.239784 0.745262 -0.622120 -vn -0.480697 0.731223 0.483932 -vn 0.000000 0.758690 0.651418 -vn 0.480697 0.731223 0.483932 -vn -0.489242 0.762963 0.422498 -vn -0.363109 0.908567 -0.206458 -vn 0.363109 0.908567 -0.206458 -vn 0.489242 0.762963 0.422498 -vn -0.645039 0.694540 0.318613 -vn 0.645039 0.694540 0.318613 -vn -0.492843 0.869015 0.043062 -vn -0.679434 0.728965 -0.083468 -vn 0.492843 0.869015 0.043062 -vn 0.679434 0.728965 -0.083468 -vn -0.391736 0.826014 -0.405225 -vn -0.644398 0.527207 -0.553880 -vn 0.391736 0.826014 -0.405225 -vn 0.644398 0.527207 -0.553880 -vn 0.000000 0.800714 -0.599017 -vn 0.000000 0.330729 -0.943693 -vn 0.000000 0.999664 0.025636 -vn 0.000000 -0.271462 -0.962432 -vn -0.685293 -0.583148 -0.436232 -vn -0.907224 0.252602 -0.336253 -vn 0.907224 0.252602 -0.336253 -vn 0.685293 -0.583148 -0.436232 -vn 0.000000 -0.984344 -0.176214 -vn 0.000000 -0.736351 -0.676565 -vn 0.000000 -0.948759 -0.315928 -vn 0.000000 -0.648244 -0.761406 -vn -0.317362 -0.946959 -0.049959 -vn -0.838282 -0.408155 0.361461 -vn 0.838282 -0.408155 0.361461 -vn 0.317362 -0.946959 -0.049959 -vn -0.939360 0.325999 0.106113 -vn 0.939360 0.325999 0.106113 -vn -0.930631 0.340159 0.134770 -vn -0.960143 0.231361 0.156774 -vn 0.960143 0.231361 0.156774 -vn 0.930631 0.340159 0.134770 -vn -0.812555 -0.001068 -0.582842 -vn -0.979583 0.093387 0.177862 -vn 0.979583 0.093387 0.177862 -vn 0.812555 -0.001068 -0.582842 -vn -0.272530 -0.301157 -0.913785 -vn 0.272530 -0.301157 -0.913785 -vn -0.090915 -0.776330 -0.623707 -vn -0.506851 -0.488144 -0.710471 -vn -0.142521 -0.147282 -0.978759 -vn -0.637257 0.093326 -0.764946 -vn 0.637257 0.093326 -0.764946 -vn 0.506851 -0.488144 -0.710471 -vn 0.142521 -0.147282 -0.978759 -vn 0.090915 -0.776330 -0.623707 -vn -0.937284 -0.254250 0.238350 -vn 0.937284 -0.254250 0.238350 -vn -0.430525 -0.895260 0.114597 -vn 0.430525 -0.895260 0.114597 -vn -0.158391 -0.974822 0.156774 -vn 0.158391 -0.974822 0.156774 -vn 0.000000 -0.915860 -0.401440 -vn 0.000000 -0.946440 0.322855 -vn 0.000000 -0.336802 -0.941557 -vn 0.000000 -0.175726 -0.984436 -vn -0.599231 -0.773980 0.204566 -vn 0.599231 -0.773980 0.204566 -vn -0.890988 -0.423261 -0.164037 -vn 0.890988 -0.423261 -0.164037 -vn -0.851985 0.219275 0.475387 -vn 0.851985 0.219275 0.475387 -vn -0.509171 0.852229 0.119999 -vn 0.509171 0.852229 0.119999 -vn -0.610431 0.759148 0.225867 -vn 0.610431 0.759148 0.225867 -vn -0.182470 0.981780 0.052492 -vn 0.182470 0.981780 0.052492 -vn 0.520371 0.770348 0.368389 -vn -0.520371 0.770348 0.368389 -vn 0.852718 0.504257 0.136204 -vn -0.852718 0.504257 0.136204 -vn 0.000000 0.970214 0.242164 -vn -0.709647 0.261818 0.654042 -vn 0.067293 -0.064272 0.995636 -vn -0.246590 -0.034089 0.968505 -vn -0.809717 -0.010224 0.586688 -vn 0.246590 -0.034089 0.968505 -vn -0.067293 -0.064272 0.995636 -vn 0.709647 0.261818 0.654042 -vn 0.809717 -0.010224 0.586688 -vn -0.465835 -0.080325 0.881191 -vn -0.737114 -0.244179 0.630085 -vn 0.465835 -0.080325 0.881191 -vn 0.737114 -0.244179 0.630085 -vn -0.211951 -0.085971 0.973479 -vn -0.367504 -0.376476 0.850398 -vn 0.211951 -0.085971 0.973479 -vn 0.367504 -0.376476 0.850398 -vn -0.430280 0.556597 0.710624 -vn -0.020081 -0.072939 0.997131 -vn 0.020081 -0.072939 0.997131 -vn 0.430280 0.556597 0.710624 -vn -0.090976 0.597339 0.796777 -vn -0.187933 -0.091617 0.977874 -vn 0.187933 -0.091617 0.977874 -vn 0.090976 0.597339 0.796777 -vn 0.165929 0.609363 0.775292 -vn -0.203314 0.092532 0.974700 -vn 0.203314 0.092532 0.974700 -vn -0.165929 0.609363 0.775292 -vn 0.269295 0.241676 0.932218 -vn -0.314219 -0.132420 0.940062 -vn 0.314219 -0.132420 0.940062 -vn -0.269295 0.241676 0.932218 -vn 0.420057 -0.118992 0.899625 -vn -0.119755 -0.070925 0.990234 -vn 0.119755 -0.070925 0.990234 -vn -0.420057 -0.118992 0.899625 -vn 0.226142 -0.606586 0.762139 -vn -0.320841 0.040712 0.946226 -vn 0.320841 0.040712 0.946226 -vn -0.226142 -0.606586 0.762139 -vn 0.232612 -0.746055 0.623890 -vn -0.074557 -0.391644 0.917081 -vn 0.074557 -0.391644 0.917081 -vn -0.232612 -0.746055 0.623890 -vn -0.121250 -0.313883 0.941679 -vn -0.146702 -0.035707 0.988525 -vn 0.146702 -0.035707 0.988525 -vn 0.121250 -0.313883 0.941679 -vn -0.216834 -0.273721 0.937010 -vn -0.187445 0.001160 0.982269 -vn 0.187445 0.001160 0.982269 -vn 0.216834 -0.273721 0.937010 -vn -0.303018 -0.201941 0.931333 -vn -0.253090 -0.161809 0.953795 -vn 0.253090 -0.161809 0.953795 -vn 0.303018 -0.201941 0.931333 -vn -0.140110 -0.091189 0.985900 -vn 0.140110 -0.091189 0.985900 -vn -0.237983 0.050172 0.969939 -vn 0.237983 0.050172 0.969939 -vn -0.312662 -0.237922 0.919553 -vn 0.312662 -0.237922 0.919553 -vn -0.373791 -0.105197 0.921506 -vn 0.373791 -0.105197 0.921506 -vn -0.470595 -0.164647 0.866817 -vn 0.470595 -0.164647 0.866817 -vn -0.439222 -0.376141 0.815821 -vn 0.439222 -0.376141 0.815821 -vn -0.219611 -0.540635 0.812037 -vn 0.219611 -0.540635 0.812037 -vn 0.166967 -0.374828 0.911893 -vn -0.166967 -0.374828 0.911893 -vn 0.201849 -0.277596 0.939238 -vn -0.201849 -0.277596 0.939238 -vn 0.001160 -0.165563 0.986175 -vn -0.001160 -0.165563 0.986175 -vn 0.292917 -0.174108 0.940123 -vn -0.292917 -0.174108 0.940123 -vn 0.000000 0.732200 0.681051 -vn 0.000000 -0.603626 0.797266 -vn 0.000000 -0.971740 0.235908 -vn 0.131779 -0.608295 0.782678 -vn -0.131779 -0.608295 0.782678 -vn 0.759117 0.068392 0.647298 -vn -0.759117 0.068392 0.647298 -vn 0.405957 0.643605 0.648793 -vn -0.405957 0.643605 0.648793 -vn 0.000000 0.598346 0.801202 -vn 0.073855 -0.330546 0.940855 -vn 0.000000 -0.124516 0.992187 -vn -0.073855 -0.330546 0.940855 -vn -0.085116 -0.339244 0.936827 -vn 0.085116 -0.339244 0.936827 -vn -0.141881 -0.148350 0.978698 -vn 0.141881 -0.148350 0.978698 -vn 0.000000 -0.482803 0.875698 -vn -0.692984 -0.001343 0.720908 -vn -0.095523 -0.326090 0.940489 -vn 0.095523 -0.326090 0.940489 -vn 0.692984 -0.001343 0.720908 -vn -0.646687 0.162603 0.745201 -vn 0.646687 0.162603 0.745201 -vn -0.593463 0.121860 0.795556 -vn 0.593463 0.121860 0.795556 -vn -0.124363 0.009674 0.992187 -vn -0.509995 -0.457717 0.728233 -vn 0.509995 -0.457717 0.728233 -vn 0.124363 0.009674 0.992187 -vn -0.972137 -0.167882 0.163549 -vn 0.972137 -0.167882 0.163549 -vn -0.715995 0.572161 0.399945 -vn 0.715995 0.572161 0.399945 -vn 0.000000 0.430525 0.902554 -vn 0.000000 0.010865 0.999939 -vn -0.221839 -0.606037 0.763848 -vn 0.000000 -0.492935 0.870022 -vn 0.000000 0.010315 0.999939 -vn -0.294320 -0.184484 0.937712 -vn 0.221839 -0.606037 0.763848 -vn 0.294320 -0.184484 0.937712 -vn -0.396924 0.534989 0.745781 -vn 0.247780 0.568224 0.784661 -vn -0.247780 0.568224 0.784661 -vn 0.396924 0.534989 0.745781 -vn -0.868221 -0.261330 0.421735 -vn -0.555986 -0.690695 0.462355 -vn 0.868221 -0.261330 0.421735 -vn 0.555986 -0.690695 0.462355 -vn -0.753075 0.649892 0.102298 -vn 0.753075 0.649892 0.102298 -vn 0.194189 0.935697 0.294473 -vn -0.194189 0.935697 0.294473 -vn 0.000000 0.788965 0.614399 -vn 0.000000 -0.888638 0.458571 -vn 0.000000 -0.336772 0.941557 -vn 0.000000 -0.251991 0.967711 -vn -0.188360 -0.040132 0.981262 -vn 0.000000 -0.032899 0.999451 -vn 0.188360 -0.040132 0.981262 -vn 0.000000 0.000000 1.000000 -vn -0.572039 -0.018708 0.820002 -vn -0.536332 -0.212409 0.816828 -vn 0.536332 -0.212409 0.816828 -vn 0.572039 -0.018708 0.820002 -vn -0.357707 -0.638325 0.681570 -vn 0.357707 -0.638325 0.681570 -vn -0.154302 -0.754112 0.638325 -vn 0.154302 -0.754112 0.638325 -vn 0.000000 -0.743461 0.668752 -vn 0.000000 -0.189123 0.981933 -vn 0.000000 -0.114475 0.993408 -vn 0.001404 -0.055635 0.998444 -vn -0.001404 -0.055635 0.998444 -vn -0.336283 -0.512833 0.789850 -vn 0.336283 -0.512833 0.789850 -vn -0.454543 -0.337077 0.824458 -vn 0.454543 -0.337077 0.824458 -vn -0.543474 -0.308603 0.780602 -vn 0.543474 -0.308603 0.780602 -vn -0.387158 -0.187811 0.902646 -vn 0.387158 -0.187811 0.902646 -vn -0.430647 -0.144902 0.890805 -vn 0.430647 -0.144902 0.890805 -vn -0.234016 -0.120548 0.964721 -vn 0.234016 -0.120548 0.964721 -vn -0.263833 0.168798 0.949675 -vn 0.263833 0.168798 0.949675 -vn 0.196722 0.141881 0.970122 -vn -0.196722 0.141881 0.970122 -vn -0.906766 -0.008332 0.421522 -vn -0.744133 -0.640919 0.188269 -vn 0.744133 -0.640919 0.188269 -vn 0.906766 -0.008332 0.421522 -vn -0.044191 -0.974395 0.220313 -vn 0.044191 -0.974395 0.220313 -vn 0.639943 -0.761498 0.102786 -vn -0.639943 -0.761498 0.102786 -vn 0.955504 -0.011444 0.294717 -vn -0.955504 -0.011444 0.294717 -vn 0.649678 0.754387 0.093570 -vn -0.649678 0.754387 0.093570 -vn -0.037049 0.978881 0.200903 -vn 0.037049 0.978881 0.200903 -vn -0.752342 0.635395 0.173742 -vn 0.752342 0.635395 0.173742 -vn -0.811792 -0.002777 0.583880 -vn -0.596942 0.486770 0.637684 -vn 0.596942 0.486770 0.637684 -vn 0.811792 -0.002777 0.583880 -vn -0.868221 -0.005829 0.496109 -vn -0.719504 0.473006 0.508469 -vn 0.719504 0.473006 0.508469 -vn 0.868221 -0.005829 0.496109 -vn -0.204260 0.828761 0.520951 -vn -0.095767 0.717277 0.690146 -vn 0.095767 0.717277 0.690146 -vn 0.204260 0.828761 0.520951 -vn 0.451704 0.459883 0.764458 -vn -0.451704 0.459883 0.764458 -vn 0.450362 0.693899 0.561815 -vn -0.450362 0.693899 0.561815 -vn 0.805536 0.109409 0.582324 -vn 0.691488 -0.074099 0.718558 -vn -0.691488 -0.074099 0.718558 -vn -0.805536 0.109409 0.582324 -vn 0.386212 -0.474685 0.790857 -vn -0.386212 -0.474685 0.790857 -vn 0.557756 -0.629109 0.541368 -vn -0.557756 -0.629109 0.541368 -vn -0.091159 -0.723716 0.684011 -vn -0.199744 -0.858058 0.473067 -vn 0.091159 -0.723716 0.684011 -vn 0.199744 -0.858058 0.473067 -vn -0.597949 -0.496475 0.629231 -vn 0.597949 -0.496475 0.629231 -vn -0.723197 -0.488907 0.487747 -vn 0.723197 -0.488907 0.487747 -usemtl Material_ray.png -s 1 -f 61/1/1 65/2/2 49/3/3 -f 50/4/4 66/5/5 62/6/6 -f 63/7/7 65/2/2 61/1/1 -f 62/6/6 66/5/5 64/8/8 -f 61/1/1 59/9/9 63/7/7 -f 64/8/8 60/10/10 62/6/6 -f 61/1/1 57/11/11 59/9/9 -f 60/10/10 58/12/12 62/6/6 -f 61/1/1 55/13/13 57/11/11 -f 58/12/12 56/14/14 62/6/6 -f 61/1/1 53/15/15 55/13/13 -f 56/14/14 54/16/16 62/6/6 -f 61/1/1 51/17/17 53/15/15 -f 54/16/16 52/18/18 62/6/6 -f 61/1/1 49/3/3 51/17/17 -f 52/18/18 50/4/4 62/6/6 -f 225/19/19 229/20/20 227/21/21 -f 228/22/22 230/23/23 226/24/24 -f 73/25/25 284/26/26 74/27/27 -f 74/28/27 285/29/28 73/30/25 -f 342/31/29 348/32/30 384/33/31 -f 385/34/32 349/35/33 343/36/34 -f 300/37/35 346/38/36 344/39/37 -f 345/40/38 347/41/39 301/42/40 -f 324/43/41 380/44/42 352/45/43 -f 353/46/44 381/47/45 325/48/46 -f 442/49/47 444/50/48 446/51/49 -f 447/52/50 445/53/51 443/54/52 -f 464/55/53 492/56/54 466/57/55 -f 467/58/56 493/59/57 465/60/58 -f 496/61/59 498/62/60 500/63/61 -f 501/64/62 499/65/63 497/66/64 -f 505/67/65 323/68/66 321/69/67 -f 505/67/65 321/69/67 391/70/68 -f 320/71/69 322/72/70 504/73/71 -f 320/71/69 504/73/71 390/74/72 -f 505/67/65 507/75/73 315/76/74 -f 505/67/65 315/76/74 323/68/66 -f 314/77/75 506/78/76 504/73/71 -f 314/77/75 504/73/71 322/72/70 -f 389/79/77 383/80/78 507/75/73 -f 383/80/78 315/76/74 507/75/73 -f 314/77/75 382/81/79 506/78/76 -f 382/81/79 388/82/80 506/78/76 -f 501/64/62 497/66/64 495/83/81 -f 501/64/62 495/83/81 503/84/82 -f 494/85/83 496/61/59 500/63/61 -f 494/85/83 500/63/61 502/86/84 -f 505/67/65 503/84/82 507/75/73 -f 503/84/82 495/83/81 507/75/73 -f 494/85/83 502/86/84 506/78/76 -f 502/86/84 504/73/71 506/78/76 -f 495/83/81 401/87/85 507/75/73 -f 401/87/85 389/79/77 507/75/73 -f 388/82/80 400/88/86 506/78/76 -f 400/88/86 494/85/83 506/78/76 -f 497/66/64 399/89/87 495/83/81 -f 399/89/87 401/87/85 495/83/81 -f 400/88/86 398/90/88 494/85/83 -f 398/90/88 496/61/59 494/85/83 -f 499/65/63 397/91/89 497/66/64 -f 397/91/89 399/89/87 497/66/64 -f 398/90/88 396/92/90 496/61/59 -f 396/92/90 498/62/60 496/61/59 -f 501/64/62 395/93/91 499/65/63 -f 395/93/91 397/91/89 499/65/63 -f 396/92/90 394/94/92 498/62/60 -f 394/94/92 500/63/61 498/62/60 -f 503/84/82 393/95/93 395/93/91 -f 503/84/82 395/93/91 501/64/62 -f 394/94/92 392/96/94 502/86/84 -f 394/94/92 502/86/84 500/63/61 -f 505/67/65 391/70/68 393/95/93 -f 505/67/65 393/95/93 503/84/82 -f 392/96/94 390/74/72 504/73/71 -f 392/96/94 504/73/71 502/86/84 -f 491/97/95 493/59/57 467/58/56 -f 491/97/95 467/58/56 469/98/96 -f 466/57/55 492/56/54 490/99/97 -f 466/57/55 490/99/97 468/100/98 -f 489/101/99 491/97/95 471/102/100 -f 491/97/95 469/98/96 471/102/100 -f 468/100/98 490/99/97 470/103/101 -f 490/99/97 488/104/102 470/103/101 -f 483/105/103 489/101/99 473/106/104 -f 489/101/99 471/102/100 473/106/104 -f 470/103/101 488/104/102 472/107/105 -f 488/104/102 482/108/106 472/107/105 -f 481/109/107 483/105/103 473/106/104 -f 481/109/107 473/106/104 475/110/108 -f 472/107/105 482/108/106 480/111/109 -f 472/107/105 480/111/109 474/112/110 -f 481/109/107 475/110/108 457/113/111 -f 475/110/108 455/114/112 457/113/111 -f 454/115/113 474/112/110 456/116/114 -f 474/112/110 480/111/109 456/116/114 -f 463/117/115 479/118/116 459/119/117 -f 463/117/115 459/119/117 461/120/118 -f 458/121/119 478/122/120 462/123/121 -f 458/121/119 462/123/121 460/124/122 -f 479/118/116 463/117/115 485/125/123 -f 463/117/115 453/126/124 485/125/123 -f 452/127/125 462/123/121 484/128/126 -f 462/123/121 478/122/120 484/128/126 -f 487/129/127 485/125/123 477/130/128 -f 485/125/123 453/126/124 477/130/128 -f 452/127/125 484/128/126 476/131/129 -f 484/128/126 486/132/130 476/131/129 -f 487/129/127 477/130/128 465/60/58 -f 487/129/127 465/60/58 493/59/57 -f 464/55/53 476/131/129 486/132/130 -f 464/55/53 486/132/130 492/56/54 -f 491/97/95 489/101/99 493/59/57 -f 489/101/99 487/129/127 493/59/57 -f 486/132/130 488/104/102 492/56/54 -f 488/104/102 490/99/97 492/56/54 -f 489/101/99 483/105/103 485/125/123 -f 489/101/99 485/125/123 487/129/127 -f 484/128/126 482/108/106 488/104/102 -f 484/128/126 488/104/102 486/132/130 -f 483/105/103 481/109/107 485/125/123 -f 481/109/107 479/118/116 485/125/123 -f 478/122/120 480/111/109 484/128/126 -f 480/111/109 482/108/106 484/128/126 -f 481/109/107 457/113/111 479/118/116 -f 457/113/111 459/119/117 479/118/116 -f 458/121/119 456/116/114 478/122/120 -f 456/116/114 480/111/109 478/122/120 -f 473/106/104 421/133/131 475/110/108 -f 421/133/131 419/134/132 475/110/108 -f 418/135/133 420/136/134 474/112/110 -f 420/136/134 472/107/105 474/112/110 -f 471/102/100 423/137/135 473/106/104 -f 423/137/135 421/133/131 473/106/104 -f 420/136/134 422/138/136 472/107/105 -f 422/138/136 470/103/101 472/107/105 -f 469/98/96 425/139/137 471/102/100 -f 425/139/137 423/137/135 471/102/100 -f 422/138/136 424/140/138 470/103/101 -f 424/140/138 468/100/98 470/103/101 -f 467/58/56 427/141/139 425/139/137 -f 467/58/56 425/139/137 469/98/96 -f 424/140/138 426/142/140 466/57/55 -f 424/140/138 466/57/55 468/100/98 -f 465/60/58 429/143/141 427/141/139 -f 465/60/58 427/141/139 467/58/56 -f 426/142/140 428/144/142 464/55/53 -f 426/142/140 464/55/53 466/57/55 -f 477/130/128 417/145/143 429/143/141 -f 477/130/128 429/143/141 465/60/58 -f 428/144/142 416/146/144 476/131/129 -f 428/144/142 476/131/129 464/55/53 -f 475/110/108 419/134/132 441/147/145 -f 475/110/108 441/147/145 455/114/112 -f 440/148/146 418/135/133 474/112/110 -f 440/148/146 474/112/110 454/115/113 -f 455/114/112 441/147/145 439/149/147 -f 455/114/112 439/149/147 457/113/111 -f 438/150/148 440/148/146 454/115/113 -f 438/150/148 454/115/113 456/116/114 -f 457/113/111 439/149/147 459/119/117 -f 439/149/147 437/151/149 459/119/117 -f 436/152/150 438/150/148 458/121/119 -f 438/150/148 456/116/114 458/121/119 -f 459/119/117 437/151/149 461/120/118 -f 437/151/149 435/153/151 461/120/118 -f 434/154/152 436/152/150 460/124/122 -f 436/152/150 458/121/119 460/124/122 -f 461/120/118 435/153/151 433/155/153 -f 461/120/118 433/155/153 463/117/115 -f 432/156/154 434/154/152 460/124/122 -f 432/156/154 460/124/122 462/123/121 -f 463/117/115 433/155/153 453/126/124 -f 433/155/153 451/157/155 453/126/124 -f 450/158/156 432/156/154 452/127/125 -f 432/156/154 462/123/121 452/127/125 -f 453/126/124 451/157/155 417/145/143 -f 453/126/124 417/145/143 477/130/128 -f 416/146/144 450/158/156 452/127/125 -f 416/146/144 452/127/125 476/131/129 -f 447/52/50 443/54/52 449/159/157 -f 443/54/52 313/160/158 449/159/157 -f 312/161/159 442/49/47 448/162/160 -f 442/49/47 446/51/49 448/162/160 -f 431/163/161 449/159/157 383/80/78 -f 449/159/157 313/160/158 383/80/78 -f 312/161/159 448/162/160 382/164/79 -f 448/162/160 430/165/162 382/164/79 -f 451/157/155 431/163/161 417/145/143 -f 431/163/161 415/166/163 417/145/143 -f 414/167/164 430/165/162 416/146/144 -f 430/165/162 450/158/156 416/146/144 -f 433/155/153 449/159/157 451/157/155 -f 449/159/157 431/163/161 451/157/155 -f 430/165/162 448/162/160 450/158/156 -f 448/162/160 432/156/154 450/158/156 -f 447/52/50 449/159/157 435/153/151 -f 449/159/157 433/155/153 435/153/151 -f 432/156/154 448/162/160 434/154/152 -f 448/162/160 446/51/49 434/154/152 -f 439/149/147 447/52/50 435/153/151 -f 439/149/147 435/153/151 437/151/149 -f 434/154/152 446/51/49 438/150/148 -f 434/154/152 438/150/148 436/152/150 -f 445/53/51 447/52/50 441/147/145 -f 447/52/50 439/149/147 441/147/145 -f 438/150/148 446/51/49 440/148/146 -f 446/51/49 444/50/48 440/148/146 -f 441/147/145 419/134/132 413/168/165 -f 441/147/145 413/168/165 445/53/51 -f 412/169/166 418/135/133 440/148/146 -f 412/169/166 440/148/146 444/50/48 -f 415/166/163 431/163/161 383/80/78 -f 415/166/163 383/80/78 389/79/77 -f 382/164/79 430/165/162 414/167/164 -f 382/164/79 414/167/164 388/170/80 -f 443/171/52 319/172/167 311/173/168 -f 443/171/52 311/173/168 313/174/158 -f 310/175/169 318/176/170 442/177/47 -f 310/175/169 442/177/47 312/178/159 -f 413/168/165 391/179/68 445/53/51 -f 391/179/68 321/180/67 445/53/51 -f 320/181/69 390/182/72 444/50/48 -f 390/182/72 412/169/166 444/50/48 -f 445/53/51 321/180/67 443/54/52 -f 321/183/67 319/172/167 443/171/52 -f 318/176/170 320/184/69 442/177/47 -f 320/181/69 444/50/48 442/49/47 -f 417/145/143 415/166/163 403/185/171 -f 417/145/143 403/185/171 429/143/141 -f 402/186/172 414/167/164 416/146/144 -f 402/186/172 416/146/144 428/144/142 -f 427/141/139 429/143/141 405/187/173 -f 429/143/141 403/185/171 405/187/173 -f 402/186/172 428/144/142 404/188/174 -f 428/144/142 426/142/140 404/188/174 -f 425/139/137 427/141/139 407/189/175 -f 427/141/139 405/187/173 407/189/175 -f 404/188/174 426/142/140 406/190/176 -f 426/142/140 424/140/138 406/190/176 -f 423/137/135 425/139/137 409/191/177 -f 425/139/137 407/189/175 409/191/177 -f 406/190/176 424/140/138 408/192/178 -f 424/140/138 422/138/136 408/192/178 -f 421/133/131 423/137/135 409/191/177 -f 421/133/131 409/191/177 411/193/179 -f 408/192/178 422/138/136 420/136/134 -f 408/192/178 420/136/134 410/194/180 -f 419/134/132 421/133/131 411/193/179 -f 419/134/132 411/193/179 413/168/165 -f 410/194/180 420/136/134 418/135/133 -f 410/194/180 418/135/133 412/169/166 -f 413/168/165 411/193/179 393/195/93 -f 413/168/165 393/195/93 391/179/68 -f 392/196/94 410/194/180 412/169/166 -f 392/196/94 412/169/166 390/182/72 -f 411/193/179 409/191/177 393/195/93 -f 409/191/177 395/197/91 393/195/93 -f 394/198/92 408/192/178 392/196/94 -f 408/192/178 410/194/180 392/196/94 -f 409/191/177 407/189/175 395/197/91 -f 407/189/175 397/199/89 395/197/91 -f 396/200/90 406/190/176 394/198/92 -f 406/190/176 408/192/178 394/198/92 -f 407/189/175 405/187/173 397/199/89 -f 405/187/173 399/89/87 397/199/89 -f 398/201/88 404/188/174 396/200/90 -f 404/188/174 406/190/176 396/200/90 -f 405/187/173 403/185/171 401/87/85 -f 405/187/173 401/87/85 399/89/87 -f 400/202/86 402/186/172 404/188/174 -f 400/202/86 404/188/174 398/201/88 -f 415/166/163 389/79/77 403/185/171 -f 389/79/77 401/87/85 403/185/171 -f 400/202/86 388/170/80 402/186/172 -f 388/170/80 414/167/164 402/186/172 -f 381/47/45 353/46/44 387/203/181 -f 353/46/44 351/204/182 387/203/181 -f 350/205/183 352/45/43 386/206/184 -f 352/45/43 380/44/42 386/206/184 -f 381/47/45 387/203/181 323/207/66 -f 387/203/181 321/183/67 323/207/66 -f 320/184/69 386/206/184 322/208/70 -f 386/206/184 380/44/42 322/208/70 -f 381/47/45 379/209/185 325/48/46 -f 379/209/185 317/210/186 325/48/46 -f 316/211/187 378/212/188 324/43/41 -f 378/212/188 380/44/42 324/43/41 -f 381/47/45 323/207/66 379/209/185 -f 323/207/66 315/213/74 379/209/185 -f 314/214/75 322/208/70 378/212/188 -f 322/208/70 380/44/42 378/212/188 -f 343/36/34 345/40/38 301/42/40 -f 343/36/34 301/42/40 385/34/32 -f 300/37/35 344/39/37 342/31/29 -f 300/37/35 342/31/29 384/33/31 -f 385/34/32 301/42/40 299/215/189 -f 385/34/32 299/215/189 319/172/167 -f 298/216/190 300/37/35 384/33/31 -f 298/216/190 384/33/31 318/176/170 -f 387/203/181 385/34/32 321/183/67 -f 385/34/32 319/172/167 321/183/67 -f 318/176/170 384/33/31 320/184/69 -f 384/33/31 386/206/184 320/184/69 -f 387/203/181 351/204/182 385/34/32 -f 351/204/182 349/35/33 385/34/32 -f 348/32/30 350/205/183 384/33/31 -f 350/205/183 386/206/184 384/33/31 -f 371/217/191 377/218/192 383/219/78 -f 377/218/192 315/213/74 383/219/78 -f 314/214/75 376/220/193 382/221/79 -f 376/220/193 370/222/194 382/221/79 -f 371/217/191 383/219/78 313/174/158 -f 371/217/191 313/174/158 369/223/195 -f 312/178/159 382/221/79 370/222/194 -f 312/178/159 370/222/194 368/224/196 -f 369/223/195 313/174/158 311/173/168 -f 369/223/195 311/173/168 363/225/197 -f 310/175/169 312/178/159 368/224/196 -f 310/175/169 368/224/196 362/226/198 -f 311/173/168 297/227/199 363/225/197 -f 297/227/199 295/228/200 363/225/197 -f 294/229/201 296/230/202 362/226/198 -f 296/230/202 310/175/169 362/226/198 -f 361/231/203 291/232/204 285/29/28 -f 361/231/203 285/29/28 74/28/27 -f 284/26/26 290/233/205 360/234/206 -f 284/26/26 360/234/206 74/27/27 -f 289/235/207 287/236/208 291/232/204 -f 287/236/208 285/29/28 291/232/204 -f 284/26/26 286/237/209 290/233/205 -f 286/237/209 288/238/210 290/233/205 -f 359/239/211 361/231/203 302/240/212 -f 361/231/203 74/28/27 302/240/212 -f 74/27/27 360/234/206 302/241/212 -f 360/234/206 358/242/213 302/241/212 -f 365/243/214 293/244/215 361/231/203 -f 293/244/215 291/232/204 361/231/203 -f 290/233/205 292/245/216 360/234/206 -f 292/245/216 364/246/217 360/234/206 -f 365/243/214 361/231/203 359/239/211 -f 365/243/214 359/239/211 367/247/218 -f 358/242/213 360/234/206 364/246/217 -f 358/242/213 364/246/217 366/248/219 -f 367/247/218 359/239/211 357/249/220 -f 367/247/218 357/249/220 373/250/221 -f 356/251/222 358/242/213 366/248/219 -f 356/251/222 366/248/219 372/252/223 -f 373/250/221 357/249/220 355/253/224 -f 373/250/221 355/253/224 375/254/225 -f 354/255/226 356/251/222 372/252/223 -f 354/255/226 372/252/223 374/256/227 -f 375/254/225 355/253/224 317/210/186 -f 375/254/225 317/210/186 379/209/185 -f 316/211/187 354/255/226 374/256/227 -f 316/211/187 374/256/227 378/212/188 -f 375/254/225 379/209/185 377/218/192 -f 379/209/185 315/213/74 377/218/192 -f 314/214/75 378/212/188 376/220/193 -f 378/212/188 374/256/227 376/220/193 -f 377/218/192 371/217/191 373/250/221 -f 377/218/192 373/250/221 375/254/225 -f 372/252/223 370/222/194 376/220/193 -f 372/252/223 376/220/193 374/256/227 -f 371/217/191 369/223/195 367/247/218 -f 371/217/191 367/247/218 373/250/221 -f 366/248/219 368/224/196 370/222/194 -f 366/248/219 370/222/194 372/252/223 -f 369/223/195 363/225/197 365/243/214 -f 369/223/195 365/243/214 367/247/218 -f 364/246/217 362/226/198 368/224/196 -f 364/246/217 368/224/196 366/248/219 -f 363/225/197 295/228/200 293/244/215 -f 363/225/197 293/244/215 365/243/214 -f 292/245/216 294/229/201 362/226/198 -f 292/245/216 362/226/198 364/246/217 -f 317/210/186 355/253/224 75/257/228 -f 317/210/186 75/257/228 76/258/229 -f 75/259/228 354/255/226 316/211/187 -f 75/259/228 316/211/187 76/260/229 -f 355/253/224 357/249/220 303/261/230 -f 355/253/224 303/261/230 75/257/228 -f 303/262/230 356/251/222 354/255/226 -f 303/262/230 354/255/226 75/259/228 -f 357/249/220 359/239/211 303/261/230 -f 359/239/211 302/240/212 303/261/230 -f 302/241/212 358/242/213 303/262/230 -f 358/242/213 356/251/222 303/262/230 -f 325/48/46 317/210/186 77/263/231 -f 317/210/186 76/258/229 77/263/231 -f 76/260/229 316/211/187 77/264/231 -f 316/211/187 324/43/41 77/264/231 -f 319/172/167 299/215/189 297/227/199 -f 319/172/167 297/227/199 311/173/168 -f 296/230/202 298/216/190 318/176/170 -f 296/230/202 318/176/170 310/175/169 -f 349/35/33 329/265/232 343/36/34 -f 329/265/232 327/266/233 343/36/34 -f 326/267/234 328/268/235 342/31/29 -f 328/268/235 348/32/30 342/31/29 -f 329/265/232 349/35/33 305/269/236 -f 329/265/232 305/269/236 309/270/237 -f 305/271/236 348/32/30 328/268/235 -f 305/271/236 328/268/235 309/272/237 -f 349/35/33 351/204/182 78/273/238 -f 349/35/33 78/273/238 305/269/236 -f 78/274/238 350/205/183 348/32/30 -f 78/274/238 348/32/30 305/271/236 -f 351/204/182 353/46/44 78/273/238 -f 353/46/44 304/275/239 78/273/238 -f 304/276/239 352/45/43 78/274/238 -f 352/45/43 350/205/183 78/274/238 -f 353/46/44 325/48/46 304/275/239 -f 325/48/46 77/263/231 304/275/239 -f 77/264/231 324/43/41 304/276/239 -f 324/43/41 352/45/43 304/276/239 -f 301/42/40 347/41/39 93/277/240 -f 347/278/39 80/279/241 93/280/240 -f 79/281/242 346/282/36 92/283/243 -f 346/38/36 300/37/35 92/284/243 -f 345/40/38 216/285/244 347/41/39 -f 216/286/244 80/279/241 347/278/39 -f 79/281/242 215/287/245 346/282/36 -f 215/288/245 344/39/37 346/38/36 -f 343/36/34 327/266/233 210/289/246 -f 327/266/233 82/290/247 210/289/246 -f 81/291/248 326/267/234 209/292/249 -f 326/267/234 342/31/29 209/292/249 -f 345/40/38 343/36/34 216/285/244 -f 343/36/34 210/289/246 216/285/244 -f 209/292/249 342/31/29 215/288/245 -f 342/31/29 344/39/37 215/288/245 -f 333/293/250 84/294/251 82/290/247 -f 333/293/250 82/290/247 327/266/233 -f 81/291/248 83/295/252 332/296/253 -f 81/291/248 332/296/253 326/267/234 -f 339/297/254 333/293/250 329/265/232 -f 333/293/250 327/266/233 329/265/232 -f 326/267/234 332/296/253 328/268/235 -f 332/296/253 338/298/255 328/268/235 -f 341/299/256 335/300/257 337/301/258 -f 335/300/257 331/302/259 337/301/258 -f 330/303/260 334/304/261 336/305/262 -f 334/304/261 340/306/263 336/305/262 -f 339/297/254 337/301/258 331/302/259 -f 339/297/254 331/302/259 333/293/250 -f 330/303/260 336/305/262 338/298/255 -f 330/303/260 338/298/255 332/296/253 -f 331/302/259 86/307/264 84/294/251 -f 331/302/259 84/294/251 333/293/250 -f 83/295/252 85/308/265 330/303/260 -f 83/295/252 330/303/260 332/296/253 -f 335/300/257 88/309/266 86/307/264 -f 335/300/257 86/307/264 331/302/259 -f 85/308/265 87/310/267 334/304/261 -f 85/308/265 334/304/261 330/303/260 -f 341/299/256 90/311/268 88/309/266 -f 341/299/256 88/309/266 335/300/257 -f 87/310/267 89/312/269 340/306/263 -f 87/310/267 340/306/263 334/304/261 -f 306/313/270 91/314/271 90/311/268 -f 306/313/270 90/311/268 341/299/256 -f 89/312/269 91/315/271 306/316/270 -f 89/312/269 306/316/270 340/306/263 -f 337/301/258 307/317/272 341/299/256 -f 307/317/272 306/313/270 341/299/256 -f 306/316/270 307/318/272 340/306/263 -f 307/318/272 336/305/262 340/306/263 -f 339/297/254 308/319/273 337/301/258 -f 308/319/273 307/317/272 337/301/258 -f 307/318/272 308/320/273 336/305/262 -f 308/320/273 338/298/255 336/305/262 -f 329/265/232 309/270/237 339/297/254 -f 309/270/237 308/319/273 339/297/254 -f 308/320/273 309/272/237 338/298/255 -f 309/272/237 328/268/235 338/298/255 -f 301/42/40 93/277/240 95/321/274 -f 301/42/40 95/321/274 299/215/189 -f 94/322/275 92/284/243 300/37/35 -f 94/322/275 300/37/35 298/216/190 -f 299/215/189 95/321/274 97/323/276 -f 299/215/189 97/323/276 297/227/199 -f 96/324/277 94/322/275 298/216/190 -f 96/324/277 298/216/190 296/230/202 -f 297/227/199 97/323/276 295/228/200 -f 97/323/276 99/325/278 295/228/200 -f 98/326/279 96/324/277 294/229/201 -f 96/324/277 296/230/202 294/229/201 -f 295/228/200 99/325/278 101/327/280 -f 295/228/200 101/327/280 293/244/215 -f 100/328/281 98/326/279 294/229/201 -f 100/328/281 294/229/201 292/245/216 -f 293/244/215 101/327/280 291/232/204 -f 101/327/280 103/329/282 291/232/204 -f 102/330/283 100/328/281 290/233/205 -f 100/328/281 292/245/216 290/233/205 -f 291/232/204 103/329/282 289/235/207 -f 103/329/282 105/331/284 289/235/207 -f 104/332/285 102/330/283 288/238/210 -f 102/330/283 290/233/205 288/238/210 -f 289/235/207 105/331/284 287/236/208 -f 105/331/284 107/333/286 287/236/208 -f 106/334/287 104/332/285 286/237/209 -f 104/332/285 288/238/210 286/237/209 -f 287/236/208 107/333/286 109/335/288 -f 287/236/208 109/335/288 285/29/28 -f 108/336/289 106/334/287 286/237/209 -f 108/336/289 286/237/209 284/26/26 -f 285/29/28 109/335/288 67/337/290 -f 285/29/28 67/337/290 73/30/25 -f 67/338/290 108/336/289 284/26/26 -f 67/338/290 284/26/26 73/25/25 -f 281/339/291 235/340/292 233/341/293 -f 281/339/291 233/341/293 283/342/294 -f 232/343/295 234/344/296 280/345/297 -f 232/343/295 280/345/297 282/346/298 -f 283/342/294 233/341/293 255/347/299 -f 283/342/294 255/347/299 261/348/300 -f 254/349/301 232/343/295 282/346/298 -f 254/349/301 282/346/298 260/350/302 -f 261/348/300 255/347/299 257/351/303 -f 261/348/300 257/351/303 259/352/304 -f 256/353/305 254/349/301 260/350/302 -f 256/353/305 260/350/302 258/354/306 -f 263/355/307 253/356/308 235/340/292 -f 263/355/307 235/340/292 281/339/291 -f 234/344/296 252/357/309 262/358/310 -f 234/344/296 262/358/310 280/345/297 -f 265/359/311 251/360/312 263/355/307 -f 251/360/312 253/356/308 263/355/307 -f 252/357/309 250/361/313 262/358/310 -f 250/361/313 264/362/314 262/358/310 -f 267/363/315 249/364/316 265/359/311 -f 249/364/316 251/360/312 265/359/311 -f 250/361/313 248/365/317 264/362/314 -f 248/365/317 266/366/318 264/362/314 -f 269/367/319 247/368/320 249/364/316 -f 269/367/319 249/364/316 267/363/315 -f 248/365/317 246/369/321 268/370/322 -f 248/365/317 268/370/322 266/366/318 -f 271/371/323 245/372/324 269/367/319 -f 245/372/324 247/368/320 269/367/319 -f 246/369/321 244/373/325 268/370/322 -f 244/373/325 270/374/326 268/370/322 -f 273/375/327 243/376/328 245/372/324 -f 273/375/327 245/372/324 271/371/323 -f 244/373/325 242/377/329 272/378/330 -f 244/373/325 272/378/330 270/374/326 -f 275/379/331 241/380/332 273/375/327 -f 241/380/332 243/376/328 273/375/327 -f 242/377/329 240/381/333 272/378/330 -f 240/381/333 274/382/334 272/378/330 -f 279/383/335 237/384/336 275/379/331 -f 237/384/336 241/380/332 275/379/331 -f 240/381/333 236/385/337 274/382/334 -f 236/385/337 278/386/338 274/382/334 -f 277/387/339 239/388/340 237/384/336 -f 277/387/339 237/384/336 279/383/335 -f 236/385/337 238/389/341 276/390/342 -f 236/385/337 276/390/342 278/386/338 -f 259/352/304 257/351/303 239/388/340 -f 259/352/304 239/388/340 277/387/339 -f 238/389/341 256/353/305 258/354/306 -f 238/389/341 258/354/306 276/390/342 -f 257/351/303 111/391/343 129/392/344 -f 257/351/303 129/392/344 239/388/340 -f 128/393/345 110/394/346 256/353/305 -f 128/393/345 256/353/305 238/389/341 -f 239/388/340 129/392/344 180/395/347 -f 239/388/340 180/395/347 237/384/336 -f 179/396/348 128/393/345 238/389/341 -f 179/396/348 238/389/341 236/385/337 -f 237/384/336 180/395/347 127/397/349 -f 237/384/336 127/397/349 241/380/332 -f 126/398/350 179/396/348 236/385/337 -f 126/398/350 236/385/337 240/381/333 -f 241/380/332 127/397/349 243/376/328 -f 127/397/349 125/399/351 243/376/328 -f 124/400/352 126/398/350 242/377/329 -f 126/398/350 240/381/333 242/377/329 -f 243/376/328 125/399/351 245/372/324 -f 125/399/351 123/401/353 245/372/324 -f 122/402/354 124/400/352 244/373/325 -f 124/400/352 242/377/329 244/373/325 -f 245/372/324 123/401/353 121/403/355 -f 245/372/324 121/403/355 247/368/320 -f 120/404/356 122/402/354 244/373/325 -f 120/404/356 244/373/325 246/369/321 -f 247/368/320 121/403/355 119/405/357 -f 247/368/320 119/405/357 249/364/316 -f 118/406/358 120/404/356 246/369/321 -f 118/406/358 246/369/321 248/365/317 -f 249/364/316 119/405/357 117/407/359 -f 249/364/316 117/407/359 251/360/312 -f 116/408/360 118/406/358 248/365/317 -f 116/408/360 248/365/317 250/361/313 -f 251/360/312 117/407/359 115/409/361 -f 251/360/312 115/409/361 253/356/308 -f 114/410/362 116/408/360 250/361/313 -f 114/410/362 250/361/313 252/357/309 -f 253/356/308 115/409/361 235/340/292 -f 115/409/361 182/411/363 235/340/292 -f 181/412/364 114/410/362 234/344/296 -f 114/410/362 252/357/309 234/344/296 -f 255/347/299 113/413/365 257/351/303 -f 113/413/365 111/391/343 257/351/303 -f 110/394/346 112/414/366 256/353/305 -f 112/414/366 254/349/301 256/353/305 -f 233/341/293 184/415/367 113/413/365 -f 233/341/293 113/413/365 255/347/299 -f 112/414/366 183/416/368 232/343/295 -f 112/414/366 232/343/295 254/349/301 -f 235/340/292 182/411/363 184/415/367 -f 235/340/292 184/415/367 233/341/293 -f 183/416/368 181/412/364 234/344/296 -f 183/416/368 234/344/296 232/343/295 -f 230/23/23 231/417/369 224/418/370 -f 230/23/23 224/418/370 226/24/24 -f 224/418/370 231/417/369 229/20/20 -f 224/418/370 229/20/20 225/19/19 -f 224/418/370 72/419/371 226/24/24 -f 72/419/371 223/420/372 226/24/24 -f 222/421/373 72/419/371 225/19/19 -f 72/419/371 224/418/370 225/19/19 -f 226/24/24 223/420/372 221/422/374 -f 226/24/24 221/422/374 228/22/22 -f 220/423/375 222/421/373 225/19/19 -f 220/423/375 225/19/19 227/21/21 -f 228/22/22 221/422/374 219/424/376 -f 228/22/22 219/424/376 230/23/23 -f 218/425/377 220/423/375 227/21/21 -f 218/425/377 227/21/21 229/20/20 -f 230/23/23 219/424/376 231/417/369 -f 219/424/376 217/426/378 231/417/369 -f 217/426/378 218/425/377 231/417/369 -f 218/425/377 229/20/20 231/417/369 -f 219/424/376 136/427/379 137/428/380 -f 219/424/376 137/428/380 217/426/378 -f 137/428/380 135/429/381 218/425/377 -f 137/428/380 218/425/377 217/426/378 -f 221/422/374 134/430/382 136/427/379 -f 221/422/374 136/427/379 219/424/376 -f 135/429/381 133/431/383 220/423/375 -f 135/429/381 220/423/375 218/425/377 -f 223/420/372 132/432/384 134/430/382 -f 223/420/372 134/430/382 221/422/374 -f 133/431/383 131/433/385 222/421/373 -f 133/431/383 222/421/373 220/423/375 -f 72/419/371 130/434/386 223/420/372 -f 130/434/386 132/432/384 223/420/372 -f 131/433/385 130/434/386 222/421/373 -f 130/434/386 72/419/371 222/421/373 -f 212/435/387 165/436/388 80/279/241 -f 212/435/387 80/279/241 216/286/244 -f 79/281/242 164/437/389 211/438/390 -f 79/281/242 211/438/390 215/287/245 -f 212/435/387 216/286/244 214/439/391 -f 216/286/244 210/440/246 214/439/391 -f 209/441/249 215/287/245 213/442/392 -f 215/287/245 211/438/390 213/442/392 -f 214/439/391 210/440/246 167/443/393 -f 210/440/246 82/444/247 167/443/393 -f 81/445/248 209/441/249 166/446/394 -f 209/441/249 213/442/392 166/446/394 -f 167/443/393 188/447/395 214/439/391 -f 188/447/395 145/448/396 214/439/391 -f 144/449/397 187/450/398 213/442/392 -f 187/450/398 166/446/394 213/442/392 -f 214/439/391 145/448/396 212/435/387 -f 145/448/396 143/451/399 212/435/387 -f 142/452/400 144/449/397 211/438/390 -f 144/449/397 213/442/392 211/438/390 -f 212/435/387 143/451/399 141/453/401 -f 212/435/387 141/453/401 165/436/388 -f 140/454/402 142/452/400 211/438/390 -f 140/454/402 211/438/390 164/437/389 -f 165/436/388 141/453/401 139/455/403 -f 165/436/388 139/455/403 177/456/404 -f 139/455/403 140/454/402 164/437/389 -f 139/455/403 164/437/389 177/456/404 -f 207/457/405 208/458/406 199/459/407 -f 207/457/405 199/459/407 205/460/408 -f 199/459/407 208/458/406 206/461/409 -f 199/459/407 206/461/409 204/462/410 -f 203/463/411 205/460/408 201/464/412 -f 205/460/408 199/459/407 201/464/412 -f 199/459/407 204/462/410 200/465/413 -f 204/462/410 202/466/414 200/465/413 -f 207/457/405 205/460/408 194/467/415 -f 207/457/405 194/467/415 192/468/416 -f 193/469/417 204/462/410 206/461/409 -f 193/469/417 206/461/409 191/470/418 -f 205/460/408 203/463/411 194/467/415 -f 203/463/411 196/471/419 194/467/415 -f 195/472/420 202/466/414 193/469/417 -f 202/466/414 204/462/410 193/469/417 -f 203/463/411 201/464/412 198/473/421 -f 203/463/411 198/473/421 196/471/419 -f 197/474/422 200/465/413 202/466/414 -f 197/474/422 202/466/414 195/472/420 -f 201/464/412 199/459/407 71/475/423 -f 201/464/412 71/475/423 198/473/421 -f 71/475/423 199/459/407 200/465/413 -f 71/475/423 200/465/413 197/474/422 -f 207/457/405 192/468/416 208/458/406 -f 192/468/416 70/476/424 208/458/406 -f 70/476/424 191/470/418 208/458/406 -f 191/470/418 206/461/409 208/458/406 -f 192/468/416 145/448/396 70/476/424 -f 145/448/396 190/477/425 70/476/424 -f 190/477/425 144/449/397 70/476/424 -f 144/449/397 191/470/418 70/476/424 -f 198/473/421 71/475/423 139/455/403 -f 71/478/423 138/479/426 139/480/403 -f 138/481/426 71/482/423 139/483/403 -f 71/475/423 197/474/422 139/455/403 -f 196/471/419 198/473/421 141/453/401 -f 198/473/421 139/455/403 141/453/401 -f 139/455/403 197/474/422 140/454/402 -f 197/474/422 195/472/420 140/454/402 -f 194/467/415 196/471/419 143/451/399 -f 196/471/419 141/453/401 143/451/399 -f 140/454/402 195/472/420 142/452/400 -f 195/472/420 193/469/417 142/452/400 -f 192/468/416 194/467/415 143/451/399 -f 192/468/416 143/451/399 145/448/396 -f 142/452/400 193/469/417 191/470/418 -f 142/452/400 191/470/418 144/449/397 -f 186/484/427 132/432/384 69/485/428 -f 132/432/384 130/434/386 69/485/428 -f 130/434/386 131/433/385 69/485/428 -f 131/433/385 185/486/429 69/485/428 -f 189/487/430 188/447/395 69/485/428 -f 188/447/395 186/484/427 69/485/428 -f 185/486/429 187/450/398 69/485/428 -f 187/450/398 189/487/430 69/485/428 -f 189/487/430 190/477/425 188/447/395 -f 190/477/425 145/448/396 188/447/395 -f 144/449/397 190/477/425 187/450/398 -f 190/477/425 189/487/430 187/450/398 -f 169/488/431 171/489/432 132/432/384 -f 169/488/431 132/432/384 186/484/427 -f 131/433/385 170/490/433 168/491/434 -f 131/433/385 168/491/434 185/486/429 -f 186/484/427 188/447/395 167/443/393 -f 186/484/427 167/443/393 169/488/431 -f 166/446/394 187/450/398 185/486/429 -f 166/446/394 185/486/429 168/491/434 -f 173/492/435 134/430/382 171/489/432 -f 134/430/382 132/432/384 171/489/432 -f 131/433/385 133/431/383 170/490/433 -f 133/431/383 172/493/436 170/490/433 -f 175/494/437 136/427/379 134/430/382 -f 175/494/437 134/430/382 173/492/435 -f 133/431/383 135/429/381 174/495/438 -f 133/431/383 174/495/438 172/493/436 -f 176/496/439 137/428/380 136/427/379 -f 176/496/439 136/427/379 175/494/437 -f 135/429/381 137/428/380 176/496/439 -f 135/429/381 176/496/439 174/495/438 -f 184/415/367 182/411/363 178/497/440 -f 182/411/363 177/456/404 178/497/440 -f 177/456/404 181/412/364 178/497/440 -f 181/412/364 183/416/368 178/497/440 -f 178/497/440 68/498/441 113/413/365 -f 178/497/440 113/413/365 184/415/367 -f 112/414/366 68/498/441 178/497/440 -f 112/414/366 178/497/440 183/416/368 -f 68/498/441 163/499/442 113/413/365 -f 163/499/442 111/391/343 113/413/365 -f 110/394/346 162/500/443 112/414/366 -f 162/500/443 68/498/441 112/414/366 -f 177/456/404 182/411/363 115/409/361 -f 177/456/404 115/409/361 165/436/388 -f 114/410/362 181/412/364 177/456/404 -f 114/410/362 177/456/404 164/437/389 -f 147/501/444 165/436/388 115/409/361 -f 147/501/444 115/409/361 117/407/359 -f 114/410/362 164/437/389 146/502/445 -f 114/410/362 146/502/445 116/408/360 -f 149/503/446 147/501/444 119/405/357 -f 147/501/444 117/407/359 119/405/357 -f 116/408/360 146/502/445 118/406/358 -f 146/502/445 148/504/447 118/406/358 -f 151/505/448 149/503/446 121/403/355 -f 149/503/446 119/405/357 121/403/355 -f 118/406/358 148/504/447 120/404/356 -f 148/504/447 150/506/449 120/404/356 -f 153/507/450 151/505/448 123/401/353 -f 151/505/448 121/403/355 123/401/353 -f 120/404/356 150/506/449 122/402/354 -f 150/506/449 152/508/451 122/402/354 -f 155/509/452 153/507/450 125/399/351 -f 153/507/450 123/401/353 125/399/351 -f 122/402/354 152/508/451 124/400/352 -f 152/508/451 154/510/453 124/400/352 -f 157/511/454 155/509/452 127/397/349 -f 155/509/452 125/399/351 127/397/349 -f 124/400/352 154/510/453 126/398/350 -f 154/510/453 156/512/455 126/398/350 -f 159/513/456 157/511/454 180/395/347 -f 157/511/454 127/397/349 180/395/347 -f 126/398/350 156/512/455 179/396/348 -f 156/512/455 158/514/457 179/396/348 -f 159/513/456 180/395/347 129/392/344 -f 159/513/456 129/392/344 161/515/458 -f 128/393/345 179/396/348 158/514/457 -f 128/393/345 158/514/457 160/516/459 -f 161/515/458 129/392/344 163/499/442 -f 129/392/344 111/391/343 163/499/442 -f 110/394/346 128/393/345 162/500/443 -f 128/393/345 160/516/459 162/500/443 -f 68/498/441 67/517/290 163/499/442 -f 67/517/290 109/518/288 163/499/442 -f 108/519/289 67/517/290 162/500/443 -f 67/517/290 68/498/441 162/500/443 -f 163/499/442 109/518/288 161/515/458 -f 109/518/288 107/520/286 161/515/458 -f 106/521/287 108/519/289 160/516/459 -f 108/519/289 162/500/443 160/516/459 -f 161/515/458 107/520/286 159/513/456 -f 107/520/286 105/522/284 159/513/456 -f 104/523/285 106/521/287 158/514/457 -f 106/521/287 160/516/459 158/514/457 -f 159/513/456 105/522/284 103/524/282 -f 159/513/456 103/524/282 157/511/454 -f 102/525/283 104/523/285 158/514/457 -f 102/525/283 158/514/457 156/512/455 -f 157/511/454 103/524/282 155/509/452 -f 103/524/282 101/526/280 155/509/452 -f 100/527/281 102/525/283 154/510/453 -f 102/525/283 156/512/455 154/510/453 -f 155/509/452 101/526/280 153/507/450 -f 101/526/280 99/528/278 153/507/450 -f 98/529/279 100/527/281 152/508/451 -f 100/527/281 154/510/453 152/508/451 -f 153/507/450 99/528/278 151/505/448 -f 99/528/278 97/530/276 151/505/448 -f 96/531/277 98/529/279 150/506/449 -f 98/529/279 152/508/451 150/506/449 -f 151/505/448 97/530/276 95/532/274 -f 151/505/448 95/532/274 149/503/446 -f 94/533/275 96/531/277 150/506/449 -f 94/533/275 150/506/449 148/504/447 -f 149/503/446 95/532/274 147/501/444 -f 95/532/274 93/280/240 147/501/444 -f 92/283/243 94/533/275 146/502/445 -f 94/533/275 148/504/447 146/502/445 -f 147/501/444 93/280/240 80/279/241 -f 147/501/444 80/279/241 165/436/388 -f 79/281/242 92/283/243 146/502/445 -f 79/281/242 146/502/445 164/437/389 -f 169/488/431 167/443/393 82/444/247 -f 169/488/431 82/444/247 84/534/251 -f 81/445/248 166/446/394 168/491/434 -f 81/445/248 168/491/434 83/535/252 -f 171/489/432 169/488/431 84/534/251 -f 171/489/432 84/534/251 86/536/264 -f 83/535/252 168/491/434 170/490/433 -f 83/535/252 170/490/433 85/537/265 -f 173/492/435 171/489/432 86/536/264 -f 173/492/435 86/536/264 88/538/266 -f 85/537/265 170/490/433 172/493/436 -f 85/537/265 172/493/436 87/539/267 -f 175/494/437 173/492/435 90/540/268 -f 173/492/435 88/538/266 90/540/268 -f 87/539/267 172/493/436 89/541/269 -f 172/493/436 174/495/438 89/541/269 -f 176/496/439 175/494/437 91/542/271 -f 175/494/437 90/540/268 91/542/271 -f 89/541/269 174/495/438 91/542/271 -f 174/495/438 176/496/439 91/542/271 -f 50/4/4 48/543/460 2/544/461 -f 50/4/4 2/544/461 66/5/5 -f 1/545/462 47/546/463 49/3/3 -f 1/545/462 49/3/3 65/2/2 -f 66/5/5 2/544/461 12/547/464 -f 66/5/5 12/547/464 64/8/8 -f 11/548/465 1/545/462 65/2/2 -f 11/548/465 65/2/2 63/7/7 -f 64/8/8 12/547/464 14/549/466 -f 64/8/8 14/549/466 60/10/10 -f 13/550/467 11/548/465 63/7/7 -f 13/550/467 63/7/7 59/9/9 -f 60/10/10 14/549/466 24/551/468 -f 60/10/10 24/551/468 58/12/12 -f 23/552/469 13/550/467 59/9/9 -f 23/552/469 59/9/9 57/11/11 -f 58/12/12 24/551/468 56/14/14 -f 24/551/468 26/553/470 56/14/14 -f 25/554/471 23/552/469 55/13/13 -f 23/552/469 57/11/11 55/13/13 -f 56/14/14 26/553/470 54/16/16 -f 26/553/470 36/555/472 54/16/16 -f 35/556/473 25/554/471 53/15/15 -f 25/554/471 55/13/13 53/15/15 -f 54/16/16 36/555/472 52/18/18 -f 36/555/472 38/557/474 52/18/18 -f 37/558/475 35/556/473 51/17/17 -f 35/556/473 53/15/15 51/17/17 -f 52/18/18 38/557/474 50/4/4 -f 38/557/474 48/543/460 50/4/4 -f 47/546/463 37/558/475 49/3/3 -f 37/558/475 51/17/17 49/3/3 -f 46/559/476 48/543/460 40/560/477 -f 48/543/460 38/557/474 40/560/477 -f 37/558/475 47/546/463 39/561/478 -f 47/546/463 45/562/479 39/561/478 -f 44/563/480 46/559/476 42/564/481 -f 46/559/476 40/560/477 42/564/481 -f 39/561/478 45/562/479 41/565/482 -f 45/562/479 43/566/483 41/565/482 -f 42/564/481 40/560/477 32/567/484 -f 40/560/477 34/568/485 32/567/484 -f 33/569/486 39/561/478 31/570/487 -f 39/561/478 41/565/482 31/570/487 -f 40/560/477 38/557/474 34/568/485 -f 38/557/474 36/555/472 34/568/485 -f 35/556/473 37/558/475 33/569/486 -f 37/558/475 39/561/478 33/569/486 -f 34/568/485 36/555/472 28/571/488 -f 36/555/472 26/553/470 28/571/488 -f 25/554/471 35/556/473 27/572/489 -f 35/556/473 33/569/486 27/572/489 -f 32/567/484 34/568/485 30/573/490 -f 34/568/485 28/571/488 30/573/490 -f 27/572/489 33/569/486 29/574/491 -f 33/569/486 31/570/487 29/574/491 -f 30/573/490 28/571/488 20/575/492 -f 28/571/488 22/576/493 20/575/492 -f 21/577/494 27/572/489 19/578/495 -f 27/572/489 29/574/491 19/578/495 -f 28/571/488 26/553/470 24/551/468 -f 28/571/488 24/551/468 22/576/493 -f 23/552/469 25/554/471 27/572/489 -f 23/552/469 27/572/489 21/577/494 -f 22/576/493 24/551/468 16/579/496 -f 24/551/468 14/549/466 16/579/496 -f 13/550/467 23/552/469 15/580/497 -f 23/552/469 21/577/494 15/580/497 -f 20/575/492 22/576/493 18/581/498 -f 22/576/493 16/579/496 18/581/498 -f 15/580/497 21/577/494 17/582/499 -f 21/577/494 19/578/495 17/582/499 -f 18/581/498 16/579/496 10/583/500 -f 18/581/498 10/583/500 8/584/501 -f 9/585/502 15/580/497 17/582/499 -f 9/585/502 17/582/499 7/586/503 -f 16/579/496 14/549/466 12/547/464 -f 16/579/496 12/547/464 10/583/500 -f 11/548/465 13/550/467 15/580/497 -f 11/548/465 15/580/497 9/585/502 -f 10/583/500 12/547/464 2/544/461 -f 10/583/500 2/544/461 4/587/504 -f 1/545/462 11/548/465 9/585/502 -f 1/545/462 9/585/502 3/588/505 -f 8/584/501 10/583/500 4/587/504 -f 8/584/501 4/587/504 6/589/506 -f 3/588/505 9/585/502 7/586/503 -f 3/588/505 7/586/503 5/590/507 -f 6/589/506 4/587/504 46/559/476 -f 6/589/506 46/559/476 44/563/480 -f 45/562/479 3/588/505 5/590/507 -f 45/562/479 5/590/507 43/566/483 -f 4/587/504 2/544/461 48/543/460 -f 4/587/504 48/543/460 46/559/476 -f 47/546/463 1/545/462 3/588/505 -f 47/546/463 3/588/505 45/562/479 diff --git a/examples/ogl_tutorials/misc05_picking_easy/src/textures/uvmap.DDS b/examples/ogl_tutorials/misc05_picking_easy/src/textures/uvmap.DDS deleted file mode 100755 index 70cb2db1..00000000 Binary files a/examples/ogl_tutorials/misc05_picking_easy/src/textures/uvmap.DDS and /dev/null differ diff --git a/examples/open_gl/Readme.md b/examples/open_gl/Readme.md deleted file mode 100644 index f52c17ea..00000000 --- a/examples/open_gl/Readme.md +++ /dev/null @@ -1,15 +0,0 @@ -Author: Roger Mc Murtrie -These examples are based on the tutorials available at https://open.gl/introduction using Glfw version 3. -The version numbers in the shader programs may need modification depending on your -platform. -For Mac users, note that the Glfw provided with OSX is incompatible with OpenGLAda as it does not contain libglfw.a. -A compatible version can be obtained from Homebrew: brew install glfw. - -GNAT Programming Studio (GPS) Considerations -Use Tools->Views->Scenarios to display the Scenario panel. -In the Scenario panel set GLFW Version to 3. -For Mac, in the Scenario panel set Windowing System to quartz. -In Preferences, ensure that Editor->Fonts & Colors->Default is set to a fixed size font. -In Preferences->Editor->Ada set appropriate format selectors. - - diff --git a/examples/open_gl/coloured_elements/.gitignore b/examples/open_gl/coloured_elements/.gitignore deleted file mode 100644 index 9f31a4fa..00000000 --- a/examples/open_gl/coloured_elements/.gitignore +++ /dev/null @@ -1 +0,0 @@ -element_buffers diff --git a/examples/open_gl/coloured_elements/element_buffers.gpr b/examples/open_gl/coloured_elements/element_buffers.gpr deleted file mode 100644 index 108b9df5..00000000 --- a/examples/open_gl/coloured_elements/element_buffers.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Element_Buffers is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("element_buffers.adb"); - - package Compiler renames OpenGL.Compiler; - -end Element_Buffers; - diff --git a/examples/open_gl/coloured_elements/src/element_buffers.adb b/examples/open_gl/coloured_elements/src/element_buffers.adb deleted file mode 100644 index 271554f7..00000000 --- a/examples/open_gl/coloured_elements/src/element_buffers.adb +++ /dev/null @@ -1,31 +0,0 @@ --- Element Buffers --- Author Roger Mc Murtrie --- Created 16 Febuary 2017 --- Based on https://open.gl/drawing Drawing Polygons - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Element_Buffers is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Element_Buffers"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Element_Buffers returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Element_Buffers."); - Put_Line (Exception_Information (anError)); -end Element_Buffers; diff --git a/examples/open_gl/coloured_elements/src/main_loop.adb b/examples/open_gl/coloured_elements/src/main_loop.adb deleted file mode 100644 index 0776d39a..00000000 --- a/examples/open_gl/coloured_elements/src/main_loop.adb +++ /dev/null @@ -1,112 +0,0 @@ -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Types; -with GL.Types.Colors; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Shader_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Elements_Buffer : GL.Objects.Buffers.Buffer; - Position_Location : GL.Attributes.Attribute; - Colour_Location : GL.Attributes.Attribute; - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types; - Back_Colour : constant Colors.Color := (0.0, 0.6, 0.6, 1.0); - Stride : constant Int := 5 * 4; - Skip : constant Int := 3 * 4; - begin - Utilities.Clear_Background_Colour (Back_Colour); - - Shader_Program.Use_Program; - Position_Location := GL.Objects.Programs.Attrib_Location - (Shader_Program, "position"); - GL.Attributes.Enable_Vertex_Attrib_Array (Position_Location); - GL.Attributes.Set_Vertex_Attrib_Pointer (Position_Location, - 2, Single_Type, False, Stride, 0); - - Colour_Location := GL.Objects.Programs.Attrib_Location - (Shader_Program, "colour"); - GL.Attributes.Enable_Vertex_Attrib_Array (Colour_Location); - GL.Attributes.Set_Vertex_Attrib_Pointer - (Colour_Location, 3, Single_Type, False, Stride, Skip); - - GL.Objects.Buffers.Draw_Elements (GL.Types.Triangles, 3, UInt_Type); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use Program_Loader; - begin - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vector5_Buffer (Array_Buffer, Vertex_Data.Vertices_Coloured, Static_Draw); - - Elements_Buffer.Initialize_Id; - Element_Array_Buffer.Bind (Elements_Buffer); - Vertex_Data.Load_Element_Buffer (Element_Array_Buffer, Vertex_Data.Elements, Static_Draw); - - Shader_Program := Program_From - ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - Put ("Shader_Program.Info_Log: "); - Put_Line (Shader_Program.Info_Log); - Put_Line ("Shader_Program.Active_Attributes:" & - GL.Types.Size'Image (Shader_Program.Active_Attributes)); - Put_Line ("Shader_Program.Active_Uniforms:" & - GL.Types.Size'Image (Shader_Program.Active_Uniforms)); - New_Line; - Utilities.Show_Shader_Program_Data (Shader_Program); - exception - when others => - Put_Line ("An exception occurred in Setup_Graphic."); - raise; - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/open_gl/coloured_elements/src/main_loop.ads b/examples/open_gl/coloured_elements/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/open_gl/coloured_elements/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/open_gl/coloured_elements/src/shaders/fragment_shader.glsl b/examples/open_gl/coloured_elements/src/shaders/fragment_shader.glsl deleted file mode 100755 index 00c3bda9..00000000 --- a/examples/open_gl/coloured_elements/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - -in vec3 triangle_colour; - -out vec4 Frag_Colour; - -void main() -{ - Frag_Colour = vec4(triangle_colour, 1.0); -} diff --git a/examples/open_gl/coloured_elements/src/shaders/vertex_shader.glsl b/examples/open_gl/coloured_elements/src/shaders/vertex_shader.glsl deleted file mode 100755 index d9f23658..00000000 --- a/examples/open_gl/coloured_elements/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 410 - -in vec2 position; -in vec3 colour; - -out vec3 triangle_colour; - -void main() -{ - triangle_colour = colour; - gl_Position = vec4(position, 0.0, 1.0); -} diff --git a/examples/open_gl/coloured_elements/src/vertex_data.ads b/examples/open_gl/coloured_elements/src/vertex_data.ads deleted file mode 100644 index 792090a8..00000000 --- a/examples/open_gl/coloured_elements/src/vertex_data.ads +++ /dev/null @@ -1,19 +0,0 @@ - -with GL.Objects.Buffers; -with GL.Types; - -with Maths; - -package Vertex_Data is - use GL.Types; - - procedure Load_Element_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (GL.Types.Int_Pointers); - - Vertices_Coloured : Maths.Vector5_Array (1 .. 3) := - ((0.0, 0.5, 1.0, 0.0, 0.0), - (0.5, -0.5, 0.0, 1.0, 0.0), - (-0.5, -0.5, 0.0, 0.0, 1.0)); - - Elements : Int_Array (1 .. 3) := (0, 1, 2); -end Vertex_Data; diff --git a/examples/open_gl/simple_uniform/.gitignore b/examples/open_gl/simple_uniform/.gitignore deleted file mode 100644 index 69b316fc..00000000 --- a/examples/open_gl/simple_uniform/.gitignore +++ /dev/null @@ -1 +0,0 @@ -uniform_example diff --git a/examples/open_gl/simple_uniform/simple_uniform.gpr b/examples/open_gl/simple_uniform/simple_uniform.gpr deleted file mode 100644 index d0e44964..00000000 --- a/examples/open_gl/simple_uniform/simple_uniform.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Simple_Uniform is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("uniform_example.adb"); - - package Compiler renames OpenGL.Compiler; - -end Simple_Uniform; - diff --git a/examples/open_gl/simple_uniform/src/main_loop.adb b/examples/open_gl/simple_uniform/src/main_loop.adb deleted file mode 100644 index 92ca1f32..00000000 --- a/examples/open_gl/simple_uniform/src/main_loop.adb +++ /dev/null @@ -1,102 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Types; -with GL.Uniforms; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Position_Location : GL.Attributes.Attribute; - Colour_Location : GL.Uniforms.Uniform; - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types; - use Maths.Single_Math_Functions; - Now : constant Glfw.Seconds := Glfw.Time; - begin - Rendering_Program.Use_Program; - GL.Uniforms.Set_Single (Colour_Location, - (1.0 + Sin (4.0 * Single (Now))) / 2.0, 0.0, 0.0); - GL.Objects.Vertex_Arrays.Draw_Arrays (GL.Types.Triangles, 0, 3); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use GL.Types; - use Program_Loader; - begin - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertex_Data.Vertices, Static_Draw); - - Rendering_Program := Program_From - ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - - Position_Location := GL.Objects.Programs.Attrib_Location - (Rendering_Program, "position"); - GL.Attributes.Set_Vertex_Attrib_Pointer - (Position_Location, 2, GL.Types.Single_Type, False, 0, 0); - GL.Attributes.Enable_Vertex_Attrib_Array (Position_Location); - Colour_Location := GL.Objects.Programs.Uniform_Location - (Rendering_Program, "triangle_colour"); - - Rendering_Program.Use_Program; -- Needed to set uniform values - GL.Uniforms.Set_Single (Colour_Location, 1.0, 0.0, 0.0); - - Utilities.Show_Shader_Program_Data (Rendering_Program); - exception - when others => - Put_Line ("An exception occurred in Setup_Graphic."); - raise; - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/open_gl/simple_uniform/src/main_loop.ads b/examples/open_gl/simple_uniform/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/open_gl/simple_uniform/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/open_gl/simple_uniform/src/shaders/fragment_shader.glsl b/examples/open_gl/simple_uniform/src/shaders/fragment_shader.glsl deleted file mode 100755 index 0418de26..00000000 --- a/examples/open_gl/simple_uniform/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - -uniform vec3 triangle_colour; - -out vec4 Frag_Colour; - -void main() -{ - Frag_Colour = vec4(triangle_colour, 1.0); -} diff --git a/examples/open_gl/simple_uniform/src/shaders/vertex_shader.glsl b/examples/open_gl/simple_uniform/src/shaders/vertex_shader.glsl deleted file mode 100755 index 8e3d27c4..00000000 --- a/examples/open_gl/simple_uniform/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 410 - -in vec2 position; -in vec3 colour; - -out vec3 colour_out; - -void main() -{ - gl_Position = vec4(position, 0.0, 1.0); - colour_out = colour; -} diff --git a/examples/open_gl/simple_uniform/src/uniform_example.adb b/examples/open_gl/simple_uniform/src/uniform_example.adb deleted file mode 100644 index 973f4652..00000000 --- a/examples/open_gl/simple_uniform/src/uniform_example.adb +++ /dev/null @@ -1,31 +0,0 @@ --- Uniform Example --- Author Roger Mc Murtrie --- Created 16 Febuary 2017 --- Based on https://open.gl/drawing - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Uniform_Example is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Simple With Uniforms"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Uniform_Example returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Uniform_Example."); - Put_Line (Exception_Information (anError)); -end Uniform_Example; diff --git a/examples/open_gl/simple_uniform/src/vertex_data.ads b/examples/open_gl/simple_uniform/src/vertex_data.ads deleted file mode 100644 index 4c9702a4..00000000 --- a/examples/open_gl/simple_uniform/src/vertex_data.ads +++ /dev/null @@ -1,11 +0,0 @@ - -with GL.Types; - -package Vertex_Data is - use GL.Types; - - Vertices : Singles.Vector2_Array (1 .. 3) := - ((0.0, 0.5), - (0.5, -0.5), - (-0.5, -0.5)); -end Vertex_Data; diff --git a/examples/open_gl/square/.gitignore b/examples/open_gl/square/.gitignore deleted file mode 100644 index 6424be22..00000000 --- a/examples/open_gl/square/.gitignore +++ /dev/null @@ -1 +0,0 @@ -coloured_square diff --git a/examples/open_gl/square/coloured_square.gpr b/examples/open_gl/square/coloured_square.gpr deleted file mode 100644 index b7a83694..00000000 --- a/examples/open_gl/square/coloured_square.gpr +++ /dev/null @@ -1,14 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Coloured_Square is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("coloured_square.adb"); - - package Compiler renames OpenGL.Compiler; - -end Coloured_Square; diff --git a/examples/open_gl/square/src/coloured_square.adb b/examples/open_gl/square/src/coloured_square.adb deleted file mode 100644 index efcb1601..00000000 --- a/examples/open_gl/square/src/coloured_square.adb +++ /dev/null @@ -1,31 +0,0 @@ --- Coloured Square --- Author Roger Mc Murtrie --- Created 22 Febuary 2017 --- Based on https://open.gl/drawing Drawing Polygons - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Coloured_Square is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Coloured Square"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Coloured_Square returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Coloured_Square."); - Put_Line (Exception_Information (anError)); -end Coloured_Square; diff --git a/examples/open_gl/square/src/main_loop.adb b/examples/open_gl/square/src/main_loop.adb deleted file mode 100644 index 3a82c9ad..00000000 --- a/examples/open_gl/square/src/main_loop.adb +++ /dev/null @@ -1,115 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Types; -with GL.Types.Colors; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Shader_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Elements_Buffer : GL.Objects.Buffers.Buffer; - Position_Location : GL.Attributes.Attribute; - Colour_Location : GL.Attributes.Attribute; - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types; - Back_Colour : constant Colors.Color := (0.0, 0.6, 0.6, 1.0); - Stride : constant Int := 5 * 4; - Skip : constant Int := 3 * 4; - begin - Utilities.Clear_Background_Colour (Back_Colour); - - Shader_Program.Use_Program; - GL.Attributes.Enable_Vertex_Attrib_Array (Position_Location); - GL.Attributes.Set_Vertex_Attrib_Pointer - (Position_Location, 2, Single_Type, False, Stride, 0); - - GL.Attributes.Enable_Vertex_Attrib_Array (Colour_Location); - - GL.Attributes.Set_Vertex_Attrib_Pointer - (Colour_Location, 3, Single_Type, False, Stride, Skip); - - GL.Objects.Buffers.Draw_Elements (GL.Types.Triangles, 6, UInt_Type); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use Program_Loader; - begin - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vector5_Buffer (Array_Buffer, Vertex_Data.Vertices, Static_Draw); - - Elements_Buffer.Initialize_Id; - Element_Array_Buffer.Bind (Elements_Buffer); - Vertex_Data.Load_Element_Buffer (Element_Array_Buffer, Vertex_Data.Elements, Static_Draw); - - Shader_Program := Program_From - ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - Put ("Shader_Program.Info_Log: "); - Put_Line (Shader_Program.Info_Log); - Put_Line ("Shader_Program.Active_Attributes:" & - GL.Types.Size'Image (Shader_Program.Active_Attributes)); - Put_Line ("Shader_Program.Active_Uniforms:" & - GL.Types.Size'Image (Shader_Program.Active_Uniforms)); - - Position_Location := GL.Objects.Programs.Attrib_Location - (Shader_Program, "position"); - Colour_Location := GL.Objects.Programs.Attrib_Location - (Shader_Program, "colour"); - - Utilities.Show_Shader_Program_Data (Shader_Program); - exception - when others => - Put_Line ("An exception occurred in Setup_Graphic."); - raise; - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/open_gl/square/src/main_loop.ads b/examples/open_gl/square/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/open_gl/square/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/open_gl/square/src/shaders/fragment_shader.glsl b/examples/open_gl/square/src/shaders/fragment_shader.glsl deleted file mode 100755 index 00c3bda9..00000000 --- a/examples/open_gl/square/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - -in vec3 triangle_colour; - -out vec4 Frag_Colour; - -void main() -{ - Frag_Colour = vec4(triangle_colour, 1.0); -} diff --git a/examples/open_gl/square/src/shaders/vertex_shader.glsl b/examples/open_gl/square/src/shaders/vertex_shader.glsl deleted file mode 100755 index d9f23658..00000000 --- a/examples/open_gl/square/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 410 - -in vec2 position; -in vec3 colour; - -out vec3 triangle_colour; - -void main() -{ - triangle_colour = colour; - gl_Position = vec4(position, 0.0, 1.0); -} diff --git a/examples/open_gl/square/src/vertex_data.ads b/examples/open_gl/square/src/vertex_data.ads deleted file mode 100644 index 3e953045..00000000 --- a/examples/open_gl/square/src/vertex_data.ads +++ /dev/null @@ -1,28 +0,0 @@ - -with Interfaces.C.Pointers; - -with GL.Objects.Buffers; -with GL.Types; - -with Maths; - -package Vertex_Data is - use GL.Types; - - type Elements_Array is array (GL.Types.Int range <>) of aliased GL.Types.Int; - - package Element_Pointers is new Interfaces.C.Pointers - (GL.Types.Int, GL.Types.Int, Elements_Array, 0); - - procedure Load_Element_Buffer is new - GL.Objects.Buffers.Load_To_Buffer (Element_Pointers); - - Vertices : Maths.Vector5_Array (1 .. 4) := - ((-0.5, 0.5, 1.0, 0.0, 0.0), -- Top-left - (0.5, 0.5, 0.0, 1.0, 0.0), -- Top-right - (0.5, -0.5, 0.0, 0.0, 1.0), -- Bottom-right - (-0.5, -0.5, 1.0, 1.0, 1.0)); -- Bottom-left - - Elements : Elements_Array (1 .. 6) := (0, 1, 2, - 2, 3, 0); -end Vertex_Data; diff --git a/examples/open_gl/very_simple/.gitignore b/examples/open_gl/very_simple/.gitignore deleted file mode 100644 index 810d36e3..00000000 --- a/examples/open_gl/very_simple/.gitignore +++ /dev/null @@ -1 +0,0 @@ -triangle diff --git a/examples/open_gl/very_simple/simple_triangle.gpr b/examples/open_gl/very_simple/simple_triangle.gpr deleted file mode 100644 index b69d942f..00000000 --- a/examples/open_gl/very_simple/simple_triangle.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Simple_Triangle is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("triangle.adb"); - - package Compiler renames OpenGL.Compiler; - -end Simple_Triangle; - diff --git a/examples/open_gl/very_simple/src/main_loop.adb b/examples/open_gl/very_simple/src/main_loop.adb deleted file mode 100644 index 8f50c52b..00000000 --- a/examples/open_gl/very_simple/src/main_loop.adb +++ /dev/null @@ -1,89 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Types; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Position_Location : GL.Attributes.Attribute; - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types; - begin - Rendering_Program.Use_Program; - GL.Objects.Vertex_Arrays.Draw_Arrays (GL.Types.Triangles, 0, 3); - exception - when others => - Put_Line ("An exception occurred in Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use GL.Types; - use Program_Loader; - begin - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertex_Data.Vertices, Static_Draw); - - Rendering_Program := Program_From - ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - - Position_Location := GL.Objects.Programs.Attrib_Location - (Rendering_Program, "position"); - GL.Attributes.Set_Vertex_Attrib_Pointer - (Position_Location, 2, GL.Types.Single_Type, False, 0, 0); - GL.Attributes.Enable_Vertex_Attrib_Array (Position_Location); - - Utilities.Show_Shader_Program_Data (Rendering_Program); - exception - when others => - Put_Line ("An exception occurred in Setup_Graphic."); - raise; - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/open_gl/very_simple/src/main_loop.ads b/examples/open_gl/very_simple/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/open_gl/very_simple/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/open_gl/very_simple/src/shaders/fragment_shader.glsl b/examples/open_gl/very_simple/src/shaders/fragment_shader.glsl deleted file mode 100755 index 4385a186..00000000 --- a/examples/open_gl/very_simple/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#version 410 - -out vec4 Frag_Colour; - -void main() -{ - Frag_Colour = vec4(1.0, 1.0, 1.0, 1.0); -} diff --git a/examples/open_gl/very_simple/src/shaders/vertex_shader.glsl b/examples/open_gl/very_simple/src/shaders/vertex_shader.glsl deleted file mode 100755 index 221c7659..00000000 --- a/examples/open_gl/very_simple/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#version 410 - -in vec2 position; - -void main() -{ - gl_Position = vec4(position, 0.0, 1.0); -} diff --git a/examples/open_gl/very_simple/src/triangle.adb b/examples/open_gl/very_simple/src/triangle.adb deleted file mode 100644 index 9f03eedb..00000000 --- a/examples/open_gl/very_simple/src/triangle.adb +++ /dev/null @@ -1,31 +0,0 @@ --- Program Triangle --- Author Roger Mc Murtrie --- Created 16 Febuary 2017 --- Based on https://open.gl/drawing - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Triangle is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Simple Triangle"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Triangle returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Triangle."); - Put_Line (Exception_Information (anError)); -end Triangle; diff --git a/examples/open_gl/very_simple/src/vertex_data.ads b/examples/open_gl/very_simple/src/vertex_data.ads deleted file mode 100644 index b1a4ecce..00000000 --- a/examples/open_gl/very_simple/src/vertex_data.ads +++ /dev/null @@ -1,10 +0,0 @@ - -with GL.Types; - -package Vertex_Data is - use GL.Types; - - Vertices : constant Singles.Vector3_Array (1 .. 2) := - ((0.0, 0.5, 0.5), - (-0.5, -0.5, -0.5)); -end Vertex_Data; diff --git a/examples/redbook/03_draw_commands/.gitignore b/examples/redbook/03_draw_commands/.gitignore deleted file mode 100644 index e7e116af..00000000 --- a/examples/redbook/03_draw_commands/.gitignore +++ /dev/null @@ -1 +0,0 @@ -draw_triangles diff --git a/examples/redbook/03_draw_commands/draw_commands.gpr b/examples/redbook/03_draw_commands/draw_commands.gpr deleted file mode 100644 index c9b11c1a..00000000 --- a/examples/redbook/03_draw_commands/draw_commands.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Draw_Commands is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Exec_Dir use "."; - for Main use ("draw_triangles.adb"); - - package Compiler renames OpenGL.Compiler; - -end Draw_Commands; - diff --git a/examples/redbook/03_draw_commands/src/draw_triangles.adb b/examples/redbook/03_draw_commands/src/draw_triangles.adb deleted file mode 100644 index dec0f78d..00000000 --- a/examples/redbook/03_draw_commands/src/draw_triangles.adb +++ /dev/null @@ -1,32 +0,0 @@ --- Draw_Triangles implements Redbook example 03-drawcommands from OGLPG-9th-Edition --- Author: R Mc Murtrie --- 5th March 1918 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Draw_Triangles is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Drawing Commands"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Draw_Triangles returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Draw_Triangles."); - Put_Line (Exception_Information (anError)); - -end Draw_Triangles; diff --git a/examples/redbook/03_draw_commands/src/main_loop.adb b/examples/redbook/03_draw_commands/src/main_loop.adb deleted file mode 100644 index d7d847ae..00000000 --- a/examples/redbook/03_draw_commands/src/main_loop.adb +++ /dev/null @@ -1,168 +0,0 @@ - - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; -with GL.Window; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - use GL.Types; - - Render_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Vertex_Buffer : GL.Objects.Buffers.Buffer; - Element_Buffer : GL.Objects.Buffers.Buffer; - - Render_Model_Matrix_ID : GL.Uniforms.Uniform; - Render_Projection_Matrix_ID : GL.Uniforms.Uniform; - - -- ------------------------------------------------------------------------ - - procedure Render (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Objects.Vertex_Arrays; - use GL.Types.Singles; - Background : constant GL.Types.Colors.Color := (0.7, 0.7, 0.7, 1.0); - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - Aspect : Single; - Scale : constant Single := 1.5; -- Increase to reduce size - Model_Matrix : Matrix4 := GL.Types.Singles.Identity4; - Projection_Matrix : Matrix4; - begin - Window.Get_Framebuffer_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (10, 10, GL.Types.Int (Window_Width) - 20, - GL.Types.Int (Window_Height) - 20); - Aspect := Scale * Single (Window_Height) / Single (Window_Width); - - GL.Toggles.Enable (GL.Toggles.Cull_Face); - Utilities.Clear_Background_Colour_And_Depth (Background); - - GL.Objects.Programs.Use_Program (Render_Program); - - -- Set up the projection matrix - -- Top, Bottom, Left, Right, Near, Far - Maths.Init_Orthographic_Transform (Scale, -Scale, -Aspect, Aspect, -1.0, 500.0, - Projection_Matrix); - GL.Uniforms.Set_Single (Render_Projection_Matrix_ID, Projection_Matrix); - - -- Set up for the Draw_Elements call - Vertex_Array.Bind; - Element_Array_Buffer.Bind (Element_Buffer); - - -- Draw arrays - Model_Matrix := Model_Matrix * Maths.Translation_Matrix ((0.0, -0.3, 5.0)); - GL.Uniforms.Set_Single (Render_Model_Matrix_ID, Model_Matrix); - Draw_Arrays (Triangles, 0, 3); - - -- Draw elements - Model_Matrix := Model_Matrix * Maths.Translation_Matrix ((-0.5, 0.2, 5.0)); - GL.Uniforms.Set_Single (Render_Model_Matrix_ID, Model_Matrix); - Draw_Elements (Triangles, 3, UInt_Type); - - -- Draw elements base vertex - Model_Matrix := Maths.Translation_Matrix ((1.0, 0.4, 5.0)); - GL.Uniforms.Set_Single (Render_Model_Matrix_ID, Model_Matrix); - Draw_Elements (Triangles, 3, UInt_Type); - - -- Draw arrays instanced - Model_Matrix := Maths.Translation_Matrix ((1.5, 0.5, 5.0)); - GL.Uniforms.Set_Single (Render_Model_Matrix_ID, Model_Matrix); - Draw_Arrays_Instanced (Triangles, 0, 3, 1); - - exception - when others => - Put_Line ("An exception occurred in Main_Loop.Render."); - raise; - end Render; - - -- ------------------------------------------------------------------------ - - procedure Setup is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use Program_Loader; - Vertex_Data_Bytes : constant Int := Vertex_Data.Vertex_Positions'Size / 8; - Colour_Data_Size : constant Int := Vertex_Data.Vertex_Colours'Size / 8; - begin - Render_Program := Program_From - ((Src ("src/shaders/primitive_restart_vs.glsl", Vertex_Shader), - Src ("src/shaders/primitive_restart_fs.glsl", Fragment_Shader))); - - Render_Model_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "model_matrix"); - Render_Projection_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "projection_matrix"); - - -- Set up the vertex attributes - -- This must be done before setting up the element array buffer - -- otherwise, calls to Draw_Elements will fail - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - -- Set up the element array buffer - Element_Buffer.Initialize_Id; - Element_Array_Buffer.Bind (Element_Buffer); - Utilities.Load_Element_Buffer (Element_Array_Buffer, - Vertex_Data.Vertex_Indices, - Static_Draw); - - Vertex_Buffer.Initialize_Id; - Array_Buffer.Bind (Vertex_Buffer); - - Allocate (Array_Buffer, Long (Vertex_Data_Bytes + Colour_Data_Size), Static_Draw); - Utilities.Load_Vertex_Sub_Buffer - (Array_Buffer, 0, Vertex_Data.Vertex_Positions); - Utilities.Load_Vertex_Sub_Buffer - (Array_Buffer, Vertex_Data_Bytes, Vertex_Data.Vertex_Colours); - - GL.Attributes.Set_Vertex_Attrib_Pointer - (0, 4, Single_Type, False, 0, 0); - GL.Attributes.Set_Vertex_Attrib_Pointer - (1, 4, Single_Type, False, 4 * 4, 0); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - GL.Attributes.Enable_Vertex_Attrib_Array (1); - - exception - when others => - Put_Line ("An exception occurred in Main_Loop.Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup; - while Running loop - Render (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exceptiom occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/redbook/03_draw_commands/src/main_loop.ads b/examples/redbook/03_draw_commands/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/redbook/03_draw_commands/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/redbook/03_draw_commands/src/shaders/primitive_restart_fs.glsl b/examples/redbook/03_draw_commands/src/shaders/primitive_restart_fs.glsl deleted file mode 100755 index 295c8ce5..00000000 --- a/examples/redbook/03_draw_commands/src/shaders/primitive_restart_fs.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 core - -in vec4 vs_fs_colour; - -layout (location = 0) out vec4 colour; - -void main(void) -{ - colour = vs_fs_colour; -} diff --git a/examples/redbook/03_draw_commands/src/shaders/primitive_restart_vs.glsl b/examples/redbook/03_draw_commands/src/shaders/primitive_restart_vs.glsl deleted file mode 100755 index 549cf277..00000000 --- a/examples/redbook/03_draw_commands/src/shaders/primitive_restart_vs.glsl +++ /dev/null @@ -1,15 +0,0 @@ -#version 410 core - -uniform mat4 model_matrix; -uniform mat4 projection_matrix; - -layout (location = 0) in vec4 position; -layout (location = 1) in vec4 colour; - -out vec4 vs_fs_colour; - -void main(void) -{ - vs_fs_colour = colour; - gl_Position = projection_matrix * (model_matrix * position); -} diff --git a/examples/redbook/03_draw_commands/src/vertex_data.ads b/examples/redbook/03_draw_commands/src/vertex_data.ads deleted file mode 100644 index 630fa4ae..00000000 --- a/examples/redbook/03_draw_commands/src/vertex_data.ads +++ /dev/null @@ -1,21 +0,0 @@ - -with GL.Types; - -package Vertex_Data is - use GL.Types; - - Vertex_Positions : Singles.Vector4_Array (1 .. 4) - := ((-1.0, -1.0, 0.0, 1.0), - (1.0, -1.0, 0.0, 1.0), - (-1.0, 1.0, 0.0, 1.0), - (-1.0, -1.0, 0.0, 1.0)); - - Vertex_Colours : Singles.Vector4_Array (1 .. 4) - := ((1.0, 1.0, 1.0, 1.0), - (1.0, 1.0, 0.0, 1.0), - (1.0, 0.0, 1.0, 1.0), - (0.0, 1.0, 1.0, 1.0)); - - Vertex_Indices : UInt_Array (1 .. 3) := (0, 1, 2); - -end Vertex_Data; diff --git a/examples/redbook/03_instancing/.gitignore b/examples/redbook/03_instancing/.gitignore deleted file mode 100644 index 99aae600..00000000 --- a/examples/redbook/03_instancing/.gitignore +++ /dev/null @@ -1 +0,0 @@ -instancing diff --git a/examples/redbook/03_instancing/instancing_example.gpr b/examples/redbook/03_instancing/instancing_example.gpr deleted file mode 100644 index b357f4a6..00000000 --- a/examples/redbook/03_instancing/instancing_example.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Instancing_Example is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Exec_Dir use "."; - for Main use ("instancing.adb"); - - package Compiler renames OpenGL.Compiler; - -end Instancing_Example; - diff --git a/examples/redbook/03_instancing/src/instancing.adb b/examples/redbook/03_instancing/src/instancing.adb deleted file mode 100644 index 5bc68e1a..00000000 --- a/examples/redbook/03_instancing/src/instancing.adb +++ /dev/null @@ -1,29 +0,0 @@ - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Instancing is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "Red Book Tutorial 3 - Instancing"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Instancing returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Instancing."); - Put_Line (Exception_Information (anError)); - -end Instancing; diff --git a/examples/redbook/03_instancing/src/main_loop.adb b/examples/redbook/03_instancing/src/main_loop.adb deleted file mode 100644 index f364a02e..00000000 --- a/examples/redbook/03_instancing/src/main_loop.adb +++ /dev/null @@ -1,224 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Buffers; -with GL.Objects; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Pixels; -with GL.Toggles; -with GL.Types.Colors; -with GL.Uniforms; -with GL.Window; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; - -with Load_VB_Object; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - use GL.Types; - - Background : constant GL.Types.Colors.Color := (1.0, 1.0, 1.0, 0.0); - - Colour_Buffer : GL.Objects.Buffers.Buffer; - Model_Matrix_Buffer : GL.Objects.Buffers.Buffer; - Colour_TBO : GL.Objects.Buffers.Buffer; - Model_Matrix_TBO : GL.Objects.Buffers.Buffer; - Render_Program : GL.Objects.Programs.Program; - - View_Matrix_ID : GL.Uniforms.Uniform; - Projection_Matrix_ID : GL.Uniforms.Uniform; - - VBM_Object : Load_VB_Object.VB_Object; - - Vertex_Location : constant Int := 0; - Normal_Location : constant Int := 1; - Tex_Coord0_Location : constant Int := 2; - - Num_Instances : constant UInt := 50; - - -- ------------------------------------------------------------------------ - - procedure Display (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Types.Singles; - use Maths; - Window_Width : Glfw.Size; - Window_Height : Glfw.Size; - Aspect : Single; - Model_Matrices : Singles.Matrix4_Array (1 .. 4); - View_Matrix : Singles.Matrix4; - Projection_Matrix : Singles.Matrix4; - Scale : constant Single := -0.006; - Current_Time : Float; -- t - a : Single; - b : Single; - c : Single; - Time_Component : Single; - begin - Current_Time := Float (Glfw.Time); - Utilities.Clear_Background_Colour_And_Depth (Background); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (LEqual); - - Window.Get_Framebuffer_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (10, 10, GL.Types.Int (Window_Width) - 10, - GL.Types.Int (Window_Height) - 10); - Aspect := Single (Window_Height) / Single (Window_Width); - - Time_Component := Single (36.0 * Current_Time); - for Index in Model_Matrices'Range loop - a := Single (50 * Index) / 4.0; - b := Single (50 * Index) / 5.0; - c := Single (50 * Index) / 6.0; - Model_Matrices (Index) := Maths.Translation_Matrix - ((a + 10.0, b + 40.0, c + 50.0)) * - Maths.Rotation_Matrix - (Degree (c + Time_Component), (0.0, 0.0, 1.0)) * - Maths.Rotation_Matrix - (Degree (a + Time_Component), (1.0, 0.0, 0.0)) * - Maths.Rotation_Matrix - (Degree (b + Time_Component), (0.0, 1.0, 0.0)); - end loop; - - -- Bind the weight VBO and change its data - Texture_Buffer.Bind (Model_Matrix_Buffer); - Utilities.Load_Texture_Buffer (Texture_Buffer, Model_Matrices, Dynamic_Draw); - - GL.Objects.Programs.Use_Program (Render_Program); - View_Matrix := - Maths.Translation_Matrix ((0.0, 0.0, 1500.0)) * - Maths.Rotation_Matrix (Degree (2.0 * Time_Component), (0.0, 1.0, 0.0)) * - Maths.Scaling_Matrix (Scale); - Init_Orthographic_Transform (-1.0, 1.0, -Aspect, Aspect, -1.0, 5000.0, - Projection_Matrix); - GL.Uniforms.Set_Single (View_Matrix_ID, View_Matrix); - GL.Uniforms.Set_Single (Projection_Matrix_ID, Projection_Matrix); - Load_VB_Object.Render (VBM_Object, 1, Num_Instances); - - exception - when others => - Put_Line ("An exception occurred in Main_Loop.Display."); - raise; - end Display; - - -- ------------------------------------------------------------------------ - - function Setup return Boolean is - use GL.Objects.Buffers; - use GL.Objects.Programs; - use GL.Objects.Shaders; - use Program_Loader; - Colour_TBO_ID : GL.Uniforms.Uniform; - Model_Matrix_TBO_ID : GL.Uniforms.Uniform; - Colours : Singles.Vector4_Array (1 .. Int (Num_Instances)); - a : Single; - b : Single; - c : Single; - VBM_Result : Boolean := False; - begin - Render_Program := Program_From - ((Src ("src/shaders/render_vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/render_fragment_shader.glsl", Fragment_Shader))); - - GL.Objects.Programs.Use_Program (Render_Program); - View_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "view_matrix"); - Projection_Matrix_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "projection_matrix"); - -- Set up the TBO samplers - Colour_TBO_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "colour_tbo"); - Model_Matrix_TBO_ID := GL.Objects.Programs.Uniform_Location - (Render_Program, "model_matrix_tbo"); - -- Set them to the correct texture unit indices - GL.Uniforms.Set_Int (Colour_TBO_ID, 0); - GL.Uniforms.Set_Int (Model_Matrix_TBO_ID, 1); - - Load_VB_Object.Load_From_VBM ("../media/armadillo_low.vbm", VBM_Object, - Vertex_Location, Normal_Location, - Tex_Coord0_Location, VBM_Result); - VBM_Result := VBM_Result and Load_VB_Object.Get_Vertex_Count (VBM_Object) > 0; - - If not VBM_Result then - Put_Line ("Main_Loop.Setup; Load_From_VBM failed."); - end if; - Load_VB_Object.Print_VBM_Object_Data ("Setup", VBM_Object); - Load_VB_Object.Print_VBM_Frame_Data ("Setup, Frame 1", VBM_Object, 1); - Load_VB_Object.Print_Attributes_Header ("Setup, Vertex Attribute", VBM_Object, 0); - Load_VB_Object.Print_Attributes_Header ("Setup, Normal Attribute", VBM_Object, 1); - Load_VB_Object.Print_Attributes_Header ("Setup, Tex Coord Attribute", VBM_Object, 2); - - Colour_TBO.Initialize_Id; - Texture_Buffer.Bind (Colour_TBO); - - for index in Colours'Range loop - a := Single (index) / 4.0; - b := Single (index) / 5.0; - c := Single (index) / 6.0; - Colours (index) (GL.X) := - 0.5 + 0.25 * (1.0 + Maths.Single_Math_Functions.Sin (1.0 + a)); - Colours (index) (GL.Y) := - 0.5 + 0.25 * (1.0 + Maths.Single_Math_Functions.Sin (2.0 + b)); - Colours (index) (GL.Z) := - 0.5 + 0.25 * (1.0 + Maths.Single_Math_Functions.Sin (3.0 + c)); - Colours (index) (GL.W) := 1.0; - end loop; - - Colour_Buffer.Initialize_Id; - Texture_Buffer.Bind (Colour_Buffer); - Utilities.Load_Vertex_Buffer (Texture_Buffer, Colours, Static_Draw); - Allocate (Texture_Buffer, GL.Pixels.RGBA32F, Colour_Buffer); - - Model_Matrix_TBO.Initialize_Id; - GL.Objects.Textures.Set_Active_Unit (1); - Texture_Buffer.Bind (Model_Matrix_TBO); - - Model_Matrix_Buffer.Initialize_Id; - Texture_Buffer.Bind (Model_Matrix_Buffer); - Allocate (Texture_Buffer, - Long (Num_Instances * Singles.Matrix4'Size), - Dynamic_Draw); - - Allocate (Texture_Buffer, GL.Pixels.RGBA32F, Model_Matrix_Buffer); - GL.Objects.Textures.Set_Active_Unit (0); - - return VBM_Result; - - exception - when others => - Put_Line ("An exception occurred in Main_Loop.Setup."); - raise; - end Setup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - if Setup then - while Running loop - Display (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; - end if; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/redbook/03_instancing/src/main_loop.ads b/examples/redbook/03_instancing/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/redbook/03_instancing/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/redbook/03_instancing/src/shaders/render_fragment_shader.glsl b/examples/redbook/03_instancing/src/shaders/render_fragment_shader.glsl deleted file mode 100755 index d2e43607..00000000 --- a/examples/redbook/03_instancing/src/shaders/render_fragment_shader.glsl +++ /dev/null @@ -1,16 +0,0 @@ -#version 410 core - -layout (location = 0) out vec4 colour; - -in VERTEX -{ - vec3 normal; - vec4 colour; -} vertex; - -void main(void) - { - // colour = vertex.colour * (0.1 + abs(vertex.normal.z)) + vec4(0.8, 0.9, 0.7, 1.0) * pow(abs(vertex.normal.z), 40.0); - colour = vertex.colour * (0.8 + 1.0 * abs(vertex.normal.z)) - + vec4(0.8, 0.9, 0.7, 1.0) * pow(abs(vertex.normal.z), 40.0); - } diff --git a/examples/redbook/03_instancing/src/shaders/render_vertex_shader.glsl b/examples/redbook/03_instancing/src/shaders/render_vertex_shader.glsl deleted file mode 100755 index f54acb99..00000000 --- a/examples/redbook/03_instancing/src/shaders/render_vertex_shader.glsl +++ /dev/null @@ -1,48 +0,0 @@ -#version 410 core - -layout (location = 0) in vec4 position; -layout (location = 1) in vec3 normal; -layout (location = 2) in vec4 colour; - -uniform mat4 view_matrix; -uniform mat4 projection_matrix; - -// These are the texture buffer objects that hold per-instance colors and per-instance model matrices -uniform samplerBuffer colour_tbo; -uniform samplerBuffer model_matrix_tbo; - -// The output of the vertex shader (matched to the fragment shader) -out VERTEX - { - vec3 normal; - vec4 colour; - } vertex; - -void main(void) - { - // Use gl_InstanceID to obtain the instance color from the color TBO - vec4 colour = texelFetch(colour_tbo, gl_InstanceID); - // Generating the model matrix is more complex because you can't - // store mat4 data in a TBO. Instead, we need to store each matrix - // as four vec4 variables and assemble the matrix in the shader. - // First, fetch the four columns of the matrix (remember, matrices are - // stored in memory in column-primary order). - vec4 col1 = texelFetch(model_matrix_tbo, gl_InstanceID * 4); - vec4 col2 = texelFetch(model_matrix_tbo, gl_InstanceID * 4 + 1); - vec4 col3 = texelFetch(model_matrix_tbo, gl_InstanceID * 4 + 2); - vec4 col4 = texelFetch(model_matrix_tbo, gl_InstanceID * 4 + 3); - // Now assemble the four columns into a matrix. - mat4 model_matrix = mat4(col1, col2, col3, col4); - - // Now construct a model-view matrix from the uniform view matrix - // and the per-instance model matrix. - mat4 model_view_matrix = view_matrix * model_matrix; - - // Transform position by the model-view matrix then by the projection matrix. - gl_Position = projection_matrix * (model_view_matrix * position); - // Transform the normal by the upper-left-3x3-submatrix of the - // model-view matrix - vertex.normal = mat3(model_view_matrix) * normal; - // Pass the per-instance colour through to the fragment shader. - vertex.colour = colour; - } diff --git a/examples/redbook/Readme.md b/examples/redbook/Readme.md deleted file mode 100644 index a4654016..00000000 --- a/examples/redbook/Readme.md +++ /dev/null @@ -1,15 +0,0 @@ -Author: Roger Mc Murtrie -These examples are based on OpenGL Programming Guide, eighth edition, -by D Shreiner, G. Sellers, J. Kessinich, and B. Licea-Kane, Addison Wesley, 2013 and the associated -computer code at https://github.com/openglredbook/examples using Glfw version 3. -The version numbers in the shader programs may need modification depending on your -platform. -For Mac users, note that the Glfw provided with OSX is incompatible with OpenGLAda as it does not contain libglfw.a. -A compatible version can be obtained from Homebrew: brew install glfw. - -GNAT Programming Studio (GPS) Considerations -Use Tools->Views->Scenarios to display the Scenario panel. -In the Scenario panel set GLFW Version to 3. -For Mac, in the Scenario panel set Windowing System to quartz. -In Preferences, ensure that Editor->Fonts & Colors->Default is set to a fixed size font. -In Preferences->Editor->Ada set appropriate format selectors. diff --git a/examples/redbook/media/armadillo_low.vbm b/examples/redbook/media/armadillo_low.vbm deleted file mode 100644 index e9af4348..00000000 Binary files a/examples/redbook/media/armadillo_low.vbm and /dev/null differ diff --git a/examples/superbible/Readme.md b/examples/superbible/Readme.md deleted file mode 100644 index 8af036c9..00000000 --- a/examples/superbible/Readme.md +++ /dev/null @@ -1,17 +0,0 @@ -Author: Roger Mc Murtrie -These examples are based on the listings in OpenGL SuperBible, seventh edition, -by G. Sellers, R. S. Wright, Jr and N. Haemel, Addison Wesley, 2016 and the associated -computer code at www.openglsuperbible.com using Glfw version 3. -The version numbers in the shader programs may need modification depending on your -platform. -For Mac users, note that the Glfw provided with OSX is incompatible with OpenGLAda as it does not contain libglfw.a. -A compatible version can be obtained from Homebrew: brew install glfw. - -GNAT Programming Studio (GPS) Considerations -Use Tools->Views->Scenarios to display the Scenario panel. -In the Scenario panel set GLFW Version to 3. -For Mac, in the Scenario panel set Windowing System to quartz. -In Preferences, ensure that Editor->Fonts & Colors->Default is set to a fixed size font. -In Preferences->Editor->Ada set appropriate format selectors. - - diff --git a/examples/superbible/fragment_colouring/.gitignore b/examples/superbible/fragment_colouring/.gitignore deleted file mode 100644 index 8a5c471a..00000000 --- a/examples/superbible/fragment_colouring/.gitignore +++ /dev/null @@ -1 +0,0 @@ -colour_fragments diff --git a/examples/superbible/fragment_colouring/fragment_colouring.gpr b/examples/superbible/fragment_colouring/fragment_colouring.gpr deleted file mode 100644 index f1412a78..00000000 --- a/examples/superbible/fragment_colouring/fragment_colouring.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Fragment_Colouring is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("colour_fragments.adb"); - - package Compiler renames OpenGL.Compiler; - -end Fragment_Colouring; - diff --git a/examples/superbible/fragment_colouring/src/colour_fragments.adb b/examples/superbible/fragment_colouring/src/colour_fragments.adb deleted file mode 100644 index 734ca746..00000000 --- a/examples/superbible/fragment_colouring/src/colour_fragments.adb +++ /dev/null @@ -1,30 +0,0 @@ --- Program Colour Fragments --- Author Roger Mc Murtrie --- Created 17 December 2016 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Colour_Fragments is - Main_Window : Glfw.Windows.Window; -begin - Glfw.Init; - Initialize (Main_Window, "OpenGL SupeBible - Fragment Colouring Example"); - Main_Loop (Main_Window); - Glfw.Shutdown; - - exception - when anError : Constraint_Error => - Put ("Colour_Fragments returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Colour_Fragments."); - Put_Line (Exception_Information (anError)); - end Colour_Fragments; diff --git a/examples/superbible/fragment_colouring/src/main_loop.adb b/examples/superbible/fragment_colouring/src/main_loop.adb deleted file mode 100644 index e610ff85..00000000 --- a/examples/superbible/fragment_colouring/src/main_loop.adb +++ /dev/null @@ -1,93 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Culling; -with GL.Objects.Programs; -with GL.Objects.Vertex_Arrays; -with GL.Objects.Shaders; -with GL.Toggles; -with GL.Types; -with GL.Types.Colors; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - - -- ------------------------------------------------------------------------ - - procedure Render_Triangle (Current_Time : Glfw.Seconds) is - use GL.Types; - use Maths.Single_Math_Functions; - Now : constant Single := Single (Current_Time); - Back_Colour : constant GL.Types.Colors.Color := - (0.5 * (1.0 + Sin (Now)), 0.5 * (1.0 + Cos (Now)), 0.0, 1.0); - Offset : constant Singles.Vector4 := - (0.5 * Sin (Now), 0.5 * Cos (Now), 0.0, 0.0); - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - - GL.Objects.Programs.Use_Program (Rendering_Program); - - GL.Attributes.Set_Single (0, Offset); - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 3); - - exception - when others => - Put_Line ("An exceptiom occurred in Render_Triangle."); - raise; - end Render_Triangle; - - -- ------------------------------------------------------------------------ - - procedure Startup is - use Program_Loader; - use GL.Objects.Shaders; - begin - Rendering_Program := Program_Loader.Program_From - ((Src ("src/shaders/vertex_shader1.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - GL.Culling.Set_Front_Face (GL.Types.Clockwise); - GL.Culling.Set_Cull_Face (GL.Culling.Back); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - Utilities.Show_Shader_Program_Data (Rendering_Program); - exception - when others => - Put_Line ("An exceptiom occurred in Startup."); - raise; - end Startup; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Startup; - while Running loop - Render_Triangle (Glfw.Time); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Keys.Escape) = Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exceptiom occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/superbible/fragment_colouring/src/main_loop.ads b/examples/superbible/fragment_colouring/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/fragment_colouring/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/fragment_colouring/src/shaders/fragment_shader.glsl b/examples/superbible/fragment_colouring/src/shaders/fragment_shader.glsl deleted file mode 100644 index 089bddbb..00000000 --- a/examples/superbible/fragment_colouring/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 410 - - out vec4 fragment_colour; - -void main() -{ - // fragment_colour = vs_colour; - fragment_colour = vec4(0.5*(1.0 + sin(gl_FragCoord.x * 0.25)), - 0.5*(1.0 + cos(gl_FragCoord.y * 0.25)), - sin(gl_FragCoord.x * 0.15) * cos(gl_FragCoord.y * 0.15), - 1.0); -} diff --git a/examples/superbible/fragment_colouring/src/shaders/vertex_shader1.glsl b/examples/superbible/fragment_colouring/src/shaders/vertex_shader1.glsl deleted file mode 100644 index e596e83c..00000000 --- a/examples/superbible/fragment_colouring/src/shaders/vertex_shader1.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - - layout (location = 0) in vec4 offset; -void main() -{ - const vec4 vertices[3] = vec4[3] (vec4( 0.25, -0.25, 0.5, 1.0), - vec4(-0.25, -0.25, 0.5, 1.0), - vec4( 0.25, 0.25, 0.5, 1.0)); - gl_Position = vertices[gl_VertexID] + offset; -} diff --git a/examples/superbible/fragment_colouring/src/shaders/vertex_shader2.glsl b/examples/superbible/fragment_colouring/src/shaders/vertex_shader2.glsl deleted file mode 100644 index 702b8168..00000000 --- a/examples/superbible/fragment_colouring/src/shaders/vertex_shader2.glsl +++ /dev/null @@ -1,17 +0,0 @@ -#version 410 - - layout (location = 0) in vec4 offset; - - out vec4 vs_colour; - -void main() -{ - const vec4 vertices[3] = vec4[3] (vec4( 0.25, -0.25, 0.5, 1.0), - vec4(-0.25, -0.25, 0.5, 1.0), - vec4( 0.25, 0.25, 0.5, 1.0)); - const vec4 colours[] = vec4[3] (vec4(1.0, 0.0, 0.0, 1.0), - vec4(0.0, 1.0, 0.0, 1.0), - vec4(0.0, 0.0, 1.0, 1.0)); - vs_colour = colours[gl_VertexID]; - gl_Position = vertices[gl_VertexID] + offset; -} diff --git a/examples/superbible/moving_triangle/.gitignore b/examples/superbible/moving_triangle/.gitignore deleted file mode 100644 index 8b706dcd..00000000 --- a/examples/superbible/moving_triangle/.gitignore +++ /dev/null @@ -1 +0,0 @@ -moving_triangle diff --git a/examples/superbible/moving_triangle/moving_triangle.gpr b/examples/superbible/moving_triangle/moving_triangle.gpr deleted file mode 100644 index 75dfbe7d..00000000 --- a/examples/superbible/moving_triangle/moving_triangle.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Moving_Triangle is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("moving_triangle.adb"); - - package Compiler renames OpenGL.Compiler; - -end Moving_Triangle; - diff --git a/examples/superbible/moving_triangle/src/main_loop.adb b/examples/superbible/moving_triangle/src/main_loop.adb deleted file mode 100644 index 559820e5..00000000 --- a/examples/superbible/moving_triangle/src/main_loop.adb +++ /dev/null @@ -1,92 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Culling; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types; -with GL.Types.Colors; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - subtype tVec4f is GL.Types.Singles.Vector4; - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - --- ---------------------------------------------------------------------------- - - procedure Render_Triangle (Current_Time : Glfw.Seconds) is - use Maths.Single_Math_Functions; - use GL.Types; - Back_Colour : constant GL.Types.Colors.Color := - (0.5 * (1.0 + Sin (Single (Current_Time))), - 0.5 * (1.0 + Cos (Single (Current_Time))), 0.0, 1.0); - Colour : constant tVec4f := - (0.8 * (1.0 + Sin (Single (Current_Time))), - 0.4 * (1.0 + Cos (Single (Current_Time))), 0.4, 1.0); - Offset : constant tVec4f := - (0.5 * Sin (Single (Current_Time)), - 0.5 * Cos (Single (Current_Time)), 0.0, 0.0); - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - - GL.Objects.Programs.Use_Program (Rendering_Program); - - GL.Attributes.Set_Single (0, Offset); - GL.Attributes.Set_Single (1, Colour); - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 3); - - exception - when others => - Put_Line ("An exceptiom occurred in Render_Triangle."); - raise; - end Render_Triangle; - --- ---------------------------------------------------------------------------- - - procedure Setup_Graphic is - use GL.Objects.Shaders; - use Program_Loader; - begin - Rendering_Program := Program_Loader.Program_From ( - (Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader)) - ); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - GL.Culling.Set_Front_Face (GL.Types.Clockwise); - GL.Culling.Set_Cull_Face (GL.Culling.Back); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - Utilities.Show_Shader_Program_Data (Rendering_Program); - end Setup_Graphic; - --- ---------------------------------------------------------------------------- - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render_Triangle (Glfw.Time); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then - not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; -end Main_Loop; diff --git a/examples/superbible/moving_triangle/src/main_loop.ads b/examples/superbible/moving_triangle/src/main_loop.ads deleted file mode 100644 index e4d8535f..00000000 --- a/examples/superbible/moving_triangle/src/main_loop.ads +++ /dev/null @@ -1,3 +0,0 @@ -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/moving_triangle/src/moving_triangle.adb b/examples/superbible/moving_triangle/src/moving_triangle.adb deleted file mode 100644 index bac2ae5f..00000000 --- a/examples/superbible/moving_triangle/src/moving_triangle.adb +++ /dev/null @@ -1,32 +0,0 @@ --- Program Moving_Triangle --- Author Roger Mc Murtrie --- Created 16 December 2016 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Moving_Triangle is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "OpenGL SuperBible Moving Triangle Example"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Moving_Triangle returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Moving_Triangle."); - Put_Line (Exception_Information (anError)); - -end Moving_Triangle; diff --git a/examples/superbible/moving_triangle/src/shaders/fragment_shader.glsl b/examples/superbible/moving_triangle/src/shaders/fragment_shader.glsl deleted file mode 100644 index 6c97211e..00000000 --- a/examples/superbible/moving_triangle/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#version 410 - - in vec4 vs_colour; - out vec4 fragment_colour; - -void main() -{ - fragment_colour = vs_colour; -} diff --git a/examples/superbible/moving_triangle/src/shaders/vertex_shader.glsl b/examples/superbible/moving_triangle/src/shaders/vertex_shader.glsl deleted file mode 100644 index 03055230..00000000 --- a/examples/superbible/moving_triangle/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,15 +0,0 @@ -#version 410 - - layout (location = 0) in vec4 offset; - layout (location = 1) in vec4 colour; - - out vec4 vs_colour; - -void main() -{ - const vec4 vertices[3] = vec4[3] (vec4( 0.25, -0.25, 0.5, 1.0), - vec4(-0.25, -0.25, 0.5, 1.0), - vec4( 0.25, 0.25, 0.5, 1.0)); - vs_colour = colour; - gl_Position = vertices[gl_VertexID] + offset; -} diff --git a/examples/superbible/rotating_squares/.gitignore b/examples/superbible/rotating_squares/.gitignore deleted file mode 100644 index 54ec0698..00000000 --- a/examples/superbible/rotating_squares/.gitignore +++ /dev/null @@ -1 +0,0 @@ -squares diff --git a/examples/superbible/rotating_squares/rotating_squares.gpr b/examples/superbible/rotating_squares/rotating_squares.gpr deleted file mode 100644 index d3115710..00000000 --- a/examples/superbible/rotating_squares/rotating_squares.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Rotating_Squares is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("squares.adb"); - - package Compiler renames OpenGL.Compiler; - -end Rotating_Squares; - diff --git a/examples/superbible/rotating_squares/src/main_loop.adb b/examples/superbible/rotating_squares/src/main_loop.adb deleted file mode 100644 index 532da3e9..00000000 --- a/examples/superbible/rotating_squares/src/main_loop.adb +++ /dev/null @@ -1,146 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; -with GL.Window; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Grey : constant GL.Types.Colors.Color := (0.8, 0.8, 0.8, 1.0); - Window_Width : constant Glfw.Size := 520; - Window_Height : constant Glfw.Size := 520; - Viewport_Width : constant GL.Types.Size := 500; - Viewport_Height : constant GL.Types.Size := 500; - Position_Buffer : GL.Objects.Buffers.Buffer; - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Projection_Location : GL.Uniforms.Uniform; - Model_View_Location : GL.Uniforms.Uniform; - - Projection_Matrix : GL.Types.Singles.Matrix4; - Set_Up_Error : Exception; - - -- ------------------------------------------------------------------------ - - procedure Render_Square (Window : in out Glfw.Windows.Window) is - use GL.Types; - use GL.Types.Singles; - use Maths.Single_Math_Functions; - - Model_View_Matrix : GL.Types.Singles.Matrix4; - Current_Time : Single; - Time_Factor : Single; - begin - Window.Set_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (10, 10, Viewport_Width, - GL.Types.Int (Viewport_Height)); - Utilities.Clear_Background_Colour (Grey); - - for count in 1 .. 10 loop - Current_Time := Single (Glfw.Time); - Time_Factor := Single (count) + 0.3 * Current_Time; - Model_View_Matrix := - Maths.Rotation_Matrix (Maths.Degree (30.0 * Current_Time), - (0.0, 0.0, 1.0)); - Model_View_Matrix := Maths.Translation_Matrix ((0.0, 0.0, -3.0)) * Model_View_Matrix; - Model_View_Matrix := - Maths.Translation_Matrix ((2.0 * Sin (2.1 * Time_Factor), - 2.0 * Cos (1.7 * Time_Factor), - 2.0 * Sin (1.3 * Time_Factor) * - Cos (1.5 * Time_Factor))) * Model_View_Matrix; - - GL.Objects.Programs.Use_Program (Rendering_Program); - GL.Uniforms.Set_Single (Model_View_Location, Model_View_Matrix); - GL.Uniforms.Set_Single (Projection_Location, Projection_Matrix); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 18); - end loop; - -exception - when others => - Put_Line ("An exception occurred in Render_Square."); - raise; - end Render_Square; - - -- ------------------------------------------------------------------------ - - procedure Set_Up (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use GL; - use GL.Types; - use Program_Loader; - begin - Window.Set_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (10, 10, Viewport_Width, Viewport_Height); - Utilities.Clear_Background_Colour (Grey); - Rendering_Program := - Program_From ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Rendering_Program); - - -- Get locations of shader programs matrix uniforms - Model_View_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "mv_matrix"); - Projection_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "projection_matrix"); - - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Position_Buffer.Initialize_Id; - Array_Buffer.Bind (Position_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertex_Data.Vert_Plane, Static_Draw); - - GL.Attributes.Set_Vertex_Attrib_Pointer (Index => 0, Count => 3, - Kind => GL.Types.Single_Type, - Normalized => False, - Stride => 0, Offset => 0); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - - Maths.Init_Perspective_Transform (50.0, Single (Viewport_Width), - Single (Viewport_Height), - 0.1, 1000.0, Projection_Matrix); - exception - when others => - Put_Line ("An exception occurred in Set_Up."); - raise Set_Up_Error; - end Set_Up; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Set_Up (Main_Window); - while Running loop - Render_Square (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = - Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/superbible/rotating_squares/src/main_loop.ads b/examples/superbible/rotating_squares/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/rotating_squares/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/rotating_squares/src/shaders/fragment_shader.glsl b/examples/superbible/rotating_squares/src/shaders/fragment_shader.glsl deleted file mode 100644 index 64b131b7..00000000 --- a/examples/superbible/rotating_squares/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 410 - - in VS_OUT -{ - vec4 colour; -} fs_in; - - out vec4 fragment_colour; - -void main() -{ - fragment_colour = fs_in.colour; -} diff --git a/examples/superbible/rotating_squares/src/shaders/vertex_shader.glsl b/examples/superbible/rotating_squares/src/shaders/vertex_shader.glsl deleted file mode 100644 index 3f7e9314..00000000 --- a/examples/superbible/rotating_squares/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,17 +0,0 @@ -#version 410 - - in vec4 position; - - out VS_OUT -{ - vec4 colour; -} vs_out; - -uniform mat4 mv_matrix; -uniform mat4 projection_matrix; - -void main() -{ - gl_Position = projection_matrix * mv_matrix * position; - vs_out.colour = 2.0 * position + vec4(0.5, 0.5, 0.5, 0.0); -} diff --git a/examples/superbible/rotating_squares/src/squares.adb b/examples/superbible/rotating_squares/src/squares.adb deleted file mode 100644 index 51ba5eca..00000000 --- a/examples/superbible/rotating_squares/src/squares.adb +++ /dev/null @@ -1,33 +0,0 @@ --- Program Rotating Squares --- Adapted from Spinning Cube listings of --- OpenGL SuperBible Chapter 5, Using Uniforms To Transform Geometry --- and OpenGL SuperBible code spinnycube.cpp --- Author Roger Mc Murtrie --- Created 26 March 2017 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Squares is - Main_Window : Glfw.Windows.Window; -begin - Glfw.Init; - Initialize (Main_Window, "OpenGL Example - Rotating Squares"); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Squares returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Squares."); - Put_Line (Exception_Information (anError)); -end Squares; diff --git a/examples/superbible/rotating_squares/src/vertex_data.ads b/examples/superbible/rotating_squares/src/vertex_data.ads deleted file mode 100644 index 920913eb..00000000 --- a/examples/superbible/rotating_squares/src/vertex_data.ads +++ /dev/null @@ -1,18 +0,0 @@ - -with GL.Types; use GL.Types; - -package Vertex_Data is - - Z_Pos : constant Single := -2.0; - - -- Vertex positions - Vert_Plane : Singles.Vector3_Array (1 .. 6) := - ((-0.2, -0.2, Z_Pos), - (-0.2, 0.2, Z_Pos), - (0.2, 0.2, Z_Pos), - - (0.2, 0.2, Z_Pos), - (0.2, -0.2, Z_Pos), - (-0.2, -0.2, Z_Pos)); - -end Vertex_Data; diff --git a/examples/superbible/simple_texture/.gitignore b/examples/superbible/simple_texture/.gitignore deleted file mode 100644 index 5dcf825b..00000000 --- a/examples/superbible/simple_texture/.gitignore +++ /dev/null @@ -1 +0,0 @@ -simple_texturing diff --git a/examples/superbible/simple_texture/simple_texture.gpr b/examples/superbible/simple_texture/simple_texture.gpr deleted file mode 100644 index bd1b2577..00000000 --- a/examples/superbible/simple_texture/simple_texture.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project simple_texture is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("simple_texturing.adb"); - - package Compiler renames OpenGL.Compiler; - -end simple_texture; - diff --git a/examples/superbible/simple_texture/src/main_loop.adb b/examples/superbible/simple_texture/src/main_loop.adb deleted file mode 100644 index 0a818f64..00000000 --- a/examples/superbible/simple_texture/src/main_loop.adb +++ /dev/null @@ -1,132 +0,0 @@ - -with Interfaces; - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Textures; -with GL.Objects.Textures.Targets; -with GL.Objects.Vertex_Arrays; -with GL.Pixels; -with GL.Types; -with GL.Types.Colors; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Program_Loader; -with Utilities; - --- ------------------------------------------------------------------------ - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - type Data is array (GL.Types.Int range <>) of GL.Types.Single; - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - theTexture : GL.Objects.Textures.Texture; - - -- ------------------------------------------------------------------------ - - procedure Generate_Texture (Texture_Data : in out Data; Width, Height : GL.Types.Int) is - use GL.Types; - use Interfaces; - Col_32 : Unsigned_32; - Row_32 : Unsigned_32; - begin - for Col in 0 .. Height - 1 loop - Col_32 := Unsigned_32 (Col); - for Row in 0 .. Width - 1 loop - Row_32 := Unsigned_32 (Row); - Texture_Data ((Col * Width + Row) * 4 + 1) := - Single ((Row_32 and Col_32) and 16#FF#) / 255.0; - Texture_Data ((Col * Width + Row) * 4 + 2) := - Single ((Row_32 or Col_32) and 16#FF#) / 255.0; - Texture_Data ((Col * Width + Row) * 4 + 3) := - Single ((Row_32 xor Col_32) and 16#FF#) / 255.0; - Texture_Data ((Col * Width + Row) * 4 + 4) := 1.0; - end loop; - end loop; - exception - when others => - Put_Line ("An exceptiom occurred in Generate_Texture."); - raise; - end Generate_Texture; - - -- ------------------------------------------------------------------------ - - procedure Render is - use GL.Types; - - Back_Colour : constant GL.Types.Colors.Color := (0.0, 0.25, 0.0, 1.0); - begin - Utilities.Clear_Background_Colour (Back_Colour); - - GL.Objects.Programs.Use_Program (Rendering_Program); - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 3); - - exception - when others => - Put_Line ("An exceptiom occurred in Render."); - raise; - end Render; - - -- ---------------------------------------------------------------------------- - - procedure Setup is - use GL.Objects.Shaders; - use GL.Objects.Textures.Targets; - use GL.Types; - use Program_Loader; - Width : constant Int := 256; - Height : constant Int := 256; - MIP_Levels : constant Int := 8; - X_Offset : constant Int := 0; - Y_Offset : constant Int := 0; - Texture_Data : aliased Data (1 .. Width * Height * 4); - Image_Data : constant GL.Objects.Textures.Image_Source := - GL.Objects.Textures.Image_Source (Texture_Data'Address); - begin - theTexture.Initialize_Id; - Texture_2D.Bind (theTexture); - Texture_2D.Storage (MIP_Levels, GL.Pixels.RGBA32F, Width, Height); - Generate_Texture (Texture_Data, Width, Height); - - -- Assume the texture is already bound to the GL_TEXTURE_2D target - Texture_2D.Load_Sub_Image_From_Data (0, X_Offset, Y_Offset, Width, Height, - GL.Pixels.RGBA, GL.Pixels.Float, - Image_Data); - Rendering_Program := Program_From - ((Src ("src/shaders/st_vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/st_fragment_shader.glsl", Fragment_Shader))); - - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - Utilities.Show_Shader_Program_Data (Rendering_Program); - exception - when others => - Put_Line ("An exceptiom occurred in Setup."); - raise; - end Setup; - - -- ---------------------------------------------------------------------------- - - use Glfw.Input; - Running : Boolean := True; -begin - Setup; - while Running loop - Render; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when Program_Loader.Shader_Loading_Error => - -- message was already written to stdout - null; -end Main_Loop; diff --git a/examples/superbible/simple_texture/src/main_loop.ads b/examples/superbible/simple_texture/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/simple_texture/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/simple_texture/src/shaders/st_fragment_shader.glsl b/examples/superbible/simple_texture/src/shaders/st_fragment_shader.glsl deleted file mode 100644 index 5544fe0d..00000000 --- a/examples/superbible/simple_texture/src/shaders/st_fragment_shader.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#version 410 core - -uniform sampler2D sampler; -out vec4 colour; - -void main() -{ - colour = texture(sampler, gl_FragCoord.xy / textureSize(sampler, 0)); -} diff --git a/examples/superbible/simple_texture/src/shaders/st_vertex_shader.glsl b/examples/superbible/simple_texture/src/shaders/st_vertex_shader.glsl deleted file mode 100644 index aec826e4..00000000 --- a/examples/superbible/simple_texture/src/shaders/st_vertex_shader.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#version 410 core - -void main() -{ - const vec4 vertices[] = vec4[](vec4(0.75, -0.75, 0.5, 1.0), - vec4(-0.75, -0.75, 0.5, 1.0), - vec4(0.75, 0.75, 0.5, 1.0)); - gl_Position = vertices[gl_VertexID]; -} diff --git a/examples/superbible/simple_texture/src/simple_texturing.adb b/examples/superbible/simple_texture/src/simple_texturing.adb deleted file mode 100644 index 629205db..00000000 --- a/examples/superbible/simple_texture/src/simple_texturing.adb +++ /dev/null @@ -1,30 +0,0 @@ --- Program Simple Texturing --- Author Roger Mc Murtrie --- Created 6 September 2017 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Simple_Texturing is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "OpenGL SuperBible - Simple Texturing"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Simple_Texturing returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Simple_Texturing."); - Put_Line (Exception_Information (anError)); -end Simple_Texturing; diff --git a/examples/superbible/simplest/.gitignore b/examples/superbible/simplest/.gitignore deleted file mode 100644 index deae3392..00000000 --- a/examples/superbible/simplest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -a_dot diff --git a/examples/superbible/simplest/just_a_dot.gpr b/examples/superbible/simplest/just_a_dot.gpr deleted file mode 100644 index b6b52d8f..00000000 --- a/examples/superbible/simplest/just_a_dot.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Just_A_Dot is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("a_dot.adb"); - - package Compiler renames OpenGL.Compiler; - -end Just_A_Dot; - diff --git a/examples/superbible/simplest/src/a_dot.adb b/examples/superbible/simplest/src/a_dot.adb deleted file mode 100644 index bafaa3a1..00000000 --- a/examples/superbible/simplest/src/a_dot.adb +++ /dev/null @@ -1,30 +0,0 @@ --- Program A_Dot --- Author Roger Mc Murtrie --- Created 16 December 2016 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure A_Dot is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "OpenGL SuperBible Centre Square Example"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Application returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Application."); - Put_Line (Exception_Information (anError)); -end A_Dot; diff --git a/examples/superbible/simplest/src/main_loop.adb b/examples/superbible/simplest/src/main_loop.adb deleted file mode 100644 index db79a0dd..00000000 --- a/examples/superbible/simplest/src/main_loop.adb +++ /dev/null @@ -1,83 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Buffers; -with GL.Toggles; -with GL.Objects.Programs; -with GL.Objects.Vertex_Arrays; -with GL.Objects.Shaders; -with GL.Types; -with GL.Types.Colors; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; - --- ------------------------------------------------------------------------ - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - - procedure Render_Dot (Current_Time : Glfw.Seconds) is - use GL.Types; - use Maths.Single_Math_Functions; - - Back_Colour : constant GL.Types.Colors.Color := - (0.5 * (1.0 + Sin (Single (Current_Time))), - 0.5 * (1.0 + Cos (Single (Current_Time))), 0.0, 1.0); - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - - GL.Objects.Programs.Use_Program (Rendering_Program); - GL.Objects.Vertex_Arrays.Draw_Arrays (Points, 0, 1); - - exception - when others => - Put_Line ("An exceptiom occurred in Render_Dot."); - raise; - end Render_Dot; - --- ---------------------------------------------------------------------------- - - procedure Setup_Graphic is - use Program_Loader; - use GL.Objects.Shaders; - begin - Rendering_Program := Program_From ( - (Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader)) - ); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - -- Point size is set in the vertex shader - GL.Toggles.Enable (GL.Toggles.Vertex_Program_Point_Size); - Utilities.Show_Shader_Program_Data (Rendering_Program); - end Setup_Graphic; - --- ---------------------------------------------------------------------------- - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render_Dot (Glfw.Time); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when Program_Loader.Shader_Loading_Error => - -- message was already written to stdout - null; -end Main_Loop; diff --git a/examples/superbible/simplest/src/main_loop.ads b/examples/superbible/simplest/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/simplest/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/simplest/src/shaders/fragment_shader.glsl b/examples/superbible/simplest/src/shaders/fragment_shader.glsl deleted file mode 100644 index 836caefe..00000000 --- a/examples/superbible/simplest/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#version 410 - -out vec4 fragment_colour; - -void main() -{ - fragment_colour = vec4(0.5, 0.0, 0.5, 1.0); -} diff --git a/examples/superbible/simplest/src/shaders/vertex_shader.glsl b/examples/superbible/simplest/src/shaders/vertex_shader.glsl deleted file mode 100644 index 628fb818..00000000 --- a/examples/superbible/simplest/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#version 410 - -void main() -{ - gl_PointSize = 40.0; - gl_Position = vec4(0.0, 0.0, 0.5, 1.0); -} diff --git a/examples/superbible/spinning_cubes/.gitignore b/examples/superbible/spinning_cubes/.gitignore deleted file mode 100644 index 1d32f7d8..00000000 --- a/examples/superbible/spinning_cubes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -spinner diff --git a/examples/superbible/spinning_cubes/spinning_cubes.gpr b/examples/superbible/spinning_cubes/spinning_cubes.gpr deleted file mode 100644 index 317505c2..00000000 --- a/examples/superbible/spinning_cubes/spinning_cubes.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Spinning_Cubes is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("spinner.adb"); - - package Compiler renames OpenGL.Compiler; - -end Spinning_Cubes; - diff --git a/examples/superbible/spinning_cubes/src/main_loop.adb b/examples/superbible/spinning_cubes/src/main_loop.adb deleted file mode 100644 index 9873d9f4..00000000 --- a/examples/superbible/spinning_cubes/src/main_loop.adb +++ /dev/null @@ -1,161 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Culling; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; -with GL.Window; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Grey : constant GL.Types.Colors.Color := (0.8, 0.8, 0.8, 1.0); - Window_Width : constant Glfw.Size := 520; - Window_Height : constant Glfw.Size := 520; - Viewport_Width : constant GL.Types.Size := 500; - Viewport_Height : constant GL.Types.Size := 500; - Position_Buffer : GL.Objects.Buffers.Buffer; - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Projection_Location : GL.Uniforms.Uniform; - Model_View_Location : GL.Uniforms.Uniform; - - Projection_Matrix : GL.Types.Singles.Matrix4; - - Set_Up_Error : Exception; - - -- ------------------------------------------------------------------------ - - procedure Render_Cubes (Window : in out Glfw.Windows.Window) is - use GL.Types; - use GL.Types.Singles; - use Maths.Single_Math_Functions; - - Model_View_Matrix : GL.Types.Singles.Matrix4; - Current_Time : Single; - Time_Factor : Single; - begin - Window.Set_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (10, 10, GL.Types.Int (Viewport_Width), - GL.Types.Int (Viewport_Height)); - Utilities.Clear_Background_Colour_And_Depth (Grey); - for count in 0 .. 10 loop - Current_Time := Single (Glfw.Time); - Time_Factor := Single (count) + 0.3 * Current_Time; - Model_View_Matrix := - Maths.Rotation_Matrix (Maths.Degree (45.0 * Current_Time), - (0.0, 1.0, 0.0)) * - Maths.Rotation_Matrix (Maths.Degree (21.0 * Current_Time), - (1.0, 0.0, 0.0)); - Model_View_Matrix := - Maths.Translation_Matrix ((0.0, 0.0, -6.0)) * Model_View_Matrix; - Model_View_Matrix := - Maths.Translation_Matrix ((2.0 * Sin (2.3 * Time_Factor), - 2.0 * Cos (1.7 * Time_Factor), - 2.0 * Sin (1.1 * Time_Factor) - * Cos (1.5 * Time_Factor))) * Model_View_Matrix; - - GL.Objects.Programs.Use_Program (Rendering_Program); - GL.Uniforms.Set_Single (Projection_Location, Projection_Matrix); - GL.Uniforms.Set_Single (Model_View_Location, Model_View_Matrix); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 36); - end loop; - -exception - when others => - Put_Line ("An exception occurred in Render_Cubes."); - raise; - end Render_Cubes; - - -- ------------------------------------------------------------------------ - - procedure Set_Up (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use GL; - use GL.Types; - use Program_Loader; - - begin - Window.Set_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (10, 10, Viewport_Width, Viewport_Height); - Utilities.Clear_Background_Colour_And_Depth (Grey); - - Rendering_Program := - Program_From ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Rendering_Program); - - -- Get locations of shader programs matrix uniforms - Model_View_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "mv_matrix"); - Projection_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "projection_matrix"); - - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Position_Buffer.Initialize_Id; - Array_Buffer.Bind (Position_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertex_Data.Vertices, Static_Draw); - - GL.Attributes.Set_Vertex_Attrib_Pointer (Index => 0, Count => 3, - Kind => GL.Types.Single_Type, - Normalized => False, - Stride => 0, Offset => 0); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - Maths.Init_Perspective_Transform (Maths.Degree (50.0), - Single (Viewport_Width), Single (Viewport_Height), - 0.1, 1000.0, Projection_Matrix); - - GL.Toggles.Enable (GL.Toggles.Cull_Face); - GL.Culling.Set_Front_Face (GL.Types.Counter_Clockwise); - -- Depth_Function specifies the function used to compare each - -- incoming pixel depth value with the depth value present in - -- the depth buffer. - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.LEqual); - - exception - when others => - Put_Line ("An exception occurred in Set_Up."); - raise Set_Up_Error; - end Set_Up; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Set_Up (Main_Window); - while Running loop - Render_Cubes (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = - Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/superbible/spinning_cubes/src/main_loop.ads b/examples/superbible/spinning_cubes/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/spinning_cubes/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/spinning_cubes/src/shaders/fragment_shader.glsl b/examples/superbible/spinning_cubes/src/shaders/fragment_shader.glsl deleted file mode 100644 index 64b131b7..00000000 --- a/examples/superbible/spinning_cubes/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 410 - - in VS_OUT -{ - vec4 colour; -} fs_in; - - out vec4 fragment_colour; - -void main() -{ - fragment_colour = fs_in.colour; -} diff --git a/examples/superbible/spinning_cubes/src/shaders/vertex_shader.glsl b/examples/superbible/spinning_cubes/src/shaders/vertex_shader.glsl deleted file mode 100644 index 3f7e9314..00000000 --- a/examples/superbible/spinning_cubes/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,17 +0,0 @@ -#version 410 - - in vec4 position; - - out VS_OUT -{ - vec4 colour; -} vs_out; - -uniform mat4 mv_matrix; -uniform mat4 projection_matrix; - -void main() -{ - gl_Position = projection_matrix * mv_matrix * position; - vs_out.colour = 2.0 * position + vec4(0.5, 0.5, 0.5, 0.0); -} diff --git a/examples/superbible/spinning_cubes/src/spinner.adb b/examples/superbible/spinning_cubes/src/spinner.adb deleted file mode 100644 index a3259c39..00000000 --- a/examples/superbible/spinning_cubes/src/spinner.adb +++ /dev/null @@ -1,31 +0,0 @@ --- Program Spinning Cubes --- Based on OpenGL SuperBible spinnycube.cpp --- Author Roger Mc Murtrie --- Created 12 February 2017 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Spinner is - Main_Window : Glfw.Windows.Window; -begin - Glfw.Init; - Initialize (Main_Window, "OpenGL SuperBible Example - Spinning Cubes"); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Spinner returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Spinner."); - Put_Line (Exception_Information (anError)); -end Spinner; diff --git a/examples/superbible/spinning_cubes/src/vertex_data.ads b/examples/superbible/spinning_cubes/src/vertex_data.ads deleted file mode 100644 index 78d532c6..00000000 --- a/examples/superbible/spinning_cubes/src/vertex_data.ads +++ /dev/null @@ -1,65 +0,0 @@ - -with GL.Types; use GL.Types; - -package Vertex_Data is - - -- Vertex positions - Vertices : constant Singles.Vector3_Array (1 .. 36) := - ((-0.25, -0.25, 0.25), - (-0.25, -0.25, -0.25), - (0.25, -0.25, -0.25), - - (0.25, -0.25, -0.25), - (0.25, -0.25, 0.25), - (-0.25, -0.25, 0.25), - - (0.25, -0.25, -0.25), - (0.25, 0.25, -0.25), - (0.25, -0.25, 0.25), - - (0.25, 0.25, -0.25), - (0.25, 0.25, 0.25), - (0.25, -0.25, 0.25), - - (0.25, 0.25, -0.25), - (-0.25, 0.25, -0.25), - (0.25, 0.25, 0.25), - - (-0.25, 0.25, -0.25), - (-0.25, 0.25, 0.25), - (0.25, 0.25, 0.25), - - (-0.25, 0.25, -0.25), - (-0.25, -0.25, -0.25), - (-0.25, 0.25, 0.25), - - (-0.25, -0.25, -0.25), - (-0.25, -0.25, 0.25), - (-0.25, 0.25, 0.25), - - (-0.25, 0.25, -0.25), - (0.25, 0.25, -0.25), - (0.25, -0.25, -0.25), - - (0.25, -0.25, -0.25), - (-0.25, -0.25, -0.25), - (-0.25, 0.25, -0.25), - - (-0.25, -0.25, 0.25), - (0.25, -0.25, 0.25), - (0.25, 0.25, 0.25), - - (0.25, 0.25, 0.25), - (-0.25, 0.25, 0.25), - (-0.25, -0.25, 0.25)); - - Square_Vertices : Singles.Vector3_Array (1 .. 6) := - ((-0.25, -0.25, 0.25), - (-0.25, -0.25, -0.25), - (0.25, -0.25, -0.25), - - (0.25, -0.25, -0.25), - (0.25, -0.25, 0.25), - (-0.25, -0.25, 0.25)); - -end Vertex_Data; diff --git a/examples/superbible/tess/.gitignore b/examples/superbible/tess/.gitignore deleted file mode 100644 index 2e686e86..00000000 --- a/examples/superbible/tess/.gitignore +++ /dev/null @@ -1 +0,0 @@ -simple_tessellation diff --git a/examples/superbible/tess/simple_tessellation.gpr b/examples/superbible/tess/simple_tessellation.gpr deleted file mode 100644 index b1d039f3..00000000 --- a/examples/superbible/tess/simple_tessellation.gpr +++ /dev/null @@ -1,14 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Simple_Tessellation is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("simple_tessellation.adb"); - - package Compiler renames OpenGL.Compiler; - -end Simple_Tessellation; diff --git a/examples/superbible/tess/src/main_loop.adb b/examples/superbible/tess/src/main_loop.adb deleted file mode 100644 index b66726ec..00000000 --- a/examples/superbible/tess/src/main_loop.adb +++ /dev/null @@ -1,90 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Rasterization; -with GL.Toggles; -with GL.Types; -with GL.Types.Colors; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Program_Loader; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - - -- ------------------------------------------------------------------------ - - procedure Render_Tesselation is - Back_Colour : constant GL.Types.Colors.Color := (0.0, 0.75, 0.0, 1.0); - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - - GL.Objects.Programs.Use_Program (Rendering_Program); - GL.Objects.Vertex_Arrays.Draw_Arrays (GL.Types.Patches, 0, 3); - - exception - when others => - Put_Line ("An exceptiom occurred in Render_Tesselation."); - raise; - end Render_Tesselation; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic is - use GL.Objects.Shaders; - begin - Rendering_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/vertex_shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/tesselation_control_shader.glsl", - Tess_Control_Shader), - Program_Loader.Src ("src/shaders/tesselation_evaluation_shader.glsl", - Tess_Evaluation_Shader), - Program_Loader.Src ("src/shaders/fragment_shader.glsl", - Fragment_Shader))); - - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - GL.Rasterization.Set_Polygon_Mode (GL.Rasterization.Line); - - Utilities.Show_Shader_Program_Data (Rendering_Program); - - exception - when others => - Put_Line ("An exceptiom occurred in Setup_Graphic."); - raise; - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render_Tesselation; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = - Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exceptiom occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/superbible/tess/src/main_loop.ads b/examples/superbible/tess/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/tess/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/tess/src/shaders/fragment_shader.glsl b/examples/superbible/tess/src/shaders/fragment_shader.glsl deleted file mode 100644 index 67f7effc..00000000 --- a/examples/superbible/tess/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#version 410 - - out vec4 colour; - -void main() -{ - colour = vec4(1.0, 0.0, 0.0, 1.0); -} diff --git a/examples/superbible/tess/src/shaders/tesselation_control_shader.glsl b/examples/superbible/tess/src/shaders/tesselation_control_shader.glsl deleted file mode 100644 index 7b88c1cf..00000000 --- a/examples/superbible/tess/src/shaders/tesselation_control_shader.glsl +++ /dev/null @@ -1,15 +0,0 @@ -#version 410 - -layout (vertices = 3) out; - -void main() -{ - if (gl_InvocationID == 0) - { - gl_TessLevelInner[0] = 5.0; - gl_TessLevelOuter[0] = 5.0; - gl_TessLevelOuter[1] = 5.0; - gl_TessLevelOuter[2] = 5.0; - } - gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; -} diff --git a/examples/superbible/tess/src/shaders/tesselation_evaluation_shader.glsl b/examples/superbible/tess/src/shaders/tesselation_evaluation_shader.glsl deleted file mode 100644 index 6df21ebf..00000000 --- a/examples/superbible/tess/src/shaders/tesselation_evaluation_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - -layout (triangles, equal_spacing, cw) in; - -void main() -{ - gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position + - gl_TessCoord.y * gl_in[1].gl_Position + - gl_TessCoord.z * gl_in[2].gl_Position); -} diff --git a/examples/superbible/tess/src/shaders/vertex_shader.glsl b/examples/superbible/tess/src/shaders/vertex_shader.glsl deleted file mode 100644 index b32cee60..00000000 --- a/examples/superbible/tess/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - -void main() -{ - const vec4 vertices[] = vec4[] (vec4( 0.25, -0.25, 0.5, 1.0), - vec4(-0.25, -0.25, 0.5, 1.0), - vec4( 0.25, 0.25, 0.5, 1.0)); - - gl_Position = vertices[gl_VertexID]; -} diff --git a/examples/superbible/tess/src/simple_tessellation.adb b/examples/superbible/tess/src/simple_tessellation.adb deleted file mode 100644 index 447e39af..00000000 --- a/examples/superbible/tess/src/simple_tessellation.adb +++ /dev/null @@ -1,32 +0,0 @@ --- Program Simple_Tessalation --- Author Roger Mc Murtrie --- Created 16 December 2016 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Simple_Tessellation is - Main_Window : aliased Glfw.Windows.Window; - Window_Title : constant String - := "OpenGL SuperBible Simple Tessellation Example"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Simple_Tessellation returned constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Simple_Tessellation."); - Put_Line (Exception_Information (anError)); -end Simple_Tessellation; diff --git a/examples/superbible/tessellation_with_geometry/.gitignore b/examples/superbible/tessellation_with_geometry/.gitignore deleted file mode 100644 index 4c61f199..00000000 --- a/examples/superbible/tessellation_with_geometry/.gitignore +++ /dev/null @@ -1 +0,0 @@ -simple_geometry diff --git a/examples/superbible/tessellation_with_geometry/simple_tessellation_with_geometry.gpr b/examples/superbible/tessellation_with_geometry/simple_tessellation_with_geometry.gpr deleted file mode 100644 index 9aeaf280..00000000 --- a/examples/superbible/tessellation_with_geometry/simple_tessellation_with_geometry.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Simple_Tessellation_With_Geometry is - - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("simple_geometry.adb"); - - package Compiler renames OpenGL.Compiler; - -end Simple_Tessellation_With_Geometry; - diff --git a/examples/superbible/tessellation_with_geometry/src/main_loop.adb b/examples/superbible/tessellation_with_geometry/src/main_loop.adb deleted file mode 100644 index 013cf013..00000000 --- a/examples/superbible/tessellation_with_geometry/src/main_loop.adb +++ /dev/null @@ -1,83 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Rasterization; -with GL.Toggles; -with GL.Types; use GL.Types; -with GL.Types.Colors; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Program_Loader; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - - -- ------------------------------------------------------------------------ - - procedure Render_Tessellation_Geometry is - Back_Colour : constant GL.Types.Colors.Color := (0.0, 0.75, 0.0, 1.0); - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - - GL.Objects.Programs.Use_Program (Rendering_Program); - GL.Objects.Vertex_Arrays.Draw_Arrays (Patches, 0, 3); - - exception - when others => - Put_Line ("An exceptiom occurred in Render_Tessellation_Geometry."); - raise; - end Render_Tessellation_Geometry; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic is - use GL.Objects.Shaders; - begin - Rendering_Program := Program_Loader.Program_From - ((Program_Loader.Src ("src/shaders/vertex_shader.glsl", - Vertex_Shader), - Program_Loader.Src ("src/shaders/geometry_shader.glsl", - Geometry_Shader), - Program_Loader.Src ("src/shaders/tessellation_control_shader.glsl", - Tess_Control_Shader), - Program_Loader.Src ("src/shaders/tessellation_evaluation_shader.glsl", - Tess_Evaluation_Shader), - Program_Loader.Src ("src/shaders/fragment_shader.glsl", - Fragment_Shader))); - - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - GL.Rasterization.Set_Polygon_Mode (GL.Rasterization.Line); - GL.Rasterization.Set_Point_Size (5.0); - - Utilities.Show_Shader_Program_Data (Rendering_Program); - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render_Tessellation_Geometry; - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then not - (Main_Window.Key_State (Glfw.Input.Keys.Escape) = - Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; -end Main_Loop; diff --git a/examples/superbible/tessellation_with_geometry/src/main_loop.ads b/examples/superbible/tessellation_with_geometry/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/tessellation_with_geometry/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/tessellation_with_geometry/src/shaders/fragment_shader.glsl b/examples/superbible/tessellation_with_geometry/src/shaders/fragment_shader.glsl deleted file mode 100644 index 67f7effc..00000000 --- a/examples/superbible/tessellation_with_geometry/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#version 410 - - out vec4 colour; - -void main() -{ - colour = vec4(1.0, 0.0, 0.0, 1.0); -} diff --git a/examples/superbible/tessellation_with_geometry/src/shaders/geometry_shader.glsl b/examples/superbible/tessellation_with_geometry/src/shaders/geometry_shader.glsl deleted file mode 100644 index b4edeb72..00000000 --- a/examples/superbible/tessellation_with_geometry/src/shaders/geometry_shader.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 410 -layout (triangles) in; -layout (points, max_vertices = 3) out; - -void main() -{ - int index; - -for (index = 0; index < gl_in.length(); index++) - { - gl_Position = gl_in[index].gl_Position; - EmitVertex(); - } -} diff --git a/examples/superbible/tessellation_with_geometry/src/shaders/tessellation_control_shader.glsl b/examples/superbible/tessellation_with_geometry/src/shaders/tessellation_control_shader.glsl deleted file mode 100644 index 7b88c1cf..00000000 --- a/examples/superbible/tessellation_with_geometry/src/shaders/tessellation_control_shader.glsl +++ /dev/null @@ -1,15 +0,0 @@ -#version 410 - -layout (vertices = 3) out; - -void main() -{ - if (gl_InvocationID == 0) - { - gl_TessLevelInner[0] = 5.0; - gl_TessLevelOuter[0] = 5.0; - gl_TessLevelOuter[1] = 5.0; - gl_TessLevelOuter[2] = 5.0; - } - gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; -} diff --git a/examples/superbible/tessellation_with_geometry/src/shaders/tessellation_evaluation_shader.glsl b/examples/superbible/tessellation_with_geometry/src/shaders/tessellation_evaluation_shader.glsl deleted file mode 100644 index 6df21ebf..00000000 --- a/examples/superbible/tessellation_with_geometry/src/shaders/tessellation_evaluation_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - -layout (triangles, equal_spacing, cw) in; - -void main() -{ - gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position + - gl_TessCoord.y * gl_in[1].gl_Position + - gl_TessCoord.z * gl_in[2].gl_Position); -} diff --git a/examples/superbible/tessellation_with_geometry/src/shaders/vertex_shader.glsl b/examples/superbible/tessellation_with_geometry/src/shaders/vertex_shader.glsl deleted file mode 100644 index b32cee60..00000000 --- a/examples/superbible/tessellation_with_geometry/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - -void main() -{ - const vec4 vertices[] = vec4[] (vec4( 0.25, -0.25, 0.5, 1.0), - vec4(-0.25, -0.25, 0.5, 1.0), - vec4( 0.25, 0.25, 0.5, 1.0)); - - gl_Position = vertices[gl_VertexID]; -} diff --git a/examples/superbible/tessellation_with_geometry/src/simple_geometry.adb b/examples/superbible/tessellation_with_geometry/src/simple_geometry.adb deleted file mode 100644 index 7c6ab6e5..00000000 --- a/examples/superbible/tessellation_with_geometry/src/simple_geometry.adb +++ /dev/null @@ -1,31 +0,0 @@ --- Program Simple_Geometry (including tesselation) --- Author Roger Mc Murtrie --- Created 16 December 2016 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; - -with Initialize; -with Main_Loop; -with Glfw.Windows; - -procedure Simple_Geometry is - Main_Window : Glfw.Windows.Window; - Window_Title : constant String := "OpenGL SuperBible Simple Tesselation Example"; -begin - Glfw.Init; - Initialize (Main_Window, Window_Title); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Simple_Geometry returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Simple_Geometry."); - Put_Line (Exception_Information (anError)); -end Simple_Geometry; diff --git a/examples/superbible/tumbling_squares/.gitignore b/examples/superbible/tumbling_squares/.gitignore deleted file mode 100644 index 54ec0698..00000000 --- a/examples/superbible/tumbling_squares/.gitignore +++ /dev/null @@ -1 +0,0 @@ -squares diff --git a/examples/superbible/tumbling_squares/src/main_loop.adb b/examples/superbible/tumbling_squares/src/main_loop.adb deleted file mode 100644 index b0e59b98..00000000 --- a/examples/superbible/tumbling_squares/src/main_loop.adb +++ /dev/null @@ -1,149 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Objects.Buffers; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Types; -with GL.Types.Colors; -with GL.Uniforms; -with GL.Window; - -with Glfw; -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; -with Vertex_Data; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Grey : constant GL.Types.Colors.Color := (0.8, 0.8, 0.8, 1.0); - - Window_Width : constant Glfw.Size := 520; - Window_Height : constant Glfw.Size := 520; - Viewport_Width : constant GL.Types.Size := 500; - Viewport_Height : constant GL.Types.Size := 500; - Position_Buffer : GL.Objects.Buffers.Buffer; - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - Projection_Location : GL.Uniforms.Uniform; - Model_View_Location : GL.Uniforms.Uniform; - - Projection_Matrix : GL.Types.Singles.Matrix4; - Set_Up_Error : Exception; - - -- ------------------------------------------------------------------------ - - procedure Render_Square (Window : in out Glfw.Windows.Window) is - use GL.Types; - use GL.Types.Singles; - use Maths.Single_Math_Functions; - - Model_View_Matrix : Singles.Matrix4; - Current_Time : Single; - Time_Factor : Single; - begin - Window.Set_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (10, 10, GL.Types.Int (Viewport_Width), - GL.Types.Int (Viewport_Height)); - Utilities.Clear_Background_Colour (Grey); - - for count in 1 .. 20 loop - Current_Time := Single (Glfw.Time); - Time_Factor := Single (count) + 0.3 * Current_Time; - Model_View_Matrix := - Maths.Rotation_Matrix (Maths.Degree (21.0 * Current_Time), - (1.0, 0.0, 0.0)) * - Maths.Rotation_Matrix (Maths.Degree (45.0 * Current_Time), - (0.0, 1.0, 0.0)); - Model_View_Matrix := - Maths.Translation_Matrix ((0.0, 0.0, -6.0)) * Model_View_Matrix; - Model_View_Matrix := - Maths.Translation_Matrix ((2.0 * Sin (2.3 * Time_Factor), - 2.0 * Cos (1.7 * Time_Factor), - 2.0 * Sin (1.3 * Time_Factor) * - Cos (1.1 * Time_Factor))) * Model_View_Matrix; - GL.Objects.Programs.Use_Program (Rendering_Program); - GL.Uniforms.Set_Single (Model_View_Location, Model_View_Matrix); - GL.Uniforms.Set_Single (Projection_Location, Projection_Matrix); - - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 18); - end loop; - - exception - when others => - Put_Line ("An exception occurred in Render_Square."); - raise; - end Render_Square; - - -- ------------------------------------------------------------------------ - - procedure Set_Up (Window : in out Glfw.Windows.Window) is - use GL.Objects.Buffers; - use GL.Objects.Shaders; - use GL; - use GL.Types; - use Program_Loader; - begin - Window.Set_Size (Window_Width, Window_Height); - GL.Window.Set_Viewport (10, 10, Viewport_Width, Viewport_Height); - Utilities.Clear_Background_Colour (Grey); - Rendering_Program := - Program_From ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - Utilities.Show_Shader_Program_Data (Rendering_Program); - - -- Get locations of shader programs matrix uniforms - Model_View_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "mv_matrix"); - Projection_Location := - GL.Objects.Programs.Uniform_Location (Rendering_Program, "projection_matrix"); - - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Position_Buffer.Initialize_Id; - Array_Buffer.Bind (Position_Buffer); - Utilities.Load_Vertex_Buffer (Array_Buffer, Vertex_Data.Vert_Plane, Static_Draw); - - GL.Attributes.Set_Vertex_Attrib_Pointer (Index => 0, Count => 3, - Kind => GL.Types.Single_Type, - Normalized => False, - Stride => 0, Offset => 0); - GL.Attributes.Enable_Vertex_Attrib_Array (0); - - Maths.Init_Perspective_Transform (50.0, Single (Viewport_Width), - Single (Viewport_Height), - 0.1, 1000.0, Projection_Matrix); - exception - when others => - Put_Line ("An exception occurred in Set_Up."); - raise Set_Up_Error; - end Set_Up; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Set_Up (Main_Window); - while Running loop - Render_Square (Main_Window); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = - Glfw.Input.Pressed); - Running := Running and not Main_Window.Should_Close; - end loop; - -exception - when others => - Put_Line ("An exception occurred in Main_Loop."); - raise; -end Main_Loop; diff --git a/examples/superbible/tumbling_squares/src/main_loop.ads b/examples/superbible/tumbling_squares/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/tumbling_squares/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/tumbling_squares/src/shaders/fragment_shader.glsl b/examples/superbible/tumbling_squares/src/shaders/fragment_shader.glsl deleted file mode 100644 index 64b131b7..00000000 --- a/examples/superbible/tumbling_squares/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 410 - - in VS_OUT -{ - vec4 colour; -} fs_in; - - out vec4 fragment_colour; - -void main() -{ - fragment_colour = fs_in.colour; -} diff --git a/examples/superbible/tumbling_squares/src/shaders/vertex_shader.glsl b/examples/superbible/tumbling_squares/src/shaders/vertex_shader.glsl deleted file mode 100644 index 3f7e9314..00000000 --- a/examples/superbible/tumbling_squares/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,17 +0,0 @@ -#version 410 - - in vec4 position; - - out VS_OUT -{ - vec4 colour; -} vs_out; - -uniform mat4 mv_matrix; -uniform mat4 projection_matrix; - -void main() -{ - gl_Position = projection_matrix * mv_matrix * position; - vs_out.colour = 2.0 * position + vec4(0.5, 0.5, 0.5, 0.0); -} diff --git a/examples/superbible/tumbling_squares/src/squares.adb b/examples/superbible/tumbling_squares/src/squares.adb deleted file mode 100644 index 735731f0..00000000 --- a/examples/superbible/tumbling_squares/src/squares.adb +++ /dev/null @@ -1,33 +0,0 @@ --- Program Tumbling Squares --- Adapted from Spinning Cube listings of --- OpenGL SuperBible Chapter 5, Using Uniforms To Transform Geometry --- and OpenGL SuperBible code spinnycube.cpp --- Author Roger Mc Murtrie --- Created 26 March 2017 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Squares is - Main_Window : Glfw.Windows.Window; -begin - Glfw.Init; - Initialize (Main_Window, "OpenGL Example - Tumbling Squares"); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Squares returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exception occurred in Squares."); - Put_Line (Exception_Information (anError)); -end Squares; diff --git a/examples/superbible/tumbling_squares/src/vertex_data.ads b/examples/superbible/tumbling_squares/src/vertex_data.ads deleted file mode 100644 index 9c603fb4..00000000 --- a/examples/superbible/tumbling_squares/src/vertex_data.ads +++ /dev/null @@ -1,18 +0,0 @@ - -with GL.Types; use GL.Types; - -package Vertex_Data is - - Z_Pos : constant Single := 0.0; - - -- Vertex positions - Vert_Plane : Singles.Vector3_Array (1 .. 6) := - ((-0.2, -0.2, Z_Pos), - (-0.2, 0.2, Z_Pos), - (0.2, 0.2, Z_Pos), - - (0.2, 0.2, Z_Pos), - (0.2, -0.2, Z_Pos), - (-0.2, -0.2, Z_Pos)); - -end Vertex_Data; diff --git a/examples/superbible/tumbling_squares/tumbling_squares.gpr b/examples/superbible/tumbling_squares/tumbling_squares.gpr deleted file mode 100644 index c48c750b..00000000 --- a/examples/superbible/tumbling_squares/tumbling_squares.gpr +++ /dev/null @@ -1,13 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Tumbling_Squares is - for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("squares.adb"); - - package Compiler renames OpenGL.Compiler; - -end Tumbling_Squares; diff --git a/examples/superbible/vertex_colouring/.gitignore b/examples/superbible/vertex_colouring/.gitignore deleted file mode 100644 index 39ae5dc5..00000000 --- a/examples/superbible/vertex_colouring/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -colour_vertices - diff --git a/examples/superbible/vertex_colouring/src/colour_vertices.adb b/examples/superbible/vertex_colouring/src/colour_vertices.adb deleted file mode 100644 index 599589be..00000000 --- a/examples/superbible/vertex_colouring/src/colour_vertices.adb +++ /dev/null @@ -1,30 +0,0 @@ --- Program Colour Vertices --- Author Roger Mc Murtrie --- Created 17 December 2016 - -with Ada.Exceptions; use Ada.Exceptions; -with Ada.Text_IO; use Ada.Text_IO; - -with Glfw; -with Glfw.Windows; - -with Initialize; -with Main_Loop; - -procedure Colour_Vertices is - Main_Window : aliased Glfw.Windows.Window; -begin - Glfw.Init; - Initialize (Main_Window, "OpenGL SuperBible Vertex Colouring Example"); - Main_Loop (Main_Window); - Glfw.Shutdown; - -exception - when anError : Constraint_Error => - Put ("Colour_Vertices returned a constraint error: "); - Put_Line (Exception_Information (anError)); - - when anError : others => - Put_Line ("An exceptiom occurred in Colour_Vertices."); - Put_Line (Exception_Information (anError)); -end Colour_Vertices; diff --git a/examples/superbible/vertex_colouring/src/main_loop.adb b/examples/superbible/vertex_colouring/src/main_loop.adb deleted file mode 100644 index 67c0cf69..00000000 --- a/examples/superbible/vertex_colouring/src/main_loop.adb +++ /dev/null @@ -1,84 +0,0 @@ - -with Ada.Text_IO; use Ada.Text_IO; - -with GL.Attributes; -with GL.Buffers; -with GL.Culling; -with GL.Objects.Programs; -with GL.Objects.Shaders; -with GL.Objects.Vertex_Arrays; -with GL.Toggles; -with GL.Types; use GL.Types; -with GL.Types.Colors; - -with Glfw.Input; -with Glfw.Input.Keys; -with Glfw.Windows; -with Glfw.Windows.Context; - -with Maths; -with Program_Loader; -with Utilities; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is - - Rendering_Program : GL.Objects.Programs.Program; - Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; - - -- ------------------------------------------------------------------------ - - procedure Render_Triangle (Current_Time : Glfw.Seconds) is - use Maths.Single_Math_Functions; - Now : constant Single := Single (Current_Time); - Back_Colour : constant GL.Types.Colors.Color := - (0.5 * (1.0 + Sin (Now)), 0.5 * (1.0 + Cos (Now)), 0.0, 1.0); - Offset : constant GL.Types.Singles.Vector4 := - (0.5 * Sin (Now), 0.5 * Cos (Now), 0.0, 0.0); - begin - Utilities.Clear_Background_Colour_And_Depth (Back_Colour); - - GL.Objects.Programs.Use_Program (Rendering_Program); - - GL.Attributes.Set_Single (0, Offset); - GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 3); - exception - when others => Put_Line ("Exception in Render_Triangle"); - raise; - end Render_Triangle; - - -- ------------------------------------------------------------------------ - - procedure Setup_Graphic is - use Program_Loader; - use GL.Objects.Shaders; - begin - Rendering_Program := Program_From - ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader), - Src ("src/shaders/fragment_shader.glsl", Fragment_Shader))); - GL.Toggles.Enable (GL.Toggles.Depth_Test); - GL.Toggles.Enable (GL.Toggles.Cull_Face); - GL.Culling.Set_Front_Face (GL.Types.Clockwise); - GL.Culling.Set_Cull_Face (GL.Culling.Back); - GL.Buffers.Set_Depth_Function (GL.Types.Less); - - Vertex_Array.Initialize_Id; - Vertex_Array.Bind; - - Utilities.Show_Shader_Program_Data (Rendering_Program); - end Setup_Graphic; - - -- ------------------------------------------------------------------------ - - use Glfw.Input; - Running : Boolean := True; -begin - Setup_Graphic; - while Running loop - Render_Triangle (Glfw.Time); - Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); - Glfw.Input.Poll_Events; - Running := Running and then not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); - Running := Running and then not Main_Window.Should_Close; - end loop; - -end Main_Loop; diff --git a/examples/superbible/vertex_colouring/src/main_loop.ads b/examples/superbible/vertex_colouring/src/main_loop.ads deleted file mode 100644 index cc564482..00000000 --- a/examples/superbible/vertex_colouring/src/main_loop.ads +++ /dev/null @@ -1,4 +0,0 @@ - -with Glfw.Windows; - -procedure Main_Loop (Main_Window : in out Glfw.Windows.Window); diff --git a/examples/superbible/vertex_colouring/src/shaders/fragment_shader.glsl b/examples/superbible/vertex_colouring/src/shaders/fragment_shader.glsl deleted file mode 100644 index 07aa7cd8..00000000 --- a/examples/superbible/vertex_colouring/src/shaders/fragment_shader.glsl +++ /dev/null @@ -1,10 +0,0 @@ -#version 410 - - in vec4 vs_colour; - -out vec4 fragment_colour; - -void main() -{ - fragment_colour = vs_colour; -} diff --git a/examples/superbible/vertex_colouring/src/shaders/vertex_shader.glsl b/examples/superbible/vertex_colouring/src/shaders/vertex_shader.glsl deleted file mode 100644 index 702b8168..00000000 --- a/examples/superbible/vertex_colouring/src/shaders/vertex_shader.glsl +++ /dev/null @@ -1,17 +0,0 @@ -#version 410 - - layout (location = 0) in vec4 offset; - - out vec4 vs_colour; - -void main() -{ - const vec4 vertices[3] = vec4[3] (vec4( 0.25, -0.25, 0.5, 1.0), - vec4(-0.25, -0.25, 0.5, 1.0), - vec4( 0.25, 0.25, 0.5, 1.0)); - const vec4 colours[] = vec4[3] (vec4(1.0, 0.0, 0.0, 1.0), - vec4(0.0, 1.0, 0.0, 1.0), - vec4(0.0, 0.0, 1.0, 1.0)); - vs_colour = colours[gl_VertexID]; - gl_Position = vertices[gl_VertexID] + offset; -} diff --git a/examples/superbible/vertex_colouring/vertex_colouring.gpr b/examples/superbible/vertex_colouring/vertex_colouring.gpr deleted file mode 100644 index 3c3735e1..00000000 --- a/examples/superbible/vertex_colouring/vertex_colouring.gpr +++ /dev/null @@ -1,15 +0,0 @@ -with "../../common/common.gpr"; -with "../../../opengl.gpr"; -limited with "../../../opengl-glfw.gpr"; - -project Vertex_Colouring is - -for Source_Dirs use ("src"); - for Object_Dir use "obj/"; - for Exec_Dir use "."; - for Main use ("colour_vertices.adb"); - - package Compiler renames OpenGL.Compiler; - -end Vertex_Colouring; - diff --git a/install/OpenGLAda.wix b/install/OpenGLAda.wix index bad416a2..b2a5aa5c 100644 --- a/install/OpenGLAda.wix +++ b/install/OpenGLAda.wix @@ -9,16 +9,17 @@ InstallerVersion="100" Languages="1033" Compressed="yes" SummaryCodepage="1252" /> - + - + + @@ -29,9 +30,10 @@ - + + @@ -41,8 +43,8 @@ - - + + @@ -50,12 +52,15 @@ + + + - - - - - + + + + + + + C, Entity => Create_Custom_Glyph, - External_Name => "ftglCreateCustomGlyph"); - - procedure Destroy_Glyph (Glyph : System.Address); - pragma Import (Convention => C, Entity => Destroy_Glyph, - External_Name => "ftglDestroyGlyph"); - - procedure Render_Glyph (Glyph : System.Address; - Pen_X, Pen_Y : GL.Types.Double; - Mode : Render_Mode; - New_X, New_Y : out GL.Types.Double); - pragma Import (Convention => C, Entity => Render_Glyph, - External_Name => "ftglRenderGlyph"); - - function Get_Glyph_Advance (Glyph : System.Address) return GL.Types.Single; - pragma Import (Convention => C, Entity => Get_Glyph_Advance, - External_Name => "ftglGetGlyphAdvance"); - - procedure Get_Glyph_BBox (Glyph : System.Address; Bounds : out Bounding_Box); - pragma Import (Convention => C, Entity => Get_Glyph_BBox, - External_Name => "ftglGetGlyphBBox"); - - function Get_Glyph_Error (Glyph : System.Address) return Errors.FT_Error; - pragma Import (Convention => C, Entity => Get_Glyph_Error, - External_Name => "ftglGetGlyphError"); - - ----------------------------------------------------------------------------- - -- Layouts - ----------------------------------------------------------------------------- - - procedure Destroy_Layout (Layout : System.Address); - pragma Import (Convention => C, Entity => Destroy_Layout, - External_Name => "ftglDestroyLayout"); - - procedure Get_Layout_BBox (Layout : System.Address; - Value : C.char_array; - Bounds : Bounding_Box); - pragma Import (Convention => C, Entity => Get_Layout_BBox, - External_Name => "ftglGetLayoutBBox"); - - procedure Render_Layout (Layout : System.Address; - Value : C.char_array; - Mode : Render_Mode); - pragma Import (Convention => C, Entity => Render_Layout, - External_Name => "ftglRenderLayout"); - - function Get_Layout_Error (Layout : System.Address) return Errors.FT_Error; - pragma Import (Convention => C, Entity => Get_Layout_Error, - External_Name => "ftglGetLayoutError"); - - ----------------------------------------------------------------------------- - -- Fonts - ----------------------------------------------------------------------------- - - -- ftglCreateCustomFont omitted because we don't want to provide a complete - -- FreeType wrapper, and without one, the function is pointless. - - function Create_Pixmap_Font (File : C.char_array) return System.Address; - pragma Import (Convention => C, Entity => Create_Pixmap_Font, - External_Name => "ftglCreatePixmapFont"); - - function Create_Buffer_Font (File : C.char_array) return System.Address; - pragma Import (Convention => C, Entity => Create_Buffer_Font, - External_Name => "ftglCreateBufferFont"); - - function Create_Bitmap_Font (File : C.char_array) return System.Address; - pragma Import (Convention => C, Entity => Create_Bitmap_Font, - External_Name => "ftglCreateBitmapFont"); - - function Create_Extrude_Font (File : C.char_array) return System.Address; - pragma Import (Convention => C, Entity => Create_Extrude_Font, - External_Name => "ftglCreateExtrudeFont"); - - function Create_Polygon_Font (File : C.char_array) return System.Address; - pragma Import (Convention => C, Entity => Create_Polygon_Font, - External_Name => "ftglCreatePolygonFont"); - - function Create_Outline_Font (File : C.char_array) return System.Address; - pragma Import (Convention => C, Entity => Create_Outline_Font, - External_Name => "ftglCreateOutlineFont"); - - function Create_Texture_Font (File : C.char_array) return System.Address; - pragma Import (Convention => C, Entity => Create_Texture_Font, - External_Name => "ftglCreateTextureFont"); - - procedure Destroy_Font (Font : System.Address); - pragma Import (Convention => C, Entity => Destroy_Font, - External_Name => "ftglDestroyFont"); - - function Attach_File (Font : System.Address; Path : C.char_array) - return C.int; - pragma Import (Convention => C, Entity => Attach_File, - External_Name => "ftglAttachFile"); - - function Attach_Data (Font : System.Address; Data : System.Address; - Size : C.size_t) return C.int; - pragma Import (Convention => C, Entity => Attach_Data, - External_Name => "ftglAttachData"); - - function Set_Font_Char_Map (Font : System.Address; Encoding : Charset) - return C.int; - pragma Import (Convention => C, Entity => Set_Font_Char_Map, - External_Name => "ftglSetFontCharMap"); - - function Get_Font_Char_Map_Count (Font : System.Address) return C.unsigned; - pragma Import (Convention => C, Entity => Get_Font_Char_Map_Count, - External_Name => "ftglGetFontCharMapCount"); - - function Get_Font_Char_Map_List (Font : System.Address) - return Charset_Pointers.Pointer; - pragma Import (Convention => C, Entity => Get_Font_Char_Map_List, - External_Name => "ftglGetFontCharMapList"); - - function Set_Font_Face_Size (Font : System.Address; - Size, Res : GL.Types.UInt) return C.int; - pragma Import (Convention => C, Entity => Set_Font_Face_Size, - External_Name => "ftglSetFontFaceSize"); - - function Get_Font_Face_Size (Font : System.Address) return GL.Types.UInt; - pragma Import (Convention => C, Entity => Get_Font_Face_Size, - External_Name => "ftglGetFontFaceSize"); - - procedure Set_Font_Depth (Font : System.Address; Depth : Fonts.Depth); - pragma Import (Convention => C, Entity => Set_Font_Depth, - External_Name => "ftglSetFontDepth"); - - procedure Set_Font_Outset (Font : System.Address; - Front, Back : GL.Types.Single); - pragma Import (Convention => C, Entity => Set_Font_Outset, - External_Name => "ftglSetFontOutset"); - - procedure Set_Font_Display_List (Font : System.Address; Use_List : C.int); - pragma Import (Convention => C, Entity => Set_Font_Display_List, - External_Name => "ftglSetFontDisplayList"); - - function Get_Font_Ascender (Font : System.Address) return GL.Types.Single; - pragma Import (Convention => C, Entity => Get_Font_Ascender, - External_Name => "ftglGetFontAscender"); - - function Get_Font_Descender (Font : System.Address) return GL.Types.Single; - pragma Import (Convention => C, Entity => Get_Font_Descender, - External_Name => "ftglGetFontDescender"); - - function Get_Font_Line_Height (Font : System.Address) return GL.Types.Single; - pragma Import (Convention => C, Entity => Get_Font_Line_Height, - External_Name => "ftglGetFontLineHeight"); - - procedure Get_Font_BBox (Font : System.Address; - Value : C.char_array; Len : C.int; - Bounds : out Bounding_Box); - pragma Import (Convention => C, Entity => Get_Font_BBox, - External_Name => "ftglGetFontBBox"); - - function Get_Font_Advance (Font : System.Address; - Value : C.char_array) return GL.Types.Single; - pragma Import (Convention => C, Entity => Get_Font_Advance, - External_Name => "ftglGetFontAdvance"); - - procedure Render_Font (Font : System.Address; - Value : C.char_array; Mode : Render_Mode); - pragma Import (Convention => C, Entity => Render_Font, - External_Name => "ftglRenderFont"); - - function Get_Font_Error (Font : System.Address) return Errors.FT_Error; - pragma Import (Convention => C, Entity => Get_Font_Error, - External_Name => "ftglGetFontError"); -end FTGL.API; diff --git a/src/ftgl/ftgl-errors.ads b/src/ftgl/ftgl-errors.ads deleted file mode 100644 index a8d751be..00000000 --- a/src/ftgl/ftgl-errors.ads +++ /dev/null @@ -1,185 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -package FTGL.Errors is - - -- FreeType error codes. not sure if all of them are needed. - type FT_Error is (Ok, - Cannot_Open_Resource, - Unknown_File_Format, - Invalid_File_Format, - Invalid_Version, - Lower_Module_Version, - Invalid_Argument, - Unimplemented_Feature, - Invalid_Table, - Invalid_Offset, - Array_Too_Large, - Invalid_Glyph_Index, - Invalid_Character_Code, - Invalid_Glyph_Format, - Cannot_Render_Glyph, - Invalid_Outline, - Invalid_Composite, - Too_Many_Hints, - Invalid_Pixel_Size, - Invalid_Handle, - Invalid_Library_Handle, - Invalid_Driver_Handle, - Invalid_Face_Handle, - Invalid_Size_Handle, - Invalid_Slot_Handle, - Invalid_CharMap_Handle, - Invalid_Cache_Handle, - Invalid_Stream_Handle, - Too_Many_Drivers, - Too_Many_Extensions, - Out_Of_Memory, - Unlisted_Object, - Cannot_Open_Stream, - Invalid_Stream_Seek, - Invalid_Stream_Skip, - Invalid_Stream_Read, - Invalid_Stream_Operation, - Invalid_Frame_Operation, - Nested_Frame_Access, - Invalid_Frame_Read, - Raster_Uninitialized, - Raster_Corrupted, - Raster_Overflow, - Raster_Negative_Height, - Too_Many_Caches, - Invalid_Opcode, - Too_Few_Arguments, - Stack_Overflow, - Code_Overflow, - Bad_Argument, - Divide_By_Zero, - Invalid_Reference, - Debug_OpCode, - ENDF_In_Exec_Stream, - Nested_DEFS, - Invalid_CodeRange, - Execution_Too_Long, - Too_Many_Function_Defs, - Too_Many_Instruction_Defs, - Table_Missing, - Horiz_Header_Missing, - Locations_Missing, - Name_Table_Missing, - CMap_Table_Missing, - Hmtx_Table_Missing, - Post_Table_Missing, - Invalid_Horiz_Metrics, - Invalid_CharMap_Format, - Invalid_PPem, - Invalid_Vert_Metrics, - Could_Not_Find_Context, - Invalid_Post_Table_Format, - Invalid_Post_Table, - Syntax_Error, - Stack_Underflow, - Ignore, - No_Unicode_Glyph_Name, - Missing_Startfont_Field, - Missing_Font_Field, - Missing_Size_Field, - Missing_Fontboundingbox_Field, - Missing_Chars_Field, - Missing_Startchar_Field, - Missing_Encoding_Field, - Missing_Bbx_Field, - Bbx_Too_Big, - Corrupted_Font_Header, - Corrupted_Font_Glyphs); -private - for FT_Error use (Ok => 16#00#, - Cannot_Open_Resource => 16#01#, - Unknown_File_Format => 16#02#, - Invalid_File_Format => 16#03#, - Invalid_Version => 16#04#, - Lower_Module_Version => 16#05#, - Invalid_Argument => 16#06#, - Unimplemented_Feature => 16#07#, - Invalid_Table => 16#08#, - Invalid_Offset => 16#09#, - Array_Too_Large => 16#0A#, - Invalid_Glyph_Index => 16#10#, - Invalid_Character_Code => 16#11#, - Invalid_Glyph_Format => 16#12#, - Cannot_Render_Glyph => 16#13#, - Invalid_Outline => 16#14#, - Invalid_Composite => 16#15#, - Too_Many_Hints => 16#16#, - Invalid_Pixel_Size => 16#17#, - Invalid_Handle => 16#20#, - Invalid_Library_Handle => 16#21#, - Invalid_Driver_Handle => 16#22#, - Invalid_Face_Handle => 16#23#, - Invalid_Size_Handle => 16#24#, - Invalid_Slot_Handle => 16#25#, - Invalid_CharMap_Handle => 16#26#, - Invalid_Cache_Handle => 16#27#, - Invalid_Stream_Handle => 16#28#, - Too_Many_Drivers => 16#30#, - Too_Many_Extensions => 16#31#, - Out_Of_Memory => 16#40#, - Unlisted_Object => 16#41#, - Cannot_Open_Stream => 16#51#, - Invalid_Stream_Seek => 16#52#, - Invalid_Stream_Skip => 16#53#, - Invalid_Stream_Read => 16#54#, - Invalid_Stream_Operation => 16#55#, - Invalid_Frame_Operation => 16#56#, - Nested_Frame_Access => 16#57#, - Invalid_Frame_Read => 16#58#, - Raster_Uninitialized => 16#60#, - Raster_Corrupted => 16#61#, - Raster_Overflow => 16#62#, - Raster_Negative_Height => 16#63#, - Too_Many_Caches => 16#70#, - Invalid_Opcode => 16#80#, - Too_Few_Arguments => 16#81#, - Stack_Overflow => 16#82#, - Code_Overflow => 16#83#, - Bad_Argument => 16#84#, - Divide_By_Zero => 16#85#, - Invalid_Reference => 16#86#, - Debug_OpCode => 16#87#, - ENDF_In_Exec_Stream => 16#88#, - Nested_DEFS => 16#89#, - Invalid_CodeRange => 16#8A#, - Execution_Too_Long => 16#8B#, - Too_Many_Function_Defs => 16#8C#, - Too_Many_Instruction_Defs => 16#8D#, - Table_Missing => 16#8E#, - Horiz_Header_Missing => 16#8F#, - Locations_Missing => 16#90#, - Name_Table_Missing => 16#91#, - CMap_Table_Missing => 16#92#, - Hmtx_Table_Missing => 16#93#, - Post_Table_Missing => 16#94#, - Invalid_Horiz_Metrics => 16#95#, - Invalid_CharMap_Format => 16#96#, - Invalid_PPem => 16#97#, - Invalid_Vert_Metrics => 16#98#, - Could_Not_Find_Context => 16#99#, - Invalid_Post_Table_Format => 16#9A#, - Invalid_Post_Table => 16#9B#, - Syntax_Error => 16#A0#, - Stack_Underflow => 16#A1#, - Ignore => 16#A2#, - No_Unicode_Glyph_Name => 16#A3#, - Missing_Startfont_Field => 16#B0#, - Missing_Font_Field => 16#B1#, - Missing_Size_Field => 16#B2#, - Missing_Fontboundingbox_Field => 16#B3#, - Missing_Chars_Field => 16#B4#, - Missing_Startchar_Field => 16#B5#, - Missing_Encoding_Field => 16#B6#, - Missing_Bbx_Field => 16#B7#, - Bbx_Too_Big => 16#B8#, - Corrupted_Font_Header => 16#B9#, - Corrupted_Font_Glyphs => 16#BA#); - for FT_Error'Size use Interfaces.C.int'Size; -end FTGL.Errors; diff --git a/src/ftgl/ftgl-fonts.adb b/src/ftgl/ftgl-fonts.adb deleted file mode 100644 index 3877d0dc..00000000 --- a/src/ftgl/ftgl-fonts.adb +++ /dev/null @@ -1,235 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with Ada.Unchecked_Deallocation; - -with FTGL.API; - -package body FTGL.Fonts is - - overriding procedure Initialize (Object : in out Font) is - begin - Object.Data := null; - end Initialize; - - overriding procedure Adjust (Object : in out Font) is - begin - if Object.Data /= null then - Object.Data.Reference_Count := Object.Data.Reference_Count + 1; - end if; - end Adjust; - - overriding procedure Finalize (Object : in out Font) is - procedure Free is new Ada.Unchecked_Deallocation (Font_Data, - Font_Data_Access); - begin - if Object.Data /= null then - if Object.Data.Reference_Count = 1 then - FTGL.API.Destroy_Font (Object.Data.Pointer); - Free (Object.Data); - else - Object.Data.Reference_Count := Object.Data.Reference_Count - 1; - end if; - end if; - end Finalize; - - generic - type Font_Type is new Font with private; - with function Creator (Path : API.C.char_array) return System.Address; - procedure Loader (Object : in out Font_Type; Path : String); - - procedure Loader (Object : in out Font_Type; Path : String) is - use type System.Address; - C_Path : constant API.C.char_array := API.C.To_C (Path); - Raw : constant System.Address := Creator (C_Path); - begin - if Raw = System.Null_Address then - raise FTGL_Error with "Could not load font " & Path; - end if; - - if Object.Data /= null then - FTGL.API.Destroy_Font (Object.Data.Pointer); - Object.Data.Pointer := Raw; - else - Object.Data := new Font_Data'(Reference_Count => 1, Pointer => Raw); - end if; - end Loader; - - procedure Bitmap_Loader is new Loader (Bitmap_Font, API.Create_Bitmap_Font); - procedure Load (Object : in out Bitmap_Font; Path : String) - renames Bitmap_Loader; - - procedure Pixmap_Loader is new Loader (Pixmap_Font, API.Create_Pixmap_Font); - procedure Load (Object : in out Pixmap_Font; Path : String) - renames Pixmap_Loader; - - procedure Polygon_Loader is - new Loader (Polygon_Font, API.Create_Polygon_Font); - procedure Load (Object : in out Polygon_Font; Path : String) - renames Polygon_Loader; - - procedure Outline_Loader is - new Loader (Outline_Font, API.Create_Outline_Font); - procedure Load (Object : in out Outline_Font; Path : String) - renames Outline_Loader; - - procedure Extrude_Loader is - new Loader (Extrude_Font, API.Create_Extrude_Font); - procedure Load (Object : in out Extrude_Font; Path : String) - renames Extrude_Loader; - - procedure Texture_Loader is - new Loader (Texture_Font, API.Create_Texture_Font); - procedure Load (Object : in out Texture_Font; Path : String) - renames Texture_Loader; - - procedure Buffer_Loader is new Loader (Buffer_Font, API.Create_Buffer_Font); - procedure Load (Object : in out Buffer_Font; Path : String) - renames Buffer_Loader; - - function Loaded (Object : Font) return Boolean is - begin - return Object.Data /= null; - end Loaded; - - procedure Set_Char_Map (Object : in out Font; Value : Charset) is - use type API.C.int; - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - if API.Set_Font_Char_Map (Object.Data.Pointer, Value) /= 1 then - raise FTGL_Error with "Cannot set char map!"; - end if; - end Set_Char_Map; - - function Get_Char_Map_List (Object : Font) return Charset_List is - Size : API.C.unsigned; - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - Size := API.Get_Font_Char_Map_Count (Object.Data.Pointer); - return API.Charset_Pointers.Value - (API.Get_Font_Char_Map_List (Object.Data.Pointer), - Interfaces.C.ptrdiff_t (Size)); - end Get_Char_Map_List; - - procedure Set_Font_Face_Size (Object : in out Font; - Size : GL.Types.UInt; - Resolution : GL.Types.UInt := 72) is - use type API.C.int; - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - if API.Set_Font_Face_Size (Object.Data.Pointer, Size, Resolution) /= 1 - then - raise FTGL_Error with "Cannot set font size"; - end if; - end Set_Font_Face_Size; - - function Get_Font_Face_Size (Object : Font) return GL.Types.UInt is - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - return API.Get_Font_Face_Size (Object.Data.Pointer); - end Get_Font_Face_Size; - - procedure Set_Font_Depth (Object : in out Font; Value : GL.Types.Single) is - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - API.Set_Font_Depth (Object.Data.Pointer, Value); - end Set_Font_Depth; - - procedure Set_Font_Outset (Object : in out Font; - Front, Back : GL.Types.Single) is - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - API.Set_Font_Outset (Object.Data.Pointer, Front, Back); - end Set_Font_Outset; - - procedure Set_Display_List (Object : in out Font; - Use_Display_List : Boolean) is - Value : API.C.int; - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - if Use_Display_List then - Value := 1; - else - Value := 0; - end if; - API.Set_Font_Display_List (Object.Data.Pointer, Value); - end Set_Display_List; - - function Ascender (Object : Font) return GL.Types.Single is - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - return API.Get_Font_Ascender (Object.Data.Pointer); - end Ascender; - - function Descender (Object : Font) return GL.Types.Single is - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - return API.Get_Font_Descender (Object.Data.Pointer); - end Descender; - - function Line_Height (Object : Font) return GL.Types.Single is - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - return API.Get_Font_Line_Height (Object.Data.Pointer); - end Line_Height; - - function Bounds (Object : Font; Text : String) return Bounding_Box is - Result : Bounding_Box; - C_Text : constant API.C.char_array := API.C.To_C (Text, False); - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - API.Get_Font_BBox (Object.Data.Pointer, C_Text, C_Text'Length, Result); - return Result; - end Bounds; - - function Advance_Width (Object : Font; Text : String) return GL.Types.Single - is - C_Text : constant API.C.char_array := API.C.To_C (Text); - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - return API.Get_Font_Advance (Object.Data.Pointer, C_Text); - end Advance_Width; - - procedure Render (Object : Font; Value : String; Mode : Render_Mode) is - C_Value : constant API.C.char_array := API.C.To_C (Value); - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - - API.Render_Font (Object.Data.Pointer, C_Value, Mode); - end Render; - - function Error (Object : Font) return Errors.FT_Error is - begin - if Object.Data = null then - raise FTGL_Error with "Font uninitialized!"; - end if; - - return API.Get_Font_Error (Object.Data.Pointer); - end Error; -end FTGL.Fonts; diff --git a/src/ftgl/ftgl-fonts.ads b/src/ftgl/ftgl-fonts.ads deleted file mode 100644 index f9ae9310..00000000 --- a/src/ftgl/ftgl-fonts.ads +++ /dev/null @@ -1,111 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with Ada.Finalization; -with System; - -with GL.Types; - -with FTGL.Errors; - -package FTGL.Fonts is - - type Charset_List is array (Positive range <>) of aliased Charset; - - subtype Depth is GL.Types.Single; - - -- reference counted - type Font is abstract new Ada.Finalization.Controlled with private; - - overriding - procedure Initialize (Object : in out Font); - - overriding - procedure Adjust (Object : in out Font); - - overriding - procedure Finalize (Object : in out Font); - - procedure Load (Object : in out Font; Path : String) is abstract; - function Loaded (Object : Font) return Boolean; - - procedure Set_Char_Map (Object : in out Font; Value : Charset); - function Get_Char_Map_List (Object : Font) return Charset_List; - - procedure Set_Font_Face_Size (Object : in out Font; - Size : GL.Types.UInt; - Resolution : GL.Types.UInt := 72); - function Get_Font_Face_Size (Object : Font) return GL.Types.UInt; - - procedure Set_Font_Depth (Object : in out Font; Value : GL.Types.Single); - - procedure Set_Font_Outset (Object : in out Font; - Front, Back : GL.Types.Single); - - procedure Set_Display_List (Object : in out Font; - Use_Display_List : Boolean); - - function Ascender (Object : Font) return GL.Types.Single; - function Descender (Object : Font) return GL.Types.Single; - function Line_Height (Object : Font) return GL.Types.Single; - function Bounds (Object : Font; Text : String) return Bounding_Box; - function Advance_Width (Object : Font; Text : String) return GL.Types.Single; - - procedure Render (Object : Font; - Value : String; - Mode : Render_Mode); - - function Error (Object : Font) return Errors.FT_Error; - - - type Bitmap_Font is new Font with private; - - overriding procedure Load (Object : in out Bitmap_Font; Path : String); - - type Pixmap_Font is new Font with private; - - overriding procedure Load (Object : in out Pixmap_Font; Path : String); - - type Polygon_Font is new Font with private; - - overriding procedure Load (Object : in out Polygon_Font; Path : String); - - type Outline_Font is new Font with private; - - overriding procedure Load (Object : in out Outline_Font; Path : String); - - type Extrude_Font is new Font with private; - - overriding procedure Load (Object : in out Extrude_Font; Path : String); - - type Texture_Font is new Font with private; - - overriding procedure Load (Object : in out Texture_Font; Path : String); - - type Buffer_Font is new Font with private; - - overriding procedure Load (Object : in out Buffer_Font; Path : String); - -private - pragma Convention (C, Charset_List); - for Charset_List'Component_Size use 32; - - type Font_Data is record - Reference_Count : Positive; - Pointer : System.Address; - end record; - - type Font_Data_Access is access all Font_Data; - - type Font is abstract new Ada.Finalization.Controlled with record - Data : Font_Data_Access; - end record; - - type Bitmap_Font is new Font with null record; - type Pixmap_Font is new Font with null record; - type Polygon_Font is new Font with null record; - type Outline_Font is new Font with null record; - type Extrude_Font is new Font with null record; - type Texture_Font is new Font with null record; - type Buffer_Font is new Font with null record; -end FTGL.Fonts; diff --git a/src/ftgl/ftgl.ads b/src/ftgl/ftgl.ads deleted file mode 100644 index 06de6db2..00000000 --- a/src/ftgl/ftgl.ads +++ /dev/null @@ -1,117 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with GL.Types; - -private with Ada.Unchecked_Conversion; -private with Interfaces.C; - -package FTGL is - --pragma Preelaborate; - - type Render_Mode is record - Front, Back, Side : Boolean; - end record; - Render_All : constant Render_Mode; - - type Text_Alignment is (Left, Center, Right, Justify); - - type Bounding_Box_Index is range 1 .. 6; - type Bounding_Box is array (Bounding_Box_Index) of GL.Types.Single; - - type Charset is (None, Adobe_Custom, Adobe_Expert, Adobe_Standard, - Apple_Roman, Big5, GB2312, Johab, Adobe_Latin_1, - Old_Latin_2, SJIS, MS_Symbol, Unicode, Wansung); - - FTGL_Error : exception; -private - for Render_Mode use record - Front at 0 range 0 .. 0; - Back at 0 range 1 .. 1; - Side at 0 range 2 .. 2; - end record; - pragma Convention (C_Pass_By_Copy, Render_Mode); - pragma Warnings (Off); - for Render_Mode'Size use Interfaces.C.int'Size; - pragma Warnings (On); - - Render_All : constant Render_Mode := (others => True); - - for Text_Alignment use (Left => 0, Center => 1, Right => 2, Justify => 3); - for Text_Alignment'Size use Interfaces.C.int'Size; - - pragma Convention (C, Bounding_Box); - pragma Pack (Bounding_Box); - - subtype Raw_Charset is Interfaces.C.char_array (1 .. 4); - function To_Rep is new Ada.Unchecked_Conversion (Raw_Charset, Integer'Base); - - -- ugliest representation clause ever - -- (the FreeType header does this with preprocessor macros) - for Charset use (None => 0, - MS_Symbol => Character'Pos ('s') * 2**24 + - Character'Pos ('y') * 2**16 + - Character'Pos ('m') * 2**8 + - Character'Pos ('b'), - - Unicode => Character'Pos ('u') * 2**24 + - Character'Pos ('n') * 2**16 + - Character'Pos ('i') * 2**8 + - Character'Pos ('c'), - - SJIS => Character'Pos ('s') * 2**24 + - Character'Pos ('j') * 2**16 + - Character'Pos ('i') * 2**8 + - Character'Pos ('s'), - - GB2312 => Character'Pos ('g') * 2**24 + - Character'Pos ('b') * 2**16 + - Character'Pos (' ') * 2**8 + - Character'Pos (' '), - - Big5 => Character'Pos ('b') * 2**24 + - Character'Pos ('i') * 2**16 + - Character'Pos ('g') * 2**8 + - Character'Pos ('5'), - - Wansung => Character'Pos ('w') * 2**24 + - Character'Pos ('a') * 2**16 + - Character'Pos ('n') * 2**8 + - Character'Pos ('s'), - - Johab => Character'Pos ('j') * 2**24 + - Character'Pos ('o') * 2**16 + - Character'Pos ('h') * 2**8 + - Character'Pos ('a'), - - Adobe_Standard => Character'Pos ('A') * 2**24 + - Character'Pos ('D') * 2**16 + - Character'Pos ('O') * 2**8 + - Character'Pos ('B'), - - Adobe_Expert => Character'Pos ('A') * 2**24 + - Character'Pos ('D') * 2**16 + - Character'Pos ('B') * 2**8 + - Character'Pos ('E'), - - Adobe_Custom => Character'Pos ('A') * 2**24 + - Character'Pos ('D') * 2**16 + - Character'Pos ('B') * 2**8 + - Character'Pos ('C'), - - Adobe_Latin_1 => Character'Pos ('l') * 2**24 + - Character'Pos ('a') * 2**16 + - Character'Pos ('t') * 2**8 + - Character'Pos ('1'), - - Old_Latin_2 => Character'Pos ('l') * 2**24 + - Character'Pos ('a') * 2**16 + - Character'Pos ('t') * 2**8 + - Character'Pos ('2'), - - Apple_Roman => Character'Pos ('a') * 2**24 + - Character'Pos ('r') * 2**16 + - Character'Pos ('m') * 2**8 + - Character'Pos ('n')); - for Charset'Size use 32; -end FTGL; diff --git a/src/gl/generated/gl-api.ads b/src/gl/generated/gl-api.ads index 5d5d53fa..e21c5a06 100644 --- a/src/gl/generated/gl-api.ads +++ b/src/gl/generated/gl-api.ads @@ -175,210 +175,236 @@ private package GL.API is pragma Convention (StdCall, T73); type T74 is access procedure (P1 : Connection_Mode; P2 : UInt; P3 : Unsigned_Numeric_Type; P4 : UInt; P5 : Int); pragma Convention (StdCall, T74); - type T75 is access procedure (P1 : UInt); + type T75 is access procedure (P1 : Connection_Mode; P2 : UInt); pragma Convention (StdCall, T75); - type T76 is access procedure (P1 : GL.Attributes.Attribute; P2 : UInt); + type T76 is access procedure (P1 : Connection_Mode; P2 : UInt; P3 : UInt); pragma Convention (StdCall, T76); - type T77 is access procedure (P1 : Buffers.Draw_Buffer_Index; P2, P3 : Blending.Blend_Factor); + type T77 is access procedure (P1 : UInt); pragma Convention (StdCall, T77); - type T78 is access procedure (P1, P2, P3, P4 : Blending.Blend_Factor); + type T78 is access procedure (P1 : GL.Attributes.Attribute; P2 : UInt); pragma Convention (StdCall, T78); - type T79 is access procedure (P1 : Buffers.Draw_Buffer_Index; P2, P3, P4, P5 : Blending.Blend_Factor); + type T79 is access procedure (P1 : Buffers.Draw_Buffer_Index; P2, P3 : Blending.Blend_Factor); pragma Convention (StdCall, T79); - type T80 is access procedure (P1, P2, P3, P4 : Colors.Component); + type T80 is access procedure (P1, P2, P3, P4 : Blending.Blend_Factor); pragma Convention (StdCall, T80); - type T81 is access procedure (P1 : Blending.Equation); + type T81 is access procedure (P1 : Buffers.Draw_Buffer_Index; P2, P3, P4, P5 : Blending.Blend_Factor); pragma Convention (StdCall, T81); - type T82 is access procedure (P1 : Buffers.Draw_Buffer_Index; P2 : Blending.Equation); + type T82 is access procedure (P1, P2, P3, P4 : Colors.Component); pragma Convention (StdCall, T82); - type T83 is access procedure (P1, P2 : Blending.Equation); + type T83 is access procedure (P1 : Blending.Equation); pragma Convention (StdCall, T83); - type T84 is access procedure (P1 : Buffers.Draw_Buffer_Index; P2, P3 : Blending.Equation); + type T84 is access procedure (P1 : Buffers.Draw_Buffer_Index; P2 : Blending.Equation); pragma Convention (StdCall, T84); - type T85 is access procedure (P1 : Enums.Point_Param; P2 : Single); + type T85 is access procedure (P1, P2 : Blending.Equation); pragma Convention (StdCall, T85); - type T86 is access procedure (P1 : UInt; P2 : Buffers.Explicit_Color_Buffer_List); + type T86 is access procedure (P1 : Buffers.Draw_Buffer_Index; P2, P3 : Blending.Equation); pragma Convention (StdCall, T86); - type T87 is access procedure (P1 : Buffers.Color_Buffer_Selector; P2 : Low_Level.Zero; P3 : Colors.Color); + type T87 is access procedure (P1 : Enums.Point_Param; P2 : Single); pragma Convention (StdCall, T87); - type T88 is access procedure (P1 : Low_Level.Enums.Only_Color_Buffer; P2 : Buffers.Draw_Buffer_Index; P3 : Colors.Color); + type T88 is access procedure (P1 : UInt; P2 : Buffers.Explicit_Color_Buffer_List); pragma Convention (StdCall, T88); - type T89 is access procedure (P1 : Low_Level.Enums.Only_Depth_Buffer; P2 : Low_Level.Zero; P3 : access constant Buffers.Depth); + type T89 is access procedure (P1 : Buffers.Color_Buffer_Selector; P2 : Low_Level.Zero; P3 : Colors.Color); pragma Convention (StdCall, T89); - type T90 is access procedure (P1 : Low_Level.Enums.Only_Stencil_Buffer; P2 : Low_Level.Zero; P3 : access constant Buffers.Stencil_Index); + type T90 is access procedure (P1 : Low_Level.Enums.Only_Color_Buffer; P2 : Buffers.Draw_Buffer_Index; P3 : Colors.Color); pragma Convention (StdCall, T90); - type T91 is access procedure (P1 : Low_Level.Enums.Only_Depth_Stencil_Buffer; P2 : Low_Level.Zero; P3 : Buffers.Depth; P4 : Buffers.Stencil_Index); + type T91 is access procedure (P1 : Low_Level.Enums.Only_Depth_Buffer; P2 : Low_Level.Zero; P3 : access constant Buffers.Depth); pragma Convention (StdCall, T91); - type T92 is access procedure (P1 : Culling.Face_Selector; P2 : Compare_Function; P3 : Int; P4 : UInt); + type T92 is access procedure (P1 : Low_Level.Enums.Only_Stencil_Buffer; P2 : Low_Level.Zero; P3 : access constant Buffers.Stencil_Index); pragma Convention (StdCall, T92); - type T93 is access procedure (P1 : Culling.Face_Selector; P2, P3, P4 : Buffers.Stencil_Action); + type T93 is access procedure (P1 : Low_Level.Enums.Only_Depth_Stencil_Buffer; P2 : Low_Level.Zero; P3 : Buffers.Depth; P4 : Buffers.Stencil_Index); pragma Convention (StdCall, T93); - type T94 is access procedure (P1 : Culling.Face_Selector; P2 : UInt); + type T94 is access procedure (P1 : Culling.Face_Selector; P2 : Compare_Function; P3 : Int; P4 : UInt); pragma Convention (StdCall, T94); - type T95 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4 : Size; P5 : Low_Level.Zero; P6 : Size; P7 : Objects.Textures.Image_Source); + type T95 is access procedure (P1 : Culling.Face_Selector; P2, P3, P4 : Buffers.Stencil_Action); pragma Convention (StdCall, T95); - type T96 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3, P4 : Int; P5, P6 : Size; P7 : Pixels.Data_Format; P8 : Pixels.Data_Type; P9 : Objects.Textures.Image_Source); + type T96 is access procedure (P1 : Culling.Face_Selector; P2 : UInt); pragma Convention (StdCall, T96); - type T97 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4 : Size); + type T97 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4 : Size; P5 : Low_Level.Zero; P6 : Size; P7 : Objects.Textures.Image_Source); pragma Convention (StdCall, T97); - type T98 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5 : Size; P6 : Low_Level.Zero; P7 : Size; P8 : Objects.Textures.Image_Source); + type T98 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3, P4 : Int; P5, P6 : Size; P7 : Pixels.Data_Format; P8 : Pixels.Data_Type; P9 : Objects.Textures.Image_Source); pragma Convention (StdCall, T98); - type T99 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5 : Size); + type T99 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4 : Size); pragma Convention (StdCall, T99); - type T100 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5, P6 : Size; P7 : Low_Level.Zero; P8 : Pixels.Data_Format; P9 : Pixels.Data_Type; P10 : Objects.Textures.Image_Source); + type T100 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5 : Size; P6 : Low_Level.Zero; P7 : Size; P8 : Objects.Textures.Image_Source); pragma Convention (StdCall, T100); - type T101 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5, P6 : Size; P7 : Low_Level.Zero; P8 : Size; P9 : Objects.Textures.Image_Source); + type T101 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5 : Size); pragma Convention (StdCall, T101); - type T102 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5, P6 : Size); + type T102 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5, P6 : Size; P7 : Low_Level.Zero; P8 : Pixels.Data_Format; P9 : Pixels.Data_Type; P10 : Objects.Textures.Image_Source); pragma Convention (StdCall, T102); - type T103 is access procedure (P1 : Int); + type T103 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5, P6 : Size; P7 : Low_Level.Zero; P8 : Size; P9 : Objects.Textures.Image_Source); pragma Convention (StdCall, T103); - type T104 is access procedure (P1 : Low_Level.Enums.Texture_Kind); + type T104 is access procedure (P1 : Low_Level.Enums.Texture_Kind; P2 : Objects.Textures.Mipmap_Level; P3 : Pixels.Internal_Format; P4, P5, P6 : Size); pragma Convention (StdCall, T104); - type T105 is access procedure (P1 : UInt; P2 : Objects.Textures.Mipmap_Level); + type T105 is access procedure (P1 : Int); pragma Convention (StdCall, T105); - type T106 is access procedure (P1 : UInt; P2 : Objects.Textures.Mipmap_Level; P3, P4, P5 : Int; P6, P7, P8 : Size); + type T106 is access procedure (P1 : Low_Level.Enums.Texture_Kind); pragma Convention (StdCall, T106); - type T107 is access procedure (P1 : Size; P2 : out UInt); + type T107 is access procedure (P1 : UInt; P2 : Objects.Textures.Mipmap_Level); pragma Convention (StdCall, T107); - type T108 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); + type T108 is access procedure (P1 : UInt; P2 : Objects.Textures.Mipmap_Level; P3, P4, P5 : Int; P6, P7, P8 : Size); pragma Convention (StdCall, T108); - type T109 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : UInt); + type T109 is access procedure (P1 : Size; P2 : out UInt); pragma Convention (StdCall, T109); - type T110 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : UInt; P3 : UInt); + type T110 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); pragma Convention (StdCall, T110); - type T111 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Low_Level.SizeIPtr; P3 : System.Address; P4 : Objects.Buffers.Buffer_Usage); + type T111 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : UInt); pragma Convention (StdCall, T111); - type T112 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Pixels.Internal_Format; P3 : UInt); + type T112 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : UInt; P3 : UInt); pragma Convention (StdCall, T112); - type T113 is access function (P1 : Low_Level.Enums.Buffer_Kind; P2 : Objects.Access_Kind) return System.Address; + type T113 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Low_Level.SizeIPtr; P3 : System.Address; P4 : Objects.Buffers.Buffer_Usage); pragma Convention (StdCall, T113); - type T114 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Pointer_Param; P3 : out System.Address); + type T114 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Pixels.Internal_Format; P3 : UInt); pragma Convention (StdCall, T114); - type T115 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Low_Level.IntPtr; P3 : Low_Level.SizeIPtr; P4 : System.Address); + type T115 is access function (P1 : Low_Level.Enums.Buffer_Kind; P2 : Objects.Access_Kind) return System.Address; pragma Convention (StdCall, T115); - type T116 is access procedure (P1 : Low_Level.Enums.Buffer_Kind); + type T116 is access function (P1 : Low_Level.Enums.Buffer_Kind; P2 : Low_Level.IntPtr; P3 : Low_Level.SizeIPtr; P4 : Low_Level.Bitfield) return System.Address; pragma Convention (StdCall, T116); - type T117 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Param; P3 : out Objects.Access_Kind); + type T117 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Pointer_Param; P3 : out System.Address); pragma Convention (StdCall, T117); - type T118 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Param; P3 : out Low_Level.Bool); + type T118 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Low_Level.IntPtr; P3 : Low_Level.SizeIPtr; P4 : System.Address); pragma Convention (StdCall, T118); - type T119 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Param; P3 : out Size); + type T119 is access procedure (P1 : Low_Level.Enums.Buffer_Kind); pragma Convention (StdCall, T119); - type T120 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Param; P3 : out Objects.Buffers.Buffer_Usage); + type T120 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Param; P3 : out Objects.Access_Kind); pragma Convention (StdCall, T120); - type T121 is access procedure (P1 : UInt); + type T121 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Param; P3 : out Low_Level.Bool); pragma Convention (StdCall, T121); - type T122 is access procedure (P1 : UInt; P2 : Low_Level.IntPtr; P3 : Low_Level.SizeIPtr); + type T122 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Param; P3 : out Size); pragma Convention (StdCall, T122); - type T123 is access procedure (P1 : Size; P2 : out UInt); + type T123 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Enums.Buffer_Param; P3 : out Objects.Buffers.Buffer_Usage); pragma Convention (StdCall, T123); - type T124 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); + type T124 is access procedure (P1 : UInt); pragma Convention (StdCall, T124); - type T125 is access procedure (P1 : UInt); + type T125 is access procedure (P1 : UInt; P2 : Low_Level.IntPtr; P3 : Low_Level.SizeIPtr); pragma Convention (StdCall, T125); - type T126 is access procedure (P1 : Size; P2 : out UInt); + type T126 is access procedure (P1 : Low_Level.Enums.Buffer_Kind; P2 : Low_Level.IntPtr; P3 : Low_Level.SizeIPtr); pragma Convention (StdCall, T126); - type T127 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); + type T127 is access procedure (P1 : Size; P2 : out UInt); pragma Convention (StdCall, T127); - type T128 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : Pixels.Internal_Format; P3, P4 : Size); + type T128 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); pragma Convention (StdCall, T128); - type T129 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : Size; P3 : Pixels.Internal_Format; P4, P5 : Size); + type T129 is access procedure (P1 : UInt); pragma Convention (StdCall, T129); - type T130 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : UInt); + type T130 is access procedure (P1 : Size; P2 : out UInt); pragma Convention (StdCall, T130); - type T131 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : Enums.Getter.Renderbuffer_Parameter; P3 : out Int); + type T131 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); pragma Convention (StdCall, T131); - type T132 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : Enums.Getter.Renderbuffer_Parameter; P3 : out Pixels.Internal_Format); + type T132 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : Pixels.Internal_Format; P3, P4 : Size); pragma Convention (StdCall, T132); - type T133 is access procedure (P1 : Enums.Clamp_Color_Param; P2 : Low_Level.Bool); + type T133 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : Size; P3 : Pixels.Internal_Format; P4, P5 : Size); pragma Convention (StdCall, T133); - type T134 is access procedure (P1 : Size; P2 : out UInt); + type T134 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : UInt); pragma Convention (StdCall, T134); - type T135 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); + type T135 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : Enums.Getter.Renderbuffer_Parameter; P3 : out Int); pragma Convention (StdCall, T135); - type T136 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : UInt); + type T136 is access procedure (P1 : Low_Level.Enums.Renderbuffer_Kind; P2 : Enums.Getter.Renderbuffer_Parameter; P3 : out Pixels.Internal_Format); pragma Convention (StdCall, T136); - type T137 is access function (P1 : Low_Level.Enums.Framebuffer_Kind) return Objects.Framebuffers.Framebuffer_Status; + type T137 is access procedure (P1 : Enums.Clamp_Color_Param; P2 : Low_Level.Bool); pragma Convention (StdCall, T137); - type T138 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Objects.Framebuffers.Attachment_Point; P3 : Low_Level.Enums.Renderbuffer_Kind; P4 : UInt); + type T138 is access procedure (P1 : Size; P2 : out UInt); pragma Convention (StdCall, T138); - type T139 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Objects.Framebuffers.Attachment_Point; P3 : UInt; P4 : Objects.Textures.Mipmap_Level); + type T139 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); pragma Convention (StdCall, T139); - type T140 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Objects.Framebuffers.Attachment_Point; P3 : UInt; P4 : Objects.Textures.Mipmap_Level; P5 : Int); + type T140 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : UInt); pragma Convention (StdCall, T140); - type T141 is access procedure (P1, P2, P3, P4, P5, P6, P7, P8 : Int; P9 : Low_Level.Bitfield; P10 : Objects.Textures.Magnifying_Function); + type T141 is access function (P1 : Low_Level.Enums.Framebuffer_Kind) return Objects.Framebuffers.Framebuffer_Status; pragma Convention (StdCall, T141); - type T142 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Size; P3 : Objects.Framebuffers.Attachment_List); + type T142 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Objects.Framebuffers.Attachment_Point; P3 : Low_Level.Enums.Renderbuffer_Kind; P4 : UInt); pragma Convention (StdCall, T142); - type T143 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Size; P3 : Objects.Framebuffers.Attachment_List; P4, P5 : Int; P6, P7 : Size); + type T143 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Objects.Framebuffers.Attachment_Point; P3 : UInt; P4 : Objects.Textures.Mipmap_Level); pragma Convention (StdCall, T143); - type T144 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Enums.Framebuffer_Param; P3 : Size); + type T144 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Objects.Framebuffers.Attachment_Point; P3 : UInt; P4 : Objects.Textures.Mipmap_Level; P5 : Int); pragma Convention (StdCall, T144); - type T145 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Enums.Framebuffer_Param; P3 : Low_Level.Bool); + type T145 is access procedure (P1, P2, P3, P4, P5, P6, P7, P8 : Int; P9 : Low_Level.Bitfield; P10 : Objects.Textures.Magnifying_Function); pragma Convention (StdCall, T145); - type T146 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Enums.Framebuffer_Param; P3 : out Size); + type T146 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Size; P3 : Objects.Framebuffers.Attachment_List); pragma Convention (StdCall, T146); - type T147 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Enums.Framebuffer_Param; P3 : out Low_Level.Bool); + type T147 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Size; P3 : Objects.Framebuffers.Attachment_List; P4, P5 : Int; P6, P7 : Size); pragma Convention (StdCall, T147); - type T148 is access procedure (P1 : UInt; P2 : Enums.Shader_Param; P3 : out Int); + type T148 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Enums.Framebuffer_Param; P3 : Size); pragma Convention (StdCall, T148); - type T149 is access procedure (P1 : UInt; P2 : Enums.Shader_Param; P3 : out Objects.Shaders.Shader_Type); + type T149 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Enums.Framebuffer_Param; P3 : Low_Level.Bool); pragma Convention (StdCall, T149); - type T150 is access function (P1 : Objects.Shaders.Shader_Type) return UInt; + type T150 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Enums.Framebuffer_Param; P3 : out Size); pragma Convention (StdCall, T150); - type T151 is access procedure (P1 : UInt); + type T151 is access procedure (P1 : Low_Level.Enums.Framebuffer_Kind; P2 : Enums.Framebuffer_Param; P3 : out Low_Level.Bool); pragma Convention (StdCall, T151); - type T152 is access procedure (P1 : UInt; P2 : Size; P3 : Low_Level.Char_Access_Array; P4 : Low_Level.Int_Array); + type T152 is access procedure (P1 : Size; P2 : out UInt); pragma Convention (StdCall, T152); - type T153 is access procedure (P1 : UInt; P2 : Size; P3 : out Size; P4 : in out String); + type T153 is access procedure (P1 : Size; P2 : Low_Level.UInt_Array); pragma Convention (StdCall, T153); - type T154 is access procedure; + type T154 is access function (P1 : UInt) return Boolean; pragma Convention (StdCall, T154); - type T155 is access function return UInt; + type T155 is access procedure (P1 : UInt; P2 : Low_Level.Enums.Query_Results; P3 : out UInt); pragma Convention (StdCall, T155); - type T156 is access procedure (P1 : UInt); + type T156 is access procedure (P1 : Low_Level.Enums.Query_Param; P2 : UInt); pragma Convention (StdCall, T156); - type T157 is access procedure (P1 : UInt; P2 : Enums.Program_Param; P3 : out Int); + type T157 is access procedure (P1 : Low_Level.Enums.Query_Param); pragma Convention (StdCall, T157); - type T158 is access procedure (P1, P2 : UInt); + type T158 is access procedure (P1 : Low_Level.Enums.Query_Param; P2, P3 : UInt); pragma Convention (StdCall, T158); - type T159 is access procedure (P1 : UInt; P2 : Size; P3 : out Size; P4 : in out String); + type T159 is access procedure (P1 : Low_Level.Enums.Query_Param; P2 : UInt); pragma Convention (StdCall, T159); - type T160 is access procedure (P1 : UInt; P2 : Objects.Shaders.Shader_Type; P3 : Enums.Program_Stage_Param; P4 : out Size); + type T160 is access procedure (P1 : UInt; P2 : Low_Level.Enums.Query_Param); pragma Convention (StdCall, T160); - type T161 is access function (P1 : UInt; P2 : Objects.Shaders.Shader_Type; P3 : Interfaces.C.char_array) return Objects.Programs.Subroutine_Index_Type; + type T161 is access procedure (P1 : UInt; P2 : Enums.Shader_Param; P3 : out Int); pragma Convention (StdCall, T161); - type T162 is access function (P1 : UInt; P2 : Objects.Shaders.Shader_Type; P3 : Interfaces.C.char_array) return Objects.Programs.Uniform_Location_Type; + type T162 is access procedure (P1 : UInt; P2 : Enums.Shader_Param; P3 : out Objects.Shaders.Shader_Type); pragma Convention (StdCall, T162); - type T163 is access function (P1 : UInt; P2 : C.char_array) return Uniforms.Uniform; + type T163 is access function (P1 : Objects.Shaders.Shader_Type) return UInt; pragma Convention (StdCall, T163); - type T164 is access procedure (P1 : UInt; P2 : Attributes.Attribute; P3 : C.char_array); + type T164 is access procedure (P1 : UInt); pragma Convention (StdCall, T164); - type T165 is access function (P1 : UInt; P2 : C.char_array) return Attributes.Attribute; + type T165 is access procedure (P1 : UInt; P2 : Size; P3 : Low_Level.Char_Access_Array; P4 : Low_Level.Int_Array); pragma Convention (StdCall, T165); - type T166 is access procedure (P1 : Attributes.Attribute; P2 : Component_Count; P3 : Numeric_Type; P4 : Low_Level.Bool; P5 : Size; P6 : Int); + type T166 is access procedure (P1 : UInt; P2 : Size; P3 : out Size; P4 : in out String); pragma Convention (StdCall, T166); - type T167 is access procedure (P1 : Attributes.Attribute; P2 : Component_Count; P3 : Numeric_Type; P4 : Size; P5 : Int); + type T167 is access procedure; pragma Convention (StdCall, T167); - type T168 is access procedure (P1 : Attributes.Attribute); + type T168 is access function return UInt; pragma Convention (StdCall, T168); - type T169 is access procedure (P1 : UInt; P2 : Size; P3 : out Size; P4 : in out UInt_Array); + type T169 is access procedure (P1 : UInt); pragma Convention (StdCall, T169); - type T170 is access procedure (P1 : UInt; P2 : Buffers.Draw_Buffer_Index; P3 : Interfaces.C.char_array); + type T170 is access procedure (P1 : UInt; P2 : Enums.Program_Param; P3 : out Int); pragma Convention (StdCall, T170); - type T171 is access function (P1 : UInt; P2 : Interfaces.C.char_array) return Int; + type T171 is access procedure (P1, P2 : UInt); pragma Convention (StdCall, T171); - type T172 is access procedure (P1 : Connection_Mode); + type T172 is access procedure (P1 : UInt; P2 : Size; P3 : out Size; P4 : in out String); pragma Convention (StdCall, T172); - type T173 is access procedure (P1 : UInt; P2 : Int; P3 : Size; P4 : Size; P5 : Size; P6 : GL.Objects.Programs.Buffer_Mode; P7 : Interfaces.C.char_array); + type T173 is access procedure (P1 : UInt; P2 : Objects.Shaders.Shader_Type; P3 : Enums.Program_Stage_Param; P4 : out Size); pragma Convention (StdCall, T173); - type T174 is access procedure (P1 : UInt; P2 : Size; P3 : Low_Level.Char_Access_Array; P4 : GL.Objects.Programs.Buffer_Mode); + type T174 is access function (P1 : UInt; P2 : Objects.Shaders.Shader_Type; P3 : Interfaces.C.char_array) return Objects.Programs.Subroutine_Index_Type; pragma Convention (StdCall, T174); - type T175 is access procedure (P1 : Enums.Patch_Parameter_Int; P2 : Int); + type T175 is access function (P1 : UInt; P2 : Objects.Shaders.Shader_Type; P3 : Interfaces.C.char_array) return Objects.Programs.Uniform_Location_Type; pragma Convention (StdCall, T175); - type T176 is access procedure (P1 : Enums.Patch_Parameter_Float_Array; P2 : Types.Single_Array); + type T176 is access function (P1 : UInt; P2 : C.char_array) return Uniforms.Uniform; pragma Convention (StdCall, T176); + type T177 is access procedure (P1 : UInt; P2 : Attributes.Attribute; P3 : C.char_array); + pragma Convention (StdCall, T177); + type T178 is access function (P1 : UInt; P2 : C.char_array) return Attributes.Attribute; + pragma Convention (StdCall, T178); + type T179 is access procedure (P1 : Attributes.Attribute; P2 : Component_Count; P3 : Numeric_Type; P4 : Low_Level.Bool; P5 : Size; P6 : Int); + pragma Convention (StdCall, T179); + type T180 is access procedure (P1 : Attributes.Attribute; P2 : Component_Count; P3 : Numeric_Type; P4 : Size; P5 : Int); + pragma Convention (StdCall, T180); + type T181 is access procedure (P1 : Attributes.Attribute); + pragma Convention (StdCall, T181); + type T182 is access procedure (P1 : UInt; P2 : Size; P3 : out Size; P4 : in out UInt_Array); + pragma Convention (StdCall, T182); + type T183 is access procedure (P1 : UInt; P2 : Buffers.Draw_Buffer_Index; P3 : Interfaces.C.char_array); + pragma Convention (StdCall, T183); + type T184 is access function (P1 : UInt; P2 : Interfaces.C.char_array) return Int; + pragma Convention (StdCall, T184); + type T185 is access procedure (P1 : Connection_Mode); + pragma Convention (StdCall, T185); + type T186 is access procedure (P1 : UInt; P2 : Int; P3 : Size; P4 : out Size; P5 : out Size; P6 : out GL.Objects.Programs.Active_Attribute; P7 : in out Interfaces.C.char_array); + pragma Convention (StdCall, T186); + type T187 is access procedure (P1 : UInt; P2 : Size; P3 : Low_Level.Char_Access_Array; P4 : GL.Objects.Programs.Buffer_Mode); + pragma Convention (StdCall, T187); + type T188 is access procedure (P1 : Enums.Patch_Parameter_Int; P2 : Int); + pragma Convention (StdCall, T188); + type T189 is access procedure (P1 : Enums.Patch_Parameter_Float_Array; P2 : Types.Single_Array); + pragma Convention (StdCall, T189); function Get_Error return Errors.Error_Code; pragma Import (StdCall, Get_Error, "glGetError"); procedure Flush; @@ -491,8 +517,10 @@ private package GL.API is pragma Import (StdCall, Draw_Elements, "glDrawElements"); Draw_Elements_Instanced : T73; Draw_Elements_Base_Vertex : T74; - Primitive_Restart_Index : T75; - Vertex_Attrib_Divisor : T76; + Draw_Transform_Feedback : T75; + Draw_Transform_Feedback_Stream : T76; + Primitive_Restart_Index : T77; + Vertex_Attrib_Divisor : T78; procedure Load_Matrix (Value : Types.Doubles.Matrix4); pragma Import (StdCall, Load_Matrix, "glLoadMatrixd"); procedure Mult_Matrix (Factor : Types.Doubles.Matrix4); @@ -531,51 +559,53 @@ private package GL.API is pragma Import (StdCall, Light_Direction, "glLightfv"); procedure Blend_Func (Src_Factor, Dst_Factor : Blending.Blend_Factor); pragma Import (StdCall, Blend_Func, "glBlendFunc"); - Blend_Func_I : T77; - Blend_Func_Separate : T78; - Blend_Func_Separate_I : T79; - Blend_Color : T80; - Blend_Equation : T81; - Blend_Equation_I : T82; - Blend_Equation_Separate : T83; - Blend_Equation_Separate_I : T84; + Blend_Func_I : T79; + Blend_Func_Separate : T80; + Blend_Func_Separate_I : T81; + Blend_Color : T82; + Blend_Equation : T83; + Blend_Equation_I : T84; + Blend_Equation_Separate : T85; + Blend_Equation_Separate_I : T86; procedure Line_Width (Value : Single); pragma Import (StdCall, Line_Width, "glLineWidth"); procedure Polygon_Mode (Face : Culling.Face_Selector; Value : Rasterization.Polygon_Mode_Type); pragma Import (StdCall, Polygon_Mode, "glPolygonMode"); procedure Set_Point_Size (Value : Single); pragma Import (StdCall, Set_Point_Size, "glPointSize"); - Set_Point_Parameter_Single : T85; + Set_Point_Parameter_Single : T87; procedure Raster_Pos4 (Value : Types.Doubles.Vector4); pragma Import (StdCall, Raster_Pos4, "glRasterPos4dv"); procedure Raster_Pos3 (Value : Types.Doubles.Vector3); pragma Import (StdCall, Raster_Pos3, "glRasterPos3dv"); procedure Raster_Pos2 (Value : Types.Doubles.Vector2); pragma Import (StdCall, Raster_Pos2, "glRasterPos2dv"); + procedure Set_Polygon_Offset (Factor, Units : Single); + pragma Import (StdCall, Set_Polygon_Offset, "glPolygonOffset"); procedure Clear (Bits : Low_Level.Bitfield); pragma Import (StdCall, Clear, "glClear"); procedure Draw_Buffer (Mode : Buffers.Explicit_Color_Buffer_Selector); pragma Import (StdCall, Draw_Buffer, "glDrawBuffer"); - Draw_Buffers : T86; + Draw_Buffers : T88; procedure Clear_Color (Red, Green, Blue, Alpha : Colors.Component); pragma Import (StdCall, Clear_Color, "glClearColor"); procedure Clear_Depth (Depth : Buffers.Depth); pragma Import (StdCall, Clear_Depth, "glClearDepth"); procedure Clear_Stencil (Index : Buffers.Stencil_Index); pragma Import (StdCall, Clear_Stencil, "glClearStencil"); - Clear_Accum : T80; - Clear_Buffer : T87; - Clear_Draw_Buffer : T88; - Clear_Buffer_Depth : T89; - Clear_Buffer_Stencil : T90; - Clear_Buffer_Depth_Stencil : T91; + Clear_Accum : T82; + Clear_Buffer : T89; + Clear_Draw_Buffer : T90; + Clear_Buffer_Depth : T91; + Clear_Buffer_Stencil : T92; + Clear_Buffer_Depth_Stencil : T93; procedure Depth_Mask (Value : Low_Level.Bool); pragma Import (StdCall, Depth_Mask, "glDepthMask"); procedure Depth_Func (Func : Compare_Function); pragma Import (StdCall, Depth_Func, "glDepthFunc"); - Stencil_Func_Separate : T92; - Stencil_Op_Separate : T93; - Stencil_Mask_Separate : T94; + Stencil_Func_Separate : T94; + Stencil_Op_Separate : T95; + Stencil_Mask_Separate : T96; procedure Tex_Parameter_Float (Target : Low_Level.Enums.Texture_Kind; Param_Name : Enums.Textures.Parameter; Value : Single); pragma Import (StdCall, Tex_Parameter_Float, "glTexParameterf"); procedure Tex_Parameter_Int (Target : Low_Level.Enums.Texture_Kind; Param_Name : Enums.Textures.Parameter; Value : Int); @@ -632,19 +662,19 @@ private package GL.API is pragma Import (StdCall, Is_Texture, "glIsTexture"); procedure Tex_Image_1D (Target : Low_Level.Enums.Texture_Kind; Level : Objects.Textures.Mipmap_Level; Internal_Format : Pixels.Internal_Format; Width : Size; Border : Low_Level.Zero; Format : Pixels.Data_Format; Data_Type : Pixels.Data_Type; Data : Objects.Textures.Image_Source); pragma Import (StdCall, Tex_Image_1D, "glTexImage1D"); - Compressed_Tex_Image_1D : T95; - Tex_Sub_Image_1D : T96; - Tex_Storage_1D : T97; + Compressed_Tex_Image_1D : T97; + Tex_Sub_Image_1D : T98; + Tex_Storage_1D : T99; procedure Tex_Image_2D (Target : Low_Level.Enums.Texture_Kind; Level : Objects.Textures.Mipmap_Level; Internal_Format : Pixels.Internal_Format; Width, Height : Size; Border : Low_Level.Zero; Format : Pixels.Data_Format; Data_Type : Pixels.Data_Type; Data : Objects.Textures.Image_Source); pragma Import (StdCall, Tex_Image_2D, "glTexImage2D"); - Compressed_Tex_Image_2D : T98; + Compressed_Tex_Image_2D : T100; procedure Tex_Sub_Image_2D (Target : Low_Level.Enums.Texture_Kind; Level : Objects.Textures.Mipmap_Level; X_Offset, Y_Offset : Int; Width, Height : Size; Format : Pixels.Data_Format; Data_Type : Pixels.Data_Type; Data : Objects.Textures.Image_Source); pragma Import (StdCall, Tex_Sub_Image_2D, "glTexSubImage2D"); - Tex_Storage_2D : T99; - Tex_Image_3D : T100; - Compressed_Tex_Image_3D : T101; - Tex_Sub_Image_3D : T96; - Tex_Storage_3D : T102; + Tex_Storage_2D : T101; + Tex_Image_3D : T102; + Compressed_Tex_Image_3D : T103; + Tex_Sub_Image_3D : T98; + Tex_Storage_3D : T104; procedure Tex_Env_Float (Target : Enums.Textures.Env_Target; Param_Name : Enums.Textures.Env_Parameter; Value : Single); pragma Import (StdCall, Tex_Env_Float, "glTexEnvf"); procedure Tex_Env_Int (Target : Enums.Textures.Env_Target; Param_Name : Enums.Textures.Env_Parameter; Value : Int); @@ -671,94 +701,109 @@ private package GL.API is pragma Import (StdCall, Get_Tex_Env_Arr, "glGetTexEnvfv"); procedure Get_Tex_Env_Bool (Target : Enums.Textures.Env_Target; Param_Name : Enums.Textures.Env_Parameter; Value : out Low_Level.Bool); pragma Import (StdCall, Get_Tex_Env_Bool, "glGetTexEnviv"); - Active_Texture : T103; - Generate_Mipmap : T104; - Invalidate_Tex_Image : T105; - Invalidate_Tex_Sub_Image : T106; - Gen_Buffers : T107; - Delete_Buffers : T108; - Bind_Buffer : T109; - Bind_Buffer_Base : T110; - Buffer_Data : T111; - Texture_Buffer_Data : T112; - Map_Buffer : T113; - Buffer_Pointer : T114; - Buffer_Sub_Data : T115; - Unmap_Buffer : T116; - Get_Buffer_Parameter_Access_Kind : T117; - Get_Buffer_Parameter_Bool : T118; - Get_Buffer_Parameter_Size : T119; - Get_Buffer_Parameter_Usage : T120; - Invalidate_Buffer_Data : T121; - Invalidate_Buffer_Sub_Data : T122; - Gen_Vertex_Arrays : T123; - Delete_Vertex_Arrays : T124; - Bind_Vertex_Array : T125; - Gen_Renderbuffers : T126; - Delete_Renderbuffers : T127; - Renderbuffer_Storage : T128; - Renderbuffer_Storage_Multisample : T129; - Bind_Renderbuffer : T130; - Get_Renderbuffer_Parameter_Int : T131; - Get_Renderbuffer_Parameter_Internal_Format : T132; + Active_Texture : T105; + Generate_Mipmap : T106; + Invalidate_Tex_Image : T107; + Invalidate_Tex_Sub_Image : T108; + Gen_Buffers : T109; + Gen_Transform_Feedbacks : T109; + Delete_Buffers : T110; + Delete_Transform_Feedbacks : T110; + Bind_Buffer : T111; + Bind_Transform_Feedback : T111; + Bind_Buffer_Base : T112; + Buffer_Data : T113; + Texture_Buffer_Data : T114; + Map_Buffer : T115; + Map_Buffer_Range : T116; + Buffer_Pointer : T117; + Buffer_Sub_Data : T118; + Get_Buffer_Sub_Data : T118; + Unmap_Buffer : T119; + Get_Buffer_Parameter_Access_Kind : T120; + Get_Buffer_Parameter_Bool : T121; + Get_Buffer_Parameter_Size : T122; + Get_Buffer_Parameter_Usage : T123; + Invalidate_Buffer_Data : T124; + Invalidate_Buffer_Sub_Data : T125; + Flush_Mapped_Buffer_Range : T126; + Gen_Vertex_Arrays : T127; + Delete_Vertex_Arrays : T128; + Bind_Vertex_Array : T129; + Gen_Renderbuffers : T130; + Delete_Renderbuffers : T131; + Renderbuffer_Storage : T132; + Renderbuffer_Storage_Multisample : T133; + Bind_Renderbuffer : T134; + Get_Renderbuffer_Parameter_Int : T135; + Get_Renderbuffer_Parameter_Internal_Format : T136; procedure Read_Pixels (X, Y : Int; Width, Height : Size; Format : Pixels.Framebuffer_Format; Data_Type : Pixels.Data_Type; Data : System.Address); pragma Import (StdCall, Read_Pixels, "glReadPixels"); procedure Logic_Op (Value : Framebuffer.Logic_Op); pragma Import (StdCall, Logic_Op, "glLogicOp"); - Clamp_Color : T133; + Clamp_Color : T137; procedure Read_Buffer (Value : Framebuffer.Read_Buffer_Selector); pragma Import (StdCall, Read_Buffer, "glReadBuffer"); - Gen_Framebuffers : T134; - Delete_Framebuffers : T135; - Bind_Framebuffer : T136; - Check_Framebuffer_Status : T137; - Framebuffer_Renderbuffer : T138; - Framebuffer_Texture : T139; - Framebuffer_Texture_Layer : T140; - Blit_Framebuffer : T141; - Invalidate_Framebuffer : T142; - Invalidate_Sub_Framebuffer : T143; - Framebuffer_Parameter_Size : T144; - Framebuffer_Parameter_Bool : T145; - Get_Framebuffer_Parameter_Size : T146; - Get_Framebuffer_Parameter_Bool : T147; - Get_Shader_Param : T148; - Get_Shader_Type : T149; - Create_Shader : T150; - Delete_Shader : T151; - Shader_Source : T152; - Get_Shader_Source : T153; - Compile_Shader : T151; - Release_Shader_Compiler : T154; - Get_Shader_Info_Log : T153; - Create_Program : T155; - Delete_Program : T156; - Get_Program_Param : T157; - Attach_Shader : T158; - Link_Program : T156; - Get_Program_Info_Log : T159; - Get_Program_Stage : T160; - Get_Subroutine_Index : T161; - Get_Subroutine_Uniform_Location : T162; - Use_Program : T156; - Validate_Program : T156; - Get_Uniform_Location : T163; - Bind_Attrib_Location : T164; - Get_Attrib_Location : T165; - Vertex_Attrib_Pointer : T166; - Vertex_AttribI_Pointer : T167; - Vertex_AttribL_Pointer : T167; - Enable_Vertex_Attrib_Array : T168; - Disable_Vertex_Attrib_Array : T168; - Get_Attached_Shaders : T169; - Bind_Frag_Data_Location : T170; - Get_Frag_Data_Location : T171; - Begin_Transform_Feedback : T172; - End_Transform_Feedback : T154; - Get_Transform_Feedback_Varying : T173; - Transform_Feedback_Varyings : T174; - Set_Patch_Parameter_Int : T175; - Set_Patch_Parameter_Float_Array : T176; + Gen_Framebuffers : T138; + Delete_Framebuffers : T139; + Bind_Framebuffer : T140; + Check_Framebuffer_Status : T141; + Framebuffer_Renderbuffer : T142; + Framebuffer_Texture : T143; + Framebuffer_Texture_Layer : T144; + Blit_Framebuffer : T145; + Invalidate_Framebuffer : T146; + Invalidate_Sub_Framebuffer : T147; + Framebuffer_Parameter_Size : T148; + Framebuffer_Parameter_Bool : T149; + Get_Framebuffer_Parameter_Size : T150; + Get_Framebuffer_Parameter_Bool : T151; + Gen_Queries : T152; + Delete_Queries : T153; + Is_Query : T154; + Get_Query_Object : T155; + Begin_Query : T156; + End_Query : T157; + Begin_Query_Indexed : T158; + End_Query_Indexed : T159; + Query_Counter : T160; + Get_Shader_Param : T161; + Get_Shader_Type : T162; + Create_Shader : T163; + Delete_Shader : T164; + Shader_Source : T165; + Get_Shader_Source : T166; + Compile_Shader : T164; + Release_Shader_Compiler : T167; + Get_Shader_Info_Log : T166; + Create_Program : T168; + Delete_Program : T169; + Get_Program_Param : T170; + Attach_Shader : T171; + Link_Program : T169; + Get_Program_Info_Log : T172; + Get_Program_Stage : T173; + Get_Subroutine_Index : T174; + Get_Subroutine_Uniform_Location : T175; + Use_Program : T169; + Validate_Program : T169; + Get_Uniform_Location : T176; + Bind_Attrib_Location : T177; + Get_Attrib_Location : T178; + Vertex_Attrib_Pointer : T179; + Vertex_AttribI_Pointer : T180; + Vertex_AttribL_Pointer : T180; + Enable_Vertex_Attrib_Array : T181; + Disable_Vertex_Attrib_Array : T181; + Get_Attached_Shaders : T182; + Bind_Frag_Data_Location : T183; + Get_Frag_Data_Location : T184; + Begin_Transform_Feedback : T185; + End_Transform_Feedback : T167; + Get_Transform_Feedback_Varying : T186; + Transform_Feedback_Varyings : T187; + Set_Patch_Parameter_Int : T188; + Set_Patch_Parameter_Float_Array : T189; procedure Depth_Range (Near, Far : Double); pragma Import (StdCall, Depth_Range, "glDepthRange"); procedure Viewport (X, Y : Int; Width, Height : Size); diff --git a/src/gl/generated/gl-load_function_pointers.adb b/src/gl/generated/gl-load_function_pointers.adb index 8215b245..6824526f 100644 --- a/src/gl/generated/gl-load_function_pointers.adb +++ b/src/gl/generated/gl-load_function_pointers.adb @@ -204,6 +204,19 @@ procedure GL.Load_Function_Pointers is function Load_T174 is new Load (T174); function Load_T175 is new Load (T175); function Load_T176 is new Load (T176); + function Load_T177 is new Load (T177); + function Load_T178 is new Load (T178); + function Load_T179 is new Load (T179); + function Load_T180 is new Load (T180); + function Load_T181 is new Load (T181); + function Load_T182 is new Load (T182); + function Load_T183 is new Load (T183); + function Load_T184 is new Load (T184); + function Load_T185 is new Load (T185); + function Load_T186 is new Load (T186); + function Load_T187 is new Load (T187); + function Load_T188 is new Load (T188); + function Load_T189 is new Load (T189); begin GL.API.Doubles.Vertex_Attrib1 := Load_T1 ("glVertexAttribL1d"); GL.API.Doubles.Vertex_Attrib2 := Load_T2 ("glVertexAttribL2d"); @@ -279,116 +292,133 @@ begin GL.API.Draw_Arrays_Instanced := Load_T72 ("glDrawArraysInstanced"); GL.API.Draw_Elements_Instanced := Load_T73 ("glDrawElementsInstanced"); GL.API.Draw_Elements_Base_Vertex := Load_T74 ("glDrawElementsBaseVertex"); - GL.API.Primitive_Restart_Index := Load_T75 ("glPrimitiveRestartIndex"); - GL.API.Vertex_Attrib_Divisor := Load_T76 ("glVertexAttribDivisor"); - GL.API.Blend_Func_I := Load_T77 ("glBlendFunci"); - GL.API.Blend_Func_Separate := Load_T78 ("glBlendFuncSeparate"); - GL.API.Blend_Func_Separate_I := Load_T79 ("glBlendFuncSeparate"); - GL.API.Blend_Color := Load_T80 ("glBlendColor"); - GL.API.Blend_Equation := Load_T81 ("glBlendEquation"); - GL.API.Blend_Equation_I := Load_T82 ("glBlendEquationi"); - GL.API.Blend_Equation_Separate := Load_T83 ("glBlendEquationSeparate"); - GL.API.Blend_Equation_Separate_I := Load_T84 ("glBlendEquationi"); - GL.API.Set_Point_Parameter_Single := Load_T85 ("glPointParameterf"); - GL.API.Draw_Buffers := Load_T86 ("glDrawBuffers"); - GL.API.Clear_Accum := Load_T80 ("glClearAccum"); - GL.API.Clear_Buffer := Load_T87 ("glClearBufferfv"); - GL.API.Clear_Draw_Buffer := Load_T88 ("glClearBufferfv"); - GL.API.Clear_Buffer_Depth := Load_T89 ("glClearBufferfv"); - GL.API.Clear_Buffer_Stencil := Load_T90 ("glClearBufferiv"); - GL.API.Clear_Buffer_Depth_Stencil := Load_T91 ("glClearBufferfi"); - GL.API.Stencil_Func_Separate := Load_T92 ("glStencilFuncSeparate"); - GL.API.Stencil_Op_Separate := Load_T93 ("glStencilOpSeparate"); - GL.API.Stencil_Mask_Separate := Load_T94 ("glStencilMaskSeparate"); - GL.API.Compressed_Tex_Image_1D := Load_T95 ("glCompressedTexImage1D"); - GL.API.Tex_Sub_Image_1D := Load_T96 ("glTexSubImage1D"); - GL.API.Tex_Storage_1D := Load_T97 ("glTexStorage1D"); - GL.API.Compressed_Tex_Image_2D := Load_T98 ("glCompressedTexImage2D"); - GL.API.Tex_Storage_2D := Load_T99 ("glTexStorage2D"); - GL.API.Tex_Image_3D := Load_T100 ("glTexImage3D"); - GL.API.Compressed_Tex_Image_3D := Load_T101 ("glCompressedTexImage3D"); - GL.API.Tex_Sub_Image_3D := Load_T96 ("glTexSubImage3D"); - GL.API.Tex_Storage_3D := Load_T102 ("glTexStorage3D"); - GL.API.Active_Texture := Load_T103 ("glActiveTexture"); - GL.API.Generate_Mipmap := Load_T104 ("glGenerateMipmap"); - GL.API.Invalidate_Tex_Image := Load_T105 ("glInvalidateTexImage"); - GL.API.Invalidate_Tex_Sub_Image := Load_T106 ("glInvalidateTexSubImage"); - GL.API.Gen_Buffers := Load_T107 ("glGenBuffers"); - GL.API.Delete_Buffers := Load_T108 ("glDeleteBuffers"); - GL.API.Bind_Buffer := Load_T109 ("glBindBuffer"); - GL.API.Bind_Buffer_Base := Load_T110 ("glBindBufferBase"); - GL.API.Buffer_Data := Load_T111 ("glBufferData"); - GL.API.Texture_Buffer_Data := Load_T112 ("glTexBuffer"); - GL.API.Map_Buffer := Load_T113 ("glMapBuffer"); - GL.API.Buffer_Pointer := Load_T114 ("glGetBufferPointerv"); - GL.API.Buffer_Sub_Data := Load_T115 ("glBufferSubData"); - GL.API.Unmap_Buffer := Load_T116 ("glUnmapBuffer"); - GL.API.Get_Buffer_Parameter_Access_Kind := Load_T117 ("glGetBufferParameteriv"); - GL.API.Get_Buffer_Parameter_Bool := Load_T118 ("glGetBufferParameteriv"); - GL.API.Get_Buffer_Parameter_Size := Load_T119 ("glGetBufferParameteriv"); - GL.API.Get_Buffer_Parameter_Usage := Load_T120 ("glGetBufferParameteriv"); - GL.API.Invalidate_Buffer_Data := Load_T121 ("glInvalidateBufferData"); - GL.API.Invalidate_Buffer_Sub_Data := Load_T122 ("glInvalidateBufferSubData"); - GL.API.Gen_Vertex_Arrays := Load_T123 ("glGenVertexArrays"); - GL.API.Delete_Vertex_Arrays := Load_T124 ("glDeleteVertexArrays"); - GL.API.Bind_Vertex_Array := Load_T125 ("glBindVertexArray"); - GL.API.Gen_Renderbuffers := Load_T126 ("glGenRenderbuffers"); - GL.API.Delete_Renderbuffers := Load_T127 ("glDeleteBuffers"); - GL.API.Renderbuffer_Storage := Load_T128 ("glRenderbufferStorage"); - GL.API.Renderbuffer_Storage_Multisample := Load_T129 ("glRenderbufferStorageMultisample"); - GL.API.Bind_Renderbuffer := Load_T130 ("glBindRenderbuffer"); - GL.API.Get_Renderbuffer_Parameter_Int := Load_T131 ("glGetRenderbufferParameteriv"); - GL.API.Get_Renderbuffer_Parameter_Internal_Format := Load_T132 ("glGetRenderbufferParameteriv"); - GL.API.Clamp_Color := Load_T133 ("glClampColor"); - GL.API.Gen_Framebuffers := Load_T134 ("glGenFramebuffers"); - GL.API.Delete_Framebuffers := Load_T135 ("glDeleteFramebuffers"); - GL.API.Bind_Framebuffer := Load_T136 ("glBindFramebuffer"); - GL.API.Check_Framebuffer_Status := Load_T137 ("glCheckFramebufferStatus"); - GL.API.Framebuffer_Renderbuffer := Load_T138 ("glFramebufferRenderbuffer"); - GL.API.Framebuffer_Texture := Load_T139 ("glFramebufferTexture"); - GL.API.Framebuffer_Texture_Layer := Load_T140 ("glFramebufferTextureLayer"); - GL.API.Blit_Framebuffer := Load_T141 ("glBlitFramebuffer"); - GL.API.Invalidate_Framebuffer := Load_T142 ("glInvalidateFramebuffer"); - GL.API.Invalidate_Sub_Framebuffer := Load_T143 ("glInvalidateSubFramebuffer"); - GL.API.Framebuffer_Parameter_Size := Load_T144 ("glFramebufferParameteri"); - GL.API.Framebuffer_Parameter_Bool := Load_T145 ("glFramebufferParameteri"); - GL.API.Get_Framebuffer_Parameter_Size := Load_T146 ("glGetFramebufferParameteriv"); - GL.API.Get_Framebuffer_Parameter_Bool := Load_T147 ("glGetFramebufferParameteriv"); - GL.API.Get_Shader_Param := Load_T148 ("glGetShaderiv"); - GL.API.Get_Shader_Type := Load_T149 ("glGetShaderiv"); - GL.API.Create_Shader := Load_T150 ("glCreateShader"); - GL.API.Delete_Shader := Load_T151 ("glDeleteShader"); - GL.API.Shader_Source := Load_T152 ("glShaderSource"); - GL.API.Get_Shader_Source := Load_T153 ("glGetShaderSource"); - GL.API.Compile_Shader := Load_T151 ("glCompileShader"); - GL.API.Release_Shader_Compiler := Load_T154 ("glReleaseShaderCompiler"); - GL.API.Get_Shader_Info_Log := Load_T153 ("glGetShaderInfoLog"); - GL.API.Create_Program := Load_T155 ("glCreateProgram"); - GL.API.Delete_Program := Load_T156 ("glDeleteProgram"); - GL.API.Get_Program_Param := Load_T157 ("glGetProgramiv"); - GL.API.Attach_Shader := Load_T158 ("glAttachShader"); - GL.API.Link_Program := Load_T156 ("glLinkProgram"); - GL.API.Get_Program_Info_Log := Load_T159 ("glGetProgramInfoLog"); - GL.API.Get_Program_Stage := Load_T160 ("glGetProgramStageiv"); - GL.API.Get_Subroutine_Index := Load_T161 ("glGetSubroutineIndex"); - GL.API.Get_Subroutine_Uniform_Location := Load_T162 ("glGetSubroutineUniformLocation"); - GL.API.Use_Program := Load_T156 ("glUseProgram"); - GL.API.Validate_Program := Load_T156 ("glValidateProgram"); - GL.API.Get_Uniform_Location := Load_T163 ("glGetUniformLocation"); - GL.API.Bind_Attrib_Location := Load_T164 ("glBindAttribLocation"); - GL.API.Get_Attrib_Location := Load_T165 ("glGetAttribLocation"); - GL.API.Vertex_Attrib_Pointer := Load_T166 ("glVertexAttribPointer"); - GL.API.Vertex_AttribI_Pointer := Load_T167 ("glVertexAttribIPointer"); - GL.API.Vertex_AttribL_Pointer := Load_T167 ("glVertexAttribLPointer"); - GL.API.Enable_Vertex_Attrib_Array := Load_T168 ("glEnableVertexAttribArray"); - GL.API.Disable_Vertex_Attrib_Array := Load_T168 ("glDisableVertexAttribArray"); - GL.API.Get_Attached_Shaders := Load_T169 ("glGetAttachedShaders"); - GL.API.Bind_Frag_Data_Location := Load_T170 ("glBindFragDataLocation"); - GL.API.Get_Frag_Data_Location := Load_T171 ("glGetFragDataLocation"); - GL.API.Begin_Transform_Feedback := Load_T172 ("glBeginTransformFeedback"); - GL.API.End_Transform_Feedback := Load_T154 ("glEndTransformFeedback"); - GL.API.Get_Transform_Feedback_Varying := Load_T173 ("glGetTransformFeedbackVarying"); - GL.API.Transform_Feedback_Varyings := Load_T174 ("glTransformFeedbackVaryings"); - GL.API.Set_Patch_Parameter_Int := Load_T175 ("glPatchParameteri"); - GL.API.Set_Patch_Parameter_Float_Array := Load_T176 ("glPatchParameterfv"); + GL.API.Draw_Transform_Feedback := Load_T75 ("glDrawTransformFeedback"); + GL.API.Draw_Transform_Feedback_Stream := Load_T76 ("glDrawTransformFeedbackStream"); + GL.API.Primitive_Restart_Index := Load_T77 ("glPrimitiveRestartIndex"); + GL.API.Vertex_Attrib_Divisor := Load_T78 ("glVertexAttribDivisor"); + GL.API.Blend_Func_I := Load_T79 ("glBlendFunci"); + GL.API.Blend_Func_Separate := Load_T80 ("glBlendFuncSeparate"); + GL.API.Blend_Func_Separate_I := Load_T81 ("glBlendFuncSeparate"); + GL.API.Blend_Color := Load_T82 ("glBlendColor"); + GL.API.Blend_Equation := Load_T83 ("glBlendEquation"); + GL.API.Blend_Equation_I := Load_T84 ("glBlendEquationi"); + GL.API.Blend_Equation_Separate := Load_T85 ("glBlendEquationSeparate"); + GL.API.Blend_Equation_Separate_I := Load_T86 ("glBlendEquationi"); + GL.API.Set_Point_Parameter_Single := Load_T87 ("glPointParameterf"); + GL.API.Draw_Buffers := Load_T88 ("glDrawBuffers"); + GL.API.Clear_Accum := Load_T82 ("glClearAccum"); + GL.API.Clear_Buffer := Load_T89 ("glClearBufferfv"); + GL.API.Clear_Draw_Buffer := Load_T90 ("glClearBufferfv"); + GL.API.Clear_Buffer_Depth := Load_T91 ("glClearBufferfv"); + GL.API.Clear_Buffer_Stencil := Load_T92 ("glClearBufferiv"); + GL.API.Clear_Buffer_Depth_Stencil := Load_T93 ("glClearBufferfi"); + GL.API.Stencil_Func_Separate := Load_T94 ("glStencilFuncSeparate"); + GL.API.Stencil_Op_Separate := Load_T95 ("glStencilOpSeparate"); + GL.API.Stencil_Mask_Separate := Load_T96 ("glStencilMaskSeparate"); + GL.API.Compressed_Tex_Image_1D := Load_T97 ("glCompressedTexImage1D"); + GL.API.Tex_Sub_Image_1D := Load_T98 ("glTexSubImage1D"); + GL.API.Tex_Storage_1D := Load_T99 ("glTexStorage1D"); + GL.API.Compressed_Tex_Image_2D := Load_T100 ("glCompressedTexImage2D"); + GL.API.Tex_Storage_2D := Load_T101 ("glTexStorage2D"); + GL.API.Tex_Image_3D := Load_T102 ("glTexImage3D"); + GL.API.Compressed_Tex_Image_3D := Load_T103 ("glCompressedTexImage3D"); + GL.API.Tex_Sub_Image_3D := Load_T98 ("glTexSubImage3D"); + GL.API.Tex_Storage_3D := Load_T104 ("glTexStorage3D"); + GL.API.Active_Texture := Load_T105 ("glActiveTexture"); + GL.API.Generate_Mipmap := Load_T106 ("glGenerateMipmap"); + GL.API.Invalidate_Tex_Image := Load_T107 ("glInvalidateTexImage"); + GL.API.Invalidate_Tex_Sub_Image := Load_T108 ("glInvalidateTexSubImage"); + GL.API.Gen_Buffers := Load_T109 ("glGenBuffers"); + GL.API.Gen_Transform_Feedbacks := Load_T109 ("glGenTransformFeedbacks"); + GL.API.Delete_Buffers := Load_T110 ("glDeleteBuffers"); + GL.API.Delete_Transform_Feedbacks := Load_T110 ("glDeleteTransformFeedbacks"); + GL.API.Bind_Buffer := Load_T111 ("glBindBuffer"); + GL.API.Bind_Transform_Feedback := Load_T111 ("glBindTransformFeedback"); + GL.API.Bind_Buffer_Base := Load_T112 ("glBindBufferBase"); + GL.API.Buffer_Data := Load_T113 ("glBufferData"); + GL.API.Texture_Buffer_Data := Load_T114 ("glTexBuffer"); + GL.API.Map_Buffer := Load_T115 ("glMapBuffer"); + GL.API.Map_Buffer_Range := Load_T116 ("glMapBufferRange"); + GL.API.Buffer_Pointer := Load_T117 ("glGetBufferPointerv"); + GL.API.Buffer_Sub_Data := Load_T118 ("glBufferSubData"); + GL.API.Get_Buffer_Sub_Data := Load_T118 ("glGetBufferSubData"); + GL.API.Unmap_Buffer := Load_T119 ("glUnmapBuffer"); + GL.API.Get_Buffer_Parameter_Access_Kind := Load_T120 ("glGetBufferParameteriv"); + GL.API.Get_Buffer_Parameter_Bool := Load_T121 ("glGetBufferParameteriv"); + GL.API.Get_Buffer_Parameter_Size := Load_T122 ("glGetBufferParameteriv"); + GL.API.Get_Buffer_Parameter_Usage := Load_T123 ("glGetBufferParameteriv"); + GL.API.Invalidate_Buffer_Data := Load_T124 ("glInvalidateBufferData"); + GL.API.Invalidate_Buffer_Sub_Data := Load_T125 ("glInvalidateBufferSubData"); + GL.API.Flush_Mapped_Buffer_Range := Load_T126 ("glFlushMappedBufferRange"); + GL.API.Gen_Vertex_Arrays := Load_T127 ("glGenVertexArrays"); + GL.API.Delete_Vertex_Arrays := Load_T128 ("glDeleteVertexArrays"); + GL.API.Bind_Vertex_Array := Load_T129 ("glBindVertexArray"); + GL.API.Gen_Renderbuffers := Load_T130 ("glGenRenderbuffers"); + GL.API.Delete_Renderbuffers := Load_T131 ("glDeleteBuffers"); + GL.API.Renderbuffer_Storage := Load_T132 ("glRenderbufferStorage"); + GL.API.Renderbuffer_Storage_Multisample := Load_T133 ("glRenderbufferStorageMultisample"); + GL.API.Bind_Renderbuffer := Load_T134 ("glBindRenderbuffer"); + GL.API.Get_Renderbuffer_Parameter_Int := Load_T135 ("glGetRenderbufferParameteriv"); + GL.API.Get_Renderbuffer_Parameter_Internal_Format := Load_T136 ("glGetRenderbufferParameteriv"); + GL.API.Clamp_Color := Load_T137 ("glClampColor"); + GL.API.Gen_Framebuffers := Load_T138 ("glGenFramebuffers"); + GL.API.Delete_Framebuffers := Load_T139 ("glDeleteFramebuffers"); + GL.API.Bind_Framebuffer := Load_T140 ("glBindFramebuffer"); + GL.API.Check_Framebuffer_Status := Load_T141 ("glCheckFramebufferStatus"); + GL.API.Framebuffer_Renderbuffer := Load_T142 ("glFramebufferRenderbuffer"); + GL.API.Framebuffer_Texture := Load_T143 ("glFramebufferTexture"); + GL.API.Framebuffer_Texture_Layer := Load_T144 ("glFramebufferTextureLayer"); + GL.API.Blit_Framebuffer := Load_T145 ("glBlitFramebuffer"); + GL.API.Invalidate_Framebuffer := Load_T146 ("glInvalidateFramebuffer"); + GL.API.Invalidate_Sub_Framebuffer := Load_T147 ("glInvalidateSubFramebuffer"); + GL.API.Framebuffer_Parameter_Size := Load_T148 ("glFramebufferParameteri"); + GL.API.Framebuffer_Parameter_Bool := Load_T149 ("glFramebufferParameteri"); + GL.API.Get_Framebuffer_Parameter_Size := Load_T150 ("glGetFramebufferParameteriv"); + GL.API.Get_Framebuffer_Parameter_Bool := Load_T151 ("glGetFramebufferParameteriv"); + GL.API.Gen_Queries := Load_T152 ("glGenQueries"); + GL.API.Delete_Queries := Load_T153 ("glDeleteQueries"); + GL.API.Is_Query := Load_T154 ("glIsQuery"); + GL.API.Get_Query_Object := Load_T155 ("glGetQueryObjectuiv"); + GL.API.Begin_Query := Load_T156 ("glBeginQuery"); + GL.API.End_Query := Load_T157 ("glEndQuery"); + GL.API.Begin_Query_Indexed := Load_T158 ("glBeginQueryIndexed"); + GL.API.End_Query_Indexed := Load_T159 ("glEndQueryIndexed"); + GL.API.Query_Counter := Load_T160 ("glQueryCounter"); + GL.API.Get_Shader_Param := Load_T161 ("glGetShaderiv"); + GL.API.Get_Shader_Type := Load_T162 ("glGetShaderiv"); + GL.API.Create_Shader := Load_T163 ("glCreateShader"); + GL.API.Delete_Shader := Load_T164 ("glDeleteShader"); + GL.API.Shader_Source := Load_T165 ("glShaderSource"); + GL.API.Get_Shader_Source := Load_T166 ("glGetShaderSource"); + GL.API.Compile_Shader := Load_T164 ("glCompileShader"); + GL.API.Release_Shader_Compiler := Load_T167 ("glReleaseShaderCompiler"); + GL.API.Get_Shader_Info_Log := Load_T166 ("glGetShaderInfoLog"); + GL.API.Create_Program := Load_T168 ("glCreateProgram"); + GL.API.Delete_Program := Load_T169 ("glDeleteProgram"); + GL.API.Get_Program_Param := Load_T170 ("glGetProgramiv"); + GL.API.Attach_Shader := Load_T171 ("glAttachShader"); + GL.API.Link_Program := Load_T169 ("glLinkProgram"); + GL.API.Get_Program_Info_Log := Load_T172 ("glGetProgramInfoLog"); + GL.API.Get_Program_Stage := Load_T173 ("glGetProgramStageiv"); + GL.API.Get_Subroutine_Index := Load_T174 ("glGetSubroutineIndex"); + GL.API.Get_Subroutine_Uniform_Location := Load_T175 ("glGetSubroutineUniformLocation"); + GL.API.Use_Program := Load_T169 ("glUseProgram"); + GL.API.Validate_Program := Load_T169 ("glValidateProgram"); + GL.API.Get_Uniform_Location := Load_T176 ("glGetUniformLocation"); + GL.API.Bind_Attrib_Location := Load_T177 ("glBindAttribLocation"); + GL.API.Get_Attrib_Location := Load_T178 ("glGetAttribLocation"); + GL.API.Vertex_Attrib_Pointer := Load_T179 ("glVertexAttribPointer"); + GL.API.Vertex_AttribI_Pointer := Load_T180 ("glVertexAttribIPointer"); + GL.API.Vertex_AttribL_Pointer := Load_T180 ("glVertexAttribLPointer"); + GL.API.Enable_Vertex_Attrib_Array := Load_T181 ("glEnableVertexAttribArray"); + GL.API.Disable_Vertex_Attrib_Array := Load_T181 ("glDisableVertexAttribArray"); + GL.API.Get_Attached_Shaders := Load_T182 ("glGetAttachedShaders"); + GL.API.Bind_Frag_Data_Location := Load_T183 ("glBindFragDataLocation"); + GL.API.Get_Frag_Data_Location := Load_T184 ("glGetFragDataLocation"); + GL.API.Begin_Transform_Feedback := Load_T185 ("glBeginTransformFeedback"); + GL.API.End_Transform_Feedback := Load_T167 ("glEndTransformFeedback"); + GL.API.Get_Transform_Feedback_Varying := Load_T186 ("glGetTransformFeedbackVarying"); + GL.API.Transform_Feedback_Varyings := Load_T187 ("glTransformFeedbackVaryings"); + GL.API.Set_Patch_Parameter_Int := Load_T188 ("glPatchParameteri"); + GL.API.Set_Patch_Parameter_Float_Array := Load_T189 ("glPatchParameterfv"); end GL.Load_Function_Pointers; diff --git a/src/gl/implementation/gl-enums-getter.ads b/src/gl/implementation/gl-enums-getter.ads index 7d3a837d..10d9c8bc 100644 --- a/src/gl/implementation/gl-enums-getter.ads +++ b/src/gl/implementation/gl-enums-getter.ads @@ -241,6 +241,8 @@ package GL.Enums.Getter is Stencil_Back_Pass_Depth_Fail, Stencil_Back_Pass_Depth_Pass, Blend_Equation_Alpha, + Query_Result, + Query_Result_Available, Max_Combined_Texture_Image_Units, Stencil_Back_Ref, Stencil_Back_Value_Mask, @@ -484,6 +486,8 @@ package GL.Enums.Getter is Stencil_Back_Pass_Depth_Fail => 16#8802#, Stencil_Back_Pass_Depth_Pass => 16#8803#, Blend_Equation_Alpha => 16#883D#, + Query_Result => 16#8866#, + Query_Result_Available => 16#8867#, Max_Combined_Texture_Image_Units => 16#8B4D#, Stencil_Back_Ref => 16#8CA3#, Stencil_Back_Value_Mask => 16#8CA4#, diff --git a/src/gl/implementation/gl-enums-queries.ads b/src/gl/implementation/gl-enums-queries.ads new file mode 100644 index 00000000..ff418444 --- /dev/null +++ b/src/gl/implementation/gl-enums-queries.ads @@ -0,0 +1,24 @@ +-- part of OpenGLAda, (c) 2017 Felix Krause +-- released under the terms of the MIT license, see the file "COPYING" + +private with GL.Low_Level; + +package GL.Enums.Queries is + pragma Preelaborate; + + -- Texture_Kind is declared in GL.Low_Level.Enums to be accessible for + -- OpenCLAda + + type Parameter is (Time_Elapsed, Samples_Passed, Any_Samples_Passed, + Transform_Feedback_Primitives_Written); + + -- needs to be declared here because of subtypes + for Parameter use (Time_Elapsed => 16#88BF#, + Samples_Passed => 16#8914#, + Any_Samples_Passed => 16#8C2F#, + Transform_Feedback_Primitives_Written => 16#8C88#); + for Parameter'Size use Low_Level.Enum'Size; + +private + +end GL.Enums.Queries; diff --git a/src/gl/implementation/gl-fixed-lighting.adb b/src/gl/implementation/gl-fixed-lighting.adb index da65ad83..223c084e 100644 --- a/src/gl/implementation/gl-fixed-lighting.adb +++ b/src/gl/implementation/gl-fixed-lighting.adb @@ -12,7 +12,8 @@ package body GL.Fixed.Lighting is function Light (Index : Light_Index) return Light_Object is begin - return Lights (Index).all; + return Light_Object'(Identifier => Toggles.Toggle'Val ( + Toggles.Toggle'Pos (Toggles.Light0) + Index)); end Light; procedure Enable_Lighting is @@ -194,7 +195,8 @@ package body GL.Fixed.Lighting is Raise_Exception_On_OpenGL_Error; end Set_Spot_Direction; - function Spot_Direction (Source : Light_Object) return Types.Singles.Vector3 is + function Spot_Direction (Source : Light_Object) + return Types.Singles.Vector3 is Value : Singles.Vector3; begin API.Get_Light_Direction (Source.Identifier, Enums.Spot_Direction, diff --git a/src/gl/implementation/gl-low_level-enums.ads b/src/gl/implementation/gl-low_level-enums.ads index 687e1dd2..5cad17bc 100644 --- a/src/gl/implementation/gl-low_level-enums.ads +++ b/src/gl/implementation/gl-low_level-enums.ads @@ -26,9 +26,9 @@ package GL.Low_Level.Enums is type Buffer_Kind is (Array_Buffer, Element_Array_Buffer, Pixel_Pack_Buffer, Pixel_Unpack_Buffer, Uniform_Buffer, Texture_Buffer, - Transform_Feedback_Buffer, Copy_Read_Buffer, - Copy_Write_Buffer, Draw_Indirect_Buffer, - Atomic_Counter_Buffer); + Transform_Feedback_Buffer, Transform_Feedback, + Copy_Read_Buffer, Copy_Write_Buffer, + Draw_Indirect_Buffer, Atomic_Counter_Buffer); type Draw_Buffer_Index is (DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, DB13, DB14, DB15); @@ -37,6 +37,10 @@ package GL.Low_Level.Enums is type Only_Stencil_Buffer is (Stencil); type Only_Depth_Stencil_Buffer is (Depth_Stencil); type Only_Color_Buffer is (Color); + + type Query_Param is (Time_Elapsed, Samples_Passed, Any_Samples_Passed, + Transform_Feedback_Primitives_Written); + type Query_Results is (Query_Result, Query_Result_Available); private for Texture_Kind use (Texture_1D => 16#0DE0#, Texture_2D => 16#0DE1#, @@ -74,6 +78,7 @@ private Uniform_Buffer => 16#8A11#, Texture_Buffer => 16#8C2A#, Transform_Feedback_Buffer => 16#8C8E#, + Transform_Feedback => 16#8E22#, Copy_Read_Buffer => 16#8F36#, Copy_Write_Buffer => 16#8F37#, Draw_Indirect_Buffer => 16#8F3F#, @@ -109,4 +114,14 @@ private for Only_Color_Buffer use (Color => 16#1800#); for Only_Color_Buffer'Size use Enum'Size; + + for Query_Param use (Time_Elapsed => 16#88BF#, + Samples_Passed => 16#8914#, + Any_Samples_Passed => 16#8C2F#, + Transform_Feedback_Primitives_Written => 16#8C88#); + for Query_Param'Size use Low_Level.Enum'Size; + + for Query_Results use (Query_Result => 16#8866#, + Query_Result_Available => 16#8867#); + for Query_Results'Size use Low_Level.Enum'Size; end GL.Low_Level.Enums; diff --git a/src/gl/implementation/gl-objects-buffers.adb b/src/gl/implementation/gl-objects-buffers.adb index 7376be05..d6c0e85e 100644 --- a/src/gl/implementation/gl-objects-buffers.adb +++ b/src/gl/implementation/gl-objects-buffers.adb @@ -1,7 +1,7 @@ -- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" -with Ada.Containers.Indefinite_Hashed_Maps; +with Ada.Containers.Indefinite_Ordered_Maps; with Ada.Unchecked_Conversion; with System; @@ -12,23 +12,20 @@ with GL.Enums; package body GL.Objects.Buffers is use type Low_Level.Enums.Buffer_Kind; - function Hash (Key : Low_Level.Enums.Buffer_Kind) - return Ada.Containers.Hash_Type is - function Value is new Ada.Unchecked_Conversion - (Source => Low_Level.Enums.Buffer_Kind, Target => Low_Level.Enum); - begin - return Ada.Containers.Hash_Type (Value (Key)); - end Hash; - - package Buffer_Maps is new Ada.Containers.Indefinite_Hashed_Maps + package Buffer_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => Low_Level.Enums.Buffer_Kind, - Element_Type => Buffer'Class, - Hash => Hash, - Equivalent_Keys => Low_Level.Enums."="); + Element_Type => Buffer'Class); use type Buffer_Maps.Cursor; Current_Buffers : Buffer_Maps.Map; + package Transform_Buffer_Maps is new Ada.Containers.Indefinite_Ordered_Maps + (Key_Type => Low_Level.Enums.Buffer_Kind, + Element_Type => Transform_Buffer'Class); + use type Transform_Buffer_Maps.Cursor; + + Current_Transform_Buffers : Transform_Buffer_Maps.Map; + procedure Bind (Target : Buffer_Target; Object : Buffer'Class) is Cursor : constant Buffer_Maps.Cursor := Current_Buffers.Find (Target.Kind); @@ -46,6 +43,25 @@ package body GL.Objects.Buffers is end if; end Bind; + procedure Bind_Transform_Feedback (Object : Transform_Buffer'Class) is + Target_Kind : constant GL.Low_Level.Enums.Buffer_Kind := + GL.Low_Level.Enums.Transform_Feedback; + Cursor : constant Transform_Buffer_Maps.Cursor + := Current_Transform_Buffers.Find (Target_Kind); + begin + if Cursor = Transform_Buffer_Maps.No_Element or else + Transform_Buffer_Maps.Element (Cursor).Reference.GL_Id /= Object.Reference.GL_Id + then + API.Bind_Transform_Feedback (Target_Kind, Object.Reference.GL_Id); + Raise_Exception_On_OpenGL_Error; + if Cursor = Transform_Buffer_Maps.No_Element then + Current_Transform_Buffers.Insert (Target_Kind, Object); + else + Current_Transform_Buffers.Replace_Element (Cursor, Object); + end if; + end if; + end Bind_Transform_Feedback; + procedure Bind_Buffer_Base (Target : Buffer_Target; Index : UInt; Object : Buffer'Class) is Cursor : constant Buffer_Maps.Cursor @@ -148,6 +164,21 @@ package body GL.Objects.Buffers is Raise_Exception_On_OpenGL_Error; end Draw_Elements_Base_Vertex; + procedure Draw_Transform_Feedback (Mode : Connection_Mode; + Object : Transform_Buffer) is + begin + API.Draw_Transform_Feedback (Mode, Object.Reference.GL_Id); + Raise_Exception_On_OpenGL_Error; + end Draw_Transform_Feedback; + + procedure Draw_Transform_Feedback_Stream (Mode : Connection_Mode; + Object : Transform_Buffer; + Stream : UInt) is + begin + API.Draw_Transform_Feedback_Stream (Mode, Object.Reference.GL_Id, Stream); + Raise_Exception_On_OpenGL_Error; + end Draw_Transform_Feedback_Stream; + procedure Map (Target : Buffer_Target'Class; Access_Type : Access_Kind; Pointer : out Pointers.Pointer) is function To_Pointer is new Ada.Unchecked_Conversion @@ -157,12 +188,36 @@ package body GL.Objects.Buffers is Raise_Exception_On_OpenGL_Error; end Map; + procedure Map_Range (Target : Buffer_Target'Class; + Access_Type : Map_Bits; + Offset : Int; + Size : Types.Size; + Pointer : out Pointers.Pointer) is + function To_Pointer is new Ada.Unchecked_Conversion + (System.Address, Pointers.Pointer); + function To_BitField is new Ada.Unchecked_Conversion + (Map_Bits, GL.Low_Level.Bitfield); + begin + Pointer := To_Pointer + (API.Map_Buffer_Range (Target.Kind, Low_Level.IntPtr (Offset), + Low_Level.SizeIPtr (Size), To_BitField (Access_Type))); + Raise_Exception_On_OpenGL_Error; + end Map_Range; + procedure Unmap (Target : Buffer_Target) is begin API.Unmap_Buffer (Target.Kind); Raise_Exception_On_OpenGL_Error; end Unmap; + procedure Flush_Mapped_Buffer_Range (Target : Buffer_Target'Class; + Offset : Int; Size : Types.Size) is + begin + API.Flush_Mapped_Buffer_Range (Target.Kind, Low_Level.IntPtr (Offset), + Low_Level.SizeIPtr (Size)); + Raise_Exception_On_OpenGL_Error; + end Flush_Mapped_Buffer_Range; + function Pointer (Target : Buffer_Target'Class) return Pointers.Pointer is function To_Pointer is new Ada.Unchecked_Conversion (System.Address, Pointers.Pointer); @@ -183,6 +238,16 @@ package body GL.Objects.Buffers is Data (Data'First)'Address); Raise_Exception_On_OpenGL_Error; end Set_Sub_Data; + + procedure Get_Sub_Data (Target : Buffer_Target'Class; + Offset : Types.Int; + Data : out Types.Single_Array) is + begin + Data := (others => <>); + API.Get_Buffer_Sub_Data (Target.Kind, Low_Level.IntPtr (Offset), + Low_Level.SizeIPtr (Data'Size / 8), Data'Address); + Raise_Exception_On_OpenGL_Error; + end Get_Sub_Data; function Access_Type (Target : Buffer_Target) return Access_Kind is Ret : Access_Kind := Access_Kind'First; @@ -225,6 +290,14 @@ package body GL.Objects.Buffers is Raise_Exception_On_OpenGL_Error; end Internal_Create_Id; + overriding + procedure Internal_Create_Id (Object : Transform_Buffer; Id : out UInt) is + pragma Unreferenced (Object); + begin + API.Gen_Transform_Feedbacks (1, Id); + Raise_Exception_On_OpenGL_Error; + end Internal_Create_Id; + overriding procedure Internal_Release_Id (Object : Buffer; Id : UInt) is pragma Unreferenced (Object); @@ -233,6 +306,14 @@ package body GL.Objects.Buffers is Raise_Exception_On_OpenGL_Error; end Internal_Release_Id; + overriding + procedure Internal_Release_Id (Object : Transform_Buffer; Id : UInt) is + pragma Unreferenced (Object); + begin + API.Delete_Transform_Feedbacks (1, (1 => Id)); + Raise_Exception_On_OpenGL_Error; + end Internal_Release_Id; + procedure Invalidate_Data (Object : in out Buffer) is begin API.Invalidate_Buffer_Data (Object.Reference.GL_Id); diff --git a/src/gl/implementation/gl-objects-programs.adb b/src/gl/implementation/gl-objects-programs.adb index 87290959..e4a968b6 100644 --- a/src/gl/implementation/gl-objects-programs.adb +++ b/src/gl/implementation/gl-objects-programs.adb @@ -153,16 +153,16 @@ package body GL.Objects.Programs is function Transform_Feedback_Buffer_Mode (Object : Program) return Buffer_Mode is Program_Buffer_Mode_Param : constant Buffer_Mode := - Buffer_Mode'Enum_Val - (Program_Int_Param (Object, Enums.Transform_Feedback_Buffer_Mode)); + Buffer_Mode'Enum_Val + (Program_Int_Param (Object, Enums.Transform_Feedback_Buffer_Mode)); begin return Program_Buffer_Mode_Param; end Transform_Feedback_Buffer_Mode; - function Transform_Feedback_Varyings (Object : Program) return Size is + function Transform_Feedback_Varyings_Size (Object : Program) return Size is begin return Program_Size_Param (Object, Enums.Transform_Feedback_Varyings); - end Transform_Feedback_Varyings; + end Transform_Feedback_Varyings_Size; function Transform_Feedback_Varying_Max_Length (Object : Program) return Size is @@ -184,13 +184,30 @@ package body GL.Objects.Programs is end End_Transform_Feedback; procedure Get_Transform_Feedback_Varying - (Object : Program; Index, Buffer_Size, Length, V_Length : Integer; - V_Type : Buffer_Mode; Name : String) is - begin - API.Get_Transform_Feedback_Varying - (Object.Reference.GL_Id, Int (Index), Size (Buffer_Size), Size (Length), - Size (V_Length), V_Type, Interfaces.C.To_C (Name)); - Raise_Exception_On_OpenGL_Error; + (Object : Program; Index : Int; Length, V_Length : out Size; + V_Type : out Active_Attribute; Name : out String) is + use Interfaces.C; + Buffer_Size : constant Size := Name'Length + 1; + C_Name : Interfaces.C.char_array (1 .. size_t (Buffer_Size + 1)); + begin + if Buffer_Size > 1 then + V_Length := Transform_Feedback_Varyings_Size (Object); + if V_Length > 0 and then + Transform_Feedback_Varying_Max_Length (Object) > 0 then + API.Get_Transform_Feedback_Varying + (Object.Reference.GL_Id, Index, Buffer_Size, + Length, V_Length, V_Type, C_Name); + Raise_Exception_On_OpenGL_Error; + Name (Name'First .. Name'First + Integer (Length) - 1) := + Interfaces.C.To_Ada (C_Name); + else + raise Constraint_Error with + "Get_Transform_Feedback_Varying, Max_Length or V_Length is 0"; + end if; + else + raise Constraint_Error with + "Get_Transform_Feedback_Varying, String must have at least one character"; + end if; end Get_Transform_Feedback_Varying; procedure Transform_Feedback_Varyings @@ -199,18 +216,18 @@ package body GL.Objects.Programs is use type Interfaces.C.char; Parameter_Buffer : Interfaces.C.char_array := - Interfaces.C.To_C (Varyings); - Pointer_Array : Low_Level.Char_Access_Array + Interfaces.C.To_C (Varyings); + Pointer_Array : Low_Level.Char_Access_Array (1 .. Parameter_Buffer'Length / 2); - -- cannot be longer than this if every name has a length of at least 1 - Pointer_Count : Size := 0; + -- cannot be longer than this if every name has a length of at least 1 + Pointer_Count : Size := 0; Recent_Was_Comma : Boolean := True; begin for Pos in Parameter_Buffer'First .. Parameter_Buffer'Last - 1 loop if Parameter_Buffer (Pos) = ',' then if Recent_Was_Comma then raise Constraint_Error with - "every varying name must have at least one character"; + "Get_Transform_Feedback_Varying, every varying name must have at least one character"; end if; Parameter_Buffer (Pos) := Interfaces.C.nul; Recent_Was_Comma := True; @@ -344,8 +361,8 @@ package body GL.Objects.Programs is end Uniform_Location; procedure Bind_Attrib_Location (Subject : Program; - Index : Attributes.Attribute; - Name : String) is + Index : Attributes.Attribute; + Name : String) is begin API.Bind_Attrib_Location (Subject.Reference.GL_Id, Index, Interfaces.C.To_C (Name)); @@ -379,7 +396,7 @@ package body GL.Objects.Programs is procedure Bind_Frag_Data_Location (Object : Program; Color_Number : Buffers.Draw_Buffer_Index; - Name : String) is + Name : String) is begin API.Bind_Frag_Data_Location (Object.Reference.GL_Id, Color_Number, C.To_C (Name)); diff --git a/src/gl/implementation/gl-objects-queries.adb b/src/gl/implementation/gl-objects-queries.adb new file mode 100644 index 00000000..d9fc4856 --- /dev/null +++ b/src/gl/implementation/gl-objects-queries.adb @@ -0,0 +1,71 @@ +-- part of OpenGLAda, (c) 2017 Felix Krause +-- released under the terms of the MIT license, see the file "COPYING" + +with GL.API; + +package body GL.Objects.Queries is + + procedure Begin_Query (Target : GL.Low_Level.Enums.Query_Param; + Object : Query_Object) is + begin + API.Begin_Query (Target, Object.Reference.GL_Id); + Raise_Exception_On_OpenGL_Error; + end Begin_Query; + + procedure End_Query (Target : GL.Low_Level.Enums.Query_Param) is + begin + API.End_Query (Target); + Raise_Exception_On_OpenGL_Error; + end End_Query; + + procedure Begin_Query_Indexed (Target : GL.Low_Level.Enums.Query_Param; + Index : UInt; Object : Query_Object) is + begin + API.Begin_Query_Indexed (Target, Index, Object.Reference.GL_Id); + Raise_Exception_On_OpenGL_Error; + end Begin_Query_Indexed; + + procedure End_Query_Indexed (Target : GL.Low_Level.Enums.Query_Param; + Index : UInt) is + begin + API.End_Query_Indexed (Target, Index); + Raise_Exception_On_OpenGL_Error; + end End_Query_Indexed; + + procedure Get_Query_Object + (Object : Query_Object; Pname : GL.Low_Level.Enums.Query_Results; + Params : out UInt) is + begin + API.Get_Query_Object (Object.Reference.GL_Id, Pname, Params); + Raise_Exception_On_OpenGL_Error; + end Get_Query_Object; + + overriding + procedure Internal_Create_Id (Object : Query_Object; Id : out UInt) is + pragma Unreferenced (Object); + begin + API.Gen_Queries (1, Id); + Raise_Exception_On_OpenGL_Error; + end Internal_Create_Id; + + overriding + procedure Internal_Release_Id (Object : Query_Object; Id : UInt) is + pragma Unreferenced (Object); + begin + API.Delete_Queries (1, (1 => Id)); + Raise_Exception_On_OpenGL_Error; + end Internal_Release_Id; + + function Is_Query (Query : Query_Object) return Boolean is + begin + return API.Is_Query (Raw_Id (Query)); + end Is_Query; + + procedure Query_Counter (Object : Query_Object; + Target : Low_Level.Enums.Query_Param) is + begin + API.Query_Counter (Object.Reference.GL_Id, Target); + Raise_Exception_On_OpenGL_Error; + end Query_Counter; + +end GL.Objects.Queries; diff --git a/src/gl/implementation/gl-objects-shaders.adb b/src/gl/implementation/gl-objects-shaders.adb index ce131fdb..e51d2691 100644 --- a/src/gl/implementation/gl-objects-shaders.adb +++ b/src/gl/implementation/gl-objects-shaders.adb @@ -10,7 +10,7 @@ package body GL.Objects.Shaders is C_Source : C.char_array := C.To_C (Source); begin API.Shader_Source (Subject.Reference.GL_Id, 1, - (1 => C_Source (C_Source'First)'Unchecked_Access), + (1 => C_Source (0)'Unchecked_Access), (1 => Source'Length)); Raise_Exception_On_OpenGL_Error; end Set_Source; @@ -96,7 +96,7 @@ package body GL.Objects.Shaders is API.Get_Shader_Type (Id, Enums.Shader_Type, Kind); Raise_Exception_On_OpenGL_Error; return Object : Shader (Kind) do - Object.Set_Raw_Id (Id); + Object.Set_Raw_Id (Id, False); end return; end Create_From_Id; diff --git a/src/gl/implementation/gl-objects-textures-with_1d_loader.adb b/src/gl/implementation/gl-objects-textures-with_1d_loader.adb index 4f154c2f..5d27fc5b 100644 --- a/src/gl/implementation/gl-objects-textures-with_1d_loader.adb +++ b/src/gl/implementation/gl-objects-textures-with_1d_loader.adb @@ -13,7 +13,8 @@ package body GL.Objects.Textures.With_1D_Loader is Width : Types.Size) is begin API.Tex_Image_1D (Texture_Proxy (Object).Kind, Level, Internal_Format, - Width, 0, Pixels.Red, + Width, 0, + Format_For_Loading_Empty_Texture (Internal_Format), Pixels.Data_Type'First, Image_Source (System.Null_Address)); Raise_Exception_On_OpenGL_Error; diff --git a/src/gl/implementation/gl-objects-textures-with_2d_loader.adb b/src/gl/implementation/gl-objects-textures-with_2d_loader.adb index 15ed89d2..347c4fec 100644 --- a/src/gl/implementation/gl-objects-textures-with_2d_loader.adb +++ b/src/gl/implementation/gl-objects-textures-with_2d_loader.adb @@ -13,11 +13,10 @@ package body GL.Objects.Textures.With_2D_Loader is Width, Height : Types.Size) is begin API.Tex_Image_2D (Texture_Proxy (Object).Kind, Level, Internal_Format, - Width, Height, 0, Pixels.Red, + Width, Height, 0, + Format_For_Loading_Empty_Texture (Internal_Format), Pixels.Data_Type'First, Image_Source (System.Null_Address)); - --raise Program_Error with "Kind => " & Texture_Proxy (Object).Kind'Img & - -- ", Type => " & Pixels.Data_Type'First'Img; Raise_Exception_On_OpenGL_Error; end Load_Empty_Texture; diff --git a/src/gl/implementation/gl-objects-textures-with_3d_loader.adb b/src/gl/implementation/gl-objects-textures-with_3d_loader.adb index e65ac21f..5067f05b 100644 --- a/src/gl/implementation/gl-objects-textures-with_3d_loader.adb +++ b/src/gl/implementation/gl-objects-textures-with_3d_loader.adb @@ -13,7 +13,8 @@ package body GL.Objects.Textures.With_3D_Loader is Width, Height, Depth : Types.Size) is begin API.Tex_Image_3D (Texture_Proxy (Object).Kind, Level, Internal_Format, - Width, Height, Depth, 0, Pixels.Red, + Width, Height, Depth, 0, + Format_For_Loading_Empty_Texture (Internal_Format), Pixels.Data_Type'First, Image_Source (System.Null_Address)); Raise_Exception_On_OpenGL_Error; diff --git a/src/gl/implementation/gl-objects-textures.adb b/src/gl/implementation/gl-objects-textures.adb index c665d9a8..44dd1764 100644 --- a/src/gl/implementation/gl-objects-textures.adb +++ b/src/gl/implementation/gl-objects-textures.adb @@ -74,8 +74,8 @@ package body GL.Objects.Textures is return Pixels.Channel_Data_Type is Ret : Pixels.Channel_Data_Type; begin - API.Get_Tex_Level_Parameter_Type (Object.Kind, Level, - Enums.Textures.Blue_Type, Ret); + API.Get_Tex_Level_Parameter_Type (Object.Kind, Level, + Enums.Textures.Blue_Type, Ret); Raise_Exception_On_OpenGL_Error; return Ret; end Blue_Type; @@ -178,7 +178,7 @@ package body GL.Objects.Textures is end Raw_Kind; function Hash (Key : Low_Level.Enums.Texture_Kind) - return Ada.Containers.Hash_Type is + return Ada.Containers.Hash_Type is function Value is new Ada.Unchecked_Conversion (Source => Low_Level.Enums.Texture_Kind, Target => Low_Level.Enum); begin @@ -186,10 +186,10 @@ package body GL.Objects.Textures is end Hash; package Texture_Maps is new Ada.Containers.Indefinite_Hashed_Maps - (Key_Type => Low_Level.Enums.Texture_Kind, - Element_Type => Texture'Class, - Hash => Hash, - Equivalent_Keys => Low_Level.Enums."="); + (Key_Type => Low_Level.Enums.Texture_Kind, + Element_Type => Texture'Class, + Hash => Hash, + Equivalent_Keys => Low_Level.Enums."="); use type Texture_Maps.Cursor; Current_Textures : Texture_Maps.Map; @@ -200,7 +200,7 @@ package body GL.Objects.Textures is begin if Cursor = Texture_Maps.No_Element or else Texture_Maps.Element (Cursor).Reference.GL_Id /= Object.Reference.GL_Id - then + then API.Bind_Texture (Target.Kind, Object.Reference.GL_Id); Raise_Exception_On_OpenGL_Error; if Cursor = Texture_Maps.No_Element then @@ -252,7 +252,7 @@ package body GL.Objects.Textures is Raise_Exception_On_OpenGL_Error; end Invalidate_Image; - procedure Invalidate_Sub_Image (Object : Texture; Level : Mipmap_Level; + procedure Invalidate_Sub_Image (Object : Texture; Level : Mipmap_Level; X, Y, Z : Int; Width, Height, Depth : Size) is begin @@ -336,7 +336,7 @@ package body GL.Objects.Textures is end Maximum_LoD; procedure Set_Lowest_Mipmap_Level (Target : Texture_Target; - Level : Mipmap_Level) is + Level : Mipmap_Level) is begin API.Tex_Parameter_Int (Target.Kind, Enums.Textures.Base_Level, Level); Raise_Exception_On_OpenGL_Error; @@ -352,7 +352,7 @@ package body GL.Objects.Textures is end Lowest_Mipmap_Level; procedure Set_Highest_Mipmap_Level (Target : Texture_Target; - Level : Mipmap_Level) is + Level : Mipmap_Level) is begin API.Tex_Parameter_Int (Target.Kind, Enums.Textures.Max_Level, Level); Raise_Exception_On_OpenGL_Error; @@ -435,7 +435,7 @@ package body GL.Objects.Textures is end Border_Color; procedure Set_Texture_Priority (Target : Texture_Target; - Value : Priority) is + Value : Priority) is begin API.Tex_Parameter_Float (Target.Kind, Enums.Textures.Priority, Single (Value)); @@ -485,7 +485,7 @@ package body GL.Objects.Textures is end Set_Compare_Function; function Current_Compare_Function (Target : Texture_Target) - return Compare_Function is + return Compare_Function is Value : Compare_Function; begin API.Get_Tex_Parameter_Comp_Func (Target.Kind, Enums.Textures.Compare_Func, @@ -495,7 +495,7 @@ package body GL.Objects.Textures is end Current_Compare_Function; procedure Set_Depth_Texture_Mode (Target : Texture_Target; - Mode : Depth_Mode) is + Mode : Depth_Mode) is begin API.Tex_Parameter_Depth_Mode (Target.Kind, Enums.Textures.Depth, Mode); Raise_Exception_On_OpenGL_Error; @@ -510,7 +510,7 @@ package body GL.Objects.Textures is return Value; end Depth_Texture_Mode; - procedure Toggle_Mipmap_Autoupdate (Target : Texture_Target; + procedure Toggle_Mipmap_Autoupdate (Target : Texture_Target; Enabled : Boolean) is begin API.Tex_Parameter_Bool (Target.Kind, Enums.Textures.Generate_Mipmap, @@ -542,8 +542,8 @@ package body GL.Objects.Textures is procedure Set_Active_Unit (Unit : Texture_Unit) is package Texture_Indexing is new Enums.Indexes - (Enums.Textures.Texture_Unit_Start_Rep, - Enums.Getter.Max_Combined_Texture_Image_Units); + (Enums.Textures.Texture_Unit_Start_Rep, + Enums.Getter.Max_Combined_Texture_Image_Units); begin API.Active_Texture (Texture_Indexing.Representation (Unit)); Raise_Exception_On_OpenGL_Error; @@ -551,8 +551,8 @@ package body GL.Objects.Textures is function Active_Unit return Texture_Unit is package Texture_Indexing is new Enums.Indexes - (Enums.Textures.Texture_Unit_Start_Rep, - Enums.Getter.Max_Combined_Texture_Image_Units); + (Enums.Textures.Texture_Unit_Start_Rep, + Enums.Getter.Max_Combined_Texture_Image_Units); Raw_Unit : aliased Int := Enums.Textures.Texture_Unit_Start_Rep; begin @@ -568,4 +568,14 @@ package body GL.Objects.Textures is return Natural (Count); end Texture_Unit_Count; + function Format_For_Loading_Empty_Texture + (Internal_Format : Pixels.Internal_Format) return Pixels.Data_Format is + use GL.Pixels; + begin + case Internal_Format is + when Depth_Component | Depth_Component16 | Depth_Component24 | + Depth_Component32 => return Depth_Component; + when others => return Red; + end case; + end Format_For_Loading_Empty_Texture; end GL.Objects.Textures; diff --git a/src/gl/implementation/gl-rasterization.adb b/src/gl/implementation/gl-rasterization.adb index 832556bf..71710630 100644 --- a/src/gl/implementation/gl-rasterization.adb +++ b/src/gl/implementation/gl-rasterization.adb @@ -59,6 +59,12 @@ package body GL.Rasterization is return Ret; end Polygon_Mode; + procedure Set_Polygon_Offset (Factor, Units : Single := 0.0) is + begin + API.Set_Polygon_Offset (Factor, Units); + Raise_Exception_On_OpenGL_Error; + end Set_Polygon_Offset; + procedure Set_Point_Size (Value : Single) is begin API.Set_Point_Size (Value); diff --git a/src/gl/interface/gl-fixed-lighting.ads b/src/gl/interface/gl-fixed-lighting.ads index 031d72be..b5d60055 100644 --- a/src/gl/interface/gl-fixed-lighting.ads +++ b/src/gl/interface/gl-fixed-lighting.ads @@ -57,7 +57,8 @@ package GL.Fixed.Lighting is procedure Set_Specular (Source : Light_Object; Color : Colors.Color); function Specular (Source : Light_Object) return Colors.Color; - procedure Set_Position (Source : Light_Object; Position : Types.Singles.Vector4); + procedure Set_Position (Source : Light_Object; + Position : Types.Singles.Vector4); function Position (Source : Light_Object) return Types.Singles.Vector4; procedure Set_Spot_Direction (Source : Light_Object; @@ -71,16 +72,6 @@ package GL.Fixed.Lighting is private type Light_Object (Identifier : Toggles.Toggle) is tagged null record; - Lights : constant array (Light_Index) of access constant Light_Object := - (0 => new Light_Object'(Identifier => Toggles.Light0), - 1 => new Light_Object'(Identifier => Toggles.Light1), - 2 => new Light_Object'(Identifier => Toggles.Light2), - 3 => new Light_Object'(Identifier => Toggles.Light3), - 4 => new Light_Object'(Identifier => Toggles.Light4), - 5 => new Light_Object'(Identifier => Toggles.Light5), - 6 => new Light_Object'(Identifier => Toggles.Light6), - 7 => new Light_Object'(Identifier => Toggles.Light7)); - for Color_Control use (Single_Color => 16#81F9#, Separate_Specular_Color => 16#81FA#); for Color_Control'Size use Low_Level.Enum'Size; @@ -89,4 +80,4 @@ private Smooth => 16#1D01#); for Shade_Model'Size use Low_Level.Enum'Size; -end GL.Fixed.Lighting; \ No newline at end of file +end GL.Fixed.Lighting; diff --git a/src/gl/interface/gl-framebuffer.ads b/src/gl/interface/gl-framebuffer.ads index 9d52abba..8869e665 100644 --- a/src/gl/interface/gl-framebuffer.ads +++ b/src/gl/interface/gl-framebuffer.ads @@ -17,7 +17,7 @@ package GL.Framebuffer is Copy_Inverted, Or_Inverted, Nand, Set); subtype Read_Buffer_Selector is Buffers.Color_Buffer_Selector range - Buffers.Front_Left .. Buffers.Right; + Buffers.None .. Buffers.Right; -- this package provides functionality the works implicitly on the current -- framebuffer. for working with framebuffer objects, diff --git a/src/gl/interface/gl-objects-buffers.ads b/src/gl/interface/gl-objects-buffers.ads index edb468ba..29e48b98 100644 --- a/src/gl/interface/gl-objects-buffers.ads +++ b/src/gl/interface/gl-objects-buffers.ads @@ -3,6 +3,7 @@ with Interfaces.C.Pointers; +with GL.Low_Level; private with GL.Low_Level.Enums; with GL.Pixels; @@ -13,11 +14,26 @@ package GL.Objects.Buffers is Static_Draw, Static_Read, Static_Copy, Dynamic_Draw, Dynamic_Read, Dynamic_Copy); + type Map_Bits is record + Read : Boolean := False; + Write : Boolean := False; + Invalidate_Range : Boolean := False; + Invalidate_Buffer : Boolean := False; + Flush_Explicit : Boolean := False; + Unsynchronized : Boolean := False; + Persistent : Boolean := False; + Coherent : Boolean := False; + Unused : Boolean := False; + end record; + pragma Convention (C, Map_Bits); + type Buffer_Target (<>) is tagged limited private; type Buffer is new GL_Object with private; + type Transform_Buffer is new GL_Object with private; procedure Bind (Target : Buffer_Target; Object : Buffer'Class); + procedure Bind_Transform_Feedback (Object : Transform_Buffer'Class); procedure Bind_Buffer_Base (Target : Buffer_Target; Index : UInt; Object : Buffer'Class); @@ -37,7 +53,17 @@ package GL.Objects.Buffers is with package Pointers is new Interfaces.C.Pointers (<>); procedure Map (Target : Buffer_Target'Class; Access_Type : Access_Kind; Pointer : out Pointers.Pointer); + generic + with package Pointers is new Interfaces.C.Pointers (<>); + procedure Map_Range (Target : Buffer_Target'Class; + Access_Type : Map_Bits; + Offset : Int; + Size : Types.Size; + Pointer : out Pointers.Pointer); + procedure Unmap (Target : Buffer_Target); + procedure Flush_Mapped_Buffer_Range (Target : Buffer_Target'Class; + Offset : Int; Size : Types.Size); generic with package Pointers is new Interfaces.C.Pointers (<>); @@ -49,6 +75,10 @@ package GL.Objects.Buffers is Offset : Types.Size; Data : Pointers.Element_Array); + procedure Get_Sub_Data (Target : Buffer_Target'Class; + Offset : Types.Int; + Data : out Types.Single_Array); + function Access_Type (Target : Buffer_Target) return Access_Kind; function Mapped (Target : Buffer_Target) return Boolean; function Size (Target : Buffer_Target) return Size; @@ -84,12 +114,18 @@ package GL.Objects.Buffers is Index_Type : Unsigned_Numeric_Type; Element_Offset : UInt; Base_Vertex : Int); + procedure Draw_Transform_Feedback (Mode : Connection_Mode; + Object : Transform_Buffer); + procedure Draw_Transform_Feedback_Stream (Mode : Connection_Mode; + Object : Transform_Buffer; + Stream : UInt); procedure Invalidate_Data (Object : in out Buffer); procedure Invalidate_Sub_Data (Object : in out Buffer; Offset, Length : Long_Size); type Texture_Buffer_Target is limited new Buffer_Target with private; + type Transform_Buffer_Target is limited new Buffer_Target with private; procedure Allocate (Target : Texture_Buffer_Target; Format : GL.Pixels.Internal_Format; Object : Buffer'Class); @@ -100,7 +136,7 @@ package GL.Objects.Buffers is Pixel_Unpack_Buffer : constant Buffer_Target; Uniform_Buffer : constant Buffer_Target; Texture_Buffer : constant Texture_Buffer_Target; - Transform_Feedback_Buffer : constant Buffer_Target; + Transform_Feedback_Buffer : constant Transform_Buffer_Target; Copy_Read_Buffer : constant Buffer_Target; Copy_Write_Buffer : constant Buffer_Target; Draw_Indirect_Buffer : constant Buffer_Target; @@ -118,17 +154,36 @@ private Dynamic_Copy => 16#88EA#); for Buffer_Usage'Size use Low_Level.Enum'Size; + for Map_Bits use record + Read at 0 range 0 .. 0; + Write at 0 range 1 .. 1; + Invalidate_Range at 0 range 2 .. 2; + Invalidate_Buffer at 0 range 3 .. 3; + Flush_Explicit at 0 range 4 .. 4; + Unsynchronized at 0 range 5 .. 5; + Persistent at 0 range 6 .. 6; + Coherent at 0 range 7 .. 7; + Unused at 0 range 8 .. 31; + end record; + for Map_Bits'Size use Low_Level.Bitfield'Size; + type Buffer_Target (Kind : Low_Level.Enums.Buffer_Kind) is tagged limited null record; type Texture_Buffer_Target is limited new Buffer_Target with null record; + type Transform_Buffer_Target is limited new Buffer_Target with null record; type Buffer is new GL_Object with null record; + type Transform_Buffer is new GL_Object with null record; overriding procedure Internal_Create_Id (Object : Buffer; Id : out UInt); + overriding + procedure Internal_Create_Id (Object : Transform_Buffer; Id : out UInt); overriding procedure Internal_Release_Id (Object : Buffer; Id : UInt); + overriding + procedure Internal_Release_Id (Object : Transform_Buffer; Id : UInt); Array_Buffer : constant Buffer_Target := Buffer_Target'(Kind => Low_Level.Enums.Array_Buffer); @@ -142,8 +197,8 @@ private := Buffer_Target'(Kind => Low_Level.Enums.Uniform_Buffer); Texture_Buffer : constant Texture_Buffer_Target := Texture_Buffer_Target'(Kind => Low_Level.Enums.Texture_Buffer); - Transform_Feedback_Buffer : constant Buffer_Target - := Buffer_Target'(Kind => Low_Level.Enums.Transform_Feedback_Buffer); + Transform_Feedback_Buffer : constant Transform_Buffer_Target + := Transform_Buffer_Target'(Kind => Low_Level.Enums.Transform_Feedback_Buffer); Copy_Read_Buffer : constant Buffer_Target := Buffer_Target'(Kind => Low_Level.Enums.Copy_Read_Buffer); Copy_Write_Buffer : constant Buffer_Target diff --git a/src/gl/interface/gl-objects-programs.ads b/src/gl/interface/gl-objects-programs.ads index c0444edd..457f2e5d 100644 --- a/src/gl/interface/gl-objects-programs.ads +++ b/src/gl/interface/gl-objects-programs.ads @@ -20,6 +20,16 @@ package GL.Objects.Programs is type Program is new GL_Object with private; + type Active_Attribute is (Int_Type, Unsigned_Int_Type, + Float_Vec2_Type, Float_Vec3_Type, Float_Vec4_Type, + Int_Vec2_Type, Int_Vec3_Type, Int_Vec4_Type, + Float_Mat2_Type, Float_Mat3_Type, Float_Mat4_Type, + Float_Mat2x3_Type, Float_Mat2x4_Type, + Float_Mat3x2_Type, Float_Mat3x4_Type, + Float_Mat4x2_Type, Float_Mat4x3_Type, + Unsigned_Int_Vec2_Type, + Unsigned_Int_Vec3_Type, Unsigned_Int_Vec4_Type); + type Tessellation_Primitive_Mode is (Triangles, Quads, Isolines); type Tessellation_Spacing is (Equal, Fractional_Odd, Fractional_Even); @@ -62,7 +72,7 @@ package GL.Objects.Programs is function Transform_Feedback_Buffer_Mode (Object : Program) return Buffer_Mode; - function Transform_Feedback_Varyings (Object : Program) return Size; + function Transform_Feedback_Varyings_Size (Object : Program) return Size; function Transform_Feedback_Varying_Max_Length (Object : Program) return Size; @@ -72,8 +82,8 @@ package GL.Objects.Programs is procedure End_Transform_Feedback; procedure Get_Transform_Feedback_Varying - (Object : Program; Index, Buffer_Size, Length, V_Length : Integer; - V_Type : Buffer_Mode; Name : String); + (Object : Program; Index : Int; Length, V_Length : out Size; + V_Type : out Active_Attribute; Name : out String); procedure Transform_Feedback_Varyings (Object : Program; Varyings : String; Mode : Buffer_Mode); @@ -149,4 +159,25 @@ private Separate_Attribs => 16#8C8D#); for Buffer_Mode'Size use Low_Level.Enum'Size; + for Active_Attribute use (Int_Type => 16#1404#, + Unsigned_Int_Type => 16#1405#, + Float_Vec2_Type => 16#8B50#, + Float_Vec3_Type => 16#8B51#, + Float_Vec4_Type => 16#8B52#, + Int_Vec2_Type => 16#8B53#, + Int_Vec3_Type => 16#8B54#, + Int_Vec4_Type => 16#8B55#, + Float_Mat2_Type => 16#8B5A#, + Float_Mat3_Type => 16#8B5C#, + Float_Mat4_Type => 16#8B5D#, + Float_Mat2x3_Type => 16#8B65#, + Float_Mat2x4_Type => 16#8B66#, + Float_Mat3x2_Type => 16#8B67#, + Float_Mat3x4_Type => 16#8B68#, + Float_Mat4x2_Type => 16#8B69#, + Float_Mat4x3_Type => 16#8B6A#, + Unsigned_Int_Vec2_Type => 16#8DC6#, + Unsigned_Int_Vec3_Type => 16#8DC7#, + Unsigned_Int_Vec4_Type => 16#8DC8#); + end GL.Objects.Programs; diff --git a/src/gl/interface/gl-objects-queries.ads b/src/gl/interface/gl-objects-queries.ads new file mode 100644 index 00000000..e57151b6 --- /dev/null +++ b/src/gl/interface/gl-objects-queries.ads @@ -0,0 +1,45 @@ +-- part of OpenGLAda, (c) 2017 Felix Krause +-- released under the terms of the MIT license, see the file "COPYING" + +with GL.Low_Level.Enums; + +package GL.Objects.Queries is + pragma Preelaborate; + + type Query_Object is new GL_Object with private; + + Default_Query : constant Query_Object; + + procedure Begin_Query (Target : GL.Low_Level.Enums.Query_Param; + Object : Query_Object); + + procedure End_Query (Target : GL.Low_Level.Enums.Query_Param); + + procedure Begin_Query_Indexed (Target : GL.Low_Level.Enums.Query_Param; + Index : UInt; Object : Query_Object); + + procedure End_Query_Indexed (Target : GL.Low_Level.Enums.Query_Param; + Index : UInt); + + procedure Get_Query_Object (Object : Query_Object; + Pname : GL.Low_Level.Enums.Query_Results; + Params : out UInt); + + function Is_Query (Query : Query_Object) return Boolean; + + procedure Query_Counter (Object : Query_Object; + Target : Low_Level.Enums.Query_Param); +private + + type Query_Object is new GL_Object with null record; + + overriding + procedure Internal_Create_Id (Object : Query_Object; Id : out UInt); + + overriding + procedure Internal_Release_Id (Object : Query_Object; Id : UInt); + + Default_Query : constant Query_Object := Query_Object'( + Ada.Finalization.Controlled with + Reference => Reference_To_Null_Object'Access); +end GL.Objects.Queries; diff --git a/src/gl/interface/gl-objects-shaders.ads b/src/gl/interface/gl-objects-shaders.ads index 911d0f99..69a944f3 100644 --- a/src/gl/interface/gl-objects-shaders.ads +++ b/src/gl/interface/gl-objects-shaders.ads @@ -22,7 +22,9 @@ package GL.Objects.Shaders is function Info_Log (Subject : Shader) return String; - -- low-level + -- low-level. creates a Shader object linking to the given OpenGL ID. + -- doesn't take ownership of the ID and therefore doesn't automatically + -- delete it when the last reference vanishes. function Create_From_Id (Id : UInt) return Shader; private type Shader (Kind : Shader_Type) is new GL_Object with null record; diff --git a/src/gl/interface/gl-objects-textures.ads b/src/gl/interface/gl-objects-textures.ads index 3705f018..a49d0992 100644 --- a/src/gl/interface/gl-objects-textures.ads +++ b/src/gl/interface/gl-objects-textures.ads @@ -44,8 +44,8 @@ package GL.Objects.Textures is subtype Mipmap_Level is Int range 0 .. Int'Last; -- Pointer to the beginning of image data. This type is not opaque so that it - -- is possible to convert addresses from other sources to it. OpenGLAda - -- provides a wrapper for SOIL to create image sources to load textures from. + -- is possible to convert addresses from other sources to it. + -- OpenGLAda provides the opengl-images.gpr extension to load image data. type Image_Source is new System.Address; ----------------------------------------------------------------------------- @@ -116,7 +116,7 @@ package GL.Objects.Textures is procedure Set_Magnifying_Filter (Target : Texture_Target; Filter : Magnifying_Function); function Magnifying_Filter (Target : Texture_Target) - return Magnifying_Function; + return Magnifying_Function; procedure Set_Minimum_LoD (Target : Texture_Target; Level : Double); function Minimum_LoD (Target : Texture_Target) return Double; @@ -125,11 +125,11 @@ package GL.Objects.Textures is function Maximum_LoD (Target : Texture_Target) return Double; procedure Set_Lowest_Mipmap_Level (Target : Texture_Target; - Level : Mipmap_Level); + Level : Mipmap_Level); function Lowest_Mipmap_Level (Target : Texture_Target) return Mipmap_Level; procedure Set_Highest_Mipmap_Level (Target : Texture_Target; - Level : Mipmap_Level); + Level : Mipmap_Level); function Highest_Mipmap_Level (Target : Texture_Target) return Mipmap_Level; procedure Set_X_Wrapping (Target : Texture_Target; Mode : Wrapping_Mode); @@ -145,7 +145,7 @@ package GL.Objects.Textures is function Border_Color (Target : Texture_Target) return Colors.Color; procedure Set_Texture_Priority (Target : Texture_Target; - Value : Priority); + Value : Priority); function Texture_Priority (Target : Texture_Target) return Priority; procedure Toggle_Compare_X_To_Texture (Target : Texture_Target; @@ -154,15 +154,15 @@ package GL.Objects.Textures is return Boolean; procedure Set_Compare_Function (Target : Texture_Target; - Func : Compare_Function); + Func : Compare_Function); function Current_Compare_Function (Target : Texture_Target) - return Compare_Function; + return Compare_Function; procedure Set_Depth_Texture_Mode (Target : Texture_Target; - Mode : Depth_Mode); + Mode : Depth_Mode); function Depth_Texture_Mode (Target : Texture_Target) return Depth_Mode; - procedure Toggle_Mipmap_Autoupdate (Target : Texture_Target; + procedure Toggle_Mipmap_Autoupdate (Target : Texture_Target; Enabled : Boolean); function Mipmap_Autoupdate_Enabled (Target : Texture_Target) return Boolean; @@ -185,7 +185,7 @@ package GL.Objects.Textures is procedure Invalidate_Image (Object : Texture; Level : Mipmap_Level); - procedure Invalidate_Sub_Image (Object : Texture; Level : Mipmap_Level; + procedure Invalidate_Sub_Image (Object : Texture; Level : Mipmap_Level; X, Y, Z : Int; Width, Height, Depth : Size); ----------------------------------------------------------------------------- @@ -227,4 +227,7 @@ private overriding procedure Internal_Release_Id (Object : Texture; Id : UInt); + function Format_For_Loading_Empty_Texture + (Internal_Format : Pixels.Internal_Format) return Pixels.Data_Format; + end GL.Objects.Textures; diff --git a/src/gl/interface/gl-rasterization.ads b/src/gl/interface/gl-rasterization.ads index 1832b741..de4e3cf4 100644 --- a/src/gl/interface/gl-rasterization.ads +++ b/src/gl/interface/gl-rasterization.ads @@ -23,6 +23,7 @@ package GL.Rasterization is procedure Set_Polygon_Mode (Value : Polygon_Mode_Type); function Polygon_Mode return Polygon_Mode_Type; + procedure Set_Polygon_Offset (Factor, Units : Single := 0.0); procedure Set_Point_Size (Value : Single); function Point_Size return Single; diff --git a/src/gl/interface/gl-toggles.ads b/src/gl/interface/gl-toggles.ads index 70c2d83f..a63c756d 100644 --- a/src/gl/interface/gl-toggles.ads +++ b/src/gl/interface/gl-toggles.ads @@ -30,7 +30,7 @@ package GL.Toggles is Sample_Coverage, Color_Table, Post_Convolution_Color_Table, Post_Color_Matrix_Color_Table, Color_Sum, Texture_Cube_Map, Vertex_Program_Point_Size, Vertex_Program_Two_Side, Point_Sprite, - Primitive_Restart); + Rasterizer_Discard, Primitive_Restart); procedure Enable (Subject : Toggle); procedure Disable (Subject : Toggle); @@ -116,6 +116,7 @@ private Vertex_Program_Point_Size => 16#8642#, Vertex_Program_Two_Side => 16#8643#, Point_Sprite => 16#8861#, + Rasterizer_Discard => 16#8C89#, Primitive_Restart => 16#8F9D#); for Toggle'Size use Low_Level.Enum'Size; diff --git a/src/gl/specs/gl-api.spec b/src/gl/specs/gl-api.spec index b913733c..4b227d3b 100644 --- a/src/gl/specs/gl-api.spec +++ b/src/gl/specs/gl-api.spec @@ -239,6 +239,12 @@ spec GL.API is Element_Offset : UInt; Base_Vertex : Int) with Dynamic => "glDrawElementsBaseVertex", Wrapper => "GL.Objects.Buffers.Draw_Elements_Base_Vertex"; + procedure Draw_Transform_Feedback (Mode : Connection_Mode; Buffer : UInt) with + Dynamic => "glDrawTransformFeedback", + Wrapper => "GL.Objects.Buffers.Draw_Transform_Feedback"; + procedure Draw_Transform_Feedback_Stream (Mode : Connection_Mode; Buffer : UInt; Stream : UInt) with + Dynamic => "glDrawTransformFeedbackStream", + Wrapper => "GL.Objects.Buffers.Draw_Transform_Feedback_Stream"; procedure Primitive_Restart_Index (Index : UInt) with Dynamic => "glPrimitiveRestartIndex", Wrapper => "GL.Objects.Vertex_Arrays.Set_Primitive_Restart_Index"; @@ -368,6 +374,8 @@ spec GL.API is Static => "glRasterPos3dv", Wrapper => "GL.Raster.Set_Pos"; procedure Raster_Pos2 (Value : Types.Doubles.Vector2) with Static => "glRasterPos2dv", Wrapper => "GL.Raster.Set_Pos"; + procedure Set_Polygon_Offset (Factor, Units : Single) with + Static => "glPolygonOffset", Wrapper => "GL.Rasterization.Set_Polygon_Offset"; ----------------------------------------------------------------------------- -- Buffers -- @@ -598,7 +606,6 @@ spec GL.API is Wrapper => "GL.Objects.Textures.Compressed"; procedure Gen_Textures (N : Size; Textures : out UInt) with Static => "glGenTextures", Wrapper => "GL.Objects.Initialize_Id"; - procedure Bind_Texture (Target : Low_Level.Enums.Texture_Kind; Texture : UInt) with Static => "glBindTexture", Wrapper => "GL.Objects.Textures.Bind"; @@ -807,10 +814,16 @@ spec GL.API is procedure Gen_Buffers (N : Size; Buffers : out UInt) with Dynamic => "glGenBuffers", Wrapper => "GL.Objects.Initialize_Id"; + procedure Gen_Transform_Feedbacks (N : Size; Buffers : out UInt) with + Dynamic => "glGenTransformFeedbacks", Wrapper => "GL.Objects.Initialize_Id"; procedure Delete_Buffers (N : Size; Buffers : Low_Level.UInt_Array) with Dynamic => "glDeleteBuffers"; + procedure Delete_Transform_Feedbacks (N : Size; Buffers : Low_Level.UInt_Array) with + Dynamic => "glDeleteTransformFeedbacks"; procedure Bind_Buffer (Target : Low_Level.Enums.Buffer_Kind; Buffer : UInt) with Dynamic =>"glBindBuffer", Wrapper => "GL.Objects.Buffers.Bind"; + procedure Bind_Transform_Feedback (Target : Low_Level.Enums.Buffer_Kind; Buffer : UInt) + with Dynamic =>"glBindTransformFeedback", Wrapper => "GL.Objects.Buffers.Bind_Transform_Feedback"; procedure Bind_Buffer_Base (Target : Low_Level.Enums.Buffer_Kind; Index : UInt; Buffer : UInt) with Dynamic =>"glBindBufferBase", Wrapper => "GL.Objects.Buffers.Bind_Buffer_Base"; procedure Buffer_Data @@ -828,6 +841,11 @@ spec GL.API is function Map_Buffer (Target : Low_Level.Enums.Buffer_Kind; Acc : Objects.Access_Kind) return System.Address with Dynamic => "glMapBuffer", Wrapper => "GL.Objects.Buffers.Map"; + function Map_Buffer_Range (Target : Low_Level.Enums.Buffer_Kind; + Offset : Low_Level.IntPtr; + Size : Low_Level.SizeIPtr; + Acc : Low_Level.Bitfield) return System.Address with + Dynamic => "glMapBufferRange", Wrapper => "GL.Objects.Buffers.Map_Range"; procedure Buffer_Pointer (Target : Low_Level.Enums.Buffer_Kind; Pname : Enums.Buffer_Pointer_Param; Params : out System.Address) with @@ -837,6 +855,11 @@ spec GL.API is Size : Low_Level.SizeIPtr; Data : System.Address) with Dynamic => "glBufferSubData", Wrapper => "GL.Objects.Buffers.Set_Sub_Data"; + procedure Get_Buffer_Sub_Data (Target : Low_Level.Enums.Buffer_Kind; + Offset : Low_Level.IntPtr; + Size : Low_Level.SizeIPtr; + Data : System.Address) with + Dynamic => "glGetBufferSubData", Wrapper => "GL.Objects.Buffers.Get_Sub_Data"; procedure Unmap_Buffer (Target : Low_Level.Enums.Buffer_Kind) with Dynamic => "glUnmapBuffer", Wrapper => "GL.Objects.Buffers.Unmap"; procedure Get_Buffer_Parameter_Access_Kind @@ -866,6 +889,11 @@ spec GL.API is (Buffer : UInt; Offset : Low_Level.IntPtr; Length : Low_Level.SizeIPtr) with Dynamic => "glInvalidateBufferSubData", Wrapper => "GL.Objects.Buffers.Invalidate_Sub_Data"; + procedure Flush_Mapped_Buffer_Range + (Target : Low_Level.Enums.Buffer_Kind; Offset : Low_Level.IntPtr; + Length : Low_Level.SizeIPtr) with + Dynamic => "glFlushMappedBufferRange", + Wrapper => "GL.Objects.Buffers.Flush_Mapped_Buffer_Range"; ----------------------------------------------------------------------------- -- Vertex Array Objects -- @@ -1015,6 +1043,37 @@ spec GL.API is Dynamic => "glGetFramebufferParameteriv", Wrapper => "GL.Objects.Framebuffers.Default_Fixed_Sample_Locations"; + ----------------------------------------------------------------------------- + -- Query Objects -- + ----------------------------------------------------------------------------- + + procedure Gen_Queries (N : Size; Queries : out UInt) with + Dynamic => "glGenQueries", + Wrapper => "GL.Objects.Initialize_Id"; + procedure Delete_Queries (N : Size; Queries : Low_Level.UInt_Array) with + Dynamic => "glDeleteQueries"; + function Is_Query (Query : UInt) return Boolean with + Dynamic => "glIsQuery", Wrapper => "GL.Objects.Queries.Is_Query"; + procedure Get_Query_Object (Query : UInt; Pname : Low_Level.Enums.Query_Results; + Params : out UInt) with + Dynamic => "glGetQueryObjectuiv", + Wrapper => "GL.Objects.Queries.Get_Query_Object"; + procedure Begin_Query (Target : Low_Level.Enums.Query_Param; Id : UInt) with + Dynamic => "glBeginQuery", + Wrapper => "GL.Objects.Queries.Begin_Query"; + procedure End_Query (Target : Low_Level.Enums.Query_Param) with + Dynamic => "glEndQuery", + Wrapper => "GL.Objects.Queries.End_Query"; + procedure Begin_Query_Indexed (Target : Low_Level.Enums.Query_Param; Index, Id : UInt) with + Dynamic => "glBeginQueryIndexed", + Wrapper => "GL.Objects.Queries.Begin_Query_Indexed"; + procedure End_Query_Indexed (Target : Low_Level.Enums.Query_Param; Index : UInt) with + Dynamic => "glEndQueryIndexed", + Wrapper => "GL.Objects.Queries.End_Query_Indexed"; + procedure Query_Counter (Id: UInt; Target : Low_Level.Enums.Query_Param) with + Dynamic => "glQueryCounter", + Wrapper => "GL.Objects.Queries.Query_Counter"; + ----------------------------------------------------------------------------- -- Shaders -- ----------------------------------------------------------------------------- @@ -1070,7 +1129,6 @@ spec GL.API is Wrapper => "GL.Objects.Programs.Transform_Feedback_Buffer_Mode", Wrapper => "GL.Objects.Programs.Transform_Feedback_Varyings", Wrapper => "GL.Objects.Programs.Transform_Feedback_Varying_Max_Length", - Wrapper => "GL.Objects.Programs.Get_Transform_Feedback_Varying", Wrapper => "GL.Objects.Programs.Begin_Transform_Feedback", Wrapper => "GL.Objects.Programs.End_Transform_Feedback"; procedure Attach_Shader (Program, Shader : UInt) with @@ -1162,8 +1220,8 @@ spec GL.API is Wrapper => "GL.Objects.Programs.End_Transform_Feedback"; procedure Get_Transform_Feedback_Varying (Program : UInt; Index : Int; Buffer_Size : Size; - Length : Size; V_Length : Size; V_Type : GL.Objects.Programs.Buffer_Mode; - Name : Interfaces.C.char_array) with + Length : out Size; V_Length : out Size; V_Type : out GL.Objects.Programs.Active_Attribute; + Name : in out Interfaces.C.char_array) with Dynamic => "glGetTransformFeedbackVarying", Wrapper => "GL.Objects.Programs.Get_Transform_Feedback_Varying"; procedure Transform_Feedback_Varyings diff --git a/src/images/gl-images.adb b/src/images/gl-images.adb new file mode 100644 index 00000000..c1741f59 --- /dev/null +++ b/src/images/gl-images.adb @@ -0,0 +1,226 @@ +with Ada.Calendar; +with Ada.Streams.Stream_IO; +with Ada.Unchecked_Deallocation; + +with GID; +with GL.Types; +with GL.Objects.Textures.Targets; + +package body GL.Images is + generic + type Component is mod <>; + Num_Components : Types.Int; + Width, Height : Types.Size; + package Loader is + type Raw_Data is array (Types.Int range <>) of Component; + type Raw_Data_Access is access Raw_Data; + + procedure To_Array ( + Source : in out GID.Image_descriptor; + Data : out Raw_Data_Access); + + procedure Free_Data is new Ada.Unchecked_Deallocation + (Raw_Data, Raw_Data_Access); + end Loader; + + package body Loader is + procedure To_Array ( + Source : in out GID.Image_descriptor; + Data : out Raw_Data_Access) is + use type Types.Int; + + Cur_Pos : Types.Int := 0; + + procedure Set_X_Y (X, Y : Natural) is + begin + Cur_Pos := GL.Types.Int (Y) * Width * Num_Components + + GL.Types.Int (X) * Num_Components; + end Set_X_Y; + + procedure Put_Pixel (R, G, B, A : Component) is + Input : constant array (Types.Int'(0) .. Types.Int'(3)) of Component := (R, G, B, A); + begin + for I in 0 .. Num_Components - 1 loop + Data (Cur_Pos + I) := Input (I); + end loop; + Cur_Pos := Cur_Pos + Num_Components; + end Put_Pixel; + + procedure Feedback (Percents : Natural) is null; + + procedure Content_Loader is new GID.Load_image_contents + (Component, Set_X_Y, Put_Pixel, Feedback, GID.nice); + + Next_Frame : Ada.Calendar.Day_Duration; + begin + Data := new Raw_Data (0 .. Width * Height * Num_Components - 1); + Content_Loader (Source, Next_Frame); + end To_Array; + end Loader; + + procedure Load_Image_To_Texture ( + Source : in out Ada.Streams.Root_Stream_Type'Class; + Texture : in out GL.Objects.Textures.Texture'Class; + Texture_Format : GL.Pixels.Internal_Format; + Try_TGA : Boolean := False) is + Descriptor : GID.Image_descriptor; + Width, Height : Types.Size; + + use GL.Pixels; + use GL.Objects.Textures.Targets; + + Needs_Wide_Component : Boolean := False; + Num_Components : GL.Types.Int; + Format : Pixels.Data_Format; + begin + GID.Load_image_header (Descriptor, Source, Try_TGA); + Width := Types.Size (GID.Pixel_width (Descriptor)); + Height := Types.Size (GID.Pixel_height (Descriptor)); + case Texture_Format is + when Depth_Component | Red | Alpha | Luminance | Alpha4 | Alpha8 | + Luminance4 | Luminance8 | Intensity | Intensity4 | Intensity8 | + Compressed_Red | R8 | R8I | R8UI | Compressed_Alpha | + Compressed_Luminance | Compressed_Intensity | SLuminance | + SLuminance8 | Compressed_Red_RGTC1 | Compressed_Signed_Red_RGTC1 | + R8_SNorm => + Num_Components := 1; + Format := Pixels.Red; + when Alpha12 | Alpha16 | Luminance12 | Luminance16 | + Intensity12 | Intensity16 | Depth_Component16 | + Depth_Component24 | Depth_Component32 | R16 | R16F | R32F | + R16I | R16UI | R32I | R32UI | R16_SNorm => + Num_Components := 1; + Format := Pixels.Red; + Needs_Wide_Component := True; + when Luminance_Alpha | Luminance4_Alpha4 | Luminance6_Alpha2 | + Luminance8_Alpha8 | Compressed_RG | RG | RG8 | RG8I | RG8UI | + Compressed_Luminance_Alpha | SLuminance_Alpha | + SLuminance8_Alpha8 | Compressed_RG_RGTC2 | + Compressed_Signed_RG_RGTC2 | RG8_SNorm => + Num_Components := 2; + Format := Pixels.RG; + when Luminance12_Alpha4 | Luminance12_Alpha12 | Luminance16_Alpha16 | + RG16 | RG16F | RG32F | RG16I | RG16UI | RG32I | RG32UI | + Depth24_Stencil8 | RG16_SNorm => + Num_Components := 2; + Format := Pixels.RG; + Needs_Wide_Component := True; + when RGB | R3_G3_B2 | RGB4 | RGB5 | RGB8 | Compressed_RGB_S3TC_DXT1 | + Compressed_RGB | SRGB | SRGB8 | Compressed_SRGB | + Compressed_SRGB_S3TC_DXT1 | RGB8UI | RGB8I | + Compressed_RGB_BPTC_Signed_Float | + Compressed_RGB_BPTC_Unsigned_Float | RGB8_SNorm => + Num_Components := 3; + Format := Pixels.RGB; + when RGB10 | RGB12 | RGB16 | R11F_G11F_B10F | RGB9_E5 | RGB32UI | + RGB16UI | RGB32I | RGB16I | RGB16_SNorm => + Num_Components := 3; + Format := Pixels.RGB; + Needs_Wide_Component := True; + when RGBA | RGBA2 | RGBA4 | RGB5_A1 | RGBA8 | + Compressed_RGBA_S3TC_DXT1 | Compressed_RGBA_S3TC_DXT3 | + Compressed_RGBA_S3TC_DXT5 | Compressed_RGBA | SRGB_Alpha | + SRGB8_Alpha8 | Compressed_SRGB_Alpha | + Compressed_SRGB_Alpha_S3TC_DXT1 | + Compressed_SRGB_Alpha_S3TC_DXT3 | + Compressed_SRGB_Alpha_S3TC_DXT5 | RGBA8UI | RGBA8I | + Compressed_RGBA_BPTC_Unorm | Compressed_SRGB_Alpha_BPTC_UNorm | + RGBA8_SNorm | Compressed_RGBA_ASTC_4x4 | + Compressed_RGBA_ASTC_5x4 | Compressed_RGBA_ASTC_5x5 | + Compressed_RGBA_ASTC_6x5 | Compressed_RGBA_ASTC_6x6 | + Compressed_RGBA_ASTC_8x5 | Compressed_RGBA_ASTC_8x6 | + Compressed_RGBA_ASTC_8x8 | Compressed_SRGB8_Alpha8_ASTC_4x4 | + Compressed_SRGB8_Alpha8_ASTC_5x4 | + Compressed_SRGB8_Alpha8_ASTC_5x5 | + Compressed_SRGB8_Alpha8_ASTC_6x5 | + Compressed_SRGB8_Alpha8_ASTC_6x6 | + Compressed_SRGB8_Alpha8_ASTC_8x5 | + Compressed_SRGB8_Alpha8_ASTC_8x6 | + Compressed_SRGB8_Alpha8_ASTC_8x8 | + Compressed_SRGB8_Alpha8_ASTC_10x5 | + Compressed_SRGB8_Alpha8_ASTC_10x6 | + Compressed_SRGB8_Alpha8_ASTC_10x8 | + Compressed_SRGB8_Alpha8_ASTC_10x10 | + Compressed_SRGB8_Alpha8_ASTC_12x10 | + Compressed_SRGB8_Alpha8_ASTC_12x12 => + Num_Components := 4; + Format := Pixels.RGBA; + when RGB10_A2 | RGBA12 | RGBA16 | RGBA32F | RGB32F | RGBA16F | RGB16F | + RGBA32UI | RGBA16UI | RGBA32I | RGBA16I | RGBA16_SNorm | + RGB10_A2UI | Compressed_RGBA_ASTC_10x5 | + Compressed_RGBA_ASTC_10x6 | Compressed_RGBA_ASTC_10x8 | + Compressed_RGBA_ASTC_10x10 | Compressed_RGBA_ASTC_12x10 | + Compressed_RGBA_ASTC_12x12 => + Num_Components := 4; + Format := Pixels.RGBA; + Needs_Wide_Component := True; + end case; + if Needs_Wide_Component then + declare + package Impl is new Loader + (GL.Types.UShort, Num_Components, Width, Height); + use type Impl.Raw_Data_Access; + Data : Impl.Raw_Data_Access := null; + begin + Impl.To_Array (Descriptor, Data); + if not Texture.Initialized then + Texture.Initialize_Id; + end if; + Texture_2D.Bind (Texture); + Texture_2D.Load_From_Data (0, Texture_Format, Width, Height, Format, + Pixels.Unsigned_Short, Objects.Textures.Image_Source + (Data.all (Data.all'First)'Address)); + Impl.Free_Data (Data); + exception when others => + if Data /= null then + Impl.Free_Data (Data); + end if; + raise; + end; + else + declare + package Impl is new Loader + (GL.Types.UByte, Num_Components, Width, Height); + use type Impl.Raw_Data_Access; + Data : Impl.Raw_Data_Access := null; + begin + Impl.To_Array (Descriptor, Data); + if not Texture.Initialized then + Texture.Initialize_Id; + end if; + Texture_2D.Bind (Texture); + Texture_2D.Set_Minifying_Filter (GL.Objects.Textures.Linear); + Texture_2D.Set_Magnifying_Filter (GL.Objects.Textures.Linear); + GL.Pixels.Set_Unpack_Alignment (GL.Pixels.Bytes); + Texture_2D.Load_From_Data (0, Texture_Format, Width, Height, Format, + Pixels.Unsigned_Byte, Objects.Textures.Image_Source + (Data.all (Data.all'First)'Address)); + Impl.Free_Data (Data); + exception when others => + if Data /= null then + Impl.Free_Data (Data); + end if; + raise; + end; + end if; + end Load_Image_To_Texture; + + procedure Load_File_To_Texture ( + Path : String; + Texture : in out GL.Objects.Textures.Texture'Class; + Texture_Format : GL.Pixels.Internal_Format; + Try_TGA : Boolean := False) is + use Ada.Streams.Stream_IO; + + Input_File : File_Type; + Input_Stream : Stream_Access; + begin + Ada.Streams.Stream_IO.Open (Input_File, In_File, Path); + Input_Stream := Stream (Input_File); + + Load_Image_To_Texture + (Input_Stream.all, Texture, Texture_Format, Try_TGA); + + Ada.Streams.Stream_IO.Close (Input_File); + end Load_File_To_Texture; +end GL.Images; \ No newline at end of file diff --git a/src/images/gl-images.ads b/src/images/gl-images.ads new file mode 100644 index 00000000..a8e242ca --- /dev/null +++ b/src/images/gl-images.ads @@ -0,0 +1,29 @@ +with Ada.Streams; +with GL.Objects.Textures; +with GL.Pixels; + +package GL.Images is + -- This procedure loads the contents of the given Source to the given + -- texture object. + -- The texture object will be initialized if it is uninitialized. + -- The texture's image is created with the given internal format. + -- + -- The image type is determined from its signature. TGA images do not have a + -- signature, so if the source contains TGA data, you need to set Try_TGA to + -- True. + -- + -- If the given Texture_Format contains components with more than 8 bits, + -- the image is loaded with 16-bit components before it is given to OpenGL. + procedure Load_Image_To_Texture ( + Source : in out Ada.Streams.Root_Stream_Type'Class; + Texture : in out GL.Objects.Textures.Texture'Class; + Texture_Format : GL.Pixels.Internal_Format; + Try_TGA : Boolean := False); + + -- Like Load_Image_To_Texture, but takes the path to a file as input. + procedure Load_File_To_Texture ( + Path : String; + Texture : in out GL.Objects.Textures.Texture'Class; + Texture_Format : GL.Pixels.Internal_Format; + Try_TGA : Boolean := False); +end GL.Images; \ No newline at end of file diff --git a/src/soil/SOIL_C.c b/src/soil/SOIL_C.c deleted file mode 100755 index 1bd3fb64..00000000 --- a/src/soil/SOIL_C.c +++ /dev/null @@ -1,2024 +0,0 @@ -/* - Jonathan Dummer - 2007-07-26-10.36 - - Simple OpenGL Image Library - - Public Domain - using Sean Barret's stb_image as a base - - Thanks to: - * Sean Barret - for the awesome stb_image - * Dan Venkitachalam - for finding some non-compliant DDS files, and patching some explicit casts - * everybody at gamedev.net -*/ - -#define SOIL_CHECK_FOR_GL_ERRORS 0 - -#ifdef WIN32 - #define WIN32_LEAN_AND_MEAN - #include - #include - #include -#elif defined(__APPLE__) || defined(__APPLE_CC__) - /* I can't test this Apple stuff! */ - #include - #include - #define APIENTRY -#else - #include - #include -#endif - -#include "SOIL_C.h" -#include "stb_image_aug.h" -#include "image_helper.h" -#include "image_DXT.h" - -#include -#include - -/* error reporting */ -char *result_string_pointer = "SOIL initialized"; - -/* for loading cube maps */ -enum{ - SOIL_CAPABILITY_UNKNOWN = -1, - SOIL_CAPABILITY_NONE = 0, - SOIL_CAPABILITY_PRESENT = 1 -}; -static int has_cubemap_capability = SOIL_CAPABILITY_UNKNOWN; -int query_cubemap_capability( void ); -#define SOIL_TEXTURE_WRAP_R 0x8072 -#define SOIL_CLAMP_TO_EDGE 0x812F -#define SOIL_NORMAL_MAP 0x8511 -#define SOIL_REFLECTION_MAP 0x8512 -#define SOIL_TEXTURE_CUBE_MAP 0x8513 -#define SOIL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define SOIL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define SOIL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define SOIL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define SOIL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define SOIL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define SOIL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -/* for non-power-of-two texture */ -static int has_NPOT_capability = SOIL_CAPABILITY_UNKNOWN; -int query_NPOT_capability( void ); -/* for texture rectangles */ -static int has_tex_rectangle_capability = SOIL_CAPABILITY_UNKNOWN; -int query_tex_rectangle_capability( void ); -#define SOIL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define SOIL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -/* for using DXT compression */ -static int has_DXT_capability = SOIL_CAPABILITY_UNKNOWN; -int query_DXT_capability( void ); -#define SOIL_RGB_S3TC_DXT1 0x83F0 -#define SOIL_RGBA_S3TC_DXT1 0x83F1 -#define SOIL_RGBA_S3TC_DXT3 0x83F2 -#define SOIL_RGBA_S3TC_DXT5 0x83F3 -typedef void (APIENTRY * P_SOIL_GLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data); -P_SOIL_GLCOMPRESSEDTEXIMAGE2DPROC soilGlCompressedTexImage2D = NULL; -unsigned int SOIL_direct_load_DDS( - const char *filename, - unsigned int reuse_texture_ID, - int flags, - int loading_as_cubemap ); -unsigned int SOIL_direct_load_DDS_from_memory( - const unsigned char *const buffer, - int buffer_length, - unsigned int reuse_texture_ID, - int flags, - int loading_as_cubemap ); -/* other functions */ -unsigned int - SOIL_internal_create_OGL_texture - ( - const unsigned char *const data, - int width, int height, int channels, - unsigned int reuse_texture_ID, - unsigned int flags, - unsigned int opengl_texture_type, - unsigned int opengl_texture_target, - unsigned int texture_check_size_enum - ); - -/* and the code magic begins here [8^) */ -unsigned int - SOIL_load_OGL_texture - ( - const char *filename, - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* variables */ - unsigned char* img; - int width, height, channels; - unsigned int tex_id; - /* does the user want direct uploading of the image as a DDS file? */ - if( flags & SOIL_FLAG_DDS_LOAD_DIRECT ) - { - /* 1st try direct loading of the image as a DDS file - note: direct uploading will only load what is in the - DDS file, no MIPmaps will be generated, the image will - not be flipped, etc. */ - tex_id = SOIL_direct_load_DDS( filename, reuse_texture_ID, flags, 0 ); - if( tex_id ) - { - /* hey, it worked!! */ - return tex_id; - } - } - /* try to load the image */ - img = SOIL_load_image( filename, &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* OK, make it a texture! */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - reuse_texture_ID, flags, - GL_TEXTURE_2D, GL_TEXTURE_2D, - GL_MAX_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - /* and return the handle, such as it is */ - return tex_id; -} - -unsigned int - SOIL_load_OGL_HDR_texture - ( - const char *filename, - int fake_HDR_format, - int rescale_to_max, - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* variables */ - unsigned char* img; - int width, height, channels; - unsigned int tex_id; - /* no direct uploading of the image as a DDS file */ - /* error check */ - if( (fake_HDR_format != SOIL_HDR_RGBE) && - (fake_HDR_format != SOIL_HDR_RGBdivA) && - (fake_HDR_format != SOIL_HDR_RGBdivA2) ) - { - result_string_pointer = "Invalid fake HDR format specified"; - return 0; - } - /* try to load the image (only the HDR type) */ - img = stbi_hdr_load_rgbe( filename, &width, &height, &channels, 4 ); - /* channels holds the original number of channels, which may have been forced */ - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* the load worked, do I need to convert it? */ - if( fake_HDR_format == SOIL_HDR_RGBdivA ) - { - RGBE_to_RGBdivA( img, width, height, rescale_to_max ); - } else if( fake_HDR_format == SOIL_HDR_RGBdivA2 ) - { - RGBE_to_RGBdivA2( img, width, height, rescale_to_max ); - } - /* OK, make it a texture! */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - reuse_texture_ID, flags, - GL_TEXTURE_2D, GL_TEXTURE_2D, - GL_MAX_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - /* and return the handle, such as it is */ - return tex_id; -} - -unsigned int - SOIL_load_OGL_texture_from_memory - ( - const unsigned char *const buffer, - int buffer_length, - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* variables */ - unsigned char* img; - int width, height, channels; - unsigned int tex_id; - /* does the user want direct uploading of the image as a DDS file? */ - if( flags & SOIL_FLAG_DDS_LOAD_DIRECT ) - { - /* 1st try direct loading of the image as a DDS file - note: direct uploading will only load what is in the - DDS file, no MIPmaps will be generated, the image will - not be flipped, etc. */ - tex_id = SOIL_direct_load_DDS_from_memory( - buffer, buffer_length, - reuse_texture_ID, flags, 0 ); - if( tex_id ) - { - /* hey, it worked!! */ - return tex_id; - } - } - /* try to load the image */ - img = SOIL_load_image_from_memory( - buffer, buffer_length, - &width, &height, &channels, - force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* OK, make it a texture! */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - reuse_texture_ID, flags, - GL_TEXTURE_2D, GL_TEXTURE_2D, - GL_MAX_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - /* and return the handle, such as it is */ - return tex_id; -} - -unsigned int - SOIL_load_OGL_cubemap - ( - const char *x_pos_file, - const char *x_neg_file, - const char *y_pos_file, - const char *y_neg_file, - const char *z_pos_file, - const char *z_neg_file, - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* variables */ - unsigned char* img; - int width, height, channels; - unsigned int tex_id; - /* error checking */ - if( (x_pos_file == NULL) || - (x_neg_file == NULL) || - (y_pos_file == NULL) || - (y_neg_file == NULL) || - (z_pos_file == NULL) || - (z_neg_file == NULL) ) - { - result_string_pointer = "Invalid cube map files list"; - return 0; - } - /* capability checking */ - if( query_cubemap_capability() != SOIL_CAPABILITY_PRESENT ) - { - result_string_pointer = "No cube map capability present"; - return 0; - } - /* 1st face: try to load the image */ - img = SOIL_load_image( x_pos_file, &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, and create a texture ID if necessary */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - reuse_texture_ID, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_POSITIVE_X, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image( x_neg_file, &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_NEGATIVE_X, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image( y_pos_file, &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_POSITIVE_Y, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image( y_neg_file, &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Y, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image( z_pos_file, &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_POSITIVE_Z, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image( z_neg_file, &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Z, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* and return the handle, such as it is */ - return tex_id; -} - -unsigned int - SOIL_load_OGL_cubemap_from_memory - ( - const unsigned char *const x_pos_buffer, - int x_pos_buffer_length, - const unsigned char *const x_neg_buffer, - int x_neg_buffer_length, - const unsigned char *const y_pos_buffer, - int y_pos_buffer_length, - const unsigned char *const y_neg_buffer, - int y_neg_buffer_length, - const unsigned char *const z_pos_buffer, - int z_pos_buffer_length, - const unsigned char *const z_neg_buffer, - int z_neg_buffer_length, - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* variables */ - unsigned char* img; - int width, height, channels; - unsigned int tex_id; - /* error checking */ - if( (x_pos_buffer == NULL) || - (x_neg_buffer == NULL) || - (y_pos_buffer == NULL) || - (y_neg_buffer == NULL) || - (z_pos_buffer == NULL) || - (z_neg_buffer == NULL) ) - { - result_string_pointer = "Invalid cube map buffers list"; - return 0; - } - /* capability checking */ - if( query_cubemap_capability() != SOIL_CAPABILITY_PRESENT ) - { - result_string_pointer = "No cube map capability present"; - return 0; - } - /* 1st face: try to load the image */ - img = SOIL_load_image_from_memory( - x_pos_buffer, x_pos_buffer_length, - &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, and create a texture ID if necessary */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - reuse_texture_ID, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_POSITIVE_X, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image_from_memory( - x_neg_buffer, x_neg_buffer_length, - &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_NEGATIVE_X, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image_from_memory( - y_pos_buffer, y_pos_buffer_length, - &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_POSITIVE_Y, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image_from_memory( - y_neg_buffer, y_neg_buffer_length, - &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Y, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image_from_memory( - z_pos_buffer, z_pos_buffer_length, - &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_POSITIVE_Z, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* continue? */ - if( tex_id != 0 ) - { - /* 1st face: try to load the image */ - img = SOIL_load_image_from_memory( - z_neg_buffer, z_neg_buffer_length, - &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* upload the texture, but reuse the assigned texture ID */ - tex_id = SOIL_internal_create_OGL_texture( - img, width, height, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Z, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - /* and nuke the image data */ - SOIL_free_image_data( img ); - } - /* and return the handle, such as it is */ - return tex_id; -} - -unsigned int - SOIL_load_OGL_single_cubemap - ( - const char *filename, - const char face_order[6], - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* variables */ - unsigned char* img; - int width, height, channels, i; - unsigned int tex_id = 0; - /* error checking */ - if( filename == NULL ) - { - result_string_pointer = "Invalid single cube map file name"; - return 0; - } - /* does the user want direct uploading of the image as a DDS file? */ - if( flags & SOIL_FLAG_DDS_LOAD_DIRECT ) - { - /* 1st try direct loading of the image as a DDS file - note: direct uploading will only load what is in the - DDS file, no MIPmaps will be generated, the image will - not be flipped, etc. */ - tex_id = SOIL_direct_load_DDS( filename, reuse_texture_ID, flags, 1 ); - if( tex_id ) - { - /* hey, it worked!! */ - return tex_id; - } - } - /* face order checking */ - for( i = 0; i < 6; ++i ) - { - if( (face_order[i] != 'N') && - (face_order[i] != 'S') && - (face_order[i] != 'W') && - (face_order[i] != 'E') && - (face_order[i] != 'U') && - (face_order[i] != 'D') ) - { - result_string_pointer = "Invalid single cube map face order"; - return 0; - }; - } - /* capability checking */ - if( query_cubemap_capability() != SOIL_CAPABILITY_PRESENT ) - { - result_string_pointer = "No cube map capability present"; - return 0; - } - /* 1st off, try to load the full image */ - img = SOIL_load_image( filename, &width, &height, &channels, force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* now, does this image have the right dimensions? */ - if( (width != 6*height) && - (6*width != height) ) - { - SOIL_free_image_data( img ); - result_string_pointer = "Single cubemap image must have a 6:1 ratio"; - return 0; - } - /* try the image split and create */ - tex_id = SOIL_create_OGL_single_cubemap( - img, width, height, channels, - face_order, reuse_texture_ID, flags - ); - /* nuke the temporary image data and return the texture handle */ - SOIL_free_image_data( img ); - return tex_id; -} - -unsigned int - SOIL_load_OGL_single_cubemap_from_memory - ( - const unsigned char *const buffer, - int buffer_length, - const char face_order[6], - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* variables */ - unsigned char* img; - int width, height, channels, i; - unsigned int tex_id = 0; - /* error checking */ - if( buffer == NULL ) - { - result_string_pointer = "Invalid single cube map buffer"; - return 0; - } - /* does the user want direct uploading of the image as a DDS file? */ - if( flags & SOIL_FLAG_DDS_LOAD_DIRECT ) - { - /* 1st try direct loading of the image as a DDS file - note: direct uploading will only load what is in the - DDS file, no MIPmaps will be generated, the image will - not be flipped, etc. */ - tex_id = SOIL_direct_load_DDS_from_memory( - buffer, buffer_length, - reuse_texture_ID, flags, 1 ); - if( tex_id ) - { - /* hey, it worked!! */ - return tex_id; - } - } - /* face order checking */ - for( i = 0; i < 6; ++i ) - { - if( (face_order[i] != 'N') && - (face_order[i] != 'S') && - (face_order[i] != 'W') && - (face_order[i] != 'E') && - (face_order[i] != 'U') && - (face_order[i] != 'D') ) - { - result_string_pointer = "Invalid single cube map face order"; - return 0; - }; - } - /* capability checking */ - if( query_cubemap_capability() != SOIL_CAPABILITY_PRESENT ) - { - result_string_pointer = "No cube map capability present"; - return 0; - } - /* 1st off, try to load the full image */ - img = SOIL_load_image_from_memory( - buffer, buffer_length, - &width, &height, &channels, - force_channels ); - /* channels holds the original number of channels, which may have been forced */ - if( (force_channels >= 1) && (force_channels <= 4) ) - { - channels = force_channels; - } - if( NULL == img ) - { - /* image loading failed */ - result_string_pointer = stbi_failure_reason(); - return 0; - } - /* now, does this image have the right dimensions? */ - if( (width != 6*height) && - (6*width != height) ) - { - SOIL_free_image_data( img ); - result_string_pointer = "Single cubemap image must have a 6:1 ratio"; - return 0; - } - /* try the image split and create */ - tex_id = SOIL_create_OGL_single_cubemap( - img, width, height, channels, - face_order, reuse_texture_ID, flags - ); - /* nuke the temporary image data and return the texture handle */ - SOIL_free_image_data( img ); - return tex_id; -} - -unsigned int - SOIL_create_OGL_single_cubemap - ( - const unsigned char *const data, - int width, int height, int channels, - const char face_order[6], - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* variables */ - unsigned char* sub_img; - int dw, dh, sz, i; - unsigned int tex_id; - /* error checking */ - if( data == NULL ) - { - result_string_pointer = "Invalid single cube map image data"; - return 0; - } - /* face order checking */ - for( i = 0; i < 6; ++i ) - { - if( (face_order[i] != 'N') && - (face_order[i] != 'S') && - (face_order[i] != 'W') && - (face_order[i] != 'E') && - (face_order[i] != 'U') && - (face_order[i] != 'D') ) - { - result_string_pointer = "Invalid single cube map face order"; - return 0; - }; - } - /* capability checking */ - if( query_cubemap_capability() != SOIL_CAPABILITY_PRESENT ) - { - result_string_pointer = "No cube map capability present"; - return 0; - } - /* now, does this image have the right dimensions? */ - if( (width != 6*height) && - (6*width != height) ) - { - result_string_pointer = "Single cubemap image must have a 6:1 ratio"; - return 0; - } - /* which way am I stepping? */ - if( width > height ) - { - dw = height; - dh = 0; - } else - { - dw = 0; - dh = width; - } - sz = dw+dh; - sub_img = (unsigned char *)malloc( sz*sz*channels ); - /* do the splitting and uploading */ - tex_id = reuse_texture_ID; - for( i = 0; i < 6; ++i ) - { - int x, y, idx = 0; - unsigned int cubemap_target = 0; - /* copy in the sub-image */ - for( y = i*dh; y < i*dh+sz; ++y ) - { - for( x = i*dw*channels; x < (i*dw+sz)*channels; ++x ) - { - sub_img[idx++] = data[y*width*channels+x]; - } - } - /* what is my texture target? - remember, this coordinate system is - LHS if viewed from inside the cube! */ - switch( face_order[i] ) - { - case 'N': - cubemap_target = SOIL_TEXTURE_CUBE_MAP_POSITIVE_Z; - break; - case 'S': - cubemap_target = SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Z; - break; - case 'W': - cubemap_target = SOIL_TEXTURE_CUBE_MAP_NEGATIVE_X; - break; - case 'E': - cubemap_target = SOIL_TEXTURE_CUBE_MAP_POSITIVE_X; - break; - case 'U': - cubemap_target = SOIL_TEXTURE_CUBE_MAP_POSITIVE_Y; - break; - case 'D': - cubemap_target = SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Y; - break; - } - /* upload it as a texture */ - tex_id = SOIL_internal_create_OGL_texture( - sub_img, sz, sz, channels, - tex_id, flags, - SOIL_TEXTURE_CUBE_MAP, - cubemap_target, - SOIL_MAX_CUBE_MAP_TEXTURE_SIZE ); - } - /* and nuke the image and sub-image data */ - SOIL_free_image_data( sub_img ); - /* and return the handle, such as it is */ - return tex_id; -} - -unsigned int - SOIL_create_OGL_texture - ( - const unsigned char *const data, - int width, int height, int channels, - unsigned int reuse_texture_ID, - unsigned int flags - ) -{ - /* wrapper function for 2D textures */ - return SOIL_internal_create_OGL_texture( - data, width, height, channels, - reuse_texture_ID, flags, - GL_TEXTURE_2D, GL_TEXTURE_2D, - GL_MAX_TEXTURE_SIZE ); -} - -#if SOIL_CHECK_FOR_GL_ERRORS -void check_for_GL_errors( const char *calling_location ) -{ - /* check for errors */ - GLenum err_code = glGetError(); - while( GL_NO_ERROR != err_code ) - { - printf( "OpenGL Error @ %s: %i", calling_location, err_code ); - err_code = glGetError(); - } -} -#else -void check_for_GL_errors( const char *calling_location ) -{ - /* no check for errors */ -} -#endif - -unsigned int - SOIL_internal_create_OGL_texture - ( - const unsigned char *const data, - int width, int height, int channels, - unsigned int reuse_texture_ID, - unsigned int flags, - unsigned int opengl_texture_type, - unsigned int opengl_texture_target, - unsigned int texture_check_size_enum - ) -{ - /* variables */ - unsigned char* img; - unsigned int tex_id; - unsigned int internal_texture_format = 0, original_texture_format = 0; - int DXT_mode = SOIL_CAPABILITY_UNKNOWN; - int max_supported_size; - /* If the user wants to use the texture rectangle I kill a few flags */ - if( flags & SOIL_FLAG_TEXTURE_RECTANGLE ) - { - /* well, the user asked for it, can we do that? */ - if( query_tex_rectangle_capability() == SOIL_CAPABILITY_PRESENT ) - { - /* only allow this if the user in _NOT_ trying to do a cubemap! */ - if( opengl_texture_type == GL_TEXTURE_2D ) - { - /* clean out the flags that cannot be used with texture rectangles */ - flags &= ~( - SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | - SOIL_FLAG_TEXTURE_REPEATS - ); - /* and change my target */ - opengl_texture_target = SOIL_TEXTURE_RECTANGLE_ARB; - opengl_texture_type = SOIL_TEXTURE_RECTANGLE_ARB; - } else - { - /* not allowed for any other uses (yes, I'm looking at you, cubemaps!) */ - flags &= ~SOIL_FLAG_TEXTURE_RECTANGLE; - } - - } else - { - /* can't do it, and that is a breakable offense (uv coords use pixels instead of [0,1]!) */ - result_string_pointer = "Texture Rectangle extension unsupported"; - return 0; - } - } - /* create a copy the image data */ - img = (unsigned char*)malloc( width*height*channels ); - memcpy( img, data, width*height*channels ); - /* does the user want me to invert the image? */ - if( flags & SOIL_FLAG_INVERT_Y ) - { - int i, j; - for( j = 0; j*2 < height; ++j ) - { - int index1 = j * width * channels; - int index2 = (height - 1 - j) * width * channels; - for( i = width * channels; i > 0; --i ) - { - unsigned char temp = img[index1]; - img[index1] = img[index2]; - img[index2] = temp; - ++index1; - ++index2; - } - } - } - /* does the user want me to scale the colors into the NTSC safe RGB range? */ - if( flags & SOIL_FLAG_NTSC_SAFE_RGB ) - { - scale_image_RGB_to_NTSC_safe( img, width, height, channels ); - } - /* does the user want me to convert from straight to pre-multiplied alpha? - (and do we even _have_ alpha?) */ - if( flags & SOIL_FLAG_MULTIPLY_ALPHA ) - { - int i; - switch( channels ) - { - case 2: - for( i = 0; i < 2*width*height; i += 2 ) - { - img[i] = (img[i] * img[i+1] + 128) >> 8; - } - break; - case 4: - for( i = 0; i < 4*width*height; i += 4 ) - { - img[i+0] = (img[i+0] * img[i+3] + 128) >> 8; - img[i+1] = (img[i+1] * img[i+3] + 128) >> 8; - img[i+2] = (img[i+2] * img[i+3] + 128) >> 8; - } - break; - default: - /* no other number of channels contains alpha data */ - break; - } - } - /* if the user can't support NPOT textures, make sure we force the POT option */ - if( (query_NPOT_capability() == SOIL_CAPABILITY_NONE) && - !(flags & SOIL_FLAG_TEXTURE_RECTANGLE) ) - { - /* add in the POT flag */ - flags |= SOIL_FLAG_POWER_OF_TWO; - } - /* how large of a texture can this OpenGL implementation handle? */ - /* texture_check_size_enum will be GL_MAX_TEXTURE_SIZE or SOIL_MAX_CUBE_MAP_TEXTURE_SIZE */ - glGetIntegerv( texture_check_size_enum, &max_supported_size ); - /* do I need to make it a power of 2? */ - if( - (flags & SOIL_FLAG_POWER_OF_TWO) || /* user asked for it */ - (flags & SOIL_FLAG_MIPMAPS) || /* need it for the MIP-maps */ - (width > max_supported_size) || /* it's too big, (make sure it's */ - (height > max_supported_size) ) /* 2^n for later down-sampling) */ - { - int new_width = 1; - int new_height = 1; - while( new_width < width ) - { - new_width *= 2; - } - while( new_height < height ) - { - new_height *= 2; - } - /* still? */ - if( (new_width != width) || (new_height != height) ) - { - /* yep, resize */ - unsigned char *resampled = (unsigned char*)malloc( channels*new_width*new_height ); - up_scale_image( - img, width, height, channels, - resampled, new_width, new_height ); - /* OJO this is for debug only! */ - /* - SOIL_save_image( "\\showme.bmp", SOIL_SAVE_TYPE_BMP, - new_width, new_height, channels, - resampled ); - */ - /* nuke the old guy, then point it at the new guy */ - SOIL_free_image_data( img ); - img = resampled; - width = new_width; - height = new_height; - } - } - /* now, if it is too large... */ - if( (width > max_supported_size) || (height > max_supported_size) ) - { - /* I've already made it a power of two, so simply use the MIPmapping - code to reduce its size to the allowable maximum. */ - unsigned char *resampled; - int reduce_block_x = 1, reduce_block_y = 1; - int new_width, new_height; - if( width > max_supported_size ) - { - reduce_block_x = width / max_supported_size; - } - if( height > max_supported_size ) - { - reduce_block_y = height / max_supported_size; - } - new_width = width / reduce_block_x; - new_height = height / reduce_block_y; - resampled = (unsigned char*)malloc( channels*new_width*new_height ); - /* perform the actual reduction */ - mipmap_image( img, width, height, channels, - resampled, reduce_block_x, reduce_block_y ); - /* nuke the old guy, then point it at the new guy */ - SOIL_free_image_data( img ); - img = resampled; - width = new_width; - height = new_height; - } - /* does the user want us to use YCoCg color space? */ - if( flags & SOIL_FLAG_CoCg_Y ) - { - /* this will only work with RGB and RGBA images */ - convert_RGB_to_YCoCg( img, width, height, channels ); - /* - save_image_as_DDS( "CoCg_Y.dds", width, height, channels, img ); - */ - } - /* create the OpenGL texture ID handle - (note: allowing a forced texture ID lets me reload a texture) */ - tex_id = reuse_texture_ID; - if( tex_id == 0 ) - { - glGenTextures( 1, &tex_id ); - } - check_for_GL_errors( "glGenTextures" ); - /* Note: sometimes glGenTextures fails (usually no OpenGL context) */ - if( tex_id ) - { - /* and what type am I using as the internal texture format? */ - switch( channels ) - { - case 1: - original_texture_format = GL_LUMINANCE; - break; - case 2: - original_texture_format = GL_LUMINANCE_ALPHA; - break; - case 3: - original_texture_format = GL_RGB; - break; - case 4: - original_texture_format = GL_RGBA; - break; - } - internal_texture_format = original_texture_format; - /* does the user want me to, and can I, save as DXT? */ - if( flags & SOIL_FLAG_COMPRESS_TO_DXT ) - { - DXT_mode = query_DXT_capability(); - if( DXT_mode == SOIL_CAPABILITY_PRESENT ) - { - /* I can use DXT, whether I compress it or OpenGL does */ - if( (channels & 1) == 1 ) - { - /* 1 or 3 channels = DXT1 */ - internal_texture_format = SOIL_RGB_S3TC_DXT1; - } else - { - /* 2 or 4 channels = DXT5 */ - internal_texture_format = SOIL_RGBA_S3TC_DXT5; - } - } - } - /* bind an OpenGL texture ID */ - glBindTexture( opengl_texture_type, tex_id ); - check_for_GL_errors( "glBindTexture" ); - /* upload the main image */ - if( DXT_mode == SOIL_CAPABILITY_PRESENT ) - { - /* user wants me to do the DXT conversion! */ - int DDS_size; - unsigned char *DDS_data = NULL; - if( (channels & 1) == 1 ) - { - /* RGB, use DXT1 */ - DDS_data = convert_image_to_DXT1( img, width, height, channels, &DDS_size ); - } else - { - /* RGBA, use DXT5 */ - DDS_data = convert_image_to_DXT5( img, width, height, channels, &DDS_size ); - } - if( DDS_data ) - { - soilGlCompressedTexImage2D( - opengl_texture_target, 0, - internal_texture_format, width, height, 0, - DDS_size, DDS_data ); - check_for_GL_errors( "glCompressedTexImage2D" ); - SOIL_free_image_data( DDS_data ); - /* printf( "Internal DXT compressor\n" ); */ - } else - { - /* my compression failed, try the OpenGL driver's version */ - glTexImage2D( - opengl_texture_target, 0, - internal_texture_format, width, height, 0, - original_texture_format, GL_UNSIGNED_BYTE, img ); - check_for_GL_errors( "glTexImage2D" ); - /* printf( "OpenGL DXT compressor\n" ); */ - } - } else - { - /* user want OpenGL to do all the work! */ - glTexImage2D( - opengl_texture_target, 0, - internal_texture_format, width, height, 0, - original_texture_format, GL_UNSIGNED_BYTE, img ); - check_for_GL_errors( "glTexImage2D" ); - /*printf( "OpenGL DXT compressor\n" ); */ - } - /* are any MIPmaps desired? */ - if( flags & SOIL_FLAG_MIPMAPS ) - { - int MIPlevel = 1; - int MIPwidth = (width+1) / 2; - int MIPheight = (height+1) / 2; - unsigned char *resampled = (unsigned char*)malloc( channels*MIPwidth*MIPheight ); - while( ((1< 0; --i ) - { - unsigned char temp = pixel_data[index1]; - pixel_data[index1] = pixel_data[index2]; - pixel_data[index2] = temp; - ++index1; - ++index2; - } - } - - /* save the image */ - save_result = SOIL_save_image( filename, image_type, width, height, 3, pixel_data); - - /* And free the memory */ - SOIL_free_image_data( pixel_data ); - return save_result; -} - -unsigned char* - SOIL_load_image - ( - const char *filename, - int *width, int *height, int *channels, - int force_channels - ) -{ - unsigned char *result = stbi_load( filename, - width, height, channels, force_channels ); - if( result == NULL ) - { - result_string_pointer = stbi_failure_reason(); - } else - { - result_string_pointer = "Image loaded"; - } - return result; -} - -unsigned char* - SOIL_load_image_from_memory - ( - const unsigned char *const buffer, - int buffer_length, - int *width, int *height, int *channels, - int force_channels - ) -{ - unsigned char *result = stbi_load_from_memory( - buffer, buffer_length, - width, height, channels, - force_channels ); - if( result == NULL ) - { - result_string_pointer = stbi_failure_reason(); - } else - { - result_string_pointer = "Image loaded from memory"; - } - return result; -} - -int - SOIL_save_image - ( - const char *filename, - int image_type, - int width, int height, int channels, - const unsigned char *const data - ) -{ - int save_result; - - /* error check */ - if( (width < 1) || (height < 1) || - (channels < 1) || (channels > 4) || - (data == NULL) || - (filename == NULL) ) - { - return 0; - } - if( image_type == SOIL_SAVE_TYPE_BMP ) - { - save_result = stbi_write_bmp( filename, - width, height, channels, (void*)data ); - } else - if( image_type == SOIL_SAVE_TYPE_TGA ) - { - save_result = stbi_write_tga( filename, - width, height, channels, (void*)data ); - } else - if( image_type == SOIL_SAVE_TYPE_DDS ) - { - save_result = save_image_as_DDS( filename, - width, height, channels, (const unsigned char *const)data ); - } else - { - save_result = 0; - } - if( save_result == 0 ) - { - result_string_pointer = "Saving the image failed"; - } else - { - result_string_pointer = "Image saved"; - } - return save_result; -} - -void - SOIL_free_image_data - ( - unsigned char *img_data - ) -{ - free( (void*)img_data ); -} - -const char* - SOIL_last_result - ( - void - ) -{ - return result_string_pointer; -} - -unsigned int SOIL_direct_load_DDS_from_memory( - const unsigned char *const buffer, - int buffer_length, - unsigned int reuse_texture_ID, - int flags, - int loading_as_cubemap ) -{ - /* variables */ - DDS_header header; - unsigned int buffer_index = 0; - unsigned int tex_ID = 0; - /* file reading variables */ - unsigned int S3TC_type = 0; - unsigned char *DDS_data; - unsigned int DDS_main_size; - unsigned int DDS_full_size; - unsigned int width, height; - int mipmaps, cubemap, uncompressed, block_size = 16; - unsigned int flag; - unsigned int cf_target, ogl_target_start, ogl_target_end; - unsigned int opengl_texture_type; - int i; - /* 1st off, does the filename even exist? */ - if( NULL == buffer ) - { - /* we can't do it! */ - result_string_pointer = "NULL buffer"; - return 0; - } - if( buffer_length < sizeof( DDS_header ) ) - { - /* we can't do it! */ - result_string_pointer = "DDS file was too small to contain the DDS header"; - return 0; - } - /* try reading in the header */ - memcpy ( (void*)(&header), (const void *)buffer, sizeof( DDS_header ) ); - buffer_index = sizeof( DDS_header ); - /* guilty until proven innocent */ - result_string_pointer = "Failed to read a known DDS header"; - /* validate the header (warning, "goto"'s ahead, shield your eyes!!) */ - flag = ('D'<<0)|('D'<<8)|('S'<<16)|(' '<<24); - if( header.dwMagic != flag ) {goto quick_exit;} - if( header.dwSize != 124 ) {goto quick_exit;} - /* I need all of these */ - flag = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; - if( (header.dwFlags & flag) != flag ) {goto quick_exit;} - /* According to the MSDN spec, the dwFlags should contain - DDSD_LINEARSIZE if it's compressed, or DDSD_PITCH if - uncompressed. Some DDS writers do not conform to the - spec, so I need to make my reader more tolerant */ - /* I need one of these */ - flag = DDPF_FOURCC | DDPF_RGB; - if( (header.sPixelFormat.dwFlags & flag) == 0 ) {goto quick_exit;} - if( header.sPixelFormat.dwSize != 32 ) {goto quick_exit;} - if( (header.sCaps.dwCaps1 & DDSCAPS_TEXTURE) == 0 ) {goto quick_exit;} - /* make sure it is a type we can upload */ - if( (header.sPixelFormat.dwFlags & DDPF_FOURCC) && - !( - (header.sPixelFormat.dwFourCC == (('D'<<0)|('X'<<8)|('T'<<16)|('1'<<24))) || - (header.sPixelFormat.dwFourCC == (('D'<<0)|('X'<<8)|('T'<<16)|('3'<<24))) || - (header.sPixelFormat.dwFourCC == (('D'<<0)|('X'<<8)|('T'<<16)|('5'<<24))) - ) ) - { - goto quick_exit; - } - /* OK, validated the header, let's load the image data */ - result_string_pointer = "DDS header loaded and validated"; - width = header.dwWidth; - height = header.dwHeight; - uncompressed = 1 - (header.sPixelFormat.dwFlags & DDPF_FOURCC) / DDPF_FOURCC; - cubemap = (header.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP) / DDSCAPS2_CUBEMAP; - if( uncompressed ) - { - S3TC_type = GL_RGB; - block_size = 3; - if( header.sPixelFormat.dwFlags & DDPF_ALPHAPIXELS ) - { - S3TC_type = GL_RGBA; - block_size = 4; - } - DDS_main_size = width * height * block_size; - } else - { - /* can we even handle direct uploading to OpenGL DXT compressed images? */ - if( query_DXT_capability() != SOIL_CAPABILITY_PRESENT ) - { - /* we can't do it! */ - result_string_pointer = "Direct upload of S3TC images not supported by the OpenGL driver"; - return 0; - } - /* well, we know it is DXT1/3/5, because we checked above */ - switch( (header.sPixelFormat.dwFourCC >> 24) - '0' ) - { - case 1: - S3TC_type = SOIL_RGBA_S3TC_DXT1; - block_size = 8; - break; - case 3: - S3TC_type = SOIL_RGBA_S3TC_DXT3; - block_size = 16; - break; - case 5: - S3TC_type = SOIL_RGBA_S3TC_DXT5; - block_size = 16; - break; - } - DDS_main_size = ((width+3)>>2)*((height+3)>>2)*block_size; - } - if( cubemap ) - { - /* does the user want a cubemap? */ - if( !loading_as_cubemap ) - { - /* we can't do it! */ - result_string_pointer = "DDS image was a cubemap"; - return 0; - } - /* can we even handle cubemaps with the OpenGL driver? */ - if( query_cubemap_capability() != SOIL_CAPABILITY_PRESENT ) - { - /* we can't do it! */ - result_string_pointer = "Direct upload of cubemap images not supported by the OpenGL driver"; - return 0; - } - ogl_target_start = SOIL_TEXTURE_CUBE_MAP_POSITIVE_X; - ogl_target_end = SOIL_TEXTURE_CUBE_MAP_NEGATIVE_Z; - opengl_texture_type = SOIL_TEXTURE_CUBE_MAP; - } else - { - /* does the user want a non-cubemap? */ - if( loading_as_cubemap ) - { - /* we can't do it! */ - result_string_pointer = "DDS image was not a cubemap"; - return 0; - } - ogl_target_start = GL_TEXTURE_2D; - ogl_target_end = GL_TEXTURE_2D; - opengl_texture_type = GL_TEXTURE_2D; - } - if( (header.sCaps.dwCaps1 & DDSCAPS_MIPMAP) && (header.dwMipMapCount > 1) ) - { - int shift_offset; - mipmaps = header.dwMipMapCount - 1; - DDS_full_size = DDS_main_size; - if( uncompressed ) - { - /* uncompressed DDS, simple MIPmap size calculation */ - shift_offset = 0; - } else - { - /* compressed DDS, MIPmap size calculation is block based */ - shift_offset = 2; - } - for( i = 1; i <= mipmaps; ++ i ) - { - int w, h; - w = width >> (shift_offset + i); - h = height >> (shift_offset + i); - if( w < 1 ) - { - w = 1; - } - if( h < 1 ) - { - h = 1; - } - DDS_full_size += w*h*block_size; - } - } else - { - mipmaps = 0; - DDS_full_size = DDS_main_size; - } - DDS_data = (unsigned char*)malloc( DDS_full_size ); - /* got the image data RAM, create or use an existing OpenGL texture handle */ - tex_ID = reuse_texture_ID; - if( tex_ID == 0 ) - { - glGenTextures( 1, &tex_ID ); - } - /* bind an OpenGL texture ID */ - glBindTexture( opengl_texture_type, tex_ID ); - /* do this for each face of the cubemap! */ - for( cf_target = ogl_target_start; cf_target <= ogl_target_end; ++cf_target ) - { - if( buffer_index + DDS_full_size <= buffer_length ) - { - unsigned int byte_offset = DDS_main_size; - memcpy( (void*)DDS_data, (const void*)(&buffer[buffer_index]), DDS_full_size ); - buffer_index += DDS_full_size; - /* upload the main chunk */ - if( uncompressed ) - { - /* and remember, DXT uncompressed uses BGR(A), - so swap to RGB(A) for ALL MIPmap levels */ - for( i = 0; i < DDS_full_size; i += block_size ) - { - unsigned char temp = DDS_data[i]; - DDS_data[i] = DDS_data[i+2]; - DDS_data[i+2] = temp; - } - glTexImage2D( - cf_target, 0, - S3TC_type, width, height, 0, - S3TC_type, GL_UNSIGNED_BYTE, DDS_data ); - } else - { - soilGlCompressedTexImage2D( - cf_target, 0, - S3TC_type, width, height, 0, - DDS_main_size, DDS_data ); - } - /* upload the mipmaps, if we have them */ - for( i = 1; i <= mipmaps; ++i ) - { - int w, h, mip_size; - w = width >> i; - h = height >> i; - if( w < 1 ) - { - w = 1; - } - if( h < 1 ) - { - h = 1; - } - /* upload this mipmap */ - if( uncompressed ) - { - mip_size = w*h*block_size; - glTexImage2D( - cf_target, i, - S3TC_type, w, h, 0, - S3TC_type, GL_UNSIGNED_BYTE, &DDS_data[byte_offset] ); - } else - { - mip_size = ((w+3)/4)*((h+3)/4)*block_size; - soilGlCompressedTexImage2D( - cf_target, i, - S3TC_type, w, h, 0, - mip_size, &DDS_data[byte_offset] ); - } - /* and move to the next mipmap */ - byte_offset += mip_size; - } - /* it worked! */ - result_string_pointer = "DDS file loaded"; - } else - { - glDeleteTextures( 1, & tex_ID ); - tex_ID = 0; - cf_target = ogl_target_end + 1; - result_string_pointer = "DDS file was too small for expected image data"; - } - }/* end reading each face */ - SOIL_free_image_data( DDS_data ); - if( tex_ID ) - { - /* did I have MIPmaps? */ - if( mipmaps > 0 ) - { - /* instruct OpenGL to use the MIPmaps */ - glTexParameteri( opengl_texture_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( opengl_texture_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - } else - { - /* instruct OpenGL _NOT_ to use the MIPmaps */ - glTexParameteri( opengl_texture_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( opengl_texture_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - } - /* does the user want clamping, or wrapping? */ - if( flags & SOIL_FLAG_TEXTURE_REPEATS ) - { - glTexParameteri( opengl_texture_type, GL_TEXTURE_WRAP_S, GL_REPEAT ); - glTexParameteri( opengl_texture_type, GL_TEXTURE_WRAP_T, GL_REPEAT ); - glTexParameteri( opengl_texture_type, SOIL_TEXTURE_WRAP_R, GL_REPEAT ); - } else - { - /* unsigned int clamp_mode = SOIL_CLAMP_TO_EDGE; */ - unsigned int clamp_mode = GL_CLAMP; - glTexParameteri( opengl_texture_type, GL_TEXTURE_WRAP_S, clamp_mode ); - glTexParameteri( opengl_texture_type, GL_TEXTURE_WRAP_T, clamp_mode ); - glTexParameteri( opengl_texture_type, SOIL_TEXTURE_WRAP_R, clamp_mode ); - } - } - -quick_exit: - /* report success or failure */ - return tex_ID; -} - -unsigned int SOIL_direct_load_DDS( - const char *filename, - unsigned int reuse_texture_ID, - int flags, - int loading_as_cubemap ) -{ - FILE *f; - unsigned char *buffer; - size_t buffer_length, bytes_read; - unsigned int tex_ID = 0; - /* error checks */ - if( NULL == filename ) - { - result_string_pointer = "NULL filename"; - return 0; - } - f = fopen( filename, "rb" ); - if( NULL == f ) - { - /* the file doesn't seem to exist (or be open-able) */ - result_string_pointer = "Can not find DDS file"; - return 0; - } - fseek( f, 0, SEEK_END ); - buffer_length = ftell( f ); - fseek( f, 0, SEEK_SET ); - buffer = (unsigned char *) malloc( buffer_length ); - if( NULL == buffer ) - { - result_string_pointer = "malloc failed"; - fclose( f ); - return 0; - } - bytes_read = fread( (void*)buffer, 1, buffer_length, f ); - fclose( f ); - if( bytes_read < buffer_length ) - { - /* huh? */ - buffer_length = bytes_read; - } - /* now try to do the loading */ - tex_ID = SOIL_direct_load_DDS_from_memory( - (const unsigned char *const)buffer, buffer_length, - reuse_texture_ID, flags, loading_as_cubemap ); - SOIL_free_image_data( buffer ); - return tex_ID; -} - -int query_NPOT_capability( void ) -{ - /* check for the capability */ - if( has_NPOT_capability == SOIL_CAPABILITY_UNKNOWN ) - { - /* we haven't yet checked for the capability, do so */ - if( - (NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ), - "GL_ARB_texture_non_power_of_two" ) ) - ) - { - /* not there, flag the failure */ - has_NPOT_capability = SOIL_CAPABILITY_NONE; - } else - { - /* it's there! */ - has_NPOT_capability = SOIL_CAPABILITY_PRESENT; - } - } - /* let the user know if we can do non-power-of-two textures or not */ - return has_NPOT_capability; -} - -int query_tex_rectangle_capability( void ) -{ - /* check for the capability */ - if( has_tex_rectangle_capability == SOIL_CAPABILITY_UNKNOWN ) - { - /* we haven't yet checked for the capability, do so */ - if( - (NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ), - "GL_ARB_texture_rectangle" ) ) - && - (NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ), - "GL_EXT_texture_rectangle" ) ) - && - (NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ), - "GL_NV_texture_rectangle" ) ) - ) - { - /* not there, flag the failure */ - has_tex_rectangle_capability = SOIL_CAPABILITY_NONE; - } else - { - /* it's there! */ - has_tex_rectangle_capability = SOIL_CAPABILITY_PRESENT; - } - } - /* let the user know if we can do texture rectangles or not */ - return has_tex_rectangle_capability; -} - -int query_cubemap_capability( void ) -{ - /* check for the capability */ - if( has_cubemap_capability == SOIL_CAPABILITY_UNKNOWN ) - { - /* we haven't yet checked for the capability, do so */ - if( - (NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ), - "GL_ARB_texture_cube_map" ) ) - && - (NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ), - "GL_EXT_texture_cube_map" ) ) - ) - { - /* not there, flag the failure */ - has_cubemap_capability = SOIL_CAPABILITY_NONE; - } else - { - /* it's there! */ - has_cubemap_capability = SOIL_CAPABILITY_PRESENT; - } - } - /* let the user know if we can do cubemaps or not */ - return has_cubemap_capability; -} - -int query_DXT_capability( void ) -{ - /* check for the capability */ - if( has_DXT_capability == SOIL_CAPABILITY_UNKNOWN ) - { - /* we haven't yet checked for the capability, do so */ - if( NULL == strstr( - (char const*)glGetString( GL_EXTENSIONS ), - "GL_EXT_texture_compression_s3tc" ) ) - { - /* not there, flag the failure */ - has_DXT_capability = SOIL_CAPABILITY_NONE; - } else - { - /* and find the address of the extension function */ - P_SOIL_GLCOMPRESSEDTEXIMAGE2DPROC ext_addr = NULL; - #ifdef WIN32 - ext_addr = (P_SOIL_GLCOMPRESSEDTEXIMAGE2DPROC) - wglGetProcAddress - ( - "glCompressedTexImage2DARB" - ); - #elif defined(__APPLE__) || defined(__APPLE_CC__) - /* I can't test this Apple stuff! */ - CFBundleRef bundle; - CFURLRef bundleURL = - CFURLCreateWithFileSystemPath( - kCFAllocatorDefault, - CFSTR("/System/Library/Frameworks/OpenGL.framework"), - kCFURLPOSIXPathStyle, - true ); - CFStringRef extensionName = - CFStringCreateWithCString( - kCFAllocatorDefault, - "glCompressedTexImage2DARB", - kCFStringEncodingASCII ); - bundle = CFBundleCreate( kCFAllocatorDefault, bundleURL ); - assert( bundle != NULL ); - ext_addr = (P_SOIL_GLCOMPRESSEDTEXIMAGE2DPROC) - CFBundleGetFunctionPointerForName - ( - bundle, extensionName - ); - CFRelease( bundleURL ); - CFRelease( extensionName ); - CFRelease( bundle ); - #else - ext_addr = (P_SOIL_GLCOMPRESSEDTEXIMAGE2DPROC) - glXGetProcAddressARB - ( - (const GLubyte *)"glCompressedTexImage2DARB" - ); - #endif - /* Flag it so no checks needed later */ - if( NULL == ext_addr ) - { - /* hmm, not good!! This should not happen, but does on my - laptop's VIA chipset. The GL_EXT_texture_compression_s3tc - spec requires that ARB_texture_compression be present too. - this means I can upload and have the OpenGL drive do the - conversion, but I can't use my own routines or load DDS files - from disk and upload them directly [8^( */ - has_DXT_capability = SOIL_CAPABILITY_NONE; - } else - { - /* all's well! */ - soilGlCompressedTexImage2D = ext_addr; - has_DXT_capability = SOIL_CAPABILITY_PRESENT; - } - } - } - /* let the user know if we can do DXT or not */ - return has_DXT_capability; -} diff --git a/src/soil/SOIL_C.h b/src/soil/SOIL_C.h deleted file mode 100755 index 57f375b7..00000000 --- a/src/soil/SOIL_C.h +++ /dev/null @@ -1,433 +0,0 @@ -/** - @mainpage SOIL - - Jonathan Dummer - 2007-07-26-10.36 - - Simple OpenGL Image Library - - A tiny c library for uploading images as - textures into OpenGL. Also saving and - loading of images is supported. - - I'm using Sean's Tool Box image loader as a base: - http://www.nothings.org/ - - I'm upgrading it to load TGA and DDS files, and a direct - path for loading DDS files straight into OpenGL textures, - when applicable. - - Image Formats: - - BMP load & save - - TGA load & save - - DDS load & save - - PNG load - - JPG load - - OpenGL Texture Features: - - resample to power-of-two sizes - - MIPmap generation - - compressed texture S3TC formats (if supported) - - can pre-multiply alpha for you, for better compositing - - can flip image about the y-axis (except pre-compressed DDS files) - - Thanks to: - * Sean Barret - for the awesome stb_image - * Dan Venkitachalam - for finding some non-compliant DDS files, and patching some explicit casts - * everybody at gamedev.net -**/ - -#ifndef HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY -#define HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY - -#ifdef __cplusplus -extern "C" { -#endif - -/** - The format of images that may be loaded (force_channels). - SOIL_LOAD_AUTO leaves the image in whatever format it was found. - SOIL_LOAD_L forces the image to load as Luminous (greyscale) - SOIL_LOAD_LA forces the image to load as Luminous with Alpha - SOIL_LOAD_RGB forces the image to load as Red Green Blue - SOIL_LOAD_RGBA forces the image to load as Red Green Blue Alpha -**/ -enum -{ - SOIL_LOAD_AUTO = 0, - SOIL_LOAD_L = 1, - SOIL_LOAD_LA = 2, - SOIL_LOAD_RGB = 3, - SOIL_LOAD_RGBA = 4 -}; - -/** - Passed in as reuse_texture_ID, will cause SOIL to - register a new texture ID using glGenTextures(). - If the value passed into reuse_texture_ID > 0 then - SOIL will just re-use that texture ID (great for - reloading image assets in-game!) -**/ -enum -{ - SOIL_CREATE_NEW_ID = 0 -}; - -/** - flags you can pass into SOIL_load_OGL_texture() - and SOIL_create_OGL_texture(). - (note that if SOIL_FLAG_DDS_LOAD_DIRECT is used - the rest of the flags with the exception of - SOIL_FLAG_TEXTURE_REPEATS will be ignored while - loading already-compressed DDS files.) - - SOIL_FLAG_POWER_OF_TWO: force the image to be POT - SOIL_FLAG_MIPMAPS: generate mipmaps for the texture - SOIL_FLAG_TEXTURE_REPEATS: otherwise will clamp - SOIL_FLAG_MULTIPLY_ALPHA: for using (GL_ONE,GL_ONE_MINUS_SRC_ALPHA) blending - SOIL_FLAG_INVERT_Y: flip the image vertically - SOIL_FLAG_COMPRESS_TO_DXT: if the card can display them, will convert RGB to DXT1, RGBA to DXT5 - SOIL_FLAG_DDS_LOAD_DIRECT: will load DDS files directly without _ANY_ additional processing - SOIL_FLAG_NTSC_SAFE_RGB: clamps RGB components to the range [16,235] - SOIL_FLAG_CoCg_Y: Google YCoCg; RGB=>CoYCg, RGBA=>CoCgAY - SOIL_FLAG_TEXTURE_RECTANGE: uses ARB_texture_rectangle ; pixel indexed & no repeat or MIPmaps or cubemaps -**/ -enum -{ - SOIL_FLAG_POWER_OF_TWO = 1, - SOIL_FLAG_MIPMAPS = 2, - SOIL_FLAG_TEXTURE_REPEATS = 4, - SOIL_FLAG_MULTIPLY_ALPHA = 8, - SOIL_FLAG_INVERT_Y = 16, - SOIL_FLAG_COMPRESS_TO_DXT = 32, - SOIL_FLAG_DDS_LOAD_DIRECT = 64, - SOIL_FLAG_NTSC_SAFE_RGB = 128, - SOIL_FLAG_CoCg_Y = 256, - SOIL_FLAG_TEXTURE_RECTANGLE = 512 -}; - -/** - The types of images that may be saved. - (TGA supports uncompressed RGB / RGBA) - (BMP supports uncompressed RGB) - (DDS supports DXT1 and DXT5) -**/ -enum -{ - SOIL_SAVE_TYPE_TGA = 0, - SOIL_SAVE_TYPE_BMP = 1, - SOIL_SAVE_TYPE_DDS = 2 -}; - -/** - Defines the order of faces in a DDS cubemap. - I recommend that you use the same order in single - image cubemap files, so they will be interchangeable - with DDS cubemaps when using SOIL. -**/ -#define SOIL_DDS_CUBEMAP_FACE_ORDER "EWUDNS" - -/** - The types of internal fake HDR representations - - SOIL_HDR_RGBE: RGB * pow( 2.0, A - 128.0 ) - SOIL_HDR_RGBdivA: RGB / A - SOIL_HDR_RGBdivA2: RGB / (A*A) -**/ -enum -{ - SOIL_HDR_RGBE = 0, - SOIL_HDR_RGBdivA = 1, - SOIL_HDR_RGBdivA2 = 2 -}; - -/** - Loads an image from disk into an OpenGL texture. - \param filename the name of the file to upload as a texture - \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_load_OGL_texture - ( - const char *filename, - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Loads 6 images from disk into an OpenGL cubemap texture. - \param x_pos_file the name of the file to upload as the +x cube face - \param x_neg_file the name of the file to upload as the -x cube face - \param y_pos_file the name of the file to upload as the +y cube face - \param y_neg_file the name of the file to upload as the -y cube face - \param z_pos_file the name of the file to upload as the +z cube face - \param z_neg_file the name of the file to upload as the -z cube face - \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_load_OGL_cubemap - ( - const char *x_pos_file, - const char *x_neg_file, - const char *y_pos_file, - const char *y_neg_file, - const char *z_pos_file, - const char *z_neg_file, - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Loads 1 image from disk and splits it into an OpenGL cubemap texture. - \param filename the name of the file to upload as a texture - \param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc. - \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_load_OGL_single_cubemap - ( - const char *filename, - const char face_order[6], - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Loads an HDR image from disk into an OpenGL texture. - \param filename the name of the file to upload as a texture - \param fake_HDR_format SOIL_HDR_RGBE, SOIL_HDR_RGBdivA, SOIL_HDR_RGBdivA2 - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_load_OGL_HDR_texture - ( - const char *filename, - int fake_HDR_format, - int rescale_to_max, - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Loads an image from RAM into an OpenGL texture. - \param buffer the image data in RAM just as if it were still in a file - \param buffer_length the size of the buffer in bytes - \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_load_OGL_texture_from_memory - ( - const unsigned char *const buffer, - int buffer_length, - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Loads 6 images from memory into an OpenGL cubemap texture. - \param x_pos_buffer the image data in RAM to upload as the +x cube face - \param x_pos_buffer_length the size of the above buffer - \param x_neg_buffer the image data in RAM to upload as the +x cube face - \param x_neg_buffer_length the size of the above buffer - \param y_pos_buffer the image data in RAM to upload as the +x cube face - \param y_pos_buffer_length the size of the above buffer - \param y_neg_buffer the image data in RAM to upload as the +x cube face - \param y_neg_buffer_length the size of the above buffer - \param z_pos_buffer the image data in RAM to upload as the +x cube face - \param z_pos_buffer_length the size of the above buffer - \param z_neg_buffer the image data in RAM to upload as the +x cube face - \param z_neg_buffer_length the size of the above buffer - \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_load_OGL_cubemap_from_memory - ( - const unsigned char *const x_pos_buffer, - int x_pos_buffer_length, - const unsigned char *const x_neg_buffer, - int x_neg_buffer_length, - const unsigned char *const y_pos_buffer, - int y_pos_buffer_length, - const unsigned char *const y_neg_buffer, - int y_neg_buffer_length, - const unsigned char *const z_pos_buffer, - int z_pos_buffer_length, - const unsigned char *const z_neg_buffer, - int z_neg_buffer_length, - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Loads 1 image from RAM and splits it into an OpenGL cubemap texture. - \param buffer the image data in RAM just as if it were still in a file - \param buffer_length the size of the buffer in bytes - \param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc. - \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_load_OGL_single_cubemap_from_memory - ( - const unsigned char *const buffer, - int buffer_length, - const char face_order[6], - int force_channels, - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Creates a 2D OpenGL texture from raw image data. Note that the raw data is - _NOT_ freed after the upload (so the user can load various versions). - \param data the raw data to be uploaded as an OpenGL texture - \param width the width of the image in pixels - \param height the height of the image in pixels - \param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_create_OGL_texture - ( - const unsigned char *const data, - int width, int height, int channels, - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Creates an OpenGL cubemap texture by splitting up 1 image into 6 parts. - \param data the raw data to be uploaded as an OpenGL texture - \param width the width of the image in pixels - \param height the height of the image in pixels - \param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA - \param face_order the order of the faces in the file, and combination of NSWEUD, for North, South, Up, etc. - \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) - \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT - \return 0-failed, otherwise returns the OpenGL texture handle -**/ -unsigned int - SOIL_create_OGL_single_cubemap - ( - const unsigned char *const data, - int width, int height, int channels, - const char face_order[6], - unsigned int reuse_texture_ID, - unsigned int flags - ); - -/** - Captures the OpenGL window (RGB) and saves it to disk - \return 0 if it failed, otherwise returns 1 -**/ -int - SOIL_save_screenshot - ( - const char *filename, - int image_type, - int x, int y, - int width, int height - ); - -/** - Loads an image from disk into an array of unsigned chars. - Note that *channels return the original channel count of the - image. If force_channels was other than SOIL_LOAD_AUTO, - the resulting image has force_channels, but *channels may be - different (if the original image had a different channel - count). - \return 0 if failed, otherwise returns 1 -**/ -unsigned char* - SOIL_load_image - ( - const char *filename, - int *width, int *height, int *channels, - int force_channels - ); - -/** - Loads an image from memory into an array of unsigned chars. - Note that *channels return the original channel count of the - image. If force_channels was other than SOIL_LOAD_AUTO, - the resulting image has force_channels, but *channels may be - different (if the original image had a different channel - count). - \return 0 if failed, otherwise returns 1 -**/ -unsigned char* - SOIL_load_image_from_memory - ( - const unsigned char *const buffer, - int buffer_length, - int *width, int *height, int *channels, - int force_channels - ); - -/** - Saves an image from an array of unsigned chars (RGBA) to disk - \return 0 if failed, otherwise returns 1 -**/ -int - SOIL_save_image - ( - const char *filename, - int image_type, - int width, int height, int channels, - const unsigned char *const data - ); - -/** - Frees the image data (note, this is just C's "free()"...this function is - present mostly so C++ programmers don't forget to use "free()" and call - "delete []" instead [8^) -**/ -void - SOIL_free_image_data - ( - unsigned char *img_data - ); - -/** - This function resturn a pointer to a string describing the last thing - that happened inside SOIL. It can be used to determine why an image - failed to load. -**/ -const char* - SOIL_last_result - ( - void - ); - - -#ifdef __cplusplus -} -#endif - -#endif /* HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY */ diff --git a/src/soil/image_DXT.c b/src/soil/image_DXT.c deleted file mode 100755 index eb90be67..00000000 --- a/src/soil/image_DXT.c +++ /dev/null @@ -1,632 +0,0 @@ -/* - Jonathan Dummer - 2007-07-31-10.32 - - simple DXT compression / decompression code - - public domain -*/ - -#include "image_DXT.h" -#include -#include -#include -#include - -/* set this =1 if you want to use the covarince matrix method... - which is better than my method of using standard deviations - overall, except on the infintesimal chance that the power - method fails for finding the largest eigenvector */ -#define USE_COV_MAT 1 - -/********* Function Prototypes *********/ -/* - Takes a 4x4 block of pixels and compresses it into 8 bytes - in DXT1 format (color only, no alpha). Speed is valued - over prettyness, at least for now. -*/ -void compress_DDS_color_block( - int channels, - const unsigned char *const uncompressed, - unsigned char compressed[8] ); -/* - Takes a 4x4 block of pixels and compresses the alpha - component it into 8 bytes for use in DXT5 DDS files. - Speed is valued over prettyness, at least for now. -*/ -void compress_DDS_alpha_block( - const unsigned char *const uncompressed, - unsigned char compressed[8] ); - -/********* Actual Exposed Functions *********/ -int - save_image_as_DDS - ( - const char *filename, - int width, int height, int channels, - const unsigned char *const data - ) -{ - /* variables */ - FILE *fout; - unsigned char *DDS_data; - DDS_header header; - int DDS_size; - /* error check */ - if( (NULL == filename) || - (width < 1) || (height < 1) || - (channels < 1) || (channels > 4) || - (data == NULL ) ) - { - return 0; - } - /* Convert the image */ - if( (channels & 1) == 1 ) - { - /* no alpha, just use DXT1 */ - DDS_data = convert_image_to_DXT1( data, width, height, channels, &DDS_size ); - } else - { - /* has alpha, so use DXT5 */ - DDS_data = convert_image_to_DXT5( data, width, height, channels, &DDS_size ); - } - /* save it */ - memset( &header, 0, sizeof( DDS_header ) ); - header.dwMagic = ('D' << 0) | ('D' << 8) | ('S' << 16) | (' ' << 24); - header.dwSize = 124; - header.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_LINEARSIZE; - header.dwWidth = width; - header.dwHeight = height; - header.dwPitchOrLinearSize = DDS_size; - header.sPixelFormat.dwSize = 32; - header.sPixelFormat.dwFlags = DDPF_FOURCC; - if( (channels & 1) == 1 ) - { - header.sPixelFormat.dwFourCC = ('D' << 0) | ('X' << 8) | ('T' << 16) | ('1' << 24); - } else - { - header.sPixelFormat.dwFourCC = ('D' << 0) | ('X' << 8) | ('T' << 16) | ('5' << 24); - } - header.sCaps.dwCaps1 = DDSCAPS_TEXTURE; - /* write it out */ - fout = fopen( filename, "wb"); - fwrite( &header, sizeof( DDS_header ), 1, fout ); - fwrite( DDS_data, 1, DDS_size, fout ); - fclose( fout ); - /* done */ - free( DDS_data ); - return 1; -} - -unsigned char* convert_image_to_DXT1( - const unsigned char *const uncompressed, - int width, int height, int channels, - int *out_size ) -{ - unsigned char *compressed; - int i, j, x, y; - unsigned char ublock[16*3]; - unsigned char cblock[8]; - int index = 0, chan_step = 1; - int block_count = 0; - /* error check */ - *out_size = 0; - if( (width < 1) || (height < 1) || - (NULL == uncompressed) || - (channels < 1) || (channels > 4) ) - { - return NULL; - } - /* for channels == 1 or 2, I do not step forward for R,G,B values */ - if( channels < 3 ) - { - chan_step = 0; - } - /* get the RAM for the compressed image - (8 bytes per 4x4 pixel block) */ - *out_size = ((width+3) >> 2) * ((height+3) >> 2) * 8; - compressed = (unsigned char*)malloc( *out_size ); - /* go through each block */ - for( j = 0; j < height; j += 4 ) - { - for( i = 0; i < width; i += 4 ) - { - /* copy this block into a new one */ - int idx = 0; - int mx = 4, my = 4; - if( j+4 >= height ) - { - my = height - j; - } - if( i+4 >= width ) - { - mx = width - i; - } - for( y = 0; y < my; ++y ) - { - for( x = 0; x < mx; ++x ) - { - ublock[idx++] = uncompressed[(j+y)*width*channels+(i+x)*channels]; - ublock[idx++] = uncompressed[(j+y)*width*channels+(i+x)*channels+chan_step]; - ublock[idx++] = uncompressed[(j+y)*width*channels+(i+x)*channels+chan_step+chan_step]; - } - for( x = mx; x < 4; ++x ) - { - ublock[idx++] = ublock[0]; - ublock[idx++] = ublock[1]; - ublock[idx++] = ublock[2]; - } - } - for( y = my; y < 4; ++y ) - { - for( x = 0; x < 4; ++x ) - { - ublock[idx++] = ublock[0]; - ublock[idx++] = ublock[1]; - ublock[idx++] = ublock[2]; - } - } - /* compress the block */ - ++block_count; - compress_DDS_color_block( 3, ublock, cblock ); - /* copy the data from the block into the main block */ - for( x = 0; x < 8; ++x ) - { - compressed[index++] = cblock[x]; - } - } - } - return compressed; -} - -unsigned char* convert_image_to_DXT5( - const unsigned char *const uncompressed, - int width, int height, int channels, - int *out_size ) -{ - unsigned char *compressed; - int i, j, x, y; - unsigned char ublock[16*4]; - unsigned char cblock[8]; - int index = 0, chan_step = 1; - int block_count = 0, has_alpha; - /* error check */ - *out_size = 0; - if( (width < 1) || (height < 1) || - (NULL == uncompressed) || - (channels < 1) || ( channels > 4) ) - { - return NULL; - } - /* for channels == 1 or 2, I do not step forward for R,G,B vales */ - if( channels < 3 ) - { - chan_step = 0; - } - /* # channels = 1 or 3 have no alpha, 2 & 4 do have alpha */ - has_alpha = 1 - (channels & 1); - /* get the RAM for the compressed image - (16 bytes per 4x4 pixel block) */ - *out_size = ((width+3) >> 2) * ((height+3) >> 2) * 16; - compressed = (unsigned char*)malloc( *out_size ); - /* go through each block */ - for( j = 0; j < height; j += 4 ) - { - for( i = 0; i < width; i += 4 ) - { - /* local variables, and my block counter */ - int idx = 0; - int mx = 4, my = 4; - if( j+4 >= height ) - { - my = height - j; - } - if( i+4 >= width ) - { - mx = width - i; - } - for( y = 0; y < my; ++y ) - { - for( x = 0; x < mx; ++x ) - { - ublock[idx++] = uncompressed[(j+y)*width*channels+(i+x)*channels]; - ublock[idx++] = uncompressed[(j+y)*width*channels+(i+x)*channels+chan_step]; - ublock[idx++] = uncompressed[(j+y)*width*channels+(i+x)*channels+chan_step+chan_step]; - ublock[idx++] = - has_alpha * uncompressed[(j+y)*width*channels+(i+x)*channels+channels-1] - + (1-has_alpha)*255; - } - for( x = mx; x < 4; ++x ) - { - ublock[idx++] = ublock[0]; - ublock[idx++] = ublock[1]; - ublock[idx++] = ublock[2]; - ublock[idx++] = ublock[3]; - } - } - for( y = my; y < 4; ++y ) - { - for( x = 0; x < 4; ++x ) - { - ublock[idx++] = ublock[0]; - ublock[idx++] = ublock[1]; - ublock[idx++] = ublock[2]; - ublock[idx++] = ublock[3]; - } - } - /* now compress the alpha block */ - compress_DDS_alpha_block( ublock, cblock ); - /* copy the data from the compressed alpha block into the main buffer */ - for( x = 0; x < 8; ++x ) - { - compressed[index++] = cblock[x]; - } - /* then compress the color block */ - ++block_count; - compress_DDS_color_block( 4, ublock, cblock ); - /* copy the data from the compressed color block into the main buffer */ - for( x = 0; x < 8; ++x ) - { - compressed[index++] = cblock[x]; - } - } - } - return compressed; -} - -/********* Helper Functions *********/ -int convert_bit_range( int c, int from_bits, int to_bits ) -{ - int b = (1 << (from_bits - 1)) + c * ((1 << to_bits) - 1); - return (b + (b >> from_bits)) >> from_bits; -} - -int rgb_to_565( int r, int g, int b ) -{ - return - (convert_bit_range( r, 8, 5 ) << 11) | - (convert_bit_range( g, 8, 6 ) << 05) | - (convert_bit_range( b, 8, 5 ) << 00); -} - -void rgb_888_from_565( unsigned int c, int *r, int *g, int *b ) -{ - *r = convert_bit_range( (c >> 11) & 31, 5, 8 ); - *g = convert_bit_range( (c >> 05) & 63, 6, 8 ); - *b = convert_bit_range( (c >> 00) & 31, 5, 8 ); -} - -void compute_color_line_STDEV( - const unsigned char *const uncompressed, - int channels, - float point[3], float direction[3] ) -{ - const float inv_16 = 1.0f / 16.0f; - int i; - float sum_r = 0.0f, sum_g = 0.0f, sum_b = 0.0f; - float sum_rr = 0.0f, sum_gg = 0.0f, sum_bb = 0.0f; - float sum_rg = 0.0f, sum_rb = 0.0f, sum_gb = 0.0f; - /* calculate all data needed for the covariance matrix - ( to compare with _rygdxt code) */ - for( i = 0; i < 16*channels; i += channels ) - { - sum_r += uncompressed[i+0]; - sum_rr += uncompressed[i+0] * uncompressed[i+0]; - sum_g += uncompressed[i+1]; - sum_gg += uncompressed[i+1] * uncompressed[i+1]; - sum_b += uncompressed[i+2]; - sum_bb += uncompressed[i+2] * uncompressed[i+2]; - sum_rg += uncompressed[i+0] * uncompressed[i+1]; - sum_rb += uncompressed[i+0] * uncompressed[i+2]; - sum_gb += uncompressed[i+1] * uncompressed[i+2]; - } - /* convert the sums to averages */ - sum_r *= inv_16; - sum_g *= inv_16; - sum_b *= inv_16; - /* and convert the squares to the squares of the value - avg_value */ - sum_rr -= 16.0f * sum_r * sum_r; - sum_gg -= 16.0f * sum_g * sum_g; - sum_bb -= 16.0f * sum_b * sum_b; - sum_rg -= 16.0f * sum_r * sum_g; - sum_rb -= 16.0f * sum_r * sum_b; - sum_gb -= 16.0f * sum_g * sum_b; - /* the point on the color line is the average */ - point[0] = sum_r; - point[1] = sum_g; - point[2] = sum_b; - #if USE_COV_MAT - /* - The following idea was from ryg. - (https://mollyrocket.com/forums/viewtopic.php?t=392) - The method worked great (less RMSE than mine) most of - the time, but had some issues handling some simple - boundary cases, like full green next to full red, - which would generate a covariance matrix like this: - - | 1 -1 0 | - | -1 1 0 | - | 0 0 0 | - - For a given starting vector, the power method can - generate all zeros! So no starting with {1,1,1} - as I was doing! This kind of error is still a - slight posibillity, but will be very rare. - */ - /* use the covariance matrix directly - (1st iteration, don't use all 1.0 values!) */ - sum_r = 1.0f; - sum_g = 2.718281828f; - sum_b = 3.141592654f; - direction[0] = sum_r*sum_rr + sum_g*sum_rg + sum_b*sum_rb; - direction[1] = sum_r*sum_rg + sum_g*sum_gg + sum_b*sum_gb; - direction[2] = sum_r*sum_rb + sum_g*sum_gb + sum_b*sum_bb; - /* 2nd iteration, use results from the 1st guy */ - sum_r = direction[0]; - sum_g = direction[1]; - sum_b = direction[2]; - direction[0] = sum_r*sum_rr + sum_g*sum_rg + sum_b*sum_rb; - direction[1] = sum_r*sum_rg + sum_g*sum_gg + sum_b*sum_gb; - direction[2] = sum_r*sum_rb + sum_g*sum_gb + sum_b*sum_bb; - /* 3rd iteration, use results from the 2nd guy */ - sum_r = direction[0]; - sum_g = direction[1]; - sum_b = direction[2]; - direction[0] = sum_r*sum_rr + sum_g*sum_rg + sum_b*sum_rb; - direction[1] = sum_r*sum_rg + sum_g*sum_gg + sum_b*sum_gb; - direction[2] = sum_r*sum_rb + sum_g*sum_gb + sum_b*sum_bb; - #else - /* use my standard deviation method - (very robust, a tiny bit slower and less accurate) */ - direction[0] = sqrt( sum_rr ); - direction[1] = sqrt( sum_gg ); - direction[2] = sqrt( sum_bb ); - /* which has a greater component */ - if( sum_gg > sum_rr ) - { - /* green has greater component, so base the other signs off of green */ - if( sum_rg < 0.0f ) - { - direction[0] = -direction[0]; - } - if( sum_gb < 0.0f ) - { - direction[2] = -direction[2]; - } - } else - { - /* red has a greater component */ - if( sum_rg < 0.0f ) - { - direction[1] = -direction[1]; - } - if( sum_rb < 0.0f ) - { - direction[2] = -direction[2]; - } - } - #endif -} - -void LSE_master_colors_max_min( - int *cmax, int *cmin, - int channels, - const unsigned char *const uncompressed ) -{ - int i, j; - /* the master colors */ - int c0[3], c1[3]; - /* used for fitting the line */ - float sum_x[] = { 0.0f, 0.0f, 0.0f }; - float sum_x2[] = { 0.0f, 0.0f, 0.0f }; - float dot_max = 1.0f, dot_min = -1.0f; - float vec_len2 = 0.0f; - float dot; - /* error check */ - if( (channels < 3) || (channels > 4) ) - { - return; - } - compute_color_line_STDEV( uncompressed, channels, sum_x, sum_x2 ); - vec_len2 = 1.0f / ( 0.00001f + - sum_x2[0]*sum_x2[0] + sum_x2[1]*sum_x2[1] + sum_x2[2]*sum_x2[2] ); - /* finding the max and min vector values */ - dot_max = - ( - sum_x2[0] * uncompressed[0] + - sum_x2[1] * uncompressed[1] + - sum_x2[2] * uncompressed[2] - ); - dot_min = dot_max; - for( i = 1; i < 16; ++i ) - { - dot = - ( - sum_x2[0] * uncompressed[i*channels+0] + - sum_x2[1] * uncompressed[i*channels+1] + - sum_x2[2] * uncompressed[i*channels+2] - ); - if( dot < dot_min ) - { - dot_min = dot; - } else if( dot > dot_max ) - { - dot_max = dot; - } - } - /* and the offset (from the average location) */ - dot = sum_x2[0]*sum_x[0] + sum_x2[1]*sum_x[1] + sum_x2[2]*sum_x[2]; - dot_min -= dot; - dot_max -= dot; - /* post multiply by the scaling factor */ - dot_min *= vec_len2; - dot_max *= vec_len2; - /* OK, build the master colors */ - for( i = 0; i < 3; ++i ) - { - /* color 0 */ - c0[i] = (int)(0.5f + sum_x[i] + dot_max * sum_x2[i]); - if( c0[i] < 0 ) - { - c0[i] = 0; - } else if( c0[i] > 255 ) - { - c0[i] = 255; - } - /* color 1 */ - c1[i] = (int)(0.5f + sum_x[i] + dot_min * sum_x2[i]); - if( c1[i] < 0 ) - { - c1[i] = 0; - } else if( c1[i] > 255 ) - { - c1[i] = 255; - } - } - /* down_sample (with rounding?) */ - i = rgb_to_565( c0[0], c0[1], c0[2] ); - j = rgb_to_565( c1[0], c1[1], c1[2] ); - if( i > j ) - { - *cmax = i; - *cmin = j; - } else - { - *cmax = j; - *cmin = i; - } -} - -void - compress_DDS_color_block - ( - int channels, - const unsigned char *const uncompressed, - unsigned char compressed[8] - ) -{ - /* variables */ - int i; - int next_bit; - int enc_c0, enc_c1; - int c0[4], c1[4]; - float color_line[] = { 0.0f, 0.0f, 0.0f, 0.0f }; - float vec_len2 = 0.0f, dot_offset = 0.0f; - /* stupid order */ - int swizzle4[] = { 0, 2, 3, 1 }; - /* get the master colors */ - LSE_master_colors_max_min( &enc_c0, &enc_c1, channels, uncompressed ); - /* store the 565 color 0 and color 1 */ - compressed[0] = (enc_c0 >> 0) & 255; - compressed[1] = (enc_c0 >> 8) & 255; - compressed[2] = (enc_c1 >> 0) & 255; - compressed[3] = (enc_c1 >> 8) & 255; - /* zero out the compressed data */ - compressed[4] = 0; - compressed[5] = 0; - compressed[6] = 0; - compressed[7] = 0; - /* reconstitute the master color vectors */ - rgb_888_from_565( enc_c0, &c0[0], &c0[1], &c0[2] ); - rgb_888_from_565( enc_c1, &c1[0], &c1[1], &c1[2] ); - /* the new vector */ - vec_len2 = 0.0f; - for( i = 0; i < 3; ++i ) - { - color_line[i] = (float)(c1[i] - c0[i]); - vec_len2 += color_line[i] * color_line[i]; - } - if( vec_len2 > 0.0f ) - { - vec_len2 = 1.0f / vec_len2; - } - /* pre-proform the scaling */ - color_line[0] *= vec_len2; - color_line[1] *= vec_len2; - color_line[2] *= vec_len2; - /* compute the offset (constant) portion of the dot product */ - dot_offset = color_line[0]*c0[0] + color_line[1]*c0[1] + color_line[2]*c0[2]; - /* store the rest of the bits */ - next_bit = 8*4; - for( i = 0; i < 16; ++i ) - { - /* find the dot product of this color, to place it on the line - (should be [-1,1]) */ - int next_value = 0; - float dot_product = - color_line[0] * uncompressed[i*channels+0] + - color_line[1] * uncompressed[i*channels+1] + - color_line[2] * uncompressed[i*channels+2] - - dot_offset; - /* map to [0,3] */ - next_value = (int)( dot_product * 3.0f + 0.5f ); - if( next_value > 3 ) - { - next_value = 3; - } else if( next_value < 0 ) - { - next_value = 0; - } - /* OK, store this value */ - compressed[next_bit >> 3] |= swizzle4[ next_value ] << (next_bit & 7); - next_bit += 2; - } - /* done compressing to DXT1 */ -} - -void - compress_DDS_alpha_block - ( - const unsigned char *const uncompressed, - unsigned char compressed[8] - ) -{ - /* variables */ - int i; - int next_bit; - int a0, a1; - float scale_me; - /* stupid order */ - int swizzle8[] = { 1, 7, 6, 5, 4, 3, 2, 0 }; - /* get the alpha limits (a0 > a1) */ - a0 = a1 = uncompressed[3]; - for( i = 4+3; i < 16*4; i += 4 ) - { - if( uncompressed[i] > a0 ) - { - a0 = uncompressed[i]; - } else if( uncompressed[i] < a1 ) - { - a1 = uncompressed[i]; - } - } - /* store those limits, and zero the rest of the compressed dataset */ - compressed[0] = a0; - compressed[1] = a1; - /* zero out the compressed data */ - compressed[2] = 0; - compressed[3] = 0; - compressed[4] = 0; - compressed[5] = 0; - compressed[6] = 0; - compressed[7] = 0; - /* store the all of the alpha values */ - next_bit = 8*2; - scale_me = 7.9999f / (a0 - a1); - for( i = 3; i < 16*4; i += 4 ) - { - /* convert this alpha value to a 3 bit number */ - int svalue; - int value = (int)((uncompressed[i] - a1) * scale_me); - svalue = swizzle8[ value&7 ]; - /* OK, store this value, start with the 1st byte */ - compressed[next_bit >> 3] |= svalue << (next_bit & 7); - if( (next_bit & 7) > 5 ) - { - /* spans 2 bytes, fill in the start of the 2nd byte */ - compressed[1 + (next_bit >> 3)] |= svalue >> (8 - (next_bit & 7) ); - } - next_bit += 3; - } - /* done compressing to DXT1 */ -} diff --git a/src/soil/image_DXT.h b/src/soil/image_DXT.h deleted file mode 100755 index ce771642..00000000 --- a/src/soil/image_DXT.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - Jonathan Dummer - 2007-07-31-10.32 - - simple DXT compression / decompression code - - public domain -*/ - -#ifndef HEADER_IMAGE_DXT -#define HEADER_IMAGE_DXT - -/** - Converts an image from an array of unsigned chars (RGB or RGBA) to - DXT1 or DXT5, then saves the converted image to disk. - \return 0 if failed, otherwise returns 1 -**/ -int -save_image_as_DDS -( - const char *filename, - int width, int height, int channels, - const unsigned char *const data -); - -/** - take an image and convert it to DXT1 (no alpha) -**/ -unsigned char* -convert_image_to_DXT1 -( - const unsigned char *const uncompressed, - int width, int height, int channels, - int *out_size -); - -/** - take an image and convert it to DXT5 (with alpha) -**/ -unsigned char* -convert_image_to_DXT5 -( - const unsigned char *const uncompressed, - int width, int height, int channels, - int *out_size -); - -/** A bunch of DirectDraw Surface structures and flags **/ -typedef struct -{ - unsigned int dwMagic; - unsigned int dwSize; - unsigned int dwFlags; - unsigned int dwHeight; - unsigned int dwWidth; - unsigned int dwPitchOrLinearSize; - unsigned int dwDepth; - unsigned int dwMipMapCount; - unsigned int dwReserved1[ 11 ]; - - /* DDPIXELFORMAT */ - struct - { - unsigned int dwSize; - unsigned int dwFlags; - unsigned int dwFourCC; - unsigned int dwRGBBitCount; - unsigned int dwRBitMask; - unsigned int dwGBitMask; - unsigned int dwBBitMask; - unsigned int dwAlphaBitMask; - } - sPixelFormat; - - /* DDCAPS2 */ - struct - { - unsigned int dwCaps1; - unsigned int dwCaps2; - unsigned int dwDDSX; - unsigned int dwReserved; - } - sCaps; - unsigned int dwReserved2; -} -DDS_header ; - -/* the following constants were copied directly off the MSDN website */ - -/* The dwFlags member of the original DDSURFACEDESC2 structure - can be set to one or more of the following values. */ -#define DDSD_CAPS 0x00000001 -#define DDSD_HEIGHT 0x00000002 -#define DDSD_WIDTH 0x00000004 -#define DDSD_PITCH 0x00000008 -#define DDSD_PIXELFORMAT 0x00001000 -#define DDSD_MIPMAPCOUNT 0x00020000 -#define DDSD_LINEARSIZE 0x00080000 -#define DDSD_DEPTH 0x00800000 - -/* DirectDraw Pixel Format */ -#define DDPF_ALPHAPIXELS 0x00000001 -#define DDPF_FOURCC 0x00000004 -#define DDPF_RGB 0x00000040 - -/* The dwCaps1 member of the DDSCAPS2 structure can be - set to one or more of the following values. */ -#define DDSCAPS_COMPLEX 0x00000008 -#define DDSCAPS_TEXTURE 0x00001000 -#define DDSCAPS_MIPMAP 0x00400000 - -/* The dwCaps2 member of the DDSCAPS2 structure can be - set to one or more of the following values. */ -#define DDSCAPS2_CUBEMAP 0x00000200 -#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400 -#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800 -#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000 -#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000 -#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000 -#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000 -#define DDSCAPS2_VOLUME 0x00200000 - -#endif /* HEADER_IMAGE_DXT */ diff --git a/src/soil/image_helper.c b/src/soil/image_helper.c deleted file mode 100755 index 445f6bbf..00000000 --- a/src/soil/image_helper.c +++ /dev/null @@ -1,435 +0,0 @@ -/* - Jonathan Dummer - - image helper functions - - MIT license -*/ - -#include "image_helper.h" -#include -#include - -/* Upscaling the image uses simple bilinear interpolation */ -int - up_scale_image - ( - const unsigned char* const orig, - int width, int height, int channels, - unsigned char* resampled, - int resampled_width, int resampled_height - ) -{ - float dx, dy; - int x, y, c; - - /* error(s) check */ - if ( (width < 1) || (height < 1) || - (resampled_width < 2) || (resampled_height < 2) || - (channels < 1) || - (NULL == orig) || (NULL == resampled) ) - { - /* signify badness */ - return 0; - } - /* - for each given pixel in the new map, find the exact location - from the original map which would contribute to this guy - */ - dx = (width - 1.0f) / (resampled_width - 1.0f); - dy = (height - 1.0f) / (resampled_height - 1.0f); - for ( y = 0; y < resampled_height; ++y ) - { - /* find the base y index and fractional offset from that */ - float sampley = y * dy; - int inty = (int)sampley; - /* if( inty < 0 ) { inty = 0; } else */ - if( inty > height - 2 ) { inty = height - 2; } - sampley -= inty; - for ( x = 0; x < resampled_width; ++x ) - { - float samplex = x * dx; - int intx = (int)samplex; - int base_index; - /* find the base x index and fractional offset from that */ - /* if( intx < 0 ) { intx = 0; } else */ - if( intx > width - 2 ) { intx = width - 2; } - samplex -= intx; - /* base index into the original image */ - base_index = (inty * width + intx) * channels; - for ( c = 0; c < channels; ++c ) - { - /* do the sampling */ - float value = 0.5f; - value += orig[base_index] - *(1.0f-samplex)*(1.0f-sampley); - value += orig[base_index+channels] - *(samplex)*(1.0f-sampley); - value += orig[base_index+width*channels] - *(1.0f-samplex)*(sampley); - value += orig[base_index+width*channels+channels] - *(samplex)*(sampley); - /* move to the next channel */ - ++base_index; - /* save the new value */ - resampled[y*resampled_width*channels+x*channels+c] = - (unsigned char)(value); - } - } - } - /* done */ - return 1; -} - -int - mipmap_image - ( - const unsigned char* const orig, - int width, int height, int channels, - unsigned char* resampled, - int block_size_x, int block_size_y - ) -{ - int mip_width, mip_height; - int i, j, c; - - /* error check */ - if( (width < 1) || (height < 1) || - (channels < 1) || (orig == NULL) || - (resampled == NULL) || - (block_size_x < 1) || (block_size_y < 1) ) - { - /* nothing to do */ - return 0; - } - mip_width = width / block_size_x; - mip_height = height / block_size_y; - if( mip_width < 1 ) - { - mip_width = 1; - } - if( mip_height < 1 ) - { - mip_height = 1; - } - for( j = 0; j < mip_height; ++j ) - { - for( i = 0; i < mip_width; ++i ) - { - for( c = 0; c < channels; ++c ) - { - const int index = (j*block_size_y)*width*channels + (i*block_size_x)*channels + c; - int sum_value; - int u,v; - int u_block = block_size_x; - int v_block = block_size_y; - int block_area; - /* do a bit of checking so we don't over-run the boundaries - (necessary for non-square textures!) */ - if( block_size_x * (i+1) > width ) - { - u_block = width - i*block_size_y; - } - if( block_size_y * (j+1) > height ) - { - v_block = height - j*block_size_y; - } - block_area = u_block*v_block; - /* for this pixel, see what the average - of all the values in the block are. - note: start the sum at the rounding value, not at 0 */ - sum_value = block_area >> 1; - for( v = 0; v < v_block; ++v ) - for( u = 0; u < u_block; ++u ) - { - sum_value += orig[index + v*width*channels + u*channels]; - } - resampled[j*mip_width*channels + i*channels + c] = sum_value / block_area; - } - } - } - return 1; -} - -int - scale_image_RGB_to_NTSC_safe - ( - unsigned char* orig, - int width, int height, int channels - ) -{ - const float scale_lo = 16.0f - 0.499f; - const float scale_hi = 235.0f + 0.499f; - int i, j; - int nc = channels; - unsigned char scale_LUT[256]; - /* error check */ - if( (width < 1) || (height < 1) || - (channels < 1) || (orig == NULL) ) - { - /* nothing to do */ - return 0; - } - /* set up the scaling Look Up Table */ - for( i = 0; i < 256; ++i ) - { - scale_LUT[i] = (unsigned char)((scale_hi - scale_lo) * i / 255.0f + scale_lo); - } - /* for channels = 2 or 4, ignore the alpha component */ - nc -= 1 - (channels & 1); - /* OK, go through the image and scale any non-alpha components */ - for( i = 0; i < width*height*channels; i += channels ) - { - for( j = 0; j < nc; ++j ) - { - orig[i+j] = scale_LUT[orig[i+j]]; - } - } - return 1; -} - -unsigned char clamp_byte( int x ) { return ( (x) < 0 ? (0) : ( (x) > 255 ? 255 : (x) ) ); } - -/* - This function takes the RGB components of the image - and converts them into YCoCg. 3 components will be - re-ordered to CoYCg (for optimum DXT1 compression), - while 4 components will be ordered CoCgAY (for DXT5 - compression). -*/ -int - convert_RGB_to_YCoCg - ( - unsigned char* orig, - int width, int height, int channels - ) -{ - int i; - /* error check */ - if( (width < 1) || (height < 1) || - (channels < 3) || (channels > 4) || - (orig == NULL) ) - { - /* nothing to do */ - return -1; - } - /* do the conversion */ - if( channels == 3 ) - { - for( i = 0; i < width*height*3; i += 3 ) - { - int r = orig[i+0]; - int g = (orig[i+1] + 1) >> 1; - int b = orig[i+2]; - int tmp = (2 + r + b) >> 2; - /* Co */ - orig[i+0] = clamp_byte( 128 + ((r - b + 1) >> 1) ); - /* Y */ - orig[i+1] = clamp_byte( g + tmp ); - /* Cg */ - orig[i+2] = clamp_byte( 128 + g - tmp ); - } - } else - { - for( i = 0; i < width*height*4; i += 4 ) - { - int r = orig[i+0]; - int g = (orig[i+1] + 1) >> 1; - int b = orig[i+2]; - unsigned char a = orig[i+3]; - int tmp = (2 + r + b) >> 2; - /* Co */ - orig[i+0] = clamp_byte( 128 + ((r - b + 1) >> 1) ); - /* Cg */ - orig[i+1] = clamp_byte( 128 + g - tmp ); - /* Alpha */ - orig[i+2] = a; - /* Y */ - orig[i+3] = clamp_byte( g + tmp ); - } - } - /* done */ - return 0; -} - -/* - This function takes the YCoCg components of the image - and converts them into RGB. See above. -*/ -int - convert_YCoCg_to_RGB - ( - unsigned char* orig, - int width, int height, int channels - ) -{ - int i; - /* error check */ - if( (width < 1) || (height < 1) || - (channels < 3) || (channels > 4) || - (orig == NULL) ) - { - /* nothing to do */ - return -1; - } - /* do the conversion */ - if( channels == 3 ) - { - for( i = 0; i < width*height*3; i += 3 ) - { - int co = orig[i+0] - 128; - int y = orig[i+1]; - int cg = orig[i+2] - 128; - /* R */ - orig[i+0] = clamp_byte( y + co - cg ); - /* G */ - orig[i+1] = clamp_byte( y + cg ); - /* B */ - orig[i+2] = clamp_byte( y - co - cg ); - } - } else - { - for( i = 0; i < width*height*4; i += 4 ) - { - int co = orig[i+0] - 128; - int cg = orig[i+1] - 128; - unsigned char a = orig[i+2]; - int y = orig[i+3]; - /* R */ - orig[i+0] = clamp_byte( y + co - cg ); - /* G */ - orig[i+1] = clamp_byte( y + cg ); - /* B */ - orig[i+2] = clamp_byte( y - co - cg ); - /* A */ - orig[i+3] = a; - } - } - /* done */ - return 0; -} - -float -find_max_RGBE -( - unsigned char *image, - int width, int height -) -{ - float max_val = 0.0f; - unsigned char *img = image; - int i, j; - for( i = width * height; i > 0; --i ) - { - /* float scale = powf( 2.0f, img[3] - 128.0f ) / 255.0f; */ - float scale = ldexp( 1.0f / 255.0f, (int)(img[3]) - 128 ); - for( j = 0; j < 3; ++j ) - { - if( img[j] * scale > max_val ) - { - max_val = img[j] * scale; - } - } - /* next pixel */ - img += 4; - } - return max_val; -} - -int -RGBE_to_RGBdivA -( - unsigned char *image, - int width, int height, - int rescale_to_max -) -{ - /* local variables */ - int i, iv; - unsigned char *img = image; - float scale = 1.0f; - /* error check */ - if( (!image) || (width < 1) || (height < 1) ) - { - return 0; - } - /* convert (note: no negative numbers, but 0.0 is possible) */ - if( rescale_to_max ) - { - scale = 255.0f / find_max_RGBE( image, width, height ); - } - for( i = width * height; i > 0; --i ) - { - /* decode this pixel, and find the max */ - float r,g,b,e, m; - /* e = scale * powf( 2.0f, img[3] - 128.0f ) / 255.0f; */ - e = scale * ldexp( 1.0f / 255.0f, (int)(img[3]) - 128 ); - r = e * img[0]; - g = e * img[1]; - b = e * img[2]; - m = (r > g) ? r : g; - m = (b > m) ? b : m; - /* and encode it into RGBdivA */ - iv = (m != 0.0f) ? (int)(255.0f / m) : 1.0f; - iv = (iv < 1) ? 1 : iv; - img[3] = (iv > 255) ? 255 : iv; - iv = (int)(img[3] * r + 0.5f); - img[0] = (iv > 255) ? 255 : iv; - iv = (int)(img[3] * g + 0.5f); - img[1] = (iv > 255) ? 255 : iv; - iv = (int)(img[3] * b + 0.5f); - img[2] = (iv > 255) ? 255 : iv; - /* and on to the next pixel */ - img += 4; - } - return 1; -} - -int -RGBE_to_RGBdivA2 -( - unsigned char *image, - int width, int height, - int rescale_to_max -) -{ - /* local variables */ - int i, iv; - unsigned char *img = image; - float scale = 1.0f; - /* error check */ - if( (!image) || (width < 1) || (height < 1) ) - { - return 0; - } - /* convert (note: no negative numbers, but 0.0 is possible) */ - if( rescale_to_max ) - { - scale = 255.0f * 255.0f / find_max_RGBE( image, width, height ); - } - for( i = width * height; i > 0; --i ) - { - /* decode this pixel, and find the max */ - float r,g,b,e, m; - /* e = scale * powf( 2.0f, img[3] - 128.0f ) / 255.0f; */ - e = scale * ldexp( 1.0f / 255.0f, (int)(img[3]) - 128 ); - r = e * img[0]; - g = e * img[1]; - b = e * img[2]; - m = (r > g) ? r : g; - m = (b > m) ? b : m; - /* and encode it into RGBdivA */ - iv = (m != 0.0f) ? (int)sqrtf( 255.0f * 255.0f / m ) : 1.0f; - iv = (iv < 1) ? 1 : iv; - img[3] = (iv > 255) ? 255 : iv; - iv = (int)(img[3] * img[3] * r / 255.0f + 0.5f); - img[0] = (iv > 255) ? 255 : iv; - iv = (int)(img[3] * img[3] * g / 255.0f + 0.5f); - img[1] = (iv > 255) ? 255 : iv; - iv = (int)(img[3] * img[3] * b / 255.0f + 0.5f); - img[2] = (iv > 255) ? 255 : iv; - /* and on to the next pixel */ - img += 4; - } - return 1; -} diff --git a/src/soil/image_helper.h b/src/soil/image_helper.h deleted file mode 100755 index abb257c3..00000000 --- a/src/soil/image_helper.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - Jonathan Dummer - - Image helper functions - - MIT license -*/ - -#ifndef HEADER_IMAGE_HELPER -#define HEADER_IMAGE_HELPER - -#ifdef __cplusplus -extern "C" { -#endif - -/** - This function upscales an image. - Not to be used to create MIPmaps, - but to make it square, - or to make it a power-of-two sized. -**/ -int - up_scale_image - ( - const unsigned char* const orig, - int width, int height, int channels, - unsigned char* resampled, - int resampled_width, int resampled_height - ); - -/** - This function downscales an image. - Used for creating MIPmaps, - the incoming image should be a - power-of-two sized. -**/ -int - mipmap_image - ( - const unsigned char* const orig, - int width, int height, int channels, - unsigned char* resampled, - int block_size_x, int block_size_y - ); - -/** - This function takes the RGB components of the image - and scales each channel from [0,255] to [16,235]. - This makes the colors "Safe" for display on NTSC - displays. Note that this is _NOT_ a good idea for - loading images like normal- or height-maps! -**/ -int - scale_image_RGB_to_NTSC_safe - ( - unsigned char* orig, - int width, int height, int channels - ); - -/** - This function takes the RGB components of the image - and converts them into YCoCg. 3 components will be - re-ordered to CoYCg (for optimum DXT1 compression), - while 4 components will be ordered CoCgAY (for DXT5 - compression). -**/ -int - convert_RGB_to_YCoCg - ( - unsigned char* orig, - int width, int height, int channels - ); - -/** - This function takes the YCoCg components of the image - and converts them into RGB. See above. -**/ -int - convert_YCoCg_to_RGB - ( - unsigned char* orig, - int width, int height, int channels - ); - -/** - Converts an HDR image from an array - of unsigned chars (RGBE) to RGBdivA - \return 0 if failed, otherwise returns 1 -**/ -int - RGBE_to_RGBdivA - ( - unsigned char *image, - int width, int height, - int rescale_to_max - ); - -/** - Converts an HDR image from an array - of unsigned chars (RGBE) to RGBdivA2 - \return 0 if failed, otherwise returns 1 -**/ -int - RGBE_to_RGBdivA2 - ( - unsigned char *image, - int width, int height, - int rescale_to_max - ); - -#ifdef __cplusplus -} -#endif - -#endif /* HEADER_IMAGE_HELPER */ diff --git a/src/soil/soil-api.ads b/src/soil/soil-api.ads deleted file mode 100644 index 4c7727a2..00000000 --- a/src/soil/soil-api.ads +++ /dev/null @@ -1,136 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with Interfaces.C.Strings; -with System; - -with GL.Types; - -private package SOIL.API is - pragma Preelaborate; - - package C renames Interfaces.C; - - function Load_OGL_Texture (Filename : C.char_array; - Force_Channels : Image_Format; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) return GL.Types.UInt; - pragma Import (Convention => C, Entity => Load_OGL_Texture, - External_Name => "SOIL_load_OGL_texture"); - - function Load_OGL_Cubemap (X_Pos_File, X_Neg_File, Y_Pos_File, Y_Neg_File, - Z_Pos_File, Z_Neg_File : C.char_array; - Force_Channels : Image_Format; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) return GL.Types.UInt; - pragma Import (Convention => C, Entity => Load_OGL_Cubemap, - External_Name => "SOIL_load_OGL_cubemap"); - - function Load_OGL_Single_Cubemap (Filename : C.char_array; - Face_Order : Cubemap_Layout; - Force_Channels : Image_Format; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) return GL.Types.UInt; - pragma Import (Convention => C, Entity => Load_OGL_Single_Cubemap, - External_Name => "SOIL_load_OGL_single_cubemap"); - - function Load_OGL_HDR_Texture - (Filename : C.char_array; - Format : Fake_HDR_Representation; - Rescale_To_Max : Bool; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) return GL.Types.UInt; - pragma Import (Convention => C, Entity => Load_OGL_HDR_Texture, - External_Name => "SOIL_load_OGL_HDR_texture"); - - function Load_OGL_Texture_From_Memory - (Buffer : System.Address; - Buffer_Length : C.int; - Force_Channels : Image_Format; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) return GL.Types.UInt; - pragma Import (Convention => C, Entity => Load_OGL_Texture_From_Memory, - External_Name => "SOIL_load_OGL_texture_from_memory"); - - function Load_OGL_Cubemap_From_Memory - (X_Pos_Buffer : System.Address; X_Pos_Length : C.int; - X_Neg_Buffer : System.Address; X_Neg_Length : C.int; - Y_Pos_Buffer : System.Address; Y_Pos_Length : C.int; - Y_Neg_Buffer : System.Address; Y_Neg_Length : C.int; - Z_Pos_Buffer : System.Address; Z_Pos_Length : C.int; - Z_Neg_Buffer : System.Address; Z_Neg_Length : C.int; - Force_Channels : Image_Format; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) - return GL.Types.UInt; - pragma Import (Convention => C, Entity => Load_OGL_Cubemap_From_Memory, - External_Name => "SOIL_load_OGL_cubemap_from_memory"); - - function Load_OGL_Single_Cubemap_From_Memory - (Buffer : System.Address; - Buffer_Length : C.int; - Face_Order : Cubemap_Layout; - Force_Channels : Image_Format; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) return GL.Types.UInt; - pragma Import (Convention => C, Entity => Load_OGL_Single_Cubemap_From_Memory, - External_Name => "SOIL_load_single_cubemap_from_memory"); - - function Create_OGL_Texture (Data : GL.Objects.Textures.Image_Source; - Width, Height : GL.Types.Int; - Channels : Explicit_Image_Format; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) return GL.Types.UInt; - pragma Import (Convention => C, Entity => Create_OGL_Texture, - External_Name => "SOIL_create_OGL_texture"); - - function Create_OGL_Single_Cubemap (Data : GL.Objects.Textures.Image_Source; - Width, Height : GL.Types.Int; - Channels : Image_Format; - Face_Order : Cubemap_Layout; - Reuse_Texture_Id : GL.Types.UInt; - Flags : Texture_Flags) - return GL.Types.UInt; - pragma Import (Convention => C, Entity => Create_OGL_Single_Cubemap, - External_Name => "SOIL_create_OGL_single_cubemap"); - - function Save_Screenshot (Filename : C.char_array; - Image_Type : Image_Save_Type; - X, Y, Width, Height : GL.Types.Int) return Bool; - pragma Import (Convention => C, Entity => Save_Screenshot, - External_Name => "SOIL_save_screenshot"); - - function Load_Image (Filename : C.char_array; - Width, Height : access GL.Types.Int; - Channels : access Explicit_Image_Format; - Force_Channels : Image_Format) - return GL.Objects.Textures.Image_Source; - pragma Import (Convention => C, Entity => Load_Image, - External_Name => "SOIL_load_image"); - - function Load_Image_From_Memory (Buffer : System.Address; - Buffer_Length : C.int; - Width, Height : access GL.Types.Int; - Channels : access Explicit_Image_Format; - Force_Channels : Image_Format) - return GL.Objects.Textures.Image_Source; - pragma Import (Convention => C, Entity => Load_Image_From_Memory, - External_Name => "SOIL_load_image_from_memory"); - - function Save_Image (Filename : C.char_array; - Image_Type : Image_Save_Type; - Width, Height : GL.Types.Int; - Channels : Image_Format; - Data : GL.Objects.Textures.Image_Source) return Bool; - pragma Import (Convention => C, Entity => Save_Image, - External_Name => "SOIL_save_image"); - - procedure Free_Image_Data (Data : GL.Objects.Textures.Image_Source); - pragma Import (Convention => C, Entity => Free_Image_Data, - External_Name => "SOIL_free_image_data"); - - function Last_Result return C.Strings.chars_ptr; - pragma Import (Convention => C, Entity => Last_Result, - External_Name => "SOIL_last_result"); - -end SOIL.API; diff --git a/src/soil/soil-images.adb b/src/soil/soil-images.adb deleted file mode 100644 index 7f341a95..00000000 --- a/src/soil/soil-images.adb +++ /dev/null @@ -1,170 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with System; - -with SOIL.API; - -package body SOIL.Images is - use type GL.Types.UInt; - use type GL.Objects.Textures.Image_Source; - - function Null_Image return GL.Objects.Textures.Image_Source is - begin - return GL.Objects.Textures.Image_Source (System.Null_Address); - end Null_Image; - pragma Inline (Null_Image); - - overriding procedure Initialize (Object : in out Image) is - begin - Object.Reference := new Image_Data'(Pointer => Null_Image, - Width => 0, - Height => 0, - Channels => L, - Reference_Count => 1); - end Initialize; - - overriding procedure Adjust (Object : in out Image) is - begin - Object.Reference.Reference_Count := Object.Reference.Reference_Count + 1; - end Adjust; - - overriding procedure Finalize (Object : in out Image) is - begin - if Object.Reference.Reference_Count = 1 then - if Object.Reference.Pointer /= Null_Image then - API.Free_Image_Data (Object.Reference.Pointer); - Object.Reference.Pointer := Null_Image; - end if; - else - Object.Reference.Reference_Count - := Object.Reference.Reference_Count - 1; - end if; - end Finalize; - - procedure Load (Object : in out Image; File_Name : String) is - begin - if Object.Reference.Pointer /= Null_Image then - API.Free_Image_Data (Object.Reference.Pointer); - end if; - Object.Reference.Pointer := API.Load_Image - (Interfaces.C.To_C (File_Name), Object.Reference.Width'Access, - Object.Reference.Height'Access, - Object.Reference.Channels'Access, Auto); - if Object.Reference.Pointer = Null_Image then - raise SOIL_Error with Last_Error; - end if; - end Load; - - procedure Load (Object : in out Image; - File_Name : String; - Force_Format : Explicit_Image_Format; - Original_Format : out Explicit_Image_Format) is - - Tmp_Original_Format : aliased Explicit_Image_Format; - begin - if Object.Reference.Pointer /= Null_Image then - API.Free_Image_Data (Object.Reference.Pointer); - end if; - Object.Reference.Pointer := API.Load_Image - (Interfaces.C.To_C (File_Name), Object.Reference.Width'Access, - Object.Reference.Height'Access, - Tmp_Original_Format'Access, Auto); - Original_Format := Tmp_Original_Format; - if Object.Reference.Pointer = Null_Image then - raise SOIL_Error with Last_Error; - end if; - Object.Reference.Channels := Force_Format; - end Load; - - procedure Save (Object : in out Image; File_Name : String; - Image_Type : Image_Save_Type) is - - Result : Bool; - begin - if Object.Reference.Pointer = Null_Image then - raise SOIL_Error with "No image loaded!"; - end if; - Result := API.Save_Image - (Interfaces.C.To_C (File_Name), Image_Type, Object.Reference.Width, - Object.Reference.Height, Object.Reference.Channels, - Object.Reference.Pointer); - if not Result then - raise SOIL_Error with Last_Error; - end if; - end Save; - - function Width (Object : Image) return GL.Types.Int is - begin - return Object.Reference.Width; - end Width; - - function Height (Object : Image) return GL.Types.Int is - begin - return Object.Reference.Height; - end Height; - - function Channels (Object : Image) return Explicit_Image_Format is - begin - return Object.Reference.Channels; - end Channels; - - function Loaded (Object : Image) return Boolean is - begin - return Object.Reference.Pointer /= Null_Image; - end Loaded; - - function Data (Object : Image) return GL.Objects.Textures.Image_Source is - begin - return Object.Reference.Pointer; - end Data; - - procedure Clear (Object : in out Image) is - begin - if Object.Reference.Pointer /= Null_Image then - API.Free_Image_Data (Object.Reference.Pointer); - Object.Reference.Pointer := Null_Image; - end if; - end Clear; - - procedure To_Texture (Object : Image; - Texture : in out GL.Objects.Textures.Texture'Class; - Flags : Texture_Flags) is - Raw_Id : GL.Types.UInt; - begin - if Object.Reference.Pointer = Null_Image then - raise SOIL_Error with "No image loaded!"; - end if; - Raw_Id := API.Create_OGL_Texture (Object.Reference.Pointer, - Object.Reference.Width, - Object.Reference.Height, - Object.Reference.Channels, - Input_Id (Texture), Flags); - if Raw_Id = 0 then - raise SOIL_Error with Last_Error; - end if; - Texture.Set_Raw_Id (Raw_Id); - end To_Texture; - - procedure To_Cubemap (Object : Image; - Texture : in out GL.Objects.Textures.Texture'Class; - Face_Order : Cubemap_Layout; - Flags : Texture_Flags) is - Raw_Id : GL.Types.UInt; - begin - if Object.Reference.Pointer = Null_Image then - raise SOIL_Error with "No image loaded!"; - end if; - Raw_Id := API.Create_OGL_Single_Cubemap (Object.Reference.Pointer, - Object.Reference.Width, - Object.Reference.Height, - Object.Reference.Channels, - Face_Order, Input_Id (Texture), - Flags); - if Raw_Id = 0 then - raise SOIL_Error with Last_Error; - end if; - Texture.Set_Raw_Id (Raw_Id); - end To_Cubemap; - -end SOIL.Images; diff --git a/src/soil/soil-images.ads b/src/soil/soil-images.ads deleted file mode 100644 index 93356b41..00000000 --- a/src/soil/soil-images.ads +++ /dev/null @@ -1,60 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with Ada.Finalization; - -package SOIL.Images is - pragma Preelaborate; - - -- reference counted - type Image is new Ada.Finalization.Controlled with private; - - overriding - procedure Initialize (Object : in out Image); - - overriding - procedure Adjust (Object : in out Image); - - overriding - procedure Finalize (Object : in out Image); - - procedure Load (Object : in out Image; File_Name : String); - -- force the image to be loaded in a certain format: - procedure Load (Object : in out Image; File_Name : String; - Force_Format : Explicit_Image_Format; - Original_Format : out Explicit_Image_Format); - procedure Save (Object : in out Image; File_Name : String; - Image_Type : Image_Save_Type); - - function Width (Object : Image) return GL.Types.Int; - function Height (Object : Image) return GL.Types.Int; - function Channels (Object : Image) return Explicit_Image_Format; - function Loaded (Object : Image) return Boolean; - function Data (Object : Image) return GL.Objects.Textures.Image_Source; - - procedure Clear (Object : in out Image); - - procedure To_Texture (Object : Image; - Texture : in out GL.Objects.Textures.Texture'Class; - Flags : Texture_Flags); - - procedure To_Cubemap (Object : Image; - Texture : in out GL.Objects.Textures.Texture'Class; - Face_Order : Cubemap_Layout; - Flags : Texture_Flags); - -private - type Image_Data is record - Pointer : GL.Objects.Textures.Image_Source; - Width, Height : aliased GL.Types.Int; - Channels : aliased Explicit_Image_Format; - Reference_Count : Positive; - end record; - - type Image_Data_Access is access all Image_Data; - - type Image is new Ada.Finalization.Controlled with record - Reference : Image_Data_Access; - end record; - -end SOIL.Images; diff --git a/src/soil/soil.adb b/src/soil/soil.adb deleted file mode 100644 index 0865bc7c..00000000 --- a/src/soil/soil.adb +++ /dev/null @@ -1,109 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with Interfaces.C.Strings; - -with SOIL.API; - -package body SOIL is - use type GL.Types.UInt; - - function Input_Id (Texture : GL.Objects.Textures.Texture'Class) - return GL.Types.UInt is - begin - if Texture.Initialized then - return Texture.Raw_Id; - else - return 0; - end if; - end Input_Id; - - procedure Load_File_To_Texture - (File_Name : String; - Texture : in out GL.Objects.Textures.Texture'Class; - Channels : Image_Format := Auto; - Flags : Texture_Flags := (others => False)) is - - Raw_Id : constant GL.Types.UInt - := API.Load_OGL_Texture (Interfaces.C.To_C (File_Name), - Channels, Input_Id (Texture), Flags); - begin - if Raw_Id = 0 then - raise SOIL_Error with Last_Error; - end if; - Texture.Set_Raw_Id (Raw_Id); - end Load_File_To_Texture; - - procedure Load_Files_To_Cubemap - (Pos_X_File, Neg_X_File, Pos_Y_File, Neg_Y_File, - Pos_Z_File, Neg_Z_File : String; - Texture : in out GL.Objects.Textures.Texture'Class; - Channels : Image_Format := Auto; - Flags : Texture_Flags := (others => False)) is - - Raw_Id : constant GL.Types.UInt := API.Load_OGL_Cubemap - (Interfaces.C.To_C (Pos_X_File), - Interfaces.C.To_C (Neg_X_File), - Interfaces.C.To_C (Pos_Y_File), - Interfaces.C.To_C (Neg_Y_File), - Interfaces.C.To_C (Pos_Z_File), - Interfaces.C.To_C (Neg_Z_File), Channels, - Input_Id (Texture), Flags); - begin - if Raw_Id = 0 then - raise SOIL_Error with Last_Error; - end if; - Texture.Set_Raw_Id (Raw_Id); - end Load_Files_To_Cubemap; - - procedure Load_File_To_Cubemap - (File_Name : String; - Texture : in out GL.Objects.Textures.Texture'Class; - Face_Order : Cubemap_Layout := "EWUDNS"; - Channels : Image_Format := Auto; - Flags : Texture_Flags := (others => False)) is - - Raw_Id : constant GL.Types.UInt - := API.Load_OGL_Single_Cubemap (Interfaces.C.To_C (File_Name), - Face_Order, Channels, - Input_Id (Texture), Flags); - begin - if Raw_Id = 0 then - raise SOIL_Error with Last_Error; - end if; - Texture.Set_Raw_Id (Raw_Id); - end Load_File_To_Cubemap; - - procedure Load_HDR_Texture - (File_Name : String; - Texture : in out GL.Objects.Textures.Texture'Class; - Format : Fake_HDR_Representation; - Rescale_To_Max : Boolean; - Flags : Texture_Flags := (others => False)) is - - Raw_Id : constant GL.Types.UInt := API.Load_OGL_HDR_Texture - (Interfaces.C.To_C (File_Name), Format, Bool (Rescale_To_Max), - Input_Id (Texture), Flags); - begin - if Raw_Id = 0 then - raise SOIL_Error with Last_Error; - end if; - Texture.Set_Raw_Id (Raw_Id); - end Load_HDR_Texture; - - procedure Save_Screenshot (File_Name : String; - Image_Type : Image_Save_Type; - X, Y, Width, Height : GL.Types.Int) is - Result : constant Bool := API.Save_Screenshot - (Interfaces.C.To_C (File_Name), Image_Type, X, Y, Width, Height); - begin - if not Result then - raise SOIL_Error with Last_Error; - end if; - end Save_Screenshot; - - function Last_Error return String is - begin - return Interfaces.C.Strings.Value (API.Last_Result); - end Last_Error; -end SOIL; diff --git a/src/soil/soil.ads b/src/soil/soil.ads deleted file mode 100644 index 9716c3d1..00000000 --- a/src/soil/soil.ads +++ /dev/null @@ -1,121 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with Interfaces.C; - -with GL.Objects.Textures; -with GL.Types; - -package SOIL is - pragma Preelaborate; - - type Image_Format is (Auto, L, LA, RGB, RGBA); - -- defined here because of the following subtype - for Image_Format use (Auto => 0, - L => 1, - LA => 2, - RGB => 3, - RGBA => 4); - for Image_Format'Size use Interfaces.C.int'Size; - - subtype Explicit_Image_Format is Image_Format range L .. RGBA; - - type Texture_Flags is record - Power_Of_Two : Boolean; - Mipmaps : Boolean; - Texture_Repeats : Boolean; - Multiply_Alpha : Boolean; - Invert_Y : Boolean; - Compress_To_DXT : Boolean; - DDS_Load_Direct : Boolean; - NTSC_Safe_RGB : Boolean; - CoCg_Y : Boolean; - Texture_Rectangle : Boolean; - end record; - - type Fake_HDR_Representation is (RGBE, RGBdivA, RGBdivA2); - - type Image_Save_Type is (TGA, BMP, DDS); - - type Cubemap_Part is ('E', 'W', 'U', 'D', 'N', 'S'); - pragma Convention (C, Cubemap_Part); - for Cubemap_Part'Size use Interfaces.C.char'Size; - type Cubemap_Layout is array (1 .. 6) of Cubemap_Part; - - SOIL_Error : exception; - - procedure Load_File_To_Texture - (File_Name : String; - Texture : in out GL.Objects.Textures.Texture'Class; - Channels : Image_Format := Auto; - Flags : Texture_Flags := (others => False)); - - procedure Load_Files_To_Cubemap - (Pos_X_File, Neg_X_File, Pos_Y_File, Neg_Y_File, - Pos_Z_File, Neg_Z_File : String; - Texture : in out GL.Objects.Textures.Texture'Class; - Channels : Image_Format := Auto; - Flags : Texture_Flags := (others => False)); - - procedure Load_File_To_Cubemap - (File_Name : String; - Texture : in out GL.Objects.Textures.Texture'Class; - Face_Order : Cubemap_Layout := "EWUDNS"; - Channels : Image_Format := Auto; - Flags : Texture_Flags := (others => False)); - - procedure Load_HDR_Texture - (File_Name : String; - Texture : in out GL.Objects.Textures.Texture'Class; - Format : Fake_HDR_Representation; - Rescale_To_Max : Boolean; - Flags : Texture_Flags := (others => False)); - - procedure Save_Screenshot (File_Name : String; - Image_Type : Image_Save_Type; - X, Y, Width, Height : GL.Types.Int); - -private - - for Texture_Flags use record - Power_Of_Two at 0 range 0 .. 0; - Mipmaps at 0 range 1 .. 1; - Texture_Repeats at 0 range 2 .. 2; - Multiply_Alpha at 0 range 3 .. 3; - Invert_Y at 0 range 4 .. 4; - Compress_To_DXT at 0 range 5 .. 5; - DDS_Load_Direct at 0 range 6 .. 6; - NTSC_Safe_RGB at 0 range 7 .. 7; - CoCg_Y at 0 range 8 .. 8; - Texture_Rectangle at 0 range 9 .. 9; - end record; - pragma Warnings (Off); - for Texture_Flags'Size use Interfaces.C.int'Size; - pragma Warnings (On); - pragma Convention (C_Pass_By_Copy, Texture_Flags); - - for Fake_HDR_Representation use (RGBE => 0, - RGBdivA => 1, - RGBdivA2 => 2); - for Fake_HDR_Representation'Size use Interfaces.C.int'Size; - - for Image_Save_Type use (TGA => 0, - BMP => 1, - DDS => 2); - for Image_Save_Type'Size use Interfaces.C.int'Size; - - pragma Convention (C, Cubemap_Layout); - - type Bool is new Boolean; - for Bool use (False => 0, True => 1); - for Bool'Size use Interfaces.C.int'Size; - - function Last_Error return String; - pragma Inline (Last_Error); - - -- returns the ID of the given texture, or 0 if the texture is not - -- initialized. - function Input_Id (Texture : GL.Objects.Textures.Texture'Class) - return GL.Types.UInt; - pragma Inline (Input_Id); -end SOIL; diff --git a/src/soil/stb_image_aug.c b/src/soil/stb_image_aug.c deleted file mode 100755 index 2fa72338..00000000 --- a/src/soil/stb_image_aug.c +++ /dev/null @@ -1,3682 +0,0 @@ -/* stbi-1.16 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c - when you control the images you're loading - - QUICK NOTES: - Primarily of interest to game developers and other people who can - avoid problematic images and only need the trivial interface - - JPEG baseline (no JPEG progressive, no oddball channel decimations) - PNG non-interlaced - BMP non-1bpp, non-RLE - TGA (not sure what subset, if a subset) - PSD (composited view only, no extra channels) - HDR (radiance rgbE format) - writes BMP,TGA (define STBI_NO_WRITE to remove code) - decoded from memory or through stdio FILE (define STBI_NO_STDIO to remove code) - supports installable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD) - - TODO: - stbi_info_* - - history: - 1.16 major bugfix - convert_format converted one too many pixels - 1.15 initialize some fields for thread safety - 1.14 fix threadsafe conversion bug; header-file-only version (#define STBI_HEADER_FILE_ONLY before including) - 1.13 threadsafe - 1.12 const qualifiers in the API - 1.11 Support installable IDCT, colorspace conversion routines - 1.10 Fixes for 64-bit (don't use "unsigned long") - optimized upsampling by Fabian "ryg" Giesen - 1.09 Fix format-conversion for PSD code (bad global variables!) - 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz - 1.07 attempt to fix C++ warning/errors again - 1.06 attempt to fix C++ warning/errors again - 1.05 fix TGA loading to return correct *comp and use good luminance calc - 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free - 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR - 1.02 support for (subset of) HDR files, float interface for preferred access to them - 1.01 fix bug: possible bug in handling right-side up bmps... not sure - fix bug: the stbi_bmp_load() and stbi_tga_load() functions didn't work at all - 1.00 interface to zlib that skips zlib header - 0.99 correct handling of alpha in palette - 0.98 TGA loader by lonesock; dynamically add loaders (untested) - 0.97 jpeg errors on too large a file; also catch another malloc failure - 0.96 fix detection of invalid v value - particleman@mollyrocket forum - 0.95 during header scan, seek to markers in case of padding - 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same - 0.93 handle jpegtran output; verbose errors - 0.92 read 4,8,16,24,32-bit BMP files of several formats - 0.91 output 24-bit Windows 3.0 BMP files - 0.90 fix a few more warnings; bump version number to approach 1.0 - 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd - 0.60 fix compiling as c++ - 0.59 fix warnings: merge Dave Moore's -Wall fixes - 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian - 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less - than 16 available - 0.56 fix bug: zlib uncompressed mode len vs. nlen - 0.55 fix bug: restart_interval not initialized to 0 - 0.54 allow NULL for 'int *comp' - 0.53 fix bug in png 3->4; speedup png decoding - 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments - 0.51 obey req_comp requests, 1-component jpegs return as 1-component, - on 'test' only check type, not whether we support this variant -*/ - -#include "stb_image_aug.h" - -#ifndef STBI_NO_HDR -#include // ldexp -#include // strcmp -#endif - -#ifndef STBI_NO_STDIO -#include -#endif -#include -#include -#include -#include - -#ifndef _MSC_VER - #ifdef __cplusplus - #define __forceinline inline - #else - #define __forceinline - #endif -#endif - - -// implementation: -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef signed short int16; -typedef unsigned int uint32; -typedef signed int int32; -typedef unsigned int uint; - -// should produce compiler error if size is wrong -typedef unsigned char validate_uint32[sizeof(uint32)==4]; - -#if defined(STBI_NO_STDIO) && !defined(STBI_NO_WRITE) -#define STBI_NO_WRITE -#endif - -#ifndef STBI_NO_DDS -#include "stbi_DDS_aug.h" -#endif - -// I (JLD) want full messages for SOIL -#define STBI_FAILURE_USERMSG 1 - -////////////////////////////////////////////////////////////////////////////// -// -// Generic API that works on all image types -// - -// this is not threadsafe -static char *failure_reason; - -char *stbi_failure_reason(void) -{ - return failure_reason; -} - -static int e(char *str) -{ - failure_reason = str; - return 0; -} - -#ifdef STBI_NO_FAILURE_STRINGS - #define e(x,y) 0 -#elif defined(STBI_FAILURE_USERMSG) - #define e(x,y) e(y) -#else - #define e(x,y) e(x) -#endif - -#define epf(x,y) ((float *) (e(x,y)?NULL:NULL)) -#define epuc(x,y) ((unsigned char *) (e(x,y)?NULL:NULL)) - -void stbi_image_free(void *retval_from_stbi_load) -{ - free(retval_from_stbi_load); -} - -#define MAX_LOADERS 32 -stbi_loader *loaders[MAX_LOADERS]; -static int max_loaders = 0; - -int stbi_register_loader(stbi_loader *loader) -{ - int i; - for (i=0; i < MAX_LOADERS; ++i) { - // already present? - if (loaders[i] == loader) - return 1; - // end of the list? - if (loaders[i] == NULL) { - loaders[i] = loader; - max_loaders = i+1; - return 1; - } - } - // no room for it - return 0; -} - -#ifndef STBI_NO_HDR -static float *ldr_to_hdr(stbi_uc *data, int x, int y, int comp); -static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp); -#endif - -#ifndef STBI_NO_STDIO -unsigned char *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = fopen(filename, "rb"); - unsigned char *result; - if (!f) return epuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -unsigned char *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - int i; - if (stbi_jpeg_test_file(f)) - return stbi_jpeg_load_from_file(f,x,y,comp,req_comp); - if (stbi_png_test_file(f)) - return stbi_png_load_from_file(f,x,y,comp,req_comp); - if (stbi_bmp_test_file(f)) - return stbi_bmp_load_from_file(f,x,y,comp,req_comp); - if (stbi_psd_test_file(f)) - return stbi_psd_load_from_file(f,x,y,comp,req_comp); - #ifndef STBI_NO_DDS - if (stbi_dds_test_file(f)) - return stbi_dds_load_from_file(f,x,y,comp,req_comp); - #endif - #ifndef STBI_NO_HDR - if (stbi_hdr_test_file(f)) { - float *hdr = stbi_hdr_load_from_file(f, x,y,comp,req_comp); - return hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); - } - #endif - for (i=0; i < max_loaders; ++i) - if (loaders[i]->test_file(f)) - return loaders[i]->load_from_file(f,x,y,comp,req_comp); - // test tga last because it's a crappy test! - if (stbi_tga_test_file(f)) - return stbi_tga_load_from_file(f,x,y,comp,req_comp); - return epuc("unknown image type", "Image not of any known type, or corrupt"); -} -#endif - -unsigned char *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - int i; - if (stbi_jpeg_test_memory(buffer,len)) - return stbi_jpeg_load_from_memory(buffer,len,x,y,comp,req_comp); - if (stbi_png_test_memory(buffer,len)) - return stbi_png_load_from_memory(buffer,len,x,y,comp,req_comp); - if (stbi_bmp_test_memory(buffer,len)) - return stbi_bmp_load_from_memory(buffer,len,x,y,comp,req_comp); - if (stbi_psd_test_memory(buffer,len)) - return stbi_psd_load_from_memory(buffer,len,x,y,comp,req_comp); - #ifndef STBI_NO_DDS - if (stbi_dds_test_memory(buffer,len)) - return stbi_dds_load_from_memory(buffer,len,x,y,comp,req_comp); - #endif - #ifndef STBI_NO_HDR - if (stbi_hdr_test_memory(buffer, len)) { - float *hdr = stbi_hdr_load_from_memory(buffer, len,x,y,comp,req_comp); - return hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); - } - #endif - for (i=0; i < max_loaders; ++i) - if (loaders[i]->test_memory(buffer,len)) - return loaders[i]->load_from_memory(buffer,len,x,y,comp,req_comp); - // test tga last because it's a crappy test! - if (stbi_tga_test_memory(buffer,len)) - return stbi_tga_load_from_memory(buffer,len,x,y,comp,req_comp); - return epuc("unknown image type", "Image not of any known type, or corrupt"); -} - -#ifndef STBI_NO_HDR - -#ifndef STBI_NO_STDIO -float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = fopen(filename, "rb"); - float *result; - if (!f) return epf("can't fopen", "Unable to open file"); - result = stbi_loadf_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - #ifndef STBI_NO_HDR - if (stbi_hdr_test_file(f)) - return stbi_hdr_load_from_file(f,x,y,comp,req_comp); - #endif - data = stbi_load_from_file(f, x, y, comp, req_comp); - if (data) - return ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); - return epf("unknown image type", "Image not of any known type, or corrupt"); -} -#endif - -float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - #ifndef STBI_NO_HDR - if (stbi_hdr_test_memory(buffer, len)) - return stbi_hdr_load_from_memory(buffer, len,x,y,comp,req_comp); - #endif - data = stbi_load_from_memory(buffer, len, x, y, comp, req_comp); - if (data) - return ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); - return epf("unknown image type", "Image not of any known type, or corrupt"); -} -#endif - -// these is-hdr-or-not is defined independent of whether STBI_NO_HDR is -// defined, for API simplicity; if STBI_NO_HDR is defined, it always -// reports false! - -int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) -{ - #ifndef STBI_NO_HDR - return stbi_hdr_test_memory(buffer, len); - #else - return 0; - #endif -} - -#ifndef STBI_NO_STDIO -extern int stbi_is_hdr (char const *filename) -{ - FILE *f = fopen(filename, "rb"); - int result=0; - if (f) { - result = stbi_is_hdr_from_file(f); - fclose(f); - } - return result; -} - -extern int stbi_is_hdr_from_file(FILE *f) -{ - #ifndef STBI_NO_HDR - return stbi_hdr_test_file(f); - #else - return 0; - #endif -} - -#endif - -// @TODO: get image dimensions & components without fully decoding -#ifndef STBI_NO_STDIO -extern int stbi_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif -extern int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_HDR -static float h2l_gamma_i=1.0f/2.2f, h2l_scale_i=1.0f; -static float l2h_gamma=2.2f, l2h_scale=1.0f; - -void stbi_hdr_to_ldr_gamma(float gamma) { h2l_gamma_i = 1/gamma; } -void stbi_hdr_to_ldr_scale(float scale) { h2l_scale_i = 1/scale; } - -void stbi_ldr_to_hdr_gamma(float gamma) { l2h_gamma = gamma; } -void stbi_ldr_to_hdr_scale(float scale) { l2h_scale = scale; } -#endif - - -////////////////////////////////////////////////////////////////////////////// -// -// Common code used by all image loaders -// - -enum -{ - SCAN_load=0, - SCAN_type, - SCAN_header, -}; - -typedef struct -{ - uint32 img_x, img_y; - int img_n, img_out_n; - - #ifndef STBI_NO_STDIO - FILE *img_file; - #endif - uint8 *img_buffer, *img_buffer_end; -} stbi; - -#ifndef STBI_NO_STDIO -static void start_file(stbi *s, FILE *f) -{ - s->img_file = f; -} -#endif - -static void start_mem(stbi *s, uint8 const *buffer, int len) -{ -#ifndef STBI_NO_STDIO - s->img_file = NULL; -#endif - s->img_buffer = (uint8 *) buffer; - s->img_buffer_end = (uint8 *) buffer+len; -} - -__forceinline static int get8(stbi *s) -{ -#ifndef STBI_NO_STDIO - if (s->img_file) { - int c = fgetc(s->img_file); - return c == EOF ? 0 : c; - } -#endif - if (s->img_buffer < s->img_buffer_end) - return *s->img_buffer++; - return 0; -} - -__forceinline static int at_eof(stbi *s) -{ -#ifndef STBI_NO_STDIO - if (s->img_file) - return feof(s->img_file); -#endif - return s->img_buffer >= s->img_buffer_end; -} - -__forceinline static uint8 get8u(stbi *s) -{ - return (uint8) get8(s); -} - -static void skip(stbi *s, int n) -{ -#ifndef STBI_NO_STDIO - if (s->img_file) - fseek(s->img_file, n, SEEK_CUR); - else -#endif - s->img_buffer += n; -} - -static int get16(stbi *s) -{ - int z = get8(s); - return (z << 8) + get8(s); -} - -static uint32 get32(stbi *s) -{ - uint32 z = get16(s); - return (z << 16) + get16(s); -} - -static int get16le(stbi *s) -{ - int z = get8(s); - return z + (get8(s) << 8); -} - -static uint32 get32le(stbi *s) -{ - uint32 z = get16le(s); - return z + (get16le(s) << 16); -} - -static void getn(stbi *s, stbi_uc *buffer, int n) -{ -#ifndef STBI_NO_STDIO - if (s->img_file) { - fread(buffer, 1, n, s->img_file); - return; - } -#endif - memcpy(buffer, s->img_buffer, n); - s->img_buffer += n; -} - -////////////////////////////////////////////////////////////////////////////// -// -// generic converter from built-in img_n to req_comp -// individual types do this automatically as much as possible (e.g. jpeg -// does all cases internally since it needs to colorspace convert anyway, -// and it never has alpha, so very few cases ). png can automatically -// interleave an alpha=255 channel, but falls back to this for other cases -// -// assume data buffer is malloced, so malloc a new one and free that one -// only failure mode is malloc failing - -static uint8 compute_y(int r, int g, int b) -{ - return (uint8) (((r*77) + (g*150) + (29*b)) >> 8); -} - -static unsigned char *convert_format(unsigned char *data, int img_n, int req_comp, uint x, uint y) -{ - int i,j; - unsigned char *good; - - if (req_comp == img_n) return data; - assert(req_comp >= 1 && req_comp <= 4); - - good = (unsigned char *) malloc(req_comp * x * y); - if (good == NULL) { - free(data); - return epuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - unsigned char *src = data + j * x * img_n ; - unsigned char *dest = good + j * x * req_comp; - - #define COMBO(a,b) ((a)*8+(b)) - #define CASE(a,b) case COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch(COMBO(img_n, req_comp)) { - CASE(1,2) dest[0]=src[0], dest[1]=255; break; - CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break; - CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break; - CASE(2,1) dest[0]=src[0]; break; - CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break; - CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break; - CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break; - CASE(3,1) dest[0]=compute_y(src[0],src[1],src[2]); break; - CASE(3,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = 255; break; - CASE(4,1) dest[0]=compute_y(src[0],src[1],src[2]); break; - CASE(4,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break; - CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break; - default: assert(0); - } - #undef CASE - } - - free(data); - return good; -} - -#ifndef STBI_NO_HDR -static float *ldr_to_hdr(stbi_uc *data, int x, int y, int comp) -{ - int i,k,n; - float *output = (float *) malloc(x * y * comp * sizeof(float)); - if (output == NULL) { free(data); return epf("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - output[i*comp + k] = (float) pow(data[i*comp+k]/255.0f, l2h_gamma) * l2h_scale; - } - if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; - } - free(data); - return output; -} - -#define float2int(x) ((int) (x)) -static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp) -{ - int i,k,n; - stbi_uc *output = (stbi_uc *) malloc(x * y * comp); - if (output == NULL) { free(data); return epuc("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - float z = (float) pow(data[i*comp+k]*h2l_scale_i, h2l_gamma_i) * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = float2int(z); - } - if (k < comp) { - float z = data[i*comp+k] * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = float2int(z); - } - } - free(data); - return output; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// "baseline" JPEG/JFIF decoder (not actually fully baseline implementation) -// -// simple implementation -// - channel subsampling of at most 2 in each dimension -// - doesn't support delayed output of y-dimension -// - simple interface (only one output format: 8-bit interleaved RGB) -// - doesn't try to recover corrupt jpegs -// - doesn't allow partial loading, loading multiple at once -// - still fast on x86 (copying globals into locals doesn't help x86) -// - allocates lots of intermediate memory (full size of all components) -// - non-interleaved case requires this anyway -// - allows good upsampling (see next) -// high-quality -// - upsampled channels are bilinearly interpolated, even across blocks -// - quality integer IDCT derived from IJG's 'slow' -// performance -// - fast huffman; reasonable integer IDCT -// - uses a lot of intermediate memory, could cache poorly -// - load http://nothings.org/remote/anemones.jpg 3 times on 2.8Ghz P4 -// stb_jpeg: 1.34 seconds (MSVC6, default release build) -// stb_jpeg: 1.06 seconds (MSVC6, processor = Pentium Pro) -// IJL11.dll: 1.08 seconds (compiled by intel) -// IJG 1998: 0.98 seconds (MSVC6, makefile provided by IJG) -// IJG 1998: 0.95 seconds (MSVC6, makefile + proc=PPro) - -// huffman decoding acceleration -#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache - -typedef struct -{ - uint8 fast[1 << FAST_BITS]; - // weirdly, repacking this into AoS is a 10% speed loss, instead of a win - uint16 code[256]; - uint8 values[256]; - uint8 size[257]; - unsigned int maxcode[18]; - int delta[17]; // old 'firstsymbol' - old 'firstcode' -} huffman; - -typedef struct -{ - #if STBI_SIMD - unsigned short dequant2[4][64]; - #endif - stbi s; - huffman huff_dc[4]; - huffman huff_ac[4]; - uint8 dequant[4][64]; - -// sizes for components, interleaved MCUs - int img_h_max, img_v_max; - int img_mcu_x, img_mcu_y; - int img_mcu_w, img_mcu_h; - -// definition of jpeg image component - struct - { - int id; - int h,v; - int tq; - int hd,ha; - int dc_pred; - - int x,y,w2,h2; - uint8 *data; - void *raw_data; - uint8 *linebuf; - } img_comp[4]; - - uint32 code_buffer; // jpeg entropy-coded buffer - int code_bits; // number of valid bits - unsigned char marker; // marker seen while filling entropy buffer - int nomore; // flag if we saw a marker so must stop - - int scan_n, order[4]; - int restart_interval, todo; -} jpeg; - -static int build_huffman(huffman *h, int *count) -{ - int i,j,k=0,code; - // build size list for each symbol (from JPEG spec) - for (i=0; i < 16; ++i) - for (j=0; j < count[i]; ++j) - h->size[k++] = (uint8) (i+1); - h->size[k] = 0; - - // compute actual symbols (from jpeg spec) - code = 0; - k = 0; - for(j=1; j <= 16; ++j) { - // compute delta to add to code to compute symbol id - h->delta[j] = k - code; - if (h->size[k] == j) { - while (h->size[k] == j) - h->code[k++] = (uint16) (code++); - if (code-1 >= (1 << j)) return e("bad code lengths","Corrupt JPEG"); - } - // compute largest code + 1 for this size, preshifted as needed later - h->maxcode[j] = code << (16-j); - code <<= 1; - } - h->maxcode[j] = 0xffffffff; - - // build non-spec acceleration table; 255 is flag for not-accelerated - memset(h->fast, 255, 1 << FAST_BITS); - for (i=0; i < k; ++i) { - int s = h->size[i]; - if (s <= FAST_BITS) { - int c = h->code[i] << (FAST_BITS-s); - int m = 1 << (FAST_BITS-s); - for (j=0; j < m; ++j) { - h->fast[c+j] = (uint8) i; - } - } - } - return 1; -} - -static void grow_buffer_unsafe(jpeg *j) -{ - do { - int b = j->nomore ? 0 : get8(&j->s); - if (b == 0xff) { - int c = get8(&j->s); - if (c != 0) { - j->marker = (unsigned char) c; - j->nomore = 1; - return; - } - } - j->code_buffer = (j->code_buffer << 8) | b; - j->code_bits += 8; - } while (j->code_bits <= 24); -} - -// (1 << n) - 1 -static uint32 bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; - -// decode a jpeg huffman value from the bitstream -__forceinline static int decode(jpeg *j, huffman *h) -{ - unsigned int temp; - int c,k; - - if (j->code_bits < 16) grow_buffer_unsafe(j); - - // look at the top FAST_BITS and determine what symbol ID it is, - // if the code is <= FAST_BITS - c = (j->code_buffer >> (j->code_bits - FAST_BITS)) & ((1 << FAST_BITS)-1); - k = h->fast[c]; - if (k < 255) { - if (h->size[k] > j->code_bits) - return -1; - j->code_bits -= h->size[k]; - return h->values[k]; - } - - // naive test is to shift the code_buffer down so k bits are - // valid, then test against maxcode. To speed this up, we've - // preshifted maxcode left so that it has (16-k) 0s at the - // end; in other words, regardless of the number of bits, it - // wants to be compared against something shifted to have 16; - // that way we don't need to shift inside the loop. - if (j->code_bits < 16) - temp = (j->code_buffer << (16 - j->code_bits)) & 0xffff; - else - temp = (j->code_buffer >> (j->code_bits - 16)) & 0xffff; - for (k=FAST_BITS+1 ; ; ++k) - if (temp < h->maxcode[k]) - break; - if (k == 17) { - // error! code not found - j->code_bits -= 16; - return -1; - } - - if (k > j->code_bits) - return -1; - - // convert the huffman code to the symbol id - c = ((j->code_buffer >> (j->code_bits - k)) & bmask[k]) + h->delta[k]; - assert((((j->code_buffer) >> (j->code_bits - h->size[c])) & bmask[h->size[c]]) == h->code[c]); - - // convert the id to a symbol - j->code_bits -= k; - return h->values[c]; -} - -// combined JPEG 'receive' and JPEG 'extend', since baseline -// always extends everything it receives. -__forceinline static int extend_receive(jpeg *j, int n) -{ - unsigned int m = 1 << (n-1); - unsigned int k; - if (j->code_bits < n) grow_buffer_unsafe(j); - k = (j->code_buffer >> (j->code_bits - n)) & bmask[n]; - j->code_bits -= n; - // the following test is probably a random branch that won't - // predict well. I tried to table accelerate it but failed. - // maybe it's compiling as a conditional move? - if (k < m) - return (-1 << n) + k + 1; - else - return k; -} - -// given a value that's at position X in the zigzag stream, -// where does it appear in the 8x8 matrix coded as row-major? -static uint8 dezigzag[64+15] = -{ - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - // let corrupt input sample past end - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63 -}; - -// decode one 64-entry block-- -static int decode_block(jpeg *j, short data[64], huffman *hdc, huffman *hac, int b) -{ - int diff,dc,k; - int t = decode(j, hdc); - if (t < 0) return e("bad huffman code","Corrupt JPEG"); - - // 0 all the ac values now so we can do it 32-bits at a time - memset(data,0,64*sizeof(data[0])); - - diff = t ? extend_receive(j, t) : 0; - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - data[0] = (short) dc; - - // decode AC components, see JPEG spec - k = 1; - do { - int r,s; - int rs = decode(j, hac); - if (rs < 0) return e("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (rs != 0xf0) break; // end block - k += 16; - } else { - k += r; - // decode into unzigzag'd location - data[dezigzag[k++]] = (short) extend_receive(j,s); - } - } while (k < 64); - return 1; -} - -// take a -128..127 value and clamp it and convert to 0..255 -__forceinline static uint8 clamp(int x) -{ - x += 128; - // trick to use a single test to catch both cases - if ((unsigned int) x > 255) { - if (x < 0) return 0; - if (x > 255) return 255; - } - return (uint8) x; -} - -#define f2f(x) (int) (((x) * 4096 + 0.5)) -#define fsh(x) ((x) << 12) - -// derived from jidctint -- DCT_ISLOW -#define IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ - int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ - p2 = s2; \ - p3 = s6; \ - p1 = (p2+p3) * f2f(0.5411961f); \ - t2 = p1 + p3*f2f(-1.847759065f); \ - t3 = p1 + p2*f2f( 0.765366865f); \ - p2 = s0; \ - p3 = s4; \ - t0 = fsh(p2+p3); \ - t1 = fsh(p2-p3); \ - x0 = t0+t3; \ - x3 = t0-t3; \ - x1 = t1+t2; \ - x2 = t1-t2; \ - t0 = s7; \ - t1 = s5; \ - t2 = s3; \ - t3 = s1; \ - p3 = t0+t2; \ - p4 = t1+t3; \ - p1 = t0+t3; \ - p2 = t1+t2; \ - p5 = (p3+p4)*f2f( 1.175875602f); \ - t0 = t0*f2f( 0.298631336f); \ - t1 = t1*f2f( 2.053119869f); \ - t2 = t2*f2f( 3.072711026f); \ - t3 = t3*f2f( 1.501321110f); \ - p1 = p5 + p1*f2f(-0.899976223f); \ - p2 = p5 + p2*f2f(-2.562915447f); \ - p3 = p3*f2f(-1.961570560f); \ - p4 = p4*f2f(-0.390180644f); \ - t3 += p1+p4; \ - t2 += p2+p3; \ - t1 += p2+p4; \ - t0 += p1+p3; - -#if !STBI_SIMD -// .344 seconds on 3*anemones.jpg -static void idct_block(uint8 *out, int out_stride, short data[64], uint8 *dequantize) -{ - int i,val[64],*v=val; - uint8 *o,*dq = dequantize; - short *d = data; - - // columns - for (i=0; i < 8; ++i,++d,++dq, ++v) { - // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing - if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 - && d[40]==0 && d[48]==0 && d[56]==0) { - // no shortcut 0 seconds - // (1|2|3|4|5|6|7)==0 0 seconds - // all separate -0.047 seconds - // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds - int dcterm = d[0] * dq[0] << 2; - v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; - } else { - IDCT_1D(d[ 0]*dq[ 0],d[ 8]*dq[ 8],d[16]*dq[16],d[24]*dq[24], - d[32]*dq[32],d[40]*dq[40],d[48]*dq[48],d[56]*dq[56]) - // constants scaled things up by 1<<12; let's bring them back - // down, but keep 2 extra bits of precision - x0 += 512; x1 += 512; x2 += 512; x3 += 512; - v[ 0] = (x0+t3) >> 10; - v[56] = (x0-t3) >> 10; - v[ 8] = (x1+t2) >> 10; - v[48] = (x1-t2) >> 10; - v[16] = (x2+t1) >> 10; - v[40] = (x2-t1) >> 10; - v[24] = (x3+t0) >> 10; - v[32] = (x3-t0) >> 10; - } - } - - for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { - // no fast case since the first 1D IDCT spread components out - IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) - // constants scaled things up by 1<<12, plus we had 1<<2 from first - // loop, plus horizontal and vertical each scale by sqrt(8) so together - // we've got an extra 1<<3, so 1<<17 total we need to remove. - x0 += 65536; x1 += 65536; x2 += 65536; x3 += 65536; - o[0] = clamp((x0+t3) >> 17); - o[7] = clamp((x0-t3) >> 17); - o[1] = clamp((x1+t2) >> 17); - o[6] = clamp((x1-t2) >> 17); - o[2] = clamp((x2+t1) >> 17); - o[5] = clamp((x2-t1) >> 17); - o[3] = clamp((x3+t0) >> 17); - o[4] = clamp((x3-t0) >> 17); - } -} -#else -static void idct_block(uint8 *out, int out_stride, short data[64], unsigned short *dequantize) -{ - int i,val[64],*v=val; - uint8 *o; - unsigned short *dq = dequantize; - short *d = data; - - // columns - for (i=0; i < 8; ++i,++d,++dq, ++v) { - // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing - if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 - && d[40]==0 && d[48]==0 && d[56]==0) { - // no shortcut 0 seconds - // (1|2|3|4|5|6|7)==0 0 seconds - // all separate -0.047 seconds - // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds - int dcterm = d[0] * dq[0] << 2; - v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; - } else { - IDCT_1D(d[ 0]*dq[ 0],d[ 8]*dq[ 8],d[16]*dq[16],d[24]*dq[24], - d[32]*dq[32],d[40]*dq[40],d[48]*dq[48],d[56]*dq[56]) - // constants scaled things up by 1<<12; let's bring them back - // down, but keep 2 extra bits of precision - x0 += 512; x1 += 512; x2 += 512; x3 += 512; - v[ 0] = (x0+t3) >> 10; - v[56] = (x0-t3) >> 10; - v[ 8] = (x1+t2) >> 10; - v[48] = (x1-t2) >> 10; - v[16] = (x2+t1) >> 10; - v[40] = (x2-t1) >> 10; - v[24] = (x3+t0) >> 10; - v[32] = (x3-t0) >> 10; - } - } - - for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { - // no fast case since the first 1D IDCT spread components out - IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) - // constants scaled things up by 1<<12, plus we had 1<<2 from first - // loop, plus horizontal and vertical each scale by sqrt(8) so together - // we've got an extra 1<<3, so 1<<17 total we need to remove. - x0 += 65536; x1 += 65536; x2 += 65536; x3 += 65536; - o[0] = clamp((x0+t3) >> 17); - o[7] = clamp((x0-t3) >> 17); - o[1] = clamp((x1+t2) >> 17); - o[6] = clamp((x1-t2) >> 17); - o[2] = clamp((x2+t1) >> 17); - o[5] = clamp((x2-t1) >> 17); - o[3] = clamp((x3+t0) >> 17); - o[4] = clamp((x3-t0) >> 17); - } -} -static stbi_idct_8x8 stbi_idct_installed = idct_block; - -extern void stbi_install_idct(stbi_idct_8x8 func) -{ - stbi_idct_installed = func; -} -#endif - -#define MARKER_none 0xff -// if there's a pending marker from the entropy stream, return that -// otherwise, fetch from the stream and get a marker. if there's no -// marker, return 0xff, which is never a valid marker value -static uint8 get_marker(jpeg *j) -{ - uint8 x; - if (j->marker != MARKER_none) { x = j->marker; j->marker = MARKER_none; return x; } - x = get8u(&j->s); - if (x != 0xff) return MARKER_none; - while (x == 0xff) - x = get8u(&j->s); - return x; -} - -// in each scan, we'll have scan_n components, and the order -// of the components is specified by order[] -#define RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) - -// after a restart interval, reset the entropy decoder and -// the dc prediction -static void reset(jpeg *j) -{ - j->code_bits = 0; - j->code_buffer = 0; - j->nomore = 0; - j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = 0; - j->marker = MARKER_none; - j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; - // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, - // since we don't even allow 1<<30 pixels -} - -static int parse_entropy_coded_data(jpeg *z) -{ - reset(z); - if (z->scan_n == 1) { - int i,j; - #if STBI_SIMD - __declspec(align(16)) - #endif - short data[64]; - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - if (!decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+z->img_comp[n].ha, n)) return 0; - #if STBI_SIMD - stbi_idct_installed(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data, z->dequant2[z->img_comp[n].tq]); - #else - idct_block(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data, z->dequant[z->img_comp[n].tq]); - #endif - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) grow_buffer_unsafe(z); - // if it's NOT a restart, then just bail, so we get corrupt data - // rather than no data - if (!RESTART(z->marker)) return 1; - reset(z); - } - } - } - } else { // interleaved! - int i,j,k,x,y; - short data[64]; - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x)*8; - int y2 = (j*z->img_comp[n].v + y)*8; - if (!decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+z->img_comp[n].ha, n)) return 0; - #if STBI_SIMD - stbi_idct_installed(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data, z->dequant2[z->img_comp[n].tq]); - #else - idct_block(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data, z->dequant[z->img_comp[n].tq]); - #endif - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) grow_buffer_unsafe(z); - // if it's NOT a restart, then just bail, so we get corrupt data - // rather than no data - if (!RESTART(z->marker)) return 1; - reset(z); - } - } - } - } - return 1; -} - -static int process_marker(jpeg *z, int m) -{ - int L; - switch (m) { - case MARKER_none: // no marker found - return e("expected marker","Corrupt JPEG"); - - case 0xC2: // SOF - progressive - return e("progressive jpeg","JPEG format not supported (progressive)"); - - case 0xDD: // DRI - specify restart interval - if (get16(&z->s) != 4) return e("bad DRI len","Corrupt JPEG"); - z->restart_interval = get16(&z->s); - return 1; - - case 0xDB: // DQT - define quantization table - L = get16(&z->s)-2; - while (L > 0) { - int q = get8(&z->s); - int p = q >> 4; - int t = q & 15,i; - if (p != 0) return e("bad DQT type","Corrupt JPEG"); - if (t > 3) return e("bad DQT table","Corrupt JPEG"); - for (i=0; i < 64; ++i) - z->dequant[t][dezigzag[i]] = get8u(&z->s); - #if STBI_SIMD - for (i=0; i < 64; ++i) - z->dequant2[t][i] = dequant[t][i]; - #endif - L -= 65; - } - return L==0; - - case 0xC4: // DHT - define huffman table - L = get16(&z->s)-2; - while (L > 0) { - uint8 *v; - int sizes[16],i,m=0; - int q = get8(&z->s); - int tc = q >> 4; - int th = q & 15; - if (tc > 1 || th > 3) return e("bad DHT header","Corrupt JPEG"); - for (i=0; i < 16; ++i) { - sizes[i] = get8(&z->s); - m += sizes[i]; - } - L -= 17; - if (tc == 0) { - if (!build_huffman(z->huff_dc+th, sizes)) return 0; - v = z->huff_dc[th].values; - } else { - if (!build_huffman(z->huff_ac+th, sizes)) return 0; - v = z->huff_ac[th].values; - } - for (i=0; i < m; ++i) - v[i] = get8u(&z->s); - L -= m; - } - return L==0; - } - // check for comment block or APP blocks - if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { - skip(&z->s, get16(&z->s)-2); - return 1; - } - return 0; -} - -// after we see SOS -static int process_scan_header(jpeg *z) -{ - int i; - int Ls = get16(&z->s); - z->scan_n = get8(&z->s); - if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s.img_n) return e("bad SOS component count","Corrupt JPEG"); - if (Ls != 6+2*z->scan_n) return e("bad SOS len","Corrupt JPEG"); - for (i=0; i < z->scan_n; ++i) { - int id = get8(&z->s), which; - int q = get8(&z->s); - for (which = 0; which < z->s.img_n; ++which) - if (z->img_comp[which].id == id) - break; - if (which == z->s.img_n) return 0; - z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return e("bad DC huff","Corrupt JPEG"); - z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return e("bad AC huff","Corrupt JPEG"); - z->order[i] = which; - } - if (get8(&z->s) != 0) return e("bad SOS","Corrupt JPEG"); - get8(&z->s); // should be 63, but might be 0 - if (get8(&z->s) != 0) return e("bad SOS","Corrupt JPEG"); - - return 1; -} - -static int process_frame_header(jpeg *z, int scan) -{ - stbi *s = &z->s; - int Lf,p,i,q, h_max=1,v_max=1,c; - Lf = get16(s); if (Lf < 11) return e("bad SOF len","Corrupt JPEG"); // JPEG - p = get8(s); if (p != 8) return e("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline - s->img_y = get16(s); if (s->img_y == 0) return e("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG - s->img_x = get16(s); if (s->img_x == 0) return e("0 width","Corrupt JPEG"); // JPEG requires - c = get8(s); - if (c != 3 && c != 1) return e("bad component count","Corrupt JPEG"); // JFIF requires - s->img_n = c; - for (i=0; i < c; ++i) { - z->img_comp[i].data = NULL; - z->img_comp[i].linebuf = NULL; - } - - if (Lf != 8+3*s->img_n) return e("bad SOF len","Corrupt JPEG"); - - for (i=0; i < s->img_n; ++i) { - z->img_comp[i].id = get8(s); - if (z->img_comp[i].id != i+1) // JFIF requires - if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! - return e("bad component ID","Corrupt JPEG"); - q = get8(s); - z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return e("bad H","Corrupt JPEG"); - z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return e("bad V","Corrupt JPEG"); - z->img_comp[i].tq = get8(s); if (z->img_comp[i].tq > 3) return e("bad TQ","Corrupt JPEG"); - } - - if (scan != SCAN_load) return 1; - - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return e("too large", "Image too large to decode"); - - for (i=0; i < s->img_n; ++i) { - if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; - if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; - } - - // compute interleaved mcu info - z->img_h_max = h_max; - z->img_v_max = v_max; - z->img_mcu_w = h_max * 8; - z->img_mcu_h = v_max * 8; - z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; - z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; - - for (i=0; i < s->img_n; ++i) { - // number of effective pixels (e.g. for non-interleaved MCU) - z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; - z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; - // to simplify generation, we'll allocate enough memory to decode - // the bogus oversized data from using interleaved MCUs and their - // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't - // discard the extra data until colorspace conversion - z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; - z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; - z->img_comp[i].raw_data = malloc(z->img_comp[i].w2 * z->img_comp[i].h2+15); - if (z->img_comp[i].raw_data == NULL) { - for(--i; i >= 0; --i) { - free(z->img_comp[i].raw_data); - z->img_comp[i].data = NULL; - } - return e("outofmem", "Out of memory"); - } - // align blocks for installable-idct using mmx/sse - z->img_comp[i].data = (uint8*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); - z->img_comp[i].linebuf = NULL; - } - - return 1; -} - -// use comparisons since in some cases we handle more than one case (e.g. SOF) -#define DNL(x) ((x) == 0xdc) -#define SOI(x) ((x) == 0xd8) -#define EOI(x) ((x) == 0xd9) -#define SOF(x) ((x) == 0xc0 || (x) == 0xc1) -#define SOS(x) ((x) == 0xda) - -static int decode_jpeg_header(jpeg *z, int scan) -{ - int m; - z->marker = MARKER_none; // initialize cached marker to empty - m = get_marker(z); - if (!SOI(m)) return e("no SOI","Corrupt JPEG"); - if (scan == SCAN_type) return 1; - m = get_marker(z); - while (!SOF(m)) { - if (!process_marker(z,m)) return 0; - m = get_marker(z); - while (m == MARKER_none) { - // some files have extra padding after their blocks, so ok, we'll scan - if (at_eof(&z->s)) return e("no SOF", "Corrupt JPEG"); - m = get_marker(z); - } - } - if (!process_frame_header(z, scan)) return 0; - return 1; -} - -static int decode_jpeg_image(jpeg *j) -{ - int m; - j->restart_interval = 0; - if (!decode_jpeg_header(j, SCAN_load)) return 0; - m = get_marker(j); - while (!EOI(m)) { - if (SOS(m)) { - if (!process_scan_header(j)) return 0; - if (!parse_entropy_coded_data(j)) return 0; - } else { - if (!process_marker(j, m)) return 0; - } - m = get_marker(j); - } - return 1; -} - -// static jfif-centered resampling (across block boundaries) - -typedef uint8 *(*resample_row_func)(uint8 *out, uint8 *in0, uint8 *in1, - int w, int hs); - -#define div4(x) ((uint8) ((x) >> 2)) - -static uint8 *resample_row_1(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - return in_near; -} - -static uint8* resample_row_v_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - // need to generate two samples vertically for every one in input - int i; - for (i=0; i < w; ++i) - out[i] = div4(3*in_near[i] + in_far[i] + 2); - return out; -} - -static uint8* resample_row_h_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - // need to generate two samples horizontally for every one in input - int i; - uint8 *input = in_near; - if (w == 1) { - // if only one sample, can't do any interpolation - out[0] = out[1] = input[0]; - return out; - } - - out[0] = input[0]; - out[1] = div4(input[0]*3 + input[1] + 2); - for (i=1; i < w-1; ++i) { - int n = 3*input[i]+2; - out[i*2+0] = div4(n+input[i-1]); - out[i*2+1] = div4(n+input[i+1]); - } - out[i*2+0] = div4(input[w-2]*3 + input[w-1] + 2); - out[i*2+1] = input[w-1]; - return out; -} - -#define div16(x) ((uint8) ((x) >> 4)) - -static uint8 *resample_row_hv_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i,t0,t1; - if (w == 1) { - out[0] = out[1] = div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - out[0] = div4(t1+2); - for (i=1; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = div16(3*t0 + t1 + 8); - out[i*2 ] = div16(3*t1 + t0 + 8); - } - out[w*2-1] = div4(t1+2); - return out; -} - -static uint8 *resample_row_generic(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - // resample with nearest-neighbor - int i,j; - for (i=0; i < w; ++i) - for (j=0; j < hs; ++j) - out[i*hs+j] = in_near[i]; - return out; -} - -#define float2fixed(x) ((int) ((x) * 65536 + 0.5)) - -// 0.38 seconds on 3*anemones.jpg (0.25 with processor = Pro) -// VC6 without processor=Pro is generating multiple LEAs per multiply! -static void YCbCr_to_RGB_row(uint8 *out, uint8 *y, uint8 *pcb, uint8 *pcr, int count, int step) -{ - int i; - for (i=0; i < count; ++i) { - int y_fixed = (y[i] << 16) + 32768; // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr*float2fixed(1.40200f); - g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); - b = y_fixed + cb*float2fixed(1.77200f); - r >>= 16; - g >>= 16; - b >>= 16; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (uint8)r; - out[1] = (uint8)g; - out[2] = (uint8)b; - out[3] = 255; - out += step; - } -} - -#if STBI_SIMD -static stbi_YCbCr_to_RGB_run stbi_YCbCr_installed = YCbCr_to_RGB_row; - -void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func) -{ - stbi_YCbCr_installed = func; -} -#endif - - -// clean up the temporary component buffers -static void cleanup_jpeg(jpeg *j) -{ - int i; - for (i=0; i < j->s.img_n; ++i) { - if (j->img_comp[i].data) { - free(j->img_comp[i].raw_data); - j->img_comp[i].data = NULL; - } - if (j->img_comp[i].linebuf) { - free(j->img_comp[i].linebuf); - j->img_comp[i].linebuf = NULL; - } - } -} - -typedef struct -{ - resample_row_func resample; - uint8 *line0,*line1; - int hs,vs; // expansion factor in each axis - int w_lores; // horizontal pixels pre-expansion - int ystep; // how far through vertical expansion we are - int ypos; // which pre-expansion row we're on -} stbi_resample; - -static uint8 *load_jpeg_image(jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) -{ - int n, decode_n; - // validate req_comp - if (req_comp < 0 || req_comp > 4) return epuc("bad req_comp", "Internal error"); - z->s.img_n = 0; - - // load a jpeg image from whichever source - if (!decode_jpeg_image(z)) { cleanup_jpeg(z); return NULL; } - - // determine actual number of components to generate - n = req_comp ? req_comp : z->s.img_n; - - if (z->s.img_n == 3 && n < 3) - decode_n = 1; - else - decode_n = z->s.img_n; - - // resample and color-convert - { - int k; - uint i,j; - uint8 *output; - uint8 *coutput[4]; - - stbi_resample res_comp[4]; - - for (k=0; k < decode_n; ++k) { - stbi_resample *r = &res_comp[k]; - - // allocate line buffer big enough for upsampling off the edges - // with upsample factor of 4 - z->img_comp[k].linebuf = (uint8 *) malloc(z->s.img_x + 3); - if (!z->img_comp[k].linebuf) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); } - - r->hs = z->img_h_max / z->img_comp[k].h; - r->vs = z->img_v_max / z->img_comp[k].v; - r->ystep = r->vs >> 1; - r->w_lores = (z->s.img_x + r->hs-1) / r->hs; - r->ypos = 0; - r->line0 = r->line1 = z->img_comp[k].data; - - if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; - else if (r->hs == 1 && r->vs == 2) r->resample = resample_row_v_2; - else if (r->hs == 2 && r->vs == 1) r->resample = resample_row_h_2; - else if (r->hs == 2 && r->vs == 2) r->resample = resample_row_hv_2; - else r->resample = resample_row_generic; - } - - // can't error after this so, this is safe - output = (uint8 *) malloc(n * z->s.img_x * z->s.img_y + 1); - if (!output) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); } - - // now go ahead and resample - for (j=0; j < z->s.img_y; ++j) { - uint8 *out = output + n * z->s.img_x * j; - for (k=0; k < decode_n; ++k) { - stbi_resample *r = &res_comp[k]; - int y_bot = r->ystep >= (r->vs >> 1); - coutput[k] = r->resample(z->img_comp[k].linebuf, - y_bot ? r->line1 : r->line0, - y_bot ? r->line0 : r->line1, - r->w_lores, r->hs); - if (++r->ystep >= r->vs) { - r->ystep = 0; - r->line0 = r->line1; - if (++r->ypos < z->img_comp[k].y) - r->line1 += z->img_comp[k].w2; - } - } - if (n >= 3) { - uint8 *y = coutput[0]; - if (z->s.img_n == 3) { - #if STBI_SIMD - stbi_YCbCr_installed(out, y, coutput[1], coutput[2], z->s.img_x, n); - #else - YCbCr_to_RGB_row(out, y, coutput[1], coutput[2], z->s.img_x, n); - #endif - } else - for (i=0; i < z->s.img_x; ++i) { - out[0] = out[1] = out[2] = y[i]; - out[3] = 255; // not used if n==3 - out += n; - } - } else { - uint8 *y = coutput[0]; - if (n == 1) - for (i=0; i < z->s.img_x; ++i) out[i] = y[i]; - else - for (i=0; i < z->s.img_x; ++i) *out++ = y[i], *out++ = 255; - } - } - cleanup_jpeg(z); - *out_x = z->s.img_x; - *out_y = z->s.img_y; - if (comp) *comp = z->s.img_n; // report original components, not output - return output; - } -} - -#ifndef STBI_NO_STDIO -unsigned char *stbi_jpeg_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - jpeg j; - start_file(&j.s, f); - return load_jpeg_image(&j, x,y,comp,req_comp); -} - -unsigned char *stbi_jpeg_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_jpeg_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return data; -} -#endif - -unsigned char *stbi_jpeg_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - jpeg j; - start_mem(&j.s, buffer,len); - return load_jpeg_image(&j, x,y,comp,req_comp); -} - -#ifndef STBI_NO_STDIO -int stbi_jpeg_test_file(FILE *f) -{ - int n,r; - jpeg j; - n = ftell(f); - start_file(&j.s, f); - r = decode_jpeg_header(&j, SCAN_type); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_jpeg_test_memory(stbi_uc const *buffer, int len) -{ - jpeg j; - start_mem(&j.s, buffer,len); - return decode_jpeg_header(&j, SCAN_type); -} - -// @TODO: -#ifndef STBI_NO_STDIO -extern int stbi_jpeg_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_jpeg_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif -extern int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -// public domain zlib decode v0.2 Sean Barrett 2006-11-18 -// simple implementation -// - all input must be provided in an upfront buffer -// - all output is written to a single output buffer (can malloc/realloc) -// performance -// - fast huffman - -// fast-way is faster to check than jpeg huffman, but slow way is slower -#define ZFAST_BITS 9 // accelerate all cases in default tables -#define ZFAST_MASK ((1 << ZFAST_BITS) - 1) - -// zlib-style huffman encoding -// (jpegs packs from left, zlib from right, so can't share code) -typedef struct -{ - uint16 fast[1 << ZFAST_BITS]; - uint16 firstcode[16]; - int maxcode[17]; - uint16 firstsymbol[16]; - uint8 size[288]; - uint16 value[288]; -} zhuffman; - -__forceinline static int bitreverse16(int n) -{ - n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); - n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); - n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); - n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); - return n; -} - -__forceinline static int bit_reverse(int v, int bits) -{ - assert(bits <= 16); - // to bit reverse n bits, reverse 16 and shift - // e.g. 11 bits, bit reverse and shift away 5 - return bitreverse16(v) >> (16-bits); -} - -static int zbuild_huffman(zhuffman *z, uint8 *sizelist, int num) -{ - int i,k=0; - int code, next_code[16], sizes[17]; - - // DEFLATE spec for generating codes - memset(sizes, 0, sizeof(sizes)); - memset(z->fast, 255, sizeof(z->fast)); - for (i=0; i < num; ++i) - ++sizes[sizelist[i]]; - sizes[0] = 0; - for (i=1; i < 16; ++i) - assert(sizes[i] <= (1 << i)); - code = 0; - for (i=1; i < 16; ++i) { - next_code[i] = code; - z->firstcode[i] = (uint16) code; - z->firstsymbol[i] = (uint16) k; - code = (code + sizes[i]); - if (sizes[i]) - if (code-1 >= (1 << i)) return e("bad codelengths","Corrupt JPEG"); - z->maxcode[i] = code << (16-i); // preshift for inner loop - code <<= 1; - k += sizes[i]; - } - z->maxcode[16] = 0x10000; // sentinel - for (i=0; i < num; ++i) { - int s = sizelist[i]; - if (s) { - int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; - z->size[c] = (uint8)s; - z->value[c] = (uint16)i; - if (s <= ZFAST_BITS) { - int k = bit_reverse(next_code[s],s); - while (k < (1 << ZFAST_BITS)) { - z->fast[k] = (uint16) c; - k += (1 << s); - } - } - ++next_code[s]; - } - } - return 1; -} - -// zlib-from-memory implementation for PNG reading -// because PNG allows splitting the zlib stream arbitrarily, -// and it's annoying structurally to have PNG call ZLIB call PNG, -// we require PNG read all the IDATs and combine them into a single -// memory buffer - -typedef struct -{ - uint8 *zbuffer, *zbuffer_end; - int num_bits; - uint32 code_buffer; - - char *zout; - char *zout_start; - char *zout_end; - int z_expandable; - - zhuffman z_length, z_distance; -} zbuf; - -__forceinline static int zget8(zbuf *z) -{ - if (z->zbuffer >= z->zbuffer_end) return 0; - return *z->zbuffer++; -} - -static void fill_bits(zbuf *z) -{ - do { - assert(z->code_buffer < (1U << z->num_bits)); - z->code_buffer |= zget8(z) << z->num_bits; - z->num_bits += 8; - } while (z->num_bits <= 24); -} - -__forceinline static unsigned int zreceive(zbuf *z, int n) -{ - unsigned int k; - if (z->num_bits < n) fill_bits(z); - k = z->code_buffer & ((1 << n) - 1); - z->code_buffer >>= n; - z->num_bits -= n; - return k; -} - -__forceinline static int zhuffman_decode(zbuf *a, zhuffman *z) -{ - int b,s,k; - if (a->num_bits < 16) fill_bits(a); - b = z->fast[a->code_buffer & ZFAST_MASK]; - if (b < 0xffff) { - s = z->size[b]; - a->code_buffer >>= s; - a->num_bits -= s; - return z->value[b]; - } - - // not resolved by fast table, so compute it the slow way - // use jpeg approach, which requires MSbits at top - k = bit_reverse(a->code_buffer, 16); - for (s=ZFAST_BITS+1; ; ++s) - if (k < z->maxcode[s]) - break; - if (s == 16) return -1; // invalid code! - // code size is s, so: - b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; - assert(z->size[b] == s); - a->code_buffer >>= s; - a->num_bits -= s; - return z->value[b]; -} - -static int expand(zbuf *z, int n) // need to make room for n bytes -{ - char *q; - int cur, limit; - if (!z->z_expandable) return e("output buffer limit","Corrupt PNG"); - cur = (int) (z->zout - z->zout_start); - limit = (int) (z->zout_end - z->zout_start); - while (cur + n > limit) - limit *= 2; - q = (char *) realloc(z->zout_start, limit); - if (q == NULL) return e("outofmem", "Out of memory"); - z->zout_start = q; - z->zout = q + cur; - z->zout_end = q + limit; - return 1; -} - -static int length_base[31] = { - 3,4,5,6,7,8,9,10,11,13, - 15,17,19,23,27,31,35,43,51,59, - 67,83,99,115,131,163,195,227,258,0,0 }; - -static int length_extra[31]= -{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; - -static int dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, -257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; - -static int dist_extra[32] = -{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -static int parse_huffman_block(zbuf *a) -{ - for(;;) { - int z = zhuffman_decode(a, &a->z_length); - if (z < 256) { - if (z < 0) return e("bad huffman code","Corrupt PNG"); // error in huffman codes - if (a->zout >= a->zout_end) if (!expand(a, 1)) return 0; - *a->zout++ = (char) z; - } else { - uint8 *p; - int len,dist; - if (z == 256) return 1; - z -= 257; - len = length_base[z]; - if (length_extra[z]) len += zreceive(a, length_extra[z]); - z = zhuffman_decode(a, &a->z_distance); - if (z < 0) return e("bad huffman code","Corrupt PNG"); - dist = dist_base[z]; - if (dist_extra[z]) dist += zreceive(a, dist_extra[z]); - if (a->zout - a->zout_start < dist) return e("bad dist","Corrupt PNG"); - if (a->zout + len > a->zout_end) if (!expand(a, len)) return 0; - p = (uint8 *) (a->zout - dist); - while (len--) - *a->zout++ = *p++; - } - } -} - -static int compute_huffman_codes(zbuf *a) -{ - static uint8 length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; - static zhuffman z_codelength; // static just to save stack space - uint8 lencodes[286+32+137];//padding for maximum single op - uint8 codelength_sizes[19]; - int i,n; - - int hlit = zreceive(a,5) + 257; - int hdist = zreceive(a,5) + 1; - int hclen = zreceive(a,4) + 4; - - memset(codelength_sizes, 0, sizeof(codelength_sizes)); - for (i=0; i < hclen; ++i) { - int s = zreceive(a,3); - codelength_sizes[length_dezigzag[i]] = (uint8) s; - } - if (!zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; - - n = 0; - while (n < hlit + hdist) { - int c = zhuffman_decode(a, &z_codelength); - assert(c >= 0 && c < 19); - if (c < 16) - lencodes[n++] = (uint8) c; - else if (c == 16) { - c = zreceive(a,2)+3; - memset(lencodes+n, lencodes[n-1], c); - n += c; - } else if (c == 17) { - c = zreceive(a,3)+3; - memset(lencodes+n, 0, c); - n += c; - } else { - assert(c == 18); - c = zreceive(a,7)+11; - memset(lencodes+n, 0, c); - n += c; - } - } - if (n != hlit+hdist) return e("bad codelengths","Corrupt PNG"); - if (!zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; - if (!zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; - return 1; -} - -static int parse_uncompressed_block(zbuf *a) -{ - uint8 header[4]; - int len,nlen,k; - if (a->num_bits & 7) - zreceive(a, a->num_bits & 7); // discard - // drain the bit-packed data into header - k = 0; - while (a->num_bits > 0) { - header[k++] = (uint8) (a->code_buffer & 255); // wtf this warns? - a->code_buffer >>= 8; - a->num_bits -= 8; - } - assert(a->num_bits == 0); - // now fill header the normal way - while (k < 4) - header[k++] = (uint8) zget8(a); - len = header[1] * 256 + header[0]; - nlen = header[3] * 256 + header[2]; - if (nlen != (len ^ 0xffff)) return e("zlib corrupt","Corrupt PNG"); - if (a->zbuffer + len > a->zbuffer_end) return e("read past buffer","Corrupt PNG"); - if (a->zout + len > a->zout_end) - if (!expand(a, len)) return 0; - memcpy(a->zout, a->zbuffer, len); - a->zbuffer += len; - a->zout += len; - return 1; -} - -static int parse_zlib_header(zbuf *a) -{ - int cmf = zget8(a); - int cm = cmf & 15; - /* int cinfo = cmf >> 4; */ - int flg = zget8(a); - if ((cmf*256+flg) % 31 != 0) return e("bad zlib header","Corrupt PNG"); // zlib spec - if (flg & 32) return e("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png - if (cm != 8) return e("bad compression","Corrupt PNG"); // DEFLATE required for png - // window = 1 << (8 + cinfo)... but who cares, we fully buffer output - return 1; -} - -// @TODO: should statically initialize these for optimal thread safety -static uint8 default_length[288], default_distance[32]; -static void init_defaults(void) -{ - int i; // use <= to match clearly with spec - for (i=0; i <= 143; ++i) default_length[i] = 8; - for ( ; i <= 255; ++i) default_length[i] = 9; - for ( ; i <= 279; ++i) default_length[i] = 7; - for ( ; i <= 287; ++i) default_length[i] = 8; - - for (i=0; i <= 31; ++i) default_distance[i] = 5; -} - -static int parse_zlib(zbuf *a, int parse_header) -{ - int final, type; - if (parse_header) - if (!parse_zlib_header(a)) return 0; - a->num_bits = 0; - a->code_buffer = 0; - do { - final = zreceive(a,1); - type = zreceive(a,2); - if (type == 0) { - if (!parse_uncompressed_block(a)) return 0; - } else if (type == 3) { - return 0; - } else { - if (type == 1) { - // use fixed code lengths - if (!default_distance[31]) init_defaults(); - if (!zbuild_huffman(&a->z_length , default_length , 288)) return 0; - if (!zbuild_huffman(&a->z_distance, default_distance, 32)) return 0; - } else { - if (!compute_huffman_codes(a)) return 0; - } - if (!parse_huffman_block(a)) return 0; - } - } while (!final); - return 1; -} - -static int do_zlib(zbuf *a, char *obuf, int olen, int exp, int parse_header) -{ - a->zout_start = obuf; - a->zout = obuf; - a->zout_end = obuf + olen; - a->z_expandable = exp; - - return parse_zlib(a, parse_header); -} - -char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) -{ - zbuf a; - char *p = (char *) malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (uint8 *) buffer; - a.zbuffer_end = (uint8 *) buffer + len; - if (do_zlib(&a, p, initial_size, 1, 1)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - free(a.zout_start); - return NULL; - } -} - -char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) -{ - return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); -} - -int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) -{ - zbuf a; - a.zbuffer = (uint8 *) ibuffer; - a.zbuffer_end = (uint8 *) ibuffer + ilen; - if (do_zlib(&a, obuffer, olen, 0, 1)) - return (int) (a.zout - a.zout_start); - else - return -1; -} - -char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) -{ - zbuf a; - char *p = (char *) malloc(16384); - if (p == NULL) return NULL; - a.zbuffer = (uint8 *) buffer; - a.zbuffer_end = (uint8 *) buffer+len; - if (do_zlib(&a, p, 16384, 1, 0)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - free(a.zout_start); - return NULL; - } -} - -int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) -{ - zbuf a; - a.zbuffer = (uint8 *) ibuffer; - a.zbuffer_end = (uint8 *) ibuffer + ilen; - if (do_zlib(&a, obuffer, olen, 0, 0)) - return (int) (a.zout - a.zout_start); - else - return -1; -} - -// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 -// simple implementation -// - only 8-bit samples -// - no CRC checking -// - allocates lots of intermediate memory -// - avoids problem of streaming data between subsystems -// - avoids explicit window management -// performance -// - uses stb_zlib, a PD zlib implementation with fast huffman decoding - - -typedef struct -{ - uint32 length; - uint32 type; -} chunk; - -#define PNG_TYPE(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) - -static chunk get_chunk_header(stbi *s) -{ - chunk c; - c.length = get32(s); - c.type = get32(s); - return c; -} - -static int check_png_header(stbi *s) -{ - static uint8 png_sig[8] = { 137,80,78,71,13,10,26,10 }; - int i; - for (i=0; i < 8; ++i) - if (get8(s) != png_sig[i]) return e("bad png sig","Not a PNG"); - return 1; -} - -typedef struct -{ - stbi s; - uint8 *idata, *expanded, *out; -} png; - - -enum { - F_none=0, F_sub=1, F_up=2, F_avg=3, F_paeth=4, - F_avg_first, F_paeth_first, -}; - -static uint8 first_row_filter[5] = -{ - F_none, F_sub, F_none, F_avg_first, F_paeth_first -}; - -static int paeth(int a, int b, int c) -{ - int p = a + b - c; - int pa = abs(p-a); - int pb = abs(p-b); - int pc = abs(p-c); - if (pa <= pb && pa <= pc) return a; - if (pb <= pc) return b; - return c; -} - -// create the png data from post-deflated data -static int create_png_image(png *a, uint8 *raw, uint32 raw_len, int out_n) -{ - stbi *s = &a->s; - uint32 i,j,stride = s->img_x*out_n; - int k; - int img_n = s->img_n; // copy it into a local for later - assert(out_n == s->img_n || out_n == s->img_n+1); - a->out = (uint8 *) malloc(s->img_x * s->img_y * out_n); - if (!a->out) return e("outofmem", "Out of memory"); - if (raw_len != (img_n * s->img_x + 1) * s->img_y) return e("not enough pixels","Corrupt PNG"); - for (j=0; j < s->img_y; ++j) { - uint8 *cur = a->out + stride*j; - uint8 *prior = cur - stride; - int filter = *raw++; - if (filter > 4) return e("invalid filter","Corrupt PNG"); - // if first row, use special filter that doesn't sample previous row - if (j == 0) filter = first_row_filter[filter]; - // handle first pixel explicitly - for (k=0; k < img_n; ++k) { - switch(filter) { - case F_none : cur[k] = raw[k]; break; - case F_sub : cur[k] = raw[k]; break; - case F_up : cur[k] = raw[k] + prior[k]; break; - case F_avg : cur[k] = raw[k] + (prior[k]>>1); break; - case F_paeth : cur[k] = (uint8) (raw[k] + paeth(0,prior[k],0)); break; - case F_avg_first : cur[k] = raw[k]; break; - case F_paeth_first: cur[k] = raw[k]; break; - } - } - if (img_n != out_n) cur[img_n] = 255; - raw += img_n; - cur += out_n; - prior += out_n; - // this is a little gross, so that we don't switch per-pixel or per-component - if (img_n == out_n) { - #define CASE(f) \ - case f: \ - for (i=s->img_x-1; i >= 1; --i, raw+=img_n,cur+=img_n,prior+=img_n) \ - for (k=0; k < img_n; ++k) - switch(filter) { - CASE(F_none) cur[k] = raw[k]; break; - CASE(F_sub) cur[k] = raw[k] + cur[k-img_n]; break; - CASE(F_up) cur[k] = raw[k] + prior[k]; break; - CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1); break; - CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n])); break; - CASE(F_avg_first) cur[k] = raw[k] + (cur[k-img_n] >> 1); break; - CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],0,0)); break; - } - #undef CASE - } else { - assert(img_n+1 == out_n); - #define CASE(f) \ - case f: \ - for (i=s->img_x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \ - for (k=0; k < img_n; ++k) - switch(filter) { - CASE(F_none) cur[k] = raw[k]; break; - CASE(F_sub) cur[k] = raw[k] + cur[k-out_n]; break; - CASE(F_up) cur[k] = raw[k] + prior[k]; break; - CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1); break; - CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n])); break; - CASE(F_avg_first) cur[k] = raw[k] + (cur[k-out_n] >> 1); break; - CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],0,0)); break; - } - #undef CASE - } - } - return 1; -} - -static int compute_transparency(png *z, uint8 tc[3], int out_n) -{ - stbi *s = &z->s; - uint32 i, pixel_count = s->img_x * s->img_y; - uint8 *p = z->out; - - // compute color-based transparency, assuming we've - // already got 255 as the alpha value in the output - assert(out_n == 2 || out_n == 4); - - if (out_n == 2) { - for (i=0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 255); - p += 2; - } - } else { - for (i=0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; -} - -static int expand_palette(png *a, uint8 *palette, int len, int pal_img_n) -{ - uint32 i, pixel_count = a->s.img_x * a->s.img_y; - uint8 *p, *temp_out, *orig = a->out; - - p = (uint8 *) malloc(pixel_count * pal_img_n); - if (p == NULL) return e("outofmem", "Out of memory"); - - // between here and free(out) below, exitting would leak - temp_out = p; - - if (pal_img_n == 3) { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p += 3; - } - } else { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p[3] = palette[n+3]; - p += 4; - } - } - free(a->out); - a->out = temp_out; - return 1; -} - -static int parse_png_file(png *z, int scan, int req_comp) -{ - uint8 palette[1024], pal_img_n=0; - uint8 has_trans=0, tc[3]; - uint32 ioff=0, idata_limit=0, i, pal_len=0; - int first=1,k; - stbi *s = &z->s; - - if (!check_png_header(s)) return 0; - - if (scan == SCAN_type) return 1; - - for(;;first=0) { - chunk c = get_chunk_header(s); - if (first && c.type != PNG_TYPE('I','H','D','R')) - return e("first not IHDR","Corrupt PNG"); - switch (c.type) { - case PNG_TYPE('I','H','D','R'): { - int depth,color,interlace,comp,filter; - if (!first) return e("multiple IHDR","Corrupt PNG"); - if (c.length != 13) return e("bad IHDR len","Corrupt PNG"); - s->img_x = get32(s); if (s->img_x > (1 << 24)) return e("too large","Very large image (corrupt?)"); - s->img_y = get32(s); if (s->img_y > (1 << 24)) return e("too large","Very large image (corrupt?)"); - depth = get8(s); if (depth != 8) return e("8bit only","PNG not supported: 8-bit only"); - color = get8(s); if (color > 6) return e("bad ctype","Corrupt PNG"); - if (color == 3) pal_img_n = 3; else if (color & 1) return e("bad ctype","Corrupt PNG"); - comp = get8(s); if (comp) return e("bad comp method","Corrupt PNG"); - filter= get8(s); if (filter) return e("bad filter method","Corrupt PNG"); - interlace = get8(s); if (interlace) return e("interlaced","PNG not supported: interlaced mode"); - if (!s->img_x || !s->img_y) return e("0-pixel image","Corrupt PNG"); - if (!pal_img_n) { - s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return e("too large", "Image too large to decode"); - if (scan == SCAN_header) return 1; - } else { - // if paletted, then pal_n is our final components, and - // img_n is # components to decompress/filter. - s->img_n = 1; - if ((1 << 30) / s->img_x / 4 < s->img_y) return e("too large","Corrupt PNG"); - // if SCAN_header, have to scan to see if we have a tRNS - } - break; - } - - case PNG_TYPE('P','L','T','E'): { - if (c.length > 256*3) return e("invalid PLTE","Corrupt PNG"); - pal_len = c.length / 3; - if (pal_len * 3 != c.length) return e("invalid PLTE","Corrupt PNG"); - for (i=0; i < pal_len; ++i) { - palette[i*4+0] = get8u(s); - palette[i*4+1] = get8u(s); - palette[i*4+2] = get8u(s); - palette[i*4+3] = 255; - } - break; - } - - case PNG_TYPE('t','R','N','S'): { - if (z->idata) return e("tRNS after IDAT","Corrupt PNG"); - if (pal_img_n) { - if (scan == SCAN_header) { s->img_n = 4; return 1; } - if (pal_len == 0) return e("tRNS before PLTE","Corrupt PNG"); - if (c.length > pal_len) return e("bad tRNS len","Corrupt PNG"); - pal_img_n = 4; - for (i=0; i < c.length; ++i) - palette[i*4+3] = get8u(s); - } else { - if (!(s->img_n & 1)) return e("tRNS with alpha","Corrupt PNG"); - if (c.length != (uint32) s->img_n*2) return e("bad tRNS len","Corrupt PNG"); - has_trans = 1; - for (k=0; k < s->img_n; ++k) - tc[k] = (uint8) get16(s); // non 8-bit images will be larger - } - break; - } - - case PNG_TYPE('I','D','A','T'): { - if (pal_img_n && !pal_len) return e("no PLTE","Corrupt PNG"); - if (scan == SCAN_header) { s->img_n = pal_img_n; return 1; } - if (ioff + c.length > idata_limit) { - uint8 *p; - if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; - while (ioff + c.length > idata_limit) - idata_limit *= 2; - p = (uint8 *) realloc(z->idata, idata_limit); if (p == NULL) return e("outofmem", "Out of memory"); - z->idata = p; - } - #ifndef STBI_NO_STDIO - if (s->img_file) - { - if (fread(z->idata+ioff,1,c.length,s->img_file) != c.length) return e("outofdata","Corrupt PNG"); - } - else - #endif - { - memcpy(z->idata+ioff, s->img_buffer, c.length); - s->img_buffer += c.length; - } - ioff += c.length; - break; - } - - case PNG_TYPE('I','E','N','D'): { - uint32 raw_len; - if (scan != SCAN_load) return 1; - if (z->idata == NULL) return e("no IDAT","Corrupt PNG"); - z->expanded = (uint8 *) stbi_zlib_decode_malloc((char *) z->idata, ioff, (int *) &raw_len); - if (z->expanded == NULL) return 0; // zlib should set error - free(z->idata); z->idata = NULL; - if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) - s->img_out_n = s->img_n+1; - else - s->img_out_n = s->img_n; - if (!create_png_image(z, z->expanded, raw_len, s->img_out_n)) return 0; - if (has_trans) - if (!compute_transparency(z, tc, s->img_out_n)) return 0; - if (pal_img_n) { - // pal_img_n == 3 or 4 - s->img_n = pal_img_n; // record the actual colors we had - s->img_out_n = pal_img_n; - if (req_comp >= 3) s->img_out_n = req_comp; - if (!expand_palette(z, palette, pal_len, s->img_out_n)) - return 0; - } - free(z->expanded); z->expanded = NULL; - return 1; - } - - default: - // if critical, fail - if ((c.type & (1 << 29)) == 0) { - #ifndef STBI_NO_FAILURE_STRINGS - // not threadsafe - static char invalid_chunk[] = "XXXX chunk not known"; - invalid_chunk[0] = (uint8) (c.type >> 24); - invalid_chunk[1] = (uint8) (c.type >> 16); - invalid_chunk[2] = (uint8) (c.type >> 8); - invalid_chunk[3] = (uint8) (c.type >> 0); - #endif - return e(invalid_chunk, "PNG not supported: unknown chunk type"); - } - skip(s, c.length); - break; - } - // end of chunk, read and skip CRC - get32(s); - } -} - -static unsigned char *do_png(png *p, int *x, int *y, int *n, int req_comp) -{ - unsigned char *result=NULL; - p->expanded = NULL; - p->idata = NULL; - p->out = NULL; - if (req_comp < 0 || req_comp > 4) return epuc("bad req_comp", "Internal error"); - if (parse_png_file(p, SCAN_load, req_comp)) { - result = p->out; - p->out = NULL; - if (req_comp && req_comp != p->s.img_out_n) { - result = convert_format(result, p->s.img_out_n, req_comp, p->s.img_x, p->s.img_y); - p->s.img_out_n = req_comp; - if (result == NULL) return result; - } - *x = p->s.img_x; - *y = p->s.img_y; - if (n) *n = p->s.img_n; - } - free(p->out); p->out = NULL; - free(p->expanded); p->expanded = NULL; - free(p->idata); p->idata = NULL; - - return result; -} - -#ifndef STBI_NO_STDIO -unsigned char *stbi_png_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - png p; - start_file(&p.s, f); - return do_png(&p, x,y,comp,req_comp); -} - -unsigned char *stbi_png_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_png_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return data; -} -#endif - -unsigned char *stbi_png_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - png p; - start_mem(&p.s, buffer,len); - return do_png(&p, x,y,comp,req_comp); -} - -#ifndef STBI_NO_STDIO -int stbi_png_test_file(FILE *f) -{ - png p; - int n,r; - n = ftell(f); - start_file(&p.s, f); - r = parse_png_file(&p, SCAN_type,STBI_default); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_png_test_memory(stbi_uc const *buffer, int len) -{ - png p; - start_mem(&p.s, buffer, len); - return parse_png_file(&p, SCAN_type,STBI_default); -} - -// TODO: load header from png -#ifndef STBI_NO_STDIO -extern int stbi_png_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_png_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif -extern int stbi_png_info_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -// Microsoft/Windows BMP image - -static int bmp_test(stbi *s) -{ - int sz; - if (get8(s) != 'B') return 0; - if (get8(s) != 'M') return 0; - get32le(s); // discard filesize - get16le(s); // discard reserved - get16le(s); // discard reserved - get32le(s); // discard data offset - sz = get32le(s); - if (sz == 12 || sz == 40 || sz == 56 || sz == 108) return 1; - return 0; -} - -#ifndef STBI_NO_STDIO -int stbi_bmp_test_file (FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s,f); - r = bmp_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_bmp_test_memory (stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return bmp_test(&s); -} - -// returns 0..31 for the highest set bit -static int high_bit(unsigned int z) -{ - int n=0; - if (z == 0) return -1; - if (z >= 0x10000) n += 16, z >>= 16; - if (z >= 0x00100) n += 8, z >>= 8; - if (z >= 0x00010) n += 4, z >>= 4; - if (z >= 0x00004) n += 2, z >>= 2; - if (z >= 0x00002) n += 1, z >>= 1; - return n; -} - -static int bitcount(unsigned int a) -{ - a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 - a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 - a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits - a = (a + (a >> 8)); // max 16 per 8 bits - a = (a + (a >> 16)); // max 32 per 8 bits - return a & 0xff; -} - -static int shiftsigned(int v, int shift, int bits) -{ - int result; - int z=0; - - if (shift < 0) v <<= -shift; - else v >>= shift; - result = v; - - z = bits; - while (z < 8) { - result += v >> z; - z += bits; - } - return result; -} - -static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - uint8 *out; - unsigned int mr=0,mg=0,mb=0,ma=0; - stbi_uc pal[256][4]; - int psize=0,i,j,compress=0,width; - int bpp, flip_vertically, pad, target, offset, hsz; - if (get8(s) != 'B' || get8(s) != 'M') return epuc("not BMP", "Corrupt BMP"); - get32le(s); // discard filesize - get16le(s); // discard reserved - get16le(s); // discard reserved - offset = get32le(s); - hsz = get32le(s); - if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108) return epuc("unknown BMP", "BMP type not supported: unknown"); - failure_reason = "bad BMP"; - if (hsz == 12) { - s->img_x = get16le(s); - s->img_y = get16le(s); - } else { - s->img_x = get32le(s); - s->img_y = get32le(s); - } - if (get16le(s) != 1) return 0; - bpp = get16le(s); - if (bpp == 1) return epuc("monochrome", "BMP type not supported: 1-bit"); - flip_vertically = ((int) s->img_y) > 0; - s->img_y = abs((int) s->img_y); - if (hsz == 12) { - if (bpp < 24) - psize = (offset - 14 - 24) / 3; - } else { - compress = get32le(s); - if (compress == 1 || compress == 2) return epuc("BMP RLE", "BMP type not supported: RLE"); - get32le(s); // discard sizeof - get32le(s); // discard hres - get32le(s); // discard vres - get32le(s); // discard colorsused - get32le(s); // discard max important - if (hsz == 40 || hsz == 56) { - if (hsz == 56) { - get32le(s); - get32le(s); - get32le(s); - get32le(s); - } - if (bpp == 16 || bpp == 32) { - mr = mg = mb = 0; - if (compress == 0) { - if (bpp == 32) { - mr = 0xff << 16; - mg = 0xff << 8; - mb = 0xff << 0; - } else { - mr = 31 << 10; - mg = 31 << 5; - mb = 31 << 0; - } - } else if (compress == 3) { - mr = get32le(s); - mg = get32le(s); - mb = get32le(s); - // not documented, but generated by photoshop and handled by mspaint - if (mr == mg && mg == mb) { - // ?!?!? - return NULL; - } - } else - return NULL; - } - } else { - assert(hsz == 108); - mr = get32le(s); - mg = get32le(s); - mb = get32le(s); - ma = get32le(s); - get32le(s); // discard color space - for (i=0; i < 12; ++i) - get32le(s); // discard color space parameters - } - if (bpp < 16) - psize = (offset - 14 - hsz) >> 2; - } - s->img_n = ma ? 4 : 3; - if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 - target = req_comp; - else - target = s->img_n; // if they want monochrome, we'll post-convert - out = (stbi_uc *) malloc(target * s->img_x * s->img_y); - if (!out) return epuc("outofmem", "Out of memory"); - if (bpp < 16) { - int z=0; - if (psize == 0 || psize > 256) { free(out); return epuc("invalid", "Corrupt BMP"); } - for (i=0; i < psize; ++i) { - pal[i][2] = get8(s); - pal[i][1] = get8(s); - pal[i][0] = get8(s); - if (hsz != 12) get8(s); - pal[i][3] = 255; - } - skip(s, offset - 14 - hsz - psize * (hsz == 12 ? 3 : 4)); - if (bpp == 4) width = (s->img_x + 1) >> 1; - else if (bpp == 8) width = s->img_x; - else { free(out); return epuc("bad bpp", "Corrupt BMP"); } - pad = (-width)&3; - for (j=0; j < (int) s->img_y; ++j) { - for (i=0; i < (int) s->img_x; i += 2) { - int v=get8(s),v2=0; - if (bpp == 4) { - v2 = v & 15; - v >>= 4; - } - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - v = (bpp == 8) ? get8(s) : v2; - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - } - skip(s, pad); - } - } else { - int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; - int z = 0; - int easy=0; - skip(s, offset - 14 - hsz); - if (bpp == 24) width = 3 * s->img_x; - else if (bpp == 16) width = 2*s->img_x; - else /* bpp = 32 and pad = 0 */ width=0; - pad = (-width) & 3; - if (bpp == 24) { - easy = 1; - } else if (bpp == 32) { - if (mb == 0xff && mg == 0xff00 && mr == 0xff000000 && ma == 0xff000000) - easy = 2; - } - if (!easy) { - if (!mr || !mg || !mb) return epuc("bad masks", "Corrupt BMP"); - // right shift amt to put high bit in position #7 - rshift = high_bit(mr)-7; rcount = bitcount(mr); - gshift = high_bit(mg)-7; gcount = bitcount(mr); - bshift = high_bit(mb)-7; bcount = bitcount(mr); - ashift = high_bit(ma)-7; acount = bitcount(mr); - } - for (j=0; j < (int) s->img_y; ++j) { - if (easy) { - for (i=0; i < (int) s->img_x; ++i) { - int a; - out[z+2] = get8(s); - out[z+1] = get8(s); - out[z+0] = get8(s); - z += 3; - a = (easy == 2 ? get8(s) : 255); - if (target == 4) out[z++] = a; - } - } else { - for (i=0; i < (int) s->img_x; ++i) { - uint32 v = (bpp == 16 ? get16le(s) : get32le(s)); - int a; - out[z++] = shiftsigned(v & mr, rshift, rcount); - out[z++] = shiftsigned(v & mg, gshift, gcount); - out[z++] = shiftsigned(v & mb, bshift, bcount); - a = (ma ? shiftsigned(v & ma, ashift, acount) : 255); - if (target == 4) out[z++] = a; - } - } - skip(s, pad); - } - } - if (flip_vertically) { - stbi_uc t; - for (j=0; j < (int) s->img_y>>1; ++j) { - stbi_uc *p1 = out + j *s->img_x*target; - stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; - for (i=0; i < (int) s->img_x*target; ++i) { - t = p1[i], p1[i] = p2[i], p2[i] = t; - } - } - } - - if (req_comp && req_comp != target) { - out = convert_format(out, target, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // convert_format frees input on failure - } - - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = target; - return out; -} - -#ifndef STBI_NO_STDIO -stbi_uc *stbi_bmp_load (char const *filename, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_bmp_load_from_file(f, x,y,comp,req_comp); - fclose(f); - return data; -} - -stbi_uc *stbi_bmp_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s, f); - return bmp_load(&s, x,y,comp,req_comp); -} -#endif - -stbi_uc *stbi_bmp_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s, buffer, len); - return bmp_load(&s, x,y,comp,req_comp); -} - -// Targa Truevision - TGA -// by Jonathan Dummer - -static int tga_test(stbi *s) -{ - int sz; - get8u(s); // discard Offset - sz = get8u(s); // color type - if( sz > 1 ) return 0; // only RGB or indexed allowed - sz = get8u(s); // image type - if( (sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) && (sz != 11) ) return 0; // only RGB or grey allowed, +/- RLE - get16(s); // discard palette start - get16(s); // discard palette length - get8(s); // discard bits per palette color entry - get16(s); // discard x origin - get16(s); // discard y origin - if( get16(s) < 1 ) return 0; // test width - if( get16(s) < 1 ) return 0; // test height - sz = get8(s); // bits per pixel - if( (sz != 8) && (sz != 16) && (sz != 24) && (sz != 32) ) return 0; // only RGB or RGBA or grey allowed - return 1; // seems to have passed everything -} - -#ifndef STBI_NO_STDIO -int stbi_tga_test_file (FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s, f); - r = tga_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_tga_test_memory (stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return tga_test(&s); -} - -static stbi_uc *tga_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - // read in the TGA header stuff - int tga_offset = get8u(s); - int tga_indexed = get8u(s); - int tga_image_type = get8u(s); - int tga_is_RLE = 0; - int tga_palette_start = get16le(s); - int tga_palette_len = get16le(s); - int tga_palette_bits = get8u(s); - int tga_x_origin = get16le(s); - int tga_y_origin = get16le(s); - int tga_width = get16le(s); - int tga_height = get16le(s); - int tga_bits_per_pixel = get8u(s); - int tga_inverted = get8u(s); - // image data - unsigned char *tga_data; - unsigned char *tga_palette = NULL; - int i, j; - unsigned char raw_data[4]; - unsigned char trans_data[] = { 0,0,0,0 }; - int RLE_count = 0; - int RLE_repeating = 0; - int read_next_pixel = 1; - // do a tiny bit of precessing - if( tga_image_type >= 8 ) - { - tga_image_type -= 8; - tga_is_RLE = 1; - } - /* int tga_alpha_bits = tga_inverted & 15; */ - tga_inverted = 1 - ((tga_inverted >> 5) & 1); - - // error check - if( //(tga_indexed) || - (tga_width < 1) || (tga_height < 1) || - (tga_image_type < 1) || (tga_image_type > 3) || - ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16) && - (tga_bits_per_pixel != 24) && (tga_bits_per_pixel != 32)) - ) - { - return NULL; - } - - // If I'm paletted, then I'll use the number of bits from the palette - if( tga_indexed ) - { - tga_bits_per_pixel = tga_palette_bits; - } - - // tga info - *x = tga_width; - *y = tga_height; - if( (req_comp < 1) || (req_comp > 4) ) - { - // just use whatever the file was - req_comp = tga_bits_per_pixel / 8; - *comp = req_comp; - } else - { - // force a new number of components - *comp = tga_bits_per_pixel/8; - } - tga_data = (unsigned char*)malloc( tga_width * tga_height * req_comp ); - - // skip to the data's starting position (offset usually = 0) - skip(s, tga_offset ); - // do I need to load a palette? - if( tga_indexed ) - { - // any data to skip? (offset usually = 0) - skip(s, tga_palette_start ); - // load the palette - tga_palette = (unsigned char*)malloc( tga_palette_len * tga_palette_bits / 8 ); - getn(s, tga_palette, tga_palette_len * tga_palette_bits / 8 ); - } - // load the data - for( i = 0; i < tga_width * tga_height; ++i ) - { - // if I'm in RLE mode, do I need to get a RLE chunk? - if( tga_is_RLE ) - { - if( RLE_count == 0 ) - { - // yep, get the next byte as a RLE command - int RLE_cmd = get8u(s); - RLE_count = 1 + (RLE_cmd & 127); - RLE_repeating = RLE_cmd >> 7; - read_next_pixel = 1; - } else if( !RLE_repeating ) - { - read_next_pixel = 1; - } - } else - { - read_next_pixel = 1; - } - // OK, if I need to read a pixel, do it now - if( read_next_pixel ) - { - // load however much data we did have - if( tga_indexed ) - { - // read in 1 byte, then perform the lookup - int pal_idx = get8u(s); - if( pal_idx >= tga_palette_len ) - { - // invalid index - pal_idx = 0; - } - pal_idx *= tga_bits_per_pixel / 8; - for( j = 0; j*8 < tga_bits_per_pixel; ++j ) - { - raw_data[j] = tga_palette[pal_idx+j]; - } - } else - { - // read in the data raw - for( j = 0; j*8 < tga_bits_per_pixel; ++j ) - { - raw_data[j] = get8u(s); - } - } - // convert raw to the intermediate format - switch( tga_bits_per_pixel ) - { - case 8: - // Luminous => RGBA - trans_data[0] = raw_data[0]; - trans_data[1] = raw_data[0]; - trans_data[2] = raw_data[0]; - trans_data[3] = 255; - break; - case 16: - // Luminous,Alpha => RGBA - trans_data[0] = raw_data[0]; - trans_data[1] = raw_data[0]; - trans_data[2] = raw_data[0]; - trans_data[3] = raw_data[1]; - break; - case 24: - // BGR => RGBA - trans_data[0] = raw_data[2]; - trans_data[1] = raw_data[1]; - trans_data[2] = raw_data[0]; - trans_data[3] = 255; - break; - case 32: - // BGRA => RGBA - trans_data[0] = raw_data[2]; - trans_data[1] = raw_data[1]; - trans_data[2] = raw_data[0]; - trans_data[3] = raw_data[3]; - break; - } - // clear the reading flag for the next pixel - read_next_pixel = 0; - } // end of reading a pixel - // convert to final format - switch( req_comp ) - { - case 1: - // RGBA => Luminance - tga_data[i*req_comp+0] = compute_y(trans_data[0],trans_data[1],trans_data[2]); - break; - case 2: - // RGBA => Luminance,Alpha - tga_data[i*req_comp+0] = compute_y(trans_data[0],trans_data[1],trans_data[2]); - tga_data[i*req_comp+1] = trans_data[3]; - break; - case 3: - // RGBA => RGB - tga_data[i*req_comp+0] = trans_data[0]; - tga_data[i*req_comp+1] = trans_data[1]; - tga_data[i*req_comp+2] = trans_data[2]; - break; - case 4: - // RGBA => RGBA - tga_data[i*req_comp+0] = trans_data[0]; - tga_data[i*req_comp+1] = trans_data[1]; - tga_data[i*req_comp+2] = trans_data[2]; - tga_data[i*req_comp+3] = trans_data[3]; - break; - } - // in case we're in RLE mode, keep counting down - --RLE_count; - } - // do I need to invert the image? - if( tga_inverted ) - { - for( j = 0; j*2 < tga_height; ++j ) - { - int index1 = j * tga_width * req_comp; - int index2 = (tga_height - 1 - j) * tga_width * req_comp; - for( i = tga_width * req_comp; i > 0; --i ) - { - unsigned char temp = tga_data[index1]; - tga_data[index1] = tga_data[index2]; - tga_data[index2] = temp; - ++index1; - ++index2; - } - } - } - // clear my palette, if I had one - if( tga_palette != NULL ) - { - free( tga_palette ); - } - // the things I do to get rid of an error message, and yet keep - // Microsoft's C compilers happy... [8^( - tga_palette_start = tga_palette_len = tga_palette_bits = - tga_x_origin = tga_y_origin = 0; - // OK, done - return tga_data; -} - -#ifndef STBI_NO_STDIO -stbi_uc *stbi_tga_load (char const *filename, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_tga_load_from_file(f, x,y,comp,req_comp); - fclose(f); - return data; -} - -stbi_uc *stbi_tga_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s, f); - return tga_load(&s, x,y,comp,req_comp); -} -#endif - -stbi_uc *stbi_tga_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s, buffer, len); - return tga_load(&s, x,y,comp,req_comp); -} - - -// ************************************************************************************************* -// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicholas Schulz, tweaked by STB - -static int psd_test(stbi *s) -{ - if (get32(s) != 0x38425053) return 0; // "8BPS" - else return 1; -} - -#ifndef STBI_NO_STDIO -int stbi_psd_test_file(FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s, f); - r = psd_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_psd_test_memory(stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return psd_test(&s); -} - -static stbi_uc *psd_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - int pixelCount; - int channelCount, compression; - int channel, i, count, len; - int w,h; - uint8 *out; - - // Check identifier - if (get32(s) != 0x38425053) // "8BPS" - return epuc("not PSD", "Corrupt PSD image"); - - // Check file type version. - if (get16(s) != 1) - return epuc("wrong version", "Unsupported version of PSD image"); - - // Skip 6 reserved bytes. - skip(s, 6 ); - - // Read the number of channels (R, G, B, A, etc). - channelCount = get16(s); - if (channelCount < 0 || channelCount > 16) - return epuc("wrong channel count", "Unsupported number of channels in PSD image"); - - // Read the rows and columns of the image. - h = get32(s); - w = get32(s); - - // Make sure the depth is 8 bits. - if (get16(s) != 8) - return epuc("unsupported bit depth", "PSD bit depth is not 8 bit"); - - // Make sure the color mode is RGB. - // Valid options are: - // 0: Bitmap - // 1: Grayscale - // 2: Indexed color - // 3: RGB color - // 4: CMYK color - // 7: Multichannel - // 8: Duotone - // 9: Lab color - if (get16(s) != 3) - return epuc("wrong color format", "PSD is not in RGB color format"); - - // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) - skip(s,get32(s) ); - - // Skip the image resources. (resolution, pen tool paths, etc) - skip(s, get32(s) ); - - // Skip the reserved data. - skip(s, get32(s) ); - - // Find out if the data is compressed. - // Known values: - // 0: no compression - // 1: RLE compressed - compression = get16(s); - if (compression > 1) - return epuc("bad compression", "PSD has an unknown compression format"); - - // Create the destination image. - out = (stbi_uc *) malloc(4 * w*h); - if (!out) return epuc("outofmem", "Out of memory"); - pixelCount = w*h; - - // Initialize the data to zero. - //memset( out, 0, pixelCount * 4 ); - - // Finally, the image data. - if (compression) { - // RLE as used by .PSD and .TIFF - // Loop until you get the number of unpacked bytes you are expecting: - // Read the next source byte into n. - // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. - // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. - // Else if n is 128, noop. - // Endloop - - // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, - // which we're going to just skip. - skip(s, h * channelCount * 2 ); - - // Read the RLE data by channel. - for (channel = 0; channel < 4; channel++) { - uint8 *p; - - p = out+channel; - if (channel >= channelCount) { - // Fill this channel with default data. - for (i = 0; i < pixelCount; i++) *p = (channel == 3 ? 255 : 0), p += 4; - } else { - // Read the RLE data. - count = 0; - while (count < pixelCount) { - len = get8(s); - if (len == 128) { - // No-op. - } else if (len < 128) { - // Copy next len+1 bytes literally. - len++; - count += len; - while (len) { - *p = get8(s); - p += 4; - len--; - } - } else if (len > 128) { - uint32 val; - // Next -len+1 bytes in the dest are replicated from next source byte. - // (Interpret len as a negative 8-bit int.) - len ^= 0x0FF; - len += 2; - val = get8(s); - count += len; - while (len) { - *p = val; - p += 4; - len--; - } - } - } - } - } - - } else { - // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) - // where each channel consists of an 8-bit value for each pixel in the image. - - // Read the data by channel. - for (channel = 0; channel < 4; channel++) { - uint8 *p; - - p = out + channel; - if (channel > channelCount) { - // Fill this channel with default data. - for (i = 0; i < pixelCount; i++) *p = channel == 3 ? 255 : 0, p += 4; - } else { - // Read the data. - count = 0; - for (i = 0; i < pixelCount; i++) - *p = get8(s), p += 4; - } - } - } - - if (req_comp && req_comp != 4) { - out = convert_format(out, 4, req_comp, w, h); - if (out == NULL) return out; // convert_format frees input on failure - } - - if (comp) *comp = channelCount; - *y = h; - *x = w; - - return out; -} - -#ifndef STBI_NO_STDIO -stbi_uc *stbi_psd_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_psd_load_from_file(f, x,y,comp,req_comp); - fclose(f); - return data; -} - -stbi_uc *stbi_psd_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s, f); - return psd_load(&s, x,y,comp,req_comp); -} -#endif - -stbi_uc *stbi_psd_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s, buffer, len); - return psd_load(&s, x,y,comp,req_comp); -} - - -// ************************************************************************************************* -// Radiance RGBE HDR loader -// originally by Nicolas Schulz -#ifndef STBI_NO_HDR -static int hdr_test(stbi *s) -{ - char *signature = "#?RADIANCE\n"; - int i; - for (i=0; signature[i]; ++i) - if (get8(s) != signature[i]) - return 0; - return 1; -} - -int stbi_hdr_test_memory(stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return hdr_test(&s); -} - -#ifndef STBI_NO_STDIO -int stbi_hdr_test_file(FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s, f); - r = hdr_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -#define HDR_BUFLEN 1024 -static char *hdr_gettoken(stbi *z, char *buffer) -{ - int len=0; - //char *s = buffer, - char c = '\0'; - - c = get8(z); - - while (!at_eof(z) && c != '\n') { - buffer[len++] = c; - if (len == HDR_BUFLEN-1) { - // flush to end of line - while (!at_eof(z) && get8(z) != '\n') - ; - break; - } - c = get8(z); - } - - buffer[len] = 0; - return buffer; -} - -static void hdr_convert(float *output, stbi_uc *input, int req_comp) -{ - if( input[3] != 0 ) { - float f1; - // Exponent - f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); - if (req_comp <= 2) - output[0] = (input[0] + input[1] + input[2]) * f1 / 3; - else { - output[0] = input[0] * f1; - output[1] = input[1] * f1; - output[2] = input[2] * f1; - } - if (req_comp == 2) output[1] = 1; - if (req_comp == 4) output[3] = 1; - } else { - switch (req_comp) { - case 4: output[3] = 1; /* fallthrough */ - case 3: output[0] = output[1] = output[2] = 0; - break; - case 2: output[1] = 1; /* fallthrough */ - case 1: output[0] = 0; - break; - } - } -} - - -static float *hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - char buffer[HDR_BUFLEN]; - char *token; - int valid = 0; - int width, height; - stbi_uc *scanline; - float *hdr_data; - int len; - unsigned char count, value; - int i, j, k, c1,c2, z; - - - // Check identifier - if (strcmp(hdr_gettoken(s,buffer), "#?RADIANCE") != 0) - return epf("not HDR", "Corrupt HDR image"); - - // Parse header - while(1) { - token = hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) return epf("unsupported format", "Unsupported HDR format"); - - // Parse width and height - // can't use sscanf() if we're not using stdio! - token = hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) return epf("unsupported data layout", "Unsupported HDR format"); - token += 3; - height = strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) return epf("unsupported data layout", "Unsupported HDR format"); - token += 3; - width = strtol(token, NULL, 10); - - *x = width; - *y = height; - - *comp = 3; - if (req_comp == 0) req_comp = 3; - - // Read data - hdr_data = (float *) malloc(height * width * req_comp * sizeof(float)); - - // Load image data - // image data is stored as some number of sca - if( width < 8 || width >= 32768) { - // Read flat data - for (j=0; j < height; ++j) { - for (i=0; i < width; ++i) { - stbi_uc rgbe[4]; - main_decode_loop: - getn(s, rgbe, 4); - hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); - } - } - } else { - // Read RLE-encoded data - scanline = NULL; - - for (j = 0; j < height; ++j) { - c1 = get8(s); - c2 = get8(s); - len = get8(s); - if (c1 != 2 || c2 != 2 || (len & 0x80)) { - // not run-length encoded, so we have to actually use THIS data as a decoded - // pixel (note this can't be a valid pixel--one of RGB must be >= 128) - stbi_uc rgbe[4] = { c1,c2,len, get8(s) }; - hdr_convert(hdr_data, rgbe, req_comp); - i = 1; - j = 0; - free(scanline); - goto main_decode_loop; // yes, this is fucking insane; blame the fucking insane format - } - len <<= 8; - len |= get8(s); - if (len != width) { free(hdr_data); free(scanline); return epf("invalid decoded scanline length", "corrupt HDR"); } - if (scanline == NULL) scanline = (stbi_uc *) malloc(width * 4); - - for (k = 0; k < 4; ++k) { - i = 0; - while (i < width) { - count = get8(s); - if (count > 128) { - // Run - value = get8(s); - count -= 128; - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = value; - } else { - // Dump - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = get8(s); - } - } - } - for (i=0; i < width; ++i) - hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); - } - free(scanline); - } - - return hdr_data; -} - -static stbi_uc *hdr_load_rgbe(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - char buffer[HDR_BUFLEN]; - char *token; - int valid = 0; - int width, height; - stbi_uc *scanline; - stbi_uc *rgbe_data; - int len; - unsigned char count, value; - int i, j, k, c1,c2, z; - - - // Check identifier - if (strcmp(hdr_gettoken(s,buffer), "#?RADIANCE") != 0) - return epuc("not HDR", "Corrupt HDR image"); - - // Parse header - while(1) { - token = hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) return epuc("unsupported format", "Unsupported HDR format"); - - // Parse width and height - // can't use sscanf() if we're not using stdio! - token = hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) return epuc("unsupported data layout", "Unsupported HDR format"); - token += 3; - height = strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) return epuc("unsupported data layout", "Unsupported HDR format"); - token += 3; - width = strtol(token, NULL, 10); - - *x = width; - *y = height; - - // RGBE _MUST_ come out as 4 components - *comp = 4; - req_comp = 4; - - // Read data - rgbe_data = (stbi_uc *) malloc(height * width * req_comp * sizeof(stbi_uc)); - // point to the beginning - scanline = rgbe_data; - - // Load image data - // image data is stored as some number of scan lines - if( width < 8 || width >= 32768) { - // Read flat data - for (j=0; j < height; ++j) { - for (i=0; i < width; ++i) { - main_decode_loop: - //getn(rgbe, 4); - getn(s,scanline, 4); - scanline += 4; - } - } - } else { - // Read RLE-encoded data - for (j = 0; j < height; ++j) { - c1 = get8(s); - c2 = get8(s); - len = get8(s); - if (c1 != 2 || c2 != 2 || (len & 0x80)) { - // not run-length encoded, so we have to actually use THIS data as a decoded - // pixel (note this can't be a valid pixel--one of RGB must be >= 128) - scanline[0] = c1; - scanline[1] = c2; - scanline[2] = len; - scanline[3] = get8(s); - scanline += 4; - i = 1; - j = 0; - goto main_decode_loop; // yes, this is insane; blame the insane format - } - len <<= 8; - len |= get8(s); - if (len != width) { free(rgbe_data); return epuc("invalid decoded scanline length", "corrupt HDR"); } - for (k = 0; k < 4; ++k) { - i = 0; - while (i < width) { - count = get8(s); - if (count > 128) { - // Run - value = get8(s); - count -= 128; - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = value; - } else { - // Dump - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = get8(s); - } - } - } - // move the scanline on - scanline += 4 * width; - } - } - - return rgbe_data; -} - -#ifndef STBI_NO_STDIO -float *stbi_hdr_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s,f); - return hdr_load(&s,x,y,comp,req_comp); -} - -stbi_uc *stbi_hdr_load_rgbe_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s,f); - return hdr_load_rgbe(&s,x,y,comp,req_comp); -} - -stbi_uc *stbi_hdr_load_rgbe (char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = fopen(filename, "rb"); - unsigned char *result; - if (!f) return epuc("can't fopen", "Unable to open file"); - result = stbi_hdr_load_rgbe_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} -#endif - -float *stbi_hdr_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s,buffer, len); - return hdr_load(&s,x,y,comp,req_comp); -} - -stbi_uc *stbi_hdr_load_rgbe_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s,buffer, len); - return hdr_load_rgbe(&s,x,y,comp,req_comp); -} - -#endif // STBI_NO_HDR - -/////////////////////// write image /////////////////////// - -#ifndef STBI_NO_WRITE - -static void write8(FILE *f, int x) { uint8 z = (uint8) x; fwrite(&z,1,1,f); } - -static void writefv(FILE *f, char *fmt, va_list v) -{ - while (*fmt) { - switch (*fmt++) { - case ' ': break; - case '1': { uint8 x = va_arg(v, int); write8(f,x); break; } - case '2': { int16 x = va_arg(v, int); write8(f,x); write8(f,x>>8); break; } - case '4': { int32 x = va_arg(v, int); write8(f,x); write8(f,x>>8); write8(f,x>>16); write8(f,x>>24); break; } - default: - assert(0); - va_end(v); - return; - } - } -} - -static void writef(FILE *f, char *fmt, ...) -{ - va_list v; - va_start(v, fmt); - writefv(f,fmt,v); - va_end(v); -} - -static void write_pixels(FILE *f, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad) -{ - uint8 bg[3] = { 255, 0, 255}, px[3]; - uint32 zero = 0; - int i,j,k, j_end; - - if (vdir < 0) - j_end = -1, j = y-1; - else - j_end = y, j = 0; - - for (; j != j_end; j += vdir) { - for (i=0; i < x; ++i) { - uint8 *d = (uint8 *) data + (j*x+i)*comp; - if (write_alpha < 0) - fwrite(&d[comp-1], 1, 1, f); - switch (comp) { - case 1: - case 2: writef(f, "111", d[0],d[0],d[0]); - break; - case 4: - if (!write_alpha) { - for (k=0; k < 3; ++k) - px[k] = bg[k] + ((d[k] - bg[k]) * d[3])/255; - writef(f, "111", px[1-rgb_dir],px[1],px[1+rgb_dir]); - break; - } - /* FALLTHROUGH */ - case 3: - writef(f, "111", d[1-rgb_dir],d[1],d[1+rgb_dir]); - break; - } - if (write_alpha > 0) - fwrite(&d[comp-1], 1, 1, f); - } - fwrite(&zero,scanline_pad,1,f); - } -} - -static int outfile(char const *filename, int rgb_dir, int vdir, int x, int y, int comp, void *data, int alpha, int pad, char *fmt, ...) -{ - FILE *f = fopen(filename, "wb"); - if (f) { - va_list v; - va_start(v, fmt); - writefv(f, fmt, v); - va_end(v); - write_pixels(f,rgb_dir,vdir,x,y,comp,data,alpha,pad); - fclose(f); - } - return f != NULL; -} - -int stbi_write_bmp(char const *filename, int x, int y, int comp, void *data) -{ - int pad = (-x*3) & 3; - return outfile(filename,-1,-1,x,y,comp,data,0,pad, - "11 4 22 4" "4 44 22 444444", - 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header - 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header -} - -int stbi_write_tga(char const *filename, int x, int y, int comp, void *data) -{ - int has_alpha = !(comp & 1); - return outfile(filename, -1,-1, x, y, comp, data, has_alpha, 0, - "111 221 2222 11", 0,0,2, 0,0,0, 0,0,x,y, 24+8*has_alpha, 8*has_alpha); -} - -// any other image formats that do interleaved rgb data? -// PNG: requires adler32,crc32 -- significant amount of code -// PSD: no, channels output separately -// TIFF: no, stripwise-interleaved... i think - -#endif // STBI_NO_WRITE - -// add in my DDS loading support -#ifndef STBI_NO_DDS -#include "stbi_DDS_aug_c.h" -#endif diff --git a/src/soil/stb_image_aug.h b/src/soil/stb_image_aug.h deleted file mode 100755 index 52ea75ca..00000000 --- a/src/soil/stb_image_aug.h +++ /dev/null @@ -1,354 +0,0 @@ -/* stbi-1.16 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c - when you control the images you're loading - - QUICK NOTES: - Primarily of interest to game developers and other people who can - avoid problematic images and only need the trivial interface - - JPEG baseline (no JPEG progressive, no oddball channel decimations) - PNG non-interlaced - BMP non-1bpp, non-RLE - TGA (not sure what subset, if a subset) - PSD (composited view only, no extra channels) - HDR (radiance rgbE format) - writes BMP,TGA (define STBI_NO_WRITE to remove code) - decoded from memory or through stdio FILE (define STBI_NO_STDIO to remove code) - supports installable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD) - - TODO: - stbi_info_* - - history: - 1.16 major bugfix - convert_format converted one too many pixels - 1.15 initialize some fields for thread safety - 1.14 fix threadsafe conversion bug; header-file-only version (#define STBI_HEADER_FILE_ONLY before including) - 1.13 threadsafe - 1.12 const qualifiers in the API - 1.11 Support installable IDCT, colorspace conversion routines - 1.10 Fixes for 64-bit (don't use "unsigned long") - optimized upsampling by Fabian "ryg" Giesen - 1.09 Fix format-conversion for PSD code (bad global variables!) - 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz - 1.07 attempt to fix C++ warning/errors again - 1.06 attempt to fix C++ warning/errors again - 1.05 fix TGA loading to return correct *comp and use good luminance calc - 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free - 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR - 1.02 support for (subset of) HDR files, float interface for preferred access to them - 1.01 fix bug: possible bug in handling right-side up bmps... not sure - fix bug: the stbi_bmp_load() and stbi_tga_load() functions didn't work at all - 1.00 interface to zlib that skips zlib header - 0.99 correct handling of alpha in palette - 0.98 TGA loader by lonesock; dynamically add loaders (untested) - 0.97 jpeg errors on too large a file; also catch another malloc failure - 0.96 fix detection of invalid v value - particleman@mollyrocket forum - 0.95 during header scan, seek to markers in case of padding - 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same - 0.93 handle jpegtran output; verbose errors - 0.92 read 4,8,16,24,32-bit BMP files of several formats - 0.91 output 24-bit Windows 3.0 BMP files - 0.90 fix a few more warnings; bump version number to approach 1.0 - 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd - 0.60 fix compiling as c++ - 0.59 fix warnings: merge Dave Moore's -Wall fixes - 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian - 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less - than 16 available - 0.56 fix bug: zlib uncompressed mode len vs. nlen - 0.55 fix bug: restart_interval not initialized to 0 - 0.54 allow NULL for 'int *comp' - 0.53 fix bug in png 3->4; speedup png decoding - 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments - 0.51 obey req_comp requests, 1-component jpegs return as 1-component, - on 'test' only check type, not whether we support this variant -*/ - -#ifndef HEADER_STB_IMAGE_AUGMENTED -#define HEADER_STB_IMAGE_AUGMENTED - -//// begin header file //////////////////////////////////////////////////// -// -// Limitations: -// - no progressive/interlaced support (jpeg, png) -// - 8-bit samples only (jpeg, png) -// - not threadsafe -// - channel subsampling of at most 2 in each dimension (jpeg) -// - no delayed line count (jpeg) -- IJG doesn't support either -// -// Basic usage (see HDR discussion below): -// int x,y,n; -// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); -// // ... process data if not NULL ... -// // ... x = width, y = height, n = # 8-bit components per pixel ... -// // ... replace '0' with '1'..'4' to force that many components per pixel -// stbi_image_free(data) -// -// Standard parameters: -// int *x -- outputs image width in pixels -// int *y -- outputs image height in pixels -// int *comp -- outputs # of image components in image file -// int req_comp -- if non-zero, # of image components requested in result -// -// The return value from an image loader is an 'unsigned char *' which points -// to the pixel data. The pixel data consists of *y scanlines of *x pixels, -// with each pixel consisting of N interleaved 8-bit components; the first -// pixel pointed to is top-left-most in the image. There is no padding between -// image scanlines or between pixels, regardless of format. The number of -// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise. -// If req_comp is non-zero, *comp has the number of components that _would_ -// have been output otherwise. E.g. if you set req_comp to 4, you will always -// get RGBA output, but you can check *comp to easily see if it's opaque. -// -// An output image with N components has the following components interleaved -// in this order in each pixel: -// -// N=#comp components -// 1 grey -// 2 grey, alpha -// 3 red, green, blue -// 4 red, green, blue, alpha -// -// If image loading fails for any reason, the return value will be NULL, -// and *x, *y, *comp will be unchanged. The function stbi_failure_reason() -// can be queried for an extremely brief, end-user unfriendly explanation -// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid -// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly -// more user-friendly ones. -// -// Paletted PNG and BMP images are automatically depalettized. -// -// -// =========================================================================== -// -// HDR image support (disable by defining STBI_NO_HDR) -// -// stb_image now supports loading HDR images in general, and currently -// the Radiance .HDR file format, although the support is provided -// generically. You can still load any file through the existing interface; -// if you attempt to load an HDR file, it will be automatically remapped to -// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; -// both of these constants can be reconfigured through this interface: -// -// stbi_hdr_to_ldr_gamma(2.2f); -// stbi_hdr_to_ldr_scale(1.0f); -// -// (note, do not use _inverse_ constants; stbi_image will invert them -// appropriately). -// -// Additionally, there is a new, parallel interface for loading files as -// (linear) floats to preserve the full dynamic range: -// -// float *data = stbi_loadf(filename, &x, &y, &n, 0); -// -// If you load LDR images through this interface, those images will -// be promoted to floating point values, run through the inverse of -// constants corresponding to the above: -// -// stbi_ldr_to_hdr_scale(1.0f); -// stbi_ldr_to_hdr_gamma(2.2f); -// -// Finally, given a filename (or an open file or memory block--see header -// file for details) containing image data, you can query for the "most -// appropriate" interface to use (that is, whether the image is HDR or -// not), using: -// -// stbi_is_hdr(char *filename); - -#ifndef STBI_NO_STDIO -#include -#endif - -#define STBI_VERSION 1 - -enum -{ - STBI_default = 0, // only used for req_comp - - STBI_grey = 1, - STBI_grey_alpha = 2, - STBI_rgb = 3, - STBI_rgb_alpha = 4, -}; - -typedef unsigned char stbi_uc; - -#ifdef __cplusplus -extern "C" { -#endif - -// WRITING API - -#if !defined(STBI_NO_WRITE) && !defined(STBI_NO_STDIO) -// write a BMP/TGA file given tightly packed 'comp' channels (no padding, nor bmp-stride-padding) -// (you must include the appropriate extension in the filename). -// returns TRUE on success, FALSE if couldn't open file, error writing file -extern int stbi_write_bmp (char const *filename, int x, int y, int comp, void *data); -extern int stbi_write_tga (char const *filename, int x, int y, int comp, void *data); -#endif - -// PRIMARY API - works on images of any type - -// load image by filename, open file, or memory buffer -#ifndef STBI_NO_STDIO -extern stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif -extern stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -// for stbi_load_from_file, file pointer is left pointing immediately after image - -#ifndef STBI_NO_HDR -#ifndef STBI_NO_STDIO -extern float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp); -extern float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif -extern float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); - -extern void stbi_hdr_to_ldr_gamma(float gamma); -extern void stbi_hdr_to_ldr_scale(float scale); - -extern void stbi_ldr_to_hdr_gamma(float gamma); -extern void stbi_ldr_to_hdr_scale(float scale); - -#endif // STBI_NO_HDR - -// get a VERY brief reason for failure -// NOT THREADSAFE -extern char *stbi_failure_reason (void); - -// free the loaded image -- this is just free() -extern void stbi_image_free (void *retval_from_stbi_load); - -// get image dimensions & components without fully decoding -extern int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); -extern int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); -#ifndef STBI_NO_STDIO -extern int stbi_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_is_hdr (char const *filename); -extern int stbi_is_hdr_from_file(FILE *f); -#endif - -// ZLIB client - used by PNG, available for other purposes - -extern char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); -extern char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); -extern int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - -extern char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); -extern int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - -// TYPE-SPECIFIC ACCESS - -// is it a jpeg? -extern int stbi_jpeg_test_memory (stbi_uc const *buffer, int len); -extern stbi_uc *stbi_jpeg_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -extern stbi_uc *stbi_jpeg_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern int stbi_jpeg_test_file (FILE *f); -extern stbi_uc *stbi_jpeg_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); - -extern int stbi_jpeg_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_jpeg_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif - -// is it a png? -extern int stbi_png_test_memory (stbi_uc const *buffer, int len); -extern stbi_uc *stbi_png_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -extern stbi_uc *stbi_png_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_png_test_file (FILE *f); -extern stbi_uc *stbi_png_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif - -// is it a bmp? -extern int stbi_bmp_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_bmp_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_bmp_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_bmp_test_file (FILE *f); -extern stbi_uc *stbi_bmp_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a tga? -extern int stbi_tga_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_tga_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_tga_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_tga_test_file (FILE *f); -extern stbi_uc *stbi_tga_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a psd? -extern int stbi_psd_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_psd_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_psd_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_psd_test_file (FILE *f); -extern stbi_uc *stbi_psd_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it an hdr? -extern int stbi_hdr_test_memory (stbi_uc const *buffer, int len); - -extern float * stbi_hdr_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern float * stbi_hdr_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_hdr_load_rgbe (char const *filename, int *x, int *y, int *comp, int req_comp); -extern float * stbi_hdr_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_hdr_test_file (FILE *f); -extern float * stbi_hdr_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_hdr_load_rgbe_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// define new loaders -typedef struct -{ - int (*test_memory)(stbi_uc const *buffer, int len); - stbi_uc * (*load_from_memory)(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); - #ifndef STBI_NO_STDIO - int (*test_file)(FILE *f); - stbi_uc * (*load_from_file)(FILE *f, int *x, int *y, int *comp, int req_comp); - #endif -} stbi_loader; - -// register a loader by filling out the above structure (you must defined ALL functions) -// returns 1 if added or already added, 0 if not added (too many loaders) -// NOT THREADSAFE -extern int stbi_register_loader(stbi_loader *loader); - -// define faster low-level operations (typically SIMD support) -#if STBI_SIMD -typedef void (*stbi_idct_8x8)(uint8 *out, int out_stride, short data[64], unsigned short *dequantize); -// compute an integer IDCT on "input" -// input[x] = data[x] * dequantize[x] -// write results to 'out': 64 samples, each run of 8 spaced by 'out_stride' -// CLAMP results to 0..255 -typedef void (*stbi_YCbCr_to_RGB_run)(uint8 *output, uint8 const *y, uint8 const *cb, uint8 const *cr, int count, int step); -// compute a conversion from YCbCr to RGB -// 'count' pixels -// write pixels to 'output'; each pixel is 'step' bytes (either 3 or 4; if 4, write '255' as 4th), order R,G,B -// y: Y input channel -// cb: Cb input channel; scale/biased to be 0..255 -// cr: Cr input channel; scale/biased to be 0..255 - -extern void stbi_install_idct(stbi_idct_8x8 func); -extern void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func); -#endif // STBI_SIMD - -#ifdef __cplusplus -} -#endif - -// -// -//// end header file ///////////////////////////////////////////////////// -#endif // STBI_INCLUDE_STB_IMAGE_H diff --git a/src/soil/stbi_DDS_aug.h b/src/soil/stbi_DDS_aug.h deleted file mode 100755 index 7317d63b..00000000 --- a/src/soil/stbi_DDS_aug.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - adding DDS loading support to stbi -*/ - -#ifndef HEADER_STB_IMAGE_DDS_AUGMENTATION -#define HEADER_STB_IMAGE_DDS_AUGMENTATION - -// is it a DDS file? -extern int stbi_dds_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_dds_load (char *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_dds_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_dds_test_file (FILE *f); -extern stbi_uc *stbi_dds_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// -// -//// end header file ///////////////////////////////////////////////////// -#endif // HEADER_STB_IMAGE_DDS_AUGMENTATION diff --git a/src/soil/stbi_DDS_aug_c.h b/src/soil/stbi_DDS_aug_c.h deleted file mode 100755 index 683d1cf0..00000000 --- a/src/soil/stbi_DDS_aug_c.h +++ /dev/null @@ -1,511 +0,0 @@ - -/// DDS file support, does decoding, _not_ direct uploading -/// (use SOIL for that ;-) - -/// A bunch of DirectDraw Surface structures and flags -typedef struct { - unsigned int dwMagic; - unsigned int dwSize; - unsigned int dwFlags; - unsigned int dwHeight; - unsigned int dwWidth; - unsigned int dwPitchOrLinearSize; - unsigned int dwDepth; - unsigned int dwMipMapCount; - unsigned int dwReserved1[ 11 ]; - - // DDPIXELFORMAT - struct { - unsigned int dwSize; - unsigned int dwFlags; - unsigned int dwFourCC; - unsigned int dwRGBBitCount; - unsigned int dwRBitMask; - unsigned int dwGBitMask; - unsigned int dwBBitMask; - unsigned int dwAlphaBitMask; - } sPixelFormat; - - // DDCAPS2 - struct { - unsigned int dwCaps1; - unsigned int dwCaps2; - unsigned int dwDDSX; - unsigned int dwReserved; - } sCaps; - unsigned int dwReserved2; -} DDS_header ; - -// the following constants were copied directly off the MSDN website - -// The dwFlags member of the original DDSURFACEDESC2 structure -// can be set to one or more of the following values. -#define DDSD_CAPS 0x00000001 -#define DDSD_HEIGHT 0x00000002 -#define DDSD_WIDTH 0x00000004 -#define DDSD_PITCH 0x00000008 -#define DDSD_PIXELFORMAT 0x00001000 -#define DDSD_MIPMAPCOUNT 0x00020000 -#define DDSD_LINEARSIZE 0x00080000 -#define DDSD_DEPTH 0x00800000 - -// DirectDraw Pixel Format -#define DDPF_ALPHAPIXELS 0x00000001 -#define DDPF_FOURCC 0x00000004 -#define DDPF_RGB 0x00000040 - -// The dwCaps1 member of the DDSCAPS2 structure can be -// set to one or more of the following values. -#define DDSCAPS_COMPLEX 0x00000008 -#define DDSCAPS_TEXTURE 0x00001000 -#define DDSCAPS_MIPMAP 0x00400000 - -// The dwCaps2 member of the DDSCAPS2 structure can be -// set to one or more of the following values. -#define DDSCAPS2_CUBEMAP 0x00000200 -#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400 -#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800 -#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000 -#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000 -#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000 -#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000 -#define DDSCAPS2_VOLUME 0x00200000 - -static int dds_test(stbi *s) -{ - // check the magic number - if (get8(s) != 'D') return 0; - if (get8(s) != 'D') return 0; - if (get8(s) != 'S') return 0; - if (get8(s) != ' ') return 0; - // check header size - if (get32le(s) != 124) return 0; - return 1; -} -#ifndef STBI_NO_STDIO -int stbi_dds_test_file (FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s,f); - r = dds_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_dds_test_memory (stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s,buffer, len); - return dds_test(&s); -} - -// helper functions -int stbi_convert_bit_range( int c, int from_bits, int to_bits ) -{ - int b = (1 << (from_bits - 1)) + c * ((1 << to_bits) - 1); - return (b + (b >> from_bits)) >> from_bits; -} -void stbi_rgb_888_from_565( unsigned int c, int *r, int *g, int *b ) -{ - *r = stbi_convert_bit_range( (c >> 11) & 31, 5, 8 ); - *g = stbi_convert_bit_range( (c >> 05) & 63, 6, 8 ); - *b = stbi_convert_bit_range( (c >> 00) & 31, 5, 8 ); -} -void stbi_decode_DXT1_block( - unsigned char uncompressed[16*4], - unsigned char compressed[8] ) -{ - int next_bit = 4*8; - int i, r, g, b; - int c0, c1; - unsigned char decode_colors[4*4]; - // find the 2 primary colors - c0 = compressed[0] + (compressed[1] << 8); - c1 = compressed[2] + (compressed[3] << 8); - stbi_rgb_888_from_565( c0, &r, &g, &b ); - decode_colors[0] = r; - decode_colors[1] = g; - decode_colors[2] = b; - decode_colors[3] = 255; - stbi_rgb_888_from_565( c1, &r, &g, &b ); - decode_colors[4] = r; - decode_colors[5] = g; - decode_colors[6] = b; - decode_colors[7] = 255; - if( c0 > c1 ) - { - // no alpha, 2 interpolated colors - decode_colors[8] = (2*decode_colors[0] + decode_colors[4]) / 3; - decode_colors[9] = (2*decode_colors[1] + decode_colors[5]) / 3; - decode_colors[10] = (2*decode_colors[2] + decode_colors[6]) / 3; - decode_colors[11] = 255; - decode_colors[12] = (decode_colors[0] + 2*decode_colors[4]) / 3; - decode_colors[13] = (decode_colors[1] + 2*decode_colors[5]) / 3; - decode_colors[14] = (decode_colors[2] + 2*decode_colors[6]) / 3; - decode_colors[15] = 255; - } else - { - // 1 interpolated color, alpha - decode_colors[8] = (decode_colors[0] + decode_colors[4]) / 2; - decode_colors[9] = (decode_colors[1] + decode_colors[5]) / 2; - decode_colors[10] = (decode_colors[2] + decode_colors[6]) / 2; - decode_colors[11] = 255; - decode_colors[12] = 0; - decode_colors[13] = 0; - decode_colors[14] = 0; - decode_colors[15] = 0; - } - // decode the block - for( i = 0; i < 16*4; i += 4 ) - { - int idx = ((compressed[next_bit>>3] >> (next_bit & 7)) & 3) * 4; - next_bit += 2; - uncompressed[i+0] = decode_colors[idx+0]; - uncompressed[i+1] = decode_colors[idx+1]; - uncompressed[i+2] = decode_colors[idx+2]; - uncompressed[i+3] = decode_colors[idx+3]; - } - // done -} -void stbi_decode_DXT23_alpha_block( - unsigned char uncompressed[16*4], - unsigned char compressed[8] ) -{ - int i, next_bit = 0; - // each alpha value gets 4 bits - for( i = 3; i < 16*4; i += 4 ) - { - uncompressed[i] = stbi_convert_bit_range( - (compressed[next_bit>>3] >> (next_bit&7)) & 15, - 4, 8 ); - next_bit += 4; - } -} -void stbi_decode_DXT45_alpha_block( - unsigned char uncompressed[16*4], - unsigned char compressed[8] ) -{ - int i, next_bit = 8*2; - unsigned char decode_alpha[8]; - // each alpha value gets 3 bits, and the 1st 2 bytes are the range - decode_alpha[0] = compressed[0]; - decode_alpha[1] = compressed[1]; - if( decode_alpha[0] > decode_alpha[1] ) - { - // 6 step intermediate - decode_alpha[2] = (6*decode_alpha[0] + 1*decode_alpha[1]) / 7; - decode_alpha[3] = (5*decode_alpha[0] + 2*decode_alpha[1]) / 7; - decode_alpha[4] = (4*decode_alpha[0] + 3*decode_alpha[1]) / 7; - decode_alpha[5] = (3*decode_alpha[0] + 4*decode_alpha[1]) / 7; - decode_alpha[6] = (2*decode_alpha[0] + 5*decode_alpha[1]) / 7; - decode_alpha[7] = (1*decode_alpha[0] + 6*decode_alpha[1]) / 7; - } else - { - // 4 step intermediate, pluss full and none - decode_alpha[2] = (4*decode_alpha[0] + 1*decode_alpha[1]) / 5; - decode_alpha[3] = (3*decode_alpha[0] + 2*decode_alpha[1]) / 5; - decode_alpha[4] = (2*decode_alpha[0] + 3*decode_alpha[1]) / 5; - decode_alpha[5] = (1*decode_alpha[0] + 4*decode_alpha[1]) / 5; - decode_alpha[6] = 0; - decode_alpha[7] = 255; - } - for( i = 3; i < 16*4; i += 4 ) - { - int idx = 0, bit; - bit = (compressed[next_bit>>3] >> (next_bit&7)) & 1; - idx += bit << 0; - ++next_bit; - bit = (compressed[next_bit>>3] >> (next_bit&7)) & 1; - idx += bit << 1; - ++next_bit; - bit = (compressed[next_bit>>3] >> (next_bit&7)) & 1; - idx += bit << 2; - ++next_bit; - uncompressed[i] = decode_alpha[idx & 7]; - } - // done -} -void stbi_decode_DXT_color_block( - unsigned char uncompressed[16*4], - unsigned char compressed[8] ) -{ - int next_bit = 4*8; - int i, r, g, b; - int c0, c1; - unsigned char decode_colors[4*3]; - // find the 2 primary colors - c0 = compressed[0] + (compressed[1] << 8); - c1 = compressed[2] + (compressed[3] << 8); - stbi_rgb_888_from_565( c0, &r, &g, &b ); - decode_colors[0] = r; - decode_colors[1] = g; - decode_colors[2] = b; - stbi_rgb_888_from_565( c1, &r, &g, &b ); - decode_colors[3] = r; - decode_colors[4] = g; - decode_colors[5] = b; - // Like DXT1, but no choicees: - // no alpha, 2 interpolated colors - decode_colors[6] = (2*decode_colors[0] + decode_colors[3]) / 3; - decode_colors[7] = (2*decode_colors[1] + decode_colors[4]) / 3; - decode_colors[8] = (2*decode_colors[2] + decode_colors[5]) / 3; - decode_colors[9] = (decode_colors[0] + 2*decode_colors[3]) / 3; - decode_colors[10] = (decode_colors[1] + 2*decode_colors[4]) / 3; - decode_colors[11] = (decode_colors[2] + 2*decode_colors[5]) / 3; - // decode the block - for( i = 0; i < 16*4; i += 4 ) - { - int idx = ((compressed[next_bit>>3] >> (next_bit & 7)) & 3) * 3; - next_bit += 2; - uncompressed[i+0] = decode_colors[idx+0]; - uncompressed[i+1] = decode_colors[idx+1]; - uncompressed[i+2] = decode_colors[idx+2]; - } - // done -} -static stbi_uc *dds_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - // all variables go up front - stbi_uc *dds_data = NULL; - stbi_uc block[16*4]; - stbi_uc compressed[8]; - int flags, DXT_family; - int has_alpha, has_mipmap; - int is_compressed, cubemap_faces; - int block_pitch, num_blocks; - DDS_header header; - int i, sz, cf; - // load the header - if( sizeof( DDS_header ) != 128 ) - { - return NULL; - } - getn( s, (stbi_uc*)(&header), 128 ); - // and do some checking - if( header.dwMagic != (('D' << 0) | ('D' << 8) | ('S' << 16) | (' ' << 24)) ) return NULL; - if( header.dwSize != 124 ) return NULL; - flags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; - if( (header.dwFlags & flags) != flags ) return NULL; - /* According to the MSDN spec, the dwFlags should contain - DDSD_LINEARSIZE if it's compressed, or DDSD_PITCH if - uncompressed. Some DDS writers do not conform to the - spec, so I need to make my reader more tolerant */ - if( header.sPixelFormat.dwSize != 32 ) return NULL; - flags = DDPF_FOURCC | DDPF_RGB; - if( (header.sPixelFormat.dwFlags & flags) == 0 ) return NULL; - if( (header.sCaps.dwCaps1 & DDSCAPS_TEXTURE) == 0 ) return NULL; - // get the image data - s->img_x = header.dwWidth; - s->img_y = header.dwHeight; - s->img_n = 4; - is_compressed = (header.sPixelFormat.dwFlags & DDPF_FOURCC) / DDPF_FOURCC; - has_alpha = (header.sPixelFormat.dwFlags & DDPF_ALPHAPIXELS) / DDPF_ALPHAPIXELS; - has_mipmap = (header.sCaps.dwCaps1 & DDSCAPS_MIPMAP) && (header.dwMipMapCount > 1); - cubemap_faces = (header.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP) / DDSCAPS2_CUBEMAP; - /* I need cubemaps to have square faces */ - cubemap_faces &= (s->img_x == s->img_y); - cubemap_faces *= 5; - cubemap_faces += 1; - block_pitch = (s->img_x+3) >> 2; - num_blocks = block_pitch * ((s->img_y+3) >> 2); - /* let the user know what's going on */ - *x = s->img_x; - *y = s->img_y; - *comp = s->img_n; - /* is this uncompressed? */ - if( is_compressed ) - { - /* compressed */ - // note: header.sPixelFormat.dwFourCC is something like (('D'<<0)|('X'<<8)|('T'<<16)|('1'<<24)) - DXT_family = 1 + (header.sPixelFormat.dwFourCC >> 24) - '1'; - if( (DXT_family < 1) || (DXT_family > 5) ) return NULL; - /* check the expected size...oops, nevermind... - those non-compliant writers leave - dwPitchOrLinearSize == 0 */ - // passed all the tests, get the RAM for decoding - sz = (s->img_x)*(s->img_y)*4*cubemap_faces; - dds_data = (unsigned char*)malloc( sz ); - /* do this once for each face */ - for( cf = 0; cf < cubemap_faces; ++ cf ) - { - // now read and decode all the blocks - for( i = 0; i < num_blocks; ++i ) - { - // where are we? - int bx, by, bw=4, bh=4; - int ref_x = 4 * (i % block_pitch); - int ref_y = 4 * (i / block_pitch); - // get the next block's worth of compressed data, and decompress it - if( DXT_family == 1 ) - { - // DXT1 - getn( s, compressed, 8 ); - stbi_decode_DXT1_block( block, compressed ); - } else if( DXT_family < 4 ) - { - // DXT2/3 - getn( s, compressed, 8 ); - stbi_decode_DXT23_alpha_block ( block, compressed ); - getn( s, compressed, 8 ); - stbi_decode_DXT_color_block ( block, compressed ); - } else - { - // DXT4/5 - getn( s, compressed, 8 ); - stbi_decode_DXT45_alpha_block ( block, compressed ); - getn( s, compressed, 8 ); - stbi_decode_DXT_color_block ( block, compressed ); - } - // is this a partial block? - if( ref_x + 4 > s->img_x ) - { - bw = s->img_x - ref_x; - } - if( ref_y + 4 > s->img_y ) - { - bh = s->img_y - ref_y; - } - // now drop our decompressed data into the buffer - for( by = 0; by < bh; ++by ) - { - int idx = 4*((ref_y+by+cf*s->img_x)*s->img_x + ref_x); - for( bx = 0; bx < bw*4; ++bx ) - { - - dds_data[idx+bx] = block[by*16+bx]; - } - } - } - /* done reading and decoding the main image... - skip MIPmaps if present */ - if( has_mipmap ) - { - int block_size = 16; - if( DXT_family == 1 ) - { - block_size = 8; - } - for( i = 1; i < header.dwMipMapCount; ++i ) - { - int mx = s->img_x >> (i + 2); - int my = s->img_y >> (i + 2); - if( mx < 1 ) - { - mx = 1; - } - if( my < 1 ) - { - my = 1; - } - skip( s, mx*my*block_size ); - } - } - }/* per cubemap face */ - } else - { - /* uncompressed */ - DXT_family = 0; - s->img_n = 3; - if( has_alpha ) - { - s->img_n = 4; - } - *comp = s->img_n; - sz = s->img_x*s->img_y*s->img_n*cubemap_faces; - dds_data = (unsigned char*)malloc( sz ); - /* do this once for each face */ - for( cf = 0; cf < cubemap_faces; ++ cf ) - { - /* read the main image for this face */ - getn( s, &dds_data[cf*s->img_x*s->img_y*s->img_n], s->img_x*s->img_y*s->img_n ); - /* done reading and decoding the main image... - skip MIPmaps if present */ - if( has_mipmap ) - { - for( i = 1; i < header.dwMipMapCount; ++i ) - { - int mx = s->img_x >> i; - int my = s->img_y >> i; - if( mx < 1 ) - { - mx = 1; - } - if( my < 1 ) - { - my = 1; - } - skip( s, mx*my*s->img_n ); - } - } - } - /* data was BGR, I need it RGB */ - for( i = 0; i < sz; i += s->img_n ) - { - unsigned char temp = dds_data[i]; - dds_data[i] = dds_data[i+2]; - dds_data[i+2] = temp; - } - } - /* finished decompressing into RGBA, - adjust the y size if we have a cubemap - note: sz is already up to date */ - s->img_y *= cubemap_faces; - *y = s->img_y; - // did the user want something else, or - // see if all the alpha values are 255 (i.e. no transparency) - has_alpha = 0; - if( s->img_n == 4) - { - for( i = 3; (i < sz) && (has_alpha == 0); i += 4 ) - { - has_alpha |= (dds_data[i] < 255); - } - } - if( (req_comp <= 4) && (req_comp >= 1) ) - { - // user has some requirements, meet them - if( req_comp != s->img_n ) - { - dds_data = convert_format( dds_data, s->img_n, req_comp, s->img_x, s->img_y ); - *comp = s->img_n; - } - } else - { - // user had no requirements, only drop to RGB is no alpha - if( (has_alpha == 0) && (s->img_n == 4) ) - { - dds_data = convert_format( dds_data, 4, 3, s->img_x, s->img_y ); - *comp = 3; - } - } - // OK, done - return dds_data; -} - -#ifndef STBI_NO_STDIO -stbi_uc *stbi_dds_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s,f); - return dds_load(&s,x,y,comp,req_comp); -} - -stbi_uc *stbi_dds_load (char *filename, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_dds_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return data; -} -#endif - -stbi_uc *stbi_dds_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s,buffer, len); - return dds_load(&s,x,y,comp,req_comp); -} diff --git a/tests/ftgl/SourceCodePro-Regular.ttf b/tests/ftgl/SourceCodePro-Regular.ttf deleted file mode 100644 index b2cff928..00000000 Binary files a/tests/ftgl/SourceCodePro-Regular.ttf and /dev/null differ diff --git a/tests/ftgl/ftgl_test-basics.adb b/tests/ftgl/ftgl_test-basics.adb deleted file mode 100644 index e28f0822..00000000 --- a/tests/ftgl/ftgl_test-basics.adb +++ /dev/null @@ -1,136 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -with Ada.Command_Line; -with Ada.Text_IO; - -with GL.Buffers; -with GL.Fixed.Matrix; -with GL.Immediate; -with GL.Raster; -with GL.Toggles; -with GL.Types; - -with FTGL.Fonts; - -with GL_Test.Display_Backend; - -procedure FTGL_Test.Basics is - use GL.Fixed.Matrix; - use GL.Types; - use GL.Types.Doubles; - - Bitmap_Font : FTGL.Fonts.Bitmap_Font; - Pixmap_Font : FTGL.Fonts.Pixmap_Font; - - Polygon_Font : FTGL.Fonts.Polygon_Font; - Outline_Font : FTGL.Fonts.Outline_Font; - Extrude_Font : FTGL.Fonts.Extrude_Font; - - Texture_Font : FTGL.Fonts.Texture_Font; - Buffer_Font : FTGL.Fonts.Buffer_Font; -begin - if Ada.Command_Line.Argument_Count /= 1 then - Ada.Text_IO.Put_Line ("Please give the path to a font file as argument."); - Ada.Command_Line.Set_Exit_Status (1); - return; - end if; - - GL_Test.Display_Backend.Init; - GL_Test.Display_Backend.Open_Window (800, 600, 8); - - GL.Toggles.Enable (GL.Toggles.Depth_Test); - - declare - Test_Font : constant String := Ada.Command_Line.Argument (1); - - procedure Setup_Font (Object : in out FTGL.Fonts.Font'Class) is - begin - Object.Load (Test_Font); - Object.Set_Font_Face_Size (72); - end Setup_Font; - begin - Setup_Font (Bitmap_Font); - Setup_Font (Pixmap_Font); - Setup_Font (Polygon_Font); - Setup_Font (Outline_Font); - Setup_Font (Extrude_Font); - Setup_Font (Texture_Font); - Setup_Font (Buffer_Font); - exception - when FTGL.FTGL_Error => - Ada.Text_IO.Put_Line ("Could not load font file " & Test_Font); - Ada.Command_Line.Set_Exit_Status (1); - return; - end; - - declare - List : constant FTGL.Fonts.Charset_List := Bitmap_Font.Get_Char_Map_List; - begin - Ada.Text_IO.Put_Line ("Charsets:"); - for I in List'Range loop - Ada.Text_IO.Put_Line (List (I)'Img); - end loop; - end; - - Extrude_Font.Set_Font_Depth (0.05); - - Projection.Load_Identity; - Projection.Apply_Frustum (0.0, 800.0, 0.0, 600.0, 1.0, 10.0); - - while GL_Test.Display_Backend.Window_Opened loop - GL.Buffers.Clear ((others => True)); - - GL.Immediate.Set_Color ((1.0, 1.0, 1.0, 1.0)); - - GL.Raster.Set_Pos (Vector3'(0.0, Double (-Bitmap_Font.Descender), -1.5)); - - Bitmap_Font.Render ("Bitmap font", (Front => True, others => False)); - - GL.Raster.Set_Pos - (Vector3'(0.0, Double (-Pixmap_Font.Descender + - Bitmap_Font.Line_Height), -1.5)); - - Pixmap_Font.Render ("Pixmap font", (Front => True, others => False)); - - Modelview.Push; - - Modelview.Apply_Rotation (0.02, (0.0, 1.0, 0.0)); - - Modelview.Apply_Translation (0.0, Double (Bitmap_Font.Line_Height * 2.0 + - Pixmap_Font.Line_Height - - Polygon_Font.Descender), -1.5); - - Polygon_Font.Render ("Polygon font", (Front => True, others => False)); - - Modelview.Apply_Translation (0.0, Double (Polygon_Font.Line_Height), 0.0); - - Outline_Font.Render ("Outline font", (Front => True, others => False)); - - Modelview.Apply_Translation (0.0, Double (Outline_Font.Line_Height), 0.0); - - Extrude_Font.Render ("Extrude font", (Front => True, others => False)); - - GL.Immediate.Set_Color ((0.5, 0.5, 0.5, 1.0)); - - Extrude_Font.Render ("Extrude font", (Side => True, others => False)); - - GL.Immediate.Set_Color ((1.0, 1.0, 1.0, 1.0)); - - Modelview.Apply_Translation (0.0, Double (Extrude_Font.Line_Height), 0.0); - - Texture_Font.Render ("Texture font", (Front => True, others => False)); - - Modelview.Apply_Translation (0.0, Double (Texture_Font.Line_Height), 0.0); - - Buffer_Font.Render ("Buffer font", (Front => True, others => False)); - - Modelview.Pop; - - GL_Test.Display_Backend.Swap_Buffers; - - GL_Test.Display_Backend.Poll_Events; - end loop; - - GL_Test.Display_Backend.Shutdown; -end FTGL_Test.Basics; diff --git a/tests/ftgl/ftgl_test.ads b/tests/ftgl/ftgl_test.ads deleted file mode 100644 index d4d6bda8..00000000 --- a/tests/ftgl/ftgl_test.ads +++ /dev/null @@ -1,6 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -package FTGL_Test is - pragma Pure; -end FTGL_Test; diff --git a/tests/soil/ada2012png-black.png b/tests/images/ada2012-black.png similarity index 100% rename from tests/soil/ada2012png-black.png rename to tests/images/ada2012-black.png diff --git a/tests/images/ada2012-color.jpg b/tests/images/ada2012-color.jpg new file mode 100644 index 00000000..ee8e65e0 Binary files /dev/null and b/tests/images/ada2012-color.jpg differ diff --git a/tests/soil/soil_test-basic.adb b/tests/images/images_test_jpg.adb similarity index 86% rename from tests/soil/soil_test-basic.adb rename to tests/images/images_test_jpg.adb index bab1bdd4..66d77960 100644 --- a/tests/soil/soil_test-basic.adb +++ b/tests/images/images_test_jpg.adb @@ -1,20 +1,19 @@ --- part of OpenGLAda, (c) 2017 Felix Krause +-- part of OpenGLAda, (c) 2020 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with GL.Buffers; with GL.Types.Colors; with GL.Fixed.Matrix; +with GL.Images; with GL.Immediate; with GL.Objects.Textures.Targets; +with GL.Pixels; with GL.Toggles; with GL.Types; -with SOIL; - with GL_Test.Display_Backend; - -procedure SOIL_Test.Basic is +procedure Images_Test_JPG is use GL.Fixed.Matrix; use GL.Types; use GL.Types.Doubles; @@ -23,10 +22,10 @@ procedure SOIL_Test.Basic is begin GL_Test.Display_Backend.Init; GL_Test.Display_Backend.Open_Window (1000, 498); - - SOIL.Load_File_To_Texture ("../tests/soil/ada2012png-black.jpg", Texture, - Flags => (Invert_Y => True, others => False)); - + + GL.Images.Load_File_To_Texture + ("../tests/images/ada2012-color.jpg", Texture, GL.Pixels.RGB); + Projection.Load_Identity; Projection.Apply_Orthogonal (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); @@ -58,4 +57,4 @@ begin end loop; GL_Test.Display_Backend.Shutdown; -end SOIL_Test.Basic; +end Images_Test_JPG; diff --git a/tests/soil/soil_test-image.adb b/tests/images/images_test_png.adb similarity index 72% rename from tests/soil/soil_test-image.adb rename to tests/images/images_test_png.adb index 8cf2082c..afab3800 100644 --- a/tests/soil/soil_test-image.adb +++ b/tests/images/images_test_png.adb @@ -1,48 +1,40 @@ --- part of OpenGLAda, (c) 2017 Felix Krause +-- part of OpenGLAda, (c) 2020 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" -with Ada.Text_IO; - +with GL.Blending; with GL.Buffers; with GL.Types.Colors; with GL.Fixed.Matrix; +with GL.Images; with GL.Immediate; with GL.Objects.Textures.Targets; +with GL.Pixels; with GL.Toggles; with GL.Types; -with SOIL.Images; - with GL_Test.Display_Backend; - -procedure SOIL_Test.Image is +procedure Images_Test_PNG is use GL.Fixed.Matrix; use GL.Types; use GL.Types.Doubles; - use Ada.Text_IO; - Texture : GL.Objects.Textures.Texture; - Image : SOIL.Images.Image; begin GL_Test.Display_Backend.Init; - - Image.Load ("../tests/soil/ada2012png-black.jpg"); - - Put_Line ("Channels: " & Image.Channels'Img); - Put_Line ("Width:" & Image.Width'Img); - Put_Line ("Height:" & Image.Height'Img); - - GL_Test.Display_Backend.Open_Window (Integer (Image.Width / 2), - Integer (Image.Height / 2)); - - Image.To_Texture (Texture, Flags => (Invert_Y => True, others => False)); - + GL_Test.Display_Backend.Open_Window (1000, 498); + + GL.Images.Load_File_To_Texture + ("../tests/images/ada2012-black.png", Texture, GL.Pixels.RGBA); + Projection.Load_Identity; Projection.Apply_Orthogonal (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); GL.Buffers.Set_Color_Clear_Value (Colors.Color'(1.0, 0.0, 0.0, 1.0)); + + GL.Toggles.Enable (GL.Toggles.Blend); + GL.Blending.Set_Blend_Func + (GL.Blending.Src_Alpha, GL.Blending.One_Minus_Src_Alpha); while GL_Test.Display_Backend.Window_Opened loop GL.Buffers.Clear ((others => True)); @@ -62,7 +54,6 @@ begin GL.Immediate.Set_Texture_Coordinates (Vector2'(1.0, 0.0)); Token.Add_Vertex (Vector2'(1.0, -1.0)); end; - GL.Toggles.Disable (GL.Toggles.Texture_2D); GL_Test.Display_Backend.Swap_Buffers; @@ -71,4 +62,4 @@ begin end loop; GL_Test.Display_Backend.Shutdown; -end SOIL_Test.Image; +end Images_Test_PNG; diff --git a/tests/soil/ada2012png-black.jpg b/tests/soil/ada2012png-black.jpg deleted file mode 100644 index 26721daf..00000000 Binary files a/tests/soil/ada2012png-black.jpg and /dev/null differ diff --git a/tests/soil/soil_test.ads b/tests/soil/soil_test.ads deleted file mode 100644 index 8f08f144..00000000 --- a/tests/soil/soil_test.ads +++ /dev/null @@ -1,6 +0,0 @@ --- part of OpenGLAda, (c) 2017 Felix Krause --- released under the terms of the MIT license, see the file "COPYING" - -package SOIL_Test is - pragma Pure; -end SOIL_Test;